Annotation of Amaya/amaya/styleparser.c, revision 1.220
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.59 cvs 1701: ParseCSSFontSize: parse a CSS font size 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);
1711: }
1712:
1713: /*----------------------------------------------------------------------
1714: ParseCSSFontSize: parse a CSS font size attr string
1715: we expect the input string describing the attribute to be
1716: xx-small, x-small, small, medium, large, x-large, xx-large
1717: or an absolute size, or an imcrement relative to the parent
1718: ----------------------------------------------------------------------*/
1.79 cvs 1719: static char *ParseCSSFontSize (Element element, PSchema tsch,
1720: PresentationContext context, char *cssRule,
1721: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1722: {
1.171 quint 1723: ElementType elType;
1.1 cvs 1724: PresentationValue pval;
1.137 vatton 1725: char *ptr = NULL, *ptr1 = NULL;
1.14 cvs 1726: ThotBool real;
1.1 cvs 1727:
1728: pval.typed_data.real = FALSE;
1.82 cvs 1729: cssRule = SkipBlanksAndComments (cssRule);
1730: if (!strncasecmp (cssRule, "larger", 6))
1.1 cvs 1731: {
1.184 vatton 1732: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1733: pval.typed_data.value = 130;
1734: cssRule = SkipWord (cssRule);
1735: }
1.82 cvs 1736: else if (!strncasecmp (cssRule, "smaller", 7))
1.1 cvs 1737: {
1.184 vatton 1738: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1739: pval.typed_data.value = 80;
1740: cssRule = SkipWord (cssRule);
1741: }
1.82 cvs 1742: else if (!strncasecmp (cssRule, "xx-small", 8))
1.1 cvs 1743: {
1.184 vatton 1744: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1745: pval.typed_data.value = 1;
1746: cssRule = SkipWord (cssRule);
1747: }
1.82 cvs 1748: else if (!strncasecmp (cssRule, "x-small", 7))
1.1 cvs 1749: {
1.184 vatton 1750: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1751: pval.typed_data.value = 2;
1752: cssRule = SkipWord (cssRule);
1753: }
1.82 cvs 1754: else if (!strncasecmp (cssRule, "small", 5))
1.1 cvs 1755: {
1.184 vatton 1756: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1757: pval.typed_data.value = 3;
1758: cssRule = SkipWord (cssRule);
1759: }
1.82 cvs 1760: else if (!strncasecmp (cssRule, "medium", 6))
1.1 cvs 1761: {
1.184 vatton 1762: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1763: pval.typed_data.value = 4;
1764: cssRule = SkipWord (cssRule);
1765: }
1.82 cvs 1766: else if (!strncasecmp (cssRule, "large", 5))
1.1 cvs 1767: {
1.184 vatton 1768: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1769: pval.typed_data.value = 5;
1770: cssRule = SkipWord (cssRule);
1771: }
1.82 cvs 1772: else if (!strncasecmp (cssRule, "x-large", 7))
1.1 cvs 1773: {
1.184 vatton 1774: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1775: pval.typed_data.value = 6;
1776: cssRule = SkipWord (cssRule);
1777: }
1.82 cvs 1778: else if (!strncasecmp (cssRule, "xx-large", 8))
1.1 cvs 1779: {
1.184 vatton 1780: pval.typed_data.unit = UNIT_REL;
1.1 cvs 1781: pval.typed_data.value = 7;
1782: cssRule = SkipWord (cssRule);
1783: }
1.171 quint 1784: else if (!isdigit (*cssRule) && *cssRule != '.')
1785: return (cssRule);
1.1 cvs 1786: else
1787: {
1.25 cvs 1788: /* look for a '/' within the current cssRule */
1.137 vatton 1789: ptr1 = strchr (cssRule, ';');
1.82 cvs 1790: ptr = strchr (cssRule, '/');
1.137 vatton 1791: if (ptr && (ptr1 == NULL || ptr < ptr1))
1.25 cvs 1792: {
1793: /* keep the line spacing rule */
1.82 cvs 1794: ptr[0] = EOS;
1.25 cvs 1795: ptr = &ptr[1];
1796: }
1.137 vatton 1797: else
1798: ptr = NULL;
1.171 quint 1799:
1.1 cvs 1800: cssRule = ParseCSSUnit (cssRule, &pval);
1.171 quint 1801:
1.184 vatton 1802: if (pval.typed_data.unit == UNIT_BOX)
1.171 quint 1803: /* no unit specified */
1804: {
1805: elType = TtaGetElementType(element);
1806: if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG"))
1807: /* we are working for an SVG element. No unit means pixels */
1.184 vatton 1808: pval.typed_data.unit = UNIT_PX;
1.171 quint 1809: }
1.168 vatton 1810: if (pval.typed_data.value != 0 &&
1.184 vatton 1811: (pval.typed_data.unit == UNIT_INVALID ||
1812: pval.typed_data.unit == UNIT_BOX ||
1.168 vatton 1813: pval.typed_data.value < 0))
1814: /* not a valid value */
1.1 cvs 1815: return (cssRule);
1.184 vatton 1816: else if (pval.typed_data.unit == UNIT_REL && pval.typed_data.value > 0)
1.1 cvs 1817: /* CSS relative sizes have to be higher than Thot ones */
1818: pval.typed_data.value += 1;
1819: else
1820: {
1821: real = pval.typed_data.real;
1.184 vatton 1822: if (pval.typed_data.unit == UNIT_EM)
1.1 cvs 1823: {
1824: if (real)
1825: {
1826: pval.typed_data.value /= 10;
1.11 cvs 1827: pval.typed_data.real = FALSE;
1.1 cvs 1828: real = FALSE;
1829: }
1830: else
1831: pval.typed_data.value *= 100;
1.184 vatton 1832: pval.typed_data.unit = UNIT_PERCENT;
1.1 cvs 1833: }
1.184 vatton 1834: else if (pval.typed_data.unit == UNIT_XHEIGHT)
1.146 quint 1835: {
1836: /* a font size expressed in ex is converted into a percentage.
1837: For example, "3ex" is converted into "180%", supposing
1838: that 1ex is approximately 0.6 times the height of the
1839: current font */
1840: if (real)
1841: {
1842: pval.typed_data.value *= 6;
1843: pval.typed_data.value /= 100;
1844: pval.typed_data.real = FALSE;
1845: real = FALSE;
1846: }
1847: else
1848: pval.typed_data.value *= 60;
1.184 vatton 1849: pval.typed_data.unit = UNIT_PERCENT;
1.146 quint 1850: }
1.1 cvs 1851: }
1852: }
1853:
1.25 cvs 1854: /* install the presentation style */
1.116 vatton 1855: if (DoApply)
1.117 vatton 1856: {
1857: if (tsch)
1858: cssRule = CheckImportantRule (cssRule, context);
1859: TtaSetStylePresentation (PRSize, element, tsch, context, pval);
1860: }
1861: if (ptr)
1.162 quint 1862: cssRule = ParseCSSLineHeight (element, tsch, context, ptr, css, isHTML);
1.1 cvs 1863: return (cssRule);
1864: }
1865:
1866: /*----------------------------------------------------------------------
1.59 cvs 1867: ParseCSSFontFamily: parse a CSS font family string
1.1 cvs 1868: we expect the input string describing the attribute to be
1869: a common generic font style name
1870: ----------------------------------------------------------------------*/
1.79 cvs 1871: static char *ParseCSSFontFamily (Element element, PSchema tsch,
1872: PresentationContext context, char *cssRule,
1873: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1874: {
1875: PresentationValue font;
1.79 cvs 1876: char quoteChar;
1.1 cvs 1877:
1878: font.typed_data.value = 0;
1.184 vatton 1879: font.typed_data.unit = UNIT_REL;
1.1 cvs 1880: font.typed_data.real = FALSE;
1.82 cvs 1881: cssRule = SkipBlanksAndComments (cssRule);
1882: if (*cssRule == '"' || *cssRule == '\'')
1.1 cvs 1883: {
1884: quoteChar = *cssRule;
1885: cssRule++;
1886: }
1887: else
1.82 cvs 1888: quoteChar = EOS;
1.1 cvs 1889:
1.92 cvs 1890: if (!strncasecmp (cssRule, "times", 5) &&
1891: (quoteChar == EOS || quoteChar == cssRule[5]))
1.86 cvs 1892: {
1.184 vatton 1893: font.typed_data.value = FontTimes;
1.86 cvs 1894: cssRule += 5;
1895: }
1.92 cvs 1896: else if (!strncasecmp (cssRule, "serif", 5) &&
1897: (quoteChar == EOS || quoteChar == cssRule[5]))
1.86 cvs 1898: {
1.184 vatton 1899: font.typed_data.value = FontTimes;
1.86 cvs 1900: cssRule += 5;
1.92 cvs 1901: if (quoteChar != EOS)
1902: cssRule++;
1.86 cvs 1903: }
1.92 cvs 1904: else if (!strncasecmp (cssRule, "helvetica", 9) &&
1905: (quoteChar == EOS || quoteChar == cssRule[9]))
1.86 cvs 1906: {
1.184 vatton 1907: font.typed_data.value = FontHelvetica;
1.86 cvs 1908: cssRule += 9;
1.92 cvs 1909: if (quoteChar != EOS)
1910: cssRule++;
1.86 cvs 1911: }
1.92 cvs 1912: else if (!strncasecmp (cssRule, "verdana", 7) &&
1913: (quoteChar == EOS || quoteChar == cssRule[7]))
1.86 cvs 1914: {
1.184 vatton 1915: font.typed_data.value = FontHelvetica;
1.86 cvs 1916: cssRule += 7;
1.92 cvs 1917: if (quoteChar != EOS)
1918: cssRule++;
1.86 cvs 1919: }
1.92 cvs 1920: else if (!strncasecmp (cssRule, "sans-serif", 10) &&
1921: (quoteChar == EOS || quoteChar == cssRule[10]))
1.86 cvs 1922: {
1.184 vatton 1923: font.typed_data.value = FontHelvetica;
1.86 cvs 1924: cssRule += 10;
1.92 cvs 1925: if (quoteChar != EOS)
1926: cssRule++;
1.86 cvs 1927: }
1.92 cvs 1928: else if (!strncasecmp (cssRule, "courier", 7) &&
1929: (quoteChar == EOS || quoteChar == cssRule[7]))
1.86 cvs 1930: {
1.184 vatton 1931: font.typed_data.value = FontCourier;
1.86 cvs 1932: cssRule += 7;
1.92 cvs 1933: if (quoteChar != EOS)
1934: cssRule++;
1.86 cvs 1935: }
1.92 cvs 1936: else if (!strncasecmp (cssRule, "monospace", 9) &&
1937: (quoteChar == EOS || quoteChar == cssRule[9]))
1.86 cvs 1938: {
1.184 vatton 1939: font.typed_data.value = FontCourier;
1.86 cvs 1940: cssRule += 9;
1.92 cvs 1941: if (quoteChar != EOS)
1942: cssRule++;
1.86 cvs 1943: }
1.1 cvs 1944: else
1945: /* unknown font name. Skip it */
1946: {
1.92 cvs 1947: if (quoteChar != EOS)
1.54 cvs 1948: cssRule = SkipQuotedString (cssRule, quoteChar);
1.86 cvs 1949: else
1.1 cvs 1950: cssRule = SkipWord (cssRule);
1.82 cvs 1951: cssRule = SkipBlanksAndComments (cssRule);
1952: if (*cssRule == ',')
1.1 cvs 1953: {
1.86 cvs 1954: cssRule++;
1955: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
1956: return (cssRule);
1.1 cvs 1957: }
1958: }
1959:
1960: if (font.typed_data.value != 0)
1961: {
1.93 vatton 1962: cssRule = SkipBlanksAndComments (cssRule);
1.133 vatton 1963: if (*cssRule == ',')
1964: {
1965: cssRule++;
1.168 vatton 1966: cssRule = SkipValue (NULL, cssRule);
1.133 vatton 1967: }
1.93 vatton 1968: /* install the new presentation */
1.116 vatton 1969: if (DoApply)
1.117 vatton 1970: {
1971: if (tsch)
1972: cssRule = CheckImportantRule (cssRule, context);
1973: TtaSetStylePresentation (PRFont, element, tsch, context, font);
1974: }
1.1 cvs 1975: }
1976: return (cssRule);
1977: }
1978:
1979: /*----------------------------------------------------------------------
1.59 cvs 1980: ParseCSSFontWeight: parse a CSS font weight string
1.1 cvs 1981: we expect the input string describing the attribute to be
1.20 cvs 1982: normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
1.1 cvs 1983: ----------------------------------------------------------------------*/
1.79 cvs 1984: static char *ParseCSSFontWeight (Element element, PSchema tsch,
1985: PresentationContext context, char *cssRule,
1986: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1987: {
1.20 cvs 1988: PresentationValue weight;
1.1 cvs 1989:
1990: weight.typed_data.value = 0;
1.184 vatton 1991: weight.typed_data.unit = UNIT_REL;
1.1 cvs 1992: weight.typed_data.real = FALSE;
1.82 cvs 1993: cssRule = SkipBlanksAndComments (cssRule);
1994: if (!strncasecmp (cssRule, "100", 3) && !isalpha (cssRule[3]))
1.1 cvs 1995: {
1996: weight.typed_data.value = -3;
1997: cssRule = SkipWord (cssRule);
1998: }
1.82 cvs 1999: else if (!strncasecmp (cssRule, "200", 3) && !isalpha (cssRule[3]))
1.1 cvs 2000: {
2001: weight.typed_data.value = -2;
2002: cssRule = SkipWord (cssRule);
2003: }
1.82 cvs 2004: else if (!strncasecmp (cssRule, "300", 3) && ! isalpha(cssRule[3]))
1.1 cvs 2005: {
2006: weight.typed_data.value = -1;
2007: cssRule = SkipWord (cssRule);
2008: }
1.82 cvs 2009: else if (!strncasecmp (cssRule, "normal", 6) || (!strncasecmp (cssRule, "400", 3) && !isalpha (cssRule[3])))
1.1 cvs 2010: {
2011: weight.typed_data.value = 0;
2012: cssRule = SkipWord (cssRule);
2013: }
1.82 cvs 2014: else if (!strncasecmp (cssRule, "500", 3) && !isalpha (cssRule[3]))
1.1 cvs 2015: {
2016: weight.typed_data.value = +1;
2017: cssRule = SkipWord (cssRule);
2018: }
1.82 cvs 2019: else if (!strncasecmp (cssRule, "600", 3) && !isalpha (cssRule[3]))
1.1 cvs 2020: {
2021: weight.typed_data.value = +2;
2022: cssRule = SkipWord (cssRule);
2023: }
1.82 cvs 2024: else if (!strncasecmp (cssRule, "bold", 4) || (!strncasecmp (cssRule, "700", 3) && !isalpha (cssRule[3])))
1.1 cvs 2025: {
2026: weight.typed_data.value = +3;
2027: cssRule = SkipWord (cssRule);
2028: }
1.82 cvs 2029: else if (!strncasecmp (cssRule, "800", 3) && !isalpha (cssRule[3]))
1.1 cvs 2030: {
2031: weight.typed_data.value = +4;
2032: cssRule = SkipWord (cssRule);
2033: }
1.82 cvs 2034: else if (!strncasecmp (cssRule, "900", 3) && !isalpha (cssRule[3]))
1.1 cvs 2035: {
2036: weight.typed_data.value = +5;
2037: cssRule = SkipWord (cssRule);
2038: }
1.82 cvs 2039: else if (!strncasecmp (cssRule, "inherit", 7) || !strncasecmp (cssRule, "bolder", 6) || !strncasecmp (cssRule, "lighter", 7))
1.1 cvs 2040: {
2041: /* not implemented */
2042: cssRule = SkipWord (cssRule);
2043: return (cssRule);
2044: }
2045: else
2046: return (cssRule);
2047:
2048: /*
1.20 cvs 2049: * Here we have to reduce since only two font weight values are supported
1.1 cvs 2050: * by the Thot presentation API.
2051: */
1.20 cvs 2052: if (weight.typed_data.value > 0)
1.184 vatton 2053: weight.typed_data.value = WeightBold;
1.20 cvs 2054: else
1.184 vatton 2055: weight.typed_data.value = WeightNormal;
1.1 cvs 2056:
2057: /* install the new presentation */
1.116 vatton 2058: if (DoApply)
1.117 vatton 2059: {
2060: if (tsch)
2061: cssRule = CheckImportantRule (cssRule, context);
2062: TtaSetStylePresentation (PRWeight, element, tsch, context, weight);
2063: }
1.1 cvs 2064: return (cssRule);
2065: }
2066:
2067: /*----------------------------------------------------------------------
1.59 cvs 2068: ParseCSSFontVariant: parse a CSS font variant string
1.1 cvs 2069: we expect the input string describing the attribute to be
2070: normal or small-caps
2071: ----------------------------------------------------------------------*/
1.79 cvs 2072: static char *ParseCSSFontVariant (Element element, PSchema tsch,
2073: PresentationContext context, char *cssRule,
2074: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2075: {
2076: PresentationValue style;
2077:
2078: style.typed_data.value = 0;
1.184 vatton 2079: style.typed_data.unit = UNIT_REL;
1.1 cvs 2080: style.typed_data.real = FALSE;
1.82 cvs 2081: cssRule = SkipBlanksAndComments (cssRule);
2082: if (!strncasecmp (cssRule, "small-caps", 10))
1.1 cvs 2083: {
2084: /* Not supported yet */
2085: cssRule = SkipWord (cssRule);
2086: }
1.82 cvs 2087: else if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 2088: {
2089: /* Not supported yet */
2090: cssRule = SkipWord (cssRule);
2091: }
1.82 cvs 2092: else if (!strncasecmp (cssRule, "inherit", 7))
1.1 cvs 2093: {
2094: /* Not supported yet */
2095: cssRule = SkipWord (cssRule);
2096: }
2097: else
2098: return (cssRule);
2099:
2100: return (cssRule);
2101: }
2102:
2103:
2104: /*----------------------------------------------------------------------
1.59 cvs 2105: ParseCSSFontStyle: parse a CSS font style string
1.1 cvs 2106: we expect the input string describing the attribute to be
2107: italic, oblique or normal
2108: ----------------------------------------------------------------------*/
1.79 cvs 2109: static char *ParseCSSFontStyle (Element element, PSchema tsch,
2110: PresentationContext context, char *cssRule,
2111: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2112: {
2113: PresentationValue style;
2114: PresentationValue size;
2115:
2116: style.typed_data.value = 0;
1.184 vatton 2117: style.typed_data.unit = UNIT_REL;
1.1 cvs 2118: style.typed_data.real = FALSE;
2119: size.typed_data.value = 0;
1.184 vatton 2120: size.typed_data.unit = UNIT_REL;
1.1 cvs 2121: size.typed_data.real = FALSE;
1.82 cvs 2122: cssRule = SkipBlanksAndComments (cssRule);
2123: if (!strncasecmp (cssRule, "italic", 6))
1.1 cvs 2124: {
1.184 vatton 2125: style.typed_data.value = StyleItalics;
1.1 cvs 2126: cssRule = SkipWord (cssRule);
2127: }
1.82 cvs 2128: else if (!strncasecmp (cssRule, "oblique", 7))
1.1 cvs 2129: {
1.184 vatton 2130: style.typed_data.value = StyleOblique;
1.1 cvs 2131: cssRule = SkipWord (cssRule);
2132: }
1.82 cvs 2133: else if (!strncasecmp (cssRule, "normal", 6))
1.1 cvs 2134: {
1.184 vatton 2135: style.typed_data.value = StyleRoman;
1.1 cvs 2136: cssRule = SkipWord (cssRule);
2137: }
1.108 cvs 2138: else if (!strncasecmp (cssRule, "inherit", 7))
2139: {
2140: /* not implemented */
2141: cssRule = SkipWord (cssRule);
2142: return (cssRule);
2143: }
1.1 cvs 2144: else
2145: {
2146: /* invalid font style */
1.108 cvs 2147: return (cssRule);
1.1 cvs 2148: }
2149:
2150: /*
2151: * install the new presentation.
2152: */
1.116 vatton 2153: if (style.typed_data.value != 0 && DoApply)
1.117 vatton 2154: {
2155: if (tsch)
2156: cssRule = CheckImportantRule (cssRule, context);
1.20 cvs 2157: TtaSetStylePresentation (PRStyle, element, tsch, context, style);
1.117 vatton 2158: }
1.116 vatton 2159: if (size.typed_data.value != 0 && DoApply)
1.1 cvs 2160: {
2161: PresentationValue previous_size;
2162:
2163: if (!TtaGetStylePresentation (PRSize, element, tsch, context, &previous_size))
2164: {
2165: /* !!!!!!!!!!!!!!!!!!!!!!!! Unite + relatif !!!!!!!!!!!!!!!! */
2166: size.typed_data.value += previous_size.typed_data.value;
2167: TtaSetStylePresentation (PRSize, element, tsch, context, size);
2168: }
2169: else
2170: {
2171: size.typed_data.value = 10;
2172: TtaSetStylePresentation (PRSize, element, tsch, context, size);
2173: }
2174: }
2175: return (cssRule);
2176: }
2177:
2178: /*----------------------------------------------------------------------
1.59 cvs 2179: ParseCSSFont: parse a CSS font attribute string
2180: we expect the input string describing the attribute to be
2181: !!!!!!
1.1 cvs 2182: ----------------------------------------------------------------------*/
1.79 cvs 2183: static char *ParseCSSFont (Element element, PSchema tsch,
2184: PresentationContext context, char *cssRule,
2185: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2186: {
1.79 cvs 2187: char *ptr;
1.93 vatton 2188: int skippedNL;
1.1 cvs 2189:
1.82 cvs 2190: cssRule = SkipBlanksAndComments (cssRule);
2191: if (!strncasecmp (cssRule, "caption", 7))
1.1 cvs 2192: ;
1.82 cvs 2193: else if (!strncasecmp (cssRule, "icon", 4))
1.1 cvs 2194: ;
1.82 cvs 2195: else if (!strncasecmp (cssRule, "menu", 4))
1.1 cvs 2196: ;
1.82 cvs 2197: else if (!strncasecmp (cssRule, "message-box", 11))
1.1 cvs 2198: ;
1.82 cvs 2199: else if (!strncasecmp (cssRule, "small-caption", 13))
1.1 cvs 2200: ;
1.82 cvs 2201: else if (!strncasecmp (cssRule, "status-bar", 10))
1.1 cvs 2202: ;
2203: else
1.43 cvs 2204: {
1.133 vatton 2205: while (*cssRule != ';' && *cssRule != EOS)
1.43 cvs 2206: {
1.72 cvs 2207: ptr = cssRule;
1.93 vatton 2208: skippedNL = NewLineSkipped;
1.72 cvs 2209: cssRule = ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML);
2210: if (ptr == cssRule)
1.93 vatton 2211: {
2212: NewLineSkipped = skippedNL;
2213: cssRule = ParseCSSFontVariant (element, tsch, context, cssRule, css, isHTML);
2214: }
1.72 cvs 2215: if (ptr == cssRule)
1.93 vatton 2216: {
2217: NewLineSkipped = skippedNL;
2218: cssRule = ParseCSSFontWeight (element, tsch, context, cssRule, css, isHTML);
2219: }
1.72 cvs 2220: if (ptr == cssRule)
1.93 vatton 2221: {
2222: NewLineSkipped = skippedNL;
2223: cssRule = ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML);
2224: }
1.72 cvs 2225: if (ptr == cssRule)
1.93 vatton 2226: {
2227: NewLineSkipped = skippedNL;
2228: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
2229: }
1.99 vatton 2230: if (ptr == cssRule)
1.168 vatton 2231: cssRule = SkipValue ("Invalid font value", cssRule);
1.82 cvs 2232: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2233: }
2234: }
2235: return (cssRule);
1.1 cvs 2236: }
2237:
2238: /*----------------------------------------------------------------------
1.59 cvs 2239: ParseCSSTextDecoration: parse a CSS text decor string
2240: we expect the input string describing the attribute to be
1.109 cvs 2241: underline, overline, line-through, blink or none.
1.1 cvs 2242: ----------------------------------------------------------------------*/
1.79 cvs 2243: static char *ParseCSSTextDecoration (Element element, PSchema tsch,
2244: PresentationContext context, char *cssRule,
2245: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2246: {
2247: PresentationValue decor;
2248:
2249: decor.typed_data.value = 0;
1.184 vatton 2250: decor.typed_data.unit = UNIT_REL;
1.1 cvs 2251: decor.typed_data.real = FALSE;
1.82 cvs 2252: cssRule = SkipBlanksAndComments (cssRule);
1.211 vatton 2253: if (!strncasecmp (cssRule, "none", 4))
1.142 quint 2254: {
2255: decor.typed_data.value = NoUnderline;
2256: cssRule = SkipWord (cssRule);
2257: }
1.211 vatton 2258: else if (!strncasecmp (cssRule, "underline", 9))
1.1 cvs 2259: {
2260: decor.typed_data.value = Underline;
2261: cssRule = SkipWord (cssRule);
2262: }
1.211 vatton 2263: else if (!strncasecmp (cssRule, "overline", 8))
1.1 cvs 2264: {
2265: decor.typed_data.value = Overline;
2266: cssRule = SkipWord (cssRule);
2267: }
1.211 vatton 2268: else if (!strncasecmp (cssRule, "line-through", 12))
1.1 cvs 2269: {
2270: decor.typed_data.value = CrossOut;
2271: cssRule = SkipWord (cssRule);
2272: }
1.211 vatton 2273: else if (!strncasecmp (cssRule, "blink", 5))
1.1 cvs 2274: {
1.109 cvs 2275: /* the blink text-decoration attribute is not supported */
1.1 cvs 2276: cssRule = SkipWord (cssRule);
2277: }
1.142 quint 2278: else if (!strncasecmp (cssRule, "inherit", 7))
1.1 cvs 2279: {
1.142 quint 2280: cssRule = SkipWord (cssRule);
2281: return (cssRule);
1.1 cvs 2282: }
2283: else
2284: {
1.211 vatton 2285: cssRule = SkipValue ("Invalid text-decoration value", cssRule);
2286: return (cssRule);
1.1 cvs 2287: }
2288:
2289: /*
2290: * install the new presentation.
2291: */
1.116 vatton 2292: if (decor.typed_data.value && DoApply)
1.1 cvs 2293: {
1.117 vatton 2294: if (tsch)
2295: cssRule = CheckImportantRule (cssRule, context);
1.1 cvs 2296: TtaSetStylePresentation (PRUnderline, element, tsch, context, decor);
2297: }
2298: return (cssRule);
2299: }
2300:
2301: /*----------------------------------------------------------------------
1.59 cvs 2302: ParseCSSHeight: parse a CSS height attribute
1.1 cvs 2303: ----------------------------------------------------------------------*/
1.79 cvs 2304: static char *ParseCSSHeight (Element element, PSchema tsch,
1.93 vatton 2305: PresentationContext context, char *cssRule,
2306: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2307: {
1.117 vatton 2308: PresentationValue val;
1.168 vatton 2309: char *ptr;
1.93 vatton 2310:
1.117 vatton 2311: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2312: ptr = cssRule;
1.117 vatton 2313: /* first parse the attribute string */
1.164 quint 2314: if (!strncasecmp (cssRule, "auto", 4))
2315: {
1.184 vatton 2316: val.typed_data.unit = VALUE_AUTO;
1.164 quint 2317: val.typed_data.value = 0;
2318: val.typed_data.real = FALSE;
2319: cssRule = SkipWord (cssRule);
2320: }
1.117 vatton 2321: else
1.168 vatton 2322: cssRule = ParseCSSUnit (cssRule, &val);
2323: if (val.typed_data.value != 0 &&
1.184 vatton 2324: (val.typed_data.unit == UNIT_INVALID ||
2325: val.typed_data.unit == UNIT_BOX))
1.211 vatton 2326: {
2327: CSSParseError ("height value", ptr, cssRule);
1.212 cvs 2328: val.typed_data.unit = UNIT_PX;
1.211 vatton 2329: }
2330: if (DoApply)
1.117 vatton 2331: {
1.164 quint 2332: if (tsch)
2333: cssRule = CheckImportantRule (cssRule, context);
2334: /* install the new presentation */
2335: TtaSetStylePresentation (PRHeight, element, tsch, context, val);
1.117 vatton 2336: }
2337: return (cssRule);
1.1 cvs 2338: }
2339:
2340: /*----------------------------------------------------------------------
1.59 cvs 2341: ParseCSSWidth: parse a CSS width attribute
1.1 cvs 2342: ----------------------------------------------------------------------*/
1.79 cvs 2343: static char *ParseCSSWidth (Element element, PSchema tsch,
1.78 cvs 2344: PresentationContext context,
1.79 cvs 2345: char *cssRule, CSSInfoPtr css,
1.78 cvs 2346: ThotBool isHTML)
1.1 cvs 2347: {
1.117 vatton 2348: PresentationValue val;
1.168 vatton 2349: char *ptr;
1.93 vatton 2350:
1.117 vatton 2351: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2352: ptr = cssRule;
1.117 vatton 2353: /* first parse the attribute string */
1.164 quint 2354: if (!strncasecmp (cssRule, "auto", 4))
2355: {
1.184 vatton 2356: val.typed_data.unit = VALUE_AUTO;
1.164 quint 2357: val.typed_data.value = 0;
2358: val.typed_data.real = FALSE;
2359: cssRule = SkipWord (cssRule);
2360: }
1.117 vatton 2361: else
1.164 quint 2362: cssRule = ParseCSSUnit (cssRule, &val);
1.168 vatton 2363: if (val.typed_data.value != 0 &&
1.184 vatton 2364: (val.typed_data.unit == UNIT_INVALID ||
2365: val.typed_data.unit == UNIT_BOX))
1.211 vatton 2366: {
2367: CSSParseError ("Invalid width value", ptr, cssRule);
1.212 cvs 2368: val.typed_data.unit = UNIT_PX;
1.211 vatton 2369: }
2370: if (DoApply)
1.117 vatton 2371: {
1.164 quint 2372: if (tsch)
2373: cssRule = CheckImportantRule (cssRule, context);
2374: /* install the new presentation */
2375: TtaSetStylePresentation (PRWidth, element, tsch, context, val);
1.117 vatton 2376: }
2377: return (cssRule);
1.1 cvs 2378: }
2379:
2380: /*----------------------------------------------------------------------
1.59 cvs 2381: ParseCSSMarginTop: parse a CSS margin-top attribute
1.1 cvs 2382: ----------------------------------------------------------------------*/
1.79 cvs 2383: static char *ParseCSSMarginTop (Element element, PSchema tsch,
1.78 cvs 2384: PresentationContext context,
1.79 cvs 2385: char *cssRule, CSSInfoPtr css,
1.78 cvs 2386: ThotBool isHTML)
1.1 cvs 2387: {
2388: PresentationValue margin;
1.168 vatton 2389: char *ptr;
1.1 cvs 2390:
1.82 cvs 2391: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2392: ptr = cssRule;
1.1 cvs 2393: /* first parse the attribute string */
1.164 quint 2394: if (!strncasecmp (cssRule, "auto", 4))
2395: {
1.184 vatton 2396: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2397: margin.typed_data.value = 0;
2398: margin.typed_data.real = FALSE;
2399: cssRule = SkipWord (cssRule);
2400: }
2401: else
1.168 vatton 2402: cssRule = ParseCSSUnit (cssRule, &margin);
2403: if (margin.typed_data.value != 0 &&
1.184 vatton 2404: (margin.typed_data.unit == UNIT_INVALID ||
2405: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2406: CSSParseError ("Invalid margin-top value", ptr, cssRule);
1.168 vatton 2407: else if (DoApply)
1.117 vatton 2408: {
2409: if (tsch)
2410: cssRule = CheckImportantRule (cssRule, context);
2411: TtaSetStylePresentation (PRMarginTop, element, tsch, context, margin);
2412: }
1.1 cvs 2413: return (cssRule);
2414: }
2415:
2416: /*----------------------------------------------------------------------
1.59 cvs 2417: ParseCSSMarginBottom: parse a CSS margin-bottom attribute
1.1 cvs 2418: ----------------------------------------------------------------------*/
1.79 cvs 2419: static char *ParseCSSMarginBottom (Element element, PSchema tsch,
1.78 cvs 2420: PresentationContext context,
1.79 cvs 2421: char *cssRule, CSSInfoPtr css,
1.78 cvs 2422: ThotBool isHTML)
1.1 cvs 2423: {
2424: PresentationValue margin;
1.168 vatton 2425: char *ptr;
1.1 cvs 2426:
1.82 cvs 2427: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2428: ptr = cssRule;
1.1 cvs 2429: /* first parse the attribute string */
1.164 quint 2430: if (!strncasecmp (cssRule, "auto", 4))
2431: {
1.184 vatton 2432: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2433: margin.typed_data.value = 0;
2434: margin.typed_data.real = FALSE;
2435: cssRule = SkipWord (cssRule);
2436: }
2437: else
1.168 vatton 2438: cssRule = ParseCSSUnit (cssRule, &margin);
2439: if (margin.typed_data.value != 0 &&
1.184 vatton 2440: (margin.typed_data.unit == UNIT_INVALID ||
2441: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2442: CSSParseError ("Invalid margin-bottom value", ptr, cssRule);
1.168 vatton 2443: else if (DoApply)
1.117 vatton 2444: {
2445: if (tsch)
2446: cssRule = CheckImportantRule (cssRule, context);
2447: TtaSetStylePresentation (PRMarginBottom, element, tsch, context, margin);
2448: }
1.1 cvs 2449: return (cssRule);
2450: }
2451:
2452: /*----------------------------------------------------------------------
1.59 cvs 2453: ParseCSSMarginLeft: parse a CSS margin-left attribute string
1.1 cvs 2454: ----------------------------------------------------------------------*/
1.79 cvs 2455: static char *ParseCSSMarginLeft (Element element, PSchema tsch,
1.78 cvs 2456: PresentationContext context,
1.79 cvs 2457: char *cssRule, CSSInfoPtr css,
1.78 cvs 2458: ThotBool isHTML)
1.1 cvs 2459: {
2460: PresentationValue margin;
1.168 vatton 2461: char *ptr;
1.1 cvs 2462:
1.82 cvs 2463: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2464: ptr = cssRule;
1.1 cvs 2465: /* first parse the attribute string */
1.164 quint 2466: if (!strncasecmp (cssRule, "auto", 4))
2467: {
1.184 vatton 2468: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2469: margin.typed_data.value = 0;
2470: margin.typed_data.real = FALSE;
2471: cssRule = SkipWord (cssRule);
2472: }
2473: else
1.168 vatton 2474: cssRule = ParseCSSUnit (cssRule, &margin);
2475: if (margin.typed_data.value != 0 &&
1.184 vatton 2476: (margin.typed_data.unit == UNIT_INVALID ||
2477: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2478: CSSParseError ("Invalid margin-left value", ptr, cssRule);
1.168 vatton 2479: else if (DoApply)
1.184 vatton 2480: if (margin.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 2481: {
2482: if (tsch)
2483: cssRule = CheckImportantRule (cssRule, context);
2484: TtaSetStylePresentation (PRMarginLeft, element, tsch, context, margin);
2485: }
1.1 cvs 2486: return (cssRule);
2487: }
2488:
2489: /*----------------------------------------------------------------------
1.59 cvs 2490: ParseCSSMarginRight: parse a CSS margin-right attribute string
1.1 cvs 2491: ----------------------------------------------------------------------*/
1.79 cvs 2492: static char *ParseCSSMarginRight (Element element, PSchema tsch,
1.78 cvs 2493: PresentationContext context,
1.79 cvs 2494: char *cssRule, CSSInfoPtr css,
1.78 cvs 2495: ThotBool isHTML)
1.1 cvs 2496: {
2497: PresentationValue margin;
1.168 vatton 2498: char *ptr;
1.1 cvs 2499:
1.82 cvs 2500: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2501: ptr = cssRule;
1.1 cvs 2502: /* first parse the attribute string */
1.164 quint 2503: if (!strncasecmp (cssRule, "auto", 4))
2504: {
1.184 vatton 2505: margin.typed_data.unit = VALUE_AUTO;
1.164 quint 2506: margin.typed_data.value = 0;
2507: margin.typed_data.real = FALSE;
2508: cssRule = SkipWord (cssRule);
2509: }
2510: else
1.168 vatton 2511: cssRule = ParseCSSUnit (cssRule, &margin);
2512: if (margin.typed_data.value != 0 &&
1.184 vatton 2513: (margin.typed_data.unit == UNIT_INVALID ||
2514: margin.typed_data.unit == UNIT_BOX))
1.169 vatton 2515: CSSParseError ("Invalid margin-right value", ptr, cssRule);
1.168 vatton 2516: else if (DoApply)
1.117 vatton 2517: {
2518: if (tsch)
2519: cssRule = CheckImportantRule (cssRule, context);
2520: TtaSetStylePresentation (PRMarginRight, element, tsch, context, margin);
2521: }
1.1 cvs 2522: return (cssRule);
2523: }
2524:
2525: /*----------------------------------------------------------------------
1.59 cvs 2526: ParseCSSMargin: parse a CSS margin attribute string
1.1 cvs 2527: ----------------------------------------------------------------------*/
1.79 cvs 2528: static char *ParseCSSMargin (Element element, PSchema tsch,
1.78 cvs 2529: PresentationContext context,
1.79 cvs 2530: char *cssRule, CSSInfoPtr css,
1.78 cvs 2531: ThotBool isHTML)
1.1 cvs 2532: {
1.79 cvs 2533: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 2534: int skippedNL;
1.1 cvs 2535:
1.82 cvs 2536: ptrT = SkipBlanksAndComments (cssRule);
1.1 cvs 2537: /* First parse Margin-Top */
2538: ptrR = ParseCSSMarginTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 2539: ptrR = SkipBlanksAndComments (ptrR);
2540: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.1 cvs 2541: {
1.93 vatton 2542: skippedNL = NewLineSkipped;
1.1 cvs 2543: cssRule = ptrR;
2544: /* apply the Margin-Top to all */
2545: ptrR = ParseCSSMarginRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2546: NewLineSkipped = skippedNL;
1.1 cvs 2547: ptrR = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2548: NewLineSkipped = skippedNL;
1.1 cvs 2549: ptrR = ParseCSSMarginLeft (element, tsch, context, ptrT, css, isHTML);
2550: }
2551: else
2552: {
2553: /* parse Margin-Right */
2554: ptrB = ParseCSSMarginRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 2555: ptrB = SkipBlanksAndComments (ptrB);
2556: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.1 cvs 2557: {
1.93 vatton 2558: skippedNL = NewLineSkipped;
1.1 cvs 2559: cssRule = ptrB;
2560: /* apply the Margin-Top to Margin-Bottom */
2561: ptrB = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2562: NewLineSkipped = skippedNL;
1.1 cvs 2563: /* apply the Margin-Right to Margin-Left */
2564: ptrB = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2565: }
2566: else
2567: {
2568: /* parse Margin-Bottom */
2569: ptrL = ParseCSSMarginBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 2570: ptrL = SkipBlanksAndComments (ptrL);
2571: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.1 cvs 2572: {
2573: cssRule = ptrL;
2574: /* apply the Margin-Right to Margin-Left */
2575: ptrL = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2576: }
2577: else
2578: /* parse Margin-Left */
2579: cssRule = ParseCSSMarginLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 2580: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 2581: }
2582: }
2583: return (cssRule);
2584: }
2585:
2586: /*----------------------------------------------------------------------
1.59 cvs 2587: ParseCSSPaddingTop: parse a CSS PaddingTop attribute string
1.1 cvs 2588: ----------------------------------------------------------------------*/
1.79 cvs 2589: static char *ParseCSSPaddingTop (Element element, PSchema tsch,
1.78 cvs 2590: PresentationContext context,
1.79 cvs 2591: char *cssRule, CSSInfoPtr css,
1.78 cvs 2592: ThotBool isHTML)
1.1 cvs 2593: {
1.43 cvs 2594: PresentationValue padding;
1.168 vatton 2595: char *ptr;
1.43 cvs 2596:
1.82 cvs 2597: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2598: ptr = cssRule;
1.43 cvs 2599: /* first parse the attribute string */
2600: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2601: if (padding.typed_data.value != 0 &&
1.184 vatton 2602: (padding.typed_data.unit == UNIT_INVALID ||
2603: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2604: {
1.169 vatton 2605: CSSParseError ("Invalid padding-top value", ptr, cssRule);
1.168 vatton 2606: padding.typed_data.value = 0;
2607: }
2608: else if (DoApply)
1.117 vatton 2609: {
2610: if (tsch)
2611: cssRule = CheckImportantRule (cssRule, context);
2612: TtaSetStylePresentation (PRPaddingTop, element, tsch, context, padding);
2613: }
1.1 cvs 2614: return (cssRule);
2615: }
2616:
2617: /*----------------------------------------------------------------------
1.59 cvs 2618: ParseCSSPaddingBottom: parse a CSS PaddingBottom attribute string
1.1 cvs 2619: ----------------------------------------------------------------------*/
1.79 cvs 2620: static char *ParseCSSPaddingBottom (Element element, PSchema tsch,
1.78 cvs 2621: PresentationContext context,
1.79 cvs 2622: char *cssRule, CSSInfoPtr css,
1.78 cvs 2623: ThotBool isHTML)
1.1 cvs 2624: {
1.43 cvs 2625: PresentationValue padding;
1.168 vatton 2626: char *ptr;
1.43 cvs 2627:
1.82 cvs 2628: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2629: ptr = cssRule;
1.43 cvs 2630: /* first parse the attribute string */
2631: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2632: if (padding.typed_data.value == 0)
1.184 vatton 2633: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2634: if (padding.typed_data.value != 0 &&
1.184 vatton 2635: (padding.typed_data.unit == UNIT_INVALID ||
2636: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2637: {
1.169 vatton 2638: CSSParseError ("Invalid padding-bottom value", ptr, cssRule);
1.168 vatton 2639: padding.typed_data.value = 0;
2640: }
2641: else if (DoApply)
1.117 vatton 2642: {
2643: if (tsch)
2644: cssRule = CheckImportantRule (cssRule, context);
2645: TtaSetStylePresentation (PRPaddingBottom, element, tsch, context, padding);
2646: }
1.1 cvs 2647: return (cssRule);
2648: }
2649:
2650: /*----------------------------------------------------------------------
1.59 cvs 2651: ParseCSSPaddingLeft: parse a CSS PaddingLeft attribute string.
1.1 cvs 2652: ----------------------------------------------------------------------*/
1.79 cvs 2653: static char *ParseCSSPaddingLeft (Element element, PSchema tsch,
1.78 cvs 2654: PresentationContext context,
1.79 cvs 2655: char *cssRule, CSSInfoPtr css,
1.78 cvs 2656: ThotBool isHTML)
1.1 cvs 2657: {
1.43 cvs 2658: PresentationValue padding;
1.168 vatton 2659: char *ptr;
1.43 cvs 2660:
1.82 cvs 2661: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2662: ptr = cssRule;
1.43 cvs 2663: /* first parse the attribute string */
2664: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2665: if (padding.typed_data.value == 0)
1.184 vatton 2666: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2667: if (padding.typed_data.value != 0 &&
1.184 vatton 2668: (padding.typed_data.unit == UNIT_INVALID ||
2669: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2670: {
1.169 vatton 2671: CSSParseError ("Invalid padding-left value", ptr, cssRule);
1.168 vatton 2672: padding.typed_data.value = 0;
2673: }
2674: else if (DoApply)
1.117 vatton 2675: {
2676: if (tsch)
2677: cssRule = CheckImportantRule (cssRule, context);
1.43 cvs 2678: TtaSetStylePresentation (PRPaddingLeft, element, tsch, context, padding);
1.117 vatton 2679: }
1.1 cvs 2680: return (cssRule);
2681: }
2682:
2683: /*----------------------------------------------------------------------
1.59 cvs 2684: ParseCSSPaddingRight: parse a CSS PaddingRight attribute string.
1.1 cvs 2685: ----------------------------------------------------------------------*/
1.79 cvs 2686: static char *ParseCSSPaddingRight (Element element, PSchema tsch,
1.78 cvs 2687: PresentationContext context,
1.79 cvs 2688: char *cssRule, CSSInfoPtr css,
1.78 cvs 2689: ThotBool isHTML)
1.1 cvs 2690: {
1.43 cvs 2691: PresentationValue padding;
1.168 vatton 2692: char *ptr;
1.43 cvs 2693:
1.82 cvs 2694: cssRule = SkipBlanksAndComments (cssRule);
1.168 vatton 2695: ptr = cssRule;
1.43 cvs 2696: /* first parse the attribute string */
2697: cssRule = ParseCSSUnit (cssRule, &padding);
1.168 vatton 2698: if (padding.typed_data.value == 0)
1.184 vatton 2699: padding.typed_data.unit = UNIT_EM;
1.168 vatton 2700: if (padding.typed_data.value != 0 &&
1.184 vatton 2701: (padding.typed_data.unit == UNIT_INVALID ||
2702: padding.typed_data.unit == UNIT_BOX))
1.168 vatton 2703: {
1.169 vatton 2704: CSSParseError ("Invalid padding-right value", ptr, cssRule);
1.168 vatton 2705: padding.typed_data.value = 0;
2706: }
2707: else if (DoApply)
1.117 vatton 2708: {
2709: if (tsch)
2710: cssRule = CheckImportantRule (cssRule, context);
1.43 cvs 2711: TtaSetStylePresentation (PRPaddingRight, element, tsch, context, padding);
1.117 vatton 2712: }
1.1 cvs 2713: return (cssRule);
2714: }
2715:
2716: /*----------------------------------------------------------------------
1.59 cvs 2717: ParseCSSPadding: parse a CSS padding attribute string.
1.1 cvs 2718: ----------------------------------------------------------------------*/
1.79 cvs 2719: static char *ParseCSSPadding (Element element, PSchema tsch,
1.78 cvs 2720: PresentationContext context,
1.79 cvs 2721: char *cssRule, CSSInfoPtr css,
1.78 cvs 2722: ThotBool isHTML)
1.1 cvs 2723: {
1.79 cvs 2724: char *ptrT, *ptrR, *ptrB, *ptrL;
1.93 vatton 2725: int skippedNL;
1.43 cvs 2726:
1.82 cvs 2727: ptrT = SkipBlanksAndComments (cssRule);
1.43 cvs 2728: /* First parse Padding-Top */
2729: ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
1.82 cvs 2730: ptrR = SkipBlanksAndComments (ptrR);
2731: if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
1.43 cvs 2732: {
1.93 vatton 2733: skippedNL = NewLineSkipped;
1.43 cvs 2734: cssRule = ptrR;
2735: /* apply the Padding-Top to all */
2736: ptrR = ParseCSSPaddingRight (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2737: NewLineSkipped = skippedNL;
1.43 cvs 2738: ptrR = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2739: NewLineSkipped = skippedNL;
1.43 cvs 2740: ptrR = ParseCSSPaddingLeft (element, tsch, context, ptrT, css, isHTML);
2741: }
2742: else
2743: {
2744: /* parse Padding-Right */
2745: ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);
1.82 cvs 2746: ptrB = SkipBlanksAndComments (ptrB);
2747: if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
1.43 cvs 2748: {
1.93 vatton 2749: skippedNL = NewLineSkipped;
1.43 cvs 2750: cssRule = ptrB;
2751: /* apply the Padding-Top to Padding-Bottom */
2752: ptrB = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
1.93 vatton 2753: NewLineSkipped = skippedNL;
1.43 cvs 2754: /* apply the Padding-Right to Padding-Left */
2755: ptrB = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2756: }
2757: else
2758: {
2759: /* parse Padding-Bottom */
2760: ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);
1.82 cvs 2761: ptrL = SkipBlanksAndComments (ptrL);
2762: if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
1.43 cvs 2763: {
2764: cssRule = ptrL;
2765: /* apply the Padding-Right to Padding-Left */
2766: ptrL = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2767: }
2768: else
2769: /* parse Padding-Left */
2770: cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);
1.82 cvs 2771: cssRule = SkipBlanksAndComments (cssRule);
1.43 cvs 2772: }
2773: }
1.1 cvs 2774: return (cssRule);
2775: }
2776:
2777: /*----------------------------------------------------------------------
1.59 cvs 2778: ParseCSSForeground: parse a CSS foreground attribute
1.1 cvs 2779: ----------------------------------------------------------------------*/
1.79 cvs 2780: static char *ParseCSSForeground (Element element, PSchema tsch,
1.78 cvs 2781: PresentationContext context,
1.79 cvs 2782: char *cssRule,
1.78 cvs 2783: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2784: {
1.117 vatton 2785: PresentationValue best;
1.1 cvs 2786:
1.117 vatton 2787: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2788: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 2789: {
2790: if (tsch)
2791: cssRule = CheckImportantRule (cssRule, context);
2792: /* install the new presentation */
2793: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2794: }
1.1 cvs 2795: return (cssRule);
2796: }
2797:
2798: /*----------------------------------------------------------------------
1.59 cvs 2799: ParseCSSBackgroundColor: parse a CSS background color attribute
1.1 cvs 2800: ----------------------------------------------------------------------*/
1.79 cvs 2801: static char *ParseCSSBackgroundColor (Element element, PSchema tsch,
1.78 cvs 2802: PresentationContext context,
1.79 cvs 2803: char *cssRule,
1.78 cvs 2804: CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2805: {
2806: PresentationValue best;
2807:
1.184 vatton 2808: best.typed_data.unit = UNIT_INVALID;
1.1 cvs 2809: best.typed_data.real = FALSE;
1.198 vatton 2810: if (!strncasecmp (cssRule, "transparent", 11))
1.1 cvs 2811: {
1.184 vatton 2812: best.typed_data.value = PATTERN_NONE;
2813: best.typed_data.unit = UNIT_REL;
1.116 vatton 2814: if (DoApply)
1.117 vatton 2815: {
2816: if (tsch)
2817: cssRule = CheckImportantRule (cssRule, context);
2818: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2819: }
1.65 cvs 2820: cssRule = SkipWord (cssRule);
1.1 cvs 2821: }
2822: else
2823: {
2824: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2825: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.1 cvs 2826: {
1.117 vatton 2827: if (tsch)
2828: cssRule = CheckImportantRule (cssRule, context);
1.1 cvs 2829: /* install the new presentation. */
2830: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
1.59 cvs 2831: /* thot specificity: need to set fill pattern for background color */
1.184 vatton 2832: best.typed_data.value = PATTERN_BACKGROUND;
2833: best.typed_data.unit = UNIT_REL;
1.1 cvs 2834: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2835: best.typed_data.value = 1;
1.184 vatton 2836: best.typed_data.unit = UNIT_REL;
1.1 cvs 2837: TtaSetStylePresentation (PRShowBox, element, tsch, context, best);
2838: }
2839: }
2840: return (cssRule);
2841: }
2842:
1.63 cvs 2843: /*----------------------------------------------------------------------
1.65 cvs 2844: ParseSVGStroke: parse a SVG stroke property
2845: ----------------------------------------------------------------------*/
1.79 cvs 2846: static char *ParseSVGStroke (Element element, PSchema tsch,
2847: PresentationContext context, char *cssRule,
2848: CSSInfoPtr css, ThotBool isHTML)
1.65 cvs 2849: {
2850: PresentationValue best;
2851:
1.184 vatton 2852: best.typed_data.unit = UNIT_INVALID;
1.65 cvs 2853: best.typed_data.real = FALSE;
1.82 cvs 2854: if (!strncasecmp (cssRule, "none", 4))
1.65 cvs 2855: {
2856: best.typed_data.value = -2; /* -2 means transparent */
1.184 vatton 2857: best.typed_data.unit = UNIT_REL;
1.116 vatton 2858: if (DoApply)
1.117 vatton 2859: {
2860: if (tsch)
2861: cssRule = CheckImportantRule (cssRule, context);
2862: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2863: }
1.65 cvs 2864: cssRule = SkipWord (cssRule);
2865: }
2866: else
2867: {
2868: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2869: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 2870: {
2871: if (tsch)
2872: cssRule = CheckImportantRule (cssRule, context);
2873: /* install the new presentation */
2874: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2875: }
1.65 cvs 2876: }
2877: return (cssRule);
2878: }
2879:
2880: /*----------------------------------------------------------------------
1.63 cvs 2881: ParseSVGFill: parse a SVG fill property
2882: ----------------------------------------------------------------------*/
1.79 cvs 2883: static char *ParseSVGFill (Element element, PSchema tsch,
2884: PresentationContext context, char *cssRule,
2885: CSSInfoPtr css, ThotBool isHTML)
1.63 cvs 2886: {
2887: PresentationValue best;
2888:
1.184 vatton 2889: best.typed_data.unit = UNIT_INVALID;
1.63 cvs 2890: best.typed_data.real = FALSE;
1.82 cvs 2891: if (!strncasecmp (cssRule, "none", 4))
1.63 cvs 2892: {
1.184 vatton 2893: best.typed_data.value = PATTERN_NONE;
2894: best.typed_data.unit = UNIT_REL;
1.116 vatton 2895: if (DoApply)
1.117 vatton 2896: {
2897: if (tsch)
2898: cssRule = CheckImportantRule (cssRule, context);
2899: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2900: }
1.65 cvs 2901: cssRule = SkipWord (cssRule);
1.63 cvs 2902: }
2903: else
2904: {
2905: cssRule = ParseCSSColor (cssRule, &best);
1.184 vatton 2906: if (best.typed_data.unit != UNIT_INVALID && DoApply)
1.63 cvs 2907: {
1.117 vatton 2908: if (tsch)
2909: cssRule = CheckImportantRule (cssRule, context);
1.63 cvs 2910: /* install the new presentation. */
2911: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
2912: /* thot specificity: need to set fill pattern for background color */
1.184 vatton 2913: best.typed_data.value = PATTERN_BACKGROUND;
2914: best.typed_data.unit = UNIT_REL;
1.63 cvs 2915: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2916: }
2917: }
2918: return (cssRule);
2919: }
1.161 quint 2920:
1.155 cheyroul 2921: /*----------------------------------------------------------------------
2922: ParseSVGOpacity: parse a SVG fill property
2923: ----------------------------------------------------------------------*/
2924: static char *ParseSVGOpacity (Element element, PSchema tsch,
2925: PresentationContext context, char *cssRule,
2926: CSSInfoPtr css, ThotBool isHTML)
2927: {
2928: PresentationValue best;
1.63 cvs 2929:
1.184 vatton 2930: best.typed_data.unit = UNIT_INVALID;
1.155 cheyroul 2931: best.typed_data.real = FALSE;
2932: cssRule = ParseClampedUnit (cssRule, &best);
2933: if (DoApply)
2934: {
2935: if (tsch)
2936: cssRule = CheckImportantRule (cssRule, context);
2937: /* install the new presentation. */
2938: TtaSetStylePresentation (PROpacity, element,
2939: tsch, context, best);
2940: }
2941: return (cssRule);
2942: }
1.170 cheyroul 2943: /*----------------------------------------------------------------------
2944: ParseSVGOpacity: parse a SVG fill property
2945: ----------------------------------------------------------------------*/
2946: static char *ParseSVGStrokeOpacity (Element element, PSchema tsch,
2947: PresentationContext context, char *cssRule,
2948: CSSInfoPtr css, ThotBool isHTML)
2949: {
2950: PresentationValue best;
1.161 quint 2951:
1.184 vatton 2952: best.typed_data.unit = UNIT_INVALID;
1.170 cheyroul 2953: best.typed_data.real = FALSE;
2954: cssRule = ParseClampedUnit (cssRule, &best);
2955: if (DoApply)
2956: {
2957: if (tsch)
2958: cssRule = CheckImportantRule (cssRule, context);
2959: /* install the new presentation. */
2960: TtaSetStylePresentation (PRStrokeOpacity, element,
2961: tsch, context, best);
2962: }
2963: return (cssRule);
2964: }
2965: /*----------------------------------------------------------------------
2966: ParseSVGOpacity: parse a SVG fill property
2967: ----------------------------------------------------------------------*/
2968: static char *ParseSVGFillOpacity (Element element, PSchema tsch,
2969: PresentationContext context, char *cssRule,
2970: CSSInfoPtr css, ThotBool isHTML)
2971: {
2972: PresentationValue best;
2973:
1.184 vatton 2974: best.typed_data.unit = UNIT_INVALID;
1.170 cheyroul 2975: best.typed_data.real = FALSE;
2976: cssRule = ParseClampedUnit (cssRule, &best);
2977: if (DoApply)
2978: {
2979: if (tsch)
2980: cssRule = CheckImportantRule (cssRule, context);
2981: /* install the new presentation. */
2982: TtaSetStylePresentation (PRFillOpacity, element,
2983: tsch, context, best);
2984: }
2985: return (cssRule);
2986: }
1.207 vatton 2987:
1.1 cvs 2988: /*----------------------------------------------------------------------
1.59 cvs 2989: ParseCSSBackgroundImageCallback: Callback called asynchronously by
2990: FetchImage when a background image has been fetched.
1.1 cvs 2991: ----------------------------------------------------------------------*/
1.82 cvs 2992: void ParseCSSBackgroundImageCallback (Document doc, Element element,
1.203 vatton 2993: char *file, void *extra,
2994: ThotBool isnew)
1.1 cvs 2995: {
1.82 cvs 2996: DisplayMode dispMode;
2997: BackgroundImageCallbackPtr callblock;
2998: Element el;
2999: PSchema tsch;
1.185 vatton 3000: CSSInfoPtr css;
1.206 vatton 3001: PInfoPtr pInfo;
1.207 vatton 3002: PresentationContext ctxt;
1.82 cvs 3003: PresentationValue image;
3004: PresentationValue value;
1.206 vatton 3005: ThotBool enabled;
1.82 cvs 3006: callblock = (BackgroundImageCallbackPtr) extra;
1.34 cvs 3007: if (callblock == NULL)
3008: return;
1.1 cvs 3009:
1.188 cheyroul 3010: css = NULL;
1.34 cvs 3011: el = callblock->el;
3012: tsch = callblock->tsch;
1.207 vatton 3013: ctxt = callblock->ctxt;
1.203 vatton 3014: if (doc == 0 && !isnew)
3015: /* apply to the current document only */
1.207 vatton 3016: doc = ctxt->doc;
1.185 vatton 3017: if (doc)
3018: {
3019: /* avoid too many redisplay */
3020: dispMode = TtaGetDisplayMode (doc);
3021: if (dispMode == DisplayImmediately)
3022: TtaSetDisplayMode (doc, DeferredDisplay);
3023: }
3024: else
3025: {
3026: /* check if the CSS still exists */
3027: css = CSSList;
3028: while (css && css != callblock->css)
3029: css = css->NextCSS;
3030: if (css == NULL)
3031: tsch = NULL;
3032: }
1.34 cvs 3033:
1.185 vatton 3034: if (el || tsch)
3035: {
3036: /* Ok the image was fetched, finish the background-image handling */
1.193 vatton 3037: image.typed_data.unit = UNIT_REL;
3038: image.typed_data.real = FALSE;
1.185 vatton 3039: image.pointer = file;
1.207 vatton 3040: TtaSetStylePresentation (PRBackgroundPicture, el, tsch, ctxt, image);
1.185 vatton 3041:
3042: /* enforce the showbox */
3043: value.typed_data.value = 1;
3044: value.typed_data.unit = UNIT_REL;
3045: value.typed_data.real = FALSE;
1.207 vatton 3046: TtaSetStylePresentation (PRShowBox, el, tsch, ctxt, value);
3047: /* check if the context can be freed */
3048: ctxt->uses -= 1;
3049: if (ctxt->uses == 0)
3050: /* no other image loading */
3051: TtaFreeMemory (ctxt);
1.185 vatton 3052: }
1.34 cvs 3053:
3054: TtaFreeMemory (callblock);
3055: /* restore the display mode */
1.185 vatton 3056: if (doc)
3057: {
3058: if (dispMode == DisplayImmediately)
3059: TtaSetDisplayMode (doc, dispMode);
3060: }
3061: else if (css)
3062: {
3063: for (doc = 1; doc < DocumentTableLength; doc++)
1.206 vatton 3064: if (css->infos[doc] &&
1.185 vatton 3065: /* don't manage a document used by make book */
3066: (DocumentMeta[doc] == NULL ||
3067: DocumentMeta[doc]->method != CE_MAKEBOOK))
3068: {
1.206 vatton 3069: pInfo = css->infos[doc];
3070: enabled = FALSE;
3071: while (pInfo && !enabled)
3072: {
3073: enabled = pInfo->PiEnabled;
3074: pInfo = pInfo->PiNext;
3075: }
1.185 vatton 3076: /* Change the Display Mode to take into account the new presentation */
3077: dispMode = TtaGetDisplayMode (doc);
3078: if (dispMode == DisplayImmediately)
1.194 vatton 3079: {
3080: TtaSetDisplayMode (doc, NoComputedDisplay);
3081: /* Restore the display mode */
3082: TtaSetDisplayMode (doc, dispMode);
3083: }
1.185 vatton 3084: }
3085: }
1.1 cvs 3086: }
3087:
3088: /*----------------------------------------------------------------------
1.217 vatton 3089: ParseCSSUrl: parse an URL
1.1 cvs 3090: ----------------------------------------------------------------------*/
1.217 vatton 3091: static char *ParseCSSUrl (char *cssRule, char **url)
1.1 cvs 3092: {
1.217 vatton 3093: char saved;
3094: char *base, *ptr;
1.1 cvs 3095:
1.217 vatton 3096: cssRule = SkipBlanksAndComments (cssRule);
3097: if (*cssRule == '(')
3098: {
3099: cssRule++;
3100: cssRule = SkipBlanksAndComments (cssRule);
3101: /*** Escaped quotes are not handled. See function SkipQuotedString */
3102: if (*cssRule == '"')
3103: {
3104: cssRule++;
3105: base = cssRule;
3106: while (*cssRule != EOS && *cssRule != '"')
3107: cssRule++;
3108: }
3109: else if (*cssRule == '\'')
3110: {
3111: cssRule++;
3112: base = cssRule;
3113: while (*cssRule != EOS && *cssRule != '\'')
3114: cssRule++;
3115: }
3116: else
3117: {
3118: base = cssRule;
3119: while (*cssRule != EOS && *cssRule != ')')
3120: cssRule++;
3121: }
3122: /* keep the current position */
3123: ptr = cssRule;
3124: if (saved == ')')
3125: {
3126: /* remove extra spaces */
3127: if (cssRule[-1] == SPACE)
1.1 cvs 3128: {
1.217 vatton 3129: *cssRule = SPACE;
3130: cssRule--;
3131: while (cssRule[-1] == SPACE)
3132: cssRule--;
1.1 cvs 3133: }
3134: }
1.217 vatton 3135: saved = *cssRule;
3136: *cssRule = EOS;
3137: *url = TtaStrdup (base);
3138: *cssRule = saved;
3139: if (saved == '"' || saved == '\'')
3140: /* we need to skip the quote character and possible spaces */
3141: {
3142: cssRule++;
3143: cssRule = SkipBlanksAndComments (cssRule);
3144: }
3145: else
3146: cssRule = ptr;
1.1 cvs 3147: }
1.217 vatton 3148: cssRule++;
3149: return cssRule;
1.1 cvs 3150: }
3151:
1.217 vatton 3152: /*----------------------------------------------------------------------
3153: GetCSSBackgroundURL searches a CSS BackgroundImage url within
3154: the cssRule.
3155: Returns NULL or a new allocated url string.
3156: ----------------------------------------------------------------------*/
3157: char *GetCSSBackgroundURL (char *cssRule)
3158: {
3159: char *b, *url;
3160:
3161: url = NULL;
3162: b = strstr (cssRule, "url");
3163: if (b)
3164: b = ParseCSSUrl (url, &url);
3165: return (url);
3166: }
3167:
3168: /*----------------------------------------------------------------------
3169: ParseCSSContent: parse a CSS content value
3170: ----------------------------------------------------------------------*/
3171: static char *ParseCSSContent (Element element, PSchema tsch,
3172: PresentationContext context, char *cssRule,
3173: CSSInfoPtr css, ThotBool isHTML)
3174: {
3175: char *p, quoteChar, *url;
3176:
3177: cssRule = SkipBlanksAndComments (cssRule);
3178: p = cssRule;
3179: if (!strncasecmp (cssRule, "url", 3))
3180: {
3181: cssRule += 3;
3182: cssRule = ParseCSSUrl (cssRule, &url);
3183: TtaFreeMemory (url);
3184: }
3185: else if (*cssRule == '"' || *cssRule == '\'')
3186: {
3187: quoteChar = *cssRule;
3188: cssRule++;
3189: cssRule = SkipQuotedString (cssRule, quoteChar);
3190: }
3191: else
3192: cssRule = SkipValue ("Invalid content value", p);
3193: return (cssRule);
3194: }
1.1 cvs 3195:
3196: /*----------------------------------------------------------------------
1.59 cvs 3197: ParseCSSBackgroundImage: parse a CSS BackgroundImage attribute string.
1.1 cvs 3198: ----------------------------------------------------------------------*/
1.79 cvs 3199: static char *ParseCSSBackgroundImage (Element element, PSchema tsch,
1.207 vatton 3200: PresentationContext ctxt,
1.79 cvs 3201: char *cssRule, CSSInfoPtr css,
3202: ThotBool isHTML)
1.1 cvs 3203: {
1.49 cvs 3204: Element el;
1.1 cvs 3205: BackgroundImageCallbackPtr callblock;
1.49 cvs 3206: PresentationValue image, value;
1.79 cvs 3207: char *url;
1.82 cvs 3208: char *bg_image;
1.79 cvs 3209: char tempname[MAX_LENGTH];
3210: char imgname[MAX_LENGTH];
1.148 vatton 3211:
1.163 quint 3212: if (element)
1.148 vatton 3213: el = element;
1.163 quint 3214: else
3215: /* default element for FetchImage */
1.207 vatton 3216: el = TtaGetMainRoot (ctxt->doc);
1.163 quint 3217:
1.1 cvs 3218: url = NULL;
1.82 cvs 3219: cssRule = SkipBlanksAndComments (cssRule);
1.161 quint 3220: if (!strncasecmp (cssRule, "none", 4))
3221: {
3222: image.pointer = NULL;
1.207 vatton 3223: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, ctxt, image);
1.198 vatton 3224: cssRule += 4;
1.161 quint 3225: }
3226: else if (!strncasecmp (cssRule, "url", 3))
1.1 cvs 3227: {
3228: cssRule += 3;
1.217 vatton 3229: cssRule = ParseCSSUrl (cssRule, &url);
1.207 vatton 3230: if (ctxt->destroy)
1.1 cvs 3231: {
3232: /* remove the background image PRule */
3233: image.pointer = NULL;
1.207 vatton 3234: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, ctxt, image);
3235: if (TtaGetStylePresentation (PRFillPattern, element, tsch, ctxt, &value) < 0)
1.1 cvs 3236: {
3237: /* there is no FillPattern rule -> remove ShowBox rule */
3238: value.typed_data.value = 1;
1.184 vatton 3239: value.typed_data.unit = UNIT_REL;
1.1 cvs 3240: value.typed_data.real = FALSE;
1.207 vatton 3241: TtaSetStylePresentation (PRShowBox, element, tsch, ctxt, value);
1.1 cvs 3242: }
3243: }
3244: else if (url)
3245: {
1.30 cvs 3246: bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
1.82 cvs 3247: if (bg_image == NULL || !strcasecmp (bg_image, "yes"))
1.161 quint 3248: /* background images are enabled */
1.1 cvs 3249: {
1.185 vatton 3250: callblock = (BackgroundImageCallbackPtr) TtaGetMemory (sizeof (BackgroundImageCallbackBlock));
1.191 vatton 3251: if (callblock)
1.1 cvs 3252: {
3253: callblock->el = element;
3254: callblock->tsch = tsch;
1.185 vatton 3255: callblock->css = css;
1.207 vatton 3256: callblock->ctxt = ctxt;
3257: /* new use of the context */
3258: ctxt->uses += 1;
1.18 cvs 3259: /* check if the image url is related to an external CSS */
1.182 vatton 3260: if (css)
1.18 cvs 3261: {
1.189 vatton 3262: if (css->url)
3263: /* the image concerns a CSS file */
3264: NormalizeURL (url, 0, tempname, imgname, css->url);
3265: else
3266: /* the image concerns a style element */
1.207 vatton 3267: NormalizeURL (url, ctxt->doc, tempname, imgname, NULL);
1.18 cvs 3268: /* fetch and display background image of element */
1.181 vatton 3269: FetchImage (0, el, tempname, AMAYA_LOAD_IMAGE,
1.161 quint 3270: ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 3271: }
3272: else
1.207 vatton 3273: FetchImage (ctxt->doc, el, url, AMAYA_LOAD_IMAGE,
1.161 quint 3274: ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 3275: }
3276: }
3277:
3278: if (url)
3279: TtaFreeMemory (url);
3280: }
3281: }
3282: return (cssRule);
3283: }
3284:
3285: /*----------------------------------------------------------------------
1.59 cvs 3286: ParseCSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
1.18 cvs 3287: ----------------------------------------------------------------------*/
1.79 cvs 3288: static char *ParseCSSBackgroundRepeat (Element element, PSchema tsch,
1.207 vatton 3289: PresentationContext ctxt,
1.97 vatton 3290: char *cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3291: {
3292: PresentationValue repeat;
3293:
1.184 vatton 3294: repeat.typed_data.value = REALSIZE;
1.191 vatton 3295: repeat.typed_data.unit = UNIT_BOX;
1.18 cvs 3296: repeat.typed_data.real = FALSE;
1.82 cvs 3297: cssRule = SkipBlanksAndComments (cssRule);
3298: if (!strncasecmp (cssRule, "no-repeat", 9))
1.184 vatton 3299: repeat.typed_data.value = REALSIZE;
1.82 cvs 3300: else if (!strncasecmp (cssRule, "repeat-y", 8))
1.184 vatton 3301: repeat.typed_data.value = VREPEAT;
1.82 cvs 3302: else if (!strncasecmp (cssRule, "repeat-x", 8))
1.184 vatton 3303: repeat.typed_data.value = HREPEAT;
1.82 cvs 3304: else if (!strncasecmp (cssRule, "repeat", 6))
1.184 vatton 3305: repeat.typed_data.value = REPEAT;
1.18 cvs 3306: else
3307: return (cssRule);
3308:
3309: /* install the new presentation */
1.116 vatton 3310: if (DoApply)
1.117 vatton 3311: {
3312: /* check if it's an important rule */
3313: if (tsch)
1.207 vatton 3314: cssRule = CheckImportantRule (cssRule, ctxt);
3315: TtaSetStylePresentation (PRPictureMode, element, tsch, ctxt, repeat);
1.117 vatton 3316: }
1.18 cvs 3317: cssRule = SkipWord (cssRule);
1.163 quint 3318: return (cssRule);
1.18 cvs 3319: }
3320:
3321: /*----------------------------------------------------------------------
1.59 cvs 3322: ParseCSSBackgroundAttachment: parse a CSS BackgroundAttachment
1.18 cvs 3323: attribute string.
3324: ----------------------------------------------------------------------*/
1.79 cvs 3325: static char *ParseCSSBackgroundAttachment (Element element, PSchema tsch,
1.207 vatton 3326: PresentationContext ctxt,
1.79 cvs 3327: char *cssRule, CSSInfoPtr css,
3328: ThotBool isHTML)
1.18 cvs 3329: {
1.200 vatton 3330: char *ptr;
3331:
1.163 quint 3332: cssRule = SkipBlanksAndComments (cssRule);
3333: if (!strncasecmp (cssRule, "scroll", 6))
1.199 vatton 3334: {
3335: /* force no-repeat for that background image */
1.200 vatton 3336: ptr = "no-repeat";
1.207 vatton 3337: ParseCSSBackgroundRepeat (element, tsch, ctxt, ptr, css, isHTML);
1.199 vatton 3338: cssRule = SkipWord (cssRule);
3339: }
1.163 quint 3340: else if (!strncasecmp (cssRule, "fixed", 5))
1.199 vatton 3341: {
3342: /* force no-repeat for that background image */
1.201 vatton 3343: ptr = "no-repeat";
1.207 vatton 3344: ParseCSSBackgroundRepeat (element, tsch, ctxt, ptr, css, isHTML);
1.199 vatton 3345: cssRule = SkipWord (cssRule);
3346: }
1.163 quint 3347: return (cssRule);
1.1 cvs 3348: }
3349:
3350: /*----------------------------------------------------------------------
1.59 cvs 3351: ParseCSSBackgroundPosition: parse a CSS BackgroundPosition
1.1 cvs 3352: attribute string.
3353: ----------------------------------------------------------------------*/
1.79 cvs 3354: static char *ParseCSSBackgroundPosition (Element element, PSchema tsch,
1.207 vatton 3355: PresentationContext ctxt,
1.79 cvs 3356: char *cssRule, CSSInfoPtr css,
3357: ThotBool isHTML)
1.1 cvs 3358: {
1.18 cvs 3359: PresentationValue repeat;
1.200 vatton 3360: char *ptr;
1.18 cvs 3361: ThotBool ok;
1.1 cvs 3362:
1.163 quint 3363: cssRule = SkipBlanksAndComments (cssRule);
3364: ok = TRUE;
3365: if (!strncasecmp (cssRule, "left", 4))
3366: cssRule = SkipWord (cssRule);
3367: else if (!strncasecmp (cssRule, "right", 5))
3368: cssRule = SkipWord (cssRule);
3369: else if (!strncasecmp (cssRule, "center", 6))
3370: cssRule = SkipWord (cssRule);
3371: else if (!strncasecmp (cssRule, "top", 3))
3372: cssRule = SkipWord (cssRule);
3373: else if (!strncasecmp (cssRule, "bottom", 6))
3374: cssRule = SkipWord (cssRule);
3375: else if (isdigit (*cssRule) || *cssRule == '.')
1.191 vatton 3376: {
1.206 vatton 3377: while (*cssRule != EOS && *cssRule != SPACE &&
3378: *cssRule != ',' && *cssRule != ';')
3379: cssRule++;
1.191 vatton 3380: }
1.163 quint 3381: else
3382: ok = FALSE;
3383:
3384: if (ok && DoApply)
1.148 vatton 3385: {
1.199 vatton 3386: /* force no-repeat for that background image */
1.200 vatton 3387: ptr = "no-repeat";
1.207 vatton 3388: ParseCSSBackgroundRepeat (element, tsch, ctxt, ptr, css, isHTML);
1.163 quint 3389: /* force realsize for the background image */
1.184 vatton 3390: repeat.typed_data.value = REALSIZE;
3391: repeat.typed_data.unit = UNIT_REL;
1.163 quint 3392: repeat.typed_data.real = FALSE;
3393: /* check if it's an important rule */
3394: if (tsch)
1.207 vatton 3395: cssRule = CheckImportantRule (cssRule, ctxt);
3396: /*TtaSetStylePresentation (PRPictureMode, element, tsch, ctxt, repeat);*/
1.218 vatton 3397:
3398: /* check the second value */
3399: cssRule = SkipBlanksAndComments (cssRule);
3400: if (*cssRule != ';' && *cssRule != '}' && *cssRule != EOS)
3401: cssRule = ParseCSSBackgroundPosition (element, tsch, ctxt,
3402: cssRule, css, isHTML);
1.148 vatton 3403: }
1.163 quint 3404: return (cssRule);
1.18 cvs 3405: }
3406:
3407: /*----------------------------------------------------------------------
1.59 cvs 3408: ParseCSSBackground: parse a CSS background attribute
1.18 cvs 3409: ----------------------------------------------------------------------*/
1.79 cvs 3410: static char *ParseCSSBackground (Element element, PSchema tsch,
1.207 vatton 3411: PresentationContext ctxt, char *cssRule,
1.79 cvs 3412: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3413: {
1.79 cvs 3414: char *ptr;
1.93 vatton 3415: int skippedNL;
1.18 cvs 3416:
1.82 cvs 3417: cssRule = SkipBlanksAndComments (cssRule);
3418: while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
1.18 cvs 3419: {
1.71 cvs 3420: /* perhaps a Background Image */
1.198 vatton 3421: if (!strncasecmp (cssRule, "url", 3) || !strncasecmp (cssRule, "none", 4))
1.207 vatton 3422: cssRule = ParseCSSBackgroundImage (element, tsch, ctxt, cssRule,
1.63 cvs 3423: css, isHTML);
1.18 cvs 3424: /* perhaps a Background Attachment */
1.82 cvs 3425: else if (!strncasecmp (cssRule, "scroll", 6) ||
3426: !strncasecmp (cssRule, "fixed", 5))
1.207 vatton 3427: cssRule = ParseCSSBackgroundAttachment (element, tsch, ctxt,
1.63 cvs 3428: cssRule, css, isHTML);
1.18 cvs 3429: /* perhaps a Background Repeat */
1.82 cvs 3430: else if (!strncasecmp (cssRule, "no-repeat", 9) ||
3431: !strncasecmp (cssRule, "repeat-y", 8) ||
3432: !strncasecmp (cssRule, "repeat-x", 8) ||
3433: !strncasecmp (cssRule, "repeat", 6))
1.207 vatton 3434: cssRule = ParseCSSBackgroundRepeat (element, tsch, ctxt,
1.82 cvs 3435: cssRule, css, isHTML);
1.18 cvs 3436: /* perhaps a Background Position */
1.82 cvs 3437: else if (!strncasecmp (cssRule, "left", 4) ||
3438: !strncasecmp (cssRule, "right", 5) ||
3439: !strncasecmp (cssRule, "center", 6) ||
3440: !strncasecmp (cssRule, "top", 3) ||
3441: !strncasecmp (cssRule, "bottom", 6) ||
1.110 vatton 3442: isdigit (*cssRule) || *cssRule == '.')
1.207 vatton 3443: cssRule = ParseCSSBackgroundPosition (element, tsch, ctxt,
1.63 cvs 3444: cssRule, css, isHTML);
1.18 cvs 3445: /* perhaps a Background Color */
3446: else
3447: {
1.93 vatton 3448: skippedNL = NewLineSkipped;
1.18 cvs 3449: /* check if the rule has been found */
3450: ptr = cssRule;
1.207 vatton 3451: cssRule = ParseCSSBackgroundColor (element, tsch, ctxt,
1.82 cvs 3452: cssRule, css, isHTML);
1.43 cvs 3453: if (ptr == cssRule)
1.93 vatton 3454: {
3455: NewLineSkipped = skippedNL;
3456: /* rule not found */
3457: cssRule = SkipProperty (cssRule);
3458: }
1.18 cvs 3459: }
1.82 cvs 3460: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 3461: }
3462: return (cssRule);
3463: }
3464:
1.59 cvs 3465: /*----------------------------------------------------------------------
1.60 cvs 3466: ParseCSSPageBreakBefore: parse a CSS page-break-before attribute
1.59 cvs 3467: ----------------------------------------------------------------------*/
1.79 cvs 3468: static char *ParseCSSPageBreakBefore (Element element, PSchema tsch,
1.207 vatton 3469: PresentationContext ctxt, char *cssRule,
1.79 cvs 3470: CSSInfoPtr css, ThotBool isHTML)
1.59 cvs 3471: {
3472: PresentationValue page;
3473:
1.184 vatton 3474: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3475: page.typed_data.real = FALSE;
1.82 cvs 3476: cssRule = SkipBlanksAndComments (cssRule);
3477: if (!strncasecmp (cssRule, "auto", 4))
1.184 vatton 3478: page.typed_data.value = PageAuto;
1.82 cvs 3479: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 3480: {
1.184 vatton 3481: page.typed_data.unit = UNIT_REL;
3482: page.typed_data.value = PageAlways;
1.59 cvs 3483: }
1.82 cvs 3484: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3485: {
1.184 vatton 3486: page.typed_data.unit = UNIT_REL;
3487: page.typed_data.value = PageAvoid;
1.59 cvs 3488: }
1.82 cvs 3489: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 3490: {
1.184 vatton 3491: page.typed_data.unit = UNIT_REL;
3492: page.typed_data.value = PageLeft;
1.59 cvs 3493: }
1.82 cvs 3494: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 3495: {
1.184 vatton 3496: page.typed_data.unit = UNIT_REL;
3497: page.typed_data.value = PageRight;
1.59 cvs 3498: }
1.82 cvs 3499: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3500: {
1.184 vatton 3501: /*page.typed_data.unit = UNIT_REL;*/
3502: page.typed_data.value = PageInherit;
1.59 cvs 3503: }
3504: cssRule = SkipWord (cssRule);
3505: /* install the new presentation */
1.184 vatton 3506: if (page.typed_data.unit == UNIT_REL &&
3507: page.typed_data.value == PageAlways && DoApply)
1.117 vatton 3508: {
3509: /* check if it's an important rule */
3510: if (tsch)
1.207 vatton 3511: cssRule = CheckImportantRule (cssRule, ctxt);
3512: TtaSetStylePresentation (PRPageBefore, element, tsch, ctxt, page);
1.117 vatton 3513: }
1.59 cvs 3514: return (cssRule);
3515: }
3516:
3517: /*----------------------------------------------------------------------
1.60 cvs 3518: ParseCSSPageBreakAfter: parse a CSS page-break-after attribute
1.59 cvs 3519: ----------------------------------------------------------------------*/
1.79 cvs 3520: static char *ParseCSSPageBreakAfter (Element element, PSchema tsch,
1.207 vatton 3521: PresentationContext ctxt,
1.79 cvs 3522: char *cssRule, CSSInfoPtr css,
3523: ThotBool isHTML)
1.59 cvs 3524: {
3525: PresentationValue page;
3526:
1.184 vatton 3527: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3528: page.typed_data.real = FALSE;
1.82 cvs 3529: cssRule = SkipBlanksAndComments (cssRule);
3530: if (!strncasecmp (cssRule, "auto", 4))
1.184 vatton 3531: page.typed_data.value = PageAuto;
1.82 cvs 3532: else if (!strncasecmp (cssRule, "always", 6))
1.59 cvs 3533: {
1.184 vatton 3534: page.typed_data.unit = UNIT_REL;
3535: page.typed_data.value = PageAlways;
1.59 cvs 3536: }
1.82 cvs 3537: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3538: {
1.184 vatton 3539: page.typed_data.unit = UNIT_REL;
3540: page.typed_data.value = PageAvoid;
1.59 cvs 3541: }
1.82 cvs 3542: else if (!strncasecmp (cssRule, "left", 4))
1.59 cvs 3543: {
1.184 vatton 3544: page.typed_data.unit = UNIT_REL;
3545: page.typed_data.value = PageLeft;
1.59 cvs 3546: }
1.82 cvs 3547: else if (!strncasecmp (cssRule, "right", 5))
1.59 cvs 3548: {
1.184 vatton 3549: page.typed_data.unit = UNIT_REL;
3550: page.typed_data.value = PageRight;
1.59 cvs 3551: }
1.82 cvs 3552: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3553: {
1.184 vatton 3554: /*page.typed_data.unit = UNIT_REL;*/
3555: page.typed_data.value = PageInherit;
1.59 cvs 3556: }
3557: cssRule = SkipWord (cssRule);
3558: /* install the new presentation */
1.184 vatton 3559: /*if (page.typed_data.unit == UNIT_REL && DoApply)
1.117 vatton 3560: {
3561: if (tsch)
1.207 vatton 3562: cssRule = CheckImportantRule (cssRule, ctxt);
3563: TtaSetStylePresentation (PRPageAfter, element, tsch, ctxt, page);
1.117 vatton 3564: }*/
1.59 cvs 3565: return (cssRule);
3566: }
3567:
3568: /*----------------------------------------------------------------------
1.60 cvs 3569: ParseCSSPageBreakInside: parse a CSS page-break-inside attribute
1.59 cvs 3570: ----------------------------------------------------------------------*/
1.79 cvs 3571: static char *ParseCSSPageBreakInside (Element element, PSchema tsch,
1.207 vatton 3572: PresentationContext ctxt,
1.79 cvs 3573: char *cssRule, CSSInfoPtr css,
3574: ThotBool isHTML)
1.59 cvs 3575: {
3576: PresentationValue page;
3577:
1.184 vatton 3578: page.typed_data.unit = UNIT_INVALID;
1.59 cvs 3579: page.typed_data.real = FALSE;
1.82 cvs 3580: cssRule = SkipBlanksAndComments (cssRule);
3581: if (!strncasecmp (cssRule, "auto", 4))
1.59 cvs 3582: {
1.184 vatton 3583: /*page.typed_data.unit = UNIT_REL;*/
3584: page.typed_data.value = PageAuto;
1.59 cvs 3585: }
1.82 cvs 3586: else if (!strncasecmp (cssRule, "avoid", 5))
1.59 cvs 3587: {
1.184 vatton 3588: page.typed_data.unit = UNIT_REL;
3589: page.typed_data.value = PageAvoid;
1.59 cvs 3590: }
1.82 cvs 3591: else if (!strncasecmp (cssRule, "inherit", 7))
1.59 cvs 3592: {
1.184 vatton 3593: /*page.typed_data.unit = UNIT_REL;*/
3594: page.typed_data.value = PageInherit;
1.59 cvs 3595: }
3596: cssRule = SkipWord (cssRule);
3597: /* install the new presentation */
1.184 vatton 3598: /*if (page.typed_data.unit == UNIT_REL &&
3599: page.typed_data.value == PageAvoid && DoApply)
1.117 vatton 3600: {
3601: if (tsch)
1.207 vatton 3602: cssRule = CheckImportantRule (cssRule, ctxt);
3603: TtaSetStylePresentation (PRPageInside, element, tsch, ctxt, page);
1.117 vatton 3604: }*/
1.59 cvs 3605: return (cssRule);
3606: }
1.18 cvs 3607:
3608:
1.60 cvs 3609: /*----------------------------------------------------------------------
1.217 vatton 3610: ParseSVGStrokeWidth: parse a SVG stroke-width property value.
1.60 cvs 3611: ----------------------------------------------------------------------*/
1.79 cvs 3612: static char *ParseSVGStrokeWidth (Element element, PSchema tsch,
1.207 vatton 3613: PresentationContext ctxt, char *cssRule,
1.79 cvs 3614: CSSInfoPtr css, ThotBool isHTML)
1.60 cvs 3615: {
3616: PresentationValue width;
3617:
1.82 cvs 3618: cssRule = SkipBlanksAndComments (cssRule);
1.60 cvs 3619: width.typed_data.value = 0;
1.184 vatton 3620: width.typed_data.unit = UNIT_INVALID;
1.60 cvs 3621: width.typed_data.real = FALSE;
1.110 vatton 3622: if (isdigit (*cssRule) || *cssRule == '.')
1.166 vatton 3623: {
1.60 cvs 3624: cssRule = ParseCSSUnit (cssRule, &width);
1.184 vatton 3625: if (width.typed_data.unit == UNIT_BOX)
3626: width.typed_data.unit = UNIT_PX;
1.166 vatton 3627: }
1.184 vatton 3628: if (width.typed_data.unit != UNIT_INVALID && DoApply)
1.117 vatton 3629: {
3630: /* check if it's an important rule */
3631: if (tsch)
1.207 vatton 3632: cssRule = CheckImportantRule (cssRule, ctxt);
3633: TtaSetStylePresentation (PRLineWeight, element, tsch, ctxt, width);
1.117 vatton 3634: width.typed_data.value = 1;
1.184 vatton 3635: width.typed_data.unit = UNIT_REL;
1.117 vatton 3636: }
1.60 cvs 3637: return (cssRule);
3638: }
3639:
1.217 vatton 3640: /*----------------------------------------------------------------------
3641: ParseCSSPosition: parse a CSS Position attribute string.
3642: ----------------------------------------------------------------------*/
3643: static char *ParseCSSPosition (Element element, PSchema tsch,
3644: PresentationContext ctxt,
3645: char *cssRule, CSSInfoPtr css,
3646: ThotBool isHTML)
3647: {
3648: char *ptr;
3649:
3650: cssRule = SkipBlanksAndComments (cssRule);
3651: ptr = cssRule;
3652: if (!strncasecmp (cssRule, "static", 6))
3653: cssRule = SkipWord (cssRule);
3654: else if (!strncasecmp (cssRule, "relative", 7))
3655: cssRule = SkipWord (cssRule);
3656: else if (!strncasecmp (cssRule, "absolute", 8))
3657: cssRule = SkipWord (cssRule);
3658: else if (!strncasecmp (cssRule, "fixed", 5))
3659: cssRule = SkipWord (cssRule);
3660: else if (!strncasecmp (cssRule, "inherit", 7))
3661: cssRule = SkipWord (cssRule);
3662: else
3663: cssRule = SkipValue ("Invalid Position value", ptr);
3664: return (cssRule);
3665: }
3666:
3667: /*----------------------------------------------------------------------
3668: ParseCSSTop: parse a CSS Top attribute
3669: ----------------------------------------------------------------------*/
3670: static char *ParseCSSTop (Element element, PSchema tsch,
3671: PresentationContext context, char *cssRule,
3672: CSSInfoPtr css, ThotBool isHTML)
3673: {
3674: PresentationValue val;
3675: char *ptr;
3676:
3677: cssRule = SkipBlanksAndComments (cssRule);
3678: ptr = cssRule;
3679: /* first parse the attribute string */
3680: if (!strncasecmp (cssRule, "auto", 4) ||
3681: !strncasecmp (cssRule, "inherit", 7))
3682: {
3683: val.typed_data.unit = VALUE_AUTO;
3684: val.typed_data.value = 0;
3685: val.typed_data.real = FALSE;
3686: cssRule = SkipWord (cssRule);
3687: }
3688: else
3689: cssRule = ParseCSSUnit (cssRule, &val);
3690: if (val.typed_data.value != 0 &&
3691: (val.typed_data.unit == UNIT_INVALID ||
3692: val.typed_data.unit == UNIT_BOX))
3693: {
1.218 vatton 3694: cssRule = SkipValue ("top value", ptr);
1.217 vatton 3695: val.typed_data.unit = UNIT_PX;
3696: }
3697: /***
3698: if (DoApply)
3699: {
3700: if (tsch)
3701: cssRule = CheckImportantRule (cssRule, context);
3702: TtaSetStylePresentation (PR, element, tsch, context, val);
3703: }
3704: ***/
3705: return (cssRule);
3706: }
3707:
3708: /*----------------------------------------------------------------------
3709: ParseCSSRight: parse a CSS Right attribute
3710: ----------------------------------------------------------------------*/
3711: static char *ParseCSSRight (Element element, PSchema tsch,
3712: PresentationContext context, char *cssRule,
3713: CSSInfoPtr css, ThotBool isHTML)
3714: {
3715: PresentationValue val;
3716: char *ptr;
3717:
3718: cssRule = SkipBlanksAndComments (cssRule);
3719: ptr = cssRule;
3720: /* first parse the attribute string */
3721: if (!strncasecmp (cssRule, "auto", 4) ||
3722: !strncasecmp (cssRule, "inherit", 7))
3723: {
3724: val.typed_data.unit = VALUE_AUTO;
3725: val.typed_data.value = 0;
3726: val.typed_data.real = FALSE;
3727: cssRule = SkipWord (cssRule);
3728: }
3729: else
3730: cssRule = ParseCSSUnit (cssRule, &val);
3731: if (val.typed_data.value != 0 &&
3732: (val.typed_data.unit == UNIT_INVALID ||
3733: val.typed_data.unit == UNIT_BOX))
3734: {
1.218 vatton 3735: cssRule = SkipValue ("right value", ptr);
1.217 vatton 3736: val.typed_data.unit = UNIT_PX;
3737: }
3738: /***
3739: if (DoApply)
3740: {
3741: if (tsch)
3742: cssRule = CheckImportantRule (cssRule, context);
3743: TtaSetStylePresentation (PR, element, tsch, context, val);
3744: }
3745: ***/
3746: return (cssRule);
3747: }
3748:
3749: /*----------------------------------------------------------------------
3750: ParseCSSBottom: parse a CSS Bottom attribute
3751: ----------------------------------------------------------------------*/
3752: static char *ParseCSSBottom (Element element, PSchema tsch,
3753: PresentationContext context, char *cssRule,
3754: CSSInfoPtr css, ThotBool isHTML)
3755: {
3756: PresentationValue val;
3757: char *ptr;
3758:
3759: cssRule = SkipBlanksAndComments (cssRule);
3760: ptr = cssRule;
3761: /* first parse the attribute string */
3762: if (!strncasecmp (cssRule, "auto", 4) ||
3763: !strncasecmp (cssRule, "inherit", 7))
3764: {
3765: val.typed_data.unit = VALUE_AUTO;
3766: val.typed_data.value = 0;
3767: val.typed_data.real = FALSE;
3768: cssRule = SkipWord (cssRule);
3769: }
3770: else
3771: cssRule = ParseCSSUnit (cssRule, &val);
3772: if (val.typed_data.value != 0 &&
3773: (val.typed_data.unit == UNIT_INVALID ||
3774: val.typed_data.unit == UNIT_BOX))
3775: {
1.218 vatton 3776: cssRule = SkipValue ("bottom value", ptr);
1.217 vatton 3777: val.typed_data.unit = UNIT_PX;
3778: }
3779: /***
3780: if (DoApply)
3781: {
3782: if (tsch)
3783: cssRule = CheckImportantRule (cssRule, context);
3784: TtaSetStylePresentation (PR, element, tsch, context, val);
3785: }
3786: ***/
3787: return (cssRule);
3788: }
3789:
3790: /*----------------------------------------------------------------------
3791: ParseCSSLeft: parse a CSS Left attribute
3792: ----------------------------------------------------------------------*/
3793: static char *ParseCSSLeft (Element element, PSchema tsch,
3794: PresentationContext context, char *cssRule,
3795: CSSInfoPtr css, ThotBool isHTML)
3796: {
3797: PresentationValue val;
3798: char *ptr;
3799:
3800: cssRule = SkipBlanksAndComments (cssRule);
3801: ptr = cssRule;
3802: /* first parse the attribute string */
3803: if (!strncasecmp (cssRule, "auto", 4) ||
3804: !strncasecmp (cssRule, "inherit", 7))
3805: {
3806: val.typed_data.unit = VALUE_AUTO;
3807: val.typed_data.value = 0;
3808: val.typed_data.real = FALSE;
3809: cssRule = SkipWord (cssRule);
3810: }
3811: else
3812: cssRule = ParseCSSUnit (cssRule, &val);
3813: if (val.typed_data.value != 0 &&
3814: (val.typed_data.unit == UNIT_INVALID ||
3815: val.typed_data.unit == UNIT_BOX))
3816: {
1.218 vatton 3817: cssRule = SkipValue ("left value", ptr);
1.217 vatton 3818: val.typed_data.unit = UNIT_PX;
3819: }
3820: /***
3821: if (DoApply)
3822: {
3823: if (tsch)
3824: cssRule = CheckImportantRule (cssRule, context);
3825: TtaSetStylePresentation (PR, element, tsch, context, val);
3826: }
3827: ***/
3828: return (cssRule);
3829: }
3830:
3831: /*----------------------------------------------------------------------
3832: ParseCSSZIndex: parse a CSS z-index attribute
3833: ----------------------------------------------------------------------*/
3834: static char *ParseCSSZIndex (Element element, PSchema tsch,
3835: PresentationContext context, char *cssRule,
3836: CSSInfoPtr css, ThotBool isHTML)
3837: {
3838: PresentationValue val;
3839: char *ptr;
3840:
3841: cssRule = SkipBlanksAndComments (cssRule);
3842: ptr = cssRule;
3843: /* first parse the attribute string */
3844: if (!strncasecmp (cssRule, "auto", 4) ||
3845: !strncasecmp (cssRule, "inherit", 7))
3846: {
3847: val.typed_data.unit = VALUE_AUTO;
3848: val.typed_data.value = 0;
3849: val.typed_data.real = FALSE;
3850: cssRule = SkipWord (cssRule);
3851: }
3852: else
3853: {
3854: cssRule = ParseCSSUnit (cssRule, &val);
3855: if (val.typed_data.unit != UNIT_BOX)
3856: {
1.218 vatton 3857: cssRule = SkipValue ("z-index value", ptr);
1.217 vatton 3858: val.typed_data.unit = UNIT_BOX;
3859: }
3860: }
3861: /***
3862: if (DoApply)
3863: {
3864: if (tsch)
3865: cssRule = CheckImportantRule (cssRule, context);
3866: TtaSetStylePresentation (PR, element, tsch, context, val);
3867: }
3868: ***/
3869: return (cssRule);
3870: }
3871:
1.18 cvs 3872: /************************************************************************
3873: * *
3874: * FUNCTIONS STYLE DECLARATIONS *
3875: * *
3876: ************************************************************************/
3877: /*
1.59 cvs 3878: * NOTE: Long attribute name MUST be placed before shortened ones !
1.18 cvs 3879: * e.g. "FONT-SIZE" must be placed before "FONT"
3880: */
3881: static CSSProperty CSSProperties[] =
3882: {
1.82 cvs 3883: {"font-family", ParseCSSFontFamily},
3884: {"font-style", ParseCSSFontStyle},
3885: {"font-variant", ParseCSSFontVariant},
3886: {"font-weight", ParseCSSFontWeight},
1.219 vatton 3887: {"font-size-adjust", ParseCSSFontSizeAdjust},
1.82 cvs 3888: {"font-size", ParseCSSFontSize},
3889: {"font", ParseCSSFont},
3890:
3891: {"color", ParseCSSForeground},
3892: {"background-color", ParseCSSBackgroundColor},
3893: {"background-image", ParseCSSBackgroundImage},
3894: {"background-repeat", ParseCSSBackgroundRepeat},
3895: {"background-attachment", ParseCSSBackgroundAttachment},
3896: {"background-position", ParseCSSBackgroundPosition},
3897: {"background", ParseCSSBackground},
3898:
3899: {"word-spacing", ParseCSSWordSpacing},
3900: {"letter-spacing", ParseCSSLetterSpacing},
3901: {"text-decoration", ParseCSSTextDecoration},
3902: {"vertical-align", ParseCSSVerticalAlign},
3903: {"text-transform", ParseCSSTextTransform},
3904: {"text-align", ParseCSSTextAlign},
3905: {"text-indent", ParseCSSTextIndent},
1.162 quint 3906: {"line-height", ParseCSSLineHeight},
1.82 cvs 3907:
1.112 quint 3908: {"direction", ParseCSSDirection},
1.113 quint 3909: {"unicode-bidi", ParseCSSUnicodeBidi},
1.112 quint 3910:
1.82 cvs 3911: {"margin-top", ParseCSSMarginTop},
3912: {"margin-right", ParseCSSMarginRight},
3913: {"margin-bottom", ParseCSSMarginBottom},
3914: {"margin-left", ParseCSSMarginLeft},
3915: {"margin", ParseCSSMargin},
3916:
3917: {"padding-top", ParseCSSPaddingTop},
3918: {"padding-right", ParseCSSPaddingRight},
3919: {"padding-bottom", ParseCSSPaddingBottom},
3920: {"padding-left", ParseCSSPaddingLeft},
3921: {"padding", ParseCSSPadding},
3922:
3923: {"border-top-width", ParseCSSBorderTopWidth},
3924: {"border-right-width", ParseCSSBorderRightWidth},
3925: {"border-bottom-width", ParseCSSBorderBottomWidth},
3926: {"border-left-width", ParseCSSBorderLeftWidth},
3927: {"border-width", ParseCSSBorderWidth},
3928: {"border-top-color", ParseCSSBorderColorTop},
3929: {"border-right-color", ParseCSSBorderColorRight},
3930: {"border-bottom-color", ParseCSSBorderColorBottom},
3931: {"border-left-color", ParseCSSBorderColorLeft},
3932: {"border-color", ParseCSSBorderColor},
3933: {"border-top-style", ParseCSSBorderStyleTop},
3934: {"border-right-style", ParseCSSBorderStyleRight},
3935: {"border-bottom-style", ParseCSSBorderStyleBottom},
3936: {"border-left-style", ParseCSSBorderStyleLeft},
3937: {"border-style", ParseCSSBorderStyle},
3938: {"border-top", ParseCSSBorderTop},
3939: {"border-right", ParseCSSBorderRight},
3940: {"border-bottom", ParseCSSBorderBottom},
3941: {"border-left", ParseCSSBorderLeft},
3942: {"border", ParseCSSBorder},
3943:
3944: {"width", ParseCSSWidth},
3945: {"height", ParseCSSHeight},
3946: {"float", ParseCSSFloat},
3947: {"clear", ParseCSSClear},
1.184 vatton 3948: {"content", ParseCSSContent},
1.82 cvs 3949:
3950: {"display", ParseCSSDisplay},
3951: {"white-space", ParseCSSWhiteSpace},
1.217 vatton 3952: {"position", ParseCSSPosition},
3953: {"top", ParseCSSTop},
3954: {"right", ParseCSSRight},
3955: {"bottom", ParseCSSBottom},
3956: {"left", ParseCSSLeft},
3957: {"z-index", ParseCSSZIndex},
1.82 cvs 3958:
3959: {"list-style-type", ParseCSSListStyleType},
3960: {"list-style-image", ParseCSSListStyleImage},
3961: {"list-style-position", ParseCSSListStylePosition},
3962: {"list-style", ParseCSSListStyle},
3963:
3964: {"page-break-before", ParseCSSPageBreakBefore},
3965: {"page-break-after", ParseCSSPageBreakAfter},
3966: {"page-break-inside", ParseCSSPageBreakInside},
1.60 cvs 3967:
3968: /* SVG extensions */
1.170 cheyroul 3969: {"stroke-opacity", ParseSVGStrokeOpacity},
1.82 cvs 3970: {"stroke-width", ParseSVGStrokeWidth},
3971: {"stroke", ParseSVGStroke},
1.170 cheyroul 3972:
3973: {"fill-opacity", ParseSVGFillOpacity},
1.155 cheyroul 3974: {"fill", ParseSVGFill},
1.170 cheyroul 3975:
1.155 cheyroul 3976: {"opacity", ParseSVGOpacity}
1.18 cvs 3977: };
1.155 cheyroul 3978:
1.18 cvs 3979: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
3980:
3981: /*----------------------------------------------------------------------
1.59 cvs 3982: ParseCSSRule: parse a CSS Style string
1.18 cvs 3983: we expect the input string describing the style to be of the
1.59 cvs 3984: form: PRORPERTY: DESCRIPTION [ ; PROPERTY: DESCRIPTION ] *
1.18 cvs 3985: but tolerate incorrect or incomplete input
3986: ----------------------------------------------------------------------*/
1.79 cvs 3987: static void ParseCSSRule (Element element, PSchema tsch,
1.207 vatton 3988: PresentationContext ctxt, char *cssRule,
1.79 cvs 3989: CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3990: {
1.34 cvs 3991: DisplayMode dispMode;
1.218 vatton 3992: char *p = NULL, c;
1.214 quint 3993: char *valueStart;
1.18 cvs 3994: int lg;
1.34 cvs 3995: unsigned int i;
1.76 cvs 3996: ThotBool found;
1.18 cvs 3997:
1.34 cvs 3998: /* avoid too many redisplay */
1.207 vatton 3999: dispMode = TtaGetDisplayMode (ctxt->doc);
1.34 cvs 4000: if (dispMode == DisplayImmediately)
1.207 vatton 4001: TtaSetDisplayMode (ctxt->doc, DeferredDisplay);
1.34 cvs 4002:
1.82 cvs 4003: while (*cssRule != EOS)
1.18 cvs 4004: {
1.82 cvs 4005: cssRule = SkipBlanksAndComments (cssRule);
1.153 vatton 4006: if (*cssRule < 0x41 || *cssRule > 0x7A ||
1.133 vatton 4007: (*cssRule > 0x5A && *cssRule < 0x60))
1.153 vatton 4008: cssRule++;
1.194 vatton 4009: else if (*cssRule != EOS)
1.89 cvs 4010: {
1.153 vatton 4011: found = FALSE;
4012: /* look for the type of property */
4013: for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
1.18 cvs 4014: {
1.153 vatton 4015: lg = strlen (CSSProperties[i].name);
4016: if (!strncasecmp (cssRule, CSSProperties[i].name, lg))
4017: {
4018: p = cssRule + lg;
4019: found = TRUE;
4020: i--;
4021: }
1.18 cvs 4022: }
1.153 vatton 4023: if (i == NB_CSSSTYLEATTRIBUTE)
4024: cssRule = SkipProperty (cssRule);
4025: else
1.18 cvs 4026: {
1.153 vatton 4027: /* update index and skip the ":" indicator if present */
1.86 cvs 4028: p = SkipBlanksAndComments (p);
1.153 vatton 4029: if (*p == ':')
1.61 cvs 4030: {
1.153 vatton 4031: p++;
4032: p = SkipBlanksAndComments (p);
4033: /* try to parse the value associated with this property */
4034: if (CSSProperties[i].parsing_function != NULL)
4035: {
1.214 quint 4036: valueStart = p;
4037: p = CSSProperties[i].parsing_function (element, tsch,
4038: ctxt, p, css, isHTML);
4039: if (!element && isHTML)
4040: {
4041: if (ctxt->type == HTML_EL_Input)
4042: /* it's a generic rule for the HTML element input.
4043: Generate a Thot Pres rule for each kind of
4044: input element */
4045: {
4046: ctxt->type = HTML_EL_Text_Input;
4047: p = CSSProperties[i].parsing_function (element,
4048: tsch, ctxt, valueStart, css, isHTML);
4049: ctxt->type = HTML_EL_Password_Input;
4050: p = CSSProperties[i].parsing_function (element,
4051: tsch, ctxt, valueStart, css, isHTML);
4052: ctxt->type = HTML_EL_File_Input;
4053: p = CSSProperties[i].parsing_function (element,
4054: tsch, ctxt, valueStart, css, isHTML);
4055: ctxt->type = HTML_EL_Checkbox_Input;
4056: p = CSSProperties[i].parsing_function (element,
4057: tsch, ctxt, valueStart, css, isHTML);
4058: ctxt->type = HTML_EL_Radio_Input;
4059: p = CSSProperties[i].parsing_function (element,
4060: tsch, ctxt, valueStart, css, isHTML);
4061: ctxt->type = HTML_EL_Submit_Input;
4062: p = CSSProperties[i].parsing_function (element,
4063: tsch, ctxt, valueStart, css, isHTML);
4064: ctxt->type = HTML_EL_Reset_Input;
4065: p = CSSProperties[i].parsing_function (element,
4066: tsch, ctxt, valueStart, css, isHTML);
4067: ctxt->type = HTML_EL_Button_Input;
4068: p = CSSProperties[i].parsing_function (element,
4069: tsch, ctxt, valueStart, css, isHTML);
4070: ctxt->type = HTML_EL_Input;
4071: }
4072: else if (ctxt->type == HTML_EL_ruby)
4073: /* it's a generic rule for the HTML element ruby.
4074: Generate a Thot Pres rule for each kind of
4075: ruby element. */
4076: {
4077: ctxt->type = HTML_EL_simple_ruby;
4078: p = CSSProperties[i].parsing_function (element,
4079: tsch, ctxt, valueStart, css, isHTML);
4080: ctxt->type = HTML_EL_complex_ruby;
4081: p = CSSProperties[i].parsing_function (element,
4082: tsch, ctxt, valueStart, css, isHTML);
4083: ctxt->type = HTML_EL_ruby;
4084: }
4085: }
1.153 vatton 4086: /* update index and skip the ";" separator if present */
4087: cssRule = p;
4088: }
1.61 cvs 4089: }
1.153 vatton 4090: else
1.217 vatton 4091: {
4092: cssRule = SkipProperty (cssRule);
1.218 vatton 4093: c = *cssRule;
4094: *cssRule = EOS;
4095: CSSPrintError ("Unknown CSS2 property", p);
4096: *cssRule = c;
1.217 vatton 4097: }
1.18 cvs 4098: }
4099: }
4100: /* next property */
1.82 cvs 4101: cssRule = SkipBlanksAndComments (cssRule);
1.89 cvs 4102: if (*cssRule == '}')
4103: {
4104: cssRule++;
1.168 vatton 4105: CSSPrintError ("Invalid character", "}");
1.89 cvs 4106: cssRule = SkipBlanksAndComments (cssRule);
4107: }
1.155 cheyroul 4108: if (*cssRule == ',' ||
4109: *cssRule == ';')
1.18 cvs 4110: {
4111: cssRule++;
1.82 cvs 4112: cssRule = SkipBlanksAndComments (cssRule);
1.18 cvs 4113: }
4114: }
1.34 cvs 4115:
4116: /* restore the display mode */
4117: if (dispMode == DisplayImmediately)
1.207 vatton 4118: TtaSetDisplayMode (ctxt->doc, dispMode);
1.18 cvs 4119: }
1.1 cvs 4120:
1.111 cvs 4121: /*----------------------------------------------------------------------
4122: AddBorderStyleValue
4123: -----------------------------------------------------------------------*/
4124: static void AddBorderStyleValue (char *buffer, int value)
4125: {
4126: switch (value)
4127: {
1.184 vatton 4128: case BorderStyleNone:
1.111 cvs 4129: strcat (buffer, "none");
4130: break;
1.184 vatton 4131: case BorderStyleHidden:
1.111 cvs 4132: strcat (buffer, "hidden");
4133: break;
1.184 vatton 4134: case BorderStyleDotted:
1.111 cvs 4135: strcat (buffer, "dotted");
4136: break;
1.184 vatton 4137: case BorderStyleDashed:
1.111 cvs 4138: strcat (buffer, "dashed");
4139: break;
1.184 vatton 4140: case BorderStyleSolid:
1.111 cvs 4141: strcat (buffer, "solid");
4142: break;
1.184 vatton 4143: case BorderStyleDouble:
1.111 cvs 4144: strcat (buffer, "double");
4145: break;
1.184 vatton 4146: case BorderStyleGroove:
1.111 cvs 4147: strcat (buffer, "groove");
4148: break;
1.184 vatton 4149: case BorderStyleRidge:
1.111 cvs 4150: strcat (buffer, "ridge");
4151: break;
1.184 vatton 4152: case BorderStyleInset:
1.111 cvs 4153: strcat (buffer, "inset");
4154: break;
1.184 vatton 4155: case BorderStyleOutset:
1.111 cvs 4156: strcat (buffer, "outset");
4157: break;
4158: }
4159: }
1.1 cvs 4160:
4161: /*----------------------------------------------------------------------
1.59 cvs 4162: PToCss: translate a PresentationSetting to the
1.18 cvs 4163: equivalent CSS string, and add it to the buffer given as the
1.67 cvs 4164: argument. It is used when extracting the CSS string from actual
4165: presentation.
4166: el is the element for which the style rule is generated
1.18 cvs 4167:
4168: All the possible values returned by the presentation drivers are
4169: described in thotlib/include/presentation.h
4170: -----------------------------------------------------------------------*/
1.79 cvs 4171: void PToCss (PresentationSetting settings, char *buffer, int len, Element el)
1.1 cvs 4172: {
1.76 cvs 4173: ElementType elType;
1.18 cvs 4174: float fval = 0;
4175: unsigned short red, green, blue;
4176: int add_unit = 0;
4177: unsigned int unit, i;
4178: ThotBool real = FALSE;
4179:
1.82 cvs 4180: buffer[0] = EOS;
1.18 cvs 4181: if (len < 40)
4182: return;
4183:
4184: unit = settings->value.typed_data.unit;
4185: if (settings->value.typed_data.real)
4186: {
4187: real = TRUE;
4188: fval = (float) settings->value.typed_data.value;
1.195 vatton 4189: fval /= 1000.;
1.18 cvs 4190: }
1.1 cvs 4191:
1.18 cvs 4192: switch (settings->type)
1.1 cvs 4193: {
1.18 cvs 4194: case PRVisibility:
4195: break;
1.111 cvs 4196: case PRHeight:
4197: if (real)
4198: sprintf (buffer, "height: %g", fval);
4199: else
4200: sprintf (buffer, "height: %d", settings->value.typed_data.value);
4201: add_unit = 1;
4202: break;
4203: case PRWidth:
4204: if (real)
4205: sprintf (buffer, "width: %g", fval);
4206: else
4207: sprintf (buffer, "width: %d", settings->value.typed_data.value);
4208: add_unit = 1;
4209: break;
4210: case PRMarginTop:
4211: if (real)
4212: sprintf (buffer, "margin-top: %g", fval);
4213: else
4214: sprintf (buffer, "margin-top: %d",settings->value.typed_data.value);
4215: add_unit = 1;
4216: break;
4217: case PRMarginBottom:
4218: if (real)
4219: sprintf (buffer, "margin-bottom: %g", fval);
4220: else
4221: sprintf (buffer, "margin-bottom: %d",
4222: settings->value.typed_data.value);
4223: add_unit = 1;
4224: break;
4225: case PRMarginLeft:
4226: if (real)
4227: sprintf (buffer, "margin-left: %g", fval);
4228: else
1.164 quint 4229: sprintf (buffer, "margin-left: %d", settings->value.typed_data.value);
1.111 cvs 4230: add_unit = 1;
4231: break;
4232: case PRMarginRight:
4233: if (real)
4234: sprintf (buffer, "margin-right: %g", fval);
4235: else
1.164 quint 4236: sprintf (buffer, "margin-right: %d", settings->value.typed_data.value);
1.111 cvs 4237: add_unit = 1;
4238: break;
4239: case PRPaddingTop:
4240: if (real)
4241: sprintf (buffer, "padding-top: %g", fval);
4242: else
1.164 quint 4243: sprintf (buffer, "padding-top: %d", settings->value.typed_data.value);
1.111 cvs 4244: add_unit = 1;
4245: break;
4246: case PRPaddingBottom:
4247: if (real)
4248: sprintf (buffer, "padding-bottom: %g", fval);
4249: else
4250: sprintf (buffer, "padding-bottom: %d",
4251: settings->value.typed_data.value);
4252: add_unit = 1;
4253: break;
4254: case PRPaddingLeft:
4255: if (real)
4256: sprintf (buffer, "padding-left: %g", fval);
4257: else
1.164 quint 4258: sprintf (buffer, "padding-left: %d", settings->value.typed_data.value);
1.111 cvs 4259: add_unit = 1;
4260: break;
4261: case PRPaddingRight:
4262: if (real)
4263: sprintf (buffer, "padding-right: %g", fval);
4264: else
4265: sprintf (buffer, "padding-right: %d",
4266: settings->value.typed_data.value);
4267: add_unit = 1;
4268: break;
4269: case PRBorderTopWidth:
4270: if (real)
4271: sprintf (buffer, "border-top-width: %g", fval);
4272: else
4273: sprintf (buffer, "border-top-width: %d",
4274: settings->value.typed_data.value);
4275: add_unit = 1;
4276: break;
4277: case PRBorderBottomWidth:
4278: if (real)
4279: sprintf (buffer, "border-bottom-width: %g", fval);
4280: else
4281: sprintf (buffer, "border-bottom-width: %d",
4282: settings->value.typed_data.value);
4283: add_unit = 1;
4284: break;
4285: case PRBorderLeftWidth:
4286: if (real)
4287: sprintf (buffer, "border-left-width: %g", fval);
4288: else
4289: sprintf (buffer, "border-left-width: %d",
4290: settings->value.typed_data.value);
4291: add_unit = 1;
4292: break;
4293: case PRBorderRightWidth:
4294: if (real)
4295: sprintf (buffer, "border-right-width: %g", fval);
4296: else
4297: sprintf (buffer, "border-right-width: %d",
4298: settings->value.typed_data.value);
4299: add_unit = 1;
4300: break;
4301: case PRBorderTopColor:
4302: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
4303: elType = TtaGetElementType(el);
4304: sprintf (buffer, "border-top-color: #%02X%02X%02X", red, green, blue);
4305: break;
4306: case PRBorderRightColor:
4307: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
4308: elType = TtaGetElementType(el);
4309: sprintf (buffer, "border-right-color: #%02X%02X%02X", red, green, blue);
4310: break;
4311: case PRBorderBottomColor:
4312: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
4313: elType = TtaGetElementType(el);
4314: sprintf (buffer, "border-bottom-color: #%02X%02X%02X", red, green, blue);
1.18 cvs 4315: break;
1.111 cvs 4316: case PRBorderLeftColor:
4317: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
4318: elType = TtaGetElementType(el);
4319: sprintf (buffer, "border-left-color: #%02X%02X%02X", red, green, blue);
1.20 cvs 4320: break;
1.111 cvs 4321: case PRBorderTopStyle:
4322: strcpy (buffer, "border-top-style: ");
4323: AddBorderStyleValue (buffer, settings->value.typed_data.value);
4324: break;
4325: case PRBorderRightStyle:
4326: strcpy (buffer, "border-right-style: ");
4327: AddBorderStyleValue (buffer, settings->value.typed_data.value);
4328: break;
4329: case PRBorderBottomStyle:
4330: strcpy (buffer, "border-bottom-style: ");
4331: AddBorderStyleValue (buffer, settings->value.typed_data.value);
4332: break;
4333: case PRBorderLeftStyle:
4334: strcpy (buffer, "border-left-style: ");
4335: AddBorderStyleValue (buffer, settings->value.typed_data.value);
1.18 cvs 4336: break;
4337: case PRSize:
1.184 vatton 4338: if (unit == UNIT_REL)
1.18 cvs 4339: {
4340: if (real)
4341: {
1.82 cvs 4342: sprintf (buffer, "font-size: %g", fval);
1.18 cvs 4343: add_unit = 1;
4344: }
4345: else
4346: switch (settings->value.typed_data.value)
4347: {
4348: case 1:
1.82 cvs 4349: strcpy (buffer, "font-size: xx-small");
1.18 cvs 4350: break;
4351: case 2:
1.82 cvs 4352: strcpy (buffer, "font-size: x-small");
1.18 cvs 4353: break;
4354: case 3:
1.82 cvs 4355: strcpy (buffer, "font-size: small");
1.18 cvs 4356: break;
4357: case 4:
1.82 cvs 4358: strcpy (buffer, "font-size: medium");
1.18 cvs 4359: break;
4360: case 5:
1.82 cvs 4361: strcpy (buffer, "font-size: large");
1.18 cvs 4362: break;
4363: case 6:
1.82 cvs 4364: strcpy (buffer, "font-size: x-large");
1.18 cvs 4365: break;
4366: case 7:
4367: case 8:
4368: case 9:
4369: case 10:
4370: case 11:
4371: case 12:
1.82 cvs 4372: strcpy (buffer, "font-size: xx-large");
1.18 cvs 4373: break;
4374: }
4375: }
4376: else
4377: {
4378: if (real)
1.82 cvs 4379: sprintf (buffer, "font-size: %g", fval);
1.18 cvs 4380: else
1.82 cvs 4381: sprintf (buffer, "font-size: %d",
1.67 cvs 4382: settings->value.typed_data.value);
1.18 cvs 4383: add_unit = 1;
4384: }
4385: break;
1.111 cvs 4386: case PRStyle:
4387: switch (settings->value.typed_data.value)
4388: {
1.184 vatton 4389: case StyleRoman:
1.111 cvs 4390: strcpy (buffer, "font-style: normal");
4391: break;
1.184 vatton 4392: case StyleItalics:
1.111 cvs 4393: strcpy (buffer, "font-style: italic");
4394: break;
1.184 vatton 4395: case StyleOblique:
1.111 cvs 4396: strcpy (buffer, "font-style: oblique");
4397: break;
4398: }
4399: break;
4400: case PRWeight:
4401: switch (settings->value.typed_data.value)
4402: {
1.184 vatton 4403: case WeightBold:
1.111 cvs 4404: strcpy (buffer, "font-weight: bold");
4405: break;
1.184 vatton 4406: case WeightNormal:
1.111 cvs 4407: strcpy (buffer, "font-weight: normal");
4408: break;
4409: }
4410: break;
4411: case PRFont:
4412: switch (settings->value.typed_data.value)
4413: {
1.184 vatton 4414: case FontHelvetica:
1.111 cvs 4415: strcpy (buffer, "font-family: helvetica");
4416: break;
1.184 vatton 4417: case FontTimes:
1.111 cvs 4418: strcpy (buffer, "font-family: times");
4419: break;
1.184 vatton 4420: case FontCourier:
1.111 cvs 4421: strcpy (buffer, "font-family: courier");
4422: break;
4423: }
4424: break;
1.18 cvs 4425: case PRUnderline:
4426: switch (settings->value.typed_data.value)
4427: {
1.184 vatton 4428: case Underline:
1.82 cvs 4429: strcpy (buffer, "text-decoration: underline");
1.18 cvs 4430: break;
1.184 vatton 4431: case Overline:
1.82 cvs 4432: strcpy (buffer, "text-decoration: overline");
1.18 cvs 4433: break;
1.184 vatton 4434: case CrossOut:
1.82 cvs 4435: strcpy (buffer, "text-decoration: line-through");
1.18 cvs 4436: break;
4437: }
4438: break;
1.111 cvs 4439: case PRThickness:
4440: break;
1.18 cvs 4441: case PRIndent:
4442: if (real)
1.82 cvs 4443: sprintf (buffer, "text-indent: %g", fval);
1.18 cvs 4444: else
1.82 cvs 4445: sprintf (buffer, "text-indent: %d",
1.67 cvs 4446: settings->value.typed_data.value);
1.18 cvs 4447: add_unit = 1;
4448: break;
4449: case PRLineSpacing:
4450: if (real)
1.82 cvs 4451: sprintf (buffer, "line-height: %g", fval);
1.1 cvs 4452: else
1.82 cvs 4453: sprintf (buffer, "line-height: %d",
1.67 cvs 4454: settings->value.typed_data.value);
1.18 cvs 4455: add_unit = 1;
4456: break;
1.111 cvs 4457: case PRDepth:
4458: break;
1.18 cvs 4459: case PRAdjust:
4460: switch (settings->value.typed_data.value)
1.1 cvs 4461: {
1.184 vatton 4462: case AdjustLeft:
1.82 cvs 4463: strcpy (buffer, "text-align: left");
1.18 cvs 4464: break;
1.184 vatton 4465: case AdjustRight:
1.82 cvs 4466: strcpy (buffer, "text-align: right");
1.18 cvs 4467: break;
1.184 vatton 4468: case Centered:
1.82 cvs 4469: strcpy (buffer, "text-align: center");
1.18 cvs 4470: break;
1.184 vatton 4471: case LeftWithDots:
1.82 cvs 4472: strcpy (buffer, "text-align: left");
1.81 cvs 4473: break;
1.184 vatton 4474: case Justify:
1.82 cvs 4475: strcpy (buffer, "text-align: justify");
1.112 quint 4476: break;
4477: }
4478: break;
4479: case PRDirection:
4480: switch (settings->value.typed_data.value)
4481: {
1.184 vatton 4482: case LeftToRight:
1.112 quint 4483: strcpy (buffer, "direction: ltr");
4484: break;
1.184 vatton 4485: case RightToLeft:
1.112 quint 4486: strcpy (buffer, "direction: rtl");
1.113 quint 4487: break;
4488: }
4489: break;
4490: case PRUnicodeBidi:
4491: switch (settings->value.typed_data.value)
4492: {
1.184 vatton 4493: case Normal:
1.113 quint 4494: strcpy (buffer, "unicode-bidi: normal");
4495: break;
1.184 vatton 4496: case Embed:
1.113 quint 4497: strcpy (buffer, "unicode-bidi: embed");
4498: break;
1.184 vatton 4499: case Override:
1.113 quint 4500: strcpy (buffer, "unicode-bidi: bidi-override");
1.18 cvs 4501: break;
1.1 cvs 4502: }
1.18 cvs 4503: break;
1.111 cvs 4504: case PRLineStyle:
4505: break;
1.126 vatton 4506: case PRDisplay:
4507: switch (settings->value.typed_data.value)
4508: {
1.184 vatton 4509: case Inline:
1.126 vatton 4510: strcpy (buffer, "display: inline");
4511: break;
1.184 vatton 4512: case Block:
1.126 vatton 4513: strcpy (buffer, "display: block");
4514: break;
1.184 vatton 4515: case ListItem:
1.126 vatton 4516: strcpy (buffer, "display: list-item");
4517: break;
1.184 vatton 4518: case RunIn:
1.126 vatton 4519: strcpy (buffer, "display: runin");
4520: break;
1.184 vatton 4521: case Compact:
1.126 vatton 4522: strcpy (buffer, "display: compact");
4523: break;
1.184 vatton 4524: case Marker:
1.126 vatton 4525: strcpy (buffer, "display: marker");
1.196 vatton 4526: break;
4527: default:
4528: break;
4529: }
4530: break;
4531: case PRFloat:
4532: switch (settings->value.typed_data.value)
4533: {
4534: case FloatNone:
4535: strcpy (buffer, "float: none");
4536: break;
4537: case FloatLeft:
4538: strcpy (buffer, "float: left");
4539: break;
4540: case FloatRight:
4541: strcpy (buffer, "float: right");
4542: break;
4543: default:
4544: break;
4545: }
4546: break;
4547: case PRClear:
4548: switch (settings->value.typed_data.value)
4549: {
4550: case ClearNone:
4551: strcpy (buffer, "clear: none");
4552: break;
4553: case ClearLeft:
4554: strcpy (buffer, "clear: left");
4555: break;
4556: case ClearRight:
4557: strcpy (buffer, "clear: right");
4558: break;
4559: case ClearBoth:
4560: strcpy (buffer, "clear: both");
1.126 vatton 4561: break;
4562: default:
4563: break;
4564: }
4565: break;
1.111 cvs 4566: case PRLineWeight:
4567: elType = TtaGetElementType(el);
4568: #ifdef _SVG
4569: if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG"))
4570: #endif /* _SVG */
4571: {
4572: if (real)
4573: sprintf (buffer, "stroke-width: %g", fval);
4574: else
4575: sprintf (buffer, "stroke-width: %d",
4576: settings->value.typed_data.value);
4577: }
4578: add_unit = 1;
1.18 cvs 4579: break;
4580: case PRFillPattern:
4581: break;
4582: case PRBackground:
4583: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.76 cvs 4584: elType = TtaGetElementType(el);
1.100 vatton 4585: #ifdef _SVG
4586: if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG") == 0)
1.82 cvs 4587: sprintf (buffer, "fill: #%02X%02X%02X", red, green, blue);
1.67 cvs 4588: else
1.100 vatton 4589: #endif /* _SVG */
1.82 cvs 4590: sprintf (buffer, "background-color: #%02X%02X%02X", red, green,
1.67 cvs 4591: blue);
1.18 cvs 4592: break;
4593: case PRForeground:
4594: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.76 cvs 4595: elType = TtaGetElementType(el);
1.100 vatton 4596: #ifdef _SVG
4597: if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "SVG") == 0)
1.82 cvs 4598: sprintf (buffer, "stroke: #%02X%02X%02X", red, green, blue);
1.67 cvs 4599: else
1.100 vatton 4600: #endif /* _SVG */
1.82 cvs 4601: sprintf (buffer, "color: #%02X%02X%02X", red, green, blue);
1.67 cvs 4602: break;
1.111 cvs 4603: case PRHyphenate:
1.195 vatton 4604: case PRVertOverflow:
4605: case PRHorizOverflow:
4606: break;
4607: case PROpacity:
4608: sprintf (buffer, "opacity: %g", fval);
1.18 cvs 4609: break;
1.195 vatton 4610: case PRStrokeOpacity:
4611: sprintf (buffer, "stroke-opacity: %g", fval);
1.18 cvs 4612: break;
1.195 vatton 4613: case PRFillOpacity:
4614: sprintf (buffer, "fill-opacity: %g", fval);
1.18 cvs 4615: break;
4616: case PRBackgroundPicture:
4617: if (settings->value.pointer != NULL)
1.82 cvs 4618: sprintf (buffer, "background-image: url(%s)",
1.67 cvs 4619: (char*)(settings->value.pointer));
1.1 cvs 4620: else
1.82 cvs 4621: sprintf (buffer, "background-image: none");
1.18 cvs 4622: break;
4623: case PRPictureMode:
4624: switch (settings->value.typed_data.value)
1.1 cvs 4625: {
1.184 vatton 4626: case REALSIZE:
1.82 cvs 4627: sprintf (buffer, "background-repeat: no-repeat");
1.18 cvs 4628: break;
1.184 vatton 4629: case REPEAT:
1.82 cvs 4630: sprintf (buffer, "background-repeat: repeat");
1.18 cvs 4631: break;
1.184 vatton 4632: case VREPEAT:
1.82 cvs 4633: sprintf (buffer, "background-repeat: repeat-y");
1.18 cvs 4634: break;
1.184 vatton 4635: case HREPEAT:
1.82 cvs 4636: sprintf (buffer, "background-repeat: repeat-x");
1.18 cvs 4637: break;
1.1 cvs 4638: }
1.18 cvs 4639: break;
4640: default:
4641: break;
1.1 cvs 4642: }
4643:
1.18 cvs 4644: if (add_unit)
1.1 cvs 4645: {
1.18 cvs 4646: /* add the unit string to the CSS string */
4647: for (i = 0; i < NB_UNITS; i++)
1.1 cvs 4648: {
1.18 cvs 4649: if (CSSUnitNames[i].unit == unit)
1.1 cvs 4650: {
1.82 cvs 4651: strcat (buffer, CSSUnitNames[i].sign);
1.18 cvs 4652: break;
1.1 cvs 4653: }
4654: }
4655: }
4656: }
4657:
4658: /*----------------------------------------------------------------------
1.59 cvs 4659: ParseHTMLSpecificStyle: parse and apply a CSS Style string.
1.18 cvs 4660: This function must be called when a specific style is applied to an
4661: element.
1.114 quint 4662: The parameter specificity is the specificity of the style, 0 if it is
4663: not really a CSS rule.
1.1 cvs 4664: ----------------------------------------------------------------------*/
1.79 cvs 4665: void ParseHTMLSpecificStyle (Element el, char *cssRule, Document doc,
1.114 quint 4666: int specificity, ThotBool destroy)
1.1 cvs 4667: {
1.207 vatton 4668: PresentationContext ctxt;
4669: ElementType elType;
4670: ThotBool isHTML;
1.1 cvs 4671:
1.207 vatton 4672: /* A rule applying to BODY is really meant to address HTML */
4673: elType = TtaGetElementType (el);
1.89 cvs 4674:
1.207 vatton 4675: /* store the current line for eventually reported errors */
4676: LineNumber = TtaGetElementLineNumber (el);
4677: if (destroy)
4678: /* no reported errors */
4679: ParsedDoc = 0;
4680: else if (ParsedDoc != doc)
4681: {
4682: /* update the context for reported errors */
4683: ParsedDoc = doc;
4684: DocURL = DocumentURLs[doc];
4685: }
4686: isHTML = (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML") == 0);
4687: /* create the context of the Specific presentation driver */
4688: ctxt = TtaGetSpecificStyleContext (doc);
4689: if (ctxt == NULL)
4690: return;
4691: ctxt->type = elType.ElTypeNum;
4692: ctxt->cssSpecificity = specificity;
4693: ctxt->destroy = destroy;
4694: /* first use of the context */
4695: ctxt->uses = 1;
4696: /* Call the parser */
4697: ParseCSSRule (el, NULL, (PresentationContext) ctxt, cssRule, NULL, isHTML);
4698: /* check if the context can be freed */
4699: ctxt->uses -= 1;
4700: if (ctxt->uses == 0)
4701: /* no image loading */
4702: TtaFreeMemory(ctxt);
1.1 cvs 4703: }
4704:
1.68 cvs 4705:
1.1 cvs 4706: /*----------------------------------------------------------------------
1.207 vatton 4707: ParseGenericSelector: Create a generic context for a given selector
4708: string.
4709: If the selector is made of multiple comma, it parses them one at a time
4710: and return the end of the selector string to be handled or NULL.
1.1 cvs 4711: ----------------------------------------------------------------------*/
1.207 vatton 4712: static char *ParseGenericSelector (char *selector, char *cssRule,
1.79 cvs 4713: GenericContext ctxt, Document doc,
1.206 vatton 4714: CSSInfoPtr css, Element link)
1.79 cvs 4715: {
4716: ElementType elType;
4717: PSchema tsch;
1.119 vatton 4718: AttributeType attrType;
1.207 vatton 4719: char *deb, *cur, *sel, c;
1.118 vatton 4720: char *schemaName, *mappedName;
1.79 cvs 4721: char *names[MAX_ANCESTORS];
4722: char *ids[MAX_ANCESTORS];
4723: char *classes[MAX_ANCESTORS];
4724: char *pseudoclasses[MAX_ANCESTORS];
4725: char *attrs[MAX_ANCESTORS];
4726: char *attrvals[MAX_ANCESTORS];
1.133 vatton 4727: AttrMatch attrmatch[MAX_ANCESTORS];
1.91 cvs 4728: int i, j, k, max;
1.125 vatton 4729: int att, maxAttr, kind;
1.118 vatton 4730: int specificity, xmlType;
1.217 vatton 4731: int skippedNL;
1.79 cvs 4732: ThotBool isHTML;
1.183 vatton 4733: ThotBool level, quoted;
1.1 cvs 4734:
1.207 vatton 4735: sel = ctxt->sel;
1.82 cvs 4736: sel[0] = EOS;
1.117 vatton 4737: specificity = 0;
1.1 cvs 4738: for (i = 0; i < MAX_ANCESTORS; i++)
4739: {
1.25 cvs 4740: names[i] = NULL;
4741: ids[i] = NULL;
4742: classes[i] = NULL;
4743: pseudoclasses[i] = NULL;
4744: attrs[i] = NULL;
4745: attrvals[i] = NULL;
1.133 vatton 4746: attrmatch[i] = Txtmatch;
1.25 cvs 4747: ctxt->name[i] = 0;
4748: ctxt->names_nb[i] = 0;
4749: ctxt->attrType[i] = 0;
1.129 vatton 4750: ctxt->attrLevel[i] = 0;
1.25 cvs 4751: ctxt->attrText[i] = NULL;
1.178 quint 4752: ctxt->attrMatch[i] = Txtmatch;
1.1 cvs 4753: }
1.25 cvs 4754: ctxt->box = 0;
4755: ctxt->type = 0;
1.114 quint 4756: /* the specificity of the rule depends on the selector */
4757: ctxt->cssSpecificity = 0;
1.25 cvs 4758:
1.82 cvs 4759: selector = SkipBlanksAndComments (selector);
1.27 cvs 4760: cur = &sel[0];
1.25 cvs 4761: max = 0; /* number of loops */
1.1 cvs 4762: while (1)
4763: {
1.85 cvs 4764: /* point to the following word in sel[] */
1.27 cvs 4765: deb = cur;
1.25 cvs 4766: /* copy an item of the selector into sel[] */
1.1 cvs 4767: /* put one word in the sel buffer */
1.82 cvs 4768: while (*selector != EOS && *selector != ',' &&
4769: *selector != '.' && *selector != ':' &&
1.118 vatton 4770: *selector != '#' && *selector != '[' &&
1.130 vatton 4771: *selector != '*' && *selector != '>' &&
1.118 vatton 4772: !TtaIsBlank (selector))
1.50 cvs 4773: *cur++ = *selector++;
1.82 cvs 4774: *cur++ = EOS; /* close the first string in sel[] */
4775: if (deb[0] != EOS)
1.117 vatton 4776: {
4777: names[0] = deb;
1.150 vatton 4778: if (!strcmp (names[0], "html"))
1.149 vatton 4779: /* give a greater priority to the backgoud color of html */
4780: specificity += 3;
4781: else
4782: specificity += 1;
1.117 vatton 4783: }
1.25 cvs 4784: else
1.27 cvs 4785: names[0] = NULL;
4786: classes[0] = NULL;
4787: pseudoclasses[0] = NULL;
4788: ids[0] = NULL;
4789: attrs[0] = NULL;
4790: attrvals[0] = NULL;
1.25 cvs 4791:
1.27 cvs 4792: /* now names[0] points to the beginning of the parsed item
1.25 cvs 4793: and cur to the next chain to be parsed */
1.129 vatton 4794: while (*selector == '.' || *selector == ':' ||
1.130 vatton 4795: *selector == '#' || *selector == '[' ||
1.183 vatton 4796: *selector == '*')
1.129 vatton 4797: {
1.85 cvs 4798: /* point to the following word in sel[] */
4799: deb = cur;
1.202 vatton 4800: if (*selector == '*' &&
4801: (selector[1] == '.' || selector[1] == ':' ||
4802: selector[1] == '#' || selector[1] == '['))
4803: selector++;
1.129 vatton 4804: if (*selector == '.')
4805: {
4806: selector++;
4807: while (*selector != EOS && *selector != ',' &&
4808: *selector != '.' && *selector != ':' &&
4809: !TtaIsBlank (selector))
4810: *cur++ = *selector++;
4811: /* close the word */
4812: *cur++ = EOS;
4813: /* point to the class in sel[] if it's valid name */
4814: if (deb[0] <= 64)
4815: {
1.168 vatton 4816: CSSPrintError ("Invalid class", deb);
1.116 vatton 4817: DoApply = FALSE;
1.129 vatton 4818: }
4819: else
4820: {
4821: classes[0] = deb;
1.178 quint 4822: /* a "class" attribute on an element may contain several
4823: words, one for each class it matches */
4824: attrmatch[0] = Txtword;
1.117 vatton 4825: specificity += 10;
1.129 vatton 4826: }
4827: }
4828: else if (*selector == ':')
4829: {
4830: selector++;
4831: while (*selector != EOS && *selector != ',' &&
4832: *selector != '.' && *selector != ':' &&
4833: !TtaIsBlank (selector))
4834: *cur++ = *selector++;
4835: /* close the word */
4836: *cur++ = EOS;
4837: /* point to the pseudoclass in sel[] if it's valid name */
4838: if (deb[0] <= 64)
4839: {
1.168 vatton 4840: CSSPrintError ("Invalid pseudoclass", deb);
1.129 vatton 4841: DoApply = FALSE;
4842: }
4843: else
4844: {
4845: if (!strcmp (deb, "first-letter") ||
4846: !strcmp (deb, "first-line") ||
4847: !strcmp (deb, "before") ||
4848: !strcmp (deb, "after"))
4849: /* not supported */
1.116 vatton 4850: DoApply = FALSE;
1.129 vatton 4851: else
4852: specificity += 10;
4853: pseudoclasses[0]= deb;
4854: }
4855: }
4856: else if (*selector == '#')
4857: {
4858: selector++;
4859: while (*selector != EOS && *selector != ',' &&
4860: *selector != '.' && *selector != ':' &&
4861: !TtaIsBlank (selector))
4862: *cur++ = *selector++;
4863: /* close the word */
4864: *cur++ = EOS;
4865: /* point to the attribute in sel[] if it's valid name */
4866: if (deb[0] <= 64)
4867: {
1.168 vatton 4868: CSSPrintError ("Invalid id", deb);
1.129 vatton 4869: DoApply = FALSE;
4870: }
4871: else
4872: {
4873: ids[0] = deb;
4874: specificity += 100;
4875: }
4876: }
4877: else if (*selector == '[')
4878: {
1.118 vatton 4879: selector++;
1.129 vatton 4880: while (*selector != EOS && *selector != ']' &&
1.131 vatton 4881: *selector != '=' && *selector != '~' &&
1.133 vatton 4882: *selector != '|' && *selector != '^' &&
4883: *selector != '!')
1.129 vatton 4884: *cur++ = *selector++;
1.133 vatton 4885: /* check matching */
4886: if (*selector == '~')
4887: {
4888: attrmatch[0] = Txtword;
4889: selector++;
4890: }
4891: else if (*selector == '|')
4892: {
4893: attrmatch[0] = Txtsubstring;
4894: selector++;
4895: }
4896: else
4897: attrmatch[0] = Txtmatch;
1.129 vatton 4898: /* close the word */
4899: *cur++ = EOS;
4900: /* point to the attribute in sel[] if it's valid name */
4901: if (deb[0] <= 64)
4902: {
1.168 vatton 4903: CSSPrintError ("Invalid attribute", deb);
1.129 vatton 4904: DoApply = FALSE;
4905: }
4906: else
4907: {
4908: attrs[0] = deb;
4909: specificity += 10;
4910: }
4911: if (*selector == '=')
4912: {
4913: /* look for a value "xxxx" */
4914: selector++;
4915: if (*selector != '"')
1.183 vatton 4916: quoted = FALSE;
1.129 vatton 4917: else
4918: {
1.183 vatton 4919: quoted = TRUE;
1.129 vatton 4920: /* we are now parsing the attribute value */
4921: selector++;
1.183 vatton 4922: }
4923: deb = cur;
4924: while ((quoted &&
4925: (*selector != '"' ||
4926: (*selector == '"' && selector[-1] == '\\'))) ||
4927: (!quoted && *selector != ']'))
4928: {
4929: if (*selector == EOS)
1.129 vatton 4930: {
1.183 vatton 4931: CSSPrintError ("Invalid attribute value", deb);
4932: DoApply = FALSE;
1.129 vatton 4933: }
1.183 vatton 4934: else
1.129 vatton 4935: {
1.183 vatton 4936: *cur++ = tolower (*selector);
1.129 vatton 4937: selector++;
4938: }
4939: }
1.183 vatton 4940: /* there is a value */
1.204 quint 4941: if (quoted && *selector == '"')
1.183 vatton 4942: {
4943: selector++;
4944: quoted = FALSE;
4945: }
4946: if (*selector != ']')
4947: {
4948: CSSPrintError ("Invalid attribute value", deb);
4949: DoApply = FALSE;
4950: }
4951: else
4952: {
4953: *cur++ = EOS;
4954: attrvals[0] = deb;
4955: selector++;
4956: }
1.129 vatton 4957: }
4958: /* end of the attribute */
1.183 vatton 4959: else if (*selector != ']')
1.129 vatton 4960: {
1.133 vatton 4961: selector[1] = EOS;
1.183 vatton 4962: CSSPrintError ("Invalid attribute", selector);
1.133 vatton 4963: selector += 2;
1.129 vatton 4964: DoApply = FALSE;
4965: }
4966: else
4967: selector++;
1.130 vatton 4968: }
4969: else
4970: {
4971: /* not supported selector */
4972: while (*selector != EOS && *selector != ',' &&
4973: *selector != '.' && *selector != ':' &&
4974: !TtaIsBlank (selector))
4975: *cur++ = *selector++;
4976: /* close the word */
4977: *cur++ = EOS;
1.205 quint 4978: CSSPrintError ("Selector not supported:", deb);
1.130 vatton 4979: DoApply = FALSE;
1.129 vatton 4980: }
4981: }
1.1 cvs 4982:
1.82 cvs 4983: selector = SkipBlanksAndComments (selector);
1.25 cvs 4984: /* is it a multi-level selector? */
1.82 cvs 4985: if (*selector == EOS)
1.1 cvs 4986: /* end of the selector */
4987: break;
1.82 cvs 4988: else if (*selector == ',')
1.1 cvs 4989: {
4990: /* end of the current selector */
4991: selector++;
4992: break;
4993: }
1.25 cvs 4994: else
4995: {
1.143 vatton 4996: if (*selector == '>')
4997: {
4998: /* handle immediat parent as a simple parent */
4999: selector++;
5000: selector = SkipBlanksAndComments (selector);
5001: }
1.25 cvs 5002: /* shifts the list to make room for the new name */
5003: max++; /* a new level in ancestor tables */
5004: if (max == MAX_ANCESTORS)
5005: /* abort the CSS parsing */
5006: return (selector);
5007: for (i = max; i > 0; i--)
5008: {
5009: names[i] = names[i - 1];
5010: ids[i] = ids[i - 1];
5011: classes[i] = classes[i - 1];
1.133 vatton 5012: pseudoclasses[i] = pseudoclasses[i - 1];
1.25 cvs 5013: attrs[i] = attrs[i - 1];
5014: attrvals[i] = attrvals[i - 1];
1.133 vatton 5015: attrmatch[i] = attrmatch[i - 1];
1.25 cvs 5016: }
5017: }
1.1 cvs 5018: }
5019:
5020: /* Now set up the context block */
1.25 cvs 5021: i = 0;
5022: k = 0;
5023: j = 0;
1.35 cvs 5024: maxAttr = 0;
1.91 cvs 5025: /* default schema name */
1.119 vatton 5026: ctxt->schema = NULL;
1.122 vatton 5027: elType.ElSSchema = NULL;
5028: schemaName = TtaGetSSchemaName(TtaGetDocumentSSchema (doc));
1.119 vatton 5029: if (!strcmp (schemaName, "HTML"))
5030: xmlType = XHTML_TYPE;
5031: else if (!strcmp (schemaName, "MathML"))
5032: xmlType = MATH_TYPE;
5033: else if (!strcmp (schemaName, "SVG"))
5034: xmlType = SVG_TYPE;
5035: else if (!strcmp (schemaName, "XLink"))
5036: xmlType = XLINK_TYPE;
5037: else if (!strcmp (schemaName, "Annot"))
5038: xmlType = ANNOT_TYPE;
5039: else
5040: xmlType = XML_TYPE;
1.25 cvs 5041: while (i <= max)
5042: {
5043: if (names[i])
5044: {
1.118 vatton 5045: /* get the element type of this name in the current document */
1.220 ! quint 5046: if (xmlType == XML_TYPE)
! 5047: /* it's a generic XML document */
! 5048: {
! 5049: elType.ElSSchema = TtaGetDocumentSSchema (doc);
! 5050: TtaGetXmlElementType (names[i], &elType, &mappedName, doc);
! 5051: if (!elType.ElTypeNum)
! 5052: elType.ElSSchema = NULL;
! 5053: }
! 5054: else
! 5055: MapXMLElementType (xmlType, names[i], &elType, &mappedName, &c,
! 5056: &level, doc);
1.25 cvs 5057: if (i == 0)
5058: {
1.106 cvs 5059: if (elType.ElSSchema == NULL)
5060: {
1.119 vatton 5061: /* Search in the list of loaded schemas */
1.106 cvs 5062: TtaGetXmlElementType (names[i], &elType, NULL, doc);
1.119 vatton 5063: if (elType.ElSSchema)
5064: {
1.154 vatton 5065: /* the element type concerns an imported nature */
1.119 vatton 5066: schemaName = TtaGetSSchemaName(elType.ElSSchema);
5067: if (!strcmp (schemaName, "HTML"))
5068: xmlType = XHTML_TYPE;
5069: else if (!strcmp (schemaName, "MathML"))
5070: xmlType = MATH_TYPE;
5071: else if (!strcmp (schemaName, "SVG"))
5072: xmlType = SVG_TYPE;
5073: else if (!strcmp (schemaName, "XLink"))
5074: xmlType = XLINK_TYPE;
5075: else if (!strcmp (schemaName, "Annot"))
5076: xmlType = ANNOT_TYPE;
5077: else
5078: xmlType = XML_TYPE;
5079: }
1.118 vatton 5080: #ifdef XML_GENERIC
1.119 vatton 5081: else if (xmlType == XML_TYPE)
1.106 cvs 5082: {
5083: /* Creation of a new element type in the main schema */
5084: elType.ElSSchema = TtaGetDocumentSSchema (doc);
1.118 vatton 5085: TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
1.106 cvs 5086: }
1.118 vatton 5087: #endif /* XML_GENERIC */
1.122 vatton 5088: else
5089: {
5090: if (xmlType != XHTML_TYPE)
5091: {
5092: MapXMLElementType (XHTML_TYPE, names[i], &elType,
5093: &mappedName, &c, &level, doc);
5094: if (elType.ElSSchema)
1.123 vatton 5095: elType.ElSSchema = GetXHTMLSSchema (doc);
1.122 vatton 5096: }
5097: if (elType.ElSSchema == NULL && xmlType != MATH_TYPE)
5098: {
5099: MapXMLElementType (MATH_TYPE, names[i], &elType,
5100: &mappedName, &c, &level, doc);
5101: if (elType.ElSSchema)
1.123 vatton 5102: elType.ElSSchema = GetMathMLSSchema (doc);
1.122 vatton 5103: }
5104: if (elType.ElSSchema == NULL && xmlType != SVG_TYPE)
5105: {
5106: MapXMLElementType (SVG_TYPE, names[i], &elType,
5107: &mappedName, &c, &level, doc);
5108: if (elType.ElSSchema)
1.123 vatton 5109: elType.ElSSchema = GetSVGSSchema (doc);
1.122 vatton 5110: }
5111: }
1.118 vatton 5112: }
1.119 vatton 5113:
1.118 vatton 5114: if (elType.ElSSchema == NULL)
5115: /* cannot apply these CSS rules */
5116: DoApply = FALSE;
5117: else
5118: {
5119: /* Store the element type */
5120: ctxt->type = elType.ElTypeNum;
5121: ctxt->name[0] = elType.ElTypeNum;
5122: ctxt->names_nb[0] = 0;
5123: ctxt->schema = elType.ElSSchema;
1.106 cvs 5124: }
1.25 cvs 5125: }
5126: else if (elType.ElTypeNum != 0)
5127: {
5128: /* look at the current context to see if the type is already
5129: stored */
1.121 vatton 5130: j = 1;
1.32 cvs 5131: while (j < k && ctxt->name[j] != elType.ElTypeNum)
1.25 cvs 5132: j++;
5133: if (j == k)
5134: {
5135: ctxt->name[j] = elType.ElTypeNum;
5136: if (j != 0)
1.121 vatton 5137: ctxt->names_nb[j] = 1;
1.25 cvs 5138: }
5139: else
5140: /* increment the number of ancestor levels */
5141: ctxt->names_nb[j]++;
5142: }
1.154 vatton 5143: #ifdef XML_GENERIC
5144: else if (xmlType == XML_TYPE)
5145: {
1.158 vatton 5146: TtaGetXmlElementType (names[i], &elType, NULL, doc);
5147: if (elType.ElTypeNum == 0)
5148: {
5149: /* Creation of a new element type in the main schema */
5150: elType.ElSSchema = TtaGetDocumentSSchema (doc);
5151: TtaAppendXmlElement (names[i], &elType, &mappedName, doc);
5152: }
1.154 vatton 5153: if (elType.ElTypeNum != 0)
5154: {
5155: /* look at the current context to see if the type is already
5156: stored */
5157: j = 1;
5158: while (j < k && ctxt->name[j] != elType.ElTypeNum)
5159: j++;
5160: if (j == k)
5161: {
5162: ctxt->name[j] = elType.ElTypeNum;
5163: if (j != 0)
5164: ctxt->names_nb[j] = 1;
5165: }
5166: else
5167: /* increment the number of ancestor levels */
5168: ctxt->names_nb[j]++;
5169: }
5170: }
5171: #endif /* XML_GENERIC */
1.25 cvs 5172: else
1.117 vatton 5173: j = k;
1.25 cvs 5174: }
1.117 vatton 5175: else
5176: j = k;
1.1 cvs 5177:
1.25 cvs 5178: /* store attributes information */
5179: if (classes[i])
5180: {
5181: ctxt->attrText[j] = classes[i];
1.119 vatton 5182: if (xmlType == SVG_TYPE)
1.100 vatton 5183: ctxt->attrType[j] = SVG_ATTR_class;
1.119 vatton 5184: else if (xmlType == MATH_TYPE)
1.91 cvs 5185: ctxt->attrType[j] = MathML_ATTR_class;
1.119 vatton 5186: else if (xmlType == XHTML_TYPE)
1.107 cvs 5187: ctxt->attrType[j] = HTML_ATTR_Class;
5188: else
1.119 vatton 5189: #ifdef XML_GENERIC
1.107 cvs 5190: ctxt->attrType[j] = XML_ATTR_class;
5191: #else /* XML_GENERIC */
1.91 cvs 5192: ctxt->attrType[j] = HTML_ATTR_Class;
1.107 cvs 5193: #endif /* XML_GENERIC */
1.157 vatton 5194: ctxt->attrMatch[j] = attrmatch[i];
1.79 cvs 5195: /* add a new entry */
1.80 cvs 5196: maxAttr = i + 1;
1.129 vatton 5197: /* update attrLevel */
5198: ctxt->attrLevel[j] = i;
5199: j++;
1.25 cvs 5200: }
1.79 cvs 5201: if (pseudoclasses[i])
1.25 cvs 5202: {
5203: ctxt->attrText[j] = pseudoclasses[i];
1.119 vatton 5204: if (xmlType == SVG_TYPE)
1.100 vatton 5205: ctxt->attrType[j] = SVG_ATTR_PseudoClass;
1.119 vatton 5206: else if (xmlType == MATH_TYPE)
1.91 cvs 5207: ctxt->attrType[j] = MathML_ATTR_PseudoClass;
1.119 vatton 5208: else if (xmlType == XHTML_TYPE)
1.107 cvs 5209: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
5210: else
1.119 vatton 5211: #ifdef XML_GENERIC
1.107 cvs 5212: ctxt->attrType[j] = XML_ATTR_PseudoClass;
5213: #else /* XML_GENERIC */
1.91 cvs 5214: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
1.107 cvs 5215: #endif /* XML_GENERIC */
1.157 vatton 5216: ctxt->attrMatch[j] = attrmatch[i];
1.79 cvs 5217: /* add a new entry */
1.80 cvs 5218: maxAttr = i + 1;
1.129 vatton 5219: /* update attrLevel */
5220: ctxt->attrLevel[j] = i;
5221: j++;
1.25 cvs 5222: }
1.79 cvs 5223: if (ids[i])
1.25 cvs 5224: {
5225: ctxt->attrText[j] = ids[i];
1.119 vatton 5226: if (xmlType == SVG_TYPE)
1.100 vatton 5227: ctxt->attrType[j] = SVG_ATTR_id;
1.119 vatton 5228: else if (xmlType == MATH_TYPE)
1.91 cvs 5229: ctxt->attrType[j] = MathML_ATTR_id;
1.119 vatton 5230: else if (xmlType == XHTML_TYPE)
1.107 cvs 5231: ctxt->attrType[j] = HTML_ATTR_ID;
5232: else
1.119 vatton 5233: #ifdef XML_GENERIC
1.107 cvs 5234: ctxt->attrType[j] = XML_ATTR_id;
5235: #else /* XML_GENERIC */
1.91 cvs 5236: ctxt->attrType[j] = HTML_ATTR_ID;
1.107 cvs 5237: #endif /* XML_GENERIC */
1.157 vatton 5238: ctxt->attrMatch[j] = attrmatch[i];
1.80 cvs 5239: /* add a new entry */
5240: maxAttr = i + 1;
1.129 vatton 5241: /* update attrLevel */
5242: ctxt->attrLevel[j] = i;
5243: j++;
1.25 cvs 5244: }
1.79 cvs 5245: if (attrs[i])
1.25 cvs 5246: {
1.125 vatton 5247: /* it's an attribute */
1.220 ! quint 5248: if (xmlType == XML_TYPE)
! 5249: {
! 5250: attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
! 5251: TtaGetXmlAttributeType (attrs[i], &attrType, doc);
! 5252: att = attrType.AttrTypeNum;
! 5253: }
! 5254: else
! 5255: MapXMLAttribute (xmlType, attrs[i], names[i], &level, doc, &att);
1.127 quint 5256: if (att == DummyAttribute && !strcmp (schemaName, "HTML"))
5257: /* it's the "type" attribute for an "input" element. In the tree
5258: it's represented by the element type, not by an attribute */
5259: att = 0;
1.119 vatton 5260: ctxt->attrType[j] = att;
1.133 vatton 5261: ctxt->attrMatch[j] = attrmatch[i];
1.125 vatton 5262: attrType.AttrSSchema = ctxt->schema;
5263: attrType.AttrTypeNum = att;
1.119 vatton 5264: if (i == 0 && att == 0 && ctxt->schema == NULL)
5265: {
1.125 vatton 5266: /* Not found -> search in the list of loaded schemas */
1.119 vatton 5267: attrType.AttrSSchema = NULL;
5268: TtaGetXmlAttributeType (attrs[i], &attrType, doc);
5269: ctxt->attrType[j] = attrType.AttrTypeNum;
5270: if (attrType.AttrSSchema)
1.125 vatton 5271: /* the element type concerns an imported nature */
5272: schemaName = TtaGetSSchemaName(attrType.AttrSSchema);
1.119 vatton 5273: #ifdef XML_GENERIC
5274: else if (xmlType == XML_TYPE)
5275: {
5276: /* The attribute is not yet present in the tree */
5277: /* Create a new global attribute */
5278: attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
5279: TtaAppendXmlAttribute (attrs[i], &attrType, doc);
5280: }
5281: #endif /* XML_GENERIC */
5282:
5283: if (attrType.AttrSSchema == NULL)
5284: /* cannot apply these CSS rules */
5285: DoApply = FALSE;
1.136 quint 5286: else if (elType.ElSSchema)
5287: ctxt->schema = elType.ElSSchema;
1.119 vatton 5288: else
1.136 quint 5289: ctxt->schema = attrType.AttrSSchema;
1.119 vatton 5290: }
1.125 vatton 5291: /* check the attribute type */
5292: if (!strcmp (schemaName, "HTML"))
5293: xmlType = XHTML_TYPE;
5294: else if (!strcmp (schemaName, "MathML"))
5295: xmlType = MATH_TYPE;
5296: else if (!strcmp (schemaName, "SVG"))
5297: xmlType = SVG_TYPE;
5298: else if (!strcmp (schemaName, "XLink"))
5299: xmlType = XLINK_TYPE;
5300: else if (!strcmp (schemaName, "Annot"))
5301: xmlType = ANNOT_TYPE;
5302: else
5303: xmlType = XML_TYPE;
5304: kind = TtaGetAttributeKind (attrType);
1.220 ! quint 5305: if (kind == 0 && attrvals[i])
1.125 vatton 5306: {
5307: /* enumerated value */
5308: MapXMLAttributeValue (xmlType, attrvals[i], attrType, &kind);
5309: /* store the attribute value */
5310: ctxt->attrText[j] = (char *) kind;
5311: }
5312: else
5313: ctxt->attrText[j] = attrvals[i];
1.80 cvs 5314: maxAttr = i + 1;
1.129 vatton 5315: /* update attrLevel */
5316: ctxt->attrLevel[j] = i;
5317: j++;
1.25 cvs 5318: }
5319: i++;
1.117 vatton 5320: /* add a new entry */
5321: k++;
1.129 vatton 5322: if (k < j)
5323: k = j;
1.119 vatton 5324: if (i == 1 && ctxt->schema == NULL)
5325: /* use the document schema */
5326: ctxt->schema = TtaGetDocumentSSchema (doc);
1.1 cvs 5327: }
1.117 vatton 5328: /* set the selector specificity */
5329: ctxt->cssSpecificity = specificity;
1.25 cvs 5330: /* sort the list of ancestors by name order */
5331: max = k;
5332: i = 1;
5333: while (i < max)
1.28 cvs 5334: {
5335: for (k = i + 1; k < max; k++)
5336: if (ctxt->name[i] > ctxt->name[k])
5337: {
5338: j = ctxt->name[i];
5339: ctxt->name[i] = ctxt->name[k];
5340: ctxt->name[k] = j;
5341: j = ctxt->names_nb[i];
5342: ctxt->names_nb[i] = ctxt->names_nb[k];
5343: ctxt->names_nb[k] = j;
5344: j = ctxt->attrType[i];
5345: ctxt->attrType[i] = ctxt->attrType[k];
5346: ctxt->attrType[k] = j;
5347: cur = ctxt->attrText[i];
5348: ctxt->attrText[i] = ctxt->attrText[k];
5349: ctxt->attrText[k] = cur;
5350: }
5351: i++;
5352: }
1.84 cvs 5353:
1.25 cvs 5354: /* Get the schema name of the main element */
1.119 vatton 5355: schemaName = TtaGetSSchemaName (ctxt->schema);
5356: isHTML = (strcmp (schemaName, "HTML") == 0);
1.206 vatton 5357: tsch = GetPExtension (doc, ctxt->schema, css, link);
1.217 vatton 5358: skippedNL = NewLineSkipped;
1.119 vatton 5359: if (tsch && cssRule)
5360: ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
1.116 vatton 5361: /* future CSS rules should apply */
5362: DoApply = TRUE;
1.217 vatton 5363: if (selector)
5364: NewLineSkipped = skippedNL;
1.1 cvs 5365: return (selector);
5366: }
5367:
5368: /*----------------------------------------------------------------------
1.206 vatton 5369: ParseStyleDeclaration: parse a style declaration stored in the style
5370: element of a document
5371: We expect the style string to be of the form:
5372: .pinky, .awful { color: pink; font-family: helvetica }
1.1 cvs 5373: ----------------------------------------------------------------------*/
1.206 vatton 5374: static void ParseStyleDeclaration (Element el, char *cssRule, Document doc,
5375: CSSInfoPtr css, Element link, ThotBool destroy)
1.1 cvs 5376: {
1.79 cvs 5377: GenericContext ctxt;
5378: char *decl_end;
5379: char *sel_end;
5380: char *selector;
1.1 cvs 5381:
5382: /* separate the selectors string */
1.82 cvs 5383: cssRule = SkipBlanksAndComments (cssRule);
1.1 cvs 5384: decl_end = cssRule;
1.82 cvs 5385: while (*decl_end != EOS && *decl_end != '{')
1.1 cvs 5386: decl_end++;
1.82 cvs 5387: if (*decl_end == EOS)
1.86 cvs 5388: {
1.168 vatton 5389: CSSPrintError ("Invalid selector", cssRule);
1.86 cvs 5390: return;
5391: }
1.1 cvs 5392: /* verify and clean the selector string */
5393: sel_end = decl_end - 1;
1.82 cvs 5394: while (*sel_end == SPACE || *sel_end == BSPACE ||
5395: *sel_end == EOL || *sel_end == CR)
1.1 cvs 5396: sel_end--;
5397: sel_end++;
1.82 cvs 5398: *sel_end = EOS;
1.1 cvs 5399: selector = cssRule;
5400:
5401: /* now, deal with the content ... */
5402: decl_end++;
5403: cssRule = decl_end;
1.137 vatton 5404: decl_end = &cssRule[strlen (cssRule) - 1];
5405: if (*decl_end != '{')
5406: *decl_end = EOS;
1.1 cvs 5407: /*
5408: * parse the style attribute string and install the corresponding
5409: * presentation attributes on the new element
5410: */
5411: ctxt = TtaGetGenericStyleContext (doc);
5412: if (ctxt == NULL)
5413: return;
5414: ctxt->destroy = destroy;
1.207 vatton 5415: /* first use of the context */
5416: ctxt->uses = 1;
1.197 vatton 5417: while (selector && *selector != EOS)
1.207 vatton 5418: selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css, link);
5419: /* check if the context can be freed */
5420: ctxt->uses -= 1;
5421: if (ctxt->uses == 0)
5422: /* no image loading */
5423: TtaFreeMemory (ctxt);
1.1 cvs 5424: }
5425:
5426: /************************************************************************
5427: * *
5428: * EVALUATION FUNCTIONS / CASCADING AND OVERLOADING *
5429: * *
5430: ************************************************************************/
5431:
5432: /*----------------------------------------------------------------------
1.59 cvs 5433: IsImplicitClassName: return wether the Class name is an
1.1 cvs 5434: implicit one, eg "H1" or "H2 EM" meaning it's a GI name
5435: or an HTML context name.
5436: ----------------------------------------------------------------------*/
1.206 vatton 5437: int IsImplicitClassName (char *class, Document doc)
1.1 cvs 5438: {
1.79 cvs 5439: char name[200];
5440: char *cur = name;
5441: char *first;
5442: char save;
5443: SSchema schema;
1.1 cvs 5444:
5445: /* make a local copy */
1.82 cvs 5446: strncpy (name, class, 199);
1.1 cvs 5447: name[199] = 0;
5448:
5449: /* loop looking if each word is a GI */
5450: while (*cur != 0)
5451: {
5452: first = cur;
5453: cur = SkipWord (cur);
5454: save = *cur;
5455: *cur = 0;
5456: schema = NULL;
5457: if (MapGI (first, &schema, doc) == -1)
5458: {
5459: return (0);
5460: }
5461: *cur = save;
1.82 cvs 5462: cur = SkipBlanksAndComments (cur);
1.1 cvs 5463: }
5464: return (1);
5465: }
5466:
5467: /************************************************************************
5468: * *
1.114 quint 5469: * Functions needed for support of HTML: translate to CSS equivalent *
1.1 cvs 5470: * *
5471: ************************************************************************/
5472:
5473: /*----------------------------------------------------------------------
1.59 cvs 5474: HTMLSetBackgroundColor:
1.1 cvs 5475: ----------------------------------------------------------------------*/
1.79 cvs 5476: void HTMLSetBackgroundColor (Document doc, Element el, char *color)
1.1 cvs 5477: {
1.79 cvs 5478: char css_command[100];
1.1 cvs 5479:
1.82 cvs 5480: sprintf (css_command, "background-color: %s", color);
1.114 quint 5481: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.1 cvs 5482: }
5483:
5484: /*----------------------------------------------------------------------
1.59 cvs 5485: HTMLSetForegroundColor:
1.1 cvs 5486: ----------------------------------------------------------------------*/
1.97 vatton 5487: void HTMLSetForegroundColor (Document doc, Element el, char *color)
1.1 cvs 5488: {
1.79 cvs 5489: char css_command[100];
1.1 cvs 5490:
1.82 cvs 5491: sprintf (css_command, "color: %s", color);
1.114 quint 5492: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.1 cvs 5493: }
5494:
5495: /*----------------------------------------------------------------------
1.59 cvs 5496: HTMLResetBackgroundColor:
1.1 cvs 5497: ----------------------------------------------------------------------*/
1.97 vatton 5498: void HTMLResetBackgroundColor (Document doc, Element el)
1.1 cvs 5499: {
1.79 cvs 5500: char css_command[100];
1.1 cvs 5501:
1.82 cvs 5502: sprintf (css_command, "background: red");
1.114 quint 5503: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5504: }
5505:
5506: /*----------------------------------------------------------------------
1.59 cvs 5507: HTMLResetBackgroundImage:
1.1 cvs 5508: ----------------------------------------------------------------------*/
1.97 vatton 5509: void HTMLResetBackgroundImage (Document doc, Element el)
1.1 cvs 5510: {
1.79 cvs 5511: char css_command[1000];
1.1 cvs 5512:
1.82 cvs 5513: sprintf (css_command, "background-image: url(xx); background-repeat: repeat");
1.114 quint 5514: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5515: }
5516:
5517: /*----------------------------------------------------------------------
1.59 cvs 5518: HTMLResetForegroundColor:
1.1 cvs 5519: ----------------------------------------------------------------------*/
1.97 vatton 5520: void HTMLResetForegroundColor (Document doc, Element el)
1.1 cvs 5521: {
1.79 cvs 5522: char css_command[100];
1.1 cvs 5523:
1.36 cvs 5524: /* it's not necessary to well know the current color but it must be valid */
1.82 cvs 5525: sprintf (css_command, "color: red");
1.114 quint 5526: ParseHTMLSpecificStyle (el, css_command, doc, 0, TRUE);
1.1 cvs 5527: }
5528:
5529: /*----------------------------------------------------------------------
1.59 cvs 5530: HTMLSetAlinkColor:
1.1 cvs 5531: ----------------------------------------------------------------------*/
1.208 vatton 5532: void HTMLSetAlinkColor (Document doc, Element el, char *color)
1.1 cvs 5533: {
1.79 cvs 5534: char css_command[100];
1.1 cvs 5535:
1.215 quint 5536: sprintf (css_command, ":link { color: %s }", color);
1.208 vatton 5537: ApplyCSSRules (el, css_command, doc, FALSE);
1.1 cvs 5538: }
5539:
5540: /*----------------------------------------------------------------------
1.59 cvs 5541: HTMLSetAactiveColor:
1.1 cvs 5542: ----------------------------------------------------------------------*/
1.208 vatton 5543: void HTMLSetAactiveColor (Document doc, Element el, char *color)
1.1 cvs 5544: {
1.79 cvs 5545: char css_command[100];
1.1 cvs 5546:
1.215 quint 5547: sprintf (css_command, ":active { color: %s }", color);
1.208 vatton 5548: ApplyCSSRules (el, css_command, doc, FALSE);
1.1 cvs 5549: }
5550:
5551: /*----------------------------------------------------------------------
1.59 cvs 5552: HTMLSetAvisitedColor:
1.1 cvs 5553: ----------------------------------------------------------------------*/
1.208 vatton 5554: void HTMLSetAvisitedColor (Document doc, Element el, char *color)
1.1 cvs 5555: {
1.79 cvs 5556: char css_command[100];
1.1 cvs 5557:
1.215 quint 5558: sprintf (css_command, ":visited { color: %s }", color);
1.208 vatton 5559: ApplyCSSRules (el, css_command, doc, FALSE);
1.1 cvs 5560: }
5561:
5562: /*----------------------------------------------------------------------
1.59 cvs 5563: HTMLResetAlinkColor:
1.1 cvs 5564: ----------------------------------------------------------------------*/
1.208 vatton 5565: void HTMLResetAlinkColor (Document doc, Element el)
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: red }");
1.208 vatton 5570: ApplyCSSRules (el, css_command, doc, TRUE);
1.1 cvs 5571: }
5572:
5573: /*----------------------------------------------------------------------
1.59 cvs 5574: HTMLResetAactiveColor:
1.1 cvs 5575: ----------------------------------------------------------------------*/
1.208 vatton 5576: void HTMLResetAactiveColor (Document doc, Element el)
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: red }");
1.208 vatton 5581: ApplyCSSRules (el, css_command, doc, TRUE);
1.1 cvs 5582: }
5583:
5584: /*----------------------------------------------------------------------
1.59 cvs 5585: HTMLResetAvisitedColor:
1.1 cvs 5586: ----------------------------------------------------------------------*/
1.208 vatton 5587: void HTMLResetAvisitedColor (Document doc, Element el)
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: red }");
1.208 vatton 5592: ApplyCSSRules (el, css_command, doc, TRUE);
1.1 cvs 5593: }
5594:
5595: /*----------------------------------------------------------------------
1.206 vatton 5596: ApplyCSSRules: parse a CSS Style description stored in the header of
5597: a HTML document.
1.1 cvs 5598: ----------------------------------------------------------------------*/
1.79 cvs 5599: void ApplyCSSRules (Element el, char *cssRule, Document doc, ThotBool destroy)
1.1 cvs 5600: {
1.206 vatton 5601: CSSInfoPtr css;
5602: PInfoPtr pInfo;
1.207 vatton 5603: ThotBool loadcss;
5604:
5605: /* check if we have to load CSS */
5606: TtaGetEnvBoolean ("LOAD_CSS", &loadcss);
5607: if (!loadcss)
5608: return;
1.1 cvs 5609:
1.206 vatton 5610: css = SearchCSS (doc, NULL, el, &pInfo);
1.1 cvs 5611: if (css == NULL)
1.209 vatton 5612: {
5613: /* create the document css context */
5614: css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, CSS_ALL, NULL, NULL, el);
5615: pInfo = css->infos[doc];
5616: }
1.206 vatton 5617: else if (pInfo == NULL)
5618: /* create the entry into the css context */
5619: pInfo = AddInfoCSS (doc, css, CSS_DOCUMENT_STYLE, CSS_ALL, el);
1.209 vatton 5620: if (pInfo->PiEnabled)
5621: ParseStyleDeclaration (el, cssRule, doc, css, el, destroy);
1.1 cvs 5622: }
5623:
5624: /*----------------------------------------------------------------------
1.145 quint 5625: ReadCSSRules: is the front-end function called by the document parser
5626: when detecting a <style type="text/css"> indicating it's the
1.1 cvs 5627: beginning of a CSS fragment or when reading a file .css.
5628:
5629: The CSS parser has to handle <!-- ... --> constructs used to
5630: prevent prehistoric browser from displaying the CSS as a text
5631: content. It will stop on any sequence "<x" where x is different
5632: from ! and will return x as to the caller. Theorically x should
1.145 quint 5633: be equal to / for the </style> end of style.
1.1 cvs 5634: The parameter doc gives the document tree that contains CSS information.
5635: The parameter docRef gives the document to which CSS are to be applied.
5636: This function uses the current css context or creates it. It's able
1.23 cvs 5637: to work on the given buffer or call GetNextChar to read the parsed
1.1 cvs 5638: file.
1.133 vatton 5639: The parameter url gives the URL of the style shheet parsed.
1.86 cvs 5640: Parameter numberOfLinesRead indicates the number of lines already
5641: read in the file.
1.1 cvs 5642: Parameter withUndo indicates whether the changes made in the document
1.145 quint 5643: structure and content have to be registered in the Undo queue or not.
1.1 cvs 5644: ----------------------------------------------------------------------*/
1.133 vatton 5645: char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, char *url,
1.144 quint 5646: int numberOfLinesRead, ThotBool withUndo,
1.206 vatton 5647: Element link)
1.1 cvs 5648: {
1.6 cvs 5649: DisplayMode dispMode;
1.206 vatton 5650: CSSInfoPtr refcss = NULL;
5651: PInfoPtr pInfo;
1.82 cvs 5652: char c;
1.138 vatton 5653: char *cssRule, *base, *saveDocURL, *ptr;
1.19 cvs 5654: int index;
1.1 cvs 5655: int CSSindex;
5656: int CSScomment;
5657: int import;
5658: int openRule;
1.93 vatton 5659: int newlines;
1.14 cvs 5660: ThotBool HTMLcomment;
1.102 vatton 5661: ThotBool toParse, eof, quoted;
1.36 cvs 5662: ThotBool ignoreMedia, media;
1.186 vatton 5663: ThotBool noRule, ignoreImport, skip;
1.1 cvs 5664:
5665: CSScomment = MAX_CSS_LENGTH;
5666: HTMLcomment = FALSE;
5667: CSSindex = 0;
5668: toParse = FALSE;
5669: noRule = FALSE;
1.36 cvs 5670: media = FALSE;
1.88 cvs 5671: ignoreImport = FALSE;
1.1 cvs 5672: ignoreMedia = FALSE;
5673: import = MAX_CSS_LENGTH;
5674: eof = FALSE;
5675: openRule = 0;
1.82 cvs 5676: c = SPACE;
1.1 cvs 5677: index = 0;
1.134 vatton 5678: base = NULL;
1.135 vatton 5679: quoted = FALSE;
1.186 vatton 5680: skip = FALSE;
1.93 vatton 5681: /* number of new lines parsed */
5682: newlines = 0;
1.6 cvs 5683: /* avoid too many redisplay */
5684: dispMode = TtaGetDisplayMode (docRef);
5685: if (dispMode == DisplayImmediately)
5686: TtaSetDisplayMode (docRef, DeferredDisplay);
1.18 cvs 5687:
5688: /* look for the CSS context */
5689: if (css == NULL)
1.206 vatton 5690: css = SearchCSS (docRef, NULL, link, &pInfo);
1.207 vatton 5691: else
5692: pInfo = css->infos[docRef];
1.18 cvs 5693: if (css == NULL)
1.206 vatton 5694: {
5695: css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, CSS_ALL, NULL, NULL, link);
5696: pInfo = css->infos[docRef];
5697: }
5698: else if (pInfo == NULL)
5699: pInfo = AddInfoCSS (docRef, css, CSS_DOCUMENT_STYLE, CSS_ALL, link);
1.174 vatton 5700: /* look for the CSS descriptor that points to the extension schema */
5701: refcss = css;
5702: if (import)
1.173 cvs 5703: {
1.206 vatton 5704: while (refcss &&
5705: refcss->infos[docRef] && refcss->infos[docRef]->PiCategory == CSS_IMPORT)
1.174 vatton 5706: refcss = refcss->NextCSS;
1.206 vatton 5707: if (refcss)
5708: pInfo = refcss->infos[docRef];
1.173 cvs 5709: }
5710:
1.144 quint 5711: /* register parsed CSS file and the document to which CSS are to be applied*/
1.86 cvs 5712: ParsedDoc = docRef;
1.133 vatton 5713: if (url)
5714: DocURL = url;
1.86 cvs 5715: else
5716: /* the CSS source in within the document itself */
5717: DocURL = DocumentURLs[docRef];
5718: LineNumber = numberOfLinesRead + 1;
1.93 vatton 5719: NewLineSkipped = 0;
1.217 vatton 5720: newlines = 0;
1.82 cvs 5721: while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof)
5722: {
5723: c = buffer[index++];
5724: eof = (c == EOS);
5725: CSSbuffer[CSSindex] = c;
1.186 vatton 5726: if (skip)
5727: {
5728: if (c == '}')
5729: {
5730: /* end of the @font-face */
5731: skip = FALSE;
5732: import = MAX_CSS_LENGTH;
5733: noRule = TRUE;
5734: CSSindex = 0;
5735: }
1.217 vatton 5736: /*if (c == EOL)
5737: LineNumber++;*/
1.186 vatton 5738: c = CR;
5739: }
5740: else if (CSScomment == MAX_CSS_LENGTH ||
1.82 cvs 5741: c == '*' || c == '/' || c == '<')
5742: {
5743: /* we're not within a comment or we're parsing * or / */
5744: switch (c)
5745: {
5746: case '@': /* perhaps an import primitive */
1.135 vatton 5747: if (!quoted)
5748: import = CSSindex;
1.82 cvs 5749: break;
5750: case ';':
1.135 vatton 5751: if (!quoted && !media && import != MAX_CSS_LENGTH)
1.82 cvs 5752: {
5753: if (strncasecmp (&CSSbuffer[import+1], "import", 6))
5754: /* it's not an import */
5755: import = MAX_CSS_LENGTH;
5756: /* save the text */
5757: noRule = TRUE;
5758: }
5759: break;
5760: case '*':
1.135 vatton 5761: if (!quoted && CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.82 cvs 5762: CSSbuffer[CSSindex - 1] == '/')
5763: /* start a comment */
5764: CSScomment = CSSindex - 1;
5765: break;
5766: case '/':
1.135 vatton 5767: if (!quoted && CSSindex > 1 && CSScomment != MAX_CSS_LENGTH &&
1.82 cvs 5768: CSSbuffer[CSSindex - 1] == '*')
5769: {
5770: /* close a comment:and ignore its contents */
5771: CSSindex = CSScomment - 1; /* will be incremented later */
5772: CSScomment = MAX_CSS_LENGTH;
1.93 vatton 5773: /* clean up the buffer */
1.103 vatton 5774: if (newlines && CSSindex > 0)
5775: while (CSSindex > 0 &&
5776: (CSSbuffer[CSSindex] == SPACE ||
5777: CSSbuffer[CSSindex] == BSPACE ||
5778: CSSbuffer[CSSindex] == EOL ||
5779: CSSbuffer[CSSindex] == TAB ||
5780: CSSbuffer[CSSindex] == __CR__))
1.93 vatton 5781: {
5782: if ( CSSbuffer[CSSindex] == EOL)
5783: {
5784: LineNumber ++;
1.217 vatton 5785: newlines --;
1.93 vatton 5786: }
5787: CSSindex--;
5788: }
1.82 cvs 5789: }
1.135 vatton 5790: else if (!quoted && CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
1.82 cvs 5791: CSSbuffer[CSSindex - 1] == '<')
5792: {
5793: /* this is the closing tag ! */
5794: CSSindex -= 2; /* remove </ from the CSS string */
5795: noRule = TRUE;
5796: }
5797: break;
5798: case '<':
1.135 vatton 5799: if (!quoted && CSScomment == MAX_CSS_LENGTH)
1.82 cvs 5800: {
5801: /* only if we're not parsing a comment */
5802: c = buffer[index++];
5803: eof = (c == EOS);
5804: if (c == '!')
5805: {
5806: /* CSS within an HTML comment */
5807: HTMLcomment = TRUE;
5808: CSSindex++;
5809: CSSbuffer[CSSindex] = c;
5810: }
5811: else if (c == EOS)
5812: CSSindex++;
5813: }
5814: break;
5815: case '-':
1.135 vatton 5816: if (!quoted && CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' &&
1.82 cvs 5817: HTMLcomment)
5818: /* CSS within an HTML comment */
5819: noRule = TRUE;
5820: break;
5821: case '>':
1.135 vatton 5822: if (!quoted && HTMLcomment)
1.82 cvs 5823: noRule = TRUE;
5824: break;
5825: case ' ':
1.135 vatton 5826: if (!quoted && import != MAX_CSS_LENGTH && openRule == 0)
1.162 quint 5827: media = !strncasecmp (&CSSbuffer[import+1], "media", 5);
1.82 cvs 5828: break;
5829: case '{':
1.135 vatton 5830: if (!quoted)
1.82 cvs 5831: {
1.135 vatton 5832: openRule++;
5833: if (import != MAX_CSS_LENGTH && openRule == 1 && media)
5834: {
5835: /* is it the screen concerned? */
5836: CSSbuffer[CSSindex+1] = EOS;
5837: if (TtaIsPrinting ())
5838: base = strstr (&CSSbuffer[import], "print");
5839: else
5840: base = strstr (&CSSbuffer[import], "screen");
5841: if (base == NULL)
5842: base = strstr (&CSSbuffer[import], "all");
5843: if (base == NULL)
5844: ignoreMedia = TRUE;
5845: noRule = TRUE;
5846: }
1.186 vatton 5847: else if (import != MAX_CSS_LENGTH &&
5848: !strncasecmp (&CSSbuffer[import], "@font-face", 10))
5849: skip = TRUE;
1.135 vatton 5850: }
5851: break;
5852: case '}':
5853: if (!quoted)
5854: {
5855: openRule--;
5856: if (import != MAX_CSS_LENGTH && openRule == 0)
5857: {
5858: import = MAX_CSS_LENGTH;
5859: noRule = TRUE;
5860: ignoreMedia = FALSE;
5861: media = FALSE;
5862: }
1.82 cvs 5863: else
1.135 vatton 5864: toParse = TRUE;
1.82 cvs 5865: }
5866: break;
1.135 vatton 5867: case '"':
5868: if (quoted)
1.82 cvs 5869: {
1.135 vatton 5870: if (CSSbuffer[CSSindex - 1] != '\\')
5871: quoted = FALSE;
1.82 cvs 5872: }
5873: else
1.135 vatton 5874: quoted = TRUE;
1.82 cvs 5875: break;
5876: default:
1.86 cvs 5877: if (c == EOL)
1.93 vatton 5878: newlines++;
1.82 cvs 5879: break;
5880: }
5881: }
1.93 vatton 5882: else if (c == EOL)
1.217 vatton 5883: {
5884: LineNumber++;
5885: c = CR;
5886: }
1.82 cvs 5887: if (c != CR)
5888: CSSindex++;
5889:
5890: if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
5891: /* we're still parsing a comment: remove the text comment */
5892: CSSindex = CSScomment;
5893:
5894: if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule)
5895: {
5896: CSSbuffer[CSSindex] = EOS;
5897: /* parse a not empty string */
5898: if (CSSindex > 0)
5899: {
1.50 cvs 5900: /* apply CSS rule if it's not just a saving of text */
5901: if (!noRule && !ignoreMedia)
1.88 cvs 5902: {
5903: /* future import rules must be ignored */
5904: ignoreImport = TRUE;
1.217 vatton 5905: NewLineSkipped = 0;
1.210 vatton 5906: ParseStyleDeclaration (NULL, CSSbuffer, docRef, refcss,
5907: pInfo->PiLink, FALSE);
1.93 vatton 5908: LineNumber += newlines;
5909: newlines = 0;
1.88 cvs 5910: }
1.82 cvs 5911: else if (import != MAX_CSS_LENGTH &&
5912: !strncasecmp (&CSSbuffer[import+1], "import", 6))
5913: {
5914: /* import section */
5915: cssRule = &CSSbuffer[import+7];
5916: cssRule = TtaSkipBlanks (cssRule);
1.93 vatton 5917: /* save the current line number */
5918: newlines += LineNumber;
1.82 cvs 5919: if (!strncasecmp (cssRule, "url", 3))
5920: {
1.50 cvs 5921: cssRule = &cssRule[3];
1.82 cvs 5922: cssRule = TtaSkipBlanks (cssRule);
5923: if (*cssRule == '(')
5924: {
5925: cssRule++;
5926: cssRule = TtaSkipBlanks (cssRule);
1.102 vatton 5927: quoted = (*cssRule == '"' || *cssRule == '\'');
5928: if (quoted)
5929: cssRule++;
1.82 cvs 5930: base = cssRule;
5931: while (*cssRule != EOS && *cssRule != ')')
5932: cssRule++;
1.102 vatton 5933: if (quoted)
1.167 vatton 5934: {
5935: /* isolate the file name */
5936: cssRule[-1] = EOS;
5937: quoted = FALSE;
5938: }
1.216 vatton 5939: else
5940: {
5941: /* remove extra spaces */
5942: if (cssRule[-1] == SPACE)
5943: {
5944: *cssRule = SPACE;
5945: cssRule--;
5946: while (cssRule[-1] == SPACE)
5947: cssRule--;
5948: }
5949: }
1.160 vatton 5950: *cssRule = EOS;
1.82 cvs 5951: }
5952: }
1.87 cvs 5953: else if (*cssRule == '"')
5954: {
1.88 cvs 5955: /*
5956: Do we have to accept single quotes?
5957: Double quotes are acceted here.
5958: Escaped quotes are not handled. See function SkipQuotedString
5959: */
1.87 cvs 5960: cssRule++;
5961: cssRule = TtaSkipBlanks (cssRule);
5962: base = cssRule;
1.179 vatton 5963: while (*cssRule != EOS &&
5964: (*cssRule != '"' ||
1.180 vatton 5965: (*cssRule == '"' && cssRule[-1] == '\\')))
1.87 cvs 5966: cssRule++;
1.160 vatton 5967: /* isolate the file name */
5968: *cssRule = EOS;
1.133 vatton 5969: }
5970: /* check if a media is defined */
5971: cssRule++;
5972: cssRule = TtaSkipBlanks (cssRule);
5973: if (*cssRule != ';')
5974: {
5975: if (TtaIsPrinting ())
5976: ignoreImport = (strncasecmp (cssRule, "print", 5) &&
5977: strncasecmp (cssRule, "all", 3));
5978: else
5979: ignoreImport = (strncasecmp (cssRule, "screen", 6) &&
5980: strncasecmp (cssRule, "all", 3));
5981: }
5982: if (!ignoreImport)
5983: {
5984: /* save the displayed URL when an error is reported */
5985: saveDocURL = DocURL;
1.138 vatton 5986: ptr = TtaStrdup (base);
5987: /* get the CSS URI in UTF-8 */
5988: ptr = ReallocUTF8String (ptr, docRef);
1.206 vatton 5989: LoadStyleSheet (base, docRef, (Element) css, css,
5990: pInfo->PiMedia,
5991: pInfo->PiCategory == CSS_USER_STYLE);
1.133 vatton 5992: /* restore the displayed URL when an error is reported */
5993: DocURL = saveDocURL;
1.138 vatton 5994: TtaFreeMemory (ptr);
1.82 cvs 5995: }
1.93 vatton 5996: /* restore the number of lines */
5997: LineNumber = newlines;
5998: newlines = 0;
1.217 vatton 5999: NewLineSkipped = 0;
1.82 cvs 6000: import = MAX_CSS_LENGTH;
6001: }
1.93 vatton 6002:
1.82 cvs 6003: }
6004: toParse = FALSE;
6005: noRule = FALSE;
6006: CSSindex = 0;
1.50 cvs 6007: }
1.82 cvs 6008: }
1.6 cvs 6009: /* restore the display mode */
6010: if (dispMode == DisplayImmediately)
1.82 cvs 6011: TtaSetDisplayMode (docRef, dispMode);
1.86 cvs 6012:
6013: /* Prepare the context for style attributes */
6014: DocURL = DocumentURLs[docRef];
6015: LineNumber = -1;
1.1 cvs 6016: return (c);
6017: }
1.89 cvs 6018:
Webmaster