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