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