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