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