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