Annotation of Amaya/amaya/styleparser.c, revision 1.266
1.1 cvs 1: /*
2: *
1.249 vatton 3: * (c) COPYRIGHT INRIA and W3C, 1996-2004
1.1 cvs 4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
1.164 quint 7:
1.1 cvs 8: /*
1.164 quint 9: * Everything directly related to the CSS syntax should now hopefully
1.1 cvs 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"
1.25 cvs 20: #include "fetchHTMLname.h"
1.100 vatton 21: #include "SVG.h"
1.107 cvs 22: #include "XML.h"
1.141 cvs 23: #include "document.h"
1.1 cvs 24:
25: typedef struct _BackgroundImageCallbackBlock
26: {
1.207 vatton 27: Element el;
28: PSchema tsch;
29: CSSInfoPtr css;
30: PresentationContext ctxt;
1.1 cvs 31: }
32: BackgroundImageCallbackBlock, *BackgroundImageCallbackPtr;
33:
34: #include "AHTURLTools_f.h"
35: #include "HTMLpresentation_f.h"
36: #include "HTMLimage_f.h"
37: #include "UIcss_f.h"
38: #include "css_f.h"
1.24 cvs 39: #include "fetchHTMLname_f.h"
1.91 cvs 40: #include "fetchXMLname_f.h"
1.1 cvs 41: #include "html2thot_f.h"
1.91 cvs 42: #include "init_f.h"
1.1 cvs 43: #include "styleparser_f.h"
44:
45: #define MAX_BUFFER_LENGTH 200
46: /*
47: * A PropertyParser is a function used to parse the
48: * description substring associated to a given style attribute
1.59 cvs 49: * e.g.: "red" for a color attribute or "12pt bold helvetica"
1.1 cvs 50: * for a font attribute.
51: */
1.79 cvs 52: typedef char *(*PropertyParser) (Element element,
1.56 cvs 53: PSchema tsch,
54: PresentationContext context,
1.79 cvs 55: char *cssRule,
1.56 cvs 56: CSSInfoPtr css,
57: ThotBool isHTML);
1.1 cvs 58:
59: /* Description of the set of CSS properties supported */
60: typedef struct CSSProperty
61: {
1.79 cvs 62: char *name;
1.25 cvs 63: PropertyParser parsing_function;
1.1 cvs 64: }
65: CSSProperty;
66:
1.86 cvs 67: static char *DocURL = NULL; /* The parsed CSS file */
68: static int LineNumber = -1; /* The line where the error occurs */
1.93 vatton 69: static int NewLineSkipped = 0;
1.116 vatton 70: static ThotBool DoApply = TRUE;
1.1 cvs 71:
72: /*----------------------------------------------------------------------
73: SkipWord:
74: ----------------------------------------------------------------------*/
1.79 cvs 75: static char *SkipWord (char *ptr)
1.1 cvs 76: {
1.168 vatton 77: while (isalnum((int)*ptr) || *ptr == '-' || *ptr == '#' || *ptr == '%')
78: ptr++;
1.1 cvs 79: return (ptr);
80: }
81:
82: /*----------------------------------------------------------------------
1.13 cvs 83: SkipBlanksAndComments:
84: ----------------------------------------------------------------------*/
1.82 cvs 85: char *SkipBlanksAndComments (char *ptr)
1.13 cvs 86: {
1.93 vatton 87: /* skip spaces */
1.155 cheyroul 88: while (*ptr == SPACE ||
89: *ptr == BSPACE ||
90: *ptr == EOL ||
91: *ptr == TAB ||
92: *ptr == __CR__)
1.93 vatton 93: {
94: if (*ptr == EOL)
95: /* increment the number of newline skipped */
96: NewLineSkipped++;
97: ptr++;
98: }
1.155 cheyroul 99: while (ptr[0] == '/' &&
100: ptr[1] == '*')
1.13 cvs 101: {
102: /* look for the end of the comment */
103: ptr = &ptr[2];
104: while (ptr[0] != EOS && (ptr[0] != '*' || ptr[1] != '/'))
105: ptr++;
106: if (ptr[0] != EOS)
107: ptr = &ptr[2];
1.93 vatton 108: /* skip spaces */
109: while (*ptr == SPACE || *ptr == BSPACE || *ptr == EOL ||
110: *ptr == TAB || *ptr == __CR__)
111: {
112: if (*ptr == EOL)
113: /* increment the number of newline skipped */
114: NewLineSkipped++;
115: ptr++;
116: }
1.13 cvs 117: }
118: return (ptr);
119: }
120:
1.49 cvs 121: /*----------------------------------------------------------------------
1.161 quint 122: SkipQuotedString
1.1 cvs 123: ----------------------------------------------------------------------*/
1.79 cvs 124: static char *SkipQuotedString (char *ptr, char quote)
1.1 cvs 125: {
1.14 cvs 126: ThotBool stop;
1.1 cvs 127:
128: stop = FALSE;
129: while (!stop)
130: {
131: if (*ptr == quote)
132: {
133: ptr++;
134: stop = TRUE;
135: }
1.82 cvs 136: else if (*ptr == EOS)
1.1 cvs 137: stop = TRUE;
1.82 cvs 138: else if (*ptr == '\\')
1.1 cvs 139: /* escape character */
140: {
141: ptr++;
1.82 cvs 142: if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
143: (*ptr >= 'a' && *ptr <= 'f'))
1.1 cvs 144: {
145: ptr++;
1.82 cvs 146: if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
147: (*ptr >= 'a' && *ptr <= 'f'))
1.1 cvs 148: ptr++;
149: }
150: else
151: ptr++;
152: }
153: else
154: ptr++;
155: }
156: return (ptr);
157: }
158:
159: /*----------------------------------------------------------------------
1.168 vatton 160: CSSPrintError
1.86 cvs 161: print the error message msg on stderr.
162: When the line is 0 ask to expat the current line number
163: ----------------------------------------------------------------------*/
1.168 vatton 164: static void CSSPrintError (char *msg, char *value)
1.86 cvs 165: {
166: if (!TtaIsPrinting () && ParsedDoc > 0)
167: {
168: if (!ErrFile)
169: {
1.90 cvs 170: if (OpenParsingErrors (ParsedDoc) == FALSE)
1.86 cvs 171: return;
172: }
173:
1.133 vatton 174: if (DocURL)
1.86 cvs 175: {
1.241 vatton 176: fprintf (ErrFile, "\n*** Errors/warnings in %s\n", DocURL);
1.86 cvs 177: /* set to NULL as long as the CSS file doesn't change */
178: DocURL = NULL;
179: }
1.89 cvs 180: CSSErrorsFound = TRUE;
1.86 cvs 181: if (LineNumber < 0)
1.205 quint 182: fprintf (ErrFile, " In style attribute, %s \"%s\"\n", msg, value);
1.86 cvs 183: else
1.232 vatton 184: fprintf (ErrFile, "@ line %d: %s \"%s\"\n", LineNumber+NewLineSkipped,
1.93 vatton 185: msg, value);
1.86 cvs 186: }
187: }
188:
1.168 vatton 189: /*----------------------------------------------------------------------
190: CSSParseError
191: print the error message msg on stderr.
1.230 quint 192: When the line is 0 ask expat about the current line number
1.168 vatton 193: ----------------------------------------------------------------------*/
194: static void CSSParseError (char *msg, char *value, char *endvalue)
195: {
1.230 quint 196: char c = EOS;
1.168 vatton 197:
198: if (endvalue)
199: {
200: /* close the string here */
201: c = *endvalue;
202: *endvalue = EOS;
203: }
204: CSSPrintError (msg, value);
205: if (endvalue)
206: *endvalue = c;
207: }
208:
1.89 cvs 209:
1.86 cvs 210: /*----------------------------------------------------------------------
1.168 vatton 211: SkipProperty skips a property and display and error message
1.86 cvs 212: ----------------------------------------------------------------------*/
1.234 vatton 213: static char *SkipProperty (char *ptr, ThotBool reportError)
1.86 cvs 214: {
215: char *deb;
216: char c;
217:
218: deb = ptr;
1.135 vatton 219: while (*ptr != EOS && *ptr != ';' && *ptr != '}')
1.133 vatton 220: {
1.194 vatton 221: if (*ptr == '"' && (ptr == deb || ptr[-1] != '\\'))
1.133 vatton 222: {
223: /* skip to the end of the string "..." */
224: ptr++;
1.194 vatton 225: while (*ptr != EOS &&
226: (*ptr != '"' || (*ptr == '"' && ptr[-1] == '\\')))
1.133 vatton 227: ptr++;
228: }
229: ptr++;
230: }
1.95 cvs 231: /* print the skipped property */
1.86 cvs 232: c = *ptr;
233: *ptr = EOS;
1.234 vatton 234: if (reportError && *deb != EOS &&
1.259 vatton 235: strncasecmp (deb, "border-collapse", 15) &&
1.234 vatton 236: strncasecmp (deb, "border-spacing", 14) &&
237: strncasecmp (deb, "caption-side", 12) &&
238: strncasecmp (deb, "clip", 4) &&
239: strncasecmp (deb, "counter-increment", 16) &&
240: strncasecmp (deb, "counter-reset", 13) &&
241: strncasecmp (deb, "cursor", 6) &&
242: strncasecmp (deb, "empty-cells", 11) &&
1.259 vatton 243: strncasecmp (deb, "font-strech", 11) &&
1.234 vatton 244: strncasecmp (deb, "letter-spacing", 14) &&
1.242 vatton 245: strncasecmp (deb, "marker-offset", 12) &&
1.234 vatton 246: strncasecmp (deb, "max-height", 10) &&
247: strncasecmp (deb, "max-width", 9) &&
248: strncasecmp (deb, "min-height", 10) &&
249: strncasecmp (deb, "min-width", 9) &&
250: strncasecmp (deb, "orphans", 7) &&
251: strncasecmp (deb, "outline-color", 13) &&
252: strncasecmp (deb, "outline-style", 13) &&
253: strncasecmp (deb, "outline-width", 13) &&
254: strncasecmp (deb, "outline", 7) &&
255: strncasecmp (deb, "overflow", 8) &&
256: strncasecmp (deb, "quotes", 6) &&
257: strncasecmp (deb, "table-layout", 12) &&
1.259 vatton 258: strncasecmp (deb, "text-shadow", 11) &&
1.234 vatton 259: strncasecmp (deb, "visibility", 10) &&
1.258 vatton 260: strncasecmp (deb, "widows", 6))
1.205 quint 261: CSSPrintError ("CSS property ignored:", deb);
1.86 cvs 262: *ptr = c;
263: return (ptr);
264: }
265:
266: /*----------------------------------------------------------------------
1.168 vatton 267: SkipValue
268: skips the value and display an error message if msg is not NULL
1.1 cvs 269: ----------------------------------------------------------------------*/
1.168 vatton 270: static char *SkipValue (char *msg, char *ptr)
1.1 cvs 271: {
1.86 cvs 272: char *deb;
273: char c;
274:
275: deb = ptr;
1.135 vatton 276: while (*ptr != EOS && *ptr != ';' && *ptr != '}')
1.133 vatton 277: {
278: if (*ptr == '"' && (ptr == deb || ptr[-1] != '\\'))
279: {
280: /* skip to the end of the string "..." */
281: ptr++;
1.184 vatton 282: while (*ptr != '"' || (ptr[0] == '"' && ptr[-1] == '\\'))
1.133 vatton 283: ptr++;
284: }
285: ptr++;
286: }
1.95 cvs 287: /* print the skipped property */
1.86 cvs 288: c = *ptr;
289: *ptr = EOS;
1.168 vatton 290: if (msg && *deb != EOS && *deb != ',')
291: CSSPrintError (msg, deb);
1.86 cvs 292: *ptr = c;
1.1 cvs 293: return (ptr);
294: }
295:
296: /*----------------------------------------------------------------------
1.64 cvs 297: ParseNumber:
298: parse a number and returns the corresponding value.
1.1 cvs 299: ----------------------------------------------------------------------*/
1.79 cvs 300: char *ParseNumber (char *cssRule, PresentationValue *pval)
1.1 cvs 301: {
302: int val = 0;
303: int minus = 0;
304: int valid = 0;
305: int f = 0;
1.14 cvs 306: ThotBool real = FALSE;
1.1 cvs 307:
1.184 vatton 308: pval->typed_data.unit = UNIT_REL;
1.1 cvs 309: pval->typed_data.real = FALSE;
1.82 cvs 310: cssRule = SkipBlanksAndComments (cssRule);
311: if (*cssRule == '-')
1.1 cvs 312: {
313: minus = 1;
314: cssRule++;
1.82 cvs 315: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 316: }
317:
1.82 cvs 318: if (*cssRule == '+')
1.1 cvs 319: {
320: cssRule++;
1.82 cvs 321: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 322: }
323:
1.82 cvs 324: while ((*cssRule >= '0') && (*cssRule <= '9'))
1.1 cvs 325: {
326: val *= 10;
1.82 cvs 327: val += *cssRule - '0';
1.1 cvs 328: cssRule++;
329: valid = 1;
330: }
331:
1.82 cvs 332: if (*cssRule == '.')
1.1 cvs 333: {
334: real = TRUE;
335: f = val;
336: val = 0;
337: cssRule++;
338: /* keep only 3 digits */
1.82 cvs 339: if (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 340: {
1.82 cvs 341: val = (*cssRule - '0') * 100;
1.1 cvs 342: cssRule++;
1.82 cvs 343: if (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 344: {
1.82 cvs 345: val += (*cssRule - '0') * 10;
1.1 cvs 346: cssRule++;
1.82 cvs 347: if ((*cssRule >= '0') && (*cssRule <= '9'))
1.1 cvs 348: {
1.82 cvs 349: val += *cssRule - '0';
1.1 cvs 350: cssRule++;
351: }
352: }
353:
1.82 cvs 354: while (*cssRule >= '0' && *cssRule <= '9')
1.1 cvs 355: cssRule++;
356: valid = 1;
357: }
358: }
359:
360: if (!valid)
361: {
1.184 vatton 362: pval->typed_data.unit = UNIT_INVALID;
1.1 cvs 363: pval->typed_data.value = 0;
364: }
365: else
366: {
367: pval->typed_data.real = real;
368: if (real)
369: {
370: if (minus)
371: pval->typed_data.value = -(f * 1000 + val);
372: else
373: pval->typed_data.value = f * 1000 + val;
374: }
375: else
376: {
377: if (minus)
378: pval->typed_data.value = -val;
379: else
380: pval->typed_data.value = val;
381: }
1.64 cvs 382: }
383: return (cssRule);
384: }
1.195 vatton 385:
1.155 cheyroul 386: /*----------------------------------------------------------------------
1.64 cvs 387: ParseCSSUnit:
388: parse a CSS Unit substring and returns the corresponding
389: value and its unit.
390: ----------------------------------------------------------------------*/
1.82 cvs 391: char *ParseCSSUnit (char *cssRule, PresentationValue *pval)
1.64 cvs 392: {
393: unsigned int uni;
394:
1.184 vatton 395: pval->typed_data.unit = UNIT_REL;
1.64 cvs 396: cssRule = ParseNumber (cssRule, pval);
1.184 vatton 397: if (pval->typed_data.unit == UNIT_INVALID)
1.64 cvs 398: cssRule = SkipWord (cssRule);
399: else
400: {
1.82 cvs 401: cssRule = SkipBlanksAndComments (cssRule);
1.231 vatton 402: uni = 0;
403: while (CSSUnitNames[uni].sign)
1.64 cvs 404: {
1.82 cvs 405: if (!strncasecmp (CSSUnitNames[uni].sign, cssRule,
406: strlen (CSSUnitNames[uni].sign)))
1.64 cvs 407: {
408: pval->typed_data.unit = CSSUnitNames[uni].unit;
1.82 cvs 409: return (cssRule + strlen (CSSUnitNames[uni].sign));
1.64 cvs 410: }
1.231 vatton 411: else
412: uni++;
1.64 cvs 413: }
414: /* not in the list of predefined units */
1.184 vatton 415: pval->typed_data.unit = UNIT_BOX;
1.1 cvs 416: }
417: return (cssRule);
418: }
419:
1.43 cvs 420: /*----------------------------------------------------------------------
1.239 vatton 421: ParseClampedUnit:
422: parse a CSS Unit substring and returns the corresponding value and unit.
423: [0,1]
424: ----------------------------------------------------------------------*/
425: char *ParseClampedUnit (char *cssRule, PresentationValue *pval)
426: {
1.251 vatton 427: char *p;
428:
429: p = cssRule;
1.239 vatton 430: cssRule = ParseNumber (cssRule, pval);
1.251 vatton 431: if (*cssRule != EOS && *cssRule != SPACE && *cssRule != ';')
1.239 vatton 432: {
1.251 vatton 433: cssRule++;
1.239 vatton 434: pval->typed_data.unit = UNIT_REL;
435: if (pval->typed_data.value > 100)
436: pval->typed_data.value = 1000;
437: else
438: pval->typed_data.value *= 10;
1.251 vatton 439: CSSParseError ("Invalid value", p, cssRule);
1.239 vatton 440: }
441: else
442: {
443: pval->typed_data.unit = UNIT_REL;
444: if (pval->typed_data.real)
445: pval->typed_data.real = FALSE;
446: else if (pval->typed_data.value > 1)
1.251 vatton 447: {
448: pval->typed_data.value = 1000;
449: CSSParseError ("Invalid value", p, cssRule);
450: }
451: else if (pval->typed_data.value < 0)
452: {
453: pval->typed_data.value = 0;
454: CSSParseError ("Invalid value", p, cssRule);
455: }
1.239 vatton 456: else
457: pval->typed_data.value *= 1000;
458: }
459: pval->data = pval->typed_data.value;
460: return (cssRule);
461: }
462:
463:
464: /*----------------------------------------------------------------------
1.43 cvs 465: ParseBorderValue
466: ----------------------------------------------------------------------*/
1.79 cvs 467: static char *ParseBorderValue (char *cssRule, PresentationValue *border)
1.43 cvs 468: {
1.168 vatton 469: char *ptr;
470:
1.43 cvs 471: /* first parse the attribute string */
472: border->typed_data.value = 0;
1.184 vatton 473: border->typed_data.unit = UNIT_INVALID;
1.43 cvs 474: border->typed_data.real = FALSE;
1.82 cvs 475: if (!strncasecmp (cssRule, "thin", 4))
1.43 cvs 476: {
1.184 vatton 477: border->typed_data.unit = UNIT_PX;
1.43 cvs 478: border->typed_data.value = 1;
479: cssRule = SkipWord (cssRule);
480: }
1.82 cvs 481: else if (!strncasecmp (cssRule, "medium", 6))
1.43 cvs 482: {
1.184 vatton 483: border->typed_data.unit = UNIT_PX;
1.43 cvs 484: border->typed_data.value = 3;
485: cssRule = SkipWord (cssRule);
486: }
1.82 cvs 487: else if (!strncasecmp (cssRule, "thick", 5))
1.43 cvs 488: {
1.184 vatton 489: border->typed_data.unit = UNIT_PX;
1.43 cvs 490: border->typed_data.value = 5;
491: cssRule = SkipWord (cssRule);
492: }
1.110 vatton 493: else if (isdigit (*cssRule) || *cssRule == '.')
1.166 vatton 494: {
1.168 vatton 495: ptr = cssRule;
1.166 vatton 496: cssRule = ParseCSSUnit (cssRule, border);
1.168 vatton 497: if (border->typed_data.value == 0)
1.184 vatton 498: border->typed_data.unit = UNIT_PX;
499: else if (border->typed_data.unit == UNIT_INVALID ||
1.244 vatton 500: border->typed_data.unit == UNIT_BOX ||
501: border->typed_data.unit == UNIT_PERCENT)
1.168 vatton 502: {
1.184 vatton 503: border->typed_data.unit = UNIT_INVALID;
1.168 vatton 504: border->typed_data.value = 0;
505: CSSParseError ("Invalid border-width value", ptr, cssRule);
506: }
1.166 vatton 507: }
1.43 cvs 508: return (cssRule);
509: }
510:
511: /*----------------------------------------------------------------------
512: ParseBorderStyle
513: ----------------------------------------------------------------------*/
1.79 cvs 514: static char *ParseBorderStyle (char *cssRule, PresentationValue *border)
1.43 cvs 515: {
516: /* first parse the attribute string */
517: border->typed_data.value = 0;
1.184 vatton 518: border->typed_data.unit = UNIT_PX;
1.43 cvs 519: border->typed_data.real = FALSE;
1.82 cvs 520: if (!strncasecmp (cssRule, "none", 4))
1.184 vatton 521: border->typed_data.value = BorderStyleNone;
1.82 cvs 522: else if (!strncasecmp (cssRule, "hidden", 6))
1.184 vatton 523: border->typed_data.value = BorderStyleHidden;
1.82 cvs 524: else if (!strncasecmp (cssRule, "dotted", 6))
1.184 vatton 525: border->typed_data.value = BorderStyleDotted;
1.82 cvs 526: else if (!strncasecmp (cssRule, "dashed", 6))
1.184 vatton 527: border->typed_data.value = BorderStyleDashed;
1.82 cvs 528: else if (!strncasecmp (cssRule, "solid", 5))
1.184 vatton 529: border->typed_data.value = BorderStyleSolid;
1.82 cvs 530: else if (!strncasecmp (cssRule, "double", 6))
1.184 vatton 531: border->typed_data.value = BorderStyleDouble;
1.82 cvs 532: else if (!strncasecmp (cssRule, "groove", 6))
1.184 vatton 533: border->typed_data.value = BorderStyleGroove;
1.82 cvs 534: else if (!strncasecmp (cssRule, "ridge", 5))
1.184 vatton 535: border->typed_data.value = BorderStyleRidge;
1.82 cvs 536: else if (!strncasecmp (cssRule, "inset", 5))
1.184 vatton 537: border->typed_data.value = BorderStyleInset;
1.82 cvs 538: else if (!strncasecmp (cssRule, "outset", 6))
1.184 vatton 539: border->typed_data.value = BorderStyleOutset;
1.43 cvs 540: else
1.44 cvs 541: {
542: /* invalid style */
1.184 vatton 543: border->typed_data.unit = UNIT_INVALID;
1.44 cvs 544: return (cssRule);
545: }
1.43 cvs 546: /* the value is parsed now */
547: cssRule = SkipWord (cssRule);
548: return (cssRule);
549: }
550:
551: /*----------------------------------------------------------------------
1.59 cvs 552: ParseCSSColor: parse a CSS color attribute string
1.43 cvs 553: we expect the input string describing the attribute to be
554: either a color name, a 3 tuple or an hexadecimal encoding.
555: The color used will be approximed from the current color
556: table
557: ----------------------------------------------------------------------*/
1.79 cvs 558: static char *ParseCSSColor (char *cssRule, PresentationValue * val)
1.43 cvs 559: {
1.79 cvs 560: char *ptr;
1.43 cvs 561: unsigned short redval = (unsigned short) -1;
562: unsigned short greenval = 0; /* composant of each RGB */
563: unsigned short blueval = 0; /* default to red if unknown ! */
564: int best = 0; /* best color in list found */
565:
1.82 cvs 566: cssRule = SkipBlanksAndComments (cssRule);
1.184 vatton 567: val->typed_data.unit = UNIT_INVALID;
1.43 cvs 568: val->typed_data.real = FALSE;
569: val->typed_data.value = 0;
1.57 cvs 570: ptr = TtaGiveRGB (cssRule, &redval, &greenval, &blueval);
1.135 vatton 571: if (!strncasecmp (cssRule, "inherit", 7))
572: {
573: cssRule = SkipWord (cssRule);
574: return (cssRule);
575: }
1.57 cvs 576: if (ptr == cssRule)
1.43 cvs 577: {
1.168 vatton 578: cssRule = SkipWord (cssRule);
579: CSSParseError ("Invalid color value", ptr, cssRule);
1.43 cvs 580: val->typed_data.value = 0;
1.184 vatton 581: val->typed_data.unit = UNIT_INVALID;
1.43 cvs 582: }
583: else
584: {
585: best = TtaGetThotColor (redval, greenval, blueval);
586: val->typed_data.value = best;
1.184 vatton 587: val->typed_data.unit = UNIT_REL;
1.57 cvs 588: cssRule = ptr;
1.43 cvs 589: }
590: val->typed_data.real = FALSE;
1.262 vatton 591: cssRule = SkipBlanksAndComments (cssRule);
1.65 cvs 592: return (cssRule);
1.43 cvs 593: }
1.1 cvs 594:
595: /*----------------------------------------------------------------------
1.231 vatton 596: CheckImportantRule updates the field important of the context and
597: the line number.
1.117 vatton 598: ----------------------------------------------------------------------*/
599: static char *CheckImportantRule (char *cssRule, PresentationContext context)
600: {
601: cssRule = SkipBlanksAndComments (cssRule);
1.231 vatton 602: /* update the line number */
603: context->cssLine = LineNumber + NewLineSkipped;
1.120 vatton 604: if (*cssRule != '!')
605: context->important = FALSE;
606: else
1.117 vatton 607: {
1.120 vatton 608: cssRule++;
609: cssRule = SkipBlanksAndComments (cssRule);
610: if (!strncasecmp (cssRule, "important", 9))
611: {
612: context->important = TRUE;
613: cssRule += 9;
614: }
615: else
616: context->important = FALSE;
1.117 vatton 617: }
618: return (cssRule);
619: }
620:
621: /*----------------------------------------------------------------------
1.59 cvs 622: ParseCSSBorderTopWidth: parse a CSS BorderTopWidth
1.1 cvs 623: attribute string.
624: ----------------------------------------------------------------------*/
1.79 cvs 625: static char *ParseCSSBorderTopWidth (Element element, PSchema tsch,
626: PresentationContext context,
627: char *cssRule, CSSInfoPtr css,
628: ThotBool isHTML)
1.1 cvs 629: {
1.41 cvs 630: PresentationValue border;
631:
1.82 cvs 632: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 633: cssRule = ParseBorderValue (cssRule, &border);
1.184 vatton 634: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.44 cvs 635: {
1.117 vatton 636: /* check if it's an important rule */
637: if (tsch)
638: cssRule = CheckImportantRule (cssRule, context);
1.44 cvs 639: TtaSetStylePresentation (PRBorderTopWidth, element, tsch, context, border);
640: border.typed_data.value = 1;
1.184 vatton 641: border.typed_data.unit = UNIT_REL;
1.44 cvs 642: }
1.1 cvs 643: return (cssRule);
644: }
645:
646: /*----------------------------------------------------------------------
1.59 cvs 647: ParseCSSBorderBottomWidth: parse a CSS BorderBottomWidth
1.1 cvs 648: attribute string.
649: ----------------------------------------------------------------------*/
1.79 cvs 650: static char *ParseCSSBorderBottomWidth (Element element, PSchema tsch,
651: PresentationContext context,
652: char *cssRule, CSSInfoPtr css,
653: ThotBool isHTML)
1.1 cvs 654: {
1.41 cvs 655: PresentationValue border;
656:
1.82 cvs 657: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 658: /* first parse the attribute string */
1.43 cvs 659: cssRule = ParseBorderValue (cssRule, &border);
1.184 vatton 660: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.44 cvs 661: {
1.117 vatton 662: /* check if it's an important rule */
663: if (tsch)
664: cssRule = CheckImportantRule (cssRule, context);
1.44 cvs 665: TtaSetStylePresentation (PRBorderBottomWidth, element, tsch, context, border);
666: border.typed_data.value = 1;
1.184 vatton 667: border.typed_data.unit = UNIT_REL;
1.44 cvs 668: }
1.1 cvs 669: return (cssRule);
670: }
671:
672: /*----------------------------------------------------------------------
1.59 cvs 673: ParseCSSBorderLeftWidth: parse a CSS BorderLeftWidth
1.1 cvs 674: attribute string.
675: ----------------------------------------------------------------------*/
1.79 cvs 676: static char *ParseCSSBorderLeftWidth (Element element, PSchema tsch,
677: PresentationContext context,
678: char *cssRule, CSSInfoPtr css,
679: ThotBool isHTML)
1.1 cvs 680: {
1.41 cvs 681: PresentationValue border;
682:
1.82 cvs 683: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 684: /* first parse the attribute string */
1.43 cvs 685: cssRule = ParseBorderValue (cssRule, &border);
1.184 vatton 686: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.44 cvs 687: {
1.117 vatton 688: /* check if it's an important rule */
689: if (tsch)
690: cssRule = CheckImportantRule (cssRule, context);
1.44 cvs 691: TtaSetStylePresentation (PRBorderLeftWidth, element, tsch, context, border);
692: border.typed_data.value = 1;
1.184 vatton 693: border.typed_data.unit = UNIT_REL;
1.44 cvs 694: }
1.1 cvs 695: return (cssRule);
696: }
697:
698: /*----------------------------------------------------------------------
1.59 cvs 699: ParseCSSBorderRightWidth: parse a CSS BorderRightWidth
1.1 cvs 700: attribute string.
701: ----------------------------------------------------------------------*/
1.79 cvs 702: static char *ParseCSSBorderRightWidth (Element element, PSchema tsch,
703: PresentationContext context,
704: char *cssRule, CSSInfoPtr css,
705: ThotBool isHTML)
1.1 cvs 706: {
1.41 cvs 707: PresentationValue border;
708:
1.82 cvs 709: cssRule = SkipBlanksAndComments (cssRule);
1.41 cvs 710: /* first parse the attribute string */
1.43 cvs 711: cssRule = ParseBorderValue (cssRule, &border);
1.184 vatton 712: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.44 cvs 713: {
1.117 vatton 714: /* check if it's an important rule */
715: if (tsch)
716: cssRule = CheckImportantRule (cssRule, context);
1.44 cvs 717: TtaSetStylePresentation (PRBorderRightWidth, element, tsch, context, border);
718: border.typed_data.value = 1;
1.184 vatton 719: border.typed_data.unit = UNIT_REL;
1.44 cvs 720: }
1.1 cvs 721: return (cssRule);
722: }
723:
724: /*----------------------------------------------------------------------
1.59 cvs 725: ParseCSSBorderWidth: parse a CSS BorderWidth
1.1 cvs 726: attribute string.
727: ----------------------------------------------------------------------*/
1.79 cvs 728: static char *ParseCSSBorderWidth (Element element, PSchema tsch,
729: PresentationContext context,
730: char *cssRule, CSSInfoPtr css,
731: ThotBool isHTML)
1.1 cvs 732: {
1.79 cvs 733: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 734: int skippedNL;
1.41 cvs 735:
1.82 cvs 736: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 737: /* First parse Border-Top */
738: ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 739: ptrR = SkipBlanksAndComments (ptrR);
740: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 741: {
1.93 vatton 742: skippedNL = NewLineSkipped;
1.42 cvs 743: cssRule = ptrR;
744: /* apply the Border-Top to all */
745: ptrR = ParseCSSBorderRightWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 746: NewLineSkipped = skippedNL;
1.42 cvs 747: ptrR = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 748: NewLineSkipped = skippedNL;
1.42 cvs 749: ptrR = ParseCSSBorderLeftWidth (element, tsch, context, ptrT, css, isHTML);
750: }
751: else
752: {
753: /* parse Border-Right */
754: ptrB = ParseCSSBorderRightWidth (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 755: ptrB = SkipBlanksAndComments (ptrB);
756: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 757: {
1.93 vatton 758: skippedNL = NewLineSkipped;
1.42 cvs 759: cssRule = ptrB;
760: /* apply the Border-Top to Border-Bottom */
761: ptrB = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 762: NewLineSkipped = skippedNL;
1.42 cvs 763: /* apply the Border-Right to Border-Left */
764: ptrB = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
765: }
766: else
767: {
768: /* parse Border-Bottom */
769: ptrL = ParseCSSBorderBottomWidth (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 770: ptrL = SkipBlanksAndComments (ptrL);
771: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 772: {
773: cssRule = ptrL;
774: /* apply the Border-Right to Border-Left */
775: ptrL = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
776: }
777: else
778: /* parse Border-Left */
779: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 780: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 781: }
782: }
1.1 cvs 783: return (cssRule);
784: }
785:
786: /*----------------------------------------------------------------------
1.59 cvs 787: ParseCSSBorderColorTop: parse a CSS BorderColorTop
1.1 cvs 788: attribute string.
789: ----------------------------------------------------------------------*/
1.79 cvs 790: static char *ParseCSSBorderColorTop (Element element, PSchema tsch,
791: PresentationContext context,
792: char *cssRule, CSSInfoPtr css,
793: ThotBool isHTML)
1.1 cvs 794: {
1.117 vatton 795: PresentationValue best;
1.43 cvs 796:
1.234 vatton 797: if (!strncasecmp (cssRule, "transparent", 11))
798: {
799: best.typed_data.value = -2; /* -2 means transparent */
800: best.typed_data.unit = UNIT_REL;
801: cssRule = SkipWord (cssRule);
802: }
803: else
804: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 805: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 806: {
807: /* check if it's an important rule */
808: if (tsch)
809: cssRule = CheckImportantRule (cssRule, context);
810: /* install the new presentation */
811: TtaSetStylePresentation (PRBorderTopColor, element, tsch, context, best);
812: }
813: return (cssRule);
1.1 cvs 814: }
815:
816: /*----------------------------------------------------------------------
1.59 cvs 817: ParseCSSBorderColorLeft: parse a CSS BorderColorLeft
1.42 cvs 818: attribute string.
819: ----------------------------------------------------------------------*/
1.79 cvs 820: static char *ParseCSSBorderColorLeft (Element element, PSchema tsch,
821: PresentationContext context,
822: char *cssRule, CSSInfoPtr css,
823: ThotBool isHTML)
1.42 cvs 824: {
1.117 vatton 825: PresentationValue best;
826:
1.234 vatton 827: if (!strncasecmp (cssRule, "transparent", 11))
828: {
829: best.typed_data.value = -2; /* -2 means transparent */
830: best.typed_data.unit = UNIT_REL;
831: cssRule = SkipWord (cssRule);
832: }
833: else
834: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 835: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 836: {
837: /* check if it's an important rule */
838: if (tsch)
839: cssRule = CheckImportantRule (cssRule, context);
840: /* install the new presentation */
841: TtaSetStylePresentation (PRBorderLeftColor, element, tsch, context, best);
842: }
843: return (cssRule);
1.42 cvs 844: }
845:
846: /*----------------------------------------------------------------------
1.59 cvs 847: ParseCSSBorderColorBottom: parse a CSS BorderColorBottom
1.42 cvs 848: attribute string.
849: ----------------------------------------------------------------------*/
1.79 cvs 850: static char *ParseCSSBorderColorBottom (Element element, PSchema tsch,
851: PresentationContext context,
852: char *cssRule, CSSInfoPtr css,
853: ThotBool isHTML)
1.42 cvs 854: {
1.117 vatton 855: PresentationValue best;
1.43 cvs 856:
1.234 vatton 857: if (!strncasecmp (cssRule, "transparent", 11))
858: {
859: best.typed_data.value = -2; /* -2 means transparent */
860: best.typed_data.unit = UNIT_REL;
861: cssRule = SkipWord (cssRule);
862: }
863: else
864: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 865: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 866: {
867: /* check if it's an important rule */
868: if (tsch)
869: cssRule = CheckImportantRule (cssRule, context);
870: /* install the new presentation */
871: TtaSetStylePresentation (PRBorderBottomColor, element, tsch, context, best);
872: }
1.65 cvs 873: return (cssRule);
1.42 cvs 874: }
875:
876: /*----------------------------------------------------------------------
1.59 cvs 877: ParseCSSBorderColorRight: parse a CSS BorderColorRight
1.1 cvs 878: attribute string.
879: ----------------------------------------------------------------------*/
1.79 cvs 880: static char *ParseCSSBorderColorRight (Element element, PSchema tsch,
881: PresentationContext context,
882: char *cssRule, CSSInfoPtr css,
883: ThotBool isHTML)
1.1 cvs 884: {
1.117 vatton 885: PresentationValue best;
1.43 cvs 886:
1.234 vatton 887: if (!strncasecmp (cssRule, "transparent", 11))
888: {
889: best.typed_data.value = -2; /* -2 means transparent */
890: best.typed_data.unit = UNIT_REL;
891: cssRule = SkipWord (cssRule);
892: }
893: else
894: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 895: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 896: {
897: /* check if it's an important rule */
898: if (tsch)
899: cssRule = CheckImportantRule (cssRule, context);
900: /* install the new presentation */
901: TtaSetStylePresentation (PRBorderRightColor, element, tsch, context, best);
902: }
903: return (cssRule);
1.1 cvs 904: }
905:
906: /*----------------------------------------------------------------------
1.59 cvs 907: ParseCSSBorderColor: parse a CSS border-color
1.42 cvs 908: attribute string.
909: ----------------------------------------------------------------------*/
1.79 cvs 910: static char *ParseCSSBorderColor (Element element, PSchema tsch,
911: PresentationContext context,
912: char *cssRule, CSSInfoPtr css,
913: ThotBool isHTML)
1.42 cvs 914: {
1.79 cvs 915: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 916: int skippedNL;
1.42 cvs 917:
1.82 cvs 918: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 919: /* First parse Border-Top */
1.43 cvs 920: ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 921: ptrR = SkipBlanksAndComments (ptrR);
922: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 923: {
1.93 vatton 924: skippedNL = NewLineSkipped;
1.42 cvs 925: cssRule = ptrR;
926: /* apply the Border-Top to all */
1.43 cvs 927: ptrR = ParseCSSBorderColorRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 928: NewLineSkipped = skippedNL;
1.43 cvs 929: ptrR = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 930: NewLineSkipped = skippedNL;
1.43 cvs 931: ptrR = ParseCSSBorderColorLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 932: }
933: else
934: {
935: /* parse Border-Right */
1.43 cvs 936: ptrB = ParseCSSBorderColorRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 937: ptrB = SkipBlanksAndComments (ptrB);
938: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 939: {
1.93 vatton 940: skippedNL = NewLineSkipped;
1.42 cvs 941: cssRule = ptrB;
942: /* apply the Border-Top to Border-Bottom */
1.43 cvs 943: ptrB = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 944: NewLineSkipped = skippedNL;
1.42 cvs 945: /* apply the Border-Right to Border-Left */
1.43 cvs 946: ptrB = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 947: }
948: else
949: {
1.93 vatton 950: skippedNL = NewLineSkipped;
1.42 cvs 951: /* parse Border-Bottom */
1.43 cvs 952: ptrL = ParseCSSBorderColorBottom (element, tsch, context, ptrB, css, isHTML);
1.93 vatton 953: NewLineSkipped = skippedNL;
1.82 cvs 954: ptrL = SkipBlanksAndComments (ptrL);
955: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 956: {
957: cssRule = ptrL;
958: /* apply the Border-Right to Border-Left */
1.43 cvs 959: ptrL = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 960: }
961: else
962: /* parse Border-Left */
1.43 cvs 963: cssRule = ParseCSSBorderColorLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 964: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 965: }
966: }
967: return (cssRule);
968: }
969:
970: /*----------------------------------------------------------------------
1.59 cvs 971: ParseCSSBorderStyleTop: parse a CSS BorderStyleTop
1.42 cvs 972: attribute string.
973: ----------------------------------------------------------------------*/
1.79 cvs 974: static char *ParseCSSBorderStyleTop (Element element, PSchema tsch,
975: PresentationContext context,
976: char *cssRule, CSSInfoPtr css,
977: ThotBool isHTML)
1.42 cvs 978: {
1.43 cvs 979: PresentationValue border;
980:
1.82 cvs 981: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 982: cssRule = ParseBorderStyle (cssRule, &border);
1.184 vatton 983: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 984: {
985: /* check if it's an important rule */
986: if (tsch)
987: cssRule = CheckImportantRule (cssRule, context);
988: TtaSetStylePresentation (PRBorderTopStyle, element, tsch, context, border);
989: }
1.42 cvs 990: return (cssRule);
991: }
992:
993: /*----------------------------------------------------------------------
1.59 cvs 994: ParseCSSBorderStyleLeft: parse a CSS BorderStyleLeft
1.42 cvs 995: attribute string.
996: ----------------------------------------------------------------------*/
1.79 cvs 997: static char *ParseCSSBorderStyleLeft (Element element, PSchema tsch,
998: PresentationContext context,
999: char *cssRule, CSSInfoPtr css,
1000: ThotBool isHTML)
1.42 cvs 1001: {
1.43 cvs 1002: PresentationValue border;
1003:
1.82 cvs 1004: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1005: cssRule = ParseBorderStyle (cssRule, &border);
1.184 vatton 1006: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 1007: {
1008: /* check if it's an important rule */
1009: if (tsch)
1010: cssRule = CheckImportantRule (cssRule, context);
1011: TtaSetStylePresentation (PRBorderLeftStyle, element, tsch, context, border);
1012: }
1.42 cvs 1013: return (cssRule);
1014: }
1015:
1016: /*----------------------------------------------------------------------
1.59 cvs 1017: ParseCSSBorderStyleBottom: parse a CSS BorderStyleBottom
1.1 cvs 1018: attribute string.
1019: ----------------------------------------------------------------------*/
1.79 cvs 1020: static char *ParseCSSBorderStyleBottom (Element element, PSchema tsch,
1021: PresentationContext context,
1022: char *cssRule, CSSInfoPtr css,
1023: ThotBool isHTML)
1.1 cvs 1024: {
1.43 cvs 1025: PresentationValue border;
1026:
1.82 cvs 1027: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1028: cssRule = ParseBorderStyle (cssRule, &border);
1.184 vatton 1029: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 1030: {
1031: /* check if it's an important rule */
1032: if (tsch)
1033: cssRule = CheckImportantRule (cssRule, context);
1034: TtaSetStylePresentation (PRBorderBottomStyle, element, tsch, context, border);
1035: }
1.1 cvs 1036: return (cssRule);
1037: }
1038:
1039: /*----------------------------------------------------------------------
1.59 cvs 1040: ParseCSSBorderStyleRight: parse a CSS BorderStyleRight
1.1 cvs 1041: attribute string.
1042: ----------------------------------------------------------------------*/
1.79 cvs 1043: static char *ParseCSSBorderStyleRight (Element element, PSchema tsch,
1044: PresentationContext context,
1045: char *cssRule, CSSInfoPtr css,
1046: ThotBool isHTML)
1.1 cvs 1047: {
1.43 cvs 1048: PresentationValue border;
1049:
1.82 cvs 1050: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1051: cssRule = ParseBorderStyle (cssRule, &border);
1.184 vatton 1052: if (border.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 1053: {
1054: /* check if it's an important rule */
1055: if (tsch)
1056: cssRule = CheckImportantRule (cssRule, context);
1057: TtaSetStylePresentation (PRBorderRightStyle, element, tsch, context, border);
1058: }
1.1 cvs 1059: return (cssRule);
1060: }
1061:
1062: /*----------------------------------------------------------------------
1.59 cvs 1063: ParseCSSBorderStyleStyle: parse a CSS border-style
1.1 cvs 1064: attribute string.
1065: ----------------------------------------------------------------------*/
1.79 cvs 1066: static char *ParseCSSBorderStyle (Element element, PSchema tsch,
1067: PresentationContext context,
1068: char *cssRule, CSSInfoPtr css,
1069: ThotBool isHTML)
1.1 cvs 1070: {
1.79 cvs 1071: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 1072: int skippedNL;
1.42 cvs 1073:
1.82 cvs 1074: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 1075: /* First parse Border-Top */
1.43 cvs 1076: ptrR = ParseCSSBorderStyleTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 1077: ptrR = SkipBlanksAndComments (ptrR);
1078: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 1079: {
1.93 vatton 1080: skippedNL = NewLineSkipped;
1.42 cvs 1081: cssRule = ptrR;
1082: /* apply the Border-Top to all */
1.43 cvs 1083: ptrR = ParseCSSBorderStyleRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1084: NewLineSkipped = skippedNL;
1.43 cvs 1085: ptrR = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1086: NewLineSkipped = skippedNL;
1.43 cvs 1087: ptrR = ParseCSSBorderStyleLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 1088: }
1089: else
1090: {
1091: /* parse Border-Right */
1.43 cvs 1092: ptrB = ParseCSSBorderStyleRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 1093: ptrB = SkipBlanksAndComments (ptrB);
1094: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.42 cvs 1095: {
1.93 vatton 1096: skippedNL = NewLineSkipped;
1.42 cvs 1097: cssRule = ptrB;
1098: /* apply the Border-Top to Border-Bottom */
1.43 cvs 1099: ptrB = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1100: NewLineSkipped = skippedNL;
1.42 cvs 1101: /* apply the Border-Right to Border-Left */
1.43 cvs 1102: ptrB = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 1103: }
1104: else
1105: {
1106: /* parse Border-Bottom */
1.43 cvs 1107: ptrL = ParseCSSBorderStyleBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 1108: ptrL = SkipBlanksAndComments (ptrL);
1109: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.42 cvs 1110: {
1111: cssRule = ptrL;
1112: /* apply the Border-Right to Border-Left */
1.43 cvs 1113: ptrL = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 1114: }
1115: else
1116: /* parse Border-Left */
1.43 cvs 1117: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 1118: cssRule = SkipBlanksAndComments (cssRule);
1.42 cvs 1119: }
1120: }
1121: return (cssRule);
1122: }
1123:
1124: /*----------------------------------------------------------------------
1.59 cvs 1125: ParseCSSBorderTop: parse a CSS BorderTop
1.42 cvs 1126: attribute string.
1127: ----------------------------------------------------------------------*/
1.79 cvs 1128: static char *ParseCSSBorderTop (Element element, PSchema tsch,
1129: PresentationContext context, char *cssRule,
1130: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1131: {
1.79 cvs 1132: char *ptr;
1.43 cvs 1133:
1.82 cvs 1134: cssRule = SkipBlanksAndComments (cssRule);
1135: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1136: {
1137: ptr = cssRule;
1138: cssRule = ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML);
1139: if (ptr == cssRule)
1140: cssRule = ParseCSSBorderTopWidth (element, tsch, context, cssRule, css, isHTML);
1141: if (ptr == cssRule)
1142: cssRule = ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML);
1143: if (ptr == cssRule)
1144: /* rule not found */
1.168 vatton 1145: cssRule = SkipValue ("Invalid border value", cssRule);
1.82 cvs 1146: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1147: }
1.42 cvs 1148: return (cssRule);
1149: }
1150:
1151: /*----------------------------------------------------------------------
1.59 cvs 1152: ParseCSSBorderLeft: parse a CSS BorderLeft
1.42 cvs 1153: attribute string.
1154: ----------------------------------------------------------------------*/
1.79 cvs 1155: static char *ParseCSSBorderLeft (Element element, PSchema tsch,
1156: PresentationContext context, char *cssRule,
1157: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1158: {
1.79 cvs 1159: char *ptr;
1.43 cvs 1160:
1.82 cvs 1161: cssRule = SkipBlanksAndComments (cssRule);
1162: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1163: {
1164: ptr = cssRule;
1165: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML);
1166: if (ptr == cssRule)
1167: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, cssRule, css, isHTML);
1168: if (ptr == cssRule)
1169: cssRule = ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML);
1170: if (ptr == cssRule)
1171: /* rule not found */
1.168 vatton 1172: cssRule = SkipValue ("Invalid border value", cssRule);
1.82 cvs 1173: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1174: }
1.1 cvs 1175: return (cssRule);
1176: }
1177:
1178: /*----------------------------------------------------------------------
1.59 cvs 1179: ParseCSSBorderBottom: parse a CSS BorderBottom
1.1 cvs 1180: attribute string.
1181: ----------------------------------------------------------------------*/
1.79 cvs 1182: static char *ParseCSSBorderBottom (Element element, PSchema tsch,
1183: PresentationContext context, char *cssRule,
1184: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1185: {
1.79 cvs 1186: char *ptr;
1.43 cvs 1187:
1.82 cvs 1188: cssRule = SkipBlanksAndComments (cssRule);
1189: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1190: {
1191: ptr = cssRule;
1192: cssRule = ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML);
1193: if (ptr == cssRule)
1194: cssRule = ParseCSSBorderBottomWidth (element, tsch, context, cssRule, css, isHTML);
1195: if (ptr == cssRule)
1196: cssRule = ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML);
1197: if (ptr == cssRule)
1198: /* rule not found */
1.168 vatton 1199: cssRule = SkipValue ("Invalid border value", cssRule);
1.82 cvs 1200: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1201: }
1.1 cvs 1202: return (cssRule);
1203: }
1204:
1205: /*----------------------------------------------------------------------
1.59 cvs 1206: ParseCSSBorderRight: parse a CSS BorderRight
1.1 cvs 1207: attribute string.
1208: ----------------------------------------------------------------------*/
1.79 cvs 1209: static char *ParseCSSBorderRight (Element element, PSchema tsch,
1210: PresentationContext context, char *cssRule,
1211: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1212: {
1.79 cvs 1213: char *ptr;
1.43 cvs 1214:
1.82 cvs 1215: cssRule = SkipBlanksAndComments (cssRule);
1216: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.43 cvs 1217: {
1218: ptr = cssRule;
1219: cssRule = ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML);
1220: if (ptr == cssRule)
1221: cssRule = ParseCSSBorderRightWidth (element, tsch, context, cssRule, css, isHTML);
1222: if (ptr == cssRule)
1223: cssRule = ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML);
1224: if (ptr == cssRule)
1225: /* rule not found */
1.168 vatton 1226: cssRule = SkipValue ("Invalid border value", cssRule);
1.82 cvs 1227: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 1228: }
1.1 cvs 1229: return (cssRule);
1230: }
1231:
1232: /*----------------------------------------------------------------------
1.59 cvs 1233: ParseCSSBorder: parse a CSS border
1.42 cvs 1234: attribute string.
1235: ----------------------------------------------------------------------*/
1.79 cvs 1236: static char *ParseCSSBorder (Element element, PSchema tsch,
1237: PresentationContext context, char *cssRule,
1238: CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1239: {
1.79 cvs 1240: char *ptrT, *ptrR;
1.93 vatton 1241: int skippedNL;
1.42 cvs 1242:
1.82 cvs 1243: ptrT = SkipBlanksAndComments (cssRule);
1.42 cvs 1244: /* First parse Border-Top */
1245: ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 1246: ptrR = SkipBlanksAndComments (ptrR);
1247: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.42 cvs 1248: {
1.93 vatton 1249: skippedNL = NewLineSkipped;
1.42 cvs 1250: cssRule = ptrR;
1251: /* apply the Border-Top to all */
1252: ptrR = ParseCSSBorderRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1253: NewLineSkipped = skippedNL;
1.42 cvs 1254: ptrR = ParseCSSBorderBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 1255: NewLineSkipped = skippedNL;
1.42 cvs 1256: ptrR = ParseCSSBorderLeft (element, tsch, context, ptrT, css, isHTML);
1257: }
1258: return (cssRule);
1259: }
1260:
1.218 vatton 1261:
1.42 cvs 1262: /*----------------------------------------------------------------------
1.184 vatton 1263: ParseCSSFloat: parse a CSS float attribute string
1264: ----------------------------------------------------------------------*/
1265: static char *ParseCSSFloat (Element element, PSchema tsch,
1266: PresentationContext context, char *cssRule,
1267: CSSInfoPtr css, ThotBool isHTML)
1268: {
1.257 vatton 1269: DisplayMode dispMode;
1.184 vatton 1270: PresentationValue pval;
1271:
1272: pval.typed_data.value = 0;
1.187 vatton 1273: pval.typed_data.unit = UNIT_BOX;
1.192 cvs 1274: pval.typed_data.real = FALSE;
1.190 vatton 1275: if (!strncasecmp (cssRule, "inherit", 7))
1276: {
1277: cssRule = SkipWord (cssRule);
1278: return (cssRule);
1279: }
1.184 vatton 1280: if (!strncasecmp (cssRule, "none", 4))
1281: pval.typed_data.value = FloatNone;
1282: else if (!strncasecmp (cssRule, "left", 4))
1283: pval.typed_data.value = FloatLeft;
1284: else if (!strncasecmp (cssRule, "right", 5))
1285: pval.typed_data.value = FloatRight;
1286:
1287: if (pval.typed_data.value == 0)
1.211 vatton 1288: cssRule = SkipValue ("Invalid float value", cssRule);
1.184 vatton 1289: else
1290: {
1291: if (DoApply)
1292: {
1.257 vatton 1293: dispMode = TtaGetDisplayMode (context->doc);
1294: if (dispMode != NoComputedDisplay)
1295: {
1296: /* force a redisplay of the whole document */
1297: TtaSetDisplayMode (context->doc, NoComputedDisplay);
1298: #ifdef AMAYA_DEBUG
1299: /*printf ("Force NoComputedDisplay doc=%d\n", context->doc);*/
1300: #endif /* AMAYA_DEBUG */
1301: }
1.184 vatton 1302: if (tsch)
1303: cssRule = CheckImportantRule (cssRule, context);
1304: TtaSetStylePresentation (PRFloat, element, tsch, context, pval);
1305: }
1.211 vatton 1306: cssRule = SkipValue (NULL, cssRule);
1.184 vatton 1307: }
1308: return (cssRule);
1309: }
1310:
1311: /*----------------------------------------------------------------------
1312: ParseCSSClear: parse a CSS clear rule
1.1 cvs 1313: ----------------------------------------------------------------------*/
1.79 cvs 1314: static char *ParseCSSClear (Element element, PSchema tsch,
1315: PresentationContext context, char *cssRule,
1316: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1317: {
1.184 vatton 1318: PresentationValue pval;
1319:
1320: pval.typed_data.value = 0;
1.187 vatton 1321: pval.typed_data.unit = UNIT_BOX;
1.193 vatton 1322: pval.typed_data.real = FALSE;
1.190 vatton 1323: if (!strncasecmp (cssRule, "inherit", 7))
1324: {
1325: cssRule = SkipWord (cssRule);
1326: return (cssRule);
1327: }
1.184 vatton 1328: if (!strncasecmp (cssRule, "none", 4))
1329: pval.typed_data.value = ClearNone;
1330: else if (!strncasecmp (cssRule, "left", 4))
1331: pval.typed_data.value = ClearLeft;
1332: else if (!strncasecmp (cssRule, "right", 5))
1333: pval.typed_data.value = ClearRight;
1334: else if (!strncasecmp (cssRule, "both", 4))
1335: pval.typed_data.value = ClearBoth;
1336:
1337: if (pval.typed_data.value == 0)
1.211 vatton 1338: cssRule = SkipValue ("Invalid clear value", cssRule);
1.184 vatton 1339: else
1340: {
1341: if (DoApply)
1342: {
1343: if (tsch)
1344: cssRule = CheckImportantRule (cssRule, context);
1345: TtaSetStylePresentation (PRClear, element, tsch, context, pval);
1346: }
1.211 vatton 1347: cssRule = SkipValue (NULL, cssRule);
1.184 vatton 1348: }
1349: return (cssRule);
1350: }
1351:
1352: /*----------------------------------------------------------------------
1.59 cvs 1353: ParseCSSDisplay: parse a CSS display attribute string
1.1 cvs 1354: ----------------------------------------------------------------------*/
1.79 cvs 1355: static char *ParseCSSDisplay (Element element, PSchema tsch,
1356: PresentationContext context, char *cssRule,
1357: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1358: {
1.184 vatton 1359: PresentationValue pval;
1.1 cvs 1360:
1.184 vatton 1361: pval.typed_data.unit = UNIT_REL;
1362: pval.typed_data.real = FALSE;
1363: cssRule = SkipBlanksAndComments (cssRule);
1364: if (!strncasecmp (cssRule, "none", 4))
1365: {
1366: pval.typed_data.value = 0;
1367: if (DoApply)
1.117 vatton 1368: {
1369: if (tsch)
1370: cssRule = CheckImportantRule (cssRule, context);
1.116 vatton 1371: TtaSetStylePresentation (PRVisibility, element, tsch, context, pval);
1.117 vatton 1372: }
1.184 vatton 1373: cssRule = SkipWord (cssRule);
1374: }
1375: else
1376: {
1377: if (!strncasecmp (cssRule, "block", 5))
1378: pval.typed_data.value = Block;
1379: else if (!strncasecmp (cssRule, "inline", 6))
1380: pval.typed_data.value = Inline;
1381: else if (!strncasecmp (cssRule, "list-item", 9))
1382: pval.typed_data.value = ListItem;
1383: else if (!strncasecmp (cssRule, "run-in", 6))
1384: pval.typed_data.value = RunIn;
1385: else if (!strncasecmp (cssRule, "compact", 7))
1386: pval.typed_data.value = Compact;
1387: else if (!strncasecmp (cssRule, "marker", 6))
1388: pval.typed_data.value = Marker;
1389: else
1390: {
1391: if (strncasecmp (cssRule, "table-row-group", 15) &&
1392: strncasecmp (cssRule, "table-column-group", 18) &&
1393: strncasecmp (cssRule, "table-header-group", 5) &&
1394: strncasecmp (cssRule, "table-footer-group", 6) &&
1395: strncasecmp (cssRule, "table-row", 9) &&
1396: strncasecmp (cssRule, "table-column", 12) &&
1397: strncasecmp (cssRule, "table-cell", 10) &&
1398: strncasecmp (cssRule, "table-caption", 13) &&
1399: strncasecmp (cssRule, "table", 5) &&
1400: strncasecmp (cssRule, "inherit", 7))
1.211 vatton 1401: cssRule = SkipValue ("Invalid display value", cssRule);
1402: return (cssRule);
1.184 vatton 1403: }
1404:
1405: if (DoApply)
1406: {
1407: if (tsch)
1408: cssRule = CheckImportantRule (cssRule, context);
1409: TtaSetStylePresentation (PRDisplay, element, tsch, context, pval);
1410: }
1411: cssRule = SkipWord (cssRule);
1412: }
1.1 cvs 1413: return (cssRule);
1414: }
1415:
1416: /*----------------------------------------------------------------------
1.59 cvs 1417: ParseCSSLetterSpacing: parse a CSS letter-spacing
1.1 cvs 1418: attribute string.
1419: ----------------------------------------------------------------------*/
1.79 cvs 1420: static char *ParseCSSLetterSpacing (Element element, PSchema tsch,
1421: PresentationContext context, char *cssRule,
1422: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1423: {
1.168 vatton 1424: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1425: return (cssRule);
1426: }
1427:
1428: /*----------------------------------------------------------------------
1.59 cvs 1429: ParseCSSListStyleType: parse a CSS list-style-type
1.1 cvs 1430: attribute string.
1431: ----------------------------------------------------------------------*/
1.79 cvs 1432: static char *ParseCSSListStyleType (Element element, PSchema tsch,
1433: PresentationContext context, char *cssRule,
1434: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1435: {
1.168 vatton 1436: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1437: return (cssRule);
1438: }
1439:
1440: /*----------------------------------------------------------------------
1.59 cvs 1441: ParseCSSListStyleImage: parse a CSS list-style-image
1.1 cvs 1442: attribute string.
1443: ----------------------------------------------------------------------*/
1.79 cvs 1444: static char *ParseCSSListStyleImage (Element element, PSchema tsch,
1445: PresentationContext context, char *cssRule,
1446: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1447: {
1.168 vatton 1448: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1449: return (cssRule);
1450: }
1451:
1452: /*----------------------------------------------------------------------
1.59 cvs 1453: ParseCSSListStylePosition: parse a CSS list-style-position
1.1 cvs 1454: attribute string.
1455: ----------------------------------------------------------------------*/
1.79 cvs 1456: static char *ParseCSSListStylePosition (Element element, PSchema tsch,
1457: PresentationContext context,
1458: char *cssRule, CSSInfoPtr css,
1459: ThotBool isHTML)
1.1 cvs 1460: {
1.168 vatton 1461: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1462: return (cssRule);
1463: }
1464:
1465: /*----------------------------------------------------------------------
1.59 cvs 1466: ParseCSSListStyle: parse a CSS list-style
1.1 cvs 1467: attribute string.
1468: ----------------------------------------------------------------------*/
1.79 cvs 1469: static char *ParseCSSListStyle (Element element, PSchema tsch,
1470: PresentationContext context, char *cssRule,
1471: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1472: {
1.168 vatton 1473: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1474: return (cssRule);
1475: }
1476:
1477: /*----------------------------------------------------------------------
1.59 cvs 1478: ParseCSSTextAlign: parse a CSS text-align
1.1 cvs 1479: attribute string.
1480: ----------------------------------------------------------------------*/
1.79 cvs 1481: static char *ParseCSSTextAlign (Element element, PSchema tsch,
1482: PresentationContext context, char *cssRule,
1483: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1484: {
1485: PresentationValue align;
1486:
1487: align.typed_data.value = 0;
1.184 vatton 1488: align.typed_data.unit = UNIT_REL;
1.1 cvs 1489: align.typed_data.real = FALSE;
1490:
1.82 cvs 1491: cssRule = SkipBlanksAndComments (cssRule);
1492: if (!strncasecmp (cssRule, "left", 4))
1.1 cvs 1493: {
1494: align.typed_data.value = AdjustLeft;
1495: cssRule = SkipWord (cssRule);
1496: }
1.82 cvs 1497: else if (!strncasecmp (cssRule, "right", 5))
1.1 cvs 1498: {
1499: align.typed_data.value = AdjustRight;
1500: cssRule = SkipWord (cssRule);
1501: }
1.82 cvs 1502: else if (!strncasecmp (cssRule, "center", 6))
1.1 cvs 1503: {
1504: align.typed_data.value = Centered;
1505: cssRule = SkipWord (cssRule);
1506: }
1.82 cvs 1507: else if (!strncasecmp (cssRule, "justify", 7))
1.1 cvs 1508: {
1.81 cvs 1509: align.typed_data.value = Justify;
1.1 cvs 1510: cssRule = SkipWord (cssRule);
1511: }
1512: else
1513: {
1.211 vatton 1514: cssRule = SkipValue ("Invalid text-align value", cssRule);
1515: return (cssRule);
1.1 cvs 1516: }
1517:
1518: /*
1519: * install the new presentation.
1520: */
1.116 vatton 1521: if (align.typed_data.value && DoApply)
1.117 vatton 1522: {
1523: if (tsch)
1524: cssRule = CheckImportantRule (cssRule, context);
1525: TtaSetStylePresentation (PRAdjust, element, tsch, context, align);
1526: }
1.1 cvs 1527: return (cssRule);
1528: }
1529:
1530: /*----------------------------------------------------------------------
1.243 quint 1531: ParseCSSTextAnchor: parse a CSS text-anchor property (SVG property)
1532: We use the Thot Adjust PRule to represent the text-anchor property
1533: for CSS 1.0, as Adjust is not used otherwise in this context.
1534: ----------------------------------------------------------------------*/
1535: static char *ParseCSSTextAnchor (Element element, PSchema tsch,
1536: PresentationContext context, char *cssRule,
1537: CSSInfoPtr css, ThotBool isHTML)
1538: {
1539: PresentationValue align;
1540:
1541: align.typed_data.value = 0;
1542: align.typed_data.unit = UNIT_REL;
1543: align.typed_data.real = FALSE;
1544:
1545: cssRule = SkipBlanksAndComments (cssRule);
1546: if (!strncasecmp (cssRule, "start", 5))
1547: {
1548: align.typed_data.value = AdjustLeft;
1549: cssRule = SkipWord (cssRule);
1550: }
1551: else if (!strncasecmp (cssRule, "middle", 6))
1552: {
1553: align.typed_data.value = Centered;
1554: cssRule = SkipWord (cssRule);
1555: }
1556: else if (!strncasecmp (cssRule, "end", 3))
1557: {
1558: align.typed_data.value = AdjustRight;
1559: cssRule = SkipWord (cssRule);
1560: }
1561: else if (!strncasecmp (cssRule, "inherit", 7))
1562: {
1563: /* not implemented */
1564: cssRule = SkipWord (cssRule);
1565: return (cssRule);
1566: }
1567: else
1568: {
1569: cssRule = SkipValue ("Invalid text-anchor value", cssRule);
1570: return (cssRule);
1571: }
1572:
1573: /*
1574: * install the new presentation.
1575: */
1576: if (align.typed_data.value && DoApply)
1577: {
1578: if (tsch)
1579: cssRule = CheckImportantRule (cssRule, context);
1580: TtaSetStylePresentation (PRAdjust, element, tsch, context, align);
1581: }
1582: return (cssRule);
1583: }
1584:
1585: /*----------------------------------------------------------------------
1.112 quint 1586: ParseCSSDirection: parse a CSS direction property
1587: ----------------------------------------------------------------------*/
1588: static char *ParseCSSDirection (Element element, PSchema tsch,
1589: PresentationContext context, char *cssRule,
1590: CSSInfoPtr css, ThotBool isHTML)
1591: {
1592: PresentationValue direction;
1593:
1594: direction.typed_data.value = 0;
1.184 vatton 1595: direction.typed_data.unit = UNIT_REL;
1.112 quint 1596: direction.typed_data.real = FALSE;
1597:
1598: cssRule = SkipBlanksAndComments (cssRule);
1599: if (!strncasecmp (cssRule, "ltr", 3))
1600: {
1.184 vatton 1601: direction.typed_data.value = LeftToRight;
1.112 quint 1602: cssRule = SkipWord (cssRule);
1603: }
1604: else if (!strncasecmp (cssRule, "rtl", 3))
1605: {
1.184 vatton 1606: direction.typed_data.value = RightToLeft;
1.112 quint 1607: cssRule = SkipWord (cssRule);
1608: }
1609: else if (!strncasecmp (cssRule, "inherit", 7))
1610: {
1611: /* not implemented */
1612: cssRule = SkipWord (cssRule);
1613: return (cssRule);
1614: }
1615: else
1616: {
1.211 vatton 1617: cssRule = SkipValue ("Invalid direction value", cssRule);
1.112 quint 1618: return (cssRule);
1619: }
1620:
1621: /*
1622: * install the new presentation.
1623: */
1.116 vatton 1624: if (direction.typed_data.value && DoApply)
1.117 vatton 1625: {
1626: if (tsch)
1627: cssRule = CheckImportantRule (cssRule, context);
1628: TtaSetStylePresentation (PRDirection, element, tsch, context, direction);
1629: }
1.112 quint 1630: return (cssRule);
1631: }
1632:
1633: /*----------------------------------------------------------------------
1.113 quint 1634: ParseCSSUnicodeBidi: parse a CSS unicode-bidi property
1635: ----------------------------------------------------------------------*/
1636: static char *ParseCSSUnicodeBidi (Element element, PSchema tsch,
1637: PresentationContext context, char *cssRule,
1638: CSSInfoPtr css, ThotBool isHTML)
1639: {
1640: PresentationValue bidi;
1641:
1642: bidi.typed_data.value = 0;
1.184 vatton 1643: bidi.typed_data.unit = UNIT_REL;
1.113 quint 1644: bidi.typed_data.real = FALSE;
1645:
1646: cssRule = SkipBlanksAndComments (cssRule);
1647: if (!strncasecmp (cssRule, "normal", 6))
1648: {
1.184 vatton 1649: bidi.typed_data.value = Normal;
1.113 quint 1650: cssRule = SkipWord (cssRule);
1651: }
1652: else if (!strncasecmp (cssRule, "embed", 5))
1653: {
1.184 vatton 1654: bidi.typed_data.value = Embed;
1.113 quint 1655: cssRule = SkipWord (cssRule);
1656: }
1657: else if (!strncasecmp (cssRule, "override", 8))
1658: {
1.184 vatton 1659: bidi.typed_data.value = Override;
1.113 quint 1660: cssRule = SkipWord (cssRule);
1661: }
1662: else if (!strncasecmp (cssRule, "inherit", 7))
1663: {
1664: /* not implemented */
1665: cssRule = SkipWord (cssRule);
1666: return (cssRule);
1667: }
1668: else
1669: {
1.211 vatton 1670: cssRule = SkipValue ("Invalid unicode-bidi value", cssRule);
1.113 quint 1671: return (cssRule);
1672: }
1673:
1674: /*
1675: * install the new presentation.
1676: */
1.116 vatton 1677: if (bidi.typed_data.value && DoApply)
1.117 vatton 1678: {
1679: if (tsch)
1680: cssRule = CheckImportantRule (cssRule, context);
1681: TtaSetStylePresentation (PRUnicodeBidi, element, tsch, context, bidi);
1682: }
1.113 quint 1683: return (cssRule);
1684: }
1685:
1686: /*----------------------------------------------------------------------
1.168 vatton 1687: ParseCSSTextIndent: parse a CSS text-indent
1.1 cvs 1688: attribute string.
1689: ----------------------------------------------------------------------*/
1.79 cvs 1690: static char *ParseCSSTextIndent (Element element, PSchema tsch,
1691: PresentationContext context, char *cssRule,
1692: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1693: {
1694: PresentationValue pval;
1.168 vatton 1695: char *ptr;
1.1 cvs 1696:
1.82 cvs 1697: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 1698: ptr = cssRule;
1.1 cvs 1699: cssRule = ParseCSSUnit (cssRule, &pval);
1.168 vatton 1700: if (pval.typed_data.value == 0)
1.184 vatton 1701: pval.typed_data.unit = UNIT_PX;
1702: else if (pval.typed_data.unit == UNIT_INVALID ||
1703: pval.typed_data.unit == UNIT_BOX)
1.168 vatton 1704: {
1705: CSSParseError ("Invalid text-indent value", ptr, cssRule);
1706: return (cssRule);
1707: }
1.1 cvs 1708: /* install the attribute */
1.116 vatton 1709: if (DoApply)
1.117 vatton 1710: {
1711: if (tsch)
1712: cssRule = CheckImportantRule (cssRule, context);
1713: TtaSetStylePresentation (PRIndent, element, tsch, context, pval);
1714: }
1.1 cvs 1715: return (cssRule);
1716: }
1717:
1718: /*----------------------------------------------------------------------
1.59 cvs 1719: ParseCSSTextTransform: parse a CSS text-transform
1.1 cvs 1720: attribute string.
1721: ----------------------------------------------------------------------*/
1.79 cvs 1722: static char *ParseCSSTextTransform (Element element, PSchema tsch,
1723: PresentationContext context, char *cssRule,
1724: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1725: {
1.168 vatton 1726: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1727: return (cssRule);
1728: }
1729:
1730: /*----------------------------------------------------------------------
1.59 cvs 1731: ParseCSSVerticalAlign: parse a CSS vertical-align
1.1 cvs 1732: attribute string.
1733: ----------------------------------------------------------------------*/
1.79 cvs 1734: static char *ParseCSSVerticalAlign (Element element, PSchema tsch,
1735: PresentationContext context, char *cssRule,
1736: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1737: {
1.168 vatton 1738: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1739: return (cssRule);
1740: }
1741:
1742: /*----------------------------------------------------------------------
1.59 cvs 1743: ParseCSSWhiteSpace: parse a CSS white-space
1.1 cvs 1744: attribute string.
1745: ----------------------------------------------------------------------*/
1.79 cvs 1746: static char *ParseCSSWhiteSpace (Element element, PSchema tsch,
1747: PresentationContext context, char *cssRule,
1748: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1749: {
1.82 cvs 1750: cssRule = SkipBlanksAndComments (cssRule);
1751: if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 1752: cssRule = SkipWord (cssRule);
1.82 cvs 1753: else if (!strncasecmp (cssRule, "pre", 3))
1.1 cvs 1754: cssRule = SkipWord (cssRule);
1.254 quint 1755: else if (!strncasecmp (cssRule, "nowrap", 6))
1756: cssRule = SkipWord (cssRule);
1757: else if (!strncasecmp (cssRule, "pre-wrap", 8))
1758: cssRule = SkipWord (cssRule);
1759: else if (!strncasecmp (cssRule, "pre-line", 8))
1760: cssRule = SkipWord (cssRule);
1761: else if (!strncasecmp (cssRule, "inherit", 7))
1762: cssRule = SkipWord (cssRule);
1.1 cvs 1763: else
1.254 quint 1764: cssRule = SkipValue ("Invalid white-space value", cssRule);
1.1 cvs 1765: return (cssRule);
1766: }
1767:
1768: /*----------------------------------------------------------------------
1.59 cvs 1769: ParseCSSWordSpacing: parse a CSS word-spacing
1.1 cvs 1770: attribute string.
1771: ----------------------------------------------------------------------*/
1.79 cvs 1772: static char *ParseCSSWordSpacing (Element element, PSchema tsch,
1773: PresentationContext context, char *cssRule,
1774: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1775: {
1.168 vatton 1776: cssRule = SkipValue (NULL, cssRule);
1.1 cvs 1777: return (cssRule);
1778: }
1779:
1780: /*----------------------------------------------------------------------
1.162 quint 1781: ParseCSSLineHeight: parse a CSS line-height property
1.25 cvs 1782: ----------------------------------------------------------------------*/
1.162 quint 1783: static char *ParseCSSLineHeight (Element element, PSchema tsch,
1.166 vatton 1784: PresentationContext context, char *cssRule,
1785: CSSInfoPtr css, ThotBool isHTML)
1.25 cvs 1786: {
1.162 quint 1787: PresentationValue pval;
1788: char *ptr;
1789:
1790: ptr = cssRule;
1791: if (!strncasecmp (cssRule, "normal", 6))
1792: {
1.184 vatton 1793: pval.typed_data.unit = UNIT_REL;
1.162 quint 1794: pval.typed_data.real = TRUE;
1795: pval.typed_data.value = 1100;
1796: cssRule = SkipWord (cssRule);
1797: }
1798: else if (!strncasecmp (cssRule, "inherit", 7))
1799: {
1800: cssRule = SkipWord (cssRule);
1801: return (cssRule);
1802: }
1803: else
1804: cssRule = ParseCSSUnit (cssRule, &pval);
1.25 cvs 1805:
1.184 vatton 1806: if (pval.typed_data.unit == UNIT_INVALID)
1.168 vatton 1807: CSSParseError ("Invalid line-height value", ptr, cssRule);
1.162 quint 1808: else if (DoApply)
1809: {
1.166 vatton 1810: /* install the new presentation */
1.184 vatton 1811: if (pval.typed_data.unit == UNIT_BOX)
1812: pval.typed_data.unit = UNIT_EM;
1.162 quint 1813: if (tsch)
1814: cssRule = CheckImportantRule (cssRule, context);
1815: TtaSetStylePresentation (PRLineSpacing, element, tsch, context, pval);
1816: }
1817: return (cssRule);
1.25 cvs 1818: }
1819:
1820: /*----------------------------------------------------------------------
1.222 quint 1821: ParseCSSFontSizeAdjust: parse a CSS fontsizeAdjust attr string
1.1 cvs 1822: we expect the input string describing the attribute to be
1823: xx-small, x-small, small, medium, large, x-large, xx-large
1824: or an absolute size, or an imcrement relative to the parent
1825: ----------------------------------------------------------------------*/
1.219 vatton 1826: static char *ParseCSSFontSizeAdjust (Element element, PSchema tsch,
1827: PresentationContext context, char *cssRule,
1828: CSSInfoPtr css, ThotBool isHTML)
1829: {
1.234 vatton 1830: cssRule = SkipProperty (cssRule, FALSE);
1.222 quint 1831: return (cssRule);
1.219 vatton 1832: }
1833:
1834: /*----------------------------------------------------------------------
1835: ParseCSSFontSize: parse a CSS font size attr string
1836: we expect the input string describing the attribute to be
1837: xx-small, x-small, small, medium, large, x-large, xx-large
1838: or an absolute size, or an imcrement relative to the parent
1839: ----------------------------------------------------------------------*/
1.79 cvs 1840: static char *ParseCSSFontSize (Element element, PSchema tsch,
1841: PresentationContext context, char *cssRule,
1842: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1843: {
1.171 quint 1844: ElementType elType;
1.1 cvs 1845: PresentationValue pval;
1.137 vatton 1846: char *ptr = NULL, *ptr1 = NULL;
1.14 cvs 1847: ThotBool real;
1.1 cvs 1848:
1849: pval.typed_data.real = FALSE;
1.82 cvs 1850: cssRule = SkipBlanksAndComments (cssRule);
1851: if (!strncasecmp (cssRule, "larger", 6))
1.1 cvs 1852: {
1.184 vatton 1853: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1854: pval.typed_data.value = 130;
1855: cssRule = SkipWord (cssRule);
1856: }
1.82 cvs 1857: else if (!strncasecmp (cssRule, "smaller", 7))
1.1 cvs 1858: {
1.184 vatton 1859: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1860: pval.typed_data.value = 80;
1861: cssRule = SkipWord (cssRule);
1862: }
1.82 cvs 1863: else if (!strncasecmp (cssRule, "xx-small", 8))
1.1 cvs 1864: {
1.184 vatton 1865: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1866: pval.typed_data.value = 1;
1867: cssRule = SkipWord (cssRule);
1868: }
1.82 cvs 1869: else if (!strncasecmp (cssRule, "x-small", 7))
1.1 cvs 1870: {
1.184 vatton 1871: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1872: pval.typed_data.value = 2;
1873: cssRule = SkipWord (cssRule);
1874: }
1.82 cvs 1875: else if (!strncasecmp (cssRule, "small", 5))
1.1 cvs 1876: {
1.184 vatton 1877: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1878: pval.typed_data.value = 3;
1879: cssRule = SkipWord (cssRule);
1880: }
1.82 cvs 1881: else if (!strncasecmp (cssRule, "medium", 6))
1.1 cvs 1882: {
1.184 vatton 1883: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1884: pval.typed_data.value = 4;
1885: cssRule = SkipWord (cssRule);
1886: }
1.82 cvs 1887: else if (!strncasecmp (cssRule, "large", 5))
1.1 cvs 1888: {
1.184 vatton 1889: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1890: pval.typed_data.value = 5;
1891: cssRule = SkipWord (cssRule);
1892: }
1.82 cvs 1893: else if (!strncasecmp (cssRule, "x-large", 7))
1.1 cvs 1894: {
1.184 vatton 1895: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1896: pval.typed_data.value = 6;
1897: cssRule = SkipWord (cssRule);
1898: }
1.82 cvs 1899: else if (!strncasecmp (cssRule, "xx-large", 8))
1.1 cvs 1900: {
1.184 vatton 1901: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1902: pval.typed_data.value = 7;
1903: cssRule = SkipWord (cssRule);
1904: }
1.171 quint 1905: else if (!isdigit (*cssRule) && *cssRule != '.')
1.260 vatton 1906: {
1907: cssRule = SkipValue ("Invalid font-size value", cssRule);
1908: return (cssRule);
1909: }
1.1 cvs 1910: else
1911: {
1.25 cvs 1912: /* look for a '/' within the current cssRule */
1.137 vatton 1913: ptr1 = strchr (cssRule, ';');
1.82 cvs 1914: ptr = strchr (cssRule, '/');
1.137 vatton 1915: if (ptr && (ptr1 == NULL || ptr < ptr1))
1.25 cvs 1916: {
1917: /* keep the line spacing rule */
1.82 cvs 1918: ptr[0] = EOS;
1.25 cvs 1919: ptr = &ptr[1];
1920: }
1.137 vatton 1921: else
1922: ptr = NULL;
1.171 quint 1923:
1.1 cvs 1924: cssRule = ParseCSSUnit (cssRule, &pval);
1.171 quint 1925:
1.184 vatton 1926: if (pval.typed_data.unit == UNIT_BOX)
1.171 quint 1927: /* no unit specified */
1928: {
1929: elType = TtaGetElementType(element);
1930: if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG"))
1931: /* we are working for an SVG element. No unit means pixels */
1.184 vatton 1932: pval.typed_data.unit = UNIT_PX;
1.171 quint 1933: }
1.168 vatton 1934: if (pval.typed_data.value != 0 &&
1.184 vatton 1935: (pval.typed_data.unit == UNIT_INVALID ||
1936: pval.typed_data.unit == UNIT_BOX ||
1.168 vatton 1937: pval.typed_data.value < 0))
1938: /* not a valid value */
1.1 cvs 1939: return (cssRule);
1.184 vatton 1940: else if (pval.typed_data.unit == UNIT_REL && pval.typed_data.value > 0)
1.1 cvs 1941: /* CSS relative sizes have to be higher than Thot ones */
1942: pval.typed_data.value += 1;
1943: else
1944: {
1945: real = pval.typed_data.real;
1.184 vatton 1946: if (pval.typed_data.unit == UNIT_EM)
1.1 cvs 1947: {
1948: if (real)
1949: {
1950: pval.typed_data.value /= 10;
1.11 cvs 1951: pval.typed_data.real = FALSE;
1.1 cvs 1952: real = FALSE;
1953: }
1954: else
1955: pval.typed_data.value *= 100;
1.184 vatton 1956: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1957: }
1.184 vatton 1958: else if (pval.typed_data.unit == UNIT_XHEIGHT)
1.146 quint 1959: {
1960: /* a font size expressed in ex is converted into a percentage.
1961: For example, "3ex" is converted into "180%", supposing
1962: that 1ex is approximately 0.6 times the height of the
1963: current font */
1964: if (real)
1965: {
1966: pval.typed_data.value *= 6;
1967: pval.typed_data.value /= 100;
1968: pval.typed_data.real = FALSE;
1969: real = FALSE;
1970: }
1971: else
1972: pval.typed_data.value *= 60;
1.184 vatton 1973: pval.typed_data.unit = UNIT_PERCENT;
1.146 quint 1974: }
1.1 cvs 1975: }
1976: }
1977:
1.25 cvs 1978: /* install the presentation style */
1.116 vatton 1979: if (DoApply)
1.117 vatton 1980: {
1981: if (tsch)
1982: cssRule = CheckImportantRule (cssRule, context);
1983: TtaSetStylePresentation (PRSize, element, tsch, context, pval);
1984: }
1985: if (ptr)
1.162 quint 1986: cssRule = ParseCSSLineHeight (element, tsch, context, ptr, css, isHTML);
1.1 cvs 1987: return (cssRule);
1988: }
1989:
1990: /*----------------------------------------------------------------------
1.59 cvs 1991: ParseCSSFontFamily: parse a CSS font family string
1.1 cvs 1992: we expect the input string describing the attribute to be
1993: a common generic font style name
1994: ----------------------------------------------------------------------*/
1.79 cvs 1995: static char *ParseCSSFontFamily (Element element, PSchema tsch,
1996: PresentationContext context, char *cssRule,
1997: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1998: {
1999: PresentationValue font;
1.252 vatton 2000: char quoteChar, *p;
1.1 cvs 2001:
2002: font.typed_data.value = 0;
1.184 vatton 2003: font.typed_data.unit = UNIT_REL;
1.1 cvs 2004: font.typed_data.real = FALSE;
1.82 cvs 2005: cssRule = SkipBlanksAndComments (cssRule);
2006: if (*cssRule == '"' || *cssRule == '\'')
1.1 cvs 2007: {
2008: quoteChar = *cssRule;
2009: cssRule++;
2010: }
2011: else
1.82 cvs 2012: quoteChar = EOS;
1.1 cvs 2013:
1.92 cvs 2014: if (!strncasecmp (cssRule, "times", 5) &&
2015: (quoteChar == EOS || quoteChar == cssRule[5]))
1.86 cvs 2016: {
1.184 vatton 2017: font.typed_data.value = FontTimes;
1.86 cvs 2018: cssRule += 5;
2019: }
1.92 cvs 2020: else if (!strncasecmp (cssRule, "serif", 5) &&
2021: (quoteChar == EOS || quoteChar == cssRule[5]))
1.86 cvs 2022: {
1.184 vatton 2023: font.typed_data.value = FontTimes;
1.86 cvs 2024: cssRule += 5;
1.92 cvs 2025: if (quoteChar != EOS)
2026: cssRule++;
1.86 cvs 2027: }
1.92 cvs 2028: else if (!strncasecmp (cssRule, "helvetica", 9) &&
2029: (quoteChar == EOS || quoteChar == cssRule[9]))
1.86 cvs 2030: {
1.184 vatton 2031: font.typed_data.value = FontHelvetica;
1.86 cvs 2032: cssRule += 9;
1.92 cvs 2033: if (quoteChar != EOS)
2034: cssRule++;
1.86 cvs 2035: }
1.92 cvs 2036: else if (!strncasecmp (cssRule, "verdana", 7) &&
2037: (quoteChar == EOS || quoteChar == cssRule[7]))
1.86 cvs 2038: {
1.184 vatton 2039: font.typed_data.value = FontHelvetica;
1.86 cvs 2040: cssRule += 7;
1.92 cvs 2041: if (quoteChar != EOS)
2042: cssRule++;
1.86 cvs 2043: }
1.92 cvs 2044: else if (!strncasecmp (cssRule, "sans-serif", 10) &&
2045: (quoteChar == EOS || quoteChar == cssRule[10]))
1.86 cvs 2046: {
1.184 vatton 2047: font.typed_data.value = FontHelvetica;
1.86 cvs 2048: cssRule += 10;
1.92 cvs 2049: if (quoteChar != EOS)
2050: cssRule++;
1.86 cvs 2051: }
1.92 cvs 2052: else if (!strncasecmp (cssRule, "courier", 7) &&
2053: (quoteChar == EOS || quoteChar == cssRule[7]))
1.86 cvs 2054: {
1.184 vatton 2055: font.typed_data.value = FontCourier;
1.86 cvs 2056: cssRule += 7;
1.92 cvs 2057: if (quoteChar != EOS)
2058: cssRule++;
1.86 cvs 2059: }
1.92 cvs 2060: else if (!strncasecmp (cssRule, "monospace", 9) &&
2061: (quoteChar == EOS || quoteChar == cssRule[9]))
1.86 cvs 2062: {
1.184 vatton 2063: font.typed_data.value = FontCourier;
1.86 cvs 2064: cssRule += 9;
1.92 cvs 2065: if (quoteChar != EOS)
2066: cssRule++;
1.86 cvs 2067: }
1.1 cvs 2068: else
2069: /* unknown font name. Skip it */
2070: {
1.252 vatton 2071: p = cssRule;
1.92 cvs 2072: if (quoteChar != EOS)
1.54 cvs 2073: cssRule = SkipQuotedString (cssRule, quoteChar);
1.86 cvs 2074: else
1.1 cvs 2075: cssRule = SkipWord (cssRule);
1.252 vatton 2076: while (p == cssRule &&
2077: *cssRule != ',' && *cssRule != ';' && *cssRule != EOS)
2078: {
2079: cssRule++;
2080: p = cssRule;
2081: cssRule = SkipWord (cssRule);
2082: }
1.82 cvs 2083: cssRule = SkipBlanksAndComments (cssRule);
2084: if (*cssRule == ',')
1.1 cvs 2085: {
1.239 vatton 2086: /* recursive call to ParseCSSFontFamily */
1.86 cvs 2087: cssRule++;
2088: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
2089: return (cssRule);
1.1 cvs 2090: }
2091: }
2092:
1.239 vatton 2093: /* skip other values */
2094: cssRule = SkipBlanksAndComments (cssRule);
2095: while (*cssRule == ',')
2096: {
2097: cssRule++;
2098: cssRule = SkipValue (NULL, cssRule);
2099: cssRule = SkipBlanksAndComments (cssRule);
2100: }
2101:
1.1 cvs 2102: if (font.typed_data.value != 0)
2103: {
1.93 vatton 2104: /* install the new presentation */
1.116 vatton 2105: if (DoApply)
1.117 vatton 2106: {
2107: if (tsch)
2108: cssRule = CheckImportantRule (cssRule, context);
2109: TtaSetStylePresentation (PRFont, element, tsch, context, font);
2110: }
1.1 cvs 2111: }
2112: return (cssRule);
2113: }
2114:
2115: /*----------------------------------------------------------------------
1.59 cvs 2116: ParseCSSFontWeight: parse a CSS font weight string
1.1 cvs 2117: we expect the input string describing the attribute to be
1.20 cvs 2118: normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
1.1 cvs 2119: ----------------------------------------------------------------------*/
1.263 vatton 2120: static char *ParseACSSFontWeight (Element element, PSchema tsch,
1.79 cvs 2121: PresentationContext context, char *cssRule,
2122: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2123: {
1.20 cvs 2124: PresentationValue weight;
1.1 cvs 2125:
2126: weight.typed_data.value = 0;
1.184 vatton 2127: weight.typed_data.unit = UNIT_REL;
1.1 cvs 2128: weight.typed_data.real = FALSE;
1.82 cvs 2129: cssRule = SkipBlanksAndComments (cssRule);
2130: if (!strncasecmp (cssRule, "100", 3) && !isalpha (cssRule[3]))
1.1 cvs 2131: {
2132: weight.typed_data.value = -3;
2133: cssRule = SkipWord (cssRule);
2134: }
1.82 cvs 2135: else if (!strncasecmp (cssRule, "200", 3) && !isalpha (cssRule[3]))
1.1 cvs 2136: {
2137: weight.typed_data.value = -2;
2138: cssRule = SkipWord (cssRule);
2139: }
1.82 cvs 2140: else if (!strncasecmp (cssRule, "300", 3) && ! isalpha(cssRule[3]))
1.1 cvs 2141: {
2142: weight.typed_data.value = -1;
2143: cssRule = SkipWord (cssRule);
2144: }
1.82 cvs 2145: else if (!strncasecmp (cssRule, "normal", 6) || (!strncasecmp (cssRule, "400", 3) && !isalpha (cssRule[3])))
1.1 cvs 2146: {
2147: weight.typed_data.value = 0;
2148: cssRule = SkipWord (cssRule);
2149: }
1.82 cvs 2150: else if (!strncasecmp (cssRule, "500", 3) && !isalpha (cssRule[3]))
1.1 cvs 2151: {
2152: weight.typed_data.value = +1;
2153: cssRule = SkipWord (cssRule);
2154: }
1.82 cvs 2155: else if (!strncasecmp (cssRule, "600", 3) && !isalpha (cssRule[3]))
1.1 cvs 2156: {
2157: weight.typed_data.value = +2;
2158: cssRule = SkipWord (cssRule);
2159: }
1.82 cvs 2160: else if (!strncasecmp (cssRule, "bold", 4) || (!strncasecmp (cssRule, "700", 3) && !isalpha (cssRule[3])))
1.1 cvs 2161: {
2162: weight.typed_data.value = +3;
2163: cssRule = SkipWord (cssRule);
2164: }
1.82 cvs 2165: else if (!strncasecmp (cssRule, "800", 3) && !isalpha (cssRule[3]))
1.1 cvs 2166: {
2167: weight.typed_data.value = +4;
2168: cssRule = SkipWord (cssRule);
2169: }
1.82 cvs 2170: else if (!strncasecmp (cssRule, "900", 3) && !isalpha (cssRule[3]))
1.1 cvs 2171: {
2172: weight.typed_data.value = +5;
2173: cssRule = SkipWord (cssRule);
2174: }
1.82 cvs 2175: else if (!strncasecmp (cssRule, "inherit", 7) || !strncasecmp (cssRule, "bolder", 6) || !strncasecmp (cssRule, "lighter", 7))
1.1 cvs 2176: {
2177: /* not implemented */
2178: cssRule = SkipWord (cssRule);
2179: return (cssRule);
2180: }
2181: else
2182: return (cssRule);
2183:
2184: /*
1.20 cvs 2185: * Here we have to reduce since only two font weight values are supported
1.1 cvs 2186: * by the Thot presentation API.
2187: */
1.20 cvs 2188: if (weight.typed_data.value > 0)
1.184 vatton 2189: weight.typed_data.value = WeightBold;
1.20 cvs 2190: else
1.184 vatton 2191: weight.typed_data.value = WeightNormal;
1.1 cvs 2192:
2193: /* install the new presentation */
1.116 vatton 2194: if (DoApply)
1.117 vatton 2195: {
2196: if (tsch)
2197: cssRule = CheckImportantRule (cssRule, context);
2198: TtaSetStylePresentation (PRWeight, element, tsch, context, weight);
2199: }
1.1 cvs 2200: return (cssRule);
2201: }
2202:
2203: /*----------------------------------------------------------------------
1.263 vatton 2204: ParseCSSFontWeight: parse a CSS font weight string
2205: we expect the input string describing the attribute to be
2206: normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
2207: ----------------------------------------------------------------------*/
2208: static char *ParseCSSFontWeight (Element element, PSchema tsch,
2209: PresentationContext context, char *cssRule,
2210: CSSInfoPtr css, ThotBool isHTML)
2211: {
2212: char *ptr;
2213:
2214: ptr = cssRule;
2215: cssRule = ParseACSSFontWeight (element, tsch, context, cssRule, css, isHTML);
2216: if (ptr == cssRule)
2217: cssRule = SkipValue ("Invalid font-weight value", cssRule);
2218: return (cssRule);
2219: }
2220:
2221: /*----------------------------------------------------------------------
1.59 cvs 2222: ParseCSSFontVariant: parse a CSS font variant string
1.1 cvs 2223: we expect the input string describing the attribute to be
2224: normal or small-caps
2225: ----------------------------------------------------------------------*/
1.263 vatton 2226: static char *ParseACSSFontVariant (Element element, PSchema tsch,
1.79 cvs 2227: PresentationContext context, char *cssRule,
2228: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2229: {
2230: PresentationValue style;
2231:
2232: style.typed_data.value = 0;
1.184 vatton 2233: style.typed_data.unit = UNIT_REL;
1.1 cvs 2234: style.typed_data.real = FALSE;
1.82 cvs 2235: cssRule = SkipBlanksAndComments (cssRule);
2236: if (!strncasecmp (cssRule, "small-caps", 10))
1.1 cvs 2237: {
2238: /* Not supported yet */
2239: cssRule = SkipWord (cssRule);
2240: }
1.82 cvs 2241: else if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 2242: {
2243: /* Not supported yet */
2244: cssRule = SkipWord (cssRule);
2245: }
1.82 cvs 2246: else if (!strncasecmp (cssRule, "inherit", 7))
1.1 cvs 2247: {
2248: /* Not supported yet */
2249: cssRule = SkipWord (cssRule);
2250: }
1.263 vatton 2251: return (cssRule);
2252: }
1.1 cvs 2253:
1.263 vatton 2254: /*----------------------------------------------------------------------
2255: ParseCSSFontVariant: parse a CSS font variant string
2256: we expect the input string describing the attribute to be
2257: normal or small-caps
2258: ----------------------------------------------------------------------*/
2259: static char *ParseCSSFontVariant (Element element, PSchema tsch,
2260: PresentationContext context, char *cssRule,
2261: CSSInfoPtr css, ThotBool isHTML)
2262: {
2263: char *ptr;
2264:
2265: ptr = cssRule;
2266: cssRule = ParseACSSFontVariant (element, tsch, context, cssRule, css, isHTML);
2267: if (ptr == cssRule)
2268: cssRule = SkipValue ("Invalid font-variant value", cssRule);
2269: return (cssRule);
1.1 cvs 2270: }
2271:
2272:
2273: /*----------------------------------------------------------------------
1.59 cvs 2274: ParseCSSFontStyle: parse a CSS font style string
1.1 cvs 2275: we expect the input string describing the attribute to be
2276: italic, oblique or normal
2277: ----------------------------------------------------------------------*/
1.263 vatton 2278: static char *ParseACSSFontStyle (Element element, PSchema tsch,
1.79 cvs 2279: PresentationContext context, char *cssRule,
2280: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2281: {
2282: PresentationValue style;
2283: PresentationValue size;
2284:
2285: style.typed_data.value = 0;
1.184 vatton 2286: style.typed_data.unit = UNIT_REL;
1.1 cvs 2287: style.typed_data.real = FALSE;
2288: size.typed_data.value = 0;
1.184 vatton 2289: size.typed_data.unit = UNIT_REL;
1.1 cvs 2290: size.typed_data.real = FALSE;
1.82 cvs 2291: cssRule = SkipBlanksAndComments (cssRule);
2292: if (!strncasecmp (cssRule, "italic", 6))
1.1 cvs 2293: {
1.184 vatton 2294: style.typed_data.value = StyleItalics;
1.1 cvs 2295: cssRule = SkipWord (cssRule);
2296: }
1.82 cvs 2297: else if (!strncasecmp (cssRule, "oblique", 7))
1.1 cvs 2298: {
1.184 vatton 2299: style.typed_data.value = StyleOblique;
1.1 cvs 2300: cssRule = SkipWord (cssRule);
2301: }
1.82 cvs 2302: else if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 2303: {
1.184 vatton 2304: style.typed_data.value = StyleRoman;
1.1 cvs 2305: cssRule = SkipWord (cssRule);
2306: }
1.108 cvs 2307: else if (!strncasecmp (cssRule, "inherit", 7))
2308: {
2309: /* not implemented */
2310: cssRule = SkipWord (cssRule);
2311: return (cssRule);
2312: }
1.1 cvs 2313: else
1.263 vatton 2314: /* invalid font style */
2315: return (cssRule);
1.1 cvs 2316:
2317: /*
2318: * install the new presentation.
2319: */
1.116 vatton 2320: if (style.typed_data.value != 0 && DoApply)
1.117 vatton 2321: {
2322: if (tsch)
2323: cssRule = CheckImportantRule (cssRule, context);
1.20 cvs 2324: TtaSetStylePresentation (PRStyle, element, tsch, context, style);
1.117 vatton 2325: }
1.116 vatton 2326: if (size.typed_data.value != 0 && DoApply)
1.1 cvs 2327: {
2328: PresentationValue previous_size;
2329:
2330: if (!TtaGetStylePresentation (PRSize, element, tsch, context, &previous_size))
2331: {
2332: /* !!!!!!!!!!!!!!!!!!!!!!!! Unite + relatif !!!!!!!!!!!!!!!! */
2333: size.typed_data.value += previous_size.typed_data.value;
2334: TtaSetStylePresentation (PRSize, element, tsch, context, size);
2335: }
2336: else
2337: {
2338: size.typed_data.value = 10;
2339: TtaSetStylePresentation (PRSize, element, tsch, context, size);
2340: }
2341: }
2342: return (cssRule);
2343: }
2344:
2345: /*----------------------------------------------------------------------
1.263 vatton 2346: ParseCSSFontStyle: parse a CSS font style string
2347: we expect the input string describing the attribute to be
2348: italic, oblique or normal
2349: ----------------------------------------------------------------------*/
2350: static char *ParseCSSFontStyle (Element element, PSchema tsch,
2351: PresentationContext context, char *cssRule,
2352: CSSInfoPtr css, ThotBool isHTML)
2353: {
2354: char *ptr;
2355:
2356: ptr = cssRule;
2357: cssRule = ParseACSSFontStyle (element, tsch, context, cssRule, css, isHTML);
2358: if (ptr == cssRule)
2359: cssRule = SkipValue ("Invalid font-style value", cssRule);
2360: return (cssRule);
2361: }
2362:
2363: /*----------------------------------------------------------------------
1.59 cvs 2364: ParseCSSFont: parse a CSS font attribute string
2365: we expect the input string describing the attribute to be
2366: !!!!!!
1.1 cvs 2367: ----------------------------------------------------------------------*/
1.79 cvs 2368: static char *ParseCSSFont (Element element, PSchema tsch,
2369: PresentationContext context, char *cssRule,
2370: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2371: {
1.79 cvs 2372: char *ptr;
1.93 vatton 2373: int skippedNL;
1.1 cvs 2374:
1.82 cvs 2375: cssRule = SkipBlanksAndComments (cssRule);
2376: if (!strncasecmp (cssRule, "caption", 7))
1.263 vatton 2377: cssRule += 7;
1.82 cvs 2378: else if (!strncasecmp (cssRule, "icon", 4))
1.263 vatton 2379: cssRule += 4;
1.82 cvs 2380: else if (!strncasecmp (cssRule, "menu", 4))
1.263 vatton 2381: cssRule += 4;
1.82 cvs 2382: else if (!strncasecmp (cssRule, "message-box", 11))
1.263 vatton 2383: cssRule += 11;
1.82 cvs 2384: else if (!strncasecmp (cssRule, "small-caption", 13))
1.263 vatton 2385: cssRule += 13;
1.82 cvs 2386: else if (!strncasecmp (cssRule, "status-bar", 10))
1.263 vatton 2387: cssRule += 10;
2388: else if (!strncasecmp (cssRule, "inherit", 7))
2389: cssRule += 7;
1.1 cvs 2390: else
1.43 cvs 2391: {
1.263 vatton 2392: skippedNL = NewLineSkipped;
2393: cssRule = ParseACSSFontStyle (element, tsch, context, cssRule, css, isHTML);
2394: NewLineSkipped = skippedNL;
2395: cssRule = ParseACSSFontVariant (element, tsch, context, cssRule, css, isHTML);
2396: NewLineSkipped = skippedNL;
2397: cssRule = ParseACSSFontWeight (element, tsch, context, cssRule, css, isHTML);
2398: NewLineSkipped = skippedNL;
2399: ptr = cssRule;
2400: if (*cssRule != ';' && *cssRule != EOS)
2401: cssRule = ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML);
2402: NewLineSkipped = skippedNL;
2403: if (*cssRule != ';' && *cssRule != EOS)
2404: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
2405: if (ptr == cssRule)
2406: cssRule = SkipValue ("Invalid font value", cssRule);
1.43 cvs 2407: }
1.263 vatton 2408: cssRule = SkipBlanksAndComments (cssRule);
2409: if (*cssRule != ';' && *cssRule != EOS)
2410: cssRule = SkipValue ("Invalid font value", cssRule);
1.43 cvs 2411: return (cssRule);
1.1 cvs 2412: }
2413:
2414: /*----------------------------------------------------------------------
1.59 cvs 2415: ParseCSSTextDecoration: parse a CSS text decor string
2416: we expect the input string describing the attribute to be
1.109 cvs 2417: underline, overline, line-through, blink or none.
1.1 cvs 2418: ----------------------------------------------------------------------*/
1.79 cvs 2419: static char *ParseCSSTextDecoration (Element element, PSchema tsch,
2420: PresentationContext context, char *cssRule,
2421: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2422: {
2423: PresentationValue decor;
2424:
2425: decor.typed_data.value = 0;
1.184 vatton 2426: decor.typed_data.unit = UNIT_REL;
1.1 cvs 2427: decor.typed_data.real = FALSE;
1.82 cvs 2428: cssRule = SkipBlanksAndComments (cssRule);
1.211 vatton 2429: if (!strncasecmp (cssRule, "none", 4))
1.142 quint 2430: {
2431: decor.typed_data.value = NoUnderline;
2432: cssRule = SkipWord (cssRule);
2433: }
1.211 vatton 2434: else if (!strncasecmp (cssRule, "underline", 9))
1.1 cvs 2435: {
2436: decor.typed_data.value = Underline;
2437: cssRule = SkipWord (cssRule);
2438: }
1.211 vatton 2439: else if (!strncasecmp (cssRule, "overline", 8))
1.1 cvs 2440: {
2441: decor.typed_data.value = Overline;
2442: cssRule = SkipWord (cssRule);
2443: }
1.211 vatton 2444: else if (!strncasecmp (cssRule, "line-through", 12))
1.1 cvs 2445: {
2446: decor.typed_data.value = CrossOut;
2447: cssRule = SkipWord (cssRule);
2448: }
1.211 vatton 2449: else if (!strncasecmp (cssRule, "blink", 5))
1.1 cvs 2450: {
1.109 cvs 2451: /* the blink text-decoration attribute is not supported */
1.1 cvs 2452: cssRule = SkipWord (cssRule);
2453: }
1.142 quint 2454: else if (!strncasecmp (cssRule, "inherit", 7))
1.1 cvs 2455: {
1.142 quint 2456: cssRule = SkipWord (cssRule);
2457: return (cssRule);
1.1 cvs 2458: }
2459: else
2460: {
1.211 vatton 2461: cssRule = SkipValue ("Invalid text-decoration value", cssRule);
2462: return (cssRule);
1.1 cvs 2463: }
2464:
2465: /*
2466: * install the new presentation.
2467: */
1.116 vatton 2468: if (decor.typed_data.value && DoApply)
1.1 cvs 2469: {
1.117 vatton 2470: if (tsch)
2471: cssRule = CheckImportantRule (cssRule, context);
1.1 cvs 2472: TtaSetStylePresentation (PRUnderline, element, tsch, context, decor);
2473: }
2474: return (cssRule);
2475: }
2476:
2477: /*----------------------------------------------------------------------
1.59 cvs 2478: ParseCSSHeight: parse a CSS height attribute
1.1 cvs 2479: ----------------------------------------------------------------------*/
1.79 cvs 2480: static char *ParseCSSHeight (Element element, PSchema tsch,
1.93 vatton 2481: PresentationContext context, char *cssRule,
2482: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2483: {
1.117 vatton 2484: PresentationValue val;
1.168 vatton 2485: char *ptr;
1.93 vatton 2486:
1.117 vatton 2487: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2488: ptr = cssRule;
1.117 vatton 2489: /* first parse the attribute string */
1.164 quint 2490: if (!strncasecmp (cssRule, "auto", 4))
2491: {
1.184 vatton 2492: val.typed_data.unit = VALUE_AUTO;
1.164 quint 2493: val.typed_data.value = 0;
2494: val.typed_data.real = FALSE;
2495: cssRule = SkipWord (cssRule);
2496: }
1.117 vatton 2497: else
1.168 vatton 2498: cssRule = ParseCSSUnit (cssRule, &val);
2499: if (val.typed_data.value != 0 &&
1.184 vatton 2500: (val.typed_data.unit == UNIT_INVALID ||
2501: val.typed_data.unit == UNIT_BOX))
1.211 vatton 2502: {
2503: CSSParseError ("height value", ptr, cssRule);
1.212 cvs 2504: val.typed_data.unit = UNIT_PX;
1.211 vatton 2505: }
2506: if (DoApply)
1.117 vatton 2507: {
1.164 quint 2508: if (tsch)
2509: cssRule = CheckImportantRule (cssRule, context);
2510: /* install the new presentation */
2511: TtaSetStylePresentation (PRHeight, element, tsch, context, val);
1.117 vatton 2512: }
2513: return (cssRule);
1.1 cvs 2514: }
2515:
2516: /*----------------------------------------------------------------------
1.59 cvs 2517: ParseCSSWidth: parse a CSS width attribute
1.1 cvs 2518: ----------------------------------------------------------------------*/
1.79 cvs 2519: static char *ParseCSSWidth (Element element, PSchema tsch,
1.78 cvs 2520: PresentationContext context,
1.79 cvs 2521: char *cssRule, CSSInfoPtr css,
1.78 cvs 2522: ThotBool isHTML)
1.1 cvs 2523: {
1.117 vatton 2524: PresentationValue val;
1.168 vatton 2525: char *ptr;
1.93 vatton 2526:
1.117 vatton 2527: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2528: ptr = cssRule;
1.117 vatton 2529: /* first parse the attribute string */
1.164 quint 2530: if (!strncasecmp (cssRule, "auto", 4))
2531: {
1.184 vatton 2532: val.typed_data.unit = VALUE_AUTO;
1.164 quint 2533: val.typed_data.value = 0;
2534: val.typed_data.real = FALSE;
2535: cssRule = SkipWord (cssRule);
2536: }
1.117 vatton 2537: else
1.164 quint 2538: cssRule = ParseCSSUnit (cssRule, &val);
1.168 vatton 2539: if (val.typed_data.value != 0 &&
1.184 vatton 2540: (val.typed_data.unit == UNIT_INVALID ||
2541: val.typed_data.unit == UNIT_BOX))
1.211 vatton 2542: {
2543: CSSParseError ("Invalid width value", ptr, cssRule);
1.212 cvs 2544: val.typed_data.unit = UNIT_PX;
1.211 vatton 2545: }
2546: if (DoApply)
1.117 vatton 2547: {
1.164 quint 2548: if (tsch)
2549: cssRule = CheckImportantRule (cssRule, context);
2550: /* install the new presentation */
2551: TtaSetStylePresentation (PRWidth, element, tsch, context, val);
1.117 vatton 2552: }
2553: return (cssRule);
1.1 cvs 2554: }
2555:
2556: /*----------------------------------------------------------------------
1.59 cvs 2557: ParseCSSMarginTop: parse a CSS margin-top attribute
1.1 cvs 2558: ----------------------------------------------------------------------*/
1.79 cvs 2559: static char *ParseCSSMarginTop (Element element, PSchema tsch,
1.78 cvs 2560: PresentationContext context,
1.79 cvs 2561: char *cssRule, CSSInfoPtr css,
1.78 cvs 2562: ThotBool isHTML)
1.1 cvs 2563: {
2564: PresentationValue margin;
1.168 vatton 2565: char *ptr;
1.1 cvs 2566:
1.82 cvs 2567: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2568: ptr = cssRule;
1.1 cvs 2569: /* first parse the attribute string */
1.164 quint 2570: if (!strncasecmp (cssRule, "auto", 4))
2571: {
1.184 vatton 2572: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2573: margin.typed_data.value = 0;
2574: margin.typed_data.real = FALSE;
2575: cssRule = SkipWord (cssRule);
2576: }
2577: else
1.168 vatton 2578: cssRule = ParseCSSUnit (cssRule, &margin);
2579: if (margin.typed_data.value != 0 &&
1.184 vatton 2580: (margin.typed_data.unit == UNIT_INVALID ||
2581: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2582: CSSParseError ("Invalid margin-top value", ptr, cssRule);
1.168 vatton 2583: else if (DoApply)
1.117 vatton 2584: {
2585: if (tsch)
2586: cssRule = CheckImportantRule (cssRule, context);
2587: TtaSetStylePresentation (PRMarginTop, element, tsch, context, margin);
2588: }
1.1 cvs 2589: return (cssRule);
2590: }
2591:
2592: /*----------------------------------------------------------------------
1.59 cvs 2593: ParseCSSMarginBottom: parse a CSS margin-bottom attribute
1.1 cvs 2594: ----------------------------------------------------------------------*/
1.79 cvs 2595: static char *ParseCSSMarginBottom (Element element, PSchema tsch,
1.78 cvs 2596: PresentationContext context,
1.79 cvs 2597: char *cssRule, CSSInfoPtr css,
1.78 cvs 2598: ThotBool isHTML)
1.1 cvs 2599: {
2600: PresentationValue margin;
1.168 vatton 2601: char *ptr;
1.1 cvs 2602:
1.82 cvs 2603: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2604: ptr = cssRule;
1.1 cvs 2605: /* first parse the attribute string */
1.164 quint 2606: if (!strncasecmp (cssRule, "auto", 4))
2607: {
1.184 vatton 2608: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2609: margin.typed_data.value = 0;
2610: margin.typed_data.real = FALSE;
2611: cssRule = SkipWord (cssRule);
2612: }
2613: else
1.168 vatton 2614: cssRule = ParseCSSUnit (cssRule, &margin);
2615: if (margin.typed_data.value != 0 &&
1.184 vatton 2616: (margin.typed_data.unit == UNIT_INVALID ||
2617: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2618: CSSParseError ("Invalid margin-bottom value", ptr, cssRule);
1.168 vatton 2619: else if (DoApply)
1.117 vatton 2620: {
2621: if (tsch)
2622: cssRule = CheckImportantRule (cssRule, context);
2623: TtaSetStylePresentation (PRMarginBottom, element, tsch, context, margin);
2624: }
1.1 cvs 2625: return (cssRule);
2626: }
2627:
2628: /*----------------------------------------------------------------------
1.59 cvs 2629: ParseCSSMarginLeft: parse a CSS margin-left attribute string
1.1 cvs 2630: ----------------------------------------------------------------------*/
1.79 cvs 2631: static char *ParseCSSMarginLeft (Element element, PSchema tsch,
1.78 cvs 2632: PresentationContext context,
1.79 cvs 2633: char *cssRule, CSSInfoPtr css,
1.78 cvs 2634: ThotBool isHTML)
1.1 cvs 2635: {
2636: PresentationValue margin;
1.168 vatton 2637: char *ptr;
1.1 cvs 2638:
1.82 cvs 2639: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2640: ptr = cssRule;
1.1 cvs 2641: /* first parse the attribute string */
1.164 quint 2642: if (!strncasecmp (cssRule, "auto", 4))
2643: {
1.184 vatton 2644: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2645: margin.typed_data.value = 0;
2646: margin.typed_data.real = FALSE;
2647: cssRule = SkipWord (cssRule);
2648: }
2649: else
1.168 vatton 2650: cssRule = ParseCSSUnit (cssRule, &margin);
2651: if (margin.typed_data.value != 0 &&
1.184 vatton 2652: (margin.typed_data.unit == UNIT_INVALID ||
2653: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2654: CSSParseError ("Invalid margin-left value", ptr, cssRule);
1.168 vatton 2655: else if (DoApply)
1.184 vatton 2656: if (margin.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 2657: {
2658: if (tsch)
2659: cssRule = CheckImportantRule (cssRule, context);
2660: TtaSetStylePresentation (PRMarginLeft, element, tsch, context, margin);
2661: }
1.1 cvs 2662: return (cssRule);
2663: }
2664:
2665: /*----------------------------------------------------------------------
1.59 cvs 2666: ParseCSSMarginRight: parse a CSS margin-right attribute string
1.1 cvs 2667: ----------------------------------------------------------------------*/
1.79 cvs 2668: static char *ParseCSSMarginRight (Element element, PSchema tsch,
1.78 cvs 2669: PresentationContext context,
1.79 cvs 2670: char *cssRule, CSSInfoPtr css,
1.78 cvs 2671: ThotBool isHTML)
1.1 cvs 2672: {
2673: PresentationValue margin;
1.168 vatton 2674: char *ptr;
1.1 cvs 2675:
1.82 cvs 2676: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2677: ptr = cssRule;
1.1 cvs 2678: /* first parse the attribute string */
1.164 quint 2679: if (!strncasecmp (cssRule, "auto", 4))
2680: {
1.184 vatton 2681: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2682: margin.typed_data.value = 0;
2683: margin.typed_data.real = FALSE;
2684: cssRule = SkipWord (cssRule);
2685: }
2686: else
1.168 vatton 2687: cssRule = ParseCSSUnit (cssRule, &margin);
2688: if (margin.typed_data.value != 0 &&
1.184 vatton 2689: (margin.typed_data.unit == UNIT_INVALID ||
2690: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2691: CSSParseError ("Invalid margin-right value", ptr, cssRule);
1.168 vatton 2692: else if (DoApply)
1.117 vatton 2693: {
2694: if (tsch)
2695: cssRule = CheckImportantRule (cssRule, context);
2696: TtaSetStylePresentation (PRMarginRight, element, tsch, context, margin);
2697: }
1.1 cvs 2698: return (cssRule);
2699: }
2700:
2701: /*----------------------------------------------------------------------
1.59 cvs 2702: ParseCSSMargin: parse a CSS margin attribute string
1.1 cvs 2703: ----------------------------------------------------------------------*/
1.79 cvs 2704: static char *ParseCSSMargin (Element element, PSchema tsch,
1.78 cvs 2705: PresentationContext context,
1.79 cvs 2706: char *cssRule, CSSInfoPtr css,
1.78 cvs 2707: ThotBool isHTML)
1.1 cvs 2708: {
1.79 cvs 2709: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 2710: int skippedNL;
1.1 cvs 2711:
1.82 cvs 2712: ptrT = SkipBlanksAndComments (cssRule);
1.1 cvs 2713: /* First parse Margin-Top */
2714: ptrR = ParseCSSMarginTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 2715: ptrR = SkipBlanksAndComments (ptrR);
2716: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.1 cvs 2717: {
1.93 vatton 2718: skippedNL = NewLineSkipped;
1.1 cvs 2719: cssRule = ptrR;
2720: /* apply the Margin-Top to all */
2721: ptrR = ParseCSSMarginRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2722: NewLineSkipped = skippedNL;
1.1 cvs 2723: ptrR = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2724: NewLineSkipped = skippedNL;
1.1 cvs 2725: ptrR = ParseCSSMarginLeft (element, tsch, context, ptrT, css, isHTML);
2726: }
2727: else
2728: {
2729: /* parse Margin-Right */
2730: ptrB = ParseCSSMarginRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 2731: ptrB = SkipBlanksAndComments (ptrB);
2732: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.1 cvs 2733: {
1.93 vatton 2734: skippedNL = NewLineSkipped;
1.1 cvs 2735: cssRule = ptrB;
2736: /* apply the Margin-Top to Margin-Bottom */
2737: ptrB = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2738: NewLineSkipped = skippedNL;
1.1 cvs 2739: /* apply the Margin-Right to Margin-Left */
2740: ptrB = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2741: }
2742: else
2743: {
2744: /* parse Margin-Bottom */
2745: ptrL = ParseCSSMarginBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 2746: ptrL = SkipBlanksAndComments (ptrL);
2747: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.1 cvs 2748: {
2749: cssRule = ptrL;
2750: /* apply the Margin-Right to Margin-Left */
2751: ptrL = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2752: }
2753: else
2754: /* parse Margin-Left */
2755: cssRule = ParseCSSMarginLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 2756: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2757: }
2758: }
2759: return (cssRule);
2760: }
2761:
2762: /*----------------------------------------------------------------------
1.59 cvs 2763: ParseCSSPaddingTop: parse a CSS PaddingTop attribute string
1.1 cvs 2764: ----------------------------------------------------------------------*/
1.79 cvs 2765: static char *ParseCSSPaddingTop (Element element, PSchema tsch,
1.78 cvs 2766: PresentationContext context,
1.79 cvs 2767: char *cssRule, CSSInfoPtr css,
1.78 cvs 2768: ThotBool isHTML)
1.1 cvs 2769: {
1.43 cvs 2770: PresentationValue padding;
1.168 vatton 2771: char *ptr;
1.43 cvs 2772:
1.82 cvs 2773: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2774: ptr = cssRule;
1.43 cvs 2775: /* first parse the attribute string */
2776: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2777: if (padding.typed_data.value != 0 &&
1.184 vatton 2778: (padding.typed_data.unit == UNIT_INVALID ||
2779: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2780: {
1.169 vatton 2781: CSSParseError ("Invalid padding-top value", ptr, cssRule);
1.168 vatton 2782: padding.typed_data.value = 0;
2783: }
2784: else if (DoApply)
1.117 vatton 2785: {
2786: if (tsch)
2787: cssRule = CheckImportantRule (cssRule, context);
2788: TtaSetStylePresentation (PRPaddingTop, element, tsch, context, padding);
2789: }
1.1 cvs 2790: return (cssRule);
2791: }
2792:
2793: /*----------------------------------------------------------------------
1.59 cvs 2794: ParseCSSPaddingBottom: parse a CSS PaddingBottom attribute string
1.1 cvs 2795: ----------------------------------------------------------------------*/
1.79 cvs 2796: static char *ParseCSSPaddingBottom (Element element, PSchema tsch,
1.78 cvs 2797: PresentationContext context,
1.79 cvs 2798: char *cssRule, CSSInfoPtr css,
1.78 cvs 2799: ThotBool isHTML)
1.1 cvs 2800: {
1.43 cvs 2801: PresentationValue padding;
1.168 vatton 2802: char *ptr;
1.43 cvs 2803:
1.82 cvs 2804: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2805: ptr = cssRule;
1.43 cvs 2806: /* first parse the attribute string */
2807: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2808: if (padding.typed_data.value == 0)
1.184 vatton 2809: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2810: if (padding.typed_data.value != 0 &&
1.184 vatton 2811: (padding.typed_data.unit == UNIT_INVALID ||
2812: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2813: {
1.169 vatton 2814: CSSParseError ("Invalid padding-bottom value", ptr, cssRule);
1.168 vatton 2815: padding.typed_data.value = 0;
2816: }
2817: else if (DoApply)
1.117 vatton 2818: {
2819: if (tsch)
2820: cssRule = CheckImportantRule (cssRule, context);
2821: TtaSetStylePresentation (PRPaddingBottom, element, tsch, context, padding);
2822: }
1.1 cvs 2823: return (cssRule);
2824: }
2825:
2826: /*----------------------------------------------------------------------
1.59 cvs 2827: ParseCSSPaddingLeft: parse a CSS PaddingLeft attribute string.
1.1 cvs 2828: ----------------------------------------------------------------------*/
1.79 cvs 2829: static char *ParseCSSPaddingLeft (Element element, PSchema tsch,
1.78 cvs 2830: PresentationContext context,
1.79 cvs 2831: char *cssRule, CSSInfoPtr css,
1.78 cvs 2832: ThotBool isHTML)
1.1 cvs 2833: {
1.43 cvs 2834: PresentationValue padding;
1.168 vatton 2835: char *ptr;
1.43 cvs 2836:
1.82 cvs 2837: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2838: ptr = cssRule;
1.43 cvs 2839: /* first parse the attribute string */
2840: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2841: if (padding.typed_data.value == 0)
1.184 vatton 2842: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2843: if (padding.typed_data.value != 0 &&
1.184 vatton 2844: (padding.typed_data.unit == UNIT_INVALID ||
2845: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2846: {
1.169 vatton 2847: CSSParseError ("Invalid padding-left value", ptr, cssRule);
1.168 vatton 2848: padding.typed_data.value = 0;
2849: }
2850: else if (DoApply)
1.117 vatton 2851: {
2852: if (tsch)
2853: cssRule = CheckImportantRule (cssRule, context);
1.43 cvs 2854: TtaSetStylePresentation (PRPaddingLeft, element, tsch, context, padding);
1.117 vatton 2855: }
1.1 cvs 2856: return (cssRule);
2857: }
2858:
2859: /*----------------------------------------------------------------------
1.59 cvs 2860: ParseCSSPaddingRight: parse a CSS PaddingRight attribute string.
1.1 cvs 2861: ----------------------------------------------------------------------*/
1.79 cvs 2862: static char *ParseCSSPaddingRight (Element element, PSchema tsch,
1.78 cvs 2863: PresentationContext context,
1.79 cvs 2864: char *cssRule, CSSInfoPtr css,
1.78 cvs 2865: ThotBool isHTML)
1.1 cvs 2866: {
1.43 cvs 2867: PresentationValue padding;
1.168 vatton 2868: char *ptr;
1.43 cvs 2869:
1.82 cvs 2870: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2871: ptr = cssRule;
1.43 cvs 2872: /* first parse the attribute string */
2873: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2874: if (padding.typed_data.value == 0)
1.184 vatton 2875: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2876: if (padding.typed_data.value != 0 &&
1.184 vatton 2877: (padding.typed_data.unit == UNIT_INVALID ||
2878: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2879: {
1.169 vatton 2880: CSSParseError ("Invalid padding-right value", ptr, cssRule);
1.168 vatton 2881: padding.typed_data.value = 0;
2882: }
2883: else if (DoApply)
1.117 vatton 2884: {
2885: if (tsch)
2886: cssRule = CheckImportantRule (cssRule, context);
1.43 cvs 2887: TtaSetStylePresentation (PRPaddingRight, element, tsch, context, padding);
1.117 vatton 2888: }
1.1 cvs 2889: return (cssRule);
2890: }
2891:
2892: /*----------------------------------------------------------------------
1.59 cvs 2893: ParseCSSPadding: parse a CSS padding attribute string.
1.1 cvs 2894: ----------------------------------------------------------------------*/
1.79 cvs 2895: static char *ParseCSSPadding (Element element, PSchema tsch,
1.78 cvs 2896: PresentationContext context,
1.79 cvs 2897: char *cssRule, CSSInfoPtr css,
1.78 cvs 2898: ThotBool isHTML)
1.1 cvs 2899: {
1.79 cvs 2900: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 2901: int skippedNL;
1.43 cvs 2902:
1.82 cvs 2903: ptrT = SkipBlanksAndComments (cssRule);
1.43 cvs 2904: /* First parse Padding-Top */
2905: ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 2906: ptrR = SkipBlanksAndComments (ptrR);
2907: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.43 cvs 2908: {
1.93 vatton 2909: skippedNL = NewLineSkipped;
1.43 cvs 2910: cssRule = ptrR;
2911: /* apply the Padding-Top to all */
2912: ptrR = ParseCSSPaddingRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2913: NewLineSkipped = skippedNL;
1.43 cvs 2914: ptrR = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2915: NewLineSkipped = skippedNL;
1.43 cvs 2916: ptrR = ParseCSSPaddingLeft (element, tsch, context, ptrT, css, isHTML);
2917: }
2918: else
2919: {
2920: /* parse Padding-Right */
2921: ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 2922: ptrB = SkipBlanksAndComments (ptrB);
2923: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.43 cvs 2924: {
1.93 vatton 2925: skippedNL = NewLineSkipped;
1.43 cvs 2926: cssRule = ptrB;
2927: /* apply the Padding-Top to Padding-Bottom */
2928: ptrB = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2929: NewLineSkipped = skippedNL;
1.43 cvs 2930: /* apply the Padding-Right to Padding-Left */
2931: ptrB = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2932: }
2933: else
2934: {
2935: /* parse Padding-Bottom */
2936: ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 2937: ptrL = SkipBlanksAndComments (ptrL);
2938: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.43 cvs 2939: {
2940: cssRule = ptrL;
2941: /* apply the Padding-Right to Padding-Left */
2942: ptrL = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2943: }
2944: else
2945: /* parse Padding-Left */
2946: cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 2947: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2948: }
2949: }
1.1 cvs 2950: return (cssRule);
2951: }
2952:
2953: /*----------------------------------------------------------------------
1.59 cvs 2954: ParseCSSForeground: parse a CSS foreground attribute
1.1 cvs 2955: ----------------------------------------------------------------------*/
1.79 cvs 2956: static char *ParseCSSForeground (Element element, PSchema tsch,
1.78 cvs 2957: PresentationContext context,
1.79 cvs 2958: char *cssRule,
1.78 cvs 2959: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2960: {
1.117 vatton 2961: PresentationValue best;
1.262 vatton 2962: char *p;
1.1 cvs 2963:
1.262 vatton 2964: p = cssRule;
1.117 vatton 2965: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2966: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 2967: {
2968: if (tsch)
2969: cssRule = CheckImportantRule (cssRule, context);
1.262 vatton 2970: if (*cssRule != EOS && *cssRule !=';')
2971: {
2972: cssRule = SkipProperty (cssRule, FALSE);
2973: CSSParseError ("Invalid value", p, cssRule);
2974: }
2975: else
2976: /* install the new presentation */
2977: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
1.117 vatton 2978: }
1.1 cvs 2979: return (cssRule);
2980: }
2981:
2982: /*----------------------------------------------------------------------
1.59 cvs 2983: ParseCSSBackgroundColor: parse a CSS background color attribute
1.1 cvs 2984: ----------------------------------------------------------------------*/
1.79 cvs 2985: static char *ParseCSSBackgroundColor (Element element, PSchema tsch,
1.78 cvs 2986: PresentationContext context,
1.79 cvs 2987: char *cssRule,
1.78 cvs 2988: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2989: {
2990: PresentationValue best;
2991:
1.184 vatton 2992: best.typed_data.unit = UNIT_INVALID;
1.1 cvs 2993: best.typed_data.real = FALSE;
1.198 vatton 2994: if (!strncasecmp (cssRule, "transparent", 11))
1.1 cvs 2995: {
1.184 vatton 2996: best.typed_data.value = PATTERN_NONE;
2997: best.typed_data.unit = UNIT_REL;
1.116 vatton 2998: if (DoApply)
1.117 vatton 2999: {
3000: if (tsch)
3001: cssRule = CheckImportantRule (cssRule, context);
3002: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
3003: }
1.65 cvs 3004: cssRule = SkipWord (cssRule);
1.1 cvs 3005: }
3006: else
3007: {
3008: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 3009: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.1 cvs 3010: {
1.117 vatton 3011: if (tsch)
3012: cssRule = CheckImportantRule (cssRule, context);
1.1 cvs 3013: /* install the new presentation. */
3014: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
1.59 cvs 3015: /* thot specificity: need to set fill pattern for background color */
1.184 vatton 3016: best.typed_data.value = PATTERN_BACKGROUND;
3017: best.typed_data.unit = UNIT_REL;
1.1 cvs 3018: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
3019: best.typed_data.value = 1;
1.184 vatton 3020: best.typed_data.unit = UNIT_REL;
1.1 cvs 3021: TtaSetStylePresentation (PRShowBox, element, tsch, context, best);
3022: }
3023: }
3024: return (cssRule);
3025: }
3026:
1.63 cvs 3027: /*----------------------------------------------------------------------
1.245 quint 3028: ParseCSSUrl: parse an URL
3029: ----------------------------------------------------------------------*/
3030: static char *ParseCSSUrl (char *cssRule, char **url)
3031: {
3032: char saved;
3033: char *base, *ptr;
3034:
3035: cssRule = SkipBlanksAndComments (cssRule);
3036: saved = *cssRule;
3037: if (*cssRule == '(')
3038: {
3039: cssRule++;
3040: cssRule = SkipBlanksAndComments (cssRule);
3041: /*** Escaped quotes are not handled. See function SkipQuotedString */
3042: if (*cssRule == '"')
3043: {
3044: cssRule++;
3045: base = cssRule;
3046: while (*cssRule != EOS && *cssRule != '"')
3047: cssRule++;
3048: }
3049: else if (*cssRule == '\'')
3050: {
3051: cssRule++;
3052: base = cssRule;
3053: while (*cssRule != EOS && *cssRule != '\'')
3054: cssRule++;
3055: }
3056: else
3057: {
3058: base = cssRule;
3059: while (*cssRule != EOS && *cssRule != ')')
3060: cssRule++;
3061: }
3062: /* keep the current position */
3063: ptr = cssRule;
3064: if (saved == ')')
3065: {
3066: /* remove extra spaces */
3067: if (cssRule[-1] == SPACE)
3068: {
3069: *cssRule = SPACE;
3070: cssRule--;
3071: while (cssRule[-1] == SPACE)
3072: cssRule--;
3073: }
3074: }
3075: saved = *cssRule;
3076: *cssRule = EOS;
3077: *url = TtaStrdup (base);
3078: *cssRule = saved;
3079: if (saved == '"' || saved == '\'')
3080: /* we need to skip the quote character and possible spaces */
3081: {
3082: cssRule++;
3083: cssRule = SkipBlanksAndComments (cssRule);
3084: }
3085: else
3086: cssRule = ptr;
3087: }
3088: cssRule++;
3089: return cssRule;
3090: }
3091:
3092: /*----------------------------------------------------------------------
1.65 cvs 3093: ParseSVGStroke: parse a SVG stroke property
3094: ----------------------------------------------------------------------*/
1.79 cvs 3095: static char *ParseSVGStroke (Element element, PSchema tsch,
3096: PresentationContext context, char *cssRule,
3097: CSSInfoPtr css, ThotBool isHTML)
1.65 cvs 3098: {
3099: PresentationValue best;
1.245 quint 3100: char *url;
1.65 cvs 3101:
1.184 vatton 3102: best.typed_data.unit = UNIT_INVALID;
1.65 cvs 3103: best.typed_data.real = FALSE;
1.82 cvs 3104: if (!strncasecmp (cssRule, "none", 4))
1.65 cvs 3105: {
3106: best.typed_data.value = -2; /* -2 means transparent */
1.184 vatton 3107: best.typed_data.unit = UNIT_REL;
1.116 vatton 3108: if (DoApply)
1.117 vatton 3109: {
3110: if (tsch)
3111: cssRule = CheckImportantRule (cssRule, context);
3112: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
3113: }
1.65 cvs 3114: cssRule = SkipWord (cssRule);
3115: }
1.245 quint 3116: else if (!strncasecmp (cssRule, "currentColor", 12))
3117: {
3118: /* **** do something here to inherit color */;
3119: }
3120: else if (!strncasecmp (cssRule, "url", 3))
3121: {
3122: cssRule += 3;
3123: cssRule = ParseCSSUrl (cssRule, &url);
3124: /* **** do something with the url ***** */;
3125: TtaFreeMemory (url);
3126: /* **** caution: another color value may follow the uri (in case
3127: the uri could ne be dereferenced) *** */
3128: }
1.65 cvs 3129: else
3130: {
3131: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 3132: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 3133: {
3134: if (tsch)
3135: cssRule = CheckImportantRule (cssRule, context);
3136: /* install the new presentation */
3137: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
3138: }
1.65 cvs 3139: }
3140: return (cssRule);
3141: }
3142:
3143: /*----------------------------------------------------------------------
1.63 cvs 3144: ParseSVGFill: parse a SVG fill property
3145: ----------------------------------------------------------------------*/
1.79 cvs 3146: static char *ParseSVGFill (Element element, PSchema tsch,
3147: PresentationContext context, char *cssRule,
3148: CSSInfoPtr css, ThotBool isHTML)
1.63 cvs 3149: {
3150: PresentationValue best;
1.245 quint 3151: char *url;
1.63 cvs 3152:
1.184 vatton 3153: best.typed_data.unit = UNIT_INVALID;
1.63 cvs 3154: best.typed_data.real = FALSE;
1.82 cvs 3155: if (!strncasecmp (cssRule, "none", 4))
1.63 cvs 3156: {
1.184 vatton 3157: best.typed_data.value = PATTERN_NONE;
3158: best.typed_data.unit = UNIT_REL;
1.116 vatton 3159: if (DoApply)
1.117 vatton 3160: {
3161: if (tsch)
3162: cssRule = CheckImportantRule (cssRule, context);
3163: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
3164: }
1.65 cvs 3165: cssRule = SkipWord (cssRule);
1.63 cvs 3166: }
1.245 quint 3167: else if (!strncasecmp (cssRule, "currentColor", 12))
3168: {
3169: /* **** do something here to inherit color */;
3170: }
3171: else if (!strncasecmp (cssRule, "url", 3))
3172: {
3173: cssRule += 3;
3174: cssRule = ParseCSSUrl (cssRule, &url);
3175: /* **** do something with the url ***** */;
3176: TtaFreeMemory (url);
3177: /* **** caution: another color value may follow the uri (in case
3178: the uri could ne be dereferenced) *** */
3179: }
1.63 cvs 3180: else
3181: {
3182: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 3183: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.63 cvs 3184: {
1.117 vatton 3185: if (tsch)
3186: cssRule = CheckImportantRule (cssRule, context);
1.63 cvs 3187: /* install the new presentation. */
3188: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
3189: /* thot specificity: need to set fill pattern for background color */
1.184 vatton 3190: best.typed_data.value = PATTERN_BACKGROUND;
3191: best.typed_data.unit = UNIT_REL;
1.63 cvs 3192: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
3193: }
3194: }
3195: return (cssRule);
3196: }
1.161 quint 3197:
1.155 cheyroul 3198: /*----------------------------------------------------------------------
3199: ParseSVGOpacity: parse a SVG fill property
3200: ----------------------------------------------------------------------*/
3201: static char *ParseSVGOpacity (Element element, PSchema tsch,
3202: PresentationContext context, char *cssRule,
3203: CSSInfoPtr css, ThotBool isHTML)
3204: {
3205: PresentationValue best;
1.63 cvs 3206:
1.184 vatton 3207: best.typed_data.unit = UNIT_INVALID;
1.155 cheyroul 3208: best.typed_data.real = FALSE;
3209: cssRule = ParseClampedUnit (cssRule, &best);
3210: if (DoApply)
3211: {
3212: if (tsch)
3213: cssRule = CheckImportantRule (cssRule, context);
3214: /* install the new presentation. */
3215: TtaSetStylePresentation (PROpacity, element,
3216: tsch, context, best);
3217: }
3218: return (cssRule);
3219: }
1.170 cheyroul 3220: /*----------------------------------------------------------------------
3221: ParseSVGOpacity: parse a SVG fill property
3222: ----------------------------------------------------------------------*/
3223: static char *ParseSVGStrokeOpacity (Element element, PSchema tsch,
3224: PresentationContext context, char *cssRule,
3225: CSSInfoPtr css, ThotBool isHTML)
3226: {
3227: PresentationValue best;
1.161 quint 3228:
1.184 vatton 3229: best.typed_data.unit = UNIT_INVALID;
1.170 cheyroul 3230: best.typed_data.real = FALSE;
3231: cssRule = ParseClampedUnit (cssRule, &best);
3232: if (DoApply)
3233: {
3234: if (tsch)
3235: cssRule = CheckImportantRule (cssRule, context);
3236: /* install the new presentation. */
3237: TtaSetStylePresentation (PRStrokeOpacity, element,
3238: tsch, context, best);
3239: }
3240: return (cssRule);
3241: }
3242: /*----------------------------------------------------------------------
3243: ParseSVGOpacity: parse a SVG fill property
3244: ----------------------------------------------------------------------*/
3245: static char *ParseSVGFillOpacity (Element element, PSchema tsch,
3246: PresentationContext context, char *cssRule,
3247: CSSInfoPtr css, ThotBool isHTML)
3248: {
3249: PresentationValue best;
3250:
1.184 vatton 3251: best.typed_data.unit = UNIT_INVALID;
1.170 cheyroul 3252: best.typed_data.real = FALSE;
3253: cssRule = ParseClampedUnit (cssRule, &best);
3254: if (DoApply)
3255: {
3256: if (tsch)
3257: cssRule = CheckImportantRule (cssRule, context);
3258: /* install the new presentation. */
3259: TtaSetStylePresentation (PRFillOpacity, element,
3260: tsch, context, best);
3261: }
3262: return (cssRule);
3263: }
1.207 vatton 3264:
1.1 cvs 3265: /*----------------------------------------------------------------------
1.59 cvs 3266: ParseCSSBackgroundImageCallback: Callback called asynchronously by
3267: FetchImage when a background image has been fetched.
1.1 cvs 3268: ----------------------------------------------------------------------*/
1.82 cvs 3269: void ParseCSSBackgroundImageCallback (Document doc, Element element,
1.203 vatton 3270: char *file, void *extra,
3271: ThotBool isnew)
1.1 cvs 3272: {
1.233 vatton 3273: DisplayMode dispMode = DisplayImmediately;
1.82 cvs 3274: BackgroundImageCallbackPtr callblock;
3275: Element el;
3276: PSchema tsch;
1.185 vatton 3277: CSSInfoPtr css;
1.206 vatton 3278: PInfoPtr pInfo;
1.207 vatton 3279: PresentationContext ctxt;
1.82 cvs 3280: PresentationValue image;
3281: PresentationValue value;
1.206 vatton 3282: ThotBool enabled;
1.82 cvs 3283: callblock = (BackgroundImageCallbackPtr) extra;
1.34 cvs 3284: if (callblock == NULL)
3285: return;
1.1 cvs 3286:
1.188 cheyroul 3287: css = NULL;
1.34 cvs 3288: el = callblock->el;
3289: tsch = callblock->tsch;
1.207 vatton 3290: ctxt = callblock->ctxt;
1.203 vatton 3291: if (doc == 0 && !isnew)
3292: /* apply to the current document only */
1.207 vatton 3293: doc = ctxt->doc;
1.185 vatton 3294: if (doc)
3295: {
3296: /* avoid too many redisplay */
3297: dispMode = TtaGetDisplayMode (doc);
3298: if (dispMode == DisplayImmediately)
3299: TtaSetDisplayMode (doc, DeferredDisplay);
3300: }
3301: else
3302: {
3303: /* check if the CSS still exists */
3304: css = CSSList;
3305: while (css && css != callblock->css)
3306: css = css->NextCSS;
3307: if (css == NULL)
3308: tsch = NULL;
3309: }
1.34 cvs 3310:
1.185 vatton 3311: if (el || tsch)
3312: {
3313: /* Ok the image was fetched, finish the background-image handling */
1.193 vatton 3314: image.typed_data.unit = UNIT_REL;
3315: image.typed_data.real = FALSE;
1.185 vatton 3316: image.pointer = file;
1.207 vatton 3317: TtaSetStylePresentation (PRBackgroundPicture, el, tsch, ctxt, image);
1.185 vatton 3318:
3319: /* enforce the showbox */
3320: value.typed_data.value = 1;
3321: value.typed_data.unit = UNIT_REL;
3322: value.typed_data.real = FALSE;
1.207 vatton 3323: TtaSetStylePresentation (PRShowBox, el, tsch, ctxt, value);
3324: /* check if the context can be freed */
3325: ctxt->uses -= 1;
3326: if (ctxt->uses == 0)
3327: /* no other image loading */
3328: TtaFreeMemory (ctxt);
1.185 vatton 3329: }
1.34 cvs 3330:
3331: TtaFreeMemory (callblock);
3332: /* restore the display mode */
1.185 vatton 3333: if (doc)
3334: {
3335: if (dispMode == DisplayImmediately)
3336: TtaSetDisplayMode (doc, dispMode);
3337: }
3338: else if (css)
3339: {
3340: for (doc = 1; doc < DocumentTableLength; doc++)
1.206 vatton 3341: if (css->infos[doc] &&
1.185 vatton 3342: /* don't manage a document used by make book */
3343: (DocumentMeta[doc] == NULL ||
3344: DocumentMeta[doc]->method != CE_MAKEBOOK))
3345: {
1.206 vatton 3346: pInfo = css->infos[doc];
3347: enabled = FALSE;
3348: while (pInfo && !enabled)
3349: {
3350: enabled = pInfo->PiEnabled;
3351: pInfo = pInfo->PiNext;
3352: }
1.185 vatton 3353: /* Change the Display Mode to take into account the new presentation */
3354: dispMode = TtaGetDisplayMode (doc);
3355: if (dispMode == DisplayImmediately)
1.194 vatton 3356: {
3357: TtaSetDisplayMode (doc, NoComputedDisplay);
3358: /* Restore the display mode */
3359: TtaSetDisplayMode (doc, dispMode);
3360: }
1.185 vatton 3361: }
3362: }
1.1 cvs 3363: }
3364:
1.217 vatton 3365: /*----------------------------------------------------------------------
3366: GetCSSBackgroundURL searches a CSS BackgroundImage url within
3367: the cssRule.
3368: Returns NULL or a new allocated url string.
3369: ----------------------------------------------------------------------*/
3370: char *GetCSSBackgroundURL (char *cssRule)
3371: {
3372: char *b, *url;
3373:
3374: url = NULL;
3375: b = strstr (cssRule, "url");
3376: if (b)
3377: b = ParseCSSUrl (url, &url);
3378: return (url);
3379: }
3380:
3381: /*----------------------------------------------------------------------
3382: ParseCSSContent: parse a CSS content value
3383: ----------------------------------------------------------------------*/
3384: static char *ParseCSSContent (Element element, PSchema tsch,
3385: PresentationContext context, char *cssRule,
3386: CSSInfoPtr css, ThotBool isHTML)
3387: {
3388: char *p, quoteChar, *url;
3389:
3390: cssRule = SkipBlanksAndComments (cssRule);
3391: p = cssRule;
3392: if (!strncasecmp (cssRule, "url", 3))
3393: {
3394: cssRule += 3;
3395: cssRule = ParseCSSUrl (cssRule, &url);
3396: TtaFreeMemory (url);
3397: }
3398: else if (*cssRule == '"' || *cssRule == '\'')
3399: {
3400: quoteChar = *cssRule;
3401: cssRule++;
3402: cssRule = SkipQuotedString (cssRule, quoteChar);
1.259 vatton 3403: cssRule = SkipBlanksAndComments (cssRule);
1.253 vatton 3404: if (*cssRule != EOS && *cssRule !=';')
1.260 vatton 3405: cssRule = SkipProperty (cssRule, FALSE);
1.217 vatton 3406: }
3407: else
1.260 vatton 3408: cssRule = SkipProperty (cssRule, FALSE);
1.217 vatton 3409: return (cssRule);
3410: }
1.1 cvs 3411:
3412: /*----------------------------------------------------------------------
1.59 cvs 3413: ParseCSSBackgroundImage: parse a CSS BackgroundImage attribute string.
1.1 cvs 3414: ----------------------------------------------------------------------*/
1.79 cvs 3415: static char *ParseCSSBackgroundImage (Element element, PSchema tsch,
1.207 vatton 3416: PresentationContext ctxt,
1.79 cvs 3417: char *cssRule, CSSInfoPtr css,
3418: ThotBool isHTML)
1.1 cvs 3419: {
1.49 cvs 3420: Element el;
1.1 cvs 3421: BackgroundImageCallbackPtr callblock;
1.49 cvs 3422: PresentationValue image, value;
1.79 cvs 3423: char *url;
1.82 cvs 3424: char *bg_image;
1.79 cvs 3425: char tempname[MAX_LENGTH];
3426: char imgname[MAX_LENGTH];
1.148 vatton 3427:
1.163 quint 3428: if (element)
1.148 vatton 3429: el = element;
1.163 quint 3430: else
3431: /* default element for FetchImage */
1.207 vatton 3432: el = TtaGetMainRoot (ctxt->doc);
1.163 quint 3433:
1.1 cvs 3434: url = NULL;
1.82 cvs 3435: cssRule = SkipBlanksAndComments (cssRule);
1.161 quint 3436: if (!strncasecmp (cssRule, "none", 4))
3437: {
1.260 vatton 3438: cssRule += 4;
3439: if (tsch)
3440: cssRule = CheckImportantRule (cssRule, ctxt);
1.247 quint 3441: if (DoApply)
3442: {
3443: /* no background image */
3444: image.pointer = NULL;
3445: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, ctxt, image);
3446: /* no background color */
3447: value.typed_data.unit = UNIT_INVALID;
3448: value.typed_data.real = FALSE;
3449: value.typed_data.value = PATTERN_NONE;
3450: value.typed_data.unit = UNIT_REL;
3451: TtaSetStylePresentation (PRFillPattern, element, tsch, ctxt, value);
3452: }
1.161 quint 3453: }
3454: else if (!strncasecmp (cssRule, "url", 3))
1.1 cvs 3455: {
3456: cssRule += 3;
1.217 vatton 3457: cssRule = ParseCSSUrl (cssRule, &url);
1.207 vatton 3458: if (ctxt->destroy)
1.1 cvs 3459: {
3460: /* remove the background image PRule */
3461: image.pointer = NULL;
1.207 vatton 3462: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, ctxt, image);
3463: if (TtaGetStylePresentation (PRFillPattern, element, tsch, ctxt, &value) < 0)
1.1 cvs 3464: {
3465: /* there is no FillPattern rule -> remove ShowBox rule */
3466: value.typed_data.value = 1;
1.184 vatton 3467: value.typed_data.unit = UNIT_REL;
1.1 cvs 3468: value.typed_data.real = FALSE;
1.207 vatton 3469: TtaSetStylePresentation (PRShowBox, element, tsch, ctxt, value);
1.1 cvs 3470: }
3471: }
3472: else if (url)
3473: {
1.30 cvs 3474: bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
1.82 cvs 3475: if (bg_image == NULL || !strcasecmp (bg_image, "yes"))
1.161 quint 3476: /* background images are enabled */
1.1 cvs 3477: {
1.260 vatton 3478: if (tsch)
3479: cssRule = CheckImportantRule (cssRule, ctxt);
1.185 vatton 3480: callblock = (BackgroundImageCallbackPtr) TtaGetMemory (sizeof (BackgroundImageCallbackBlock));
1.191 vatton 3481: if (callblock)
1.1 cvs 3482: {
3483: callblock->el = element;
3484: callblock->tsch = tsch;
1.185 vatton 3485: callblock->css = css;
1.207 vatton 3486: callblock->ctxt = ctxt;
3487: /* new use of the context */
3488: ctxt->uses += 1;
1.18 cvs 3489: /* check if the image url is related to an external CSS */
1.182 vatton 3490: if (css)
1.18 cvs 3491: {
1.189 vatton 3492: if (css->url)
3493: /* the image concerns a CSS file */
3494: NormalizeURL (url, 0, tempname, imgname, css->url);
3495: else
3496: /* the image concerns a style element */
1.207 vatton 3497: NormalizeURL (url, ctxt->doc, tempname, imgname, NULL);
1.18 cvs 3498: /* fetch and display background image of element */
1.181 vatton 3499: FetchImage (0, el, tempname, AMAYA_LOAD_IMAGE,
1.161 quint 3500: ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 3501: }
3502: else
1.207 vatton 3503: FetchImage (ctxt->doc, el, url, AMAYA_LOAD_IMAGE,
1.161 quint 3504: ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 3505: }
3506: }
3507: }
1.229 vatton 3508: if (url)
3509: TtaFreeMemory (url);
1.18 cvs 3510: }
3511: return (cssRule);
3512: }
3513:
3514: /*----------------------------------------------------------------------
1.59 cvs 3515: ParseCSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
1.18 cvs 3516: ----------------------------------------------------------------------*/
1.79 cvs 3517: static char *ParseCSSBackgroundRepeat (Element element, PSchema tsch,
1.207 vatton 3518: PresentationContext ctxt,
1.97 vatton 3519: char *cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3520: {
3521: PresentationValue repeat;
3522:
1.184 vatton 3523: repeat.typed_data.value = REALSIZE;
1.191 vatton 3524: repeat.typed_data.unit = UNIT_BOX;
1.18 cvs 3525: repeat.typed_data.real = FALSE;
1.82 cvs 3526: cssRule = SkipBlanksAndComments (cssRule);
3527: if (!strncasecmp (cssRule, "no-repeat", 9))
1.184 vatton 3528: repeat.typed_data.value = REALSIZE;
1.82 cvs 3529: else if (!strncasecmp (cssRule, "repeat-y", 8))
1.265 vatton 3530: repeat.typed_data.value = YREPEAT;
1.82 cvs 3531: else if (!strncasecmp (cssRule, "repeat-x", 8))
1.265 vatton 3532: repeat.typed_data.value = XREPEAT;
1.82 cvs 3533: else if (!strncasecmp (cssRule, "repeat", 6))
1.184 vatton 3534: repeat.typed_data.value = REPEAT;
1.18 cvs 3535: else
3536: return (cssRule);
3537:
3538: /* install the new presentation */
1.116 vatton 3539: if (DoApply)
1.117 vatton 3540: {
3541: /* check if it's an important rule */
3542: if (tsch)
1.207 vatton 3543: cssRule = CheckImportantRule (cssRule, ctxt);
3544: TtaSetStylePresentation (PRPictureMode, element, tsch, ctxt, repeat);
1.117 vatton 3545: }
1.18 cvs 3546: cssRule = SkipWord (cssRule);
1.163 quint 3547: return (cssRule);
1.18 cvs 3548: }
3549:
3550: /*----------------------------------------------------------------------
1.59 cvs 3551: ParseCSSBackgroundAttachment: parse a CSS BackgroundAttachment
1.18 cvs 3552: attribute string.
3553: ----------------------------------------------------------------------*/
1.79 cvs 3554: static char *ParseCSSBackgroundAttachment (Element element, PSchema tsch,
1.207 vatton 3555: PresentationContext ctxt,
1.79 cvs 3556: char *cssRule, CSSInfoPtr css,
3557: ThotBool isHTML)
1.18 cvs 3558: {
1.200 vatton 3559: char *ptr;
3560:
1.163 quint 3561: cssRule = SkipBlanksAndComments (cssRule);
3562: if (!strncasecmp (cssRule, "scroll", 6))
1.199 vatton 3563: {
3564: /* force no-repeat for that background image */
1.200 vatton 3565: ptr = "no-repeat";
1.207 vatton 3566: ParseCSSBackgroundRepeat (element, tsch, ctxt, ptr, css, isHTML);
1.199 vatton 3567: cssRule = SkipWord (cssRule);
3568: }
1.163 quint 3569: else if (!strncasecmp (cssRule, "fixed", 5))
1.199 vatton 3570: {
3571: /* force no-repeat for that background image */
1.201 vatton 3572: ptr = "no-repeat";
1.207 vatton 3573: ParseCSSBackgroundRepeat (element, tsch, ctxt, ptr, css, isHTML);
1.199 vatton 3574: cssRule = SkipWord (cssRule);
3575: }
1.163 quint 3576: return (cssRule);
1.1 cvs 3577: }
3578:
3579: /*----------------------------------------------------------------------
1.59 cvs 3580: ParseCSSBackgroundPosition: parse a CSS BackgroundPosition
1.1 cvs 3581: attribute string.
3582: ----------------------------------------------------------------------*/
1.79 cvs 3583: static char *ParseCSSBackgroundPosition (Element element, PSchema tsch,
1.207 vatton 3584: PresentationContext ctxt,
1.79 cvs 3585: char *cssRule, CSSInfoPtr css,
3586: ThotBool isHTML)
1.1 cvs 3587: {
1.18 cvs 3588: PresentationValue repeat;
1.200 vatton 3589: char *ptr;
1.18 cvs 3590: ThotBool ok;
1.1 cvs 3591:
1.163 quint 3592: cssRule = SkipBlanksAndComments (cssRule);
3593: ok = TRUE;
3594: if (!strncasecmp (cssRule, "left", 4))
3595: cssRule = SkipWord (cssRule);
3596: else if (!strncasecmp (cssRule, "right", 5))
3597: cssRule = SkipWord (cssRule);
3598: else if (!strncasecmp (cssRule, "center", 6))
3599: cssRule = SkipWord (cssRule);
3600: else if (!strncasecmp (cssRule, "top", 3))
3601: cssRule = SkipWord (cssRule);
3602: else if (!strncasecmp (cssRule, "bottom", 6))
3603: cssRule = SkipWord (cssRule);
3604: else if (isdigit (*cssRule) || *cssRule == '.')
1.191 vatton 3605: {
1.206 vatton 3606: while (*cssRule != EOS && *cssRule != SPACE &&
3607: *cssRule != ',' && *cssRule != ';')
3608: cssRule++;
1.191 vatton 3609: }
1.163 quint 3610: else
3611: ok = FALSE;
3612:
3613: if (ok && DoApply)
1.148 vatton 3614: {
1.199 vatton 3615: /* force no-repeat for that background image */
1.200 vatton 3616: ptr = "no-repeat";
1.207 vatton 3617: ParseCSSBackgroundRepeat (element, tsch, ctxt, ptr, css, isHTML);
1.163 quint 3618: /* force realsize for the background image */
1.184 vatton 3619: repeat.typed_data.value = REALSIZE;
3620: repeat.typed_data.unit = UNIT_REL;
1.163 quint 3621: repeat.typed_data.real = FALSE;
3622: /* check if it's an important rule */
3623: if (tsch)
1.207 vatton 3624: cssRule = CheckImportantRule (cssRule, ctxt);
3625: /*TtaSetStylePresentation (PRPictureMode, element, tsch, ctxt, repeat);*/
1.218 vatton 3626:
3627: /* check the second value */
3628: cssRule = SkipBlanksAndComments (cssRule);
3629: if (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS)
3630: cssRule = ParseCSSBackgroundPosition (element, tsch, ctxt,
3631: cssRule, css, isHTML);
1.148 vatton 3632: }
1.163 quint 3633: return (cssRule);
1.18 cvs 3634: }
3635:
3636: /*----------------------------------------------------------------------
1.59 cvs 3637: ParseCSSBackground: parse a CSS background attribute
1.18 cvs 3638: ----------------------------------------------------------------------*/
1.79 cvs 3639: static char *ParseCSSBackground (Element element, PSchema tsch,
1.207 vatton 3640: PresentationContext ctxt, char *cssRule,
1.79 cvs 3641: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3642: {
1.79 cvs 3643: char *ptr;
1.93 vatton 3644: int skippedNL;
1.18 cvs 3645:
1.82 cvs 3646: cssRule = SkipBlanksAndComments (cssRule);
3647: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.18 cvs 3648: {
1.71 cvs 3649: /* perhaps a Background Image */
1.198 vatton 3650: if (!strncasecmp (cssRule, "url", 3) || !strncasecmp (cssRule, "none", 4))
1.207 vatton 3651: cssRule = ParseCSSBackgroundImage (element, tsch, ctxt, cssRule,
1.63 cvs 3652: css, isHTML);
1.18 cvs 3653: /* perhaps a Background Attachment */
1.82 cvs 3654: else if (!strncasecmp (cssRule, "scroll", 6) ||
3655: !strncasecmp (cssRule, "fixed", 5))
1.207 vatton 3656: cssRule = ParseCSSBackgroundAttachment (element, tsch, ctxt,
1.63 cvs 3657: cssRule, css, isHTML);
1.18 cvs 3658: /* perhaps a Background Repeat */
1.82 cvs 3659: else if (!strncasecmp (cssRule, "no-repeat", 9) ||
3660: !strncasecmp (cssRule, "repeat-y", 8) ||
3661: !strncasecmp (cssRule, "repeat-x", 8) ||
3662: !strncasecmp (cssRule, "repeat", 6))
1.207 vatton 3663: cssRule = ParseCSSBackgroundRepeat (element, tsch, ctxt,
1.82 cvs 3664: cssRule, css, isHTML);
1.18 cvs 3665: /* perhaps a Background Position */
1.82 cvs 3666: else if (!strncasecmp (cssRule, "left", 4) ||
3667: !strncasecmp (cssRule, "right", 5) ||
3668: !strncasecmp (cssRule, "center", 6) ||
3669: !strncasecmp (cssRule, "top", 3) ||
3670: !strncasecmp (cssRule, "bottom", 6) ||
1.110 vatton 3671: isdigit (*cssRule) || *cssRule == '.')
1.207 vatton 3672: cssRule = ParseCSSBackgroundPosition (element, tsch, ctxt,
1.63 cvs 3673: cssRule, css, isHTML);
1.18 cvs 3674: /* perhaps a Background Color */
3675: else
3676: {
1.93 vatton 3677: skippedNL = NewLineSkipped;
1.18 cvs 3678: /* check if the rule has been found */
3679: ptr = cssRule;
1.207 vatton 3680: cssRule = ParseCSSBackgroundColor (element, tsch, ctxt,
1.82 cvs 3681: cssRule, css, isHTML);
1.43 cvs 3682: if (ptr == cssRule)
1.93 vatton 3683: {
3684: NewLineSkipped = skippedNL;
3685: /* rule not found */
1.234 vatton 3686: cssRule = SkipProperty (cssRule, FALSE);
1.93 vatton 3687: }
1.18 cvs 3688: }
1.82 cvs 3689: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 3690: }
3691: return (cssRule);
3692: }
3693:
1.59 cvs 3694: /*----------------------------------------------------------------------
1.60 cvs 3695: ParseCSSPageBreakBefore: parse a CSS page-break-before attribute
1.59 cvs 3696: ----------------------------------------------------------------------*/
1.79 cvs 3697: static char *ParseCSSPageBreakBefore (Element element, PSchema tsch,
1.207 vatton 3698: PresentationContext ctxt, char *cssRule,
1.79 cvs 3699: CSSInfoPtr css, ThotBool isHTML)
1.59 cvs 3700: {
3701: PresentationValue page;
3702:
1.184 vatton 3703: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3704: page.typed_data.real = FALSE;
1.82 cvs 3705: cssRule = SkipBlanksAndComments (cssRule);
3706: if (!strncasecmp (cssRule, "auto", 4))
1.184 vatton 3707: page.typed_data.value = PageAuto;
1.82 cvs 3708: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 3709: {
1.184 vatton 3710: page.typed_data.unit = UNIT_REL;
3711: page.typed_data.value = PageAlways;
1.59 cvs 3712: }
1.82 cvs 3713: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3714: {
1.184 vatton 3715: page.typed_data.unit = UNIT_REL;
3716: page.typed_data.value = PageAvoid;
1.59 cvs 3717: }
1.82 cvs 3718: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 3719: {
1.184 vatton 3720: page.typed_data.unit = UNIT_REL;
3721: page.typed_data.value = PageLeft;
1.59 cvs 3722: }
1.82 cvs 3723: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 3724: {
1.184 vatton 3725: page.typed_data.unit = UNIT_REL;
3726: page.typed_data.value = PageRight;
1.59 cvs 3727: }
1.82 cvs 3728: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3729: {
1.184 vatton 3730: /*page.typed_data.unit = UNIT_REL;*/
3731: page.typed_data.value = PageInherit;
1.59 cvs 3732: }
3733: cssRule = SkipWord (cssRule);
3734: /* install the new presentation */
1.184 vatton 3735: if (page.typed_data.unit == UNIT_REL &&
3736: page.typed_data.value == PageAlways && DoApply)
1.117 vatton 3737: {
3738: /* check if it's an important rule */
3739: if (tsch)
1.207 vatton 3740: cssRule = CheckImportantRule (cssRule, ctxt);
3741: TtaSetStylePresentation (PRPageBefore, element, tsch, ctxt, page);
1.117 vatton 3742: }
1.59 cvs 3743: return (cssRule);
3744: }
3745:
3746: /*----------------------------------------------------------------------
1.60 cvs 3747: ParseCSSPageBreakAfter: parse a CSS page-break-after attribute
1.59 cvs 3748: ----------------------------------------------------------------------*/
1.79 cvs 3749: static char *ParseCSSPageBreakAfter (Element element, PSchema tsch,
1.207 vatton 3750: PresentationContext ctxt,
1.79 cvs 3751: char *cssRule, CSSInfoPtr css,
3752: ThotBool isHTML)
1.59 cvs 3753: {
3754: PresentationValue page;
3755:
1.184 vatton 3756: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3757: page.typed_data.real = FALSE;
1.82 cvs 3758: cssRule = SkipBlanksAndComments (cssRule);
3759: if (!strncasecmp (cssRule, "auto", 4))
1.184 vatton 3760: page.typed_data.value = PageAuto;
1.82 cvs 3761: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 3762: {
1.184 vatton 3763: page.typed_data.unit = UNIT_REL;
3764: page.typed_data.value = PageAlways;
1.59 cvs 3765: }
1.82 cvs 3766: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3767: {
1.184 vatton 3768: page.typed_data.unit = UNIT_REL;
3769: page.typed_data.value = PageAvoid;
1.59 cvs 3770: }
1.82 cvs 3771: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 3772: {
1.184 vatton 3773: page.typed_data.unit = UNIT_REL;
3774: page.typed_data.value = PageLeft;
1.59 cvs 3775: }
1.82 cvs 3776: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 3777: {
1.184 vatton 3778: page.typed_data.unit = UNIT_REL;
3779: page.typed_data.value = PageRight;
1.59 cvs 3780: }
1.82 cvs 3781: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3782: {
1.184 vatton 3783: /*page.typed_data.unit = UNIT_REL;*/
3784: page.typed_data.value = PageInherit;
1.59 cvs 3785: }
3786: cssRule = SkipWord (cssRule);
3787: /* install the new presentation */
1.184 vatton 3788: /*if (page.typed_data.unit == UNIT_REL && DoApply)
1.117 vatton 3789: {
3790: if (tsch)
1.207 vatton 3791: cssRule = CheckImportantRule (cssRule, ctxt);
3792: TtaSetStylePresentation (PRPageAfter, element, tsch, ctxt, page);
1.117 vatton 3793: }*/
1.59 cvs 3794: return (cssRule);
3795: }
3796:
3797: /*----------------------------------------------------------------------
1.60 cvs 3798: ParseCSSPageBreakInside: parse a CSS page-break-inside attribute
1.59 cvs 3799: ----------------------------------------------------------------------*/
1.79 cvs 3800: static char *ParseCSSPageBreakInside (Element element, PSchema tsch,
1.207 vatton 3801: PresentationContext ctxt,
1.79 cvs 3802: char *cssRule, CSSInfoPtr css,
3803: ThotBool isHTML)
1.59 cvs 3804: {
3805: PresentationValue page;
3806:
1.184 vatton 3807: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3808: page.typed_data.real = FALSE;
1.82 cvs 3809: cssRule = SkipBlanksAndComments (cssRule);
3810: if (!strncasecmp (cssRule, "auto", 4))
1.59 cvs 3811: {
1.184 vatton 3812: /*page.typed_data.unit = UNIT_REL;*/
3813: page.typed_data.value = PageAuto;
1.59 cvs 3814: }
1.82 cvs 3815: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3816: {
1.184 vatton 3817: page.typed_data.unit = UNIT_REL;
3818: page.typed_data.value = PageAvoid;
1.59 cvs 3819: }
1.82 cvs 3820: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3821: {
1.184 vatton 3822: /*page.typed_data.unit = UNIT_REL;*/
3823: page.typed_data.value = PageInherit;
1.59 cvs 3824: }
3825: cssRule = SkipWord (cssRule);
3826: /* install the new presentation */
1.184 vatton 3827: /*if (page.typed_data.unit == UNIT_REL &&
3828: page.typed_data.value == PageAvoid && DoApply)
1.117 vatton 3829: {
3830: if (tsch)
1.207 vatton 3831: cssRule = CheckImportantRule (cssRule, ctxt);
3832: TtaSetStylePresentation (PRPageInside, element, tsch, ctxt, page);
1.117 vatton 3833: }*/
1.59 cvs 3834: return (cssRule);
3835: }
1.18 cvs 3836:
3837:
1.60 cvs 3838: /*----------------------------------------------------------------------
1.217 vatton 3839: ParseSVGStrokeWidth: parse a SVG stroke-width property value.
1.60 cvs 3840: ----------------------------------------------------------------------*/
1.79 cvs 3841: static char *ParseSVGStrokeWidth (Element element, PSchema tsch,
1.207 vatton 3842: PresentationContext ctxt, char *cssRule,
1.79 cvs 3843: CSSInfoPtr css, ThotBool isHTML)
1.60 cvs 3844: {
3845: PresentationValue width;
3846:
1.82 cvs 3847: cssRule = SkipBlanksAndComments (cssRule);
1.60 cvs 3848: width.typed_data.value = 0;
1.184 vatton 3849: width.typed_data.unit = UNIT_INVALID;
1.60 cvs 3850: width.typed_data.real = FALSE;
1.110 vatton 3851: if (isdigit (*cssRule) || *cssRule == '.')
1.166 vatton 3852: {
1.60 cvs 3853: cssRule = ParseCSSUnit (cssRule, &width);
1.184 vatton 3854: if (width.typed_data.unit == UNIT_BOX)
3855: width.typed_data.unit = UNIT_PX;
1.166 vatton 3856: }
1.184 vatton 3857: if (width.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 3858: {
3859: /* check if it's an important rule */
3860: if (tsch)
1.207 vatton 3861: cssRule = CheckImportantRule (cssRule, ctxt);
3862: TtaSetStylePresentation (PRLineWeight, element, tsch, ctxt, width);
1.117 vatton 3863: width.typed_data.value = 1;
1.184 vatton 3864: width.typed_data.unit = UNIT_REL;
1.117 vatton 3865: }
1.60 cvs 3866: return (cssRule);
3867: }
3868:
1.217 vatton 3869: /*----------------------------------------------------------------------
3870: ParseCSSPosition: parse a CSS Position attribute string.
3871: ----------------------------------------------------------------------*/
3872: static char *ParseCSSPosition (Element element, PSchema tsch,
3873: PresentationContext ctxt,
3874: char *cssRule, CSSInfoPtr css,
3875: ThotBool isHTML)
3876: {
3877: char *ptr;
3878:
3879: cssRule = SkipBlanksAndComments (cssRule);
3880: ptr = cssRule;
3881: if (!strncasecmp (cssRule, "static", 6))
3882: cssRule = SkipWord (cssRule);
3883: else if (!strncasecmp (cssRule, "relative", 7))
3884: cssRule = SkipWord (cssRule);
3885: else if (!strncasecmp (cssRule, "absolute", 8))
3886: cssRule = SkipWord (cssRule);
3887: else if (!strncasecmp (cssRule, "fixed", 5))
3888: cssRule = SkipWord (cssRule);
3889: else if (!strncasecmp (cssRule, "inherit", 7))
3890: cssRule = SkipWord (cssRule);
3891: else
3892: cssRule = SkipValue ("Invalid Position value", ptr);
3893: return (cssRule);
3894: }
3895:
3896: /*----------------------------------------------------------------------
3897: ParseCSSTop: parse a CSS Top attribute
3898: ----------------------------------------------------------------------*/
3899: static char *ParseCSSTop (Element element, PSchema tsch,
3900: PresentationContext context, char *cssRule,
3901: CSSInfoPtr css, ThotBool isHTML)
3902: {
3903: PresentationValue val;
3904: char *ptr;
3905:
3906: cssRule = SkipBlanksAndComments (cssRule);
3907: ptr = cssRule;
3908: /* first parse the attribute string */
3909: if (!strncasecmp (cssRule, "auto", 4) ||
3910: !strncasecmp (cssRule, "inherit", 7))
3911: {
3912: val.typed_data.unit = VALUE_AUTO;
3913: val.typed_data.value = 0;
3914: val.typed_data.real = FALSE;
3915: cssRule = SkipWord (cssRule);
3916: }
3917: else
3918: cssRule = ParseCSSUnit (cssRule, &val);
3919: if (val.typed_data.value != 0 &&
3920: (val.typed_data.unit == UNIT_INVALID ||
3921: val.typed_data.unit == UNIT_BOX))
3922: {
1.218 vatton 3923: cssRule = SkipValue ("top value", ptr);
1.217 vatton 3924: val.typed_data.unit = UNIT_PX;
3925: }
3926: /***
3927: if (DoApply)
3928: {
3929: if (tsch)
3930: cssRule = CheckImportantRule (cssRule, context);
3931: TtaSetStylePresentation (PR, element, tsch, context, val);
3932: }
3933: ***/
3934: return (cssRule);
3935: }
3936:
3937: /*----------------------------------------------------------------------
3938: ParseCSSRight: parse a CSS Right attribute
3939: ----------------------------------------------------------------------*/
3940: static char *ParseCSSRight (Element element, PSchema tsch,
3941: PresentationContext context, char *cssRule,
3942: CSSInfoPtr css, ThotBool isHTML)
3943: {
3944: PresentationValue val;
3945: char *ptr;
3946:
3947: cssRule = SkipBlanksAndComments (cssRule);
3948: ptr = cssRule;
3949: /* first parse the attribute string */
3950: if (!strncasecmp (cssRule, "auto", 4) ||
3951: !strncasecmp (cssRule, "inherit", 7))
3952: {
3953: val.typed_data.unit = VALUE_AUTO;
3954: val.typed_data.value = 0;
3955: val.typed_data.real = FALSE;
3956: cssRule = SkipWord (cssRule);
3957: }
3958: else
3959: cssRule = ParseCSSUnit (cssRule, &val);
3960: if (val.typed_data.value != 0 &&
3961: (val.typed_data.unit == UNIT_INVALID ||
3962: val.typed_data.unit == UNIT_BOX))
3963: {
1.218 vatton 3964: cssRule = SkipValue ("right value", ptr);
1.217 vatton 3965: val.typed_data.unit = UNIT_PX;
3966: }
3967: /***
3968: if (DoApply)
3969: {
3970: if (tsch)
3971: cssRule = CheckImportantRule (cssRule, context);
3972: TtaSetStylePresentation (PR, element, tsch, context, val);
3973: }
3974: ***/
3975: return (cssRule);
3976: }
3977:
3978: /*----------------------------------------------------------------------
3979: ParseCSSBottom: parse a CSS Bottom attribute
3980: ----------------------------------------------------------------------*/
3981: static char *ParseCSSBottom (Element element, PSchema tsch,
3982: PresentationContext context, char *cssRule,
3983: CSSInfoPtr css, ThotBool isHTML)
3984: {
3985: PresentationValue val;
3986: char *ptr;
3987:
3988: cssRule = SkipBlanksAndComments (cssRule);
3989: ptr = cssRule;
3990: /* first parse the attribute string */
3991: if (!strncasecmp (cssRule, "auto", 4) ||
3992: !strncasecmp (cssRule, "inherit", 7))
3993: {
3994: val.typed_data.unit = VALUE_AUTO;
3995: val.typed_data.value = 0;
3996: val.typed_data.real = FALSE;
3997: cssRule = SkipWord (cssRule);
3998: }
3999: else
4000: cssRule = ParseCSSUnit (cssRule, &val);
4001: if (val.typed_data.value != 0 &&
4002: (val.typed_data.unit == UNIT_INVALID ||
4003: val.typed_data.unit == UNIT_BOX))
4004: {
1.218 vatton 4005: cssRule = SkipValue ("bottom value", ptr);
1.217 vatton 4006: val.typed_data.unit = UNIT_PX;
4007: }
4008: /***
4009: if (DoApply)
4010: {
4011: if (tsch)
4012: cssRule = CheckImportantRule (cssRule, context);
4013: TtaSetStylePresentation (PR, element, tsch, context, val);
4014: }
4015: ***/
4016: return (cssRule);
4017: }
4018:
4019: /*----------------------------------------------------------------------
4020: ParseCSSLeft: parse a CSS Left attribute
4021: ----------------------------------------------------------------------*/
4022: static char *ParseCSSLeft (Element element, PSchema tsch,
4023: PresentationContext context, char *cssRule,
4024: CSSInfoPtr css, ThotBool isHTML)
4025: {
4026: PresentationValue val;
4027: char *ptr;
4028:
4029: cssRule = SkipBlanksAndComments (cssRule);
4030: ptr = cssRule;
4031: /* first parse the attribute string */
4032: if (!strncasecmp (cssRule, "auto", 4) ||
4033: !strncasecmp (cssRule, "inherit", 7))
4034: {
4035: val.typed_data.unit = VALUE_AUTO;
4036: val.typed_data.value = 0;
4037: val.typed_data.real = FALSE;
4038: cssRule = SkipWord (cssRule);
4039: }
4040: else
4041: cssRule = ParseCSSUnit (cssRule, &val);
4042: if (val.typed_data.value != 0 &&
4043: (val.typed_data.unit == UNIT_INVALID ||
4044: val.typed_data.unit == UNIT_BOX))
4045: {
1.218 vatton 4046: cssRule = SkipValue ("left value", ptr);
1.217 vatton 4047: val.typed_data.unit = UNIT_PX;
4048: }
4049: /***
4050: if (DoApply)
4051: {
4052: if (tsch)
4053: cssRule = CheckImportantRule (cssRule, context);
4054: TtaSetStylePresentation (PR, element, tsch, context, val);
4055: }
4056: ***/
4057: return (cssRule);
4058: }
4059:
4060: /*----------------------------------------------------------------------
4061: ParseCSSZIndex: parse a CSS z-index attribute
4062: ----------------------------------------------------------------------*/
4063: static char *ParseCSSZIndex (Element element, PSchema tsch,
4064: PresentationContext context, char *cssRule,
4065: CSSInfoPtr css, ThotBool isHTML)
4066: {
4067: PresentationValue val;
4068: char *ptr;
4069:
4070: cssRule = SkipBlanksAndComments (cssRule);
4071: ptr = cssRule;
4072: /* first parse the attribute string */
4073: if (!strncasecmp (cssRule, "auto", 4) ||
4074: !strncasecmp (cssRule, "inherit", 7))
4075: {
4076: val.typed_data.unit = VALUE_AUTO;
4077: val.typed_data.value = 0;
4078: val.typed_data.real = FALSE;
4079: cssRule = SkipWord (cssRule);
4080: }
4081: else
4082: {
4083: cssRule = ParseCSSUnit (cssRule, &val);
4084: if (val.typed_data.unit != UNIT_BOX)
4085: {
1.218 vatton 4086: cssRule = SkipValue ("z-index value", ptr);
1.217 vatton 4087: val.typed_data.unit = UNIT_BOX;
4088: }
4089: }
4090: /***
4091: if (DoApply)
4092: {
4093: if (tsch)
4094: cssRule = CheckImportantRule (cssRule, context);
4095: TtaSetStylePresentation (PR, element, tsch, context, val);
4096: }
4097: ***/
4098: return (cssRule);
4099: }
4100:
1.18 cvs 4101: /************************************************************************
4102: * *
4103: * FUNCTIONS STYLE DECLARATIONS *
4104: * *
4105: ************************************************************************/
4106: /*
1.59 cvs 4107: * NOTE: Long attribute name MUST be placed before shortened ones !
1.18 cvs 4108: * e.g. "FONT-SIZE" must be placed before "FONT"
4109: */
4110: static CSSProperty CSSProperties[] =
4111: {
1.82 cvs 4112: {"background-color", ParseCSSBackgroundColor},
4113: {"background-image", ParseCSSBackgroundImage},
4114: {"background-repeat", ParseCSSBackgroundRepeat},
4115: {"background-attachment", ParseCSSBackgroundAttachment},
4116: {"background-position", ParseCSSBackgroundPosition},
4117: {"background", ParseCSSBackground},
4118: {"border-top-width", ParseCSSBorderTopWidth},
4119: {"border-right-width", ParseCSSBorderRightWidth},
4120: {"border-bottom-width", ParseCSSBorderBottomWidth},
4121: {"border-left-width", ParseCSSBorderLeftWidth},
4122: {"border-width", ParseCSSBorderWidth},
4123: {"border-top-color", ParseCSSBorderColorTop},
4124: {"border-right-color", ParseCSSBorderColorRight},
4125: {"border-bottom-color", ParseCSSBorderColorBottom},
4126: {"border-left-color", ParseCSSBorderColorLeft},
4127: {"border-color", ParseCSSBorderColor},
4128: {"border-top-style", ParseCSSBorderStyleTop},
4129: {"border-right-style", ParseCSSBorderStyleRight},
4130: {"border-bottom-style", ParseCSSBorderStyleBottom},
4131: {"border-left-style", ParseCSSBorderStyleLeft},
4132: {"border-style", ParseCSSBorderStyle},
4133: {"border-top", ParseCSSBorderTop},
4134: {"border-right", ParseCSSBorderRight},
4135: {"border-bottom", ParseCSSBorderBottom},
4136: {"border-left", ParseCSSBorderLeft},
4137: {"border", ParseCSSBorder},
1.234 vatton 4138: {"bottom", ParseCSSBottom},
1.82 cvs 4139: {"clear", ParseCSSClear},
1.234 vatton 4140: {"color", ParseCSSForeground},
1.184 vatton 4141: {"content", ParseCSSContent},
1.234 vatton 4142: {"direction", ParseCSSDirection},
1.82 cvs 4143: {"display", ParseCSSDisplay},
1.234 vatton 4144: {"float", ParseCSSFloat},
4145: {"font-family", ParseCSSFontFamily},
4146: {"font-style", ParseCSSFontStyle},
4147: {"font-variant", ParseCSSFontVariant},
4148: {"font-weight", ParseCSSFontWeight},
4149: {"font-size-adjust", ParseCSSFontSizeAdjust},
4150: {"font-size", ParseCSSFontSize},
4151: {"font", ParseCSSFont},
4152: {"height", ParseCSSHeight},
1.217 vatton 4153: {"left", ParseCSSLeft},
1.234 vatton 4154: {"letter-spacing", ParseCSSLetterSpacing},
4155: {"line-height", ParseCSSLineHeight},
1.82 cvs 4156: {"list-style-type", ParseCSSListStyleType},
4157: {"list-style-image", ParseCSSListStyleImage},
4158: {"list-style-position", ParseCSSListStylePosition},
4159: {"list-style", ParseCSSListStyle},
1.234 vatton 4160: {"margin-bottom", ParseCSSMarginBottom},
4161: {"margin-top", ParseCSSMarginTop},
4162: {"margin-right", ParseCSSMarginRight},
4163: {"margin-left", ParseCSSMarginLeft},
4164: {"margin", ParseCSSMargin},
4165: {"padding-top", ParseCSSPaddingTop},
4166: {"padding-right", ParseCSSPaddingRight},
4167: {"padding-bottom", ParseCSSPaddingBottom},
4168: {"padding-left", ParseCSSPaddingLeft},
4169: {"padding", ParseCSSPadding},
1.82 cvs 4170: {"page-break-before", ParseCSSPageBreakBefore},
4171: {"page-break-after", ParseCSSPageBreakAfter},
4172: {"page-break-inside", ParseCSSPageBreakInside},
1.234 vatton 4173: {"position", ParseCSSPosition},
4174: {"right", ParseCSSRight},
4175: {"text-align", ParseCSSTextAlign},
1.243 quint 4176: {"text-anchor", ParseCSSTextAnchor},
1.234 vatton 4177: {"text-indent", ParseCSSTextIndent},
4178: {"text-decoration", ParseCSSTextDecoration},
4179: {"text-transform", ParseCSSTextTransform},
4180: {"top", ParseCSSTop},
4181: {"unicode-bidi", ParseCSSUnicodeBidi},
4182: {"vertical-align", ParseCSSVerticalAlign},
4183: {"white-space", ParseCSSWhiteSpace},
4184: {"width", ParseCSSWidth},
4185: {"word-spacing", ParseCSSWordSpacing},
4186: {"z-index", ParseCSSZIndex},
1.60 cvs 4187:
4188: /* SVG extensions */
1.234 vatton 4189: {"fill-opacity", ParseSVGFillOpacity},
4190: {"fill", ParseSVGFill},
4191: {"opacity", ParseSVGOpacity},
1.170 cheyroul 4192: {"stroke-opacity", ParseSVGStrokeOpacity},
1.82 cvs 4193: {"stroke-width", ParseSVGStrokeWidth},
1.234 vatton 4194: {"stroke", ParseSVGStroke}
1.18 cvs 4195: };
1.155 cheyroul 4196:
1.18 cvs 4197: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
4198:
4199: /*----------------------------------------------------------------------
1.59 cvs 4200: ParseCSSRule: parse a CSS Style string
1.18 cvs 4201: we expect the input string describing the style to be of the
1.59 cvs 4202: form: PRORPERTY: DESCRIPTION [ ; PROPERTY: DESCRIPTION ] *
1.18 cvs 4203: but tolerate incorrect or incomplete input
4204: ----------------------------------------------------------------------*/
1.79 cvs 4205: static void ParseCSSRule (Element element, PSchema tsch,
1.207 vatton 4206: PresentationContext ctxt, char *cssRule,
1.79 cvs 4207: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 4208: {
1.34 cvs 4209: DisplayMode dispMode;
1.250 vatton 4210: char *p = NULL, *next;
1.214 quint 4211: char *valueStart;
1.18 cvs 4212: int lg;
1.34 cvs 4213: unsigned int i;
1.76 cvs 4214: ThotBool found;
1.18 cvs 4215:
1.34 cvs 4216: /* avoid too many redisplay */
1.207 vatton 4217: dispMode = TtaGetDisplayMode (ctxt->doc);
1.34 cvs 4218: if (dispMode == DisplayImmediately)
1.207 vatton 4219: TtaSetDisplayMode (ctxt->doc, DeferredDisplay);
1.34 cvs 4220:
1.82 cvs 4221: while (*cssRule != EOS)
1.18 cvs 4222: {
1.82 cvs 4223: cssRule = SkipBlanksAndComments (cssRule);
1.153 vatton 4224: if (*cssRule < 0x41 || *cssRule > 0x7A ||
1.133 vatton 4225: (*cssRule > 0x5A && *cssRule < 0x60))
1.153 vatton 4226: cssRule++;
1.194 vatton 4227: else if (*cssRule != EOS)
1.89 cvs 4228: {
1.153 vatton 4229: found = FALSE;
4230: /* look for the type of property */
4231: for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
1.18 cvs 4232: {
1.153 vatton 4233: lg = strlen (CSSProperties[i].name);
4234: if (!strncasecmp (cssRule, CSSProperties[i].name, lg))
4235: {
4236: p = cssRule + lg;
4237: found = TRUE;
4238: i--;
4239: }
1.18 cvs 4240: }
1.153 vatton 4241: if (i == NB_CSSSTYLEATTRIBUTE)
1.234 vatton 4242: cssRule = SkipProperty (cssRule, TRUE);
1.153 vatton 4243: else
1.18 cvs 4244: {
1.153 vatton 4245: /* update index and skip the ":" indicator if present */
1.86 cvs 4246: p = SkipBlanksAndComments (p);
1.153 vatton 4247: if (*p == ':')
1.61 cvs 4248: {
1.153 vatton 4249: p++;
4250: p = SkipBlanksAndComments (p);
4251: /* try to parse the value associated with this property */
4252: if (CSSProperties[i].parsing_function != NULL)
4253: {
1.214 quint 4254: valueStart = p;
4255: p = CSSProperties[i].parsing_function (element, tsch,
4256: ctxt, p, css, isHTML);
4257: if (!element && isHTML)
4258: {
4259: if (ctxt->type == HTML_EL_Input)
4260: /* it's a generic rule for the HTML element input.
4261: Generate a Thot Pres rule for each kind of
4262: input element */
4263: {
4264: ctxt->type = HTML_EL_Text_Input;
4265: p = CSSProperties[i].parsing_function (element,
4266: tsch, ctxt, valueStart, css, isHTML);
4267: ctxt->type = HTML_EL_Password_Input;
4268: p = CSSProperties[i].parsing_function (element,
4269: tsch, ctxt, valueStart, css, isHTML);
4270: ctxt->type = HTML_EL_File_Input;
4271: p = CSSProperties[i].parsing_function (element,
4272: tsch, ctxt, valueStart, css, isHTML);
4273: ctxt->type = HTML_EL_Checkbox_Input;
4274: p = CSSProperties[i].parsing_function (element,
4275: tsch, ctxt, valueStart, css, isHTML);
4276: ctxt->type = HTML_EL_Radio_Input;
4277: p = CSSProperties[i].parsing_function (element,
4278: tsch, ctxt, valueStart, css, isHTML);
4279: ctxt->type = HTML_EL_Submit_Input;
4280: p = CSSProperties[i].parsing_function (element,
4281: tsch, ctxt, valueStart, css, isHTML);
4282: ctxt->type = HTML_EL_Reset_Input;
4283: p = CSSProperties[i].parsing_function (element,
4284: tsch, ctxt, valueStart, css, isHTML);
4285: ctxt->type = HTML_EL_Button_Input;
4286: p = CSSProperties[i].parsing_function (element,
4287: tsch, ctxt, valueStart, css, isHTML);
4288: ctxt->type = HTML_EL_Input;
4289: }
4290: else if (ctxt->type == HTML_EL_ruby)
4291: /* it's a generic rule for the HTML element ruby.
4292: Generate a Thot Pres rule for each kind of
4293: ruby element. */
4294: {
4295: ctxt->type = HTML_EL_simple_ruby;
4296: p = CSSProperties[i].parsing_function (element,
4297: tsch, ctxt, valueStart, css, isHTML);
4298: ctxt->type = HTML_EL_complex_ruby;
4299: p = CSSProperties[i].parsing_function (element,
4300: tsch, ctxt, valueStart, css, isHTML);
4301: ctxt->type = HTML_EL_ruby;
4302: }
4303: }
1.153 vatton 4304: /* update index and skip the ";" separator if present */
1.250 vatton 4305: next = SkipBlanksAndComments (p);
4306: if (*next != EOS && *next != ';')
1.251 vatton 4307: CSSParseError ("Missing closing ';'", cssRule, p);
1.250 vatton 4308: cssRule = next;
1.153 vatton 4309: }
1.61 cvs 4310: }
1.153 vatton 4311: else
1.234 vatton 4312: cssRule = SkipProperty (cssRule, TRUE);
1.18 cvs 4313: }
4314: }
4315: /* next property */
1.82 cvs 4316: cssRule = SkipBlanksAndComments (cssRule);
1.89 cvs 4317: if (*cssRule == '}')
4318: {
4319: cssRule++;
1.168 vatton 4320: CSSPrintError ("Invalid character", "}");
1.89 cvs 4321: cssRule = SkipBlanksAndComments (cssRule);
4322: }
1.155 cheyroul 4323: if (*cssRule == ',' ||
4324: *cssRule == ';')
1.18 cvs 4325: {
4326: cssRule++;
1.82 cvs 4327: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 4328: }
4329: }
1.34 cvs 4330:
4331: /* restore the display mode */
4332: if (dispMode == DisplayImmediately)
1.207 vatton 4333: TtaSetDisplayMode (ctxt->doc, dispMode);
1.18 cvs 4334: }
1.1 cvs 4335:
1.111 cvs 4336: /*----------------------------------------------------------------------
1.59 cvs 4337: ParseHTMLSpecificStyle: parse and apply a CSS Style string.
1.18 cvs 4338: This function must be called when a specific style is applied to an
4339: element.
1.114 quint 4340: The parameter specificity is the specificity of the style, 0 if it is
4341: not really a CSS rule.
1.1 cvs 4342: ----------------------------------------------------------------------*/
1.79 cvs 4343: void ParseHTMLSpecificStyle (Element el, char *cssRule, Document doc,
1.114 quint 4344: int specificity, ThotBool destroy)
1.1 cvs 4345: {
1.257 vatton 4346: DisplayMode dispMode;
1.207 vatton 4347: PresentationContext ctxt;
4348: ElementType elType;
4349: ThotBool isHTML;
1.1 cvs 4350:
1.207 vatton 4351: /* A rule applying to BODY is really meant to address HTML */
4352: elType = TtaGetElementType (el);
1.89 cvs 4353:
1.207 vatton 4354: /* store the current line for eventually reported errors */
4355: LineNumber = TtaGetElementLineNumber (el);
4356: if (destroy)
4357: /* no reported errors */
4358: ParsedDoc = 0;
4359: else if (ParsedDoc != doc)
4360: {
4361: /* update the context for reported errors */
4362: ParsedDoc = doc;
4363: DocURL = DocumentURLs[doc];
4364: }
4365: isHTML = (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML") == 0);
4366: /* create the context of the Specific presentation driver */
4367: ctxt = TtaGetSpecificStyleContext (doc);
4368: if (ctxt == NULL)
4369: return;
4370: ctxt->type = elType.ElTypeNum;
4371: ctxt->cssSpecificity = specificity;
1.236 quint 4372: ctxt->cssLine = LineNumber;
1.207 vatton 4373: ctxt->destroy = destroy;
4374: /* first use of the context */
4375: ctxt->uses = 1;
1.257 vatton 4376: /* save the current display mode */
4377: dispMode = TtaGetDisplayMode (doc);
1.207 vatton 4378: /* Call the parser */
4379: ParseCSSRule (el, NULL, (PresentationContext) ctxt, cssRule, NULL, isHTML);
1.257 vatton 4380: /* restore the display mode if necessary */
4381: TtaSetDisplayMode (doc, dispMode);
1.207 vatton 4382: /* check if the context can be freed */
4383: ctxt->uses -= 1;
4384: if (ctxt->uses == 0)
4385: /* no image loading */
4386: TtaFreeMemory(ctxt);
1.1 cvs 4387: }
4388:
1.68 cvs 4389:
1.1 cvs 4390: /*----------------------------------------------------------------------
1.207 vatton 4391: ParseGenericSelector: Create a generic context for a given selector
4392: string.
4393: If the selector is made of multiple comma, it parses them one at a time
4394: and return the end of the selector string to be handled or NULL.
1.231 vatton 4395: The parameter ctxt gives the current style context which will be passed
4396: to Thotlib.
4397: The parameter css points to the current CSS context.
4398: The parameter link points to the link element.
4399: The parameter url gives the URL of the parsed style sheet.
1.1 cvs 4400: ----------------------------------------------------------------------*/
1.207 vatton 4401: static char *ParseGenericSelector (char *selector, char *cssRule,
1.79 cvs 4402: GenericContext ctxt, Document doc,
1.231 vatton 4403: CSSInfoPtr css, Element link, char *url)
1.79 cvs 4404: {
4405: ElementType elType;
4406: PSchema tsch;
1.119 vatton 4407: AttributeType attrType;
1.240 quint 4408: char *deb, *cur, *sel, *next, c;
1.118 vatton 4409: char *schemaName, *mappedName;
1.79 cvs 4410: char *names[MAX_ANCESTORS];
4411: char *ids[MAX_ANCESTORS];
4412: char *classes[MAX_ANCESTORS];
4413: char *pseudoclasses[MAX_ANCESTORS];
4414: char *attrs[MAX_ANCESTORS];
4415: char *attrvals[MAX_ANCESTORS];
1.133 vatton 4416: AttrMatch attrmatch[MAX_ANCESTORS];
1.255 vatton 4417: ElemRel rel[MAX_ANCESTORS];
1.91 cvs 4418: int i, j, k, max;
1.256 vatton 4419: int att, kind;
1.118 vatton 4420: int specificity, xmlType;
1.217 vatton 4421: int skippedNL;
1.79 cvs 4422: ThotBool isHTML;
1.183 vatton 4423: ThotBool level, quoted;
1.1 cvs 4424:
1.207 vatton 4425: sel = ctxt->sel;
1.82 cvs 4426: sel[0] = EOS;
1.117 vatton 4427: specificity = 0;
1.1 cvs 4428: for (i = 0; i < MAX_ANCESTORS; i++)
4429: {
1.25 cvs 4430: names[i] = NULL;
4431: ids[i] = NULL;
4432: classes[i] = NULL;
4433: pseudoclasses[i] = NULL;
4434: attrs[i] = NULL;
4435: attrvals[i] = NULL;
1.133 vatton 4436: attrmatch[i] = Txtmatch;
1.255 vatton 4437: rel[i] = RelAncestor;
1.25 cvs 4438: ctxt->name[i] = 0;
4439: ctxt->names_nb[i] = 0;
4440: ctxt->attrType[i] = 0;
1.129 vatton 4441: ctxt->attrLevel[i] = 0;
1.25 cvs 4442: ctxt->attrText[i] = NULL;
1.178 quint 4443: ctxt->attrMatch[i] = Txtmatch;
1.1 cvs 4444: }
1.25 cvs 4445: ctxt->box = 0;
4446: ctxt->type = 0;
1.114 quint 4447: /* the specificity of the rule depends on the selector */
4448: ctxt->cssSpecificity = 0;
1.231 vatton 4449: /* localisation of the CSS rule */
4450: ctxt->cssLine = LineNumber + NewLineSkipped;
4451: ctxt->cssURL = url;
1.240 quint 4452:
1.82 cvs 4453: selector = SkipBlanksAndComments (selector);
1.27 cvs 4454: cur = &sel[0];
1.25 cvs 4455: max = 0; /* number of loops */
1.1 cvs 4456: while (1)
4457: {
1.85 cvs 4458: /* point to the following word in sel[] */
1.27 cvs 4459: deb = cur;
1.25 cvs 4460: /* copy an item of the selector into sel[] */
1.1 cvs 4461: /* put one word in the sel buffer */
1.82 cvs 4462: while (*selector != EOS && *selector != ',' &&
4463: *selector != '.' && *selector != ':' &&
1.118 vatton 4464: *selector != '#' && *selector != '[' &&
1.250 vatton 4465: *selector != '>' && *selector != '+' &&
1.118 vatton 4466: !TtaIsBlank (selector))
1.50 cvs 4467: *cur++ = *selector++;
1.82 cvs 4468: *cur++ = EOS; /* close the first string in sel[] */
4469: if (deb[0] != EOS)
1.117 vatton 4470: {
1.240 quint 4471: if (deb[0] <= 64 && deb[0] != '*')
4472: {
4473: CSSPrintError ("Invalid element", deb);
4474: return NULL;
4475: }
1.149 vatton 4476: else
1.240 quint 4477: {
4478: names[0] = deb;
4479: if (!strcmp (names[0], "html"))
4480: /* give a greater priority to the backgoud color of html */
4481: specificity += 3;
4482: else
4483: /* selector "*" has specificity zero */
4484: if (strcmp (names[0], "*"))
4485: specificity += 1;
4486: }
1.117 vatton 4487: }
1.25 cvs 4488: else
1.27 cvs 4489: names[0] = NULL;
1.226 quint 4490:
1.27 cvs 4491: classes[0] = NULL;
4492: pseudoclasses[0] = NULL;
4493: ids[0] = NULL;
4494: attrs[0] = NULL;
4495: attrvals[0] = NULL;
1.25 cvs 4496:
1.27 cvs 4497: /* now names[0] points to the beginning of the parsed item
1.25 cvs 4498: and cur to the next chain to be parsed */
1.129 vatton 4499: while (*selector == '.' || *selector == ':' ||
1.234 vatton 4500: *selector == '#' || *selector == '[')
1.129 vatton 4501: {
1.85 cvs 4502: /* point to the following word in sel[] */
4503: deb = cur;
1.129 vatton 4504: if (*selector == '.')
4505: {
4506: selector++;
4507: while (*selector != EOS && *selector != ',' &&
4508: *selector != '.' && *selector != ':' &&
4509: !TtaIsBlank (selector))
1.240 quint 4510: {
4511: if (*selector == '\\')
4512: {
4513: selector++;
4514: if (*selector != EOS)
4515: *cur++ = *selector++;
4516: }
4517: else
4518: *cur++ = *selector++;
4519: }
1.129 vatton 4520: /* close the word */
4521: *cur++ = EOS;
4522: /* point to the class in sel[] if it's valid name */
4523: if (deb[0] <= 64)
4524: {
1.168 vatton 4525: CSSPrintError ("Invalid class", deb);
1.116 vatton 4526: DoApply = FALSE;
1.129 vatton 4527: }
4528: else
4529: {
4530: classes[0] = deb;
1.178 quint 4531: /* a "class" attribute on an element may contain several
4532: words, one for each class it matches */
4533: attrmatch[0] = Txtword;
1.117 vatton 4534: specificity += 10;
1.227 quint 4535: if (names[0] && !strcmp (names[0], "*"))
1.226 quint 4536: names[0] = NULL;
1.129 vatton 4537: }
4538: }
4539: else if (*selector == ':')
4540: {
4541: selector++;
4542: while (*selector != EOS && *selector != ',' &&
4543: *selector != '.' && *selector != ':' &&
4544: !TtaIsBlank (selector))
4545: *cur++ = *selector++;
4546: /* close the word */
4547: *cur++ = EOS;
4548: /* point to the pseudoclass in sel[] if it's valid name */
4549: if (deb[0] <= 64)
4550: {
1.168 vatton 4551: CSSPrintError ("Invalid pseudoclass", deb);
1.129 vatton 4552: DoApply = FALSE;
4553: }
4554: else
4555: {
4556: if (!strcmp (deb, "first-letter") ||
4557: !strcmp (deb, "first-line") ||
4558: !strcmp (deb, "before") ||
1.266 ! quint 4559: !strcmp (deb, "after") ||
! 4560: !strcmp (deb, "hover") ||
! 4561: !strcmp (deb, "focus"))
1.129 vatton 4562: /* not supported */
1.116 vatton 4563: DoApply = FALSE;
1.129 vatton 4564: else
4565: specificity += 10;
1.238 quint 4566: if (!strncmp (deb, "lang", 4))
4567: /* it's the lang pseudo-class */
4568: {
4569: if (deb[4] != '(' || deb[strlen(deb)-1] != ')')
4570: /* at least one paranthesis is missing. Error */
4571: {
4572: CSSPrintError ("Invalid :lang pseudoclass", deb);
4573: DoApply = FALSE;
4574: }
4575: else
4576: /* simulate selector [lang|="xxx"] if there no
4577: attribute yet in the selector */
4578: if (!attrs[0])
4579: {
4580: deb[strlen(deb)-1] = EOS;
4581: deb[4] = EOS;
4582: attrmatch[0] = Txtsubstring;
4583: attrs[0] = deb;
4584: attrvals[0] = &deb[5];
4585: }
4586: }
4587: else
1.263 vatton 4588: {
4589: pseudoclasses[0] = deb;
4590: /* a "pseudo-class" attribute must match */
4591: attrmatch[0] = Txtmatch;
4592: }
1.227 quint 4593: if (names[0] && !strcmp (names[0], "*"))
1.226 quint 4594: names[0] = NULL;
1.129 vatton 4595: }
4596: }
4597: else if (*selector == '#')
4598: {
4599: selector++;
4600: while (*selector != EOS && *selector != ',' &&
4601: *selector != '.' && *selector != ':' &&
1.237 quint 4602: *selector != '#' &&
1.129 vatton 4603: !TtaIsBlank (selector))
4604: *cur++ = *selector++;
4605: /* close the word */
4606: *cur++ = EOS;
4607: /* point to the attribute in sel[] if it's valid name */
4608: if (deb[0] <= 64)
4609: {
1.168 vatton 4610: CSSPrintError ("Invalid id", deb);
1.129 vatton 4611: DoApply = FALSE;
4612: }
4613: else
4614: {
1.237 quint 4615: if (ids[0] && strcmp(ids[0], deb))
4616: {
4617: CSSPrintError ("Too many ids", deb);
4618: DoApply = FALSE;
4619: }
4620: else
4621: {
4622: ids[0] = deb;
4623: specificity += 100;
4624: if (names[0] && !strcmp (names[0], "*"))
4625: names[0] = NULL;
1.261 vatton 4626: /* a "id" attribute must match */
4627: attrmatch[0] = Txtmatch;
1.237 quint 4628: }
1.129 vatton 4629: }
4630: }
4631: else if (*selector == '[')
4632: {
1.118 vatton 4633: selector++;
1.129 vatton 4634: while (*selector != EOS && *selector != ']' &&
1.131 vatton 4635: *selector != '=' && *selector != '~' &&
1.133 vatton 4636: *selector != '|' && *selector != '^' &&
4637: *selector != '!')
1.129 vatton 4638: *cur++ = *selector++;
1.133 vatton 4639: /* check matching */
4640: if (*selector == '~')
4641: {
4642: attrmatch[0] = Txtword;
4643: selector++;
4644: }
4645: else if (*selector == '|')
4646: {
4647: attrmatch[0] = Txtsubstring;
4648: selector++;
4649: }
4650: else
4651: attrmatch[0] = Txtmatch;
1.129 vatton 4652: /* close the word */
4653: *cur++ = EOS;
4654: /* point to the attribute in sel[] if it's valid name */
4655: if (deb[0] <= 64)
4656: {
1.168 vatton 4657: CSSPrintError ("Invalid attribute", deb);
1.129 vatton 4658: DoApply = FALSE;
4659: }
4660: else
4661: {
4662: attrs[0] = deb;
4663: specificity += 10;
4664: }
4665: if (*selector == '=')
4666: {
4667: /* look for a value "xxxx" */
4668: selector++;
4669: if (*selector != '"')
1.183 vatton 4670: quoted = FALSE;
1.129 vatton 4671: else
4672: {
1.183 vatton 4673: quoted = TRUE;
1.129 vatton 4674: /* we are now parsing the attribute value */
4675: selector++;
1.183 vatton 4676: }
4677: deb = cur;
4678: while ((quoted &&
4679: (*selector != '"' ||
4680: (*selector == '"' && selector[-1] == '\\'))) ||
4681: (!quoted && *selector != ']'))
4682: {
4683: if (*selector == EOS)
1.129 vatton 4684: {
1.183 vatton 4685: CSSPrintError ("Invalid attribute value", deb);
4686: DoApply = FALSE;
1.129 vatton 4687: }
1.183 vatton 4688: else
1.129 vatton 4689: {
1.228 quint 4690: if (attrmatch[0] == Txtword && TtaIsBlank (selector))
4691: {
4692: CSSPrintError ("No space allowed here: ", selector);
4693: DoApply = FALSE;
4694: }
1.238 quint 4695: *cur++ = *selector;
1.129 vatton 4696: }
1.228 quint 4697: selector++;
1.129 vatton 4698: }
1.183 vatton 4699: /* there is a value */
1.204 quint 4700: if (quoted && *selector == '"')
1.183 vatton 4701: {
4702: selector++;
4703: quoted = FALSE;
4704: }
4705: if (*selector != ']')
4706: {
4707: CSSPrintError ("Invalid attribute value", deb);
4708: DoApply = FALSE;
4709: }
4710: else
4711: {
4712: *cur++ = EOS;
4713: attrvals[0] = deb;
4714: selector++;
4715: }
1.129 vatton 4716: }
4717: /* end of the attribute */
1.183 vatton 4718: else if (*selector != ']')
1.129 vatton 4719: {
1.133 vatton 4720: selector[1] = EOS;
1.183 vatton 4721: CSSPrintError ("Invalid attribute", selector);
1.133 vatton 4722: selector += 2;
1.129 vatton 4723: DoApply = FALSE;
4724: }
4725: else
1.226 quint 4726: {
1.129 vatton 4727: selector++;
1.227 quint 4728: if (names[0] && !strcmp (names[0], "*"))
1.226 quint 4729: names[0] = NULL;
4730: }
1.130 vatton 4731: }
4732: else
4733: {
4734: /* not supported selector */
4735: while (*selector != EOS && *selector != ',' &&
4736: *selector != '.' && *selector != ':' &&
4737: !TtaIsBlank (selector))
4738: *cur++ = *selector++;
4739: /* close the word */
4740: *cur++ = EOS;
1.205 quint 4741: CSSPrintError ("Selector not supported:", deb);
1.130 vatton 4742: DoApply = FALSE;
1.129 vatton 4743: }
4744: }
1.1 cvs 4745:
1.82 cvs 4746: selector = SkipBlanksAndComments (selector);
1.25 cvs 4747: /* is it a multi-level selector? */
1.82 cvs 4748: if (*selector == EOS)
1.1 cvs 4749: /* end of the selector */
4750: break;
1.82 cvs 4751: else if (*selector == ',')
1.1 cvs 4752: {
4753: /* end of the current selector */
4754: selector++;
1.240 quint 4755: next = SkipBlanksAndComments (selector);
4756: if (*next == EOS)
4757: /* nothing after the comma. Invalid selector */
4758: {
4759: CSSPrintError ("Syntax error:", selector);
4760: return NULL;
4761: }
1.1 cvs 4762: break;
4763: }
1.25 cvs 4764: else
4765: {
1.143 vatton 4766: if (*selector == '>')
4767: {
4768: /* handle immediat parent as a simple parent */
4769: selector++;
4770: selector = SkipBlanksAndComments (selector);
1.255 vatton 4771: rel[0] = RelImmediat;
1.250 vatton 4772: }
4773: else if (*selector == '+')
4774: {
4775: /* handle immediat parent as a simple parent */
4776: selector++;
4777: selector = SkipBlanksAndComments (selector);
1.255 vatton 4778: rel[0] = RelPrevious;
1.143 vatton 4779: }
1.25 cvs 4780: /* shifts the list to make room for the new name */
4781: max++; /* a new level in ancestor tables */
4782: if (max == MAX_ANCESTORS)
4783: /* abort the CSS parsing */
4784: return (selector);
4785: for (i = max; i > 0; i--)
4786: {
4787: names[i] = names[i - 1];
4788: ids[i] = ids[i - 1];
4789: classes[i] = classes[i - 1];
1.133 vatton 4790: pseudoclasses[i] = pseudoclasses[i - 1];
1.25 cvs 4791: attrs[i] = attrs[i - 1];
4792: attrvals[i] = attrvals[i - 1];
1.133 vatton 4793: attrmatch[i] = attrmatch[i - 1];
1.250 vatton 4794: rel[i] = rel[i - 1];
1.25 cvs 4795: }
4796: }
1.1 cvs 4797: }
4798:
4799: /* Now set up the context block */
1.25 cvs 4800: i = 0;
4801: k = 0;
4802: j = 0;
1.91 cvs 4803: /* default schema name */
1.119 vatton 4804: ctxt->schema = NULL;
1.122 vatton 4805: elType.ElSSchema = NULL;
4806: schemaName = TtaGetSSchemaName(TtaGetDocumentSSchema (doc));
1.119 vatton 4807: if (!strcmp (schemaName, "HTML"))
4808: xmlType = XHTML_TYPE;
4809: else if (!strcmp (schemaName, "MathML"))
4810: xmlType = MATH_TYPE;
4811: else if (!strcmp (schemaName, "SVG"))
4812: xmlType = SVG_TYPE;
4813: else if (!strcmp (schemaName, "XLink"))
4814: xmlType = XLINK_TYPE;
4815: else if (!strcmp (schemaName, "Annot"))
4816: xmlType = ANNOT_TYPE;
4817: else
4818: xmlType = XML_TYPE;
1.256 vatton 4819: while (i <= max && j < MAX_ANCESTORS)
1.25 cvs 4820: {
4821: if (names[i])
4822: {
1.118 vatton 4823: /* get the element type of this name in the current document */
1.220 quint 4824: if (xmlType == XML_TYPE)
1.223 quint 4825: /* it's a generic XML document. Check the main document schema */
1.220 quint 4826: {
4827: elType.ElSSchema = TtaGetDocumentSSchema (doc);
4828: TtaGetXmlElementType (names[i], &elType, &mappedName, doc);
4829: if (!elType.ElTypeNum)
1.226 quint 4830: {
4831: if (!strcmp (names[i], "*"))
4832: elType.ElTypeNum = HTML_EL_ANY_TYPE;
4833: else
4834: elType.ElSSchema = NULL;
4835: }
1.220 quint 4836: }
4837: else
1.226 quint 4838: {
4839: if (!strcmp (names[i], "*"))
4840: {
4841: elType.ElSSchema = TtaGetDocumentSSchema (doc);
4842: elType.ElTypeNum = HTML_EL_ANY_TYPE;
4843: }
4844: else
4845: MapXMLElementType (xmlType, names[i], &elType, &mappedName, &c,
4846: &level, doc);
4847: }
1.25 cvs 4848: if (i == 0)
4849: {
1.106 cvs 4850: if (elType.ElSSchema == NULL)
4851: {
1.119 vatton 4852: /* Search in the list of loaded schemas */
1.106 cvs 4853: TtaGetXmlElementType (names[i], &elType, NULL, doc);
1.119 vatton 4854: if (elType.ElSSchema)
4855: {
1.154 vatton 4856: /* the element type concerns an imported nature */
1.119 vatton 4857: schemaName = TtaGetSSchemaName(elType.ElSSchema);
4858: if (!strcmp (schemaName, "HTML"))
4859: xmlType = XHTML_TYPE;
4860: else if (!strcmp (schemaName, "MathML"))
4861: xmlType = MATH_TYPE;
4862: else if (!strcmp (schemaName, "SVG"))
4863: xmlType = SVG_TYPE;
4864: else if (!strcmp (schemaName, "XLink"))
4865: xmlType = XLINK_TYPE;
4866: else if (!strcmp (schemaName, "Annot"))
4867: xmlType = ANNOT_TYPE;
4868: else
4869: xmlType = XML_TYPE;
4870: }
1.118 vatton 4871: #ifdef XML_GENERIC
1.119 vatton 4872: else if (xmlType == XML_TYPE)
1.106 cvs 4873: {
4874: /* Creation of a new element type in the main schema */
4875: elType.ElSSchema = TtaGetDocumentSSchema (doc);
1.118 vatton 4876: TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
1.106 cvs 4877: }
1.118 vatton 4878: #endif /* XML_GENERIC */
1.122 vatton 4879: else
4880: {
4881: if (xmlType != XHTML_TYPE)
4882: {
4883: MapXMLElementType (XHTML_TYPE, names[i], &elType,
4884: &mappedName, &c, &level, doc);
4885: if (elType.ElSSchema)
1.123 vatton 4886: elType.ElSSchema = GetXHTMLSSchema (doc);
1.122 vatton 4887: }
4888: if (elType.ElSSchema == NULL && xmlType != MATH_TYPE)
4889: {
4890: MapXMLElementType (MATH_TYPE, names[i], &elType,
4891: &mappedName, &c, &level, doc);
4892: if (elType.ElSSchema)
1.123 vatton 4893: elType.ElSSchema = GetMathMLSSchema (doc);
1.122 vatton 4894: }
4895: if (elType.ElSSchema == NULL && xmlType != SVG_TYPE)
4896: {
4897: MapXMLElementType (SVG_TYPE, names[i], &elType,
4898: &mappedName, &c, &level, doc);
4899: if (elType.ElSSchema)
1.123 vatton 4900: elType.ElSSchema = GetSVGSSchema (doc);
1.122 vatton 4901: }
4902: }
1.118 vatton 4903: }
1.119 vatton 4904:
1.118 vatton 4905: if (elType.ElSSchema == NULL)
4906: /* cannot apply these CSS rules */
4907: DoApply = FALSE;
4908: else
4909: {
4910: /* Store the element type */
4911: ctxt->type = elType.ElTypeNum;
4912: ctxt->name[0] = elType.ElTypeNum;
4913: ctxt->names_nb[0] = 0;
1.255 vatton 4914: ctxt->rel[0] = RelAncestor;
1.118 vatton 4915: ctxt->schema = elType.ElSSchema;
1.106 cvs 4916: }
1.25 cvs 4917: }
4918: else if (elType.ElTypeNum != 0)
4919: {
4920: /* look at the current context to see if the type is already
4921: stored */
1.121 vatton 4922: j = 1;
1.250 vatton 4923: while (j < k &&
1.255 vatton 4924: (ctxt->name[j] != elType.ElTypeNum ||
4925: ctxt->rel[j] != RelAncestor))
1.25 cvs 4926: j++;
4927: if (j == k)
4928: {
4929: ctxt->name[j] = elType.ElTypeNum;
4930: if (j != 0)
1.255 vatton 4931: {
4932: ctxt->names_nb[j] = 1;
4933: ctxt->rel[j] = rel[i];
4934: }
1.25 cvs 4935: }
4936: else
4937: /* increment the number of ancestor levels */
4938: ctxt->names_nb[j]++;
4939: }
1.154 vatton 4940: #ifdef XML_GENERIC
4941: else if (xmlType == XML_TYPE)
4942: {
1.158 vatton 4943: TtaGetXmlElementType (names[i], &elType, NULL, doc);
4944: if (elType.ElTypeNum == 0)
4945: {
4946: /* Creation of a new element type in the main schema */
4947: elType.ElSSchema = TtaGetDocumentSSchema (doc);
4948: TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
4949: }
1.154 vatton 4950: if (elType.ElTypeNum != 0)
4951: {
4952: /* look at the current context to see if the type is already
4953: stored */
4954: j = 1;
1.250 vatton 4955: while (j < k &&
1.255 vatton 4956: (ctxt->name[j] != elType.ElTypeNum ||
4957: ctxt->rel[j] != RelAncestor))
1.154 vatton 4958: j++;
4959: if (j == k)
4960: {
4961: ctxt->name[j] = elType.ElTypeNum;
4962: if (j != 0)
1.250 vatton 4963: {
4964: ctxt->names_nb[j] = 1;
4965: ctxt->rel[j] = rel[i];
4966: }
4967: else
1.255 vatton 4968: ctxt->rel[j] = RelAncestor;
1.154 vatton 4969: }
4970: else
4971: /* increment the number of ancestor levels */
4972: ctxt->names_nb[j]++;
4973: }
4974: }
4975: #endif /* XML_GENERIC */
1.25 cvs 4976: else
1.117 vatton 4977: j = k;
1.25 cvs 4978: }
1.117 vatton 4979: else
4980: j = k;
1.1 cvs 4981:
1.25 cvs 4982: /* store attributes information */
4983: if (classes[i])
4984: {
4985: ctxt->attrText[j] = classes[i];
1.119 vatton 4986: if (xmlType == SVG_TYPE)
1.100 vatton 4987: ctxt->attrType[j] = SVG_ATTR_class;
1.119 vatton 4988: else if (xmlType == MATH_TYPE)
1.91 cvs 4989: ctxt->attrType[j] = MathML_ATTR_class;
1.119 vatton 4990: else if (xmlType == XHTML_TYPE)
1.107 cvs 4991: ctxt->attrType[j] = HTML_ATTR_Class;
4992: else
1.119 vatton 4993: #ifdef XML_GENERIC
1.107 cvs 4994: ctxt->attrType[j] = XML_ATTR_class;
4995: #else /* XML_GENERIC */
1.91 cvs 4996: ctxt->attrType[j] = HTML_ATTR_Class;
1.107 cvs 4997: #endif /* XML_GENERIC */
1.157 vatton 4998: ctxt->attrMatch[j] = attrmatch[i];
1.79 cvs 4999: /* add a new entry */
1.129 vatton 5000: /* update attrLevel */
5001: ctxt->attrLevel[j] = i;
5002: j++;
1.25 cvs 5003: }
1.79 cvs 5004: if (pseudoclasses[i])
1.25 cvs 5005: {
5006: ctxt->attrText[j] = pseudoclasses[i];
1.119 vatton 5007: if (xmlType == SVG_TYPE)
1.100 vatton 5008: ctxt->attrType[j] = SVG_ATTR_PseudoClass;
1.119 vatton 5009: else if (xmlType == MATH_TYPE)
1.91 cvs 5010: ctxt->attrType[j] = MathML_ATTR_PseudoClass;
1.119 vatton 5011: else if (xmlType == XHTML_TYPE)
1.107 cvs 5012: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
5013: else
1.119 vatton 5014: #ifdef XML_GENERIC
1.107 cvs 5015: ctxt->attrType[j] = XML_ATTR_PseudoClass;
5016: #else /* XML_GENERIC */
1.91 cvs 5017: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
1.107 cvs 5018: #endif /* XML_GENERIC */
1.157 vatton 5019: ctxt->attrMatch[j] = attrmatch[i];
1.79 cvs 5020: /* add a new entry */
1.129 vatton 5021: /* update attrLevel */
5022: ctxt->attrLevel[j] = i;
5023: j++;
1.25 cvs 5024: }
1.79 cvs 5025: if (ids[i])
1.25 cvs 5026: {
5027: ctxt->attrText[j] = ids[i];
1.119 vatton 5028: if (xmlType == SVG_TYPE)
1.100 vatton 5029: ctxt->attrType[j] = SVG_ATTR_id;
1.119 vatton 5030: else if (xmlType == MATH_TYPE)
1.91 cvs 5031: ctxt->attrType[j] = MathML_ATTR_id;
1.119 vatton 5032: else if (xmlType == XHTML_TYPE)
1.107 cvs 5033: ctxt->attrType[j] = HTML_ATTR_ID;
5034: else
1.119 vatton 5035: #ifdef XML_GENERIC
1.107 cvs 5036: ctxt->attrType[j] = XML_ATTR_id;
5037: #else /* XML_GENERIC */
1.91 cvs 5038: ctxt->attrType[j] = HTML_ATTR_ID;
1.107 cvs 5039: #endif /* XML_GENERIC */
1.157 vatton 5040: ctxt->attrMatch[j] = attrmatch[i];
1.80 cvs 5041: /* add a new entry */
1.129 vatton 5042: /* update attrLevel */
5043: ctxt->attrLevel[j] = i;
5044: j++;
1.25 cvs 5045: }
1.79 cvs 5046: if (attrs[i])
1.25 cvs 5047: {
1.125 vatton 5048: /* it's an attribute */
1.220 quint 5049: if (xmlType == XML_TYPE)
5050: {
5051: attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
5052: TtaGetXmlAttributeType (attrs[i], &attrType, doc);
5053: att = attrType.AttrTypeNum;
5054: }
5055: else
1.221 vatton 5056: {
5057: MapXMLAttribute (xmlType, attrs[i], names[i], &level, doc, &att);
5058: if (ctxt->schema == NULL && att != 0)
5059: ctxt->schema = TtaGetDocumentSSchema (doc);
5060: }
1.127 quint 5061: if (att == DummyAttribute && !strcmp (schemaName, "HTML"))
5062: /* it's the "type" attribute for an "input" element. In the tree
5063: it's represented by the element type, not by an attribute */
5064: att = 0;
1.119 vatton 5065: ctxt->attrType[j] = att;
1.133 vatton 5066: ctxt->attrMatch[j] = attrmatch[i];
1.125 vatton 5067: attrType.AttrSSchema = ctxt->schema;
5068: attrType.AttrTypeNum = att;
1.119 vatton 5069: if (i == 0 && att == 0 && ctxt->schema == NULL)
5070: {
1.125 vatton 5071: /* Not found -> search in the list of loaded schemas */
1.119 vatton 5072: attrType.AttrSSchema = NULL;
5073: TtaGetXmlAttributeType (attrs[i], &attrType, doc);
5074: ctxt->attrType[j] = attrType.AttrTypeNum;
5075: if (attrType.AttrSSchema)
1.125 vatton 5076: /* the element type concerns an imported nature */
5077: schemaName = TtaGetSSchemaName(attrType.AttrSSchema);
1.119 vatton 5078: #ifdef XML_GENERIC
5079: else if (xmlType == XML_TYPE)
5080: {
5081: /* The attribute is not yet present in the tree */
5082: /* Create a new global attribute */
5083: attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
5084: TtaAppendXmlAttribute (attrs[i], &attrType, doc);
5085: }
5086: #endif /* XML_GENERIC */
5087:
5088: if (attrType.AttrSSchema == NULL)
5089: /* cannot apply these CSS rules */
5090: DoApply = FALSE;
1.136 quint 5091: else if (elType.ElSSchema)
5092: ctxt->schema = elType.ElSSchema;
1.119 vatton 5093: else
1.136 quint 5094: ctxt->schema = attrType.AttrSSchema;
1.119 vatton 5095: }
1.125 vatton 5096: /* check the attribute type */
5097: if (!strcmp (schemaName, "HTML"))
5098: xmlType = XHTML_TYPE;
5099: else if (!strcmp (schemaName, "MathML"))
5100: xmlType = MATH_TYPE;
5101: else if (!strcmp (schemaName, "SVG"))
5102: xmlType = SVG_TYPE;
5103: else if (!strcmp (schemaName, "XLink"))
5104: xmlType = XLINK_TYPE;
5105: else if (!strcmp (schemaName, "Annot"))
5106: xmlType = ANNOT_TYPE;
5107: else
5108: xmlType = XML_TYPE;
5109: kind = TtaGetAttributeKind (attrType);
1.220 quint 5110: if (kind == 0 && attrvals[i])
1.125 vatton 5111: {
5112: /* enumerated value */
1.248 gully 5113: MapXMLAttributeValue (xmlType, attrvals[i], &attrType, &kind);
1.125 vatton 5114: /* store the attribute value */
5115: ctxt->attrText[j] = (char *) kind;
5116: }
5117: else
5118: ctxt->attrText[j] = attrvals[i];
1.129 vatton 5119: /* update attrLevel */
5120: ctxt->attrLevel[j] = i;
5121: j++;
1.25 cvs 5122: }
5123: i++;
1.117 vatton 5124: /* add a new entry */
5125: k++;
1.129 vatton 5126: if (k < j)
5127: k = j;
1.119 vatton 5128: if (i == 1 && ctxt->schema == NULL)
5129: /* use the document schema */
5130: ctxt->schema = TtaGetDocumentSSchema (doc);
1.1 cvs 5131: }
1.117 vatton 5132: /* set the selector specificity */
5133: ctxt->cssSpecificity = specificity;
1.25 cvs 5134: /* Get the schema name of the main element */
1.119 vatton 5135: schemaName = TtaGetSSchemaName (ctxt->schema);
5136: isHTML = (strcmp (schemaName, "HTML") == 0);
1.206 vatton 5137: tsch = GetPExtension (doc, ctxt->schema, css, link);
1.217 vatton 5138: skippedNL = NewLineSkipped;
1.119 vatton 5139: if (tsch && cssRule)
5140: ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
1.116 vatton 5141: /* future CSS rules should apply */
5142: DoApply = TRUE;
1.217 vatton 5143: if (selector)
5144: NewLineSkipped = skippedNL;
1.1 cvs 5145: return (selector);
5146: }
5147:
5148: /*----------------------------------------------------------------------
1.206 vatton 5149: ParseStyleDeclaration: parse a style declaration stored in the style
5150: element of a document
5151: We expect the style string to be of the form:
5152: .pinky, .awful { color: pink; font-family: helvetica }
1.231 vatton 5153: The parameter css points to the current CSS context.
5154: The parameter link points to the link element.
5155: The parameter url gives the URL of the parsed style sheet.
1.1 cvs 5156: ----------------------------------------------------------------------*/
1.206 vatton 5157: static void ParseStyleDeclaration (Element el, char *cssRule, Document doc,
1.231 vatton 5158: CSSInfoPtr css, Element link, char *url,
5159: ThotBool destroy)
1.1 cvs 5160: {
1.79 cvs 5161: GenericContext ctxt;
5162: char *decl_end;
5163: char *sel_end;
5164: char *selector;
1.1 cvs 5165:
5166: /* separate the selectors string */
1.82 cvs 5167: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 5168: decl_end = cssRule;
1.82 cvs 5169: while (*decl_end != EOS && *decl_end != '{')
1.1 cvs 5170: decl_end++;
1.82 cvs 5171: if (*decl_end == EOS)
1.86 cvs 5172: {
1.168 vatton 5173: CSSPrintError ("Invalid selector", cssRule);
1.86 cvs 5174: return;
5175: }
1.1 cvs 5176: /* verify and clean the selector string */
5177: sel_end = decl_end - 1;
1.82 cvs 5178: while (*sel_end == SPACE || *sel_end == BSPACE ||
5179: *sel_end == EOL || *sel_end == CR)
1.1 cvs 5180: sel_end--;
5181: sel_end++;
1.82 cvs 5182: *sel_end = EOS;
1.1 cvs 5183: selector = cssRule;
5184:
5185: /* now, deal with the content ... */
5186: decl_end++;
5187: cssRule = decl_end;
1.137 vatton 5188: decl_end = &cssRule[strlen (cssRule) - 1];
5189: if (*decl_end != '{')
5190: *decl_end = EOS;
1.1 cvs 5191: /*
5192: * parse the style attribute string and install the corresponding
5193: * presentation attributes on the new element
5194: */
5195: ctxt = TtaGetGenericStyleContext (doc);
5196: if (ctxt == NULL)
5197: return;
5198: ctxt->destroy = destroy;
1.207 vatton 5199: /* first use of the context */
5200: ctxt->uses = 1;
1.197 vatton 5201: while (selector && *selector != EOS)
1.231 vatton 5202: selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css,
5203: link, url);
1.207 vatton 5204: /* check if the context can be freed */
5205: ctxt->uses -= 1;
5206: if (ctxt->uses == 0)
5207: /* no image loading */
5208: TtaFreeMemory (ctxt);
1.1 cvs 5209: }
5210:
5211: /************************************************************************
5212: * *
5213: * EVALUATION FUNCTIONS / CASCADING AND OVERLOADING *
5214: * *
5215: ************************************************************************/
5216:
5217: /*----------------------------------------------------------------------
1.59 cvs 5218: IsImplicitClassName: return wether the Class name is an
1.1 cvs 5219: implicit one, eg "H1" or "H2 EM" meaning it's a GI name
5220: or an HTML context name.
5221: ----------------------------------------------------------------------*/
1.248 gully 5222: int IsImplicitClassName (char *class_, Document doc)
1.1 cvs 5223: {
1.79 cvs 5224: char name[200];
5225: char *cur = name;
5226: char *first;
5227: char save;
5228: SSchema schema;
1.1 cvs 5229:
5230: /* make a local copy */
1.248 gully 5231: strncpy (name, class_, 199);
1.1 cvs 5232: name[199] = 0;
5233:
5234: /* loop looking if each word is a GI */
5235: while (*cur != 0)
5236: {
5237: first = cur;
5238: cur = SkipWord (cur);
5239: save = *cur;
5240: *cur = 0;
5241: schema = NULL;
5242: if (MapGI (first, &schema, doc) == -1)
5243: {
5244: return (0);
5245: }
5246: *cur = save;
1.82 cvs 5247: cur = SkipBlanksAndComments (cur);
1.1 cvs 5248: }
5249: return (1);
5250: }
5251:
5252: /************************************************************************
5253: * *
1.114 quint 5254: * Functions needed for support of HTML: translate to CSS equivalent *
1.1 cvs 5255: * *
5256: ************************************************************************/
5257:
5258: /*----------------------------------------------------------------------
1.59 cvs 5259: HTMLSetBackgroundColor:
1.1 cvs 5260: ----------------------------------------------------------------------*/
1.264 vatton 5261: void HTMLSetBackgroundColor (Document doc, Element el, int specificity,
5262: char *color)
1.1 cvs 5263: {
1.79 cvs 5264: char css_command[100];
1.1 cvs 5265:
1.82 cvs 5266: sprintf (css_command, "background-color: %s", color);
1.264 vatton 5267: ParseHTMLSpecificStyle (el, css_command, doc, specificity, FALSE);
1.1 cvs 5268: }
5269:
5270: /*----------------------------------------------------------------------
1.59 cvs 5271: HTMLSetForegroundColor:
1.1 cvs 5272: ----------------------------------------------------------------------*/
1.264 vatton 5273: void HTMLSetForegroundColor (Document doc, Element el, int specificity,
5274: char *color)
1.1 cvs 5275: {
1.79 cvs 5276: char css_command[100];
1.1 cvs 5277:
1.82 cvs 5278: sprintf (css_command, "color: %s", color);
1.264 vatton 5279: ParseHTMLSpecificStyle (el, css_command, doc, specificity, FALSE);
1.1 cvs 5280: }
5281:
5282: /*----------------------------------------------------------------------
1.59 cvs 5283: HTMLResetBackgroundColor:
1.1 cvs 5284: ----------------------------------------------------------------------*/
1.97 vatton 5285: void HTMLResetBackgroundColor (Document doc, Element el)
1.1 cvs 5286: {
1.79 cvs 5287: char css_command[100];
1.1 cvs 5288:
1.82 cvs 5289: sprintf (css_command, "background: red");
1.114 quint 5290: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5291: }
5292:
5293: /*----------------------------------------------------------------------
1.59 cvs 5294: HTMLResetBackgroundImage:
1.1 cvs 5295: ----------------------------------------------------------------------*/
1.97 vatton 5296: void HTMLResetBackgroundImage (Document doc, Element el)
1.1 cvs 5297: {
1.79 cvs 5298: char css_command[1000];
1.1 cvs 5299:
1.82 cvs 5300: sprintf (css_command, "background-image: url(xx); background-repeat: repeat");
1.114 quint 5301: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5302: }
5303:
5304: /*----------------------------------------------------------------------
1.59 cvs 5305: HTMLResetForegroundColor:
1.1 cvs 5306: ----------------------------------------------------------------------*/
1.97 vatton 5307: void HTMLResetForegroundColor (Document doc, Element el)
1.1 cvs 5308: {
1.79 cvs 5309: char css_command[100];
1.1 cvs 5310:
1.36 cvs 5311: /* it's not necessary to well know the current color but it must be valid */
1.82 cvs 5312: sprintf (css_command, "color: red");
1.114 quint 5313: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5314: }
5315:
5316: /*----------------------------------------------------------------------
1.59 cvs 5317: HTMLSetAlinkColor:
1.1 cvs 5318: ----------------------------------------------------------------------*/
1.208 vatton 5319: void HTMLSetAlinkColor (Document doc, Element el, char *color)
1.1 cvs 5320: {
1.79 cvs 5321: char css_command[100];
1.1 cvs 5322:
1.215 quint 5323: sprintf (css_command, ":link { color: %s }", color);
1.208 vatton 5324: ApplyCSSRules (el, css_command, doc, FALSE);
1.1 cvs 5325: }
5326:
5327: /*----------------------------------------------------------------------
1.59 cvs 5328: HTMLSetAactiveColor:
1.1 cvs 5329: ----------------------------------------------------------------------*/
1.208 vatton 5330: void HTMLSetAactiveColor (Document doc, Element el, char *color)
1.1 cvs 5331: {
1.79 cvs 5332: char css_command[100];
1.1 cvs 5333:
1.215 quint 5334: sprintf (css_command, ":active { color: %s }", color);
1.208 vatton 5335: ApplyCSSRules (el, css_command, doc, FALSE);
1.1 cvs 5336: }
5337:
5338: /*----------------------------------------------------------------------
1.59 cvs 5339: HTMLSetAvisitedColor:
1.1 cvs 5340: ----------------------------------------------------------------------*/
1.208 vatton 5341: void HTMLSetAvisitedColor (Document doc, Element el, char *color)
1.1 cvs 5342: {
1.79 cvs 5343: char css_command[100];
1.1 cvs 5344:
1.215 quint 5345: sprintf (css_command, ":visited { color: %s }", color);
1.208 vatton 5346: ApplyCSSRules (el, css_command, doc, FALSE);
1.1 cvs 5347: }
5348:
5349: /*----------------------------------------------------------------------
1.59 cvs 5350: HTMLResetAlinkColor:
1.1 cvs 5351: ----------------------------------------------------------------------*/
1.208 vatton 5352: void HTMLResetAlinkColor (Document doc, Element el)
1.1 cvs 5353: {
1.79 cvs 5354: char css_command[100];
1.1 cvs 5355:
1.215 quint 5356: sprintf (css_command, ":link { color: red }");
1.208 vatton 5357: ApplyCSSRules (el, css_command, doc, TRUE);
1.1 cvs 5358: }
5359:
5360: /*----------------------------------------------------------------------
1.59 cvs 5361: HTMLResetAactiveColor:
1.1 cvs 5362: ----------------------------------------------------------------------*/
1.208 vatton 5363: void HTMLResetAactiveColor (Document doc, Element el)
1.1 cvs 5364: {
1.79 cvs 5365: char css_command[100];
1.1 cvs 5366:
1.215 quint 5367: sprintf (css_command, ":active { color: red }");
1.208 vatton 5368: ApplyCSSRules (el, css_command, doc, TRUE);
1.1 cvs 5369: }
5370:
5371: /*----------------------------------------------------------------------
1.59 cvs 5372: HTMLResetAvisitedColor:
1.1 cvs 5373: ----------------------------------------------------------------------*/
1.208 vatton 5374: void HTMLResetAvisitedColor (Document doc, Element el)
1.1 cvs 5375: {
1.79 cvs 5376: char css_command[100];
1.1 cvs 5377:
1.215 quint 5378: sprintf (css_command, ":visited { color: red }");
1.208 vatton 5379: ApplyCSSRules (el, css_command, doc, TRUE);
1.1 cvs 5380: }
5381:
5382: /*----------------------------------------------------------------------
1.206 vatton 5383: ApplyCSSRules: parse a CSS Style description stored in the header of
5384: a HTML document.
1.1 cvs 5385: ----------------------------------------------------------------------*/
1.79 cvs 5386: void ApplyCSSRules (Element el, char *cssRule, Document doc, ThotBool destroy)
1.1 cvs 5387: {
1.206 vatton 5388: CSSInfoPtr css;
5389: PInfoPtr pInfo;
1.207 vatton 5390: ThotBool loadcss;
5391:
5392: /* check if we have to load CSS */
5393: TtaGetEnvBoolean ("LOAD_CSS", &loadcss);
5394: if (!loadcss)
5395: return;
1.1 cvs 5396:
1.206 vatton 5397: css = SearchCSS (doc, NULL, el, &pInfo);
1.1 cvs 5398: if (css == NULL)
1.209 vatton 5399: {
5400: /* create the document css context */
5401: css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, CSS_ALL, NULL, NULL, el);
5402: pInfo = css->infos[doc];
5403: }
1.206 vatton 5404: else if (pInfo == NULL)
5405: /* create the entry into the css context */
5406: pInfo = AddInfoCSS (doc, css, CSS_DOCUMENT_STYLE, CSS_ALL, el);
1.209 vatton 5407: if (pInfo->PiEnabled)
1.231 vatton 5408: ParseStyleDeclaration (el, cssRule, doc, css, el, NULL, destroy);
1.1 cvs 5409: }
5410:
5411: /*----------------------------------------------------------------------
1.145 quint 5412: ReadCSSRules: is the front-end function called by the document parser
5413: when detecting a <style type="text/css"> indicating it's the
1.1 cvs 5414: beginning of a CSS fragment or when reading a file .css.
5415:
5416: The CSS parser has to handle <!-- ... --> constructs used to
5417: prevent prehistoric browser from displaying the CSS as a text
5418: content. It will stop on any sequence "<x" where x is different
5419: from ! and will return x as to the caller. Theorically x should
1.145 quint 5420: be equal to / for the </style> end of style.
1.1 cvs 5421: The parameter doc gives the document tree that contains CSS information.
5422: The parameter docRef gives the document to which CSS are to be applied.
5423: This function uses the current css context or creates it. It's able
1.23 cvs 5424: to work on the given buffer or call GetNextChar to read the parsed
1.1 cvs 5425: file.
1.231 vatton 5426: The parameter url gives the URL of the parsed style sheet.
5427: The parameter numberOfLinesRead gives the number of lines already
1.86 cvs 5428: read in the file.
1.231 vatton 5429: The parameter withUndo indicates whether the changes made in the document
1.145 quint 5430: structure and content have to be registered in the Undo queue or not.
1.1 cvs 5431: ----------------------------------------------------------------------*/
1.133 vatton 5432: char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, char *url,
1.144 quint 5433: int numberOfLinesRead, ThotBool withUndo,
1.206 vatton 5434: Element link)
1.1 cvs 5435: {
1.6 cvs 5436: DisplayMode dispMode;
1.206 vatton 5437: CSSInfoPtr refcss = NULL;
5438: PInfoPtr pInfo;
1.82 cvs 5439: char c;
1.138 vatton 5440: char *cssRule, *base, *saveDocURL, *ptr;
1.19 cvs 5441: int index;
1.1 cvs 5442: int CSSindex;
5443: int CSScomment;
5444: int import;
5445: int openRule;
1.93 vatton 5446: int newlines;
1.14 cvs 5447: ThotBool HTMLcomment;
1.102 vatton 5448: ThotBool toParse, eof, quoted;
1.234 vatton 5449: ThotBool ignore, media, page;
5450: ThotBool noRule, ignoreImport, fontface;
1.1 cvs 5451:
5452: CSScomment = MAX_CSS_LENGTH;
5453: HTMLcomment = FALSE;
5454: CSSindex = 0;
5455: toParse = FALSE;
5456: noRule = FALSE;
1.234 vatton 5457: media = FALSE;
1.88 cvs 5458: ignoreImport = FALSE;
1.234 vatton 5459: ignore = FALSE;
5460: page = FALSE;
5461: quoted = FALSE;
5462: fontface = FALSE;
1.1 cvs 5463: eof = FALSE;
5464: openRule = 0;
1.234 vatton 5465: import = MAX_CSS_LENGTH;
1.82 cvs 5466: c = SPACE;
1.1 cvs 5467: index = 0;
1.134 vatton 5468: base = NULL;
1.93 vatton 5469: /* number of new lines parsed */
5470: newlines = 0;
1.6 cvs 5471: /* avoid too many redisplay */
5472: dispMode = TtaGetDisplayMode (docRef);
5473: if (dispMode == DisplayImmediately)
5474: TtaSetDisplayMode (docRef, DeferredDisplay);
1.18 cvs 5475:
5476: /* look for the CSS context */
5477: if (css == NULL)
1.206 vatton 5478: css = SearchCSS (docRef, NULL, link, &pInfo);
1.207 vatton 5479: else
5480: pInfo = css->infos[docRef];
1.18 cvs 5481: if (css == NULL)
1.206 vatton 5482: {
5483: css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, CSS_ALL, NULL, NULL, link);
5484: pInfo = css->infos[docRef];
5485: }
5486: else if (pInfo == NULL)
5487: pInfo = AddInfoCSS (docRef, css, CSS_DOCUMENT_STYLE, CSS_ALL, link);
1.174 vatton 5488: /* look for the CSS descriptor that points to the extension schema */
5489: refcss = css;
1.224 vatton 5490: if (pInfo && pInfo->PiCategory == CSS_IMPORT)
1.173 cvs 5491: {
1.206 vatton 5492: while (refcss &&
5493: refcss->infos[docRef] && refcss->infos[docRef]->PiCategory == CSS_IMPORT)
1.174 vatton 5494: refcss = refcss->NextCSS;
1.206 vatton 5495: if (refcss)
5496: pInfo = refcss->infos[docRef];
1.173 cvs 5497: }
5498:
1.144 quint 5499: /* register parsed CSS file and the document to which CSS are to be applied*/
1.86 cvs 5500: ParsedDoc = docRef;
1.133 vatton 5501: if (url)
5502: DocURL = url;
1.86 cvs 5503: else
5504: /* the CSS source in within the document itself */
5505: DocURL = DocumentURLs[docRef];
5506: LineNumber = numberOfLinesRead + 1;
1.93 vatton 5507: NewLineSkipped = 0;
1.217 vatton 5508: newlines = 0;
1.82 cvs 5509: while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof)
5510: {
5511: c = buffer[index++];
5512: eof = (c == EOS);
5513: CSSbuffer[CSSindex] = c;
1.234 vatton 5514: if (CSScomment == MAX_CSS_LENGTH ||
1.246 vatton 5515: c == '*' || c == '/' || c == '<' || c == EOL)
1.82 cvs 5516: {
5517: /* we're not within a comment or we're parsing * or / */
5518: switch (c)
5519: {
5520: case '@': /* perhaps an import primitive */
1.234 vatton 5521: if (!fontface && !page && !quoted)
1.135 vatton 5522: import = CSSindex;
1.82 cvs 5523: break;
5524: case ';':
1.135 vatton 5525: if (!quoted && !media && import != MAX_CSS_LENGTH)
1.82 cvs 5526: {
5527: if (strncasecmp (&CSSbuffer[import+1], "import", 6))
5528: /* it's not an import */
5529: import = MAX_CSS_LENGTH;
5530: /* save the text */
5531: noRule = TRUE;
5532: }
5533: break;
5534: case '*':
1.135 vatton 5535: if (!quoted && CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.82 cvs 5536: CSSbuffer[CSSindex - 1] == '/')
5537: /* start a comment */
5538: CSScomment = CSSindex - 1;
5539: break;
5540: case '/':
1.135 vatton 5541: if (!quoted && CSSindex > 1 && CSScomment != MAX_CSS_LENGTH &&
1.82 cvs 5542: CSSbuffer[CSSindex - 1] == '*')
5543: {
1.234 vatton 5544: /* close a comment and ignore its contents */
1.82 cvs 5545: CSSindex = CSScomment - 1; /* will be incremented later */
5546: CSScomment = MAX_CSS_LENGTH;
1.93 vatton 5547: /* clean up the buffer */
1.103 vatton 5548: if (newlines && CSSindex > 0)
5549: while (CSSindex > 0 &&
5550: (CSSbuffer[CSSindex] == SPACE ||
5551: CSSbuffer[CSSindex] == BSPACE ||
5552: CSSbuffer[CSSindex] == EOL ||
5553: CSSbuffer[CSSindex] == TAB ||
5554: CSSbuffer[CSSindex] == __CR__))
1.93 vatton 5555: {
5556: if ( CSSbuffer[CSSindex] == EOL)
5557: {
5558: LineNumber ++;
1.217 vatton 5559: newlines --;
1.93 vatton 5560: }
5561: CSSindex--;
5562: }
1.82 cvs 5563: }
1.234 vatton 5564: else if (!fontface && !page && !quoted &&
5565: CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.82 cvs 5566: CSSbuffer[CSSindex - 1] == '<')
5567: {
5568: /* this is the closing tag ! */
5569: CSSindex -= 2; /* remove </ from the CSS string */
5570: noRule = TRUE;
5571: }
5572: break;
5573: case '<':
1.234 vatton 5574: if (!fontface && !page && !quoted &&
5575: CSScomment == MAX_CSS_LENGTH)
1.82 cvs 5576: {
5577: /* only if we're not parsing a comment */
5578: c = buffer[index++];
5579: eof = (c == EOS);
5580: if (c == '!')
5581: {
5582: /* CSS within an HTML comment */
5583: HTMLcomment = TRUE;
5584: CSSindex++;
5585: CSSbuffer[CSSindex] = c;
5586: }
5587: else if (c == EOS)
5588: CSSindex++;
5589: }
5590: break;
5591: case '-':
1.234 vatton 5592: if (!fontface && !page && !quoted &&
5593: CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' &&
1.82 cvs 5594: HTMLcomment)
5595: /* CSS within an HTML comment */
5596: noRule = TRUE;
5597: break;
5598: case '>':
1.234 vatton 5599: if (!fontface && !page && !quoted && HTMLcomment)
1.82 cvs 5600: noRule = TRUE;
5601: break;
5602: case ' ':
1.135 vatton 5603: if (!quoted && import != MAX_CSS_LENGTH && openRule == 0)
1.234 vatton 5604: media = !strncasecmp (&CSSbuffer[import+1], "media", 5);
1.82 cvs 5605: break;
5606: case '{':
1.135 vatton 5607: if (!quoted)
1.82 cvs 5608: {
1.135 vatton 5609: openRule++;
1.234 vatton 5610: if (import != MAX_CSS_LENGTH)
1.135 vatton 5611: {
1.234 vatton 5612: if (openRule == 1 && media)
5613: {
5614: /* is it the screen concerned? */
5615: CSSbuffer[CSSindex+1] = EOS;
5616: if (TtaIsPrinting ())
5617: base = strstr (&CSSbuffer[import], "print");
5618: else
5619: base = strstr (&CSSbuffer[import], "screen");
5620: if (base == NULL)
5621: base = strstr (&CSSbuffer[import], "all");
5622: if (base == NULL)
5623: ignore = TRUE;
1.235 vatton 5624: noRule = TRUE;
1.234 vatton 5625: }
5626: else if (!strncasecmp (&CSSbuffer[import+1], "page", 4))
1.235 vatton 5627: {
5628: page = TRUE;
5629: noRule = TRUE;
5630: }
1.234 vatton 5631: else if (!strncasecmp (&CSSbuffer[import+1], "font-face", 9))
1.235 vatton 5632: {
5633: fontface = TRUE;
5634: noRule = TRUE;
5635: }
1.135 vatton 5636: }
5637: }
5638: break;
5639: case '}':
5640: if (!quoted)
5641: {
5642: openRule--;
1.234 vatton 5643: if (page)
5644: {
5645: noRule = TRUE;
5646: page = FALSE; /* close the page section */
5647: }
5648: else if (fontface)
5649: {
5650: noRule = TRUE;
5651: fontface = FALSE; /* close the fontface section */
5652: }
5653: else if (openRule == 0 && import != MAX_CSS_LENGTH)
1.135 vatton 5654: {
5655: import = MAX_CSS_LENGTH;
5656: noRule = TRUE;
1.234 vatton 5657: ignore = FALSE;
1.135 vatton 5658: media = FALSE;
5659: }
1.82 cvs 5660: else
1.135 vatton 5661: toParse = TRUE;
1.82 cvs 5662: }
5663: break;
1.135 vatton 5664: case '"':
5665: if (quoted)
1.82 cvs 5666: {
1.135 vatton 5667: if (CSSbuffer[CSSindex - 1] != '\\')
5668: quoted = FALSE;
1.82 cvs 5669: }
5670: else
1.135 vatton 5671: quoted = TRUE;
1.82 cvs 5672: break;
5673: default:
1.86 cvs 5674: if (c == EOL)
1.93 vatton 5675: newlines++;
1.82 cvs 5676: break;
5677: }
5678: }
1.93 vatton 5679: else if (c == EOL)
1.217 vatton 5680: {
5681: LineNumber++;
5682: c = CR;
5683: }
1.234 vatton 5684:
1.82 cvs 5685: if (c != CR)
5686: CSSindex++;
5687:
5688: if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
5689: /* we're still parsing a comment: remove the text comment */
5690: CSSindex = CSScomment;
5691:
5692: if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule)
5693: {
5694: CSSbuffer[CSSindex] = EOS;
5695: /* parse a not empty string */
5696: if (CSSindex > 0)
5697: {
1.50 cvs 5698: /* apply CSS rule if it's not just a saving of text */
1.234 vatton 5699: if (!noRule && !ignore)
1.88 cvs 5700: {
5701: /* future import rules must be ignored */
5702: ignoreImport = TRUE;
1.217 vatton 5703: NewLineSkipped = 0;
1.210 vatton 5704: ParseStyleDeclaration (NULL, CSSbuffer, docRef, refcss,
1.231 vatton 5705: pInfo->PiLink, url, FALSE);
1.93 vatton 5706: LineNumber += newlines;
5707: newlines = 0;
1.88 cvs 5708: }
1.82 cvs 5709: else if (import != MAX_CSS_LENGTH &&
5710: !strncasecmp (&CSSbuffer[import+1], "import", 6))
5711: {
5712: /* import section */
5713: cssRule = &CSSbuffer[import+7];
5714: cssRule = TtaSkipBlanks (cssRule);
1.93 vatton 5715: /* save the current line number */
5716: newlines += LineNumber;
1.82 cvs 5717: if (!strncasecmp (cssRule, "url", 3))
5718: {
1.50 cvs 5719: cssRule = &cssRule[3];
1.82 cvs 5720: cssRule = TtaSkipBlanks (cssRule);
5721: if (*cssRule == '(')
5722: {
5723: cssRule++;
5724: cssRule = TtaSkipBlanks (cssRule);
1.102 vatton 5725: quoted = (*cssRule == '"' || *cssRule == '\'');
5726: if (quoted)
5727: cssRule++;
1.82 cvs 5728: base = cssRule;
5729: while (*cssRule != EOS && *cssRule != ')')
5730: cssRule++;
1.102 vatton 5731: if (quoted)
1.167 vatton 5732: {
5733: /* isolate the file name */
5734: cssRule[-1] = EOS;
5735: quoted = FALSE;
5736: }
1.216 vatton 5737: else
5738: {
5739: /* remove extra spaces */
5740: if (cssRule[-1] == SPACE)
5741: {
5742: *cssRule = SPACE;
5743: cssRule--;
5744: while (cssRule[-1] == SPACE)
5745: cssRule--;
5746: }
5747: }
1.160 vatton 5748: *cssRule = EOS;
1.82 cvs 5749: }
5750: }
1.87 cvs 5751: else if (*cssRule == '"')
5752: {
1.88 cvs 5753: /*
5754: Do we have to accept single quotes?
5755: Double quotes are acceted here.
5756: Escaped quotes are not handled. See function SkipQuotedString
5757: */
1.87 cvs 5758: cssRule++;
5759: cssRule = TtaSkipBlanks (cssRule);
5760: base = cssRule;
1.179 vatton 5761: while (*cssRule != EOS &&
5762: (*cssRule != '"' ||
1.180 vatton 5763: (*cssRule == '"' && cssRule[-1] == '\\')))
1.87 cvs 5764: cssRule++;
1.160 vatton 5765: /* isolate the file name */
5766: *cssRule = EOS;
1.133 vatton 5767: }
5768: /* check if a media is defined */
5769: cssRule++;
5770: cssRule = TtaSkipBlanks (cssRule);
5771: if (*cssRule != ';')
5772: {
5773: if (TtaIsPrinting ())
5774: ignoreImport = (strncasecmp (cssRule, "print", 5) &&
5775: strncasecmp (cssRule, "all", 3));
5776: else
5777: ignoreImport = (strncasecmp (cssRule, "screen", 6) &&
5778: strncasecmp (cssRule, "all", 3));
5779: }
5780: if (!ignoreImport)
5781: {
5782: /* save the displayed URL when an error is reported */
5783: saveDocURL = DocURL;
1.138 vatton 5784: ptr = TtaStrdup (base);
5785: /* get the CSS URI in UTF-8 */
5786: ptr = ReallocUTF8String (ptr, docRef);
1.206 vatton 5787: LoadStyleSheet (base, docRef, (Element) css, css,
5788: pInfo->PiMedia,
5789: pInfo->PiCategory == CSS_USER_STYLE);
1.133 vatton 5790: /* restore the displayed URL when an error is reported */
5791: DocURL = saveDocURL;
1.138 vatton 5792: TtaFreeMemory (ptr);
1.82 cvs 5793: }
1.93 vatton 5794: /* restore the number of lines */
5795: LineNumber = newlines;
5796: newlines = 0;
1.217 vatton 5797: NewLineSkipped = 0;
1.82 cvs 5798: import = MAX_CSS_LENGTH;
5799: }
1.234 vatton 5800: else
5801: {
5802: LineNumber += newlines;
5803: newlines = 0;
5804: }
1.82 cvs 5805: }
5806: toParse = FALSE;
5807: noRule = FALSE;
5808: CSSindex = 0;
1.50 cvs 5809: }
1.82 cvs 5810: }
1.6 cvs 5811: /* restore the display mode */
5812: if (dispMode == DisplayImmediately)
1.82 cvs 5813: TtaSetDisplayMode (docRef, dispMode);
1.86 cvs 5814:
5815: /* Prepare the context for style attributes */
5816: DocURL = DocumentURLs[docRef];
5817: LineNumber = -1;
1.1 cvs 5818: return (c);
5819: }
1.89 cvs 5820:
Webmaster