Annotation of Amaya/amaya/styleparser.c, revision 1.44
1.1 cvs 1: /*
2: *
3: * (c) COPYRIGHT MIT and INRIA, 1996.
4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
7:
8: /*
9: * Everything directly linked to the CSS syntax should now hopefully
10: * be contained in this module.
11: *
12: * Author: I. Vatton
13: *
14: */
15:
16: /* Included headerfiles */
17: #define THOT_EXPORT extern
18: #include "amaya.h"
19: #include "css.h"
20: #include "undo.h"
1.25 cvs 21: #include "fetchHTMLname.h"
1.1 cvs 22:
23: typedef struct _BackgroundImageCallbackBlock
24: {
25: Element el;
26: PSchema tsch;
27: union
28: {
29: PresentationContextBlock specific;
30: GenericContextBlock generic;
31: } context;
32: }
33: BackgroundImageCallbackBlock, *BackgroundImageCallbackPtr;
34:
35: #include "AHTURLTools_f.h"
36: #include "HTMLpresentation_f.h"
37: #include "HTMLimage_f.h"
38: #include "UIcss_f.h"
39: #include "css_f.h"
1.24 cvs 40: #include "fetchHTMLname_f.h"
1.1 cvs 41: #include "html2thot_f.h"
42: #include "styleparser_f.h"
43:
44: #define MAX_BUFFER_LENGTH 200
45: /*
46: * A PropertyParser is a function used to parse the
47: * description substring associated to a given style attribute
48: * e.g. : "red" for a color attribute or "12pt bold helvetica"
49: * for a font attribute.
50: */
51: #ifdef __STDC__
1.17 cvs 52: typedef STRING (*PropertyParser) (Element element,
1.1 cvs 53: PSchema tsch,
54: PresentationContext context,
55: STRING cssRule,
56: CSSInfoPtr css,
1.14 cvs 57: ThotBool isHTML);
1.1 cvs 58: #else
1.17 cvs 59: typedef STRING (*PropertyParser) ();
1.1 cvs 60: #endif
61:
62: /* Description of the set of CSS properties supported */
63: typedef struct CSSProperty
64: {
65: STRING name;
1.25 cvs 66: PropertyParser parsing_function;
1.1 cvs 67: }
68: CSSProperty;
69:
70: #include "HTMLstyleColor.h"
71:
72: struct unit_def
73: {
74: STRING sign;
75: unsigned int unit;
76: };
77:
78: static struct unit_def CSSUnitNames[] =
79: {
1.18 cvs 80: {TEXT ("pt"), STYLE_UNIT_PT},
81: {TEXT ("pc"), STYLE_UNIT_PC},
82: {TEXT ("in"), STYLE_UNIT_IN},
83: {TEXT ("cm"), STYLE_UNIT_CM},
84: {TEXT ("mm"), STYLE_UNIT_MM},
85: {TEXT ("em"), STYLE_UNIT_EM},
86: {TEXT ("px"), STYLE_UNIT_PX},
87: {TEXT ("ex"), STYLE_UNIT_XHEIGHT},
88: {TEXT ("%"), STYLE_UNIT_PERCENT}
1.1 cvs 89: };
90:
91: #define NB_UNITS (sizeof(CSSUnitNames) / sizeof(struct unit_def))
92:
93: /*----------------------------------------------------------------------
94: ----------------------------------------------------------------------*/
95: #ifdef __STDC__
1.7 cvs 96: static unsigned int hexa_val (CHAR_T c)
1.1 cvs 97: #else
98: static unsigned int hexa_val (c)
1.7 cvs 99: CHAR_T c;
1.1 cvs 100: #endif
101: {
102: if (c >= '0' && c <= '9')
103: return (c - '0');
104: if (c >= 'a' && c <= 'f')
105: return (c - 'a' + 10);
106: if (c >= 'A' && c <= 'F')
107: return (c - 'A' + 10);
108: return (0);
109: }
110:
111: /*----------------------------------------------------------------------
112: SkipWord:
113: ----------------------------------------------------------------------*/
114: #ifdef __STDC__
115: static STRING SkipWord (STRING ptr)
116: #else
117: static STRING SkipWord (ptr)
118: STRING ptr;
119: #endif
120: {
121: while (isalnum(*ptr) || *ptr == '-' || *ptr == '%')
122: ptr++;
123: return (ptr);
124: }
125:
126: /*----------------------------------------------------------------------
1.13 cvs 127: SkipBlanksAndComments:
128: ----------------------------------------------------------------------*/
129: #ifdef __STDC__
1.23 cvs 130: STRING SkipBlanksAndComments (STRING ptr)
1.13 cvs 131: #else
1.23 cvs 132: STRING SkipBlanksAndComments (ptr)
133: STRING ptr;
1.13 cvs 134: #endif
135: {
136: ptr = TtaSkipBlanks (ptr);
137: while (ptr[0] == '/' && ptr[1] == '*')
138: {
139: /* look for the end of the comment */
140: ptr = &ptr[2];
141: while (ptr[0] != EOS && (ptr[0] != '*' || ptr[1] != '/'))
142: ptr++;
143: if (ptr[0] != EOS)
144: ptr = &ptr[2];
145: ptr = TtaSkipBlanks (ptr);
146: }
147: return (ptr);
148: }
149:
150: /*----------------------------------------------------------------------
1.1 cvs 151: SkipQuotedString:
152: ----------------------------------------------------------------------*/
153: #ifdef __STDC__
1.7 cvs 154: static STRING SkipQuotedString (STRING ptr, CHAR_T quote)
1.1 cvs 155: #else
156: static STRING SkipQuotedString (ptr, quote)
157: STRING ptr;
1.7 cvs 158: CHAR_T quote;
1.1 cvs 159: #endif
160: {
1.14 cvs 161: ThotBool stop;
1.1 cvs 162:
163: stop = FALSE;
164: while (!stop)
165: {
166: if (*ptr == quote)
167: {
168: ptr++;
169: stop = TRUE;
170: }
171: else if (*ptr == EOS)
172: stop = TRUE;
173: else if (*ptr == '\\')
174: /* escape character */
175: {
176: ptr++;
177: if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
178: (*ptr >= 'a' && *ptr <= 'f'))
179: {
180: ptr++;
181: if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
182: (*ptr >= 'a' && *ptr <= 'f'))
183: ptr++;
184: }
185: else
186: ptr++;
187: }
188: else
189: ptr++;
190: }
191: return (ptr);
192: }
193:
194: /*----------------------------------------------------------------------
195: SkipProperty:
196: ----------------------------------------------------------------------*/
197: #ifdef __STDC__
198: STRING SkipProperty (STRING ptr)
199: #else
200: STRING SkipProperty (ptr)
201: STRING ptr;
202: #endif
203: {
204: while (*ptr != EOS && *ptr != ';' && *ptr != '}')
205: ptr++;
206: return (ptr);
207: }
208:
209: /*----------------------------------------------------------------------
210: ParseCSSUnit :
211: parse a CSS Unit substring and returns the corresponding
212: value and its unit.
213: ----------------------------------------------------------------------*/
214: #ifdef __STDC__
215: static STRING ParseCSSUnit (STRING cssRule, PresentationValue *pval)
216: #else
217: static STRING ParseCSSUnit (cssRule, pval)
218: STRING cssRule;
219: PresentationValue *pval;
220: #endif
221: {
222: int val = 0;
223: int minus = 0;
224: int valid = 0;
225: int f = 0;
226: unsigned int uni;
1.14 cvs 227: ThotBool real = FALSE;
1.1 cvs 228:
229: pval->typed_data.unit = STYLE_UNIT_REL;
230: pval->typed_data.real = FALSE;
1.13 cvs 231: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 232: if (*cssRule == '-')
233: {
234: minus = 1;
235: cssRule++;
1.13 cvs 236: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 237: }
238:
239: if (*cssRule == '+')
240: {
241: cssRule++;
1.13 cvs 242: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 243: }
244:
245: while ((*cssRule >= '0') && (*cssRule <= '9'))
246: {
247: val *= 10;
248: val += *cssRule - '0';
249: cssRule++;
250: valid = 1;
251: }
252:
253: if (*cssRule == '.')
254: {
255: real = TRUE;
256: f = val;
257: val = 0;
258: cssRule++;
259: /* keep only 3 digits */
260: if (*cssRule >= '0' && *cssRule <= '9')
261: {
262: val = (*cssRule - '0') * 100;
263: cssRule++;
264: if (*cssRule >= '0' && *cssRule <= '9')
265: {
266: val += (*cssRule - '0') * 10;
267: cssRule++;
268: if ((*cssRule >= '0') && (*cssRule <= '9'))
269: {
270: val += *cssRule - '0';
271: cssRule++;
272: }
273: }
274:
275: while (*cssRule >= '0' && *cssRule <= '9')
276: cssRule++;
277: valid = 1;
278: }
279: }
280:
281: if (!valid)
282: {
283: cssRule = SkipWord (cssRule);
284: pval->typed_data.unit = STYLE_UNIT_INVALID;
285: pval->typed_data.value = 0;
286: }
287: else
288: {
1.13 cvs 289: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 290: for (uni = 0; uni < NB_UNITS; uni++)
291: {
292: if (!ustrncasecmp (CSSUnitNames[uni].sign, cssRule,
293: ustrlen (CSSUnitNames[uni].sign)))
294: {
295: pval->typed_data.unit = CSSUnitNames[uni].unit;
296: pval->typed_data.real = real;
297: if (real)
298: {
299: if (minus)
300: pval->typed_data.value = -(f * 1000 + val);
301: else
302: pval->typed_data.value = f * 1000 + val;
303: }
304: else
305: {
306: if (minus)
307: pval->typed_data.value = -val;
308: else
309: pval->typed_data.value = val;
310: }
311: return (cssRule + ustrlen (CSSUnitNames[uni].sign));
312: }
313: }
314:
315: /* not in the list of predefined units */
316: pval->typed_data.unit = STYLE_UNIT_REL;
317: pval->typed_data.real = real;
318: if (real)
319: {
320: if (minus)
321: pval->typed_data.value = -(f * 1000 + val);
322: else
323: pval->typed_data.value = f * 1000 + val;
324: }
325: else
326: {
327: if (minus)
328: pval->typed_data.value = -val;
329: else
330: pval->typed_data.value = val;
331: }
332: }
333: return (cssRule);
334: }
335:
1.43 cvs 336: /*----------------------------------------------------------------------
337: ParseBorderValue
338: ----------------------------------------------------------------------*/
339: #ifdef __STDC__
340: static STRING ParseBorderValue (STRING cssRule, PresentationValue *border)
341: #else
342: static STRING ParseBorderValue (cssRule, border)
343: STRING cssRule;
344: PresentationValue *border
345: #endif
346: {
347: /* first parse the attribute string */
348: border->typed_data.value = 0;
1.44 ! cvs 349: border->typed_data.unit = STYLE_UNIT_INVALID;
1.43 cvs 350: border->typed_data.real = FALSE;
351: if (!ustrncasecmp (cssRule, TEXT("thin"), 4))
352: {
1.44 ! cvs 353: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 354: border->typed_data.value = 1;
355: cssRule = SkipWord (cssRule);
356: }
357: else if (!ustrncasecmp (cssRule, TEXT("medium"), 6))
358: {
1.44 ! cvs 359: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 360: border->typed_data.value = 3;
361: cssRule = SkipWord (cssRule);
362: }
363: else if (!ustrncasecmp (cssRule, TEXT("thick"), 5))
364: {
1.44 ! cvs 365: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 366: border->typed_data.value = 5;
367: cssRule = SkipWord (cssRule);
368: }
369: else if (isdigit (*cssRule))
370: cssRule = ParseCSSUnit (cssRule, border);
371: return (cssRule);
372: }
373:
374: /*----------------------------------------------------------------------
375: ParseBorderStyle
376: ----------------------------------------------------------------------*/
377: #ifdef __STDC__
378: static STRING ParseBorderStyle (STRING cssRule, PresentationValue *border)
379: #else
380: static STRING ParseBorderStyle (cssRule, border)
381: STRING cssRule;
382: PresentationValue *border
383: #endif
384: {
385: /* first parse the attribute string */
386: border->typed_data.value = 0;
387: border->typed_data.unit = STYLE_UNIT_PX;
388: border->typed_data.real = FALSE;
389: if (!ustrncasecmp (cssRule, TEXT("none"), 4))
390: border->typed_data.value = STYLE_BORDERNONE;
391: else if (!ustrncasecmp (cssRule, TEXT("hidden"), 6))
392: border->typed_data.value = STYLE_BORDERHIDDEN;
393: else if (!ustrncasecmp (cssRule, TEXT("dotted"), 6))
394: border->typed_data.value = STYLE_BORDERDOTTED;
395: else if (!ustrncasecmp (cssRule, TEXT("dashed"), 6))
396: border->typed_data.value = STYLE_BORDERDASHED;
397: else if (!ustrncasecmp (cssRule, TEXT("solid"), 5))
398: border->typed_data.value = STYLE_BORDERSOLID;
399: else if (!ustrncasecmp (cssRule, TEXT("double"), 6))
400: border->typed_data.value = STYLE_BORDERDOUBLE;
401: else if (!ustrncasecmp (cssRule, TEXT("groove"), 6))
402: border->typed_data.value = STYLE_BORDERGROOVE;
403: else if (!ustrncasecmp (cssRule, TEXT("ridge"), 5))
404: border->typed_data.value = STYLE_BORDERRIDGE;
405: else if (!ustrncasecmp (cssRule, TEXT("inset"), 5))
406: border->typed_data.value = STYLE_BORDERINSET;
407: else if (!ustrncasecmp (cssRule, TEXT("outset"), 6))
408: border->typed_data.value = STYLE_BORDEROUTSET;
409: else
1.44 ! cvs 410: {
! 411: /* invalid style */
! 412: border->typed_data.unit = STYLE_UNIT_INVALID;
! 413: return (cssRule);
! 414: }
1.43 cvs 415: /* the value is parsed now */
416: cssRule = SkipWord (cssRule);
417: return (cssRule);
418: }
419:
420: /*----------------------------------------------------------------------
421: ParseCSSColor : parse a CSS color attribute string
422: we expect the input string describing the attribute to be
423: either a color name, a 3 tuple or an hexadecimal encoding.
424: The color used will be approximed from the current color
425: table
426: ----------------------------------------------------------------------*/
427: #ifdef __STDC__
428: static STRING ParseCSSColor (STRING cssRule, PresentationValue * val)
429: #else
430: static STRING ParseCSSColor (cssRule, val)
431: STRING cssRule;
432: PresentationValue *val;
433: #endif
434: {
1.44 ! cvs 435: CHAR_T colname[100];
! 436: STRING ptr;
1.43 cvs 437: unsigned short redval = (unsigned short) -1;
438: unsigned short greenval = 0; /* composant of each RGB */
439: unsigned short blueval = 0; /* default to red if unknown ! */
440: unsigned int i, len;
441: int r, g, b;
442: int best = 0; /* best color in list found */
443: ThotBool failed;
444:
445: cssRule = SkipBlanksAndComments (cssRule);
446: val->typed_data.unit = STYLE_UNIT_INVALID;
447: val->typed_data.real = FALSE;
448: val->typed_data.value = 0;
449: failed = TRUE;
450: /*
451: * first parse the attribute string
452: * NOTE : this can't lookup for color name in
453: * cause we try first to lokup color name from digits
454: * [0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]
455: */
456: if ((*cssRule == '#') ||
457: (isxdigit (cssRule[0]) && isxdigit (cssRule[1]) &&
458: isxdigit (cssRule[2])))
459: {
460: if (*cssRule == '#')
461: cssRule++;
462: failed = FALSE;
463: /* we expect an hexa encoding like F00 or FF0000 */
464: if ((!isxdigit (cssRule[0])) || (!isxdigit (cssRule[1])) ||
465: (!isxdigit (cssRule[2])))
466: {
467: fprintf (stderr, "Invalid color encoding %s\n", cssRule - 1);
468: failed = TRUE;
469: }
470: else if (!isxdigit (cssRule[3]))
471: {
472: /* encoded as on 3 digits #F0F */
473: redval = hexa_val (cssRule[0]) * 16 + hexa_val (cssRule[0]);
474: greenval = hexa_val (cssRule[1]) * 16 + hexa_val (cssRule[1]);
475: blueval = hexa_val (cssRule[2]) * 16 + hexa_val (cssRule[2]);
476: cssRule = &cssRule[3];
477: }
478: else if ((!isxdigit (cssRule[4])) || (!isxdigit (cssRule[5])))
479: fprintf (stderr, "Invalid color encoding %s\n", cssRule - 1);
480: else
481: {
482: /* encoded as on 3 digits #FF00FF */
483: redval = hexa_val (cssRule[0]) * 16 + hexa_val (cssRule[1]);
484: greenval = hexa_val (cssRule[2]) * 16 + hexa_val (cssRule[3]);
485: blueval = hexa_val (cssRule[4]) * 16 + hexa_val (cssRule[5]);
486: cssRule = &cssRule[6];
487: }
488: }
489: else if (!ustrncasecmp (cssRule, TEXT("rgb"), 3))
490: {
491: cssRule = &cssRule[3];
492: cssRule = SkipBlanksAndComments (cssRule);
493: if (*cssRule == '(')
494: {
495: cssRule++;
496: cssRule = SkipBlanksAndComments (cssRule);
497: failed = FALSE;
498: if (*cssRule == '%')
499: {
500: /* encoded as rgb(%red,%green,&blue) */
501: usscanf (cssRule, TEXT("%%%d"), &r);
502: while (*cssRule != EOS && *cssRule != TEXT(','))
503: cssRule++;
504: cssRule++;
505: usscanf (cssRule, TEXT("%%%d"), &g);
506: while (*cssRule != EOS && *cssRule != TEXT(','))
507: cssRule++;
508: cssRule++;
509: usscanf (cssRule, TEXT("%%%d"), &b);
510: redval = (unsigned short)(r * 255 / 100);
511: greenval = (unsigned short)(g * 255 / 100);
512: blueval = (unsigned short)(b * 255 / 100);
513: }
514: else
515: {
516: /* encoded as rgb(red,green,blue) */
517: usscanf (cssRule, TEXT("%d"), &r);
518: while (*cssRule != EOS && *cssRule != TEXT(','))
519: cssRule++;
520: cssRule++;
521: usscanf (cssRule, TEXT("%d"), &g);
522: while (*cssRule != EOS && *cssRule != TEXT(','))
523: cssRule++;
524: cssRule++;
525: usscanf (cssRule, TEXT("%d"), &b);
526: redval = (unsigned short)r;
527: greenval = (unsigned short)g;
528: blueval = (unsigned short)b;
529: }
530: /* search the rgb end */
531: while (*cssRule != EOS && *cssRule != ')')
532: cssRule++;
533: cssRule++;
534: }
535: else
536: cssRule = SkipProperty (cssRule);
537: }
538: else if (isalpha (*cssRule))
539: {
540: /* we expect a color name like "red", store it in colname */
1.44 ! cvs 541: ptr = cssRule;
1.43 cvs 542: len = sizeof (colname) - 1;
1.44 ! cvs 543: for (i = 0; i < len && ptr[i] != EOS; i++)
1.43 cvs 544: {
1.44 ! cvs 545: if (!isalnum (ptr[i]) && ptr[i] != EOS)
1.43 cvs 546: {
1.44 ! cvs 547: ptr += i;
1.43 cvs 548: break;
549: }
1.44 ! cvs 550: colname[i] = ptr[i];
1.43 cvs 551: }
552: colname[i] = EOS;
553:
554: /* Lookup the color name in our own color name database */
555: for (i = 0; i < NBCOLORNAME; i++)
556: if (!ustrcasecmp (ColornameTable[i].name, colname))
557: {
558: redval = ColornameTable[i].red;
559: greenval = ColornameTable[i].green;
560: blueval = ColornameTable[i].blue;
561: failed = FALSE;
1.44 ! cvs 562: cssRule = ptr;
1.43 cvs 563: i = NBCOLORNAME;
564: }
565: }
566:
567: if (failed)
568: {
569: val->typed_data.value = 0;
570: val->typed_data.unit = STYLE_UNIT_INVALID;
571: }
572: else
573: {
574: best = TtaGetThotColor (redval, greenval, blueval);
575: val->typed_data.value = best;
576: val->typed_data.unit = STYLE_UNIT_REL;
577: }
578: val->typed_data.real = FALSE;
579: return (cssRule);
580: }
1.1 cvs 581:
582: /*----------------------------------------------------------------------
583: ParseCSSBorderTopWidth : parse a CSS BorderTopWidth
584: attribute string.
585: ----------------------------------------------------------------------*/
586: #ifdef __STDC__
587: static STRING ParseCSSBorderTopWidth (Element element, PSchema tsch,
1.14 cvs 588: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 589: #else
590: static STRING ParseCSSBorderTopWidth (element, tsch, context, cssRule, css, isHTML)
591: Element element;
592: PSchema tsch;
593: PresentationContext context;
594: STRING cssRule;
595: CSSInfoPtr css;
1.14 cvs 596: ThotBool isHTML;
1.1 cvs 597: #endif
598: {
1.41 cvs 599: PresentationValue border;
600:
601: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 602: cssRule = ParseBorderValue (cssRule, &border);
603: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 ! cvs 604: {
! 605: TtaSetStylePresentation (PRBorderTopWidth, element, tsch, context, border);
! 606: border.typed_data.value = 1;
! 607: border.typed_data.unit = STYLE_UNIT_REL;
! 608: TtaSetStylePresentation (PRShowBox, element, tsch, context, border);
! 609: }
1.1 cvs 610: return (cssRule);
611: }
612:
613: /*----------------------------------------------------------------------
1.41 cvs 614: ParseCSSBorderBottomWidth : parse a CSS BorderBottomWidth
1.1 cvs 615: attribute string.
616: ----------------------------------------------------------------------*/
617: #ifdef __STDC__
1.41 cvs 618: static STRING ParseCSSBorderBottomWidth (Element element, PSchema tsch,
1.14 cvs 619: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 620: #else
1.41 cvs 621: static STRING ParseCSSBorderBottomWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 622: Element element;
623: PSchema tsch;
624: PresentationContext context;
625: STRING cssRule;
626: CSSInfoPtr css;
1.14 cvs 627: ThotBool isHTML;
1.1 cvs 628: #endif
629: {
1.41 cvs 630: PresentationValue border;
631:
632: cssRule = SkipBlanksAndComments (cssRule);
633: /* first parse the attribute string */
1.43 cvs 634: cssRule = ParseBorderValue (cssRule, &border);
635: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 ! cvs 636: {
! 637: TtaSetStylePresentation (PRBorderBottomWidth, element, tsch, context, border);
! 638: border.typed_data.value = 1;
! 639: border.typed_data.unit = STYLE_UNIT_REL;
! 640: TtaSetStylePresentation (PRShowBox, element, tsch, context, border);
! 641: }
1.1 cvs 642: return (cssRule);
643: }
644:
645: /*----------------------------------------------------------------------
1.41 cvs 646: ParseCSSBorderLeftWidth : parse a CSS BorderLeftWidth
1.1 cvs 647: attribute string.
648: ----------------------------------------------------------------------*/
649: #ifdef __STDC__
1.41 cvs 650: static STRING ParseCSSBorderLeftWidth (Element element, PSchema tsch,
1.14 cvs 651: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 652: #else
1.41 cvs 653: static STRING ParseCSSBorderLeftWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 654: Element element;
655: PSchema tsch;
656: PresentationContext context;
657: STRING cssRule;
658: CSSInfoPtr css;
1.14 cvs 659: ThotBool isHTML;
1.1 cvs 660: #endif
661: {
1.41 cvs 662: PresentationValue border;
663:
664: cssRule = SkipBlanksAndComments (cssRule);
665: /* first parse the attribute string */
1.43 cvs 666: cssRule = ParseBorderValue (cssRule, &border);
667: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 ! cvs 668: {
! 669: TtaSetStylePresentation (PRBorderLeftWidth, element, tsch, context, border);
! 670: border.typed_data.value = 1;
! 671: border.typed_data.unit = STYLE_UNIT_REL;
! 672: TtaSetStylePresentation (PRShowBox, element, tsch, context, border);
! 673: }
1.1 cvs 674: return (cssRule);
675: }
676:
677: /*----------------------------------------------------------------------
1.41 cvs 678: ParseCSSBorderRightWidth : parse a CSS BorderRightWidth
1.1 cvs 679: attribute string.
680: ----------------------------------------------------------------------*/
681: #ifdef __STDC__
1.41 cvs 682: static STRING ParseCSSBorderRightWidth (Element element, PSchema tsch,
1.14 cvs 683: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 684: #else
1.41 cvs 685: static STRING ParseCSSBorderRightWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 686: Element element;
687: PSchema tsch;
688: PresentationContext context;
689: STRING cssRule;
690: CSSInfoPtr css;
1.14 cvs 691: ThotBool isHTML;
1.1 cvs 692: #endif
693: {
1.41 cvs 694: PresentationValue border;
695:
696: cssRule = SkipBlanksAndComments (cssRule);
697: /* first parse the attribute string */
1.43 cvs 698: cssRule = ParseBorderValue (cssRule, &border);
699: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 ! cvs 700: {
! 701: TtaSetStylePresentation (PRBorderRightWidth, element, tsch, context, border);
! 702: border.typed_data.value = 1;
! 703: border.typed_data.unit = STYLE_UNIT_REL;
! 704: TtaSetStylePresentation (PRShowBox, element, tsch, context, border);
! 705: }
1.1 cvs 706: return (cssRule);
707: }
708:
709: /*----------------------------------------------------------------------
710: ParseCSSBorderWidth : parse a CSS BorderWidth
711: attribute string.
712: ----------------------------------------------------------------------*/
713: #ifdef __STDC__
714: static STRING ParseCSSBorderWidth (Element element, PSchema tsch,
1.14 cvs 715: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 716: #else
717: static STRING ParseCSSBorderWidth (element, tsch, context, cssRule, css, isHTML)
718: Element element;
719: PSchema tsch;
720: PresentationContext context;
721: STRING cssRule;
722: CSSInfoPtr css;
1.14 cvs 723: ThotBool isHTML;
1.1 cvs 724: #endif
725: {
1.42 cvs 726: STRING ptrT, ptrR, ptrB, ptrL;
1.41 cvs 727:
1.42 cvs 728: ptrT = SkipBlanksAndComments (cssRule);
729: /* First parse Border-Top */
730: ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);
731: ptrR = SkipBlanksAndComments (ptrR);
732: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
733: {
734: cssRule = ptrR;
735: /* apply the Border-Top to all */
736: ptrR = ParseCSSBorderRightWidth (element, tsch, context, ptrT, css, isHTML);
737: ptrR = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
738: ptrR = ParseCSSBorderLeftWidth (element, tsch, context, ptrT, css, isHTML);
739: }
740: else
741: {
742: /* parse Border-Right */
743: ptrB = ParseCSSBorderRightWidth (element, tsch, context, ptrR, css, isHTML);
744: ptrB = SkipBlanksAndComments (ptrB);
745: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
746: {
747: cssRule = ptrB;
748: /* apply the Border-Top to Border-Bottom */
749: ptrB = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
750: /* apply the Border-Right to Border-Left */
751: ptrB = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
752: }
753: else
754: {
755: /* parse Border-Bottom */
756: ptrL = ParseCSSBorderBottomWidth (element, tsch, context, ptrB, css, isHTML);
757: ptrL = SkipBlanksAndComments (ptrL);
758: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
759: {
760: cssRule = ptrL;
761: /* apply the Border-Right to Border-Left */
762: ptrL = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
763: }
764: else
765: /* parse Border-Left */
766: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, ptrL, css, isHTML);
767: cssRule = SkipBlanksAndComments (cssRule);
768: }
769: }
1.1 cvs 770: return (cssRule);
771: }
772:
773: /*----------------------------------------------------------------------
1.43 cvs 774: ParseCSSBorderColorTop : parse a CSS BorderColorTop
1.1 cvs 775: attribute string.
776: ----------------------------------------------------------------------*/
777: #ifdef __STDC__
1.43 cvs 778: static STRING ParseCSSBorderColorTop (Element element, PSchema tsch,
1.14 cvs 779: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 780: #else
1.43 cvs 781: static STRING ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 782: Element element;
783: PSchema tsch;
784: PresentationContext context;
785: STRING cssRule;
786: CSSInfoPtr css;
1.14 cvs 787: ThotBool isHTML;
1.1 cvs 788: #endif
789: {
1.43 cvs 790: PresentationValue best;
791:
792: cssRule = ParseCSSColor (cssRule, &best);
793: if (best.typed_data.unit != STYLE_UNIT_INVALID)
794: /* install the new presentation */
795: TtaSetStylePresentation (PRBorderTopColor, element, tsch, context, best);
1.1 cvs 796: return (cssRule);
797: }
798:
799: /*----------------------------------------------------------------------
1.43 cvs 800: ParseCSSBorderColorLeft : parse a CSS BorderColorLeft
1.42 cvs 801: attribute string.
802: ----------------------------------------------------------------------*/
803: #ifdef __STDC__
1.43 cvs 804: static STRING ParseCSSBorderColorLeft (Element element, PSchema tsch,
1.42 cvs 805: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
806: #else
1.43 cvs 807: static STRING ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 808: Element element;
809: PSchema tsch;
810: PresentationContext context;
811: STRING cssRule;
812: CSSInfoPtr css;
813: ThotBool isHTML;
814: #endif
815: {
1.43 cvs 816: PresentationValue best;
817:
818: cssRule = ParseCSSColor (cssRule, &best);
819: if (best.typed_data.unit != STYLE_UNIT_INVALID)
820: /* install the new presentation */
821: TtaSetStylePresentation (PRBorderLeftColor, element, tsch, context, best);
1.42 cvs 822: return (cssRule);
823: }
824:
825: /*----------------------------------------------------------------------
1.43 cvs 826: ParseCSSBorderColorBottom : parse a CSS BorderColorBottom
1.42 cvs 827: attribute string.
828: ----------------------------------------------------------------------*/
829: #ifdef __STDC__
1.43 cvs 830: static STRING ParseCSSBorderColorBottom (Element element, PSchema tsch,
1.42 cvs 831: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
832: #else
1.43 cvs 833: static STRING ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 834: Element element;
835: PSchema tsch;
836: PresentationContext context;
837: STRING cssRule;
838: CSSInfoPtr css;
839: ThotBool isHTML;
840: #endif
841: {
1.43 cvs 842: PresentationValue best;
843:
844: cssRule = ParseCSSColor (cssRule, &best);
845: if (best.typed_data.unit != STYLE_UNIT_INVALID)
846: /* install the new presentation */
847: TtaSetStylePresentation (PRBorderBottomColor, element, tsch, context, best);
1.42 cvs 848: return (cssRule);
849: }
850:
851: /*----------------------------------------------------------------------
1.43 cvs 852: ParseCSSBorderColorRight : parse a CSS BorderColorRight
1.1 cvs 853: attribute string.
854: ----------------------------------------------------------------------*/
855: #ifdef __STDC__
1.43 cvs 856: static STRING ParseCSSBorderColorRight (Element element, PSchema tsch,
1.14 cvs 857: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 858: #else
1.43 cvs 859: static STRING ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 860: Element element;
861: PSchema tsch;
862: PresentationContext context;
863: STRING cssRule;
864: CSSInfoPtr css;
1.14 cvs 865: ThotBool isHTML;
1.1 cvs 866: #endif
867: {
1.43 cvs 868: PresentationValue best;
869:
870: cssRule = ParseCSSColor (cssRule, &best);
871: if (best.typed_data.unit != STYLE_UNIT_INVALID)
872: /* install the new presentation */
873: TtaSetStylePresentation (PRBorderRightColor, element, tsch, context, best);
1.1 cvs 874: return (cssRule);
875: }
876:
877: /*----------------------------------------------------------------------
1.43 cvs 878: ParseCSSBorderColor : parse a CSS border-color
1.42 cvs 879: attribute string.
880: ----------------------------------------------------------------------*/
881: #ifdef __STDC__
1.43 cvs 882: static STRING ParseCSSBorderColor (Element element, PSchema tsch,
1.42 cvs 883: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
884: #else
1.43 cvs 885: static STRING ParseCSSBorderColor (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 886: Element element;
887: PSchema tsch;
888: PresentationContext context;
889: STRING cssRule;
890: CSSInfoPtr css;
891: ThotBool isHTML;
892: #endif
893: {
894: STRING ptrT, ptrR, ptrB, ptrL;
895:
896: ptrT = SkipBlanksAndComments (cssRule);
897: /* First parse Border-Top */
1.43 cvs 898: ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 899: ptrR = SkipBlanksAndComments (ptrR);
900: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
901: {
902: cssRule = ptrR;
903: /* apply the Border-Top to all */
1.43 cvs 904: ptrR = ParseCSSBorderColorRight (element, tsch, context, ptrT, css, isHTML);
905: ptrR = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
906: ptrR = ParseCSSBorderColorLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 907: }
908: else
909: {
910: /* parse Border-Right */
1.43 cvs 911: ptrB = ParseCSSBorderColorRight (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 912: ptrB = SkipBlanksAndComments (ptrB);
913: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
914: {
915: cssRule = ptrB;
916: /* apply the Border-Top to Border-Bottom */
1.43 cvs 917: ptrB = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 918: /* apply the Border-Right to Border-Left */
1.43 cvs 919: ptrB = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 920: }
921: else
922: {
923: /* parse Border-Bottom */
1.43 cvs 924: ptrL = ParseCSSBorderColorBottom (element, tsch, context, ptrB, css, isHTML);
1.42 cvs 925: ptrL = SkipBlanksAndComments (ptrL);
926: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
927: {
928: cssRule = ptrL;
929: /* apply the Border-Right to Border-Left */
1.43 cvs 930: ptrL = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 931: }
932: else
933: /* parse Border-Left */
1.43 cvs 934: cssRule = ParseCSSBorderColorLeft (element, tsch, context, ptrL, css, isHTML);
1.42 cvs 935: cssRule = SkipBlanksAndComments (cssRule);
936: }
937: }
938: return (cssRule);
939: }
940:
941: /*----------------------------------------------------------------------
1.43 cvs 942: ParseCSSBorderStyleTop : parse a CSS BorderStyleTop
1.42 cvs 943: attribute string.
944: ----------------------------------------------------------------------*/
945: #ifdef __STDC__
1.43 cvs 946: static STRING ParseCSSBorderStyleTop (Element element, PSchema tsch,
1.42 cvs 947: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
948: #else
1.43 cvs 949: static STRING ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 950: Element element;
951: PSchema tsch;
952: PresentationContext context;
953: STRING cssRule;
954: CSSInfoPtr css;
955: ThotBool isHTML;
956: #endif
957: {
1.43 cvs 958: PresentationValue border;
959:
960: cssRule = SkipBlanksAndComments (cssRule);
961: cssRule = ParseBorderStyle (cssRule, &border);
962: if (border.typed_data.unit != STYLE_UNIT_INVALID)
963: TtaSetStylePresentation (PRBorderTopStyle, element, tsch, context, border);
1.42 cvs 964: return (cssRule);
965: }
966:
967: /*----------------------------------------------------------------------
1.43 cvs 968: ParseCSSBorderStyleLeft : parse a CSS BorderStyleLeft
1.42 cvs 969: attribute string.
970: ----------------------------------------------------------------------*/
971: #ifdef __STDC__
1.43 cvs 972: static STRING ParseCSSBorderStyleLeft (Element element, PSchema tsch,
1.42 cvs 973: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
974: #else
1.43 cvs 975: static STRING ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 976: Element element;
977: PSchema tsch;
978: PresentationContext context;
979: STRING cssRule;
980: CSSInfoPtr css;
981: ThotBool isHTML;
982: #endif
983: {
1.43 cvs 984: PresentationValue border;
985:
986: cssRule = SkipBlanksAndComments (cssRule);
987: cssRule = ParseBorderStyle (cssRule, &border);
988: if (border.typed_data.unit != STYLE_UNIT_INVALID)
989: TtaSetStylePresentation (PRBorderLeftStyle, element, tsch, context, border);
1.42 cvs 990: return (cssRule);
991: }
992:
993: /*----------------------------------------------------------------------
1.43 cvs 994: ParseCSSBorderStyleBottom : parse a CSS BorderStyleBottom
1.1 cvs 995: attribute string.
996: ----------------------------------------------------------------------*/
997: #ifdef __STDC__
1.43 cvs 998: static STRING ParseCSSBorderStyleBottom (Element element, PSchema tsch,
1.14 cvs 999: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1000: #else
1.43 cvs 1001: static STRING ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1002: Element element;
1003: PSchema tsch;
1004: PresentationContext context;
1005: STRING cssRule;
1006: CSSInfoPtr css;
1.14 cvs 1007: ThotBool isHTML;
1.1 cvs 1008: #endif
1009: {
1.43 cvs 1010: PresentationValue border;
1011:
1012: cssRule = SkipBlanksAndComments (cssRule);
1013: cssRule = ParseBorderStyle (cssRule, &border);
1014: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1015: TtaSetStylePresentation (PRBorderBottomStyle, element, tsch, context, border);
1.1 cvs 1016: return (cssRule);
1017: }
1018:
1019: /*----------------------------------------------------------------------
1.43 cvs 1020: ParseCSSBorderStyleRight : parse a CSS BorderStyleRight
1.1 cvs 1021: attribute string.
1022: ----------------------------------------------------------------------*/
1023: #ifdef __STDC__
1.43 cvs 1024: static STRING ParseCSSBorderStyleRight (Element element, PSchema tsch,
1.14 cvs 1025: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1026: #else
1.43 cvs 1027: static STRING ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1028: Element element;
1029: PSchema tsch;
1030: PresentationContext context;
1031: STRING cssRule;
1032: CSSInfoPtr css;
1.14 cvs 1033: ThotBool isHTML;
1.1 cvs 1034: #endif
1035: {
1.43 cvs 1036: PresentationValue border;
1037:
1038: cssRule = SkipBlanksAndComments (cssRule);
1039: cssRule = ParseBorderStyle (cssRule, &border);
1040: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1041: TtaSetStylePresentation (PRBorderRightStyle, element, tsch, context, border);
1.1 cvs 1042: return (cssRule);
1043: }
1044:
1045: /*----------------------------------------------------------------------
1.43 cvs 1046: ParseCSSBorderStyleStyle : parse a CSS border-style
1.1 cvs 1047: attribute string.
1048: ----------------------------------------------------------------------*/
1049: #ifdef __STDC__
1.43 cvs 1050: static STRING ParseCSSBorderStyle (Element element, PSchema tsch,
1.14 cvs 1051: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1052: #else
1.43 cvs 1053: static STRING ParseCSSBorderStyle (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1054: Element element;
1055: PSchema tsch;
1056: PresentationContext context;
1057: STRING cssRule;
1058: CSSInfoPtr css;
1.14 cvs 1059: ThotBool isHTML;
1.1 cvs 1060: #endif
1061: {
1.42 cvs 1062: STRING ptrT, ptrR, ptrB, ptrL;
1063:
1064: ptrT = SkipBlanksAndComments (cssRule);
1065: /* First parse Border-Top */
1.43 cvs 1066: ptrR = ParseCSSBorderStyleTop (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 1067: ptrR = SkipBlanksAndComments (ptrR);
1068: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1069: {
1070: cssRule = ptrR;
1071: /* apply the Border-Top to all */
1.43 cvs 1072: ptrR = ParseCSSBorderStyleRight (element, tsch, context, ptrT, css, isHTML);
1073: ptrR = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1074: ptrR = ParseCSSBorderStyleLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 1075: }
1076: else
1077: {
1078: /* parse Border-Right */
1.43 cvs 1079: ptrB = ParseCSSBorderStyleRight (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 1080: ptrB = SkipBlanksAndComments (ptrB);
1081: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1082: {
1083: cssRule = ptrB;
1084: /* apply the Border-Top to Border-Bottom */
1.43 cvs 1085: ptrB = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 1086: /* apply the Border-Right to Border-Left */
1.43 cvs 1087: ptrB = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 1088: }
1089: else
1090: {
1091: /* parse Border-Bottom */
1.43 cvs 1092: ptrL = ParseCSSBorderStyleBottom (element, tsch, context, ptrB, css, isHTML);
1.42 cvs 1093: ptrL = SkipBlanksAndComments (ptrL);
1094: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1095: {
1096: cssRule = ptrL;
1097: /* apply the Border-Right to Border-Left */
1.43 cvs 1098: ptrL = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 1099: }
1100: else
1101: /* parse Border-Left */
1.43 cvs 1102: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, ptrL, css, isHTML);
1.42 cvs 1103: cssRule = SkipBlanksAndComments (cssRule);
1104: }
1105: }
1106: return (cssRule);
1107: }
1108:
1109: /*----------------------------------------------------------------------
1.43 cvs 1110: ParseCSSBorderTop : parse a CSS BorderTop
1.42 cvs 1111: attribute string.
1112: ----------------------------------------------------------------------*/
1113: #ifdef __STDC__
1.43 cvs 1114: static STRING ParseCSSBorderTop (Element element, PSchema tsch,
1.42 cvs 1115: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1116: #else
1.43 cvs 1117: static STRING ParseCSSBorderTop (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 1118: Element element;
1119: PSchema tsch;
1120: PresentationContext context;
1121: STRING cssRule;
1122: CSSInfoPtr css;
1123: ThotBool isHTML;
1124: #endif
1125: {
1.43 cvs 1126: STRING ptr;
1127:
1128: cssRule = SkipBlanksAndComments (cssRule);
1129: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1130: {
1131: ptr = cssRule;
1132: cssRule = ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML);
1133: if (ptr == cssRule)
1134: cssRule = ParseCSSBorderTopWidth (element, tsch, context, cssRule, css, isHTML);
1135: if (ptr == cssRule)
1136: cssRule = ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML);
1137: if (ptr == cssRule)
1138: /* rule not found */
1139: cssRule = SkipProperty (cssRule);
1.44 ! cvs 1140: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1141: }
1.42 cvs 1142: return (cssRule);
1143: }
1144:
1145: /*----------------------------------------------------------------------
1.43 cvs 1146: ParseCSSBorderLeft : parse a CSS BorderLeft
1.42 cvs 1147: attribute string.
1148: ----------------------------------------------------------------------*/
1149: #ifdef __STDC__
1.43 cvs 1150: static STRING ParseCSSBorderLeft (Element element, PSchema tsch,
1.42 cvs 1151: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1152: #else
1.43 cvs 1153: static STRING ParseCSSBorderLeft (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 1154: Element element;
1155: PSchema tsch;
1156: PresentationContext context;
1157: STRING cssRule;
1158: CSSInfoPtr css;
1159: ThotBool isHTML;
1160: #endif
1161: {
1.43 cvs 1162: STRING ptr;
1163:
1164: cssRule = SkipBlanksAndComments (cssRule);
1165: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1166: {
1167: ptr = cssRule;
1168: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML);
1169: if (ptr == cssRule)
1170: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, cssRule, css, isHTML);
1171: if (ptr == cssRule)
1172: cssRule = ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML);
1173: if (ptr == cssRule)
1174: /* rule not found */
1175: cssRule = SkipProperty (cssRule);
1.44 ! cvs 1176: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1177: }
1.1 cvs 1178: return (cssRule);
1179: }
1180:
1181: /*----------------------------------------------------------------------
1.43 cvs 1182: ParseCSSBorderBottom : parse a CSS BorderBottom
1.1 cvs 1183: attribute string.
1184: ----------------------------------------------------------------------*/
1185: #ifdef __STDC__
1.43 cvs 1186: static STRING ParseCSSBorderBottom (Element element, PSchema tsch,
1.14 cvs 1187: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1188: #else
1.43 cvs 1189: static STRING ParseCSSBorderBottom (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1190: Element element;
1191: PSchema tsch;
1192: PresentationContext context;
1193: STRING cssRule;
1194: CSSInfoPtr css;
1.14 cvs 1195: ThotBool isHTML;
1.1 cvs 1196: #endif
1197: {
1.43 cvs 1198: STRING ptr;
1199:
1200: cssRule = SkipBlanksAndComments (cssRule);
1201: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1202: {
1203: ptr = cssRule;
1204: cssRule = ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML);
1205: if (ptr == cssRule)
1206: cssRule = ParseCSSBorderBottomWidth (element, tsch, context, cssRule, css, isHTML);
1207: if (ptr == cssRule)
1208: cssRule = ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML);
1209: if (ptr == cssRule)
1210: /* rule not found */
1211: cssRule = SkipProperty (cssRule);
1.44 ! cvs 1212: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1213: }
1.1 cvs 1214: return (cssRule);
1215: }
1216:
1217: /*----------------------------------------------------------------------
1.43 cvs 1218: ParseCSSBorderRight : parse a CSS BorderRight
1.1 cvs 1219: attribute string.
1220: ----------------------------------------------------------------------*/
1221: #ifdef __STDC__
1.43 cvs 1222: static STRING ParseCSSBorderRight (Element element, PSchema tsch,
1.14 cvs 1223: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1224: #else
1.43 cvs 1225: static STRING ParseCSSBorderRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1226: Element element;
1227: PSchema tsch;
1228: PresentationContext context;
1229: STRING cssRule;
1230: CSSInfoPtr css;
1.14 cvs 1231: ThotBool isHTML;
1.1 cvs 1232: #endif
1233: {
1.43 cvs 1234: STRING ptr;
1235:
1236: cssRule = SkipBlanksAndComments (cssRule);
1237: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1238: {
1239: ptr = cssRule;
1240: cssRule = ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML);
1241: if (ptr == cssRule)
1242: cssRule = ParseCSSBorderRightWidth (element, tsch, context, cssRule, css, isHTML);
1243: if (ptr == cssRule)
1244: cssRule = ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML);
1245: if (ptr == cssRule)
1246: /* rule not found */
1247: cssRule = SkipProperty (cssRule);
1.44 ! cvs 1248: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1249: }
1.1 cvs 1250: return (cssRule);
1251: }
1252:
1253: /*----------------------------------------------------------------------
1.43 cvs 1254: ParseCSSBorder : parse a CSS border
1.42 cvs 1255: attribute string.
1256: ----------------------------------------------------------------------*/
1257: #ifdef __STDC__
1.43 cvs 1258: static STRING ParseCSSBorder (Element element, PSchema tsch,
1.42 cvs 1259: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1260: #else
1.43 cvs 1261: static STRING ParseCSSBorder (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 1262: Element element;
1263: PSchema tsch;
1264: PresentationContext context;
1265: STRING cssRule;
1266: CSSInfoPtr css;
1267: ThotBool isHTML;
1268: #endif
1269: {
1270: STRING ptrT, ptrR, ptrB, ptrL;
1271:
1272: ptrT = SkipBlanksAndComments (cssRule);
1273: /* First parse Border-Top */
1274: ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);
1275: ptrR = SkipBlanksAndComments (ptrR);
1276: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1277: {
1278: cssRule = ptrR;
1279: /* apply the Border-Top to all */
1280: ptrR = ParseCSSBorderRight (element, tsch, context, ptrT, css, isHTML);
1281: ptrR = ParseCSSBorderBottom (element, tsch, context, ptrT, css, isHTML);
1282: ptrR = ParseCSSBorderLeft (element, tsch, context, ptrT, css, isHTML);
1283: }
1284: return (cssRule);
1285: }
1286:
1287: /*----------------------------------------------------------------------
1.1 cvs 1288: ParseCSSClear : parse a CSS clear attribute string
1289: ----------------------------------------------------------------------*/
1290: #ifdef __STDC__
1291: static STRING ParseCSSClear (Element element, PSchema tsch,
1.14 cvs 1292: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1293: #else
1294: static STRING ParseCSSClear (element, tsch, context, cssRule, css, isHTML)
1295: Element element;
1296: PSchema tsch;
1297: PresentationContext context;
1298: STRING cssRule;
1299: CSSInfoPtr css;
1.14 cvs 1300: ThotBool isHTML;
1.1 cvs 1301: #endif
1302: {
1303: cssRule = SkipProperty (cssRule);
1304: return (cssRule);
1305: }
1306:
1307: /*----------------------------------------------------------------------
1308: ParseCSSDisplay : parse a CSS display attribute string
1309: ----------------------------------------------------------------------*/
1310: #ifdef __STDC__
1311: static STRING ParseCSSDisplay (Element element, PSchema tsch,
1.14 cvs 1312: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1313: #else
1314: static STRING ParseCSSDisplay (element, tsch, context, cssRule, css, isHTML)
1315: Element element;
1316: PSchema tsch;
1317: PresentationContext context;
1318: STRING cssRule;
1319: CSSInfoPtr css;
1.14 cvs 1320: ThotBool isHTML;
1.1 cvs 1321: #endif
1322: {
1323: PresentationValue pval;
1324:
1325: pval.typed_data.unit = STYLE_UNIT_REL;
1326: pval.typed_data.real = FALSE;
1.13 cvs 1327: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 1328: if (!ustrncasecmp (cssRule, TEXT("block"), 5))
1.1 cvs 1329: {
1330: pval.typed_data.value = STYLE_NOTINLINE;
1331: TtaSetStylePresentation (PRLine, element, tsch, context, pval);
1332: cssRule = SkipWord (cssRule);
1333: }
1.17 cvs 1334: else if (!ustrncasecmp (cssRule, TEXT("inline"), 6))
1.1 cvs 1335: {
1336: pval.typed_data.value = STYLE_INLINE;
1337: TtaSetStylePresentation (PRLine, element, tsch, context, pval);
1338: cssRule = SkipWord (cssRule);
1339: }
1.17 cvs 1340: else if (!ustrncasecmp (cssRule, TEXT("none"), 4))
1.1 cvs 1341: {
1342: pval.typed_data.value = STYLE_HIDE;
1343: TtaSetStylePresentation (PRVisibility, element, tsch, context, pval);
1344: cssRule = SkipWord (cssRule);
1345: }
1.17 cvs 1346: else if (!ustrncasecmp (cssRule, TEXT("list-item"), 9))
1.1 cvs 1347: cssRule = SkipProperty (cssRule);
1348: else
1349: fprintf (stderr, "invalid display value %s\n", cssRule);
1.34 cvs 1350:
1.1 cvs 1351: return (cssRule);
1352: }
1353:
1354: /*----------------------------------------------------------------------
1355: ParseCSSFloat : parse a CSS float attribute string
1356: ----------------------------------------------------------------------*/
1357: #ifdef __STDC__
1358: static STRING ParseCSSFloat (Element element, PSchema tsch,
1.14 cvs 1359: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1360: #else
1361: static STRING ParseCSSFloat (element, tsch, context, cssRule, css, isHTML)
1362: Element element;
1363: PSchema tsch;
1364: PresentationContext context;
1365: STRING cssRule;
1366: CSSInfoPtr css;
1.14 cvs 1367: ThotBool isHTML;
1.1 cvs 1368: #endif
1369: {
1370: cssRule = SkipProperty (cssRule);
1371: return (cssRule);
1372: }
1373:
1374: /*----------------------------------------------------------------------
1375: ParseCSSLetterSpacing : parse a CSS letter-spacing
1376: attribute string.
1377: ----------------------------------------------------------------------*/
1378: #ifdef __STDC__
1379: static STRING ParseCSSLetterSpacing (Element element, PSchema tsch,
1.14 cvs 1380: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1381: #else
1382: static STRING ParseCSSLetterSpacing (element, tsch, context, cssRule, css, isHTML)
1383: Element element;
1384: PSchema tsch;
1385: PresentationContext context;
1386: STRING cssRule;
1387: CSSInfoPtr css;
1.14 cvs 1388: ThotBool isHTML;
1.1 cvs 1389: #endif
1390: {
1391: cssRule = SkipProperty (cssRule);
1392: return (cssRule);
1393: }
1394:
1395: /*----------------------------------------------------------------------
1396: ParseCSSListStyleType : parse a CSS list-style-type
1397: attribute string.
1398: ----------------------------------------------------------------------*/
1399: #ifdef __STDC__
1400: static STRING ParseCSSListStyleType (Element element, PSchema tsch,
1.14 cvs 1401: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1402: #else
1403: static STRING ParseCSSListStyleType (element, tsch, context, cssRule, css, isHTML)
1404: Element element;
1405: PSchema tsch;
1406: PresentationContext context;
1407: STRING cssRule;
1408: CSSInfoPtr css;
1.14 cvs 1409: ThotBool isHTML;
1.1 cvs 1410: #endif
1411: {
1412: cssRule = SkipProperty (cssRule);
1413: return (cssRule);
1414: }
1415:
1416: /*----------------------------------------------------------------------
1417: ParseCSSListStyleImage : parse a CSS list-style-image
1418: attribute string.
1419: ----------------------------------------------------------------------*/
1420: #ifdef __STDC__
1421: static STRING ParseCSSListStyleImage (Element element, PSchema tsch,
1.14 cvs 1422: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1423: #else
1424: static STRING ParseCSSListStyleImage (element, tsch, context, cssRule, css, isHTML)
1425: Element element;
1426: PSchema tsch;
1427: PresentationContext context;
1428: STRING cssRule;
1429: CSSInfoPtr css;
1.14 cvs 1430: ThotBool isHTML;
1.1 cvs 1431: #endif
1432: {
1433: cssRule = SkipProperty (cssRule);
1434: return (cssRule);
1435: }
1436:
1437: /*----------------------------------------------------------------------
1438: ParseCSSListStylePosition : parse a CSS list-style-position
1439: attribute string.
1440: ----------------------------------------------------------------------*/
1441: #ifdef __STDC__
1442: static STRING ParseCSSListStylePosition (Element element, PSchema tsch,
1.14 cvs 1443: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1444: #else
1445: static STRING ParseCSSListStylePosition (element, tsch, context, cssRule, css, isHTML)
1446: Element element;
1447: PSchema tsch;
1448: PresentationContext context;
1449: STRING cssRule;
1450: CSSInfoPtr css;
1.14 cvs 1451: ThotBool isHTML;
1.1 cvs 1452: #endif
1453: {
1454: cssRule = SkipProperty (cssRule);
1455: return (cssRule);
1456: }
1457:
1458: /*----------------------------------------------------------------------
1459: ParseCSSListStyle : parse a CSS list-style
1460: attribute string.
1461: ----------------------------------------------------------------------*/
1462: #ifdef __STDC__
1463: static STRING ParseCSSListStyle (Element element, PSchema tsch,
1.14 cvs 1464: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1465: #else
1466: static STRING ParseCSSListStyle (element, tsch, context, cssRule, css, isHTML)
1467: Element element;
1468: PSchema tsch;
1469: PresentationContext context;
1470: STRING cssRule;
1471: CSSInfoPtr css;
1.14 cvs 1472: ThotBool isHTML;
1.1 cvs 1473: #endif
1474: {
1475: cssRule = SkipProperty (cssRule);
1476: return (cssRule);
1477: }
1478:
1479: /*----------------------------------------------------------------------
1480: ParseCSSTextAlign : parse a CSS text-align
1481: attribute string.
1482: ----------------------------------------------------------------------*/
1483: #ifdef __STDC__
1484: static STRING ParseCSSTextAlign (Element element, PSchema tsch,
1.14 cvs 1485: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1486: #else
1487: static STRING ParseCSSTextAlign (element, tsch, context, cssRule, css, isHTML)
1488: Element element;
1489: PSchema tsch;
1490: PresentationContext context;
1491: STRING cssRule;
1492: CSSInfoPtr css;
1.14 cvs 1493: ThotBool isHTML;
1.1 cvs 1494: #endif
1495: {
1496: PresentationValue align;
1497: PresentationValue justify;
1498:
1499: align.typed_data.value = 0;
1500: align.typed_data.unit = STYLE_UNIT_REL;
1501: align.typed_data.real = FALSE;
1502: justify.typed_data.value = 0;
1503: justify.typed_data.unit = STYLE_UNIT_REL;
1504: justify.typed_data.real = FALSE;
1505:
1.13 cvs 1506: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 1507: if (!ustrncasecmp (cssRule, TEXT("left"), 4))
1.1 cvs 1508: {
1509: align.typed_data.value = AdjustLeft;
1510: cssRule = SkipWord (cssRule);
1511: }
1.17 cvs 1512: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
1.1 cvs 1513: {
1514: align.typed_data.value = AdjustRight;
1515: cssRule = SkipWord (cssRule);
1516: }
1.17 cvs 1517: else if (!ustrncasecmp (cssRule, TEXT("center"), 6))
1.1 cvs 1518: {
1519: align.typed_data.value = Centered;
1520: cssRule = SkipWord (cssRule);
1521: }
1.17 cvs 1522: else if (!ustrncasecmp (cssRule, TEXT("justify"), 7))
1.1 cvs 1523: {
1524: justify.typed_data.value = Justified;
1525: cssRule = SkipWord (cssRule);
1526: }
1527: else
1528: {
1529: fprintf (stderr, "invalid align value\n");
1530: return (cssRule);
1531: }
1532:
1533: /*
1534: * install the new presentation.
1535: */
1536: if (align.typed_data.value)
1537: {
1538: TtaSetStylePresentation (PRAdjust, element, tsch, context, align);
1539: }
1540: if (justify.typed_data.value)
1541: {
1542: TtaSetStylePresentation (PRJustify, element, tsch, context, justify);
1543: TtaSetStylePresentation (PRHyphenate, element, tsch, context, justify);
1544: }
1545: return (cssRule);
1546: }
1547:
1548: /*----------------------------------------------------------------------
1549: ParseCSSTextIndent : parse a CSS text-indent
1550: attribute string.
1551: ----------------------------------------------------------------------*/
1552: #ifdef __STDC__
1553: static STRING ParseCSSTextIndent (Element element, PSchema tsch,
1.14 cvs 1554: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1555: #else
1556: static STRING ParseCSSTextIndent (element, tsch, context, cssRule, css, isHTML)
1557: Element element;
1558: PSchema tsch;
1559: PresentationContext context;
1560: STRING cssRule;
1561: CSSInfoPtr css;
1.14 cvs 1562: ThotBool isHTML;
1.1 cvs 1563: #endif
1564: {
1565: PresentationValue pval;
1566:
1.13 cvs 1567: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1568: cssRule = ParseCSSUnit (cssRule, &pval);
1569: if (pval.typed_data.unit == STYLE_UNIT_INVALID)
1570: return (cssRule);
1571: /* install the attribute */
1572: TtaSetStylePresentation (PRIndent, element, tsch, context, pval);
1573: return (cssRule);
1574: }
1575:
1576: /*----------------------------------------------------------------------
1577: ParseCSSTextTransform : parse a CSS text-transform
1578: attribute string.
1579: ----------------------------------------------------------------------*/
1580: #ifdef __STDC__
1581: static STRING ParseCSSTextTransform (Element element, PSchema tsch,
1.14 cvs 1582: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1583: #else
1584: static STRING ParseCSSTextTransform (element, tsch, context, cssRule, css, isHTML)
1585: Element element;
1586: PSchema tsch;
1587: PresentationContext context;
1588: STRING cssRule;
1589: CSSInfoPtr css;
1.14 cvs 1590: ThotBool isHTML;
1.1 cvs 1591: #endif
1592: {
1593: cssRule = SkipProperty (cssRule);
1594: return (cssRule);
1595: }
1596:
1597: /*----------------------------------------------------------------------
1598: ParseCSSVerticalAlign : parse a CSS vertical-align
1599: attribute string.
1600: ----------------------------------------------------------------------*/
1601: #ifdef __STDC__
1602: static STRING ParseCSSVerticalAlign (Element element, PSchema tsch,
1.14 cvs 1603: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1604: #else
1605: static STRING ParseCSSVerticalAlign (element, tsch, context, cssRule, css, isHTML)
1606: Element element;
1607: PSchema tsch;
1608: PresentationContext context;
1609: STRING cssRule;
1610: CSSInfoPtr css;
1.14 cvs 1611: ThotBool isHTML;
1.1 cvs 1612: #endif
1613: {
1614: cssRule = SkipProperty (cssRule);
1615: return (cssRule);
1616: }
1617:
1618: /*----------------------------------------------------------------------
1619: ParseCSSWhiteSpace : parse a CSS white-space
1620: attribute string.
1621: ----------------------------------------------------------------------*/
1622: #ifdef __STDC__
1623: static STRING ParseCSSWhiteSpace (Element element, PSchema tsch,
1.14 cvs 1624: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1625: #else
1626: static STRING ParseCSSWhiteSpace (element, tsch, context, cssRule, css, isHTML)
1627: Element element;
1628: PSchema tsch;
1629: PresentationContext context;
1630: STRING cssRule;
1631: CSSInfoPtr css;
1.14 cvs 1632: ThotBool isHTML;
1.1 cvs 1633: #endif
1634: {
1.13 cvs 1635: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 1636: if (!ustrncasecmp (cssRule, TEXT("normal"), 6))
1.1 cvs 1637: cssRule = SkipWord (cssRule);
1.17 cvs 1638: else if (!ustrncasecmp (cssRule, TEXT("pre"), 3))
1.1 cvs 1639: cssRule = SkipWord (cssRule);
1640: else
1641: return (cssRule);
1642: return (cssRule);
1643: }
1644:
1645: /*----------------------------------------------------------------------
1646: ParseCSSWordSpacing : parse a CSS word-spacing
1647: attribute string.
1648: ----------------------------------------------------------------------*/
1649: #ifdef __STDC__
1650: static STRING ParseCSSWordSpacing (Element element, PSchema tsch,
1.14 cvs 1651: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1652: #else
1653: static STRING ParseCSSWordSpacing (element, tsch, context, cssRule, css, isHTML)
1654: Element element;
1655: PSchema tsch;
1656: PresentationContext context;
1657: STRING cssRule;
1658: CSSInfoPtr css;
1.14 cvs 1659: ThotBool isHTML;
1.1 cvs 1660: #endif
1661: {
1662: cssRule = SkipProperty (cssRule);
1663: return (cssRule);
1664: }
1665:
1666: /*----------------------------------------------------------------------
1.25 cvs 1667: ParseCSSLineSpacing : parse a CSS font leading string
1668: we expect the input string describing the attribute to be
1669: value% or value
1670: ----------------------------------------------------------------------*/
1671: #ifdef __STDC__
1672: static STRING ParseCSSLineSpacing (Element element, PSchema tsch,
1673: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1674: #else
1675: static STRING ParseCSSLineSpacing (element, tsch, context, cssRule, css, isHTML)
1676: Element element;
1677: PSchema tsch;
1678: PresentationContext context;
1679: STRING cssRule;
1680: CSSInfoPtr css;
1681: ThotBool isHTML;
1682: #endif
1683: {
1684: PresentationValue lead;
1685:
1686: cssRule = ParseCSSUnit (cssRule, &lead);
1687: if (lead.typed_data.unit == STYLE_UNIT_INVALID)
1688: {
1689: /* invalid line spacing */
1690: return (cssRule);
1691: }
1692: /* install the new presentation */
1693: TtaSetStylePresentation (PRLineSpacing, element, tsch, context, lead);
1694: return (cssRule);
1695: }
1696:
1697: /*----------------------------------------------------------------------
1.1 cvs 1698: ParseCSSFontSize : parse a CSS font size attr string
1699: we expect the input string describing the attribute to be
1700: xx-small, x-small, small, medium, large, x-large, xx-large
1701: or an absolute size, or an imcrement relative to the parent
1702: ----------------------------------------------------------------------*/
1703: #ifdef __STDC__
1704: static STRING ParseCSSFontSize (Element element, PSchema tsch,
1.14 cvs 1705: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1706: #else
1707: static STRING ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML)
1708: Element element;
1709: PSchema tsch;
1710: PresentationContext context;
1711: STRING cssRule;
1712: CSSInfoPtr css;
1.14 cvs 1713: ThotBool isHTML;
1.1 cvs 1714: #endif
1715: {
1716: PresentationValue pval;
1.25 cvs 1717: STRING ptr = NULL;
1.14 cvs 1718: ThotBool real;
1.1 cvs 1719:
1720: pval.typed_data.real = FALSE;
1.13 cvs 1721: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 1722: if (!ustrncasecmp (cssRule, TEXT("larger"), 6))
1.1 cvs 1723: {
1724: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1725: pval.typed_data.value = 130;
1726: cssRule = SkipWord (cssRule);
1727: }
1.17 cvs 1728: else if (!ustrncasecmp (cssRule, TEXT("smaller"), 7))
1.1 cvs 1729: {
1730: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1731: pval.typed_data.value = 80;
1732: cssRule = SkipWord (cssRule);
1733: }
1.17 cvs 1734: else if (!ustrncasecmp (cssRule, TEXT("xx-small"), 8))
1.1 cvs 1735: {
1736: pval.typed_data.unit = STYLE_UNIT_REL;
1737: pval.typed_data.value = 1;
1738: cssRule = SkipWord (cssRule);
1739: }
1.17 cvs 1740: else if (!ustrncasecmp (cssRule, TEXT("x-small"), 7))
1.1 cvs 1741: {
1742: pval.typed_data.unit = STYLE_UNIT_REL;
1743: pval.typed_data.value = 2;
1744: cssRule = SkipWord (cssRule);
1745: }
1.17 cvs 1746: else if (!ustrncasecmp (cssRule, TEXT("small"), 5))
1.1 cvs 1747: {
1748: pval.typed_data.unit = STYLE_UNIT_REL;
1749: pval.typed_data.value = 3;
1750: cssRule = SkipWord (cssRule);
1751: }
1.17 cvs 1752: else if (!ustrncasecmp (cssRule, TEXT("medium"), 6))
1.1 cvs 1753: {
1754: pval.typed_data.unit = STYLE_UNIT_REL;
1755: pval.typed_data.value = 4;
1756: cssRule = SkipWord (cssRule);
1757: }
1.17 cvs 1758: else if (!ustrncasecmp (cssRule, TEXT("large"), 5))
1.1 cvs 1759: {
1760: pval.typed_data.unit = STYLE_UNIT_REL;
1761: pval.typed_data.value = 5;
1762: cssRule = SkipWord (cssRule);
1763: }
1.17 cvs 1764: else if (!ustrncasecmp (cssRule, TEXT("x-large"), 7))
1.1 cvs 1765: {
1766: pval.typed_data.unit = STYLE_UNIT_REL;
1767: pval.typed_data.value = 6;
1768: cssRule = SkipWord (cssRule);
1769: }
1.17 cvs 1770: else if (!ustrncasecmp (cssRule, TEXT("xx-large"), 8))
1.1 cvs 1771: {
1772: pval.typed_data.unit = STYLE_UNIT_REL;
1773: pval.typed_data.value = 7;
1774: cssRule = SkipWord (cssRule);
1775: }
1776: else
1777: {
1.25 cvs 1778: /* look for a '/' within the current cssRule */
1779: ptr = ustrchr (cssRule, TEXT('/'));
1780: if (ptr != NULL)
1781: {
1782: /* keep the line spacing rule */
1783: ptr[0] = EOS;
1784: ptr = &ptr[1];
1785: }
1.1 cvs 1786: cssRule = ParseCSSUnit (cssRule, &pval);
1787: if (pval.typed_data.unit == STYLE_UNIT_INVALID ||
1788: pval.typed_data.value < 0)
1789: return (cssRule);
1790: if (pval.typed_data.unit == STYLE_UNIT_REL && pval.typed_data.value > 0)
1791: /* CSS relative sizes have to be higher than Thot ones */
1792: pval.typed_data.value += 1;
1793: else
1794: {
1795: real = pval.typed_data.real;
1796: if (pval.typed_data.unit == STYLE_UNIT_EM)
1797: {
1798: if (real)
1799: {
1800: pval.typed_data.value /= 10;
1.11 cvs 1801: pval.typed_data.real = FALSE;
1.1 cvs 1802: real = FALSE;
1803: }
1804: else
1805: pval.typed_data.value *= 100;
1806: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1807: }
1808: }
1.25 cvs 1809:
1.1 cvs 1810: }
1811:
1.25 cvs 1812: /* install the presentation style */
1.1 cvs 1813: TtaSetStylePresentation (PRSize, element, tsch, context, pval);
1.25 cvs 1814:
1815: if (ptr != NULL)
1816: cssRule = ParseCSSLineSpacing (element, tsch, context, ptr, css, isHTML);
1.1 cvs 1817: return (cssRule);
1818: }
1819:
1820: /*----------------------------------------------------------------------
1821: ParseCSSFontFamily : parse a CSS font family string
1822: we expect the input string describing the attribute to be
1823: a common generic font style name
1824: ----------------------------------------------------------------------*/
1825: #ifdef __STDC__
1826: static STRING ParseCSSFontFamily (Element element, PSchema tsch,
1.14 cvs 1827: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1828: #else
1829: static STRING ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML)
1830: Element element;
1831: PSchema tsch;
1832: PresentationContext context;
1833: STRING cssRule;
1834: CSSInfoPtr css;
1.14 cvs 1835: ThotBool isHTML;
1.1 cvs 1836: #endif
1837: {
1838: PresentationValue font;
1.7 cvs 1839: CHAR_T quoteChar;
1.1 cvs 1840:
1841: font.typed_data.value = 0;
1842: font.typed_data.unit = STYLE_UNIT_REL;
1843: font.typed_data.real = FALSE;
1.13 cvs 1844: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1845: if (*cssRule == '"' || *cssRule == '\'')
1846: {
1847: quoteChar = *cssRule;
1848: cssRule++;
1849: }
1850: else
1851: quoteChar = '\0';
1852:
1.17 cvs 1853: if (!ustrncasecmp (cssRule, TEXT("times"), 5))
1.1 cvs 1854: font.typed_data.value = STYLE_FONT_TIMES;
1.17 cvs 1855: else if (!ustrncasecmp (cssRule, TEXT("serif"), 5))
1.1 cvs 1856: font.typed_data.value = STYLE_FONT_TIMES;
1.17 cvs 1857: else if (!ustrncasecmp (cssRule, TEXT("helvetica"), 9) ||
1858: !ustrncasecmp (cssRule, TEXT("verdana"), 7))
1.1 cvs 1859: font.typed_data.value = STYLE_FONT_HELVETICA;
1.17 cvs 1860: else if (!ustrncasecmp (cssRule, TEXT("sans-serif"), 10))
1.1 cvs 1861: font.typed_data.value = STYLE_FONT_HELVETICA;
1.17 cvs 1862: else if (!ustrncasecmp (cssRule, TEXT("courier"), 7))
1.1 cvs 1863: font.typed_data.value = STYLE_FONT_COURIER;
1.17 cvs 1864: else if (!ustrncasecmp (cssRule, TEXT("monospace"), 9))
1.1 cvs 1865: font.typed_data.value = STYLE_FONT_COURIER;
1866: else
1867: /* unknown font name. Skip it */
1868: {
1869: if (quoteChar)
1870: cssRule = SkipQuotedString (cssRule, quoteChar);
1871: else
1872: cssRule = SkipWord (cssRule);
1.13 cvs 1873: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 1874: if (*cssRule == ',')
1875: {
1876: cssRule++;
1877: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
1878: return (cssRule);
1879: }
1880: }
1881:
1882: if (font.typed_data.value != 0)
1883: {
1884: cssRule = SkipProperty (cssRule);
1885: /* install the new presentation */
1886: TtaSetStylePresentation (PRFont, element, tsch, context, font);
1887: }
1888: return (cssRule);
1889: }
1890:
1891: /*----------------------------------------------------------------------
1892: ParseCSSFontWeight : parse a CSS font weight string
1893: we expect the input string describing the attribute to be
1.20 cvs 1894: normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
1.1 cvs 1895: ----------------------------------------------------------------------*/
1896: #ifdef __STDC__
1897: static STRING ParseCSSFontWeight (Element element, PSchema tsch,
1.14 cvs 1898: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1899: #else
1900: static STRING ParseCSSFontWeight (element, tsch, context, cssRule, css, isHTML)
1901: Element element;
1902: PSchema tsch;
1903: PresentationContext context;
1904: STRING cssRule;
1905: CSSInfoPtr css;
1.14 cvs 1906: ThotBool isHTML;
1.1 cvs 1907: #endif
1908: {
1.20 cvs 1909: PresentationValue weight;
1.1 cvs 1910:
1911: weight.typed_data.value = 0;
1912: weight.typed_data.unit = STYLE_UNIT_REL;
1913: weight.typed_data.real = FALSE;
1.13 cvs 1914: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 1915: if (!ustrncasecmp (cssRule, TEXT("100"), 3) && !isalpha (cssRule[3]))
1.1 cvs 1916: {
1917: weight.typed_data.value = -3;
1918: cssRule = SkipWord (cssRule);
1919: }
1.17 cvs 1920: else if (!ustrncasecmp (cssRule, TEXT("200"), 3) && !isalpha (cssRule[3]))
1.1 cvs 1921: {
1922: weight.typed_data.value = -2;
1923: cssRule = SkipWord (cssRule);
1924: }
1.17 cvs 1925: else if (!ustrncasecmp (cssRule, TEXT("300"), 3) && !isalpha (cssRule[3]))
1.1 cvs 1926: {
1927: weight.typed_data.value = -1;
1928: cssRule = SkipWord (cssRule);
1929: }
1.17 cvs 1930: else if (!ustrncasecmp (cssRule, TEXT("normal"), 6) ||
1931: (!ustrncasecmp (cssRule, TEXT("400"), 3) && !isalpha (cssRule[3])))
1.1 cvs 1932: {
1933: weight.typed_data.value = 0;
1934: cssRule = SkipWord (cssRule);
1935: }
1.17 cvs 1936: else if (!ustrncasecmp (cssRule, TEXT("500"), 3) && !isalpha (cssRule[3]))
1.1 cvs 1937: {
1938: weight.typed_data.value = +1;
1939: cssRule = SkipWord (cssRule);
1940: }
1.17 cvs 1941: else if (!ustrncasecmp (cssRule, TEXT("600"), 3) && !isalpha (cssRule[3]))
1.1 cvs 1942: {
1943: weight.typed_data.value = +2;
1944: cssRule = SkipWord (cssRule);
1945: }
1.17 cvs 1946: else if (!ustrncasecmp (cssRule, TEXT("bold"), 4) ||
1947: (!ustrncasecmp (cssRule, TEXT("700"), 3) && !isalpha (cssRule[3])))
1.1 cvs 1948: {
1949: weight.typed_data.value = +3;
1950: cssRule = SkipWord (cssRule);
1951: }
1.17 cvs 1952: else if (!ustrncasecmp (cssRule, TEXT("800"), 3) && !isalpha (cssRule[3]))
1.1 cvs 1953: {
1954: weight.typed_data.value = +4;
1955: cssRule = SkipWord (cssRule);
1956: }
1.17 cvs 1957: else if (!ustrncasecmp (cssRule, TEXT("900"), 3) && !isalpha (cssRule[3]))
1.1 cvs 1958: {
1959: weight.typed_data.value = +5;
1960: cssRule = SkipWord (cssRule);
1961: }
1.17 cvs 1962: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7) ||
1963: !ustrncasecmp (cssRule, TEXT("bolder"), 6) ||
1964: !ustrncasecmp (cssRule, TEXT("lighter"), 7))
1.1 cvs 1965: {
1966: /* not implemented */
1967: cssRule = SkipWord (cssRule);
1968: return (cssRule);
1969: }
1970: else
1971: return (cssRule);
1972:
1973: /*
1.20 cvs 1974: * Here we have to reduce since only two font weight values are supported
1.1 cvs 1975: * by the Thot presentation API.
1976: */
1.20 cvs 1977: if (weight.typed_data.value > 0)
1978: weight.typed_data.value = STYLE_WEIGHT_BOLD;
1979: else
1980: weight.typed_data.value = STYLE_WEIGHT_NORMAL;
1.1 cvs 1981:
1982: /* install the new presentation */
1.21 cvs 1983: TtaSetStylePresentation (PRWeight, element, tsch, context, weight);
1.1 cvs 1984: return (cssRule);
1985: }
1986:
1987: /*----------------------------------------------------------------------
1988: ParseCSSFontVariant : parse a CSS font variant string
1989: we expect the input string describing the attribute to be
1990: normal or small-caps
1991: ----------------------------------------------------------------------*/
1992: #ifdef __STDC__
1993: static STRING ParseCSSFontVariant (Element element, PSchema tsch,
1.14 cvs 1994: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1995: #else
1996: static STRING ParseCSSFontVariant (element, tsch, context, cssRule, css, isHTML)
1997: Element element;
1998: PSchema tsch;
1999: PresentationContext context;
2000: STRING cssRule;
2001: CSSInfoPtr css;
1.14 cvs 2002: ThotBool isHTML;
1.1 cvs 2003: #endif
2004: {
2005: PresentationValue style;
2006:
2007: style.typed_data.value = 0;
2008: style.typed_data.unit = STYLE_UNIT_REL;
2009: style.typed_data.real = FALSE;
1.13 cvs 2010: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 2011: if (!ustrncasecmp (cssRule, TEXT("small-caps"), 10))
1.1 cvs 2012: {
2013: /* Not supported yet */
2014: cssRule = SkipWord (cssRule);
2015: }
1.17 cvs 2016: else if (!ustrncasecmp (cssRule, TEXT("normal"), 6))
1.1 cvs 2017: {
2018: /* Not supported yet */
2019: cssRule = SkipWord (cssRule);
2020: }
1.17 cvs 2021: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))
1.1 cvs 2022: {
2023: /* Not supported yet */
2024: cssRule = SkipWord (cssRule);
2025: }
2026: else
2027: return (cssRule);
2028:
2029: return (cssRule);
2030: }
2031:
2032:
2033: /*----------------------------------------------------------------------
2034: ParseCSSFontStyle : parse a CSS font style string
2035: we expect the input string describing the attribute to be
2036: italic, oblique or normal
2037: ----------------------------------------------------------------------*/
2038: #ifdef __STDC__
2039: static STRING ParseCSSFontStyle (Element element, PSchema tsch,
1.14 cvs 2040: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2041: #else
2042: static STRING ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML)
2043: Element element;
2044: PSchema tsch;
2045: PresentationContext context;
2046: STRING cssRule;
2047: CSSInfoPtr css;
1.14 cvs 2048: ThotBool isHTML;
1.1 cvs 2049: #endif
2050: {
2051: PresentationValue style;
2052: PresentationValue size;
2053:
2054: style.typed_data.value = 0;
2055: style.typed_data.unit = STYLE_UNIT_REL;
2056: style.typed_data.real = FALSE;
2057: size.typed_data.value = 0;
2058: size.typed_data.unit = STYLE_UNIT_REL;
2059: size.typed_data.real = FALSE;
1.13 cvs 2060: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 2061: if (!ustrncasecmp (cssRule, TEXT("italic"), 6))
1.1 cvs 2062: {
2063: style.typed_data.value = STYLE_FONT_ITALICS;
2064: cssRule = SkipWord (cssRule);
2065: }
1.17 cvs 2066: else if (!ustrncasecmp (cssRule, TEXT("oblique"), 7))
1.1 cvs 2067: {
2068: style.typed_data.value = STYLE_FONT_OBLIQUE;
2069: cssRule = SkipWord (cssRule);
2070: }
1.17 cvs 2071: else if (!ustrncasecmp (cssRule, TEXT("normal"), 6))
1.1 cvs 2072: {
2073: style.typed_data.value = STYLE_FONT_ROMAN;
2074: cssRule = SkipWord (cssRule);
2075: }
2076: else
2077: {
2078: /* invalid font style */
2079: return (cssRule);
2080: }
2081:
2082: /*
2083: * install the new presentation.
2084: */
2085: if (style.typed_data.value != 0)
1.20 cvs 2086: TtaSetStylePresentation (PRStyle, element, tsch, context, style);
1.1 cvs 2087: if (size.typed_data.value != 0)
2088: {
2089: PresentationValue previous_size;
2090:
2091: if (!TtaGetStylePresentation (PRSize, element, tsch, context, &previous_size))
2092: {
2093: /* !!!!!!!!!!!!!!!!!!!!!!!! Unite + relatif !!!!!!!!!!!!!!!! */
2094: size.typed_data.value += previous_size.typed_data.value;
2095: TtaSetStylePresentation (PRSize, element, tsch, context, size);
2096: }
2097: else
2098: {
2099: size.typed_data.value = 10;
2100: TtaSetStylePresentation (PRSize, element, tsch, context, size);
2101: }
2102: }
2103: return (cssRule);
2104: }
2105:
2106: /*----------------------------------------------------------------------
2107: ParseCSSFont : parse a CSS font attribute string
2108: we expect the input string describing the attribute to be
2109: !!!!!!
2110: ----------------------------------------------------------------------*/
2111: #ifdef __STDC__
2112: static STRING ParseCSSFont (Element element, PSchema tsch,
1.14 cvs 2113: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2114: #else
2115: static STRING ParseCSSFont (element, tsch, context, cssRule, css, isHTML)
2116: Element element;
2117: PSchema tsch;
2118: PresentationContext context;
2119: STRING cssRule;
2120: CSSInfoPtr css;
1.14 cvs 2121: ThotBool isHTML;
1.1 cvs 2122: #endif
2123: {
2124: STRING ptr;
2125:
1.13 cvs 2126: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 2127: if (!ustrncasecmp (cssRule, TEXT("caption"), 7))
1.1 cvs 2128: ;
1.17 cvs 2129: else if (!ustrncasecmp (cssRule, TEXT("icon"), 4))
1.1 cvs 2130: ;
1.17 cvs 2131: else if (!ustrncasecmp (cssRule, TEXT("menu"), 4))
1.1 cvs 2132: ;
1.17 cvs 2133: else if (!ustrncasecmp (cssRule, TEXT("message-box"), 11))
1.1 cvs 2134: ;
1.17 cvs 2135: else if (!ustrncasecmp (cssRule, TEXT("small-caption"), 13))
1.1 cvs 2136: ;
1.17 cvs 2137: else if (!ustrncasecmp (cssRule, TEXT("status-bar"), 10))
1.1 cvs 2138: ;
2139: else
1.43 cvs 2140: {
2141: ptr = cssRule;
2142: cssRule = ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML);
2143: if (ptr == cssRule)
2144: cssRule = ParseCSSFontVariant (element, tsch, context, cssRule, css, isHTML);
2145: if (ptr == cssRule)
2146: cssRule = ParseCSSFontWeight (element, tsch, context, cssRule, css, isHTML);
2147: cssRule = ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML);
2148: if (*cssRule == '/')
2149: {
2150: cssRule++;
2151: SkipBlanksAndComments (cssRule);
2152: cssRule = SkipWord (cssRule);
2153: }
2154: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
2155: cssRule = SkipBlanksAndComments (cssRule);
2156: while (*cssRule != ';' && *cssRule != EOS)
2157: {
2158: /* now skip remainding info */
2159: cssRule++;
2160: }
2161: }
2162: return (cssRule);
1.1 cvs 2163: }
2164:
2165: /*----------------------------------------------------------------------
2166: ParseCSSTextDecoration : parse a CSS text decor string
2167: we expect the input string describing the attribute to be
2168: underline, overline, line-through, box, shadowbox, box3d,
2169: cartouche, blink or none
2170: ----------------------------------------------------------------------*/
2171: #ifdef __STDC__
2172: static STRING ParseCSSTextDecoration (Element element, PSchema tsch,
1.14 cvs 2173: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2174: #else
2175: static STRING ParseCSSTextDecoration (element, tsch, context, cssRule, css, isHTML)
2176: Element element;
2177: PSchema tsch;
2178: PresentationContext context;
2179: STRING cssRule;
2180: CSSInfoPtr css;
1.14 cvs 2181: ThotBool isHTML;
1.1 cvs 2182: #endif
2183: {
2184: PresentationValue decor;
2185:
2186: decor.typed_data.value = 0;
2187: decor.typed_data.unit = STYLE_UNIT_REL;
2188: decor.typed_data.real = FALSE;
1.13 cvs 2189: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 2190: if (!ustrncasecmp (cssRule, TEXT("underline"), ustrlen (TEXT("underline"))))
1.1 cvs 2191: {
2192: decor.typed_data.value = Underline;
2193: cssRule = SkipWord (cssRule);
2194: }
1.17 cvs 2195: else if (!ustrncasecmp (cssRule, TEXT("overline"), ustrlen (TEXT("overline"))))
1.1 cvs 2196: {
2197: decor.typed_data.value = Overline;
2198: cssRule = SkipWord (cssRule);
2199: }
1.17 cvs 2200: else if (!ustrncasecmp (cssRule, TEXT("line-through"), ustrlen (TEXT("line-through"))))
1.1 cvs 2201: {
2202: decor.typed_data.value = CrossOut;
2203: cssRule = SkipWord (cssRule);
2204: }
1.17 cvs 2205: else if (!ustrncasecmp (cssRule, TEXT("box"), ustrlen (TEXT("box"))))
1.1 cvs 2206: {
2207: /* the box text-decoration attribute is not yet supported */
2208: cssRule = SkipWord (cssRule);
2209: }
1.17 cvs 2210: else if (!ustrncasecmp (cssRule, TEXT("boxshadow"), ustrlen (TEXT("boxshadow"))))
1.1 cvs 2211: {
2212: /* the boxshadow text-decoration attribute is not yet supported */
2213: cssRule = SkipWord (cssRule);
2214: }
1.17 cvs 2215: else if (!ustrncasecmp (cssRule, TEXT("box3d"), ustrlen (TEXT("box3d"))))
1.1 cvs 2216: {
2217: /* the box3d text-decoration attribute is not yet supported */
2218: cssRule = SkipWord (cssRule);
2219: }
1.17 cvs 2220: else if (!ustrncasecmp (cssRule, TEXT("cartouche"), ustrlen (TEXT("cartouche"))))
1.1 cvs 2221: {
2222: /*the cartouche text-decoration attribute is not yet supported */
2223: cssRule = SkipWord (cssRule);
2224: }
1.17 cvs 2225: else if (!ustrncasecmp (cssRule, TEXT("blink"), ustrlen (TEXT("blink"))))
1.1 cvs 2226: {
2227: /*the blink text-decoration attribute will not be supported */
2228: cssRule = SkipWord (cssRule);
2229: }
1.17 cvs 2230: else if (!ustrncasecmp (cssRule, TEXT("none"), ustrlen (TEXT("none"))))
1.1 cvs 2231: {
2232: decor.typed_data.value = NoUnderline;
2233: cssRule = SkipWord (cssRule);
2234: }
2235: else
2236: {
2237: fprintf (stderr, "invalid text decoration\n");
2238: return (cssRule);
2239: }
2240:
2241: /*
2242: * install the new presentation.
2243: */
2244: if (decor.typed_data.value)
2245: {
2246: TtaSetStylePresentation (PRUnderline, element, tsch, context, decor);
2247: }
2248: return (cssRule);
2249: }
2250:
2251: /*----------------------------------------------------------------------
2252: ParseCSSHeight : parse a CSS height attribute
2253: ----------------------------------------------------------------------*/
2254: #ifdef __STDC__
2255: static STRING ParseCSSHeight (Element element, PSchema tsch,
1.14 cvs 2256: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2257: #else
2258: static STRING ParseCSSHeight (element, tsch, context, cssRule, css, isHTML)
2259: Element element;
2260: PSchema tsch;
2261: PresentationContext context;
2262: STRING cssRule;
2263: CSSInfoPtr css;
1.14 cvs 2264: ThotBool isHTML;
1.1 cvs 2265: #endif
2266: {
1.13 cvs 2267: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2268:
2269: /* first parse the attribute string */
1.17 cvs 2270: if (!ustrcasecmp (cssRule, TEXT("auto")))
1.1 cvs 2271: {
2272: cssRule = SkipWord (cssRule);
2273: /* ParseCSSHeight : auto */
2274: return (cssRule);
2275: }
2276: else
2277: cssRule = SkipProperty (cssRule);
2278: return (cssRule);
2279: }
2280:
2281: /*----------------------------------------------------------------------
2282: ParseCSSWidth : parse a CSS width attribute
2283: ----------------------------------------------------------------------*/
2284: #ifdef __STDC__
2285: static STRING ParseCSSWidth (Element element, PSchema tsch,
1.14 cvs 2286: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2287: #else
2288: static STRING ParseCSSWidth (element, tsch, context, cssRule, css, isHTML)
2289: Element element;
2290: PSchema tsch;
2291: PresentationContext context;
2292: STRING cssRule;
2293: CSSInfoPtr css;
1.14 cvs 2294: ThotBool isHTML;
1.1 cvs 2295: #endif
2296: {
1.13 cvs 2297: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2298:
2299: /* first parse the attribute string */
1.17 cvs 2300: if (!ustrcasecmp (cssRule, TEXT("auto")))
1.1 cvs 2301: {
2302: cssRule = SkipWord (cssRule);
2303: return (cssRule);
2304: }
2305: else
2306: cssRule = SkipProperty (cssRule);
2307: return (cssRule);
2308: }
2309:
2310: /*----------------------------------------------------------------------
2311: ParseCSSMarginTop : parse a CSS margin-top attribute
2312: ----------------------------------------------------------------------*/
2313: #ifdef __STDC__
2314: static STRING ParseCSSMarginTop (Element element, PSchema tsch,
1.14 cvs 2315: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2316: #else
2317: static STRING ParseCSSMarginTop (element, tsch, context, cssRule, css, isHTML)
2318: Element element;
2319: PSchema tsch;
2320: PresentationContext context;
2321: STRING cssRule;
2322: CSSInfoPtr css;
1.14 cvs 2323: ThotBool isHTML;
1.1 cvs 2324: #endif
2325: {
2326: PresentationValue margin;
2327:
1.13 cvs 2328: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2329: /* first parse the attribute string */
2330: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 2331: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
1.1 cvs 2332: {
1.40 cvs 2333: TtaSetStylePresentation (PRMarginTop, element, tsch, context, margin);
1.1 cvs 2334: if (margin.typed_data.value < 0)
2335: TtaSetStylePresentation (PRVertOverflow, element, tsch, context, margin);
2336: }
2337: return (cssRule);
2338: }
2339:
2340: /*----------------------------------------------------------------------
2341: ParseCSSMarginBottom : parse a CSS margin-bottom
2342: attribute
2343: ----------------------------------------------------------------------*/
2344: #ifdef __STDC__
2345: static STRING ParseCSSMarginBottom (Element element, PSchema tsch,
1.14 cvs 2346: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2347: #else
2348: static STRING ParseCSSMarginBottom (element, tsch, context, cssRule, css, isHTML)
2349: Element element;
2350: PSchema tsch;
2351: PresentationContext context;
2352: STRING cssRule;
2353: CSSInfoPtr css;
1.14 cvs 2354: ThotBool isHTML;
1.1 cvs 2355: #endif
2356: {
2357: PresentationValue margin;
2358:
1.13 cvs 2359: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2360: /* first parse the attribute string */
2361: cssRule = ParseCSSUnit (cssRule, &margin);
2362: margin.typed_data.value = - margin.typed_data.value;
1.43 cvs 2363: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
2364: TtaSetStylePresentation (PRMarginBottom, element, tsch, context, margin);
1.1 cvs 2365: return (cssRule);
2366: }
2367:
2368: /*----------------------------------------------------------------------
2369: ParseCSSMarginLeft : parse a CSS margin-left
2370: attribute string.
2371: ----------------------------------------------------------------------*/
2372: #ifdef __STDC__
2373: static STRING ParseCSSMarginLeft (Element element, PSchema tsch,
1.14 cvs 2374: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2375: #else
2376: static STRING ParseCSSMarginLeft (element, tsch, context, cssRule, css, isHTML)
2377: Element element;
2378: PSchema tsch;
2379: PresentationContext context;
2380: STRING cssRule;
2381: CSSInfoPtr css;
1.14 cvs 2382: ThotBool isHTML;
1.1 cvs 2383: #endif
2384: {
2385: PresentationValue margin;
2386:
1.13 cvs 2387: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2388: /* first parse the attribute string */
2389: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 2390: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
1.1 cvs 2391: {
1.40 cvs 2392: TtaSetStylePresentation (PRMarginLeft, element, tsch, context, margin);
1.1 cvs 2393: if (margin.typed_data.value < 0)
2394: TtaSetStylePresentation (PRHorizOverflow, element, tsch, context, margin);
2395: }
2396: return (cssRule);
2397: }
2398:
2399: /*----------------------------------------------------------------------
2400: ParseCSSMarginRight : parse a CSS margin-right
2401: attribute string.
2402: ----------------------------------------------------------------------*/
2403: #ifdef __STDC__
2404: static STRING ParseCSSMarginRight (Element element, PSchema tsch,
1.14 cvs 2405: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2406: #else
2407: static STRING ParseCSSMarginRight (element, tsch, context, cssRule, css, isHTML)
2408: Element element;
2409: PSchema tsch;
2410: PresentationContext context;
2411: STRING cssRule;
2412: CSSInfoPtr css;
1.14 cvs 2413: ThotBool isHTML;
1.1 cvs 2414: #endif
2415: {
2416: PresentationValue margin;
2417:
1.13 cvs 2418: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2419: /* first parse the attribute string */
2420: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 2421: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
2422: TtaSetStylePresentation (PRMarginRight, element, tsch, context, margin);
1.1 cvs 2423: return (cssRule);
2424: }
2425:
2426: /*----------------------------------------------------------------------
2427: ParseCSSMargin : parse a CSS margin attribute string.
2428: ----------------------------------------------------------------------*/
2429: #ifdef __STDC__
2430: static STRING ParseCSSMargin (Element element, PSchema tsch,
1.14 cvs 2431: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2432: #else
2433: static STRING ParseCSSMargin (element, tsch, context, cssRule, css, isHTML)
2434: Element element;
2435: PSchema tsch;
2436: PresentationContext context;
2437: STRING cssRule;
2438: CSSInfoPtr css;
1.14 cvs 2439: ThotBool isHTML;
1.1 cvs 2440: #endif
2441: {
2442: STRING ptrT, ptrR, ptrB, ptrL;
2443:
1.13 cvs 2444: ptrT = SkipBlanksAndComments (cssRule);
1.1 cvs 2445: /* First parse Margin-Top */
2446: ptrR = ParseCSSMarginTop (element, tsch, context, ptrT, css, isHTML);
1.13 cvs 2447: ptrR = SkipBlanksAndComments (ptrR);
1.1 cvs 2448: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
2449: {
2450: cssRule = ptrR;
2451: /* apply the Margin-Top to all */
2452: ptrR = ParseCSSMarginRight (element, tsch, context, ptrT, css, isHTML);
2453: ptrR = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
2454: ptrR = ParseCSSMarginLeft (element, tsch, context, ptrT, css, isHTML);
2455: }
2456: else
2457: {
2458: /* parse Margin-Right */
2459: ptrB = ParseCSSMarginRight (element, tsch, context, ptrR, css, isHTML);
1.13 cvs 2460: ptrB = SkipBlanksAndComments (ptrB);
1.1 cvs 2461: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
2462: {
2463: cssRule = ptrB;
2464: /* apply the Margin-Top to Margin-Bottom */
2465: ptrB = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
2466: /* apply the Margin-Right to Margin-Left */
2467: ptrB = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2468: }
2469: else
2470: {
2471: /* parse Margin-Bottom */
2472: ptrL = ParseCSSMarginBottom (element, tsch, context, ptrB, css, isHTML);
1.13 cvs 2473: ptrL = SkipBlanksAndComments (ptrL);
1.1 cvs 2474: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
2475: {
2476: cssRule = ptrL;
2477: /* apply the Margin-Right to Margin-Left */
2478: ptrL = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2479: }
2480: else
2481: /* parse Margin-Left */
2482: cssRule = ParseCSSMarginLeft (element, tsch, context, ptrL, css, isHTML);
1.13 cvs 2483: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2484: }
2485: }
2486: return (cssRule);
2487: }
2488:
2489: /*----------------------------------------------------------------------
2490: ParseCSSPaddingTop : parse a CSS PaddingTop
2491: attribute string.
2492: ----------------------------------------------------------------------*/
2493: #ifdef __STDC__
2494: static STRING ParseCSSPaddingTop (Element element, PSchema tsch,
1.14 cvs 2495: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2496: #else
2497: static STRING ParseCSSPaddingTop (element, tsch, context, cssRule, css, isHTML)
2498: Element element;
2499: PSchema tsch;
2500: PresentationContext context;
2501: STRING cssRule;
2502: CSSInfoPtr css;
1.14 cvs 2503: ThotBool isHTML;
1.1 cvs 2504: #endif
2505: {
1.43 cvs 2506: PresentationValue padding;
2507:
2508: cssRule = SkipBlanksAndComments (cssRule);
2509: /* first parse the attribute string */
2510: cssRule = ParseCSSUnit (cssRule, &padding);
2511: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2512: TtaSetStylePresentation (PRPaddingTop, element, tsch, context, padding);
1.1 cvs 2513: return (cssRule);
2514: }
2515:
2516: /*----------------------------------------------------------------------
1.43 cvs 2517: ParseCSSPaddingBottom : parse a CSS PaddingBottom
1.1 cvs 2518: attribute string.
2519: ----------------------------------------------------------------------*/
2520: #ifdef __STDC__
1.43 cvs 2521: static STRING ParseCSSPaddingBottom (Element element, PSchema tsch,
1.14 cvs 2522: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2523: #else
1.43 cvs 2524: static STRING ParseCSSPaddingBottom (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2525: Element element;
2526: PSchema tsch;
2527: PresentationContext context;
2528: STRING cssRule;
2529: CSSInfoPtr css;
1.14 cvs 2530: ThotBool isHTML;
1.1 cvs 2531: #endif
2532: {
1.43 cvs 2533: PresentationValue padding;
2534:
2535: cssRule = SkipBlanksAndComments (cssRule);
2536: /* first parse the attribute string */
2537: cssRule = ParseCSSUnit (cssRule, &padding);
2538: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2539: TtaSetStylePresentation (PRPaddingBottom, element, tsch, context, padding);
1.1 cvs 2540: return (cssRule);
2541: }
2542:
2543: /*----------------------------------------------------------------------
1.43 cvs 2544: ParseCSSPaddingLeft : parse a CSS PaddingLeft
1.1 cvs 2545: attribute string.
2546: ----------------------------------------------------------------------*/
2547: #ifdef __STDC__
1.43 cvs 2548: static STRING ParseCSSPaddingLeft (Element element, PSchema tsch,
1.14 cvs 2549: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2550: #else
1.43 cvs 2551: static STRING ParseCSSPaddingLeft (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2552: Element element;
2553: PSchema tsch;
2554: PresentationContext context;
2555: STRING cssRule;
2556: CSSInfoPtr css;
1.14 cvs 2557: ThotBool isHTML;
1.1 cvs 2558: #endif
2559: {
1.43 cvs 2560: PresentationValue padding;
2561:
2562: cssRule = SkipBlanksAndComments (cssRule);
2563: /* first parse the attribute string */
2564: cssRule = ParseCSSUnit (cssRule, &padding);
2565: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2566: TtaSetStylePresentation (PRPaddingLeft, element, tsch, context, padding);
1.1 cvs 2567: return (cssRule);
2568: }
2569:
2570: /*----------------------------------------------------------------------
1.43 cvs 2571: ParseCSSPaddingRight : parse a CSS PaddingRight
1.1 cvs 2572: attribute string.
2573: ----------------------------------------------------------------------*/
2574: #ifdef __STDC__
1.43 cvs 2575: static STRING ParseCSSPaddingRight (Element element, PSchema tsch,
1.14 cvs 2576: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2577: #else
1.43 cvs 2578: static STRING ParseCSSPaddingRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2579: Element element;
2580: PSchema tsch;
2581: PresentationContext context;
2582: STRING cssRule;
2583: CSSInfoPtr css;
1.14 cvs 2584: ThotBool isHTML;
1.1 cvs 2585: #endif
2586: {
1.43 cvs 2587: PresentationValue padding;
2588:
2589: cssRule = SkipBlanksAndComments (cssRule);
2590: /* first parse the attribute string */
2591: cssRule = ParseCSSUnit (cssRule, &padding);
2592: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2593: TtaSetStylePresentation (PRPaddingRight, element, tsch, context, padding);
1.1 cvs 2594: return (cssRule);
2595: }
2596:
2597: /*----------------------------------------------------------------------
2598: ParseCSSPadding : parse a CSS padding attribute string.
2599: ----------------------------------------------------------------------*/
2600: #ifdef __STDC__
2601: static STRING ParseCSSPadding (Element element, PSchema tsch,
1.14 cvs 2602: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2603: #else
2604: static STRING ParseCSSPadding (element, tsch, context, cssRule, css, isHTML)
2605: Element element;
2606: PSchema tsch;
2607: PresentationContext context;
2608: STRING cssRule;
2609: CSSInfoPtr css;
1.14 cvs 2610: ThotBool isHTML;
1.1 cvs 2611: #endif
2612: {
1.43 cvs 2613: STRING ptrT, ptrR, ptrB, ptrL;
2614:
2615: ptrT = SkipBlanksAndComments (cssRule);
2616: /* First parse Padding-Top */
2617: ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
2618: ptrR = SkipBlanksAndComments (ptrR);
2619: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
2620: {
2621: cssRule = ptrR;
2622: /* apply the Padding-Top to all */
2623: ptrR = ParseCSSPaddingRight (element, tsch, context, ptrT, css, isHTML);
2624: ptrR = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
2625: ptrR = ParseCSSPaddingLeft (element, tsch, context, ptrT, css, isHTML);
2626: }
2627: else
2628: {
2629: /* parse Padding-Right */
2630: ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);
2631: ptrB = SkipBlanksAndComments (ptrB);
2632: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
2633: {
2634: cssRule = ptrB;
2635: /* apply the Padding-Top to Padding-Bottom */
2636: ptrB = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
2637: /* apply the Padding-Right to Padding-Left */
2638: ptrB = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2639: }
2640: else
2641: {
2642: /* parse Padding-Bottom */
2643: ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);
2644: ptrL = SkipBlanksAndComments (ptrL);
2645: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
2646: {
2647: cssRule = ptrL;
2648: /* apply the Padding-Right to Padding-Left */
2649: ptrL = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2650: }
2651: else
2652: /* parse Padding-Left */
2653: cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);
2654: cssRule = SkipBlanksAndComments (cssRule);
2655: }
2656: }
1.1 cvs 2657: return (cssRule);
2658: }
2659:
2660: /*----------------------------------------------------------------------
2661: ParseCSSForeground : parse a CSS foreground attribute
2662: ----------------------------------------------------------------------*/
2663: #ifdef __STDC__
2664: static STRING ParseCSSForeground (Element element, PSchema tsch,
1.14 cvs 2665: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2666: #else
2667: static STRING ParseCSSForeground (element, tsch, context, cssRule, css, isHTML)
2668: Element element;
2669: PSchema tsch;
2670: PresentationContext context;
2671: STRING cssRule;
2672: CSSInfoPtr css;
1.14 cvs 2673: ThotBool isHTML;
1.1 cvs 2674: #endif
2675: {
2676: PresentationValue best;
2677:
2678: cssRule = ParseCSSColor (cssRule, &best);
1.25 cvs 2679: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2680: /* install the new presentation */
2681: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
1.1 cvs 2682: return (cssRule);
2683: }
2684:
2685: /*----------------------------------------------------------------------
2686: ParseCSSBackgroundColor : parse a CSS background color attribute
2687: ----------------------------------------------------------------------*/
2688: #ifdef __STDC__
2689: static STRING ParseCSSBackgroundColor (Element element, PSchema tsch,
1.14 cvs 2690: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2691: #else
2692: static STRING ParseCSSBackgroundColor (element, tsch, context, cssRule, css, isHTML)
2693: Element element;
2694: PSchema tsch;
2695: PresentationContext context;
2696: STRING cssRule;
2697: CSSInfoPtr css;
1.14 cvs 2698: ThotBool isHTML;
1.1 cvs 2699: #endif
2700: {
2701: PresentationValue best;
2702: unsigned int savedtype = 0;
1.14 cvs 2703: ThotBool moved;
1.1 cvs 2704:
2705: /* move the BODY rule to the HTML element */
2706: moved = (context->type == HTML_EL_BODY && isHTML);
2707: if (moved)
2708: {
2709: if (element)
2710: element = TtaGetMainRoot (context->doc);
2711: else
2712: {
2713: savedtype = context->type;
2714: context->type = HTML_EL_HTML;
2715: }
2716: }
2717:
2718: best.typed_data.unit = STYLE_UNIT_INVALID;
2719: best.typed_data.real = FALSE;
1.17 cvs 2720: if (!ustrncasecmp (cssRule, TEXT("transparent"), ustrlen (TEXT("transparent"))))
1.1 cvs 2721: {
2722: best.typed_data.value = STYLE_PATTERN_NONE;
2723: best.typed_data.unit = STYLE_UNIT_REL;
2724: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2725: }
2726: else
2727: {
2728: cssRule = ParseCSSColor (cssRule, &best);
2729: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2730: {
2731: /* install the new presentation. */
2732: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
2733: /* thot specificity : need to set fill pattern for background color */
2734: best.typed_data.value = STYLE_PATTERN_BACKGROUND;
2735: best.typed_data.unit = STYLE_UNIT_REL;
2736: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2737: best.typed_data.value = 1;
2738: best.typed_data.unit = STYLE_UNIT_REL;
2739: TtaSetStylePresentation (PRShowBox, element, tsch, context, best);
2740: }
2741: }
2742: cssRule = SkipWord (cssRule);
2743:
2744: /* restore the refered element */
2745: if (moved && !element)
2746: context->type = savedtype;
2747: return (cssRule);
2748: }
2749:
2750: /*----------------------------------------------------------------------
2751: ParseCSSBackgroundImageCallback : Callback called asynchronously by
2752: FetchImage when a background image has been fetched.
2753: ----------------------------------------------------------------------*/
2754: #ifdef __STDC__
2755: void ParseCSSBackgroundImageCallback (Document doc, Element element, STRING file,
2756: void *extra)
2757: #else
2758: void ParseCSSBackgroundImageCallback (doc, element, file, extra)
2759: Document doc;
2760: Element element;
2761: STRING file;
2762: void *extra;
2763: #endif
2764: {
1.34 cvs 2765: DisplayMode dispMode;
2766: BackgroundImageCallbackPtr callblock = (BackgroundImageCallbackPtr) extra;
2767: Element el;
2768: PSchema tsch;
2769: PresentationContext context;
2770: PresentationValue image;
2771: PresentationValue repeat;
2772: PresentationValue value;
1.1 cvs 2773:
1.34 cvs 2774: if (callblock == NULL)
2775: return;
1.1 cvs 2776:
1.34 cvs 2777: /* avoid too many redisplay */
2778: dispMode = TtaGetDisplayMode (doc);
2779: if (dispMode == DisplayImmediately)
2780: TtaSetDisplayMode (doc, DeferredDisplay);
2781:
2782: el = callblock->el;
2783: tsch = callblock->tsch;
2784: context = &callblock->context.specific;
2785:
2786: /* Ok the image was fetched, finish the background-image handling */
2787: image.pointer = file;
2788: TtaSetStylePresentation (PRBackgroundPicture, el, tsch, context, image);
1.1 cvs 2789:
1.34 cvs 2790: /* If there is no default repeat mode, enforce a V-Repeat */
2791: if (TtaGetStylePresentation (PRPictureMode, el, tsch, context, &repeat) < 0)
2792: {
2793: repeat.typed_data.value = STYLE_REPEAT;
2794: repeat.typed_data.unit = STYLE_UNIT_REL;
2795: repeat.typed_data.real = FALSE;
2796: TtaSetStylePresentation (PRPictureMode, el, tsch, context, repeat);
2797: }
2798:
2799: /* If there is no default repeat mode, enforce a V-Repeat */
2800: value.typed_data.value = 1;
2801: value.typed_data.unit = STYLE_UNIT_REL;
2802: value.typed_data.real = FALSE;
2803: TtaSetStylePresentation (PRShowBox, el, tsch, context, value);
2804:
2805: TtaFreeMemory (callblock);
2806: /* restore the display mode */
2807: if (dispMode == DisplayImmediately)
2808: TtaSetDisplayMode (doc, dispMode);
1.1 cvs 2809: }
2810:
2811:
2812: /*----------------------------------------------------------------------
2813: GetCSSBackgroundURL searches a CSS BackgroundImage url within
2814: the styleString.
2815: Returns NULL or a new allocated url string.
2816: ----------------------------------------------------------------------*/
2817: #ifdef __STDC__
2818: STRING GetCSSBackgroundURL (STRING styleString)
2819: #else
2820: STRING GetCSSBackgroundURL (styleString)
2821: STRING styleString;
2822: #endif
2823: {
2824: STRING b, e, ptr;
2825: int len;
2826:
2827: ptr = NULL;
1.17 cvs 2828: b = ustrstr (styleString, TEXT("url"));
1.1 cvs 2829: if (b != NULL)
2830: {
2831: b += 3;
1.13 cvs 2832: b = SkipBlanksAndComments (b);
1.1 cvs 2833: if (*b == '(')
2834: {
2835: b++;
1.13 cvs 2836: b = SkipBlanksAndComments (b);
1.1 cvs 2837: /*** Caution: Strings can either be written with double quotes or
2838: with single quotes. Only double quotes are handled here.
2839: Escaped quotes are not handled. See function SkipQuotedString */
2840: if (*b == '"')
2841: {
2842: b++;
2843: /* search the url end */
2844: e = b;
2845: while (*e != EOS && *e != '"')
2846: e++;
2847: }
2848: else
2849: {
2850: /* search the url end */
2851: e = b;
2852: while (*e != EOS && *e != ')')
2853: e++;
2854: }
2855: if (*e != EOS)
2856: {
2857: len = (int)(e - b);
2858: ptr = (STRING) TtaGetMemory (len+1);
2859: ustrncpy (ptr, b, len);
2860: ptr[len] = EOS;
2861: }
2862: }
2863: }
2864: return (ptr);
2865: }
2866:
2867:
2868: /*----------------------------------------------------------------------
2869: ParseCSSBackgroundImage : parse a CSS BackgroundImage
2870: attribute string.
2871: ----------------------------------------------------------------------*/
2872: #ifdef __STDC__
2873: static STRING ParseCSSBackgroundImage (Element element, PSchema tsch,
1.14 cvs 2874: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2875: #else
2876: static STRING ParseCSSBackgroundImage (element, tsch, context, cssRule, css, isHTML)
2877: Element element;
2878: PSchema tsch;
2879: PresentationContext context;
2880: STRING cssRule;
2881: CSSInfoPtr css;
1.14 cvs 2882: ThotBool isHTML;
1.1 cvs 2883: #endif
2884: {
2885: Element el;
2886: GenericContext gblock;
2887: PresentationContextBlock *sblock;
2888: BackgroundImageCallbackPtr callblock;
2889: PresentationValue image, value;
2890: STRING url;
2891: STRING bg_image;
1.25 cvs 2892: CHAR_T saved;
1.1 cvs 2893: STRING base;
1.25 cvs 2894: CHAR_T tempname[MAX_LENGTH];
2895: CHAR_T imgname[MAX_LENGTH];
1.1 cvs 2896: unsigned int savedtype = 0;
1.14 cvs 2897: ThotBool moved;
1.1 cvs 2898:
2899: /* default element for FetchImage */
2900: el = TtaGetMainRoot (context->doc);
2901: /* move the BODY rule to the HTML element */
2902: moved = (context->type == HTML_EL_BODY && isHTML);
2903: if (moved)
2904: {
2905: if (element)
2906: element = el;
2907: else
2908: {
2909: savedtype = context->type;
2910: context->type = HTML_EL_HTML;
2911: }
2912: }
2913: else if (element)
2914: el = element;
2915:
2916: url = NULL;
1.13 cvs 2917: cssRule = SkipBlanksAndComments (cssRule);
1.17 cvs 2918: if (!ustrncasecmp (cssRule, TEXT("url"), 3))
1.1 cvs 2919: {
2920: cssRule += 3;
1.13 cvs 2921: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2922: if (*cssRule == '(')
2923: {
2924: cssRule++;
1.13 cvs 2925: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2926: /*** Caution: Strings can either be written with double quotes or
2927: with single quotes. Only double quotes are handled here.
2928: Escaped quotes are not handled. See function SkipQuotedString */
2929: if (*cssRule == '"')
2930: {
2931: cssRule++;
2932: base = cssRule;
2933: while (*cssRule != EOS && *cssRule != '"')
2934: cssRule++;
2935: }
2936: else
2937: {
2938: base = cssRule;
2939: while (*cssRule != EOS && *cssRule != ')')
2940: cssRule++;
2941: }
2942: saved = *cssRule;
2943: *cssRule = EOS;
2944: url = TtaStrdup (base);
2945: *cssRule = saved;
2946: if (saved == '"')
2947: /* we need to skip two characters */
2948: cssRule++;
2949: }
2950: cssRule++;
2951:
2952: if (context->destroy)
2953: {
2954: /* remove the background image PRule */
2955: image.pointer = NULL;
2956: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, context, image);
2957: if (TtaGetStylePresentation (PRFillPattern, element, tsch, context, &value) < 0)
2958: {
2959: /* there is no FillPattern rule -> remove ShowBox rule */
2960: value.typed_data.value = 1;
2961: value.typed_data.unit = STYLE_UNIT_REL;
2962: value.typed_data.real = FALSE;
2963: TtaSetStylePresentation (PRShowBox, element, tsch, context, value);
2964: }
2965: }
2966: else if (url)
2967: {
1.30 cvs 2968: bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
1.17 cvs 2969: if (bg_image == NULL || !ustrcasecmp (bg_image, TEXT("yes")))
1.1 cvs 2970: {
2971: callblock = (BackgroundImageCallbackPtr) TtaGetMemory(sizeof(BackgroundImageCallbackBlock));
2972: if (callblock != NULL)
2973: {
2974: callblock->el = element;
2975: callblock->tsch = tsch;
2976: if (element == NULL)
1.18 cvs 2977: {
2978: gblock = (GenericContext) context;
2979: memcpy (&callblock->context.generic, gblock,
2980: sizeof (GenericContextBlock));
2981: }
2982: else
2983: {
2984: sblock = context;
2985: memcpy (&callblock->context.specific, sblock,
2986: sizeof(PresentationContextBlock));
2987: }
2988:
2989: /* check if the image url is related to an external CSS */
2990: if (css != NULL && css->category == CSS_EXTERNAL_STYLE)
2991: {
2992: NormalizeURL (url, 0, tempname, imgname, css->url);
2993: /* fetch and display background image of element */
1.33 cvs 2994: FetchImage (context->doc, el, tempname, AMAYA_LOAD_IMAGE,
1.18 cvs 2995: ParseCSSBackgroundImageCallback, callblock);
2996: }
2997: else
1.33 cvs 2998: FetchImage (context->doc, el, url, AMAYA_LOAD_IMAGE,
1.18 cvs 2999: ParseCSSBackgroundImageCallback, callblock);
3000: }
3001: }
3002:
3003: if (url)
3004: TtaFreeMemory (url);
3005: }
3006: }
3007:
3008: /* restore the refered element */
3009: if (moved && !element)
3010: context->type = savedtype;
3011: return (cssRule);
3012: }
3013:
3014: /*----------------------------------------------------------------------
3015: ParseCSSBackgroundRepeat : parse a CSS BackgroundRepeat
3016: attribute string.
3017: ----------------------------------------------------------------------*/
3018: #ifdef __STDC__
3019: static STRING ParseCSSBackgroundRepeat (Element element, PSchema tsch,
3020: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
3021: #else
3022: static STRING ParseCSSBackgroundRepeat (element, tsch, context, cssRule, css, isHTML)
3023: Element element;
3024: PSchema tsch;
3025: PresentationContext context;
3026: STRING cssRule;
3027: CSSInfoPtr css;
3028: ThotBool isHTML;
3029: #endif
3030: {
3031: PresentationValue repeat;
3032: unsigned int savedtype = 0;
3033: ThotBool moved;
3034:
3035: /* move the BODY rule to the HTML element */
3036: moved = (context->type == HTML_EL_BODY && isHTML);
3037: if (moved)
3038: {
3039: if (element)
3040: element = TtaGetMainRoot (context->doc);
3041: else
3042: {
3043: savedtype = context->type;
3044: context->type = HTML_EL_HTML;
3045: }
3046: }
3047:
3048: repeat.typed_data.value = STYLE_REALSIZE;
3049: repeat.typed_data.unit = STYLE_UNIT_REL;
3050: repeat.typed_data.real = FALSE;
3051: cssRule = SkipBlanksAndComments (cssRule);
3052: if (!ustrncasecmp (cssRule, TEXT("no-repeat"), 9))
3053: repeat.typed_data.value = STYLE_REALSIZE;
3054: else if (!ustrncasecmp (cssRule, TEXT("repeat-y"), 8))
3055: repeat.typed_data.value = STYLE_VREPEAT;
3056: else if (!ustrncasecmp (cssRule, TEXT("repeat-x"), 8))
3057: repeat.typed_data.value = STYLE_HREPEAT;
3058: else if (!ustrncasecmp (cssRule, TEXT("repeat"), 6))
3059: repeat.typed_data.value = STYLE_REPEAT;
3060: else
3061: return (cssRule);
3062:
3063: /* install the new presentation */
3064: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
3065: cssRule = SkipWord (cssRule);
3066:
3067: /* restore the refered element */
3068: if (moved && !element)
3069: context->type = savedtype;
3070: return (cssRule);
3071: }
3072:
3073: /*----------------------------------------------------------------------
3074: ParseCSSBackgroundAttachment : parse a CSS BackgroundAttachment
3075: attribute string.
3076: ----------------------------------------------------------------------*/
3077: #ifdef __STDC__
3078: static STRING ParseCSSBackgroundAttachment (Element element, PSchema tsch,
3079: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
3080: #else
3081: static STRING ParseCSSBackgroundAttachment (element, tsch, context, cssRule, css, isHTML)
3082: Element element;
3083: PSchema tsch;
3084: PresentationContext context;
3085: STRING cssRule;
3086: CSSInfoPtr css;
3087: ThotBool isHTML;
3088: #endif
3089: {
3090: unsigned int savedtype = 0;
3091: ThotBool moved;
1.1 cvs 3092:
1.18 cvs 3093: /* move the BODY rule to the HTML element */
3094: moved = (context->type == HTML_EL_BODY && isHTML);
3095: if (moved)
3096: {
3097: if (element)
3098: element = TtaGetMainRoot (context->doc);
3099: else
3100: {
3101: savedtype = context->type;
3102: context->type = HTML_EL_HTML;
1.1 cvs 3103: }
3104: }
3105:
1.18 cvs 3106: cssRule = SkipBlanksAndComments (cssRule);
3107: if (!ustrncasecmp (cssRule, TEXT("scroll"), 6))
3108: cssRule = SkipWord (cssRule);
3109: else if (!ustrncasecmp (cssRule, TEXT("fixed"), 5))
3110: cssRule = SkipWord (cssRule);
3111:
1.1 cvs 3112: /* restore the refered element */
3113: if (moved && !element)
3114: context->type = savedtype;
1.18 cvs 3115: return (cssRule);
1.1 cvs 3116: }
3117:
3118: /*----------------------------------------------------------------------
1.18 cvs 3119: ParseCSSBackgroundPosition : parse a CSS BackgroundPosition
1.1 cvs 3120: attribute string.
3121: ----------------------------------------------------------------------*/
3122: #ifdef __STDC__
1.18 cvs 3123: static STRING ParseCSSBackgroundPosition (Element element, PSchema tsch,
1.14 cvs 3124: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 3125: #else
1.18 cvs 3126: static STRING ParseCSSBackgroundPosition (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 3127: Element element;
3128: PSchema tsch;
3129: PresentationContext context;
3130: STRING cssRule;
3131: CSSInfoPtr css;
1.14 cvs 3132: ThotBool isHTML;
1.1 cvs 3133: #endif
3134: {
1.18 cvs 3135: PresentationValue repeat;
3136: unsigned int savedtype = 0;
3137: ThotBool moved;
3138: ThotBool ok;
1.1 cvs 3139:
3140: /* move the BODY rule to the HTML element */
3141: moved = (context->type == HTML_EL_BODY && isHTML);
3142: if (moved)
3143: {
3144: if (element)
3145: element = TtaGetMainRoot (context->doc);
3146: else
3147: {
3148: savedtype = context->type;
3149: context->type = HTML_EL_HTML;
3150: }
3151: }
3152:
1.18 cvs 3153: cssRule = SkipBlanksAndComments (cssRule);
3154: ok = TRUE;
3155: if (!ustrncasecmp (cssRule, TEXT("left"), 4))
3156: cssRule = SkipWord (cssRule);
3157: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
3158: cssRule = SkipWord (cssRule);
3159: else if (!ustrncasecmp (cssRule, TEXT("center"), 6))
3160: cssRule = SkipWord (cssRule);
3161: else if (!ustrncasecmp (cssRule, TEXT("top"), 3))
3162: cssRule = SkipWord (cssRule);
3163: else if (!ustrncasecmp (cssRule, TEXT("bottom"), 6))
3164: cssRule = SkipWord (cssRule);
3165: else if (isdigit (*cssRule))
3166: cssRule = SkipWord (cssRule);
3167: else
3168: ok = FALSE;
3169:
3170: if (ok)
3171: {
3172: /* force realsize for the background image */
3173: repeat.typed_data.value = STYLE_REALSIZE;
3174: repeat.typed_data.unit = STYLE_UNIT_REL;
3175: repeat.typed_data.real = FALSE;
3176: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
3177: }
3178:
3179: /* restore the refered element */
3180: if (moved && !element)
3181: context->type = savedtype;
3182: return (cssRule);
3183: }
3184:
3185: /*----------------------------------------------------------------------
3186: ParseCSSBackground : parse a CSS background attribute
3187: ----------------------------------------------------------------------*/
3188: #ifdef __STDC__
3189: static STRING ParseCSSBackground (Element element, PSchema tsch,
3190: PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
3191: #else
3192: static STRING ParseCSSBackground (element, tsch, context, cssRule, css, isHTML)
3193: Element element;
3194: PSchema tsch;
3195: PresentationContext context;
3196: STRING cssRule;
3197: CSSInfoPtr css;
3198: ThotBool isHTML;
3199: #endif
3200: {
3201: STRING ptr;
3202:
1.13 cvs 3203: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 3204: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
3205: {
3206: /* perhaps a Backgroud Image */
3207: if (!ustrncasecmp (cssRule, TEXT("url"), 3))
3208: cssRule = ParseCSSBackgroundImage (element, tsch, context, cssRule, css, isHTML);
3209: /* perhaps a Background Attachment */
3210: else if (!ustrncasecmp (cssRule, TEXT("scroll"), 6) ||
3211: !ustrncasecmp (cssRule, TEXT("fixed"), 5))
3212: cssRule = ParseCSSBackgroundAttachment (element, tsch, context, cssRule, css, isHTML);
3213: /* perhaps a Background Repeat */
3214: else if (!ustrncasecmp (cssRule, TEXT("no-repeat"), 9) ||
3215: !ustrncasecmp (cssRule, TEXT("repeat-y"), 8) ||
3216: !ustrncasecmp (cssRule, TEXT("repeat-x"), 8) ||
3217: !ustrncasecmp (cssRule, TEXT("repeat"), 6))
3218: cssRule = ParseCSSBackgroundRepeat (element, tsch, context, cssRule, css, isHTML);
3219: /* perhaps a Background Position */
3220: else if (!ustrncasecmp (cssRule, TEXT("left"), 4) ||
3221: !ustrncasecmp (cssRule, TEXT("right"), 5) ||
3222: !ustrncasecmp (cssRule, TEXT("center"), 6) ||
3223: !ustrncasecmp (cssRule, TEXT("top"), 3) ||
3224: !ustrncasecmp (cssRule, TEXT("bottom"), 6) ||
3225: isdigit (*cssRule))
3226: cssRule = ParseCSSBackgroundPosition (element, tsch, context, cssRule, css, isHTML);
3227: /* perhaps a Background Color */
3228: else
3229: {
3230: /* check if the rule has been found */
3231: ptr = cssRule;
3232: cssRule = ParseCSSBackgroundColor (element, tsch, context, cssRule, css, isHTML);
1.43 cvs 3233: if (ptr == cssRule)
1.18 cvs 3234: /* rule not found */
3235: cssRule = SkipProperty (cssRule);
3236: }
3237: cssRule = SkipBlanksAndComments (cssRule);
3238: }
3239: return (cssRule);
3240: }
3241:
3242:
3243:
3244: /************************************************************************
3245: * *
3246: * FUNCTIONS STYLE DECLARATIONS *
3247: * *
3248: ************************************************************************/
3249: /*
3250: * NOTE : Long attribute name MUST be placed before shortened ones !
3251: * e.g. "FONT-SIZE" must be placed before "FONT"
3252: */
3253: static CSSProperty CSSProperties[] =
3254: {
3255: {TEXT ("font-family"), ParseCSSFontFamily},
3256: {TEXT ("font-style"), ParseCSSFontStyle},
3257: {TEXT ("font-variant"), ParseCSSFontVariant},
3258: {TEXT ("font-weight"), ParseCSSFontWeight},
3259: {TEXT ("font-size"), ParseCSSFontSize},
3260: {TEXT ("font"), ParseCSSFont},
3261:
3262: {TEXT ("color"), ParseCSSForeground},
3263: {TEXT ("background-color"), ParseCSSBackgroundColor},
3264: {TEXT ("background-image"), ParseCSSBackgroundImage},
3265: {TEXT ("background-repeat"), ParseCSSBackgroundRepeat},
3266: {TEXT ("background-attachment"), ParseCSSBackgroundAttachment},
3267: {TEXT ("background-position"), ParseCSSBackgroundPosition},
3268: {TEXT ("background"), ParseCSSBackground},
3269:
3270: {TEXT ("word-spacing"), ParseCSSWordSpacing},
3271: {TEXT ("letter-spacing"), ParseCSSLetterSpacing},
3272: {TEXT ("text-decoration"), ParseCSSTextDecoration},
3273: {TEXT ("vertical-align"), ParseCSSVerticalAlign},
3274: {TEXT ("text-transform"), ParseCSSTextTransform},
3275: {TEXT ("text-align"), ParseCSSTextAlign},
3276: {TEXT ("text-indent"), ParseCSSTextIndent},
3277: {TEXT ("line-height"), ParseCSSLineSpacing},
3278:
3279: {TEXT ("margin-top"), ParseCSSMarginTop},
3280: {TEXT ("margin-right"), ParseCSSMarginRight},
3281: {TEXT ("margin-bottom"), ParseCSSMarginBottom},
3282: {TEXT ("margin-left"), ParseCSSMarginLeft},
3283: {TEXT ("margin"), ParseCSSMargin},
3284:
3285: {TEXT ("padding-top"), ParseCSSPaddingTop},
3286: {TEXT ("padding-right"), ParseCSSPaddingRight},
3287: {TEXT ("padding-bottom"), ParseCSSPaddingBottom},
3288: {TEXT ("padding-left"), ParseCSSPaddingLeft},
3289: {TEXT ("padding"), ParseCSSPadding},
3290:
3291: {TEXT ("border-top-width"), ParseCSSBorderTopWidth},
3292: {TEXT ("border-right-width"), ParseCSSBorderRightWidth},
3293: {TEXT ("border-bottom-width"), ParseCSSBorderBottomWidth},
3294: {TEXT ("border-left-width"), ParseCSSBorderLeftWidth},
3295: {TEXT ("border-width"), ParseCSSBorderWidth},
1.42 cvs 3296: {TEXT ("border-top-color"), ParseCSSBorderColorTop},
3297: {TEXT ("border-right-color"), ParseCSSBorderColorRight},
3298: {TEXT ("border-bottom-color"), ParseCSSBorderColorBottom},
3299: {TEXT ("border-left-color"), ParseCSSBorderColorLeft},
1.18 cvs 3300: {TEXT ("border-color"), ParseCSSBorderColor},
1.42 cvs 3301: {TEXT ("border-top-style"), ParseCSSBorderStyleTop},
3302: {TEXT ("border-right-style"), ParseCSSBorderStyleRight},
3303: {TEXT ("border-bottom-style"), ParseCSSBorderStyleBottom},
3304: {TEXT ("border-left-style"), ParseCSSBorderStyleLeft},
1.18 cvs 3305: {TEXT ("border-style"), ParseCSSBorderStyle},
3306: {TEXT ("border-top"), ParseCSSBorderTop},
3307: {TEXT ("border-right"), ParseCSSBorderRight},
3308: {TEXT ("border-bottom"), ParseCSSBorderBottom},
3309: {TEXT ("border-left"), ParseCSSBorderLeft},
3310: {TEXT ("border"), ParseCSSBorder},
3311:
3312: {TEXT ("width"), ParseCSSWidth},
3313: {TEXT ("height"), ParseCSSHeight},
3314: {TEXT ("float"), ParseCSSFloat},
3315: {TEXT ("clear"), ParseCSSClear},
3316:
3317: {TEXT ("display"), ParseCSSDisplay},
3318: {TEXT ("white-space"), ParseCSSWhiteSpace},
3319:
3320: {TEXT ("list-style-type"), ParseCSSListStyleType},
3321: {TEXT ("list-style-image"), ParseCSSListStyleImage},
3322: {TEXT ("list-style-position"), ParseCSSListStylePosition},
3323: {TEXT ("list-style"), ParseCSSListStyle}
3324: };
3325: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
3326:
3327: /*----------------------------------------------------------------------
3328: ParseCSSRule : parse a CSS Style string
3329: we expect the input string describing the style to be of the
3330: form : PRORPERTY : DESCRIPTION [ ; PROPERTY : DESCRIPTION ] *
3331: but tolerate incorrect or incomplete input
3332: ----------------------------------------------------------------------*/
3333: #ifdef __STDC__
3334: static void ParseCSSRule (Element element, PSchema tsch, PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML)
3335: #else
3336: static void ParseCSSRule (element, tsch, context, cssRule, css, isHTML)
3337: Element element;
3338: PSchema tsch;
3339: PresentationContext context;
3340: STRING cssRule;
3341: CSSInfoPtr css;
3342: ThotBool isHTML;
3343: #endif
3344: {
1.34 cvs 3345: DisplayMode dispMode;
1.18 cvs 3346: STRING p = NULL;
3347: int lg;
1.34 cvs 3348: unsigned int i;
1.18 cvs 3349: ThotBool found;
3350:
1.34 cvs 3351: /* avoid too many redisplay */
3352: dispMode = TtaGetDisplayMode (context->doc);
3353: if (dispMode == DisplayImmediately)
3354: TtaSetDisplayMode (context->doc, DeferredDisplay);
3355:
1.18 cvs 3356: while (*cssRule != EOS)
3357: {
3358: cssRule = SkipBlanksAndComments (cssRule);
3359:
3360: found = FALSE;
3361: /* look for the type of property */
3362: for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
3363: {
3364: lg = ustrlen (CSSProperties[i].name);
3365: if (!ustrncasecmp (cssRule, CSSProperties[i].name, lg))
3366: {
3367: cssRule += lg;
3368: found = TRUE;
3369: i--;
3370: }
3371: }
3372:
3373: if (i == NB_CSSSTYLEATTRIBUTE)
3374: cssRule = SkipProperty (cssRule);
3375: else
3376: {
3377: /* update index and skip the ":" indicator if present */
3378: cssRule = SkipBlanksAndComments (cssRule);
3379: if (*cssRule == ':')
3380: {
3381: cssRule++;
3382: cssRule = SkipBlanksAndComments (cssRule);
3383: }
3384: /* try to parse the attribute associated to this attribute */
3385: if (CSSProperties[i].parsing_function != NULL)
3386: {
1.34 cvs 3387: p = CSSProperties[i].parsing_function (element, tsch, context, cssRule, css, isHTML);
3388: /* update index and skip the ";" separator if present */
3389: cssRule = p;
1.18 cvs 3390: }
3391: }
3392: /* next property */
3393: cssRule = SkipBlanksAndComments (cssRule);
3394: if (*cssRule == ',' || *cssRule == ';')
3395: {
3396: cssRule++;
3397: cssRule = SkipBlanksAndComments (cssRule);
3398: }
3399: }
1.34 cvs 3400:
3401: /* restore the display mode */
3402: if (dispMode == DisplayImmediately)
3403: TtaSetDisplayMode (context->doc, dispMode);
1.18 cvs 3404: }
1.1 cvs 3405:
3406:
3407: /*----------------------------------------------------------------------
1.18 cvs 3408: PToCss : translate a PresentationSetting to the
3409: equivalent CSS string, and add it to the buffer given as the
3410: argument. It is used when extracting the CSS string from actual
3411: presentation.
3412:
3413: All the possible values returned by the presentation drivers are
3414: described in thotlib/include/presentation.h
3415: -----------------------------------------------------------------------*/
1.1 cvs 3416: #ifdef __STDC__
1.18 cvs 3417: void PToCss (PresentationSetting settings, STRING buffer, int len)
1.1 cvs 3418: #else
1.18 cvs 3419: void PToCss (settings, buffer, len)
3420: PresentationSetting settings;
3421: STRING param;
3422: int len
1.1 cvs 3423: #endif
3424: {
1.18 cvs 3425: float fval = 0;
3426: unsigned short red, green, blue;
3427: int add_unit = 0;
3428: unsigned int unit, i;
3429: ThotBool real = FALSE;
3430:
3431: buffer[0] = EOS;
3432: if (len < 40)
3433: return;
3434:
3435: unit = settings->value.typed_data.unit;
3436: if (settings->value.typed_data.real)
3437: {
3438: real = TRUE;
3439: fval = (float) settings->value.typed_data.value;
3440: fval /= 1000;
3441: }
1.1 cvs 3442:
1.18 cvs 3443: switch (settings->type)
1.1 cvs 3444: {
1.18 cvs 3445: case PRVisibility:
3446: break;
3447: case PRFont:
3448: switch (settings->value.typed_data.value)
3449: {
3450: case STYLE_FONT_HELVETICA:
3451: ustrcpy (buffer, TEXT("font-family: helvetica"));
3452: break;
3453: case STYLE_FONT_TIMES:
3454: ustrcpy (buffer, TEXT("font-family: times"));
3455: break;
3456: case STYLE_FONT_COURIER:
3457: ustrcpy (buffer, TEXT("font-family: courier"));
3458: break;
3459: }
3460: break;
3461: case PRStyle:
3462: switch (settings->value.typed_data.value)
3463: {
3464: case STYLE_FONT_ROMAN:
3465: ustrcpy (buffer, TEXT("font-style: normal"));
3466: break;
3467: case STYLE_FONT_ITALICS:
3468: ustrcpy (buffer, TEXT("font-style: italic"));
3469: break;
3470: case STYLE_FONT_OBLIQUE:
3471: ustrcpy (buffer, TEXT("font-style: oblique"));
3472: break;
1.20 cvs 3473: }
3474: break;
3475: case PRWeight:
3476: switch (settings->value.typed_data.value)
3477: {
3478: case STYLE_WEIGHT_BOLD:
3479: ustrcpy (buffer, TEXT("font-weight: bold"));
3480: break;
3481: case STYLE_WEIGHT_NORMAL:
3482: ustrcpy (buffer, TEXT("font-weight: normal"));
1.18 cvs 3483: break;
3484: }
3485: break;
3486: case PRSize:
3487: if (unit == STYLE_UNIT_REL)
3488: {
3489: if (real)
3490: {
3491: usprintf (buffer, TEXT("font-size: %g"), fval);
3492: add_unit = 1;
3493: }
3494: else
3495: switch (settings->value.typed_data.value)
3496: {
3497: case 1:
3498: ustrcpy (buffer, TEXT("font-size: xx-small"));
3499: break;
3500: case 2:
3501: ustrcpy (buffer, TEXT("font-size: x-small"));
3502: break;
3503: case 3:
3504: ustrcpy (buffer, TEXT("font-size: small"));
3505: break;
3506: case 4:
3507: ustrcpy (buffer, TEXT("font-size: medium"));
3508: break;
3509: case 5:
3510: ustrcpy (buffer, TEXT("font-size: large"));
3511: break;
3512: case 6:
3513: ustrcpy (buffer, TEXT("font-size: x-large"));
3514: break;
3515: case 7:
3516: case 8:
3517: case 9:
3518: case 10:
3519: case 11:
3520: case 12:
3521: ustrcpy (buffer, TEXT("font-size: xx-large"));
3522: break;
3523: }
3524: }
3525: else
3526: {
3527: if (real)
3528: usprintf (buffer, TEXT("font-size: %g"), fval);
3529: else
3530: usprintf (buffer, TEXT("font-size: %d"), settings->value.typed_data.value);
3531: add_unit = 1;
3532: }
3533: break;
3534: case PRUnderline:
3535: switch (settings->value.typed_data.value)
3536: {
3537: case STYLE_UNDERLINE:
3538: ustrcpy (buffer, TEXT("text-decoration: underline"));
3539: break;
3540: case STYLE_OVERLINE:
3541: ustrcpy (buffer, TEXT("text-decoration: overline"));
3542: break;
3543: case STYLE_CROSSOUT:
3544: ustrcpy (buffer, TEXT("text-decoration: line-through"));
3545: break;
3546: }
3547: break;
3548: case PRIndent:
3549: if (real)
3550: usprintf (buffer, TEXT("text-indent: %g"), fval);
3551: else
3552: usprintf (buffer, TEXT("text-indent: %d"), settings->value.typed_data.value);
3553: add_unit = 1;
3554: break;
3555: case PRLineSpacing:
3556: if (real)
3557: usprintf (buffer, TEXT("line-height: %g"), fval);
1.1 cvs 3558: else
1.18 cvs 3559: usprintf (buffer, TEXT("line-height: %d"), settings->value.typed_data.value);
3560: add_unit = 1;
3561: break;
3562: case PRJustify:
3563: if (settings->value.typed_data.value == STYLE_JUSTIFIED)
3564: usprintf (buffer, TEXT("text-align: justify"));
3565: break;
3566: case PRAdjust:
3567: switch (settings->value.typed_data.value)
1.1 cvs 3568: {
1.18 cvs 3569: case STYLE_ADJUSTLEFT:
3570: ustrcpy (buffer, TEXT("text-align: left"));
3571: break;
3572: case STYLE_ADJUSTRIGHT:
3573: ustrcpy (buffer, TEXT("text-align: right"));
3574: break;
3575: case STYLE_ADJUSTCENTERED:
3576: ustrcpy (buffer, TEXT("text-align: center"));
3577: break;
3578: case STYLE_ADJUSTLEFTWITHDOTS:
3579: ustrcpy (buffer, TEXT("text-align: left"));
3580: break;
1.1 cvs 3581: }
1.18 cvs 3582: break;
3583: case PRHyphenate:
3584: break;
3585: case PRFillPattern:
3586: break;
3587: case PRBackground:
3588: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3589: usprintf (buffer, TEXT("background-color: #%02X%02X%02X"), red, green, blue);
3590: break;
3591: case PRForeground:
3592: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
3593: usprintf (buffer, TEXT("color: #%02X%02X%02X"), red, green, blue);
3594: break;
1.40 cvs 3595: case PRMarginTop:
1.18 cvs 3596: if (real)
3597: usprintf (buffer, TEXT("marging-top: %g"), fval);
3598: else
3599: usprintf (buffer, TEXT("marging-top: %d"), settings->value.typed_data.value);
3600: add_unit = 1;
3601: break;
1.40 cvs 3602: case PRMarginLeft:
1.18 cvs 3603: if (real)
3604: usprintf (buffer, TEXT("margin-left: %g"), fval);
3605: else
3606: usprintf (buffer, TEXT("margin-left: %d"), settings->value.typed_data.value);
3607: add_unit = 1;
3608: break;
3609: case PRHeight:
3610: if (real)
3611: usprintf (buffer, TEXT("height: %g"), fval);
3612: else
3613: usprintf (buffer, TEXT("height: %d"), settings->value.typed_data.value);
3614: add_unit = 1;
3615: break;
3616: case PRWidth:
3617: if (real)
3618: usprintf (buffer, TEXT("width: %g"), fval);
1.1 cvs 3619: else
1.18 cvs 3620: usprintf (buffer, TEXT("width: %d"), settings->value.typed_data.value);
3621: add_unit = 1;
3622: break;
3623: case PRLine:
3624: if (settings->value.typed_data.value == STYLE_INLINE)
3625: ustrcpy (buffer, TEXT("display: inline"));
3626: else if (settings->value.typed_data.value == STYLE_NOTINLINE)
3627: ustrcpy (buffer, TEXT("display: block"));
3628: break;
3629: case PRBackgroundPicture:
3630: if (settings->value.pointer != NULL)
1.19 cvs 3631: usprintf (buffer, TEXT("background-image: url(%s)"), (STRING)(settings->value.pointer));
1.1 cvs 3632: else
1.18 cvs 3633: usprintf (buffer, TEXT("background-image: none"));
3634: break;
3635: case PRPictureMode:
3636: switch (settings->value.typed_data.value)
1.1 cvs 3637: {
1.18 cvs 3638: case STYLE_REALSIZE:
3639: usprintf (buffer, TEXT("background-repeat: no-repeat"));
3640: break;
3641: case STYLE_REPEAT:
3642: usprintf (buffer, TEXT("background-repeat: repeat"));
3643: break;
3644: case STYLE_VREPEAT:
3645: usprintf (buffer, TEXT("background-repeat: repeat-y"));
3646: break;
3647: case STYLE_HREPEAT:
3648: usprintf (buffer, TEXT("background-repeat: repeat-x"));
3649: break;
1.1 cvs 3650: }
1.18 cvs 3651: break;
3652: default:
3653: break;
1.1 cvs 3654: }
3655:
1.18 cvs 3656: if (add_unit)
1.1 cvs 3657: {
1.18 cvs 3658: /* add the unit string to the CSS string */
3659: for (i = 0; i < NB_UNITS; i++)
1.1 cvs 3660: {
1.18 cvs 3661: if (CSSUnitNames[i].unit == unit)
1.1 cvs 3662: {
1.18 cvs 3663: ustrcat (buffer, CSSUnitNames[i].sign);
3664: break;
1.1 cvs 3665: }
3666: }
3667: }
3668: }
3669:
3670: /*----------------------------------------------------------------------
1.18 cvs 3671: ParseHTMLSpecificStyle : parse and apply a CSS Style string.
3672: This function must be called when a specific style is applied to an
3673: element.
1.1 cvs 3674: ----------------------------------------------------------------------*/
3675: #ifdef __STDC__
1.14 cvs 3676: void ParseHTMLSpecificStyle (Element el, STRING cssRule, Document doc, ThotBool destroy)
1.1 cvs 3677: #else
3678: void ParseHTMLSpecificStyle (el, cssRule, doc, destroy)
3679: Element elem;
3680: STRING cssRule;
3681: Document doc;
1.14 cvs 3682: ThotBool destroy;
1.1 cvs 3683: #endif
3684: {
3685: PresentationContext context;
3686: ElementType elType;
1.14 cvs 3687: ThotBool isHTML;
1.1 cvs 3688:
3689: /* A rule applying to BODY is really meant to address HTML */
3690: elType = TtaGetElementType (el);
1.17 cvs 3691: isHTML = (ustrcmp(TtaGetSSchemaName (elType.ElSSchema), TEXT("HTML")) == 0);
1.1 cvs 3692: /* create the context of the Specific presentation driver */
3693: context = TtaGetSpecificStyleContext (doc);
3694: if (context == NULL)
3695: return;
3696: context->type = elType.ElTypeNum;
3697: context->destroy = destroy;
3698: /* Call the parser */
3699: ParseCSSRule (el, NULL, (PresentationContext) context, cssRule, NULL, isHTML);
3700: /* free the context */
3701: TtaFreeMemory(context);
3702: }
3703:
3704: /*----------------------------------------------------------------------
1.25 cvs 3705: ParseGenericSelector : Create a generic context for a given
1.1 cvs 3706: selector string. If the selector is made of multiple comma-
3707: separated selector items, it parses them one at a time and
3708: return the end of the selector string to be handled or NULL
3709: ----------------------------------------------------------------------*/
3710: #ifdef __STDC__
1.25 cvs 3711: static STRING ParseGenericSelector (STRING selector, STRING cssRule,
1.1 cvs 3712: GenericContext ctxt, Document doc, CSSInfoPtr css)
3713: #else
1.25 cvs 3714: static STRING ParseGenericSelector (selector, cssRule, ctxt, doc, css)
1.1 cvs 3715: STRING selector;
3716: STRING cssRule;
3717: GenericContext ctxt;
3718: Document doc;
3719: CSSInfoPtr css;
3720: #endif
3721: {
3722: ElementType elType;
3723: PSchema tsch;
1.25 cvs 3724: AttributeType attrType;
3725: CHAR_T sel[MAX_ANCESTORS * 50];
3726: STRING deb, cur;
3727: STRING structName;
3728: STRING names[MAX_ANCESTORS];
3729: STRING ids[MAX_ANCESTORS];
3730: STRING classes[MAX_ANCESTORS];
3731: STRING pseudoclasses[MAX_ANCESTORS];
3732: STRING attrs[MAX_ANCESTORS];
3733: STRING attrvals[MAX_ANCESTORS];
1.35 cvs 3734: int i, j, k, max, maxAttr;
1.25 cvs 3735: ThotBool isHTML;
1.1 cvs 3736:
3737: sel[0] = EOS;
3738: for (i = 0; i < MAX_ANCESTORS; i++)
3739: {
1.25 cvs 3740: names[i] = NULL;
3741: ids[i] = NULL;
3742: classes[i] = NULL;
3743: pseudoclasses[i] = NULL;
3744: attrs[i] = NULL;
3745: attrvals[i] = NULL;
3746:
3747: ctxt->name[i] = 0;
3748: ctxt->names_nb[i] = 0;
3749: ctxt->attrType[i] = 0;
3750: ctxt->attrText[i] = NULL;
1.1 cvs 3751: }
1.25 cvs 3752: ctxt->box = 0;
3753: ctxt->type = 0;
3754:
1.13 cvs 3755: selector = SkipBlanksAndComments (selector);
1.27 cvs 3756: cur = &sel[0];
1.25 cvs 3757: max = 0; /* number of loops */
1.1 cvs 3758: while (1)
3759: {
1.27 cvs 3760: deb = cur;
1.25 cvs 3761: /* copy an item of the selector into sel[] */
1.1 cvs 3762: /* put one word in the sel buffer */
3763: while (*selector != EOS && *selector != ',' &&
3764: *selector != '.' && *selector != ':' &&
3765: *selector != '#' && !TtaIsBlank (selector))
3766: *cur++ = *selector++;
1.25 cvs 3767: *cur++ = EOS; /* close the first string in sel[] */
3768: if (deb[0] != EOS)
1.27 cvs 3769: names[0] = deb;
1.25 cvs 3770: else
1.27 cvs 3771: names[0] = NULL;
3772: classes[0] = NULL;
3773: pseudoclasses[0] = NULL;
3774: ids[0] = NULL;
3775: attrs[0] = NULL;
3776: attrvals[0] = NULL;
1.25 cvs 3777:
1.27 cvs 3778: /* now names[0] points to the beginning of the parsed item
1.25 cvs 3779: and cur to the next chain to be parsed */
1.1 cvs 3780: if (*selector == ':' || *selector == '.' || *selector == '#')
1.25 cvs 3781: /* keep the element name which precedes the id or
3782: pseudo class or the class */
1.27 cvs 3783: deb = cur;
1.1 cvs 3784:
3785: if (*selector == '.')
3786: {
1.25 cvs 3787: /* copy into sel[] the class */
1.27 cvs 3788: classes[0] = cur;
1.1 cvs 3789: selector++;
3790: while (*selector != EOS && *selector != ',' &&
3791: *selector != '.' && *selector != ':' &&
3792: !TtaIsBlank (selector))
3793: *cur++ = *selector++;
3794: *cur++ = EOS;
3795: }
3796: else if (*selector == ':')
3797: {
1.25 cvs 3798: /* copy into sel[] the pseudoclass */
1.27 cvs 3799: pseudoclasses[0]= cur;
1.1 cvs 3800: selector++;
3801: while (*selector != EOS && *selector != ',' &&
3802: *selector != '.' && *selector != ':' &&
3803: !TtaIsBlank (selector))
3804: *cur++ = *selector++;
3805: *cur++ = EOS;
3806: }
3807: else if (*selector == '#')
3808: {
1.25 cvs 3809: /* copy into sel[] the attribute */
1.27 cvs 3810: ids[0] = cur;
1.1 cvs 3811: selector++;
3812: while (*selector != EOS && *selector != ',' &&
3813: *selector != '.' && *selector != ':' &&
3814: !TtaIsBlank (selector))
3815: *cur++ = *selector++;
3816: *cur++ = EOS;
3817: }
1.25 cvs 3818: else if (*selector == '[')
1.1 cvs 3819: {
1.25 cvs 3820: /* copy into sel[] the attribute */
1.27 cvs 3821: attrs[0] = cur;
1.25 cvs 3822: selector++;
3823: while (*selector != EOS && *selector != ']' && *selector != '=')
3824: *cur++ = *selector++;
3825: if (*cur == '=')
3826: {
3827: /* there is a value "xxxx" */
3828: *cur++ = EOS;
3829: while (*selector != EOS && *selector != ']' && *selector != '"')
3830: selector++;
3831: if (*selector != EOS)
3832: {
3833: /* we are now parsing the attribute value */
1.27 cvs 3834: attrvals[0] = cur;
1.25 cvs 3835: selector++;
3836: while (*selector != EOS && *selector != '"')
3837: *cur++ = *selector++;
3838: if (*selector != EOS)
3839: selector++;
3840: }
3841: }
3842: *cur++ = EOS;
1.1 cvs 3843: }
3844:
1.27 cvs 3845: selector = SkipBlanksAndComments (selector);
1.1 cvs 3846:
1.25 cvs 3847: /* is it a multi-level selector? */
1.1 cvs 3848: if (*selector == EOS)
3849: /* end of the selector */
3850: break;
3851: else if (*selector == ',')
3852: {
3853: /* end of the current selector */
3854: selector++;
3855: break;
3856: }
1.25 cvs 3857: else
3858: {
3859: /* shifts the list to make room for the new name */
3860: max++; /* a new level in ancestor tables */
3861: if (max == MAX_ANCESTORS)
3862: /* abort the CSS parsing */
3863: return (selector);
3864: for (i = max; i > 0; i--)
3865: {
3866: names[i] = names[i - 1];
3867: ids[i] = ids[i - 1];
3868: classes[i] = classes[i - 1];
3869: attrs[i] = attrs[i - 1];
3870: attrvals[i] = attrvals[i - 1];
3871: pseudoclasses[i] = pseudoclasses[i - 1];
3872: }
3873: }
1.1 cvs 3874: }
3875:
3876: /* Now set up the context block */
1.25 cvs 3877: i = 0;
3878: k = 0;
3879: j = 0;
1.35 cvs 3880: maxAttr = 0;
1.25 cvs 3881: while (i <= max)
3882: {
3883: if (names[i])
3884: {
3885: /* get the new element type of this name */
3886: GIType (names[i], &elType, doc);
3887: if (i == 0)
3888: {
3889: /* Store the element type */
3890: ctxt->type = elType.ElTypeNum;
1.32 cvs 3891: ctxt->name[0] = elType.ElTypeNum;
3892: ctxt->names_nb[0] = 0;
1.25 cvs 3893: ctxt->schema = elType.ElSSchema;
1.27 cvs 3894: k++;
1.25 cvs 3895: }
3896: else if (elType.ElTypeNum != 0)
3897: {
3898: /* look at the current context to see if the type is already
3899: stored */
3900: j = 0;
1.32 cvs 3901: while (j < k && ctxt->name[j] != elType.ElTypeNum)
1.25 cvs 3902: j++;
3903: if (j == k)
3904: {
3905: /* add a new entry */
3906: k++;
3907: ctxt->name[j] = elType.ElTypeNum;
3908: if (j != 0)
3909: ctxt->names_nb[j] = 1;
3910: }
3911: else
3912: /* increment the number of ancestor levels */
3913: ctxt->names_nb[j]++;
3914: }
3915: else
3916: {
3917: /* add a new entry */
3918: j = k;
3919: k++;
3920: }
3921: }
1.1 cvs 3922: else
1.25 cvs 3923: {
3924: /* add a new entry */
3925: j = k;
3926: k++;
3927: }
3928:
1.35 cvs 3929: if (classes[i] || pseudoclasses[i] || ids[i] || attrs[i])
3930: if (maxAttr > 0)
3931: /* Thot is not able to manage this kind of selector -> abort */
3932: return (selector);
3933: else
3934: maxAttr++;
1.1 cvs 3935:
1.25 cvs 3936: /* store attributes information */
3937: if (classes[i])
3938: {
3939: ctxt->attrText[j] = classes[i];
3940: ctxt->attrType[j] = HTML_ATTR_Class;
3941: }
3942: else if (pseudoclasses[i])
3943: {
3944: ctxt->attrText[j] = pseudoclasses[i];
3945: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
3946: }
3947: else if (ids[i])
3948: {
3949: ctxt->attrText[j] = ids[i];
3950: ctxt->attrType[j] = HTML_ATTR_ID;
3951: }
3952: else if (attrs[i])
3953: {
3954: MapHTMLAttribute (attrs[i], &attrType, names[i], doc);
3955: ctxt->attrText[j] = attrvals[i];
3956: ctxt->attrType[j] = attrType.AttrTypeNum;
3957: }
3958: i++;
1.1 cvs 3959: }
3960:
1.25 cvs 3961: /* sort the list of ancestors by name order */
3962: max = k;
3963: i = 1;
3964: while (i < max)
1.28 cvs 3965: {
3966: for (k = i + 1; k < max; k++)
3967: if (ctxt->name[i] > ctxt->name[k])
3968: {
3969: j = ctxt->name[i];
3970: ctxt->name[i] = ctxt->name[k];
3971: ctxt->name[k] = j;
3972: j = ctxt->names_nb[i];
3973: ctxt->names_nb[i] = ctxt->names_nb[k];
3974: ctxt->names_nb[k] = j;
3975: j = ctxt->attrType[i];
3976: ctxt->attrType[i] = ctxt->attrType[k];
3977: ctxt->attrType[k] = j;
3978: cur = ctxt->attrText[i];
3979: ctxt->attrText[i] = ctxt->attrText[k];
3980: ctxt->attrText[k] = cur;
3981: }
3982: i++;
3983: }
1.25 cvs 3984:
3985: /* Get the schema name of the main element */
3986: if (ctxt->schema == NULL)
1.1 cvs 3987: ctxt->schema = TtaGetDocumentSSchema (doc);
1.17 cvs 3988: isHTML = (ustrcmp(TtaGetSSchemaName (ctxt->schema), TEXT("HTML")) == 0);
1.1 cvs 3989: tsch = GetPExtension (doc, ctxt->schema, css);
3990: structName = TtaGetSSchemaName (ctxt->schema);
3991: if (cssRule)
3992: ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
3993: return (selector);
3994: }
3995:
3996: /*----------------------------------------------------------------------
3997: ParseStyleDeclaration : parse one HTML style declaration
3998: stored in the header of a HTML document
3999: We expect the style string to be of the form :
4000: [
4001: e.g: pinky, awful { color: pink, font-family: helvetica }
4002: ----------------------------------------------------------------------*/
4003: #ifdef __STDC__
1.14 cvs 4004: static void ParseStyleDeclaration (Element el, STRING cssRule, Document doc, CSSInfoPtr css, ThotBool destroy)
1.1 cvs 4005: #else
4006: static void ParseStyleDeclaration (el, cssRule, doc, css, destroy)
4007: Element el;
4008: STRING cssRule;
4009: Document doc;
4010: CSSInfoPtr css;
1.14 cvs 4011: ThotBool destroy;
1.1 cvs 4012: #endif
4013: {
4014: GenericContext ctxt;
4015: STRING decl_end;
4016: STRING sel_end;
4017: STRING selector;
1.7 cvs 4018: CHAR_T saved1;
4019: CHAR_T saved2;
1.1 cvs 4020:
4021: /* separate the selectors string */
1.13 cvs 4022: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 4023: decl_end = cssRule;
4024: while ((*decl_end != EOS) && (*decl_end != '{'))
4025: decl_end++;
4026: if (*decl_end == EOS)
4027: return;
4028: /* verify and clean the selector string */
4029: sel_end = decl_end - 1;
1.18 cvs 4030: while (*sel_end == SPACE || *sel_end == BSPACE ||
4031: *sel_end == EOL || *sel_end == __CR__)
1.1 cvs 4032: sel_end--;
4033: sel_end++;
4034: saved1 = *sel_end;
4035: *sel_end = EOS;
4036: selector = cssRule;
4037:
4038: /* now, deal with the content ... */
4039: decl_end++;
4040: cssRule = decl_end;
4041: while (*decl_end != EOS && *decl_end != '}')
4042: decl_end++;
4043: if (*decl_end == EOS)
4044: {
4045: fprintf (stderr, "Invalid STYLE declaration : %s\n", cssRule);
4046: return;
4047: }
4048: saved2 = *decl_end;
4049: *decl_end = EOS;
4050:
4051: /*
4052: * parse the style attribute string and install the corresponding
4053: * presentation attributes on the new element
4054: */
4055: ctxt = TtaGetGenericStyleContext (doc);
4056: if (ctxt == NULL)
4057: return;
4058: ctxt->destroy = destroy;
4059:
4060: while ((selector != NULL) && (*selector != EOS))
1.25 cvs 4061: selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css);
1.1 cvs 4062: TtaFreeMemory (ctxt);
4063:
4064: /* restore the string to its original form ! */
4065: *sel_end = saved1;
4066: *decl_end = saved2;
4067: }
4068:
4069: /************************************************************************
4070: * *
4071: * EVALUATION FUNCTIONS / CASCADING AND OVERLOADING *
4072: * *
4073: ************************************************************************/
4074:
4075: /*----------------------------------------------------------------------
4076: IsImplicitClassName : return wether the Class name is an
4077: implicit one, eg "H1" or "H2 EM" meaning it's a GI name
4078: or an HTML context name.
4079: ----------------------------------------------------------------------*/
4080: #ifdef __STDC__
4081: int IsImplicitClassName (STRING class, Document doc)
4082: #else
4083: int IsImplicitClassName (class, doc)
4084: STRING class;
4085: Document doc;
4086: #endif
4087: {
1.25 cvs 4088: CHAR_T name[200];
4089: STRING cur = name, first;
4090: CHAR_T save;
1.1 cvs 4091: SSchema schema;
4092:
4093: /* make a local copy */
4094: ustrncpy (name, class, 199);
4095: name[199] = 0;
4096:
4097: /* loop looking if each word is a GI */
4098: while (*cur != 0)
4099: {
4100: first = cur;
4101: cur = SkipWord (cur);
4102: save = *cur;
4103: *cur = 0;
4104: schema = NULL;
4105: if (MapGI (first, &schema, doc) == -1)
4106: {
4107: return (0);
4108: }
4109: *cur = save;
1.13 cvs 4110: cur = SkipBlanksAndComments (cur);
1.1 cvs 4111: }
4112: return (1);
4113: }
4114:
4115: /************************************************************************
4116: * *
4117: * Functions Needed for support of HTML 3.2 : translate to CSS equiv *
4118: * *
4119: ************************************************************************/
4120:
4121: /*----------------------------------------------------------------------
4122: HTMLSetBackgroundColor :
4123: ----------------------------------------------------------------------*/
4124: #ifdef __STDC__
4125: void HTMLSetBackgroundColor (Document doc, Element el, STRING color)
4126: #else
4127: void HTMLSetBackgroundColor (doc, el, color)
4128: Document doc;
4129: Element el;
4130: STRING color;
4131: #endif
4132: {
1.7 cvs 4133: CHAR_T css_command[100];
1.1 cvs 4134:
1.17 cvs 4135: usprintf (css_command, TEXT("background-color: %s"), color);
1.1 cvs 4136: ParseHTMLSpecificStyle (el, css_command, doc, FALSE);
4137: }
4138:
4139: /*----------------------------------------------------------------------
4140: HTMLSetBackgroundImage :
4141: repeat = repeat value
4142: image = url of background image
4143: ----------------------------------------------------------------------*/
4144: #ifdef __STDC__
4145: void HTMLSetBackgroundImage (Document doc, Element el, int repeat, STRING image)
4146: #else
4147: void HTMLSetBackgroundImage (doc, el, repeat, image)
4148: Document doc;
4149: Element el;
4150: int repeat;
4151: STRING image;
4152: #endif
4153: {
1.7 cvs 4154: CHAR_T css_command[400];
1.1 cvs 4155:
4156: /******* check buffer overflow ********/
1.17 cvs 4157: usprintf (css_command, TEXT("background-image: url(%s); background-repeat: "), image);
1.1 cvs 4158: if (repeat == STYLE_REPEAT)
1.17 cvs 4159: ustrcat (css_command, TEXT("repeat"));
1.1 cvs 4160: else if (repeat == STYLE_HREPEAT)
1.17 cvs 4161: ustrcat (css_command, TEXT("repeat-x"));
1.1 cvs 4162: else if (repeat == STYLE_VREPEAT)
1.17 cvs 4163: ustrcat (css_command, TEXT("repeat-y"));
1.1 cvs 4164: else
1.17 cvs 4165: ustrcat (css_command, TEXT("no-repeat"));
1.1 cvs 4166: ParseHTMLSpecificStyle (el, css_command, doc, FALSE);
4167: }
4168:
4169: /*----------------------------------------------------------------------
4170: HTMLSetForegroundColor :
4171: ----------------------------------------------------------------------*/
4172: #ifdef __STDC__
4173: void HTMLSetForegroundColor (Document doc, Element el, STRING color)
4174: #else
4175: void HTMLSetForegroundColor (doc, el, color)
4176: Document doc;
4177: Element el;
4178: STRING color;
4179: #endif
4180: {
1.7 cvs 4181: CHAR_T css_command[100];
1.1 cvs 4182:
1.17 cvs 4183: usprintf (css_command, TEXT("color: %s"), color);
1.1 cvs 4184: ParseHTMLSpecificStyle (el, css_command, doc, FALSE);
4185: }
4186:
4187: /*----------------------------------------------------------------------
4188: HTMLResetBackgroundColor :
4189: ----------------------------------------------------------------------*/
4190: #ifdef __STDC__
4191: void HTMLResetBackgroundColor (Document doc, Element el)
4192: #else
4193: void HTMLResetBackgroundColor (doc, el)
4194: Document doc;
4195: Element el;
4196: #endif
4197: {
1.7 cvs 4198: CHAR_T css_command[100];
1.1 cvs 4199:
1.36 cvs 4200: usprintf (css_command, TEXT("background: red"));
1.1 cvs 4201: ParseHTMLSpecificStyle (el, css_command, doc, TRUE);
4202: }
4203:
4204: /*----------------------------------------------------------------------
4205: HTMLResetBackgroundImage :
4206: ----------------------------------------------------------------------*/
4207: #ifdef __STDC__
4208: void HTMLResetBackgroundImage (Document doc, Element el)
4209: #else
4210: void HTMLResetBackgroundImage (doc, el)
4211: Document doc;
4212: Element el;
4213: #endif
4214: {
1.7 cvs 4215: CHAR_T css_command[1000];
1.1 cvs 4216:
1.17 cvs 4217: usprintf (css_command, TEXT("background-image: url(xx); background-repeat: repeat"));
1.1 cvs 4218: ParseHTMLSpecificStyle (el, css_command, doc, TRUE);
4219: }
4220:
4221: /*----------------------------------------------------------------------
4222: HTMLResetForegroundColor :
4223: ----------------------------------------------------------------------*/
4224: #ifdef __STDC__
4225: void HTMLResetForegroundColor (Document doc, Element el)
4226: #else
4227: void HTMLResetForegroundColor (doc, el)
4228: Document doc;
4229: Element el;
4230: #endif
4231: {
1.7 cvs 4232: CHAR_T css_command[100];
1.1 cvs 4233:
1.36 cvs 4234: /* it's not necessary to well know the current color but it must be valid */
4235: usprintf (css_command, TEXT("color: red"));
1.1 cvs 4236: ParseHTMLSpecificStyle (el, css_command, doc, TRUE);
4237: }
4238:
4239: /*----------------------------------------------------------------------
4240: HTMLSetAlinkColor :
4241: ----------------------------------------------------------------------*/
4242: #ifdef __STDC__
4243: void HTMLSetAlinkColor (Document doc, STRING color)
4244: #else
4245: void HTMLSetAlinkColor (doc, color)
4246: Document doc;
4247: STRING color;
4248: #endif
4249: {
1.7 cvs 4250: CHAR_T css_command[100];
1.1 cvs 4251:
1.37 cvs 4252: usprintf (css_command, TEXT("a:link { color : %s }"), color);
1.1 cvs 4253: ApplyCSSRules (NULL, css_command, doc, FALSE);
4254: }
4255:
4256: /*----------------------------------------------------------------------
4257: HTMLSetAactiveColor :
4258: ----------------------------------------------------------------------*/
4259: #ifdef __STDC__
4260: void HTMLSetAactiveColor (Document doc, STRING color)
4261: #else
4262: void HTMLSetAactiveColor (doc, color)
4263: Document doc;
4264: STRING color;
4265: #endif
4266: {
1.7 cvs 4267: CHAR_T css_command[100];
1.1 cvs 4268:
1.37 cvs 4269: usprintf (css_command, TEXT("a:active { color : %s }"), color);
1.1 cvs 4270: ApplyCSSRules (NULL, css_command, doc, FALSE);
4271: }
4272:
4273: /*----------------------------------------------------------------------
4274: HTMLSetAvisitedColor :
4275: ----------------------------------------------------------------------*/
4276: #ifdef __STDC__
4277: void HTMLSetAvisitedColor (Document doc, STRING color)
4278: #else
4279: void HTMLSetAvisitedColor (doc, color)
4280: Document doc;
4281: STRING color;
4282: #endif
4283: {
1.7 cvs 4284: CHAR_T css_command[100];
1.1 cvs 4285:
1.37 cvs 4286: usprintf (css_command, TEXT("a:visited { color : %s }"), color);
1.1 cvs 4287: ApplyCSSRules (NULL, css_command, doc, FALSE);
4288: }
4289:
4290: /*----------------------------------------------------------------------
4291: HTMLResetAlinkColor :
4292: ----------------------------------------------------------------------*/
4293: #ifdef __STDC__
4294: void HTMLResetAlinkColor (Document doc)
4295: #else
4296: void HTMLResetAlinkColor (doc)
4297: Document doc;
4298: #endif
4299: {
1.7 cvs 4300: CHAR_T css_command[100];
1.1 cvs 4301:
1.37 cvs 4302: usprintf (css_command, TEXT("a:link { color : red }"));
1.1 cvs 4303: ApplyCSSRules (NULL, css_command, doc, TRUE);
4304: }
4305:
4306: /*----------------------------------------------------------------------
4307: HTMLResetAactiveColor :
4308: ----------------------------------------------------------------------*/
4309: #ifdef __STDC__
4310: void HTMLResetAactiveColor (Document doc)
4311: #else
4312: void HTMLResetAactiveColor (doc)
4313: Document doc;
4314: #endif
4315: {
1.7 cvs 4316: CHAR_T css_command[100];
1.1 cvs 4317:
1.37 cvs 4318: usprintf (css_command, TEXT("a:active { color : red }"));
1.1 cvs 4319: ApplyCSSRules (NULL, css_command, doc, TRUE);
4320: }
4321:
4322: /*----------------------------------------------------------------------
4323: HTMLResetAvisitedColor :
4324: ----------------------------------------------------------------------*/
4325: #ifdef __STDC__
4326: void HTMLResetAvisitedColor (Document doc)
4327: #else
4328: void HTMLResetAvisitedColor (doc)
4329: Document doc;
4330: #endif
4331: {
1.7 cvs 4332: CHAR_T css_command[100];
1.1 cvs 4333:
1.37 cvs 4334: usprintf (css_command, TEXT("a:visited { color : red }"));
1.1 cvs 4335: ApplyCSSRules (NULL, css_command, doc, TRUE);
4336: }
4337:
4338: /*----------------------------------------------------------------------
4339: ApplyCSSRules: parse an CSS Style description stored in the
4340: header of a HTML document.
4341: ----------------------------------------------------------------------*/
4342: #ifdef __STDC__
1.14 cvs 4343: void ApplyCSSRules (Element el, STRING cssRule, Document doc, ThotBool destroy)
1.1 cvs 4344: #else
4345: void ApplyCSSRules (el, cssRule, doc, destroy)
4346: Element el;
4347: STRING cssRule;
4348: Document doc;
1.14 cvs 4349: ThotBool destroy;
1.1 cvs 4350: #endif
4351: {
4352: CSSInfoPtr css;
4353:
4354: css = SearchCSS (doc, NULL);
4355: if (css == NULL)
4356: /* create the document css */
4357: css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, NULL, NULL);
4358: ParseStyleDeclaration (el, cssRule, doc, css, destroy);
4359: }
4360:
4361: /*----------------------------------------------------------------------
4362: ReadCSSRules : is the front-end function called by the HTML parser
4363: when detecting a <STYLE TYPE="text/css"> indicating it's the
4364: beginning of a CSS fragment or when reading a file .css.
4365:
4366: The CSS parser has to handle <!-- ... --> constructs used to
4367: prevent prehistoric browser from displaying the CSS as a text
4368: content. It will stop on any sequence "<x" where x is different
4369: from ! and will return x as to the caller. Theorically x should
4370: be equal to / for the </STYLE> end of style.
4371:
4372: The parameter doc gives the document tree that contains CSS information.
4373: The parameter docRef gives the document to which CSS are to be applied.
4374: This function uses the current css context or creates it. It's able
1.23 cvs 4375: to work on the given buffer or call GetNextChar to read the parsed
1.1 cvs 4376: file.
4377: Parameter withUndo indicates whether the changes made in the document
4378: structure and content have to be registered in the Undo queue or not
4379: ----------------------------------------------------------------------*/
4380: #ifdef __STDC__
1.18 cvs 4381: CHAR_T ReadCSSRules (Document docRef, CSSInfoPtr css, STRING buffer, ThotBool withUndo)
1.1 cvs 4382: #else
1.18 cvs 4383: CHAR_T ReadCSSRules (docRef, css, buffer, withUndo)
1.1 cvs 4384: Document docRef;
4385: CSSInfoPtr css;
4386: STRING buffer;
1.14 cvs 4387: ThotBool withUndo;
1.1 cvs 4388: #endif
4389: {
1.13 cvs 4390: CHAR_T c;
1.31 cvs 4391: STRING cssRule, base;
1.6 cvs 4392: DisplayMode dispMode;
1.19 cvs 4393: int index;
1.1 cvs 4394: int CSSindex;
4395: int CSScomment;
4396: int import;
4397: int openRule;
1.14 cvs 4398: ThotBool HTMLcomment;
4399: ThotBool toParse, eof;
1.36 cvs 4400: ThotBool ignoreMedia, media;
1.25 cvs 4401: ThotBool noRule;
1.1 cvs 4402:
4403: CSScomment = MAX_CSS_LENGTH;
4404: HTMLcomment = FALSE;
4405: CSSindex = 0;
4406: toParse = FALSE;
4407: noRule = FALSE;
1.36 cvs 4408: media = FALSE;
1.1 cvs 4409: ignoreMedia = FALSE;
4410: import = MAX_CSS_LENGTH;
4411: eof = FALSE;
4412: openRule = 0;
4413: c = SPACE;
4414: index = 0;
1.6 cvs 4415: /* avoid too many redisplay */
4416: dispMode = TtaGetDisplayMode (docRef);
4417: if (dispMode == DisplayImmediately)
4418: TtaSetDisplayMode (docRef, DeferredDisplay);
1.18 cvs 4419:
4420: /* look for the CSS context */
4421: if (css == NULL)
4422: css = SearchCSS (docRef, NULL);
4423: if (css == NULL)
4424: css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL);
1.1 cvs 4425:
1.25 cvs 4426: while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof)
1.1 cvs 4427: {
1.23 cvs 4428: c = buffer[index++];
4429: eof = (c == EOS);
1.1 cvs 4430: CSSbuffer[CSSindex] = c;
1.13 cvs 4431: if (CSScomment == MAX_CSS_LENGTH || c == '*' || c == '/' || c == '<')
1.1 cvs 4432: {
1.5 cvs 4433: /* we're not within a comment or we're parsing * or / */
4434: switch (c)
1.1 cvs 4435: {
1.5 cvs 4436: case '@':
4437: /* perhaps an import primitive */
4438: import = CSSindex;
4439: break;
4440: case ';':
1.36 cvs 4441: if (import != MAX_CSS_LENGTH && !media)
1.5 cvs 4442: {
1.17 cvs 4443: if (ustrncasecmp (&CSSbuffer[import+1], TEXT("import"), 6))
1.5 cvs 4444: /* it's not an import */
4445: import = MAX_CSS_LENGTH;
4446: /* save the text */
4447: noRule = TRUE;
4448: }
4449: break;
4450: case '*':
1.13 cvs 4451: if (CSScomment == MAX_CSS_LENGTH &&
4452: CSSindex > 0 && CSSbuffer[CSSindex - 1] == '/')
1.5 cvs 4453: /* start a comment */
4454: CSScomment = CSSindex - 1;
4455: break;
4456: case '/':
1.8 cvs 4457: if (CSSindex > 1 &&
1.13 cvs 4458: CSScomment != MAX_CSS_LENGTH &&
4459: CSSbuffer[CSSindex - 1] == '*')
1.5 cvs 4460: {
1.25 cvs 4461: /* close a comment:and ignore its contents */
4462: CSSindex = CSScomment - 1; /* will be incremented later */
1.5 cvs 4463: CSScomment = MAX_CSS_LENGTH;
4464: }
1.25 cvs 4465: else if (CSScomment == MAX_CSS_LENGTH &&
4466: CSSindex > 0 &&
4467: CSSbuffer[CSSindex - 1] == '<')
1.5 cvs 4468: {
4469: /* this is the closing tag ! */
4470: CSSindex -= 2; /* remove </ from the CSS string */
1.13 cvs 4471: noRule = TRUE;
1.8 cvs 4472: }
1.5 cvs 4473: break;
4474: case '<':
1.25 cvs 4475: if (CSScomment == MAX_CSS_LENGTH)
1.5 cvs 4476: {
1.25 cvs 4477: /* only if we're not parsing a comment */
4478: c = buffer[index++];
4479: eof = (c == EOS);
4480: if (c == '!')
4481: {
4482: /* CSS within an HTML comment */
4483: HTMLcomment = TRUE;
4484: CSSindex++;
4485: CSSbuffer[CSSindex] = c;
4486: }
4487: else if (c == EOS)
4488: CSSindex++;
1.5 cvs 4489: }
4490: break;
4491: case '-':
4492: if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' && HTMLcomment)
4493: /* CSS within an HTML comment */
4494: noRule = TRUE;
4495: break;
4496: case '>':
4497: if (HTMLcomment)
4498: noRule = TRUE;
4499: break;
1.36 cvs 4500: case ' ':
4501: if (import != MAX_CSS_LENGTH && openRule == 0)
4502: media = !ustrncmp (&CSSbuffer[import+1], TEXT("media"), 5);
4503: break;
1.5 cvs 4504: case '{':
4505: openRule++;
1.36 cvs 4506: if (import != MAX_CSS_LENGTH && openRule == 1 && media)
1.5 cvs 4507: {
4508: /* is it the screen concerned? */
4509: CSSbuffer[CSSindex+1] = EOS;
1.25 cvs 4510: if (TtaIsPrinting ())
4511: base = ustrstr (&CSSbuffer[import], TEXT("print"));
4512: else
4513: base = ustrstr (&CSSbuffer[import], TEXT("screen"));
1.5 cvs 4514: if (base == NULL)
4515: ignoreMedia = TRUE;
4516: noRule = TRUE;
4517: }
4518: break;
4519: case '}':
4520: openRule--;
4521: if (import != MAX_CSS_LENGTH && openRule == 0)
4522: {
4523: import = MAX_CSS_LENGTH;
4524: noRule = TRUE;
4525: ignoreMedia = FALSE;
1.36 cvs 4526: media = FALSE;
1.12 cvs 4527: }
1.5 cvs 4528: else
4529: toParse = TRUE;
4530: break;
4531: default:
4532: break;
1.1 cvs 4533: }
4534: }
1.18 cvs 4535: if (c != __CR__)
1.13 cvs 4536: CSSindex++;
1.12 cvs 4537:
1.29 cvs 4538: if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
4539: /* we're still parsing a comment: remove the text comment */
4540: CSSindex = CSScomment;
4541:
1.25 cvs 4542: if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule)
1.1 cvs 4543: {
4544: CSSbuffer[CSSindex] = EOS;
4545: /* parse a not empty string */
4546: if (CSSindex > 0)
4547: {
4548: /* apply CSS rule if it's not just a saving of text */
4549: if (!noRule && !ignoreMedia)
1.18 cvs 4550: ParseStyleDeclaration (NULL, CSSbuffer, docRef, css, FALSE);
1.1 cvs 4551: else if (import != MAX_CSS_LENGTH &&
1.17 cvs 4552: !ustrncasecmp (&CSSbuffer[import+1], TEXT("import"), 6))
1.1 cvs 4553: {
4554: /* import section */
4555: cssRule = &CSSbuffer[import+7];
4556: cssRule = TtaSkipBlanks (cssRule);
1.17 cvs 4557: if (!ustrncasecmp (cssRule, TEXT("url"), 3))
1.1 cvs 4558: {
1.13 cvs 4559: cssRule = &cssRule[3];
1.1 cvs 4560: cssRule = TtaSkipBlanks (cssRule);
4561: if (*cssRule == '(')
4562: {
4563: cssRule++;
4564: cssRule = TtaSkipBlanks (cssRule);
4565: base = cssRule;
4566: while (*cssRule != EOS && *cssRule != ')')
4567: cssRule++;
4568: *cssRule = EOS;
1.38 cvs 4569: LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
1.1 cvs 4570: }
4571: }
4572: /*** Caution: Strings can either be written with double quotes or
4573: with single quotes. Only double quotes are handled here.
4574: Escaped quotes are not handled. See function SkipQuotedString */
4575: else if (*cssRule == '"')
4576: {
4577: cssRule++;
4578: base = cssRule;
4579: while (*cssRule != EOS && *cssRule != '"')
4580: cssRule++;
4581: *cssRule = EOS;
1.38 cvs 4582: LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
1.1 cvs 4583: }
4584: import = MAX_CSS_LENGTH;
4585: }
4586: }
4587: toParse = FALSE;
4588: noRule = FALSE;
4589: CSSindex = 0;
4590: }
4591: }
1.6 cvs 4592: /* restore the display mode */
4593: if (dispMode == DisplayImmediately)
4594: TtaSetDisplayMode (docRef, dispMode);
1.1 cvs 4595: return (c);
4596: }
Webmaster