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