Annotation of Amaya/amaya/styleparser.c, revision 1.73
1.1 cvs 1: /*
2: *
1.55 cvs 3: * (c) COPYRIGHT MIT and INRIA, 1996-2000
1.1 cvs 4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
1.53 cvs 7:
1.1 cvs 8: /*
9: * Everything directly linked to the CSS syntax should now hopefully
10: * be contained in this module.
11: *
12: * Author: I. Vatton
1.55 cvs 13: * R. Guetari: Unicode.
1.1 cvs 14: *
15: */
16:
17: /* Included headerfiles */
18: #define THOT_EXPORT extern
19: #include "amaya.h"
20: #include "css.h"
21: #include "undo.h"
1.52 cvs 22: #include "registry.h"
1.25 cvs 23: #include "fetchHTMLname.h"
1.61 cvs 24: #include "GraphML.h"
1.50 cvs 25: #include "uaccess.h"
1.1 cvs 26:
27: typedef struct _BackgroundImageCallbackBlock
28: {
29: Element el;
30: PSchema tsch;
31: union
32: {
33: PresentationContextBlock specific;
34: GenericContextBlock generic;
35: } context;
36: }
37: BackgroundImageCallbackBlock, *BackgroundImageCallbackPtr;
38:
39: #include "AHTURLTools_f.h"
40: #include "HTMLpresentation_f.h"
41: #include "HTMLimage_f.h"
42: #include "UIcss_f.h"
43: #include "css_f.h"
1.24 cvs 44: #include "fetchHTMLname_f.h"
1.1 cvs 45: #include "html2thot_f.h"
46: #include "styleparser_f.h"
47:
48: #define MAX_BUFFER_LENGTH 200
49: /*
50: * A PropertyParser is a function used to parse the
51: * description substring associated to a given style attribute
1.59 cvs 52: * e.g.: "red" for a color attribute or "12pt bold helvetica"
1.1 cvs 53: * for a font attribute.
54: */
55: #ifdef __STDC__
1.50 cvs 56: typedef CHAR_T* (*PropertyParser) (Element element,
1.56 cvs 57: PSchema tsch,
58: PresentationContext context,
59: CHAR_T* cssRule,
60: CSSInfoPtr css,
61: ThotBool isHTML);
1.1 cvs 62: #else
1.50 cvs 63: typedef CHAR_T* (*PropertyParser) ();
1.1 cvs 64: #endif
65:
66: /* Description of the set of CSS properties supported */
67: typedef struct CSSProperty
68: {
1.50 cvs 69: CHAR_T* name;
1.25 cvs 70: PropertyParser parsing_function;
1.1 cvs 71: }
72: CSSProperty;
73:
74: struct unit_def
75: {
1.50 cvs 76: CHAR_T* sign;
1.1 cvs 77: unsigned int unit;
78: };
79:
80: static struct unit_def CSSUnitNames[] =
81: {
1.50 cvs 82: {TEXT("pt"), STYLE_UNIT_PT},
83: {TEXT("pc"), STYLE_UNIT_PC},
84: {TEXT("in"), STYLE_UNIT_IN},
85: {TEXT("cm"), STYLE_UNIT_CM},
86: {TEXT("mm"), STYLE_UNIT_MM},
87: {TEXT("em"), STYLE_UNIT_EM},
88: {TEXT("px"), STYLE_UNIT_PX},
89: {TEXT("ex"), STYLE_UNIT_XHEIGHT},
90: {TEXT("%"), STYLE_UNIT_PERCENT}
1.1 cvs 91: };
92:
93: #define NB_UNITS (sizeof(CSSUnitNames) / sizeof(struct unit_def))
94:
95: /*----------------------------------------------------------------------
96: SkipWord:
97: ----------------------------------------------------------------------*/
98: #ifdef __STDC__
1.50 cvs 99: static CHAR_T* SkipWord (CHAR_T* ptr)
1.1 cvs 100: #else
1.50 cvs 101: static CHAR_T* SkipWord (ptr)
102: CHAR_T* ptr;
1.1 cvs 103: #endif
104: {
1.50 cvs 105: # ifdef _WINDOWS
106: /* iswalnum is supposed to be supported by the i18n veriosn of libc
107: use it when available */
108: while (iswalnum (*ptr) || *ptr == TEXT('-') || *ptr == TEXT('%'))
109: # else /* !_WINDOWS */
110: while (isalnum((int)*ptr) || *ptr == TEXT('-') || *ptr == TEXT('%'))
111: # endif /* !_WINDOWS */
112: ptr++;
1.1 cvs 113: return (ptr);
114: }
115:
116: /*----------------------------------------------------------------------
1.13 cvs 117: SkipBlanksAndComments:
118: ----------------------------------------------------------------------*/
119: #ifdef __STDC__
1.47 cvs 120: char* SkipBlanksAndComments (char* ptr)
1.13 cvs 121: #else
1.47 cvs 122: char* SkipBlanksAndComments (ptr)
123: char* ptr;
1.13 cvs 124: #endif
125: {
126: ptr = TtaSkipBlanks (ptr);
127: while (ptr[0] == '/' && ptr[1] == '*')
128: {
129: /* look for the end of the comment */
130: ptr = &ptr[2];
131: while (ptr[0] != EOS && (ptr[0] != '*' || ptr[1] != '/'))
132: ptr++;
133: if (ptr[0] != EOS)
134: ptr = &ptr[2];
135: ptr = TtaSkipBlanks (ptr);
136: }
137: return (ptr);
138: }
139:
140: /*----------------------------------------------------------------------
1.49 cvs 141: SkipWCBlanksAndComments:
142: ----------------------------------------------------------------------*/
143: #ifdef __STDC__
144: CHAR_T* SkipWCBlanksAndComments (CHAR_T* ptr)
145: #else
146: CHAR_T* SkipWCBlanksAndComments (ptr)
147: CHAR_T* ptr;
148: #endif
149: {
150: ptr = TtaSkipWCBlanks (ptr);
151: while (ptr[0] == TEXT('/') && ptr[1] == TEXT('*'))
152: {
153: /* look for the end of the comment */
154: ptr = &ptr[2];
155: while (ptr[0] != WC_EOS && (ptr[0] != TEXT('*') || ptr[1] != TEXT('/')))
156: ptr++;
157: if (ptr[0] != WC_EOS)
158: ptr = &ptr[2];
159: ptr = TtaSkipWCBlanks (ptr);
160: }
161: return (ptr);
162: }
163:
164: /*----------------------------------------------------------------------
1.1 cvs 165: SkipQuotedString:
166: ----------------------------------------------------------------------*/
167: #ifdef __STDC__
1.50 cvs 168: static CHAR_T* SkipQuotedString (CHAR_T* ptr, CHAR_T quote)
1.1 cvs 169: #else
1.50 cvs 170: static CHAR_T* SkipQuotedString (ptr, quote)
171: CHAR_T* ptr;
172: CHAR_T quote;
1.1 cvs 173: #endif
174: {
1.14 cvs 175: ThotBool stop;
1.1 cvs 176:
177: stop = FALSE;
178: while (!stop)
179: {
180: if (*ptr == quote)
181: {
182: ptr++;
183: stop = TRUE;
184: }
1.50 cvs 185: else if (*ptr == WC_EOS)
1.1 cvs 186: stop = TRUE;
1.50 cvs 187: else if (*ptr == TEXT('\\'))
1.1 cvs 188: /* escape character */
189: {
190: ptr++;
1.50 cvs 191: if ((*ptr >= TEXT('0') && *ptr <= TEXT('9')) || (*ptr >= TEXT('A') && *ptr <= TEXT('F')) ||
192: (*ptr >= TEXT('a') && *ptr <= TEXT('f')))
1.1 cvs 193: {
194: ptr++;
1.50 cvs 195: if ((*ptr >= TEXT('0') && *ptr <= TEXT('9')) || (*ptr >= TEXT('A') && *ptr <= TEXT('F')) ||
196: (*ptr >= TEXT('a') && *ptr <= TEXT('f')))
1.1 cvs 197: ptr++;
198: }
199: else
200: ptr++;
201: }
202: else
203: ptr++;
204: }
205: return (ptr);
206: }
207:
208: /*----------------------------------------------------------------------
209: SkipProperty:
210: ----------------------------------------------------------------------*/
211: #ifdef __STDC__
1.50 cvs 212: CHAR_T* SkipProperty (CHAR_T* ptr)
1.1 cvs 213: #else
1.50 cvs 214: CHAR_T* SkipProperty (ptr)
215: CHAR_T* ptr;
1.1 cvs 216: #endif
217: {
1.50 cvs 218: while (*ptr != WC_EOS && *ptr != TEXT(';') && *ptr != TEXT('}'))
1.1 cvs 219: ptr++;
220: return (ptr);
221: }
222:
223: /*----------------------------------------------------------------------
1.64 cvs 224: ParseNumber:
225: parse a number and returns the corresponding value.
1.1 cvs 226: ----------------------------------------------------------------------*/
227: #ifdef __STDC__
1.64 cvs 228: CHAR_T* ParseNumber (CHAR_T* cssRule, PresentationValue *pval)
1.1 cvs 229: #else
1.64 cvs 230: CHAR_T* ParseNumber (cssRule, pval)
1.56 cvs 231: CHAR_T* cssRule;
1.1 cvs 232: PresentationValue *pval;
233: #endif
234: {
235: int val = 0;
236: int minus = 0;
237: int valid = 0;
238: int f = 0;
1.14 cvs 239: ThotBool real = FALSE;
1.1 cvs 240:
241: pval->typed_data.unit = STYLE_UNIT_REL;
242: pval->typed_data.real = FALSE;
1.50 cvs 243: cssRule = SkipWCBlanksAndComments (cssRule);
244: if (*cssRule == TEXT('-'))
1.1 cvs 245: {
246: minus = 1;
247: cssRule++;
1.50 cvs 248: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 249: }
250:
1.50 cvs 251: if (*cssRule == TEXT('+'))
1.1 cvs 252: {
253: cssRule++;
1.50 cvs 254: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 255: }
256:
1.50 cvs 257: while ((*cssRule >= TEXT('0')) && (*cssRule <= TEXT('9')))
1.1 cvs 258: {
259: val *= 10;
1.50 cvs 260: val += *cssRule - TEXT('0');
1.1 cvs 261: cssRule++;
262: valid = 1;
263: }
264:
1.50 cvs 265: if (*cssRule == TEXT('.'))
1.1 cvs 266: {
267: real = TRUE;
268: f = val;
269: val = 0;
270: cssRule++;
271: /* keep only 3 digits */
1.50 cvs 272: if (*cssRule >= TEXT('0') && *cssRule <= TEXT('9'))
1.1 cvs 273: {
1.50 cvs 274: val = (*cssRule - TEXT('0')) * 100;
1.1 cvs 275: cssRule++;
1.50 cvs 276: if (*cssRule >= TEXT('0') && *cssRule <= TEXT('9'))
1.1 cvs 277: {
1.50 cvs 278: val += (*cssRule - TEXT('0')) * 10;
1.1 cvs 279: cssRule++;
1.50 cvs 280: if ((*cssRule >= TEXT('0')) && (*cssRule <= TEXT('9')))
1.1 cvs 281: {
1.50 cvs 282: val += *cssRule - TEXT('0');
1.1 cvs 283: cssRule++;
284: }
285: }
286:
1.50 cvs 287: while (*cssRule >= TEXT('0') && *cssRule <= TEXT('9'))
1.1 cvs 288: cssRule++;
289: valid = 1;
290: }
291: }
292:
293: if (!valid)
294: {
295: pval->typed_data.unit = STYLE_UNIT_INVALID;
296: pval->typed_data.value = 0;
297: }
298: else
299: {
300: pval->typed_data.real = real;
301: if (real)
302: {
303: if (minus)
304: pval->typed_data.value = -(f * 1000 + val);
305: else
306: pval->typed_data.value = f * 1000 + val;
307: }
308: else
309: {
310: if (minus)
311: pval->typed_data.value = -val;
312: else
313: pval->typed_data.value = val;
314: }
1.64 cvs 315: }
316: return (cssRule);
317: }
318:
319: /*----------------------------------------------------------------------
320: ParseCSSUnit:
321: parse a CSS Unit substring and returns the corresponding
322: value and its unit.
323: ----------------------------------------------------------------------*/
324: #ifdef __STDC__
1.66 cvs 325: CHAR_T *ParseCSSUnit (CHAR_T* cssRule, PresentationValue *pval)
1.64 cvs 326: #else
1.66 cvs 327: CHAR_T *ParseCSSUnit (cssRule, pval)
328: CHAR_T *cssRule;
329: PresentationValue *pval;
1.64 cvs 330: #endif
331: {
332: unsigned int uni;
333:
334: pval->typed_data.unit = STYLE_UNIT_REL;
335: cssRule = ParseNumber (cssRule, pval);
336: if (pval->typed_data.unit == STYLE_UNIT_INVALID)
337: cssRule = SkipWord (cssRule);
338: else
339: {
340: cssRule = SkipWCBlanksAndComments (cssRule);
341: for (uni = 0; uni < NB_UNITS; uni++)
342: {
343: if (!ustrncasecmp (CSSUnitNames[uni].sign, cssRule,
344: ustrlen (CSSUnitNames[uni].sign)))
345: {
346: pval->typed_data.unit = CSSUnitNames[uni].unit;
347: return (cssRule + ustrlen (CSSUnitNames[uni].sign));
348: }
349: }
350: /* not in the list of predefined units */
351: pval->typed_data.unit = STYLE_UNIT_PX;
1.1 cvs 352: }
353: return (cssRule);
354: }
355:
1.43 cvs 356: /*----------------------------------------------------------------------
357: ParseBorderValue
358: ----------------------------------------------------------------------*/
359: #ifdef __STDC__
1.50 cvs 360: static CHAR_T* ParseBorderValue (CHAR_T* cssRule, PresentationValue *border)
1.43 cvs 361: #else
1.50 cvs 362: static CHAR_T* ParseBorderValue (cssRule, border)
363: CHAR_T* cssRule;
1.43 cvs 364: PresentationValue *border
365: #endif
366: {
367: /* first parse the attribute string */
368: border->typed_data.value = 0;
1.44 cvs 369: border->typed_data.unit = STYLE_UNIT_INVALID;
1.43 cvs 370: border->typed_data.real = FALSE;
1.50 cvs 371: if (!ustrncasecmp (cssRule, TEXT("thin"), 4))
1.43 cvs 372: {
1.44 cvs 373: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 374: border->typed_data.value = 1;
375: cssRule = SkipWord (cssRule);
376: }
1.50 cvs 377: else if (!ustrncasecmp (cssRule, TEXT("medium"), 6))
1.43 cvs 378: {
1.44 cvs 379: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 380: border->typed_data.value = 3;
381: cssRule = SkipWord (cssRule);
382: }
1.50 cvs 383: else if (!ustrncasecmp (cssRule, TEXT("thick"), 5))
1.43 cvs 384: {
1.44 cvs 385: border->typed_data.unit = STYLE_UNIT_PX;
1.43 cvs 386: border->typed_data.value = 5;
387: cssRule = SkipWord (cssRule);
388: }
1.50 cvs 389: else if (TtaIsDigit (*cssRule))
1.43 cvs 390: cssRule = ParseCSSUnit (cssRule, border);
391: return (cssRule);
392: }
393:
394: /*----------------------------------------------------------------------
395: ParseBorderStyle
396: ----------------------------------------------------------------------*/
397: #ifdef __STDC__
1.50 cvs 398: static CHAR_T* ParseBorderStyle (CHAR_T* cssRule, PresentationValue *border)
1.43 cvs 399: #else
1.50 cvs 400: static CHAR_T* ParseBorderStyle (cssRule, border)
401: CHAR_T* cssRule;
1.43 cvs 402: PresentationValue *border
403: #endif
404: {
405: /* first parse the attribute string */
406: border->typed_data.value = 0;
407: border->typed_data.unit = STYLE_UNIT_PX;
408: border->typed_data.real = FALSE;
1.50 cvs 409: if (!ustrncasecmp (cssRule, TEXT("none"), 4))
1.43 cvs 410: border->typed_data.value = STYLE_BORDERNONE;
1.50 cvs 411: else if (!ustrncasecmp (cssRule, TEXT("hidden"), 6))
1.43 cvs 412: border->typed_data.value = STYLE_BORDERHIDDEN;
1.50 cvs 413: else if (!ustrncasecmp (cssRule, TEXT("dotted"), 6))
1.43 cvs 414: border->typed_data.value = STYLE_BORDERDOTTED;
1.50 cvs 415: else if (!ustrncasecmp (cssRule, TEXT("dashed"), 6))
1.43 cvs 416: border->typed_data.value = STYLE_BORDERDASHED;
1.50 cvs 417: else if (!ustrncasecmp (cssRule, TEXT("solid"), 5))
1.43 cvs 418: border->typed_data.value = STYLE_BORDERSOLID;
1.50 cvs 419: else if (!ustrncasecmp (cssRule, TEXT("double"), 6))
1.43 cvs 420: border->typed_data.value = STYLE_BORDERDOUBLE;
1.50 cvs 421: else if (!ustrncasecmp (cssRule, TEXT("groove"), 6))
1.43 cvs 422: border->typed_data.value = STYLE_BORDERGROOVE;
1.50 cvs 423: else if (!ustrncasecmp (cssRule, TEXT("ridge"), 5))
1.43 cvs 424: border->typed_data.value = STYLE_BORDERRIDGE;
1.50 cvs 425: else if (!ustrncasecmp (cssRule, TEXT("inset"), 5))
1.43 cvs 426: border->typed_data.value = STYLE_BORDERINSET;
1.50 cvs 427: else if (!ustrncasecmp (cssRule, TEXT("outset"), 6))
1.43 cvs 428: border->typed_data.value = STYLE_BORDEROUTSET;
429: else
1.44 cvs 430: {
431: /* invalid style */
432: border->typed_data.unit = STYLE_UNIT_INVALID;
433: return (cssRule);
434: }
1.43 cvs 435: /* the value is parsed now */
436: cssRule = SkipWord (cssRule);
437: return (cssRule);
438: }
439:
440: /*----------------------------------------------------------------------
1.59 cvs 441: ParseCSSColor: parse a CSS color attribute string
1.43 cvs 442: we expect the input string describing the attribute to be
443: either a color name, a 3 tuple or an hexadecimal encoding.
444: The color used will be approximed from the current color
445: table
446: ----------------------------------------------------------------------*/
447: #ifdef __STDC__
1.50 cvs 448: static CHAR_T* ParseCSSColor (CHAR_T* cssRule, PresentationValue * val)
1.43 cvs 449: #else
1.50 cvs 450: static CHAR_T* ParseCSSColor (cssRule, val)
451: CHAR_T* cssRule;
452: PresentationValue *val;
1.43 cvs 453: #endif
454: {
1.50 cvs 455: CHAR_T* ptr;
1.43 cvs 456: unsigned short redval = (unsigned short) -1;
457: unsigned short greenval = 0; /* composant of each RGB */
458: unsigned short blueval = 0; /* default to red if unknown ! */
459: int best = 0; /* best color in list found */
460:
1.50 cvs 461: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 462: val->typed_data.unit = STYLE_UNIT_INVALID;
463: val->typed_data.real = FALSE;
464: val->typed_data.value = 0;
1.57 cvs 465: ptr = TtaGiveRGB (cssRule, &redval, &greenval, &blueval);
466: if (ptr == cssRule)
1.43 cvs 467: {
1.57 cvs 468: cssRule = SkipProperty (cssRule);
1.43 cvs 469: val->typed_data.value = 0;
470: val->typed_data.unit = STYLE_UNIT_INVALID;
471: }
472: else
473: {
474: best = TtaGetThotColor (redval, greenval, blueval);
475: val->typed_data.value = best;
476: val->typed_data.unit = STYLE_UNIT_REL;
1.57 cvs 477: cssRule = ptr;
1.43 cvs 478: }
479: val->typed_data.real = FALSE;
1.65 cvs 480: return (cssRule);
1.43 cvs 481: }
1.1 cvs 482:
483: /*----------------------------------------------------------------------
1.59 cvs 484: ParseCSSBorderTopWidth: parse a CSS BorderTopWidth
1.1 cvs 485: attribute string.
486: ----------------------------------------------------------------------*/
487: #ifdef __STDC__
1.50 cvs 488: static CHAR_T* ParseCSSBorderTopWidth (Element element, PSchema tsch,
489: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 490: #else
1.50 cvs 491: static CHAR_T* ParseCSSBorderTopWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 492: Element element;
493: PSchema tsch;
494: PresentationContext context;
1.50 cvs 495: CHAR_T* cssRule;
1.1 cvs 496: CSSInfoPtr css;
1.14 cvs 497: ThotBool isHTML;
1.1 cvs 498: #endif
499: {
1.41 cvs 500: PresentationValue border;
501:
1.50 cvs 502: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 503: cssRule = ParseBorderValue (cssRule, &border);
504: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 cvs 505: {
506: TtaSetStylePresentation (PRBorderTopWidth, element, tsch, context, border);
507: border.typed_data.value = 1;
508: border.typed_data.unit = STYLE_UNIT_REL;
509: }
1.1 cvs 510: return (cssRule);
511: }
512:
513: /*----------------------------------------------------------------------
1.59 cvs 514: ParseCSSBorderBottomWidth: parse a CSS BorderBottomWidth
1.1 cvs 515: attribute string.
516: ----------------------------------------------------------------------*/
517: #ifdef __STDC__
1.50 cvs 518: static CHAR_T* ParseCSSBorderBottomWidth (Element element, PSchema tsch,
519: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 520: #else
1.50 cvs 521: static CHAR_T* ParseCSSBorderBottomWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 522: Element element;
523: PSchema tsch;
524: PresentationContext context;
1.50 cvs 525: CHAR_T* cssRule;
1.1 cvs 526: CSSInfoPtr css;
1.14 cvs 527: ThotBool isHTML;
1.1 cvs 528: #endif
529: {
1.41 cvs 530: PresentationValue border;
531:
1.50 cvs 532: cssRule = SkipWCBlanksAndComments (cssRule);
1.41 cvs 533: /* first parse the attribute string */
1.43 cvs 534: cssRule = ParseBorderValue (cssRule, &border);
535: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 cvs 536: {
537: TtaSetStylePresentation (PRBorderBottomWidth, element, tsch, context, border);
538: border.typed_data.value = 1;
539: border.typed_data.unit = STYLE_UNIT_REL;
540: }
1.1 cvs 541: return (cssRule);
542: }
543:
544: /*----------------------------------------------------------------------
1.59 cvs 545: ParseCSSBorderLeftWidth: parse a CSS BorderLeftWidth
1.1 cvs 546: attribute string.
547: ----------------------------------------------------------------------*/
548: #ifdef __STDC__
1.50 cvs 549: static CHAR_T* ParseCSSBorderLeftWidth (Element element, PSchema tsch,
550: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 551: #else
1.50 cvs 552: static CHAR_T* ParseCSSBorderLeftWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 553: Element element;
554: PSchema tsch;
555: PresentationContext context;
1.50 cvs 556: CHAR_T* cssRule;
1.1 cvs 557: CSSInfoPtr css;
1.14 cvs 558: ThotBool isHTML;
1.1 cvs 559: #endif
560: {
1.41 cvs 561: PresentationValue border;
562:
1.50 cvs 563: cssRule = SkipWCBlanksAndComments (cssRule);
1.41 cvs 564: /* first parse the attribute string */
1.43 cvs 565: cssRule = ParseBorderValue (cssRule, &border);
566: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 cvs 567: {
568: TtaSetStylePresentation (PRBorderLeftWidth, element, tsch, context, border);
569: border.typed_data.value = 1;
570: border.typed_data.unit = STYLE_UNIT_REL;
571: }
1.1 cvs 572: return (cssRule);
573: }
574:
575: /*----------------------------------------------------------------------
1.59 cvs 576: ParseCSSBorderRightWidth: parse a CSS BorderRightWidth
1.1 cvs 577: attribute string.
578: ----------------------------------------------------------------------*/
579: #ifdef __STDC__
1.50 cvs 580: static CHAR_T* ParseCSSBorderRightWidth (Element element, PSchema tsch,
581: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 582: #else
1.50 cvs 583: static CHAR_T* ParseCSSBorderRightWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 584: Element element;
585: PSchema tsch;
586: PresentationContext context;
1.50 cvs 587: CHAR_T* cssRule;
1.1 cvs 588: CSSInfoPtr css;
1.14 cvs 589: ThotBool isHTML;
1.1 cvs 590: #endif
591: {
1.41 cvs 592: PresentationValue border;
593:
1.50 cvs 594: cssRule = SkipWCBlanksAndComments (cssRule);
1.41 cvs 595: /* first parse the attribute string */
1.43 cvs 596: cssRule = ParseBorderValue (cssRule, &border);
597: if (border.typed_data.unit != STYLE_UNIT_INVALID)
1.44 cvs 598: {
599: TtaSetStylePresentation (PRBorderRightWidth, element, tsch, context, border);
600: border.typed_data.value = 1;
601: border.typed_data.unit = STYLE_UNIT_REL;
602: }
1.1 cvs 603: return (cssRule);
604: }
605:
606: /*----------------------------------------------------------------------
1.59 cvs 607: ParseCSSBorderWidth: parse a CSS BorderWidth
1.1 cvs 608: attribute string.
609: ----------------------------------------------------------------------*/
610: #ifdef __STDC__
1.50 cvs 611: static CHAR_T* ParseCSSBorderWidth (Element element, PSchema tsch,
612: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 613: #else
1.50 cvs 614: static CHAR_T* ParseCSSBorderWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 615: Element element;
616: PSchema tsch;
617: PresentationContext context;
1.50 cvs 618: CHAR_T* cssRule;
1.1 cvs 619: CSSInfoPtr css;
1.14 cvs 620: ThotBool isHTML;
1.1 cvs 621: #endif
622: {
1.50 cvs 623: CHAR_T *ptrT, *ptrR, *ptrB, *ptrL;
1.41 cvs 624:
1.50 cvs 625: ptrT = SkipWCBlanksAndComments (cssRule);
1.42 cvs 626: /* First parse Border-Top */
627: ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);
1.50 cvs 628: ptrR = SkipWCBlanksAndComments (ptrR);
629: if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))
1.42 cvs 630: {
631: cssRule = ptrR;
632: /* apply the Border-Top to all */
633: ptrR = ParseCSSBorderRightWidth (element, tsch, context, ptrT, css, isHTML);
634: ptrR = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
635: ptrR = ParseCSSBorderLeftWidth (element, tsch, context, ptrT, css, isHTML);
636: }
637: else
638: {
639: /* parse Border-Right */
640: ptrB = ParseCSSBorderRightWidth (element, tsch, context, ptrR, css, isHTML);
1.50 cvs 641: ptrB = SkipWCBlanksAndComments (ptrB);
642: if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))
1.42 cvs 643: {
644: cssRule = ptrB;
645: /* apply the Border-Top to Border-Bottom */
646: ptrB = ParseCSSBorderBottomWidth (element, tsch, context, ptrT, css, isHTML);
647: /* apply the Border-Right to Border-Left */
648: ptrB = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
649: }
650: else
651: {
652: /* parse Border-Bottom */
653: ptrL = ParseCSSBorderBottomWidth (element, tsch, context, ptrB, css, isHTML);
1.50 cvs 654: ptrL = SkipWCBlanksAndComments (ptrL);
655: if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))
1.42 cvs 656: {
657: cssRule = ptrL;
658: /* apply the Border-Right to Border-Left */
659: ptrL = ParseCSSBorderLeftWidth (element, tsch, context, ptrR, css, isHTML);
660: }
661: else
662: /* parse Border-Left */
663: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, ptrL, css, isHTML);
1.50 cvs 664: cssRule = SkipWCBlanksAndComments (cssRule);
1.42 cvs 665: }
666: }
1.1 cvs 667: return (cssRule);
668: }
669:
670: /*----------------------------------------------------------------------
1.59 cvs 671: ParseCSSBorderColorTop: parse a CSS BorderColorTop
1.1 cvs 672: attribute string.
673: ----------------------------------------------------------------------*/
674: #ifdef __STDC__
1.50 cvs 675: static CHAR_T* ParseCSSBorderColorTop (Element element, PSchema tsch,
676: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 677: #else
1.50 cvs 678: static CHAR_T* ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 679: Element element;
680: PSchema tsch;
681: PresentationContext context;
1.50 cvs 682: CHAR_T* cssRule;
1.1 cvs 683: CSSInfoPtr css;
1.14 cvs 684: ThotBool isHTML;
1.1 cvs 685: #endif
686: {
1.43 cvs 687: PresentationValue best;
688:
689: cssRule = ParseCSSColor (cssRule, &best);
690: if (best.typed_data.unit != STYLE_UNIT_INVALID)
691: /* install the new presentation */
692: TtaSetStylePresentation (PRBorderTopColor, element, tsch, context, best);
1.65 cvs 693: return (cssRule);
1.1 cvs 694: }
695:
696: /*----------------------------------------------------------------------
1.59 cvs 697: ParseCSSBorderColorLeft: parse a CSS BorderColorLeft
1.42 cvs 698: attribute string.
699: ----------------------------------------------------------------------*/
700: #ifdef __STDC__
1.50 cvs 701: static CHAR_T* ParseCSSBorderColorLeft (Element element, PSchema tsch,
702: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 703: #else
1.50 cvs 704: static CHAR_T* ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 705: Element element;
706: PSchema tsch;
707: PresentationContext context;
1.50 cvs 708: CHAR_T* cssRule;
1.42 cvs 709: CSSInfoPtr css;
710: ThotBool isHTML;
711: #endif
712: {
1.43 cvs 713: PresentationValue best;
714:
715: cssRule = ParseCSSColor (cssRule, &best);
716: if (best.typed_data.unit != STYLE_UNIT_INVALID)
717: /* install the new presentation */
718: TtaSetStylePresentation (PRBorderLeftColor, element, tsch, context, best);
1.65 cvs 719: return (cssRule);
1.42 cvs 720: }
721:
722: /*----------------------------------------------------------------------
1.59 cvs 723: ParseCSSBorderColorBottom: parse a CSS BorderColorBottom
1.42 cvs 724: attribute string.
725: ----------------------------------------------------------------------*/
726: #ifdef __STDC__
1.50 cvs 727: static CHAR_T* ParseCSSBorderColorBottom (Element element, PSchema tsch,
728: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 729: #else
1.50 cvs 730: static CHAR_T* ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 731: Element element;
732: PSchema tsch;
733: PresentationContext context;
1.50 cvs 734: CHAR_T* cssRule;
1.42 cvs 735: CSSInfoPtr css;
736: ThotBool isHTML;
737: #endif
738: {
1.43 cvs 739: PresentationValue best;
740:
741: cssRule = ParseCSSColor (cssRule, &best);
742: if (best.typed_data.unit != STYLE_UNIT_INVALID)
743: /* install the new presentation */
744: TtaSetStylePresentation (PRBorderBottomColor, element, tsch, context, best);
1.65 cvs 745: return (cssRule);
1.42 cvs 746: }
747:
748: /*----------------------------------------------------------------------
1.59 cvs 749: ParseCSSBorderColorRight: parse a CSS BorderColorRight
1.1 cvs 750: attribute string.
751: ----------------------------------------------------------------------*/
752: #ifdef __STDC__
1.50 cvs 753: static CHAR_T* ParseCSSBorderColorRight (Element element, PSchema tsch,
754: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 755: #else
1.50 cvs 756: static CHAR_T* ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 757: Element element;
758: PSchema tsch;
759: PresentationContext context;
1.50 cvs 760: CHAR_T* cssRule;
1.1 cvs 761: CSSInfoPtr css;
1.14 cvs 762: ThotBool isHTML;
1.1 cvs 763: #endif
764: {
1.43 cvs 765: PresentationValue best;
766:
767: cssRule = ParseCSSColor (cssRule, &best);
768: if (best.typed_data.unit != STYLE_UNIT_INVALID)
769: /* install the new presentation */
770: TtaSetStylePresentation (PRBorderRightColor, element, tsch, context, best);
1.65 cvs 771: return (cssRule);
1.1 cvs 772: }
773:
774: /*----------------------------------------------------------------------
1.59 cvs 775: ParseCSSBorderColor: parse a CSS border-color
1.42 cvs 776: attribute string.
777: ----------------------------------------------------------------------*/
778: #ifdef __STDC__
1.50 cvs 779: static CHAR_T* ParseCSSBorderColor (Element element, PSchema tsch,
780: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 781: #else
1.50 cvs 782: static CHAR_T* ParseCSSBorderColor (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 783: Element element;
784: PSchema tsch;
785: PresentationContext context;
1.50 cvs 786: CHAR_T* cssRule;
1.42 cvs 787: CSSInfoPtr css;
788: ThotBool isHTML;
789: #endif
790: {
1.50 cvs 791: CHAR_T *ptrT, *ptrR, *ptrB, *ptrL;
1.42 cvs 792:
1.50 cvs 793: ptrT = SkipWCBlanksAndComments (cssRule);
1.42 cvs 794: /* First parse Border-Top */
1.43 cvs 795: ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);
1.50 cvs 796: ptrR = SkipWCBlanksAndComments (ptrR);
797: if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))
1.42 cvs 798: {
799: cssRule = ptrR;
800: /* apply the Border-Top to all */
1.43 cvs 801: ptrR = ParseCSSBorderColorRight (element, tsch, context, ptrT, css, isHTML);
802: ptrR = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
803: ptrR = ParseCSSBorderColorLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 804: }
805: else
806: {
807: /* parse Border-Right */
1.43 cvs 808: ptrB = ParseCSSBorderColorRight (element, tsch, context, ptrR, css, isHTML);
1.50 cvs 809: ptrB = SkipWCBlanksAndComments (ptrB);
810: if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))
1.42 cvs 811: {
812: cssRule = ptrB;
813: /* apply the Border-Top to Border-Bottom */
1.43 cvs 814: ptrB = ParseCSSBorderColorBottom (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 815: /* apply the Border-Right to Border-Left */
1.43 cvs 816: ptrB = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 817: }
818: else
819: {
820: /* parse Border-Bottom */
1.43 cvs 821: ptrL = ParseCSSBorderColorBottom (element, tsch, context, ptrB, css, isHTML);
1.50 cvs 822: ptrL = SkipWCBlanksAndComments (ptrL);
823: if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))
1.42 cvs 824: {
825: cssRule = ptrL;
826: /* apply the Border-Right to Border-Left */
1.43 cvs 827: ptrL = ParseCSSBorderColorLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 828: }
829: else
830: /* parse Border-Left */
1.43 cvs 831: cssRule = ParseCSSBorderColorLeft (element, tsch, context, ptrL, css, isHTML);
1.50 cvs 832: cssRule = SkipWCBlanksAndComments (cssRule);
1.42 cvs 833: }
834: }
835: return (cssRule);
836: }
837:
838: /*----------------------------------------------------------------------
1.59 cvs 839: ParseCSSBorderStyleTop: parse a CSS BorderStyleTop
1.42 cvs 840: attribute string.
841: ----------------------------------------------------------------------*/
842: #ifdef __STDC__
1.50 cvs 843: static CHAR_T* ParseCSSBorderStyleTop (Element element, PSchema tsch,
844: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 845: #else
1.50 cvs 846: static CHAR_T* ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 847: Element element;
848: PSchema tsch;
849: PresentationContext context;
1.50 cvs 850: CHAR_T* cssRule;
1.42 cvs 851: CSSInfoPtr css;
852: ThotBool isHTML;
853: #endif
854: {
1.43 cvs 855: PresentationValue border;
856:
1.50 cvs 857: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 858: cssRule = ParseBorderStyle (cssRule, &border);
859: if (border.typed_data.unit != STYLE_UNIT_INVALID)
860: TtaSetStylePresentation (PRBorderTopStyle, element, tsch, context, border);
1.42 cvs 861: return (cssRule);
862: }
863:
864: /*----------------------------------------------------------------------
1.59 cvs 865: ParseCSSBorderStyleLeft: parse a CSS BorderStyleLeft
1.42 cvs 866: attribute string.
867: ----------------------------------------------------------------------*/
868: #ifdef __STDC__
1.50 cvs 869: static CHAR_T* ParseCSSBorderStyleLeft (Element element, PSchema tsch,
870: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 871: #else
1.50 cvs 872: static CHAR_T* ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 873: Element element;
874: PSchema tsch;
875: PresentationContext context;
1.50 cvs 876: CHAR_T* cssRule;
1.42 cvs 877: CSSInfoPtr css;
878: ThotBool isHTML;
879: #endif
880: {
1.43 cvs 881: PresentationValue border;
882:
1.50 cvs 883: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 884: cssRule = ParseBorderStyle (cssRule, &border);
885: if (border.typed_data.unit != STYLE_UNIT_INVALID)
886: TtaSetStylePresentation (PRBorderLeftStyle, element, tsch, context, border);
1.42 cvs 887: return (cssRule);
888: }
889:
890: /*----------------------------------------------------------------------
1.59 cvs 891: ParseCSSBorderStyleBottom: parse a CSS BorderStyleBottom
1.1 cvs 892: attribute string.
893: ----------------------------------------------------------------------*/
894: #ifdef __STDC__
1.50 cvs 895: static CHAR_T* ParseCSSBorderStyleBottom (Element element, PSchema tsch,
896: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 897: #else
1.50 cvs 898: static CHAR_T* ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 899: Element element;
900: PSchema tsch;
901: PresentationContext context;
1.50 cvs 902: CHAR_T* cssRule;
1.1 cvs 903: CSSInfoPtr css;
1.14 cvs 904: ThotBool isHTML;
1.1 cvs 905: #endif
906: {
1.43 cvs 907: PresentationValue border;
908:
1.50 cvs 909: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 910: cssRule = ParseBorderStyle (cssRule, &border);
911: if (border.typed_data.unit != STYLE_UNIT_INVALID)
912: TtaSetStylePresentation (PRBorderBottomStyle, element, tsch, context, border);
1.1 cvs 913: return (cssRule);
914: }
915:
916: /*----------------------------------------------------------------------
1.59 cvs 917: ParseCSSBorderStyleRight: parse a CSS BorderStyleRight
1.1 cvs 918: attribute string.
919: ----------------------------------------------------------------------*/
920: #ifdef __STDC__
1.50 cvs 921: static CHAR_T* ParseCSSBorderStyleRight (Element element, PSchema tsch,
922: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 923: #else
1.50 cvs 924: static CHAR_T* ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 925: Element element;
926: PSchema tsch;
927: PresentationContext context;
1.50 cvs 928: CHAR_T* cssRule;
1.1 cvs 929: CSSInfoPtr css;
1.14 cvs 930: ThotBool isHTML;
1.1 cvs 931: #endif
932: {
1.43 cvs 933: PresentationValue border;
934:
1.50 cvs 935: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 936: cssRule = ParseBorderStyle (cssRule, &border);
937: if (border.typed_data.unit != STYLE_UNIT_INVALID)
938: TtaSetStylePresentation (PRBorderRightStyle, element, tsch, context, border);
1.1 cvs 939: return (cssRule);
940: }
941:
942: /*----------------------------------------------------------------------
1.59 cvs 943: ParseCSSBorderStyleStyle: parse a CSS border-style
1.1 cvs 944: attribute string.
945: ----------------------------------------------------------------------*/
946: #ifdef __STDC__
1.50 cvs 947: static CHAR_T* ParseCSSBorderStyle (Element element, PSchema tsch,
948: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 949: #else
1.50 cvs 950: static CHAR_T* ParseCSSBorderStyle (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 951: Element element;
952: PSchema tsch;
953: PresentationContext context;
1.50 cvs 954: CHAR_T* cssRule;
1.1 cvs 955: CSSInfoPtr css;
1.14 cvs 956: ThotBool isHTML;
1.1 cvs 957: #endif
958: {
1.50 cvs 959: CHAR_T *ptrT, *ptrR, *ptrB, *ptrL;
1.42 cvs 960:
1.50 cvs 961: ptrT = SkipWCBlanksAndComments (cssRule);
1.42 cvs 962: /* First parse Border-Top */
1.43 cvs 963: ptrR = ParseCSSBorderStyleTop (element, tsch, context, ptrT, css, isHTML);
1.50 cvs 964: ptrR = SkipWCBlanksAndComments (ptrR);
965: if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))
1.42 cvs 966: {
967: cssRule = ptrR;
968: /* apply the Border-Top to all */
1.43 cvs 969: ptrR = ParseCSSBorderStyleRight (element, tsch, context, ptrT, css, isHTML);
970: ptrR = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
971: ptrR = ParseCSSBorderStyleLeft (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 972: }
973: else
974: {
975: /* parse Border-Right */
1.43 cvs 976: ptrB = ParseCSSBorderStyleRight (element, tsch, context, ptrR, css, isHTML);
1.50 cvs 977: ptrB = SkipWCBlanksAndComments (ptrB);
978: if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))
1.42 cvs 979: {
980: cssRule = ptrB;
981: /* apply the Border-Top to Border-Bottom */
1.43 cvs 982: ptrB = ParseCSSBorderStyleBottom (element, tsch, context, ptrT, css, isHTML);
1.42 cvs 983: /* apply the Border-Right to Border-Left */
1.43 cvs 984: ptrB = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 985: }
986: else
987: {
988: /* parse Border-Bottom */
1.43 cvs 989: ptrL = ParseCSSBorderStyleBottom (element, tsch, context, ptrB, css, isHTML);
1.50 cvs 990: ptrL = SkipWCBlanksAndComments (ptrL);
991: if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))
1.42 cvs 992: {
993: cssRule = ptrL;
994: /* apply the Border-Right to Border-Left */
1.43 cvs 995: ptrL = ParseCSSBorderStyleLeft (element, tsch, context, ptrR, css, isHTML);
1.42 cvs 996: }
997: else
998: /* parse Border-Left */
1.43 cvs 999: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, ptrL, css, isHTML);
1.50 cvs 1000: cssRule = SkipWCBlanksAndComments (cssRule);
1.42 cvs 1001: }
1002: }
1003: return (cssRule);
1004: }
1005:
1006: /*----------------------------------------------------------------------
1.59 cvs 1007: ParseCSSBorderTop: parse a CSS BorderTop
1.42 cvs 1008: attribute string.
1009: ----------------------------------------------------------------------*/
1010: #ifdef __STDC__
1.50 cvs 1011: static CHAR_T* ParseCSSBorderTop (Element element, PSchema tsch,
1012: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1013: #else
1.50 cvs 1014: static CHAR_T* ParseCSSBorderTop (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 1015: Element element;
1016: PSchema tsch;
1017: PresentationContext context;
1.50 cvs 1018: CHAR_T* cssRule;
1.42 cvs 1019: CSSInfoPtr css;
1020: ThotBool isHTML;
1021: #endif
1022: {
1.50 cvs 1023: CHAR_T* ptr;
1.43 cvs 1024:
1.50 cvs 1025: cssRule = SkipWCBlanksAndComments (cssRule);
1026: while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))
1.43 cvs 1027: {
1028: ptr = cssRule;
1029: cssRule = ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML);
1030: if (ptr == cssRule)
1031: cssRule = ParseCSSBorderTopWidth (element, tsch, context, cssRule, css, isHTML);
1032: if (ptr == cssRule)
1033: cssRule = ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML);
1034: if (ptr == cssRule)
1035: /* rule not found */
1036: cssRule = SkipProperty (cssRule);
1.50 cvs 1037: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 1038: }
1.42 cvs 1039: return (cssRule);
1040: }
1041:
1042: /*----------------------------------------------------------------------
1.59 cvs 1043: ParseCSSBorderLeft: parse a CSS BorderLeft
1.42 cvs 1044: attribute string.
1045: ----------------------------------------------------------------------*/
1046: #ifdef __STDC__
1.50 cvs 1047: static CHAR_T* ParseCSSBorderLeft (Element element, PSchema tsch,
1048: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1049: #else
1.50 cvs 1050: static CHAR_T* ParseCSSBorderLeft (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 1051: Element element;
1052: PSchema tsch;
1053: PresentationContext context;
1.50 cvs 1054: CHAR_T* cssRule;
1.42 cvs 1055: CSSInfoPtr css;
1056: ThotBool isHTML;
1057: #endif
1058: {
1.50 cvs 1059: CHAR_T* ptr;
1.43 cvs 1060:
1.50 cvs 1061: cssRule = SkipWCBlanksAndComments (cssRule);
1062: while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))
1.43 cvs 1063: {
1064: ptr = cssRule;
1065: cssRule = ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML);
1066: if (ptr == cssRule)
1067: cssRule = ParseCSSBorderLeftWidth (element, tsch, context, cssRule, css, isHTML);
1068: if (ptr == cssRule)
1069: cssRule = ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML);
1070: if (ptr == cssRule)
1071: /* rule not found */
1072: cssRule = SkipProperty (cssRule);
1.50 cvs 1073: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 1074: }
1.1 cvs 1075: return (cssRule);
1076: }
1077:
1078: /*----------------------------------------------------------------------
1.59 cvs 1079: ParseCSSBorderBottom: parse a CSS BorderBottom
1.1 cvs 1080: attribute string.
1081: ----------------------------------------------------------------------*/
1082: #ifdef __STDC__
1.50 cvs 1083: static CHAR_T* ParseCSSBorderBottom (Element element, PSchema tsch,
1084: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1085: #else
1.50 cvs 1086: static CHAR_T* ParseCSSBorderBottom (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1087: Element element;
1088: PSchema tsch;
1089: PresentationContext context;
1.50 cvs 1090: CHAR_T* cssRule;
1.1 cvs 1091: CSSInfoPtr css;
1.14 cvs 1092: ThotBool isHTML;
1.1 cvs 1093: #endif
1094: {
1.50 cvs 1095: CHAR_T* ptr;
1.43 cvs 1096:
1.50 cvs 1097: cssRule = SkipWCBlanksAndComments (cssRule);
1098: while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))
1.43 cvs 1099: {
1100: ptr = cssRule;
1101: cssRule = ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML);
1102: if (ptr == cssRule)
1103: cssRule = ParseCSSBorderBottomWidth (element, tsch, context, cssRule, css, isHTML);
1104: if (ptr == cssRule)
1105: cssRule = ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML);
1106: if (ptr == cssRule)
1107: /* rule not found */
1108: cssRule = SkipProperty (cssRule);
1.50 cvs 1109: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 1110: }
1.1 cvs 1111: return (cssRule);
1112: }
1113:
1114: /*----------------------------------------------------------------------
1.59 cvs 1115: ParseCSSBorderRight: parse a CSS BorderRight
1.1 cvs 1116: attribute string.
1117: ----------------------------------------------------------------------*/
1118: #ifdef __STDC__
1.50 cvs 1119: static CHAR_T* ParseCSSBorderRight (Element element, PSchema tsch,
1120: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1121: #else
1.50 cvs 1122: static CHAR_T* ParseCSSBorderRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1123: Element element;
1124: PSchema tsch;
1125: PresentationContext context;
1.50 cvs 1126: CHAR_T* cssRule;
1.1 cvs 1127: CSSInfoPtr css;
1.14 cvs 1128: ThotBool isHTML;
1.1 cvs 1129: #endif
1130: {
1.50 cvs 1131: CHAR_T* ptr;
1.43 cvs 1132:
1.50 cvs 1133: cssRule = SkipWCBlanksAndComments (cssRule);
1134: while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))
1.43 cvs 1135: {
1136: ptr = cssRule;
1137: cssRule = ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML);
1138: if (ptr == cssRule)
1139: cssRule = ParseCSSBorderRightWidth (element, tsch, context, cssRule, css, isHTML);
1140: if (ptr == cssRule)
1141: cssRule = ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML);
1142: if (ptr == cssRule)
1143: /* rule not found */
1144: cssRule = SkipProperty (cssRule);
1.50 cvs 1145: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 1146: }
1.1 cvs 1147: return (cssRule);
1148: }
1149:
1150: /*----------------------------------------------------------------------
1.59 cvs 1151: ParseCSSBorder: parse a CSS border
1.42 cvs 1152: attribute string.
1153: ----------------------------------------------------------------------*/
1154: #ifdef __STDC__
1.50 cvs 1155: static CHAR_T* ParseCSSBorder (Element element, PSchema tsch,
1156: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.42 cvs 1157: #else
1.50 cvs 1158: static CHAR_T* ParseCSSBorder (element, tsch, context, cssRule, css, isHTML)
1.42 cvs 1159: Element element;
1160: PSchema tsch;
1161: PresentationContext context;
1.50 cvs 1162: CHAR_T* cssRule;
1.42 cvs 1163: CSSInfoPtr css;
1164: ThotBool isHTML;
1165: #endif
1166: {
1.50 cvs 1167: CHAR_T *ptrT, *ptrR;
1.42 cvs 1168:
1.50 cvs 1169: ptrT = SkipWCBlanksAndComments (cssRule);
1.42 cvs 1170: /* First parse Border-Top */
1171: ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);
1.50 cvs 1172: ptrR = SkipWCBlanksAndComments (ptrR);
1173: if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))
1.42 cvs 1174: {
1175: cssRule = ptrR;
1176: /* apply the Border-Top to all */
1177: ptrR = ParseCSSBorderRight (element, tsch, context, ptrT, css, isHTML);
1178: ptrR = ParseCSSBorderBottom (element, tsch, context, ptrT, css, isHTML);
1179: ptrR = ParseCSSBorderLeft (element, tsch, context, ptrT, css, isHTML);
1180: }
1181: return (cssRule);
1182: }
1183:
1184: /*----------------------------------------------------------------------
1.59 cvs 1185: ParseCSSClear: parse a CSS clear attribute string
1.1 cvs 1186: ----------------------------------------------------------------------*/
1187: #ifdef __STDC__
1.50 cvs 1188: static CHAR_T* ParseCSSClear (Element element, PSchema tsch,
1189: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1190: #else
1.50 cvs 1191: static CHAR_T* ParseCSSClear (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1192: Element element;
1193: PSchema tsch;
1194: PresentationContext context;
1.50 cvs 1195: CHAR_T* cssRule;
1.1 cvs 1196: CSSInfoPtr css;
1.14 cvs 1197: ThotBool isHTML;
1.1 cvs 1198: #endif
1199: {
1200: cssRule = SkipProperty (cssRule);
1201: return (cssRule);
1202: }
1203:
1204: /*----------------------------------------------------------------------
1.59 cvs 1205: ParseCSSDisplay: parse a CSS display attribute string
1.1 cvs 1206: ----------------------------------------------------------------------*/
1207: #ifdef __STDC__
1.50 cvs 1208: static CHAR_T* ParseCSSDisplay (Element element, PSchema tsch,
1209: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1210: #else
1.50 cvs 1211: static CHAR_T* ParseCSSDisplay (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1212: Element element;
1213: PSchema tsch;
1214: PresentationContext context;
1.50 cvs 1215: CHAR_T* cssRule;
1.1 cvs 1216: CSSInfoPtr css;
1.14 cvs 1217: ThotBool isHTML;
1.1 cvs 1218: #endif
1219: {
1220: PresentationValue pval;
1221:
1222: pval.typed_data.unit = STYLE_UNIT_REL;
1223: pval.typed_data.real = FALSE;
1.50 cvs 1224: cssRule = SkipWCBlanksAndComments (cssRule);
1225: if (!ustrncasecmp (cssRule, TEXT("block"), 5))
1.1 cvs 1226: {
1227: pval.typed_data.value = STYLE_NOTINLINE;
1228: TtaSetStylePresentation (PRLine, element, tsch, context, pval);
1229: cssRule = SkipWord (cssRule);
1230: }
1.50 cvs 1231: else if (!ustrncasecmp (cssRule, TEXT("inline"), 6))
1.1 cvs 1232: {
1233: pval.typed_data.value = STYLE_INLINE;
1234: TtaSetStylePresentation (PRLine, element, tsch, context, pval);
1235: cssRule = SkipWord (cssRule);
1236: }
1.50 cvs 1237: else if (!ustrncasecmp (cssRule, TEXT("none"), 4))
1.1 cvs 1238: {
1239: pval.typed_data.value = STYLE_HIDE;
1240: TtaSetStylePresentation (PRVisibility, element, tsch, context, pval);
1241: cssRule = SkipWord (cssRule);
1242: }
1.50 cvs 1243: else if (!ustrncasecmp (cssRule, TEXT("list-item"), 9))
1.1 cvs 1244: cssRule = SkipProperty (cssRule);
1245: else
1246: fprintf (stderr, "invalid display value %s\n", cssRule);
1.34 cvs 1247:
1.1 cvs 1248: return (cssRule);
1249: }
1250:
1251: /*----------------------------------------------------------------------
1.59 cvs 1252: ParseCSSFloat: parse a CSS float attribute string
1.1 cvs 1253: ----------------------------------------------------------------------*/
1254: #ifdef __STDC__
1.50 cvs 1255: static CHAR_T* ParseCSSFloat (Element element, PSchema tsch,
1256: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1257: #else
1.50 cvs 1258: static CHAR_T* ParseCSSFloat (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1259: Element element;
1260: PSchema tsch;
1261: PresentationContext context;
1.50 cvs 1262: CHAR_T* cssRule;
1.1 cvs 1263: CSSInfoPtr css;
1.14 cvs 1264: ThotBool isHTML;
1.1 cvs 1265: #endif
1266: {
1267: cssRule = SkipProperty (cssRule);
1268: return (cssRule);
1269: }
1270:
1271: /*----------------------------------------------------------------------
1.59 cvs 1272: ParseCSSLetterSpacing: parse a CSS letter-spacing
1.1 cvs 1273: attribute string.
1274: ----------------------------------------------------------------------*/
1275: #ifdef __STDC__
1.50 cvs 1276: static CHAR_T* ParseCSSLetterSpacing (Element element, PSchema tsch,
1277: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1278: #else
1.50 cvs 1279: static CHAR_T* ParseCSSLetterSpacing (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1280: Element element;
1281: PSchema tsch;
1282: PresentationContext context;
1.50 cvs 1283: CHAR_T* cssRule;
1.1 cvs 1284: CSSInfoPtr css;
1.14 cvs 1285: ThotBool isHTML;
1.1 cvs 1286: #endif
1287: {
1288: cssRule = SkipProperty (cssRule);
1289: return (cssRule);
1290: }
1291:
1292: /*----------------------------------------------------------------------
1.59 cvs 1293: ParseCSSListStyleType: parse a CSS list-style-type
1.1 cvs 1294: attribute string.
1295: ----------------------------------------------------------------------*/
1296: #ifdef __STDC__
1.50 cvs 1297: static CHAR_T* ParseCSSListStyleType (Element element, PSchema tsch,
1298: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1299: #else
1.50 cvs 1300: static CHAR_T* ParseCSSListStyleType (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1301: Element element;
1302: PSchema tsch;
1303: PresentationContext context;
1.50 cvs 1304: CHAR_T* cssRule;
1.1 cvs 1305: CSSInfoPtr css;
1.14 cvs 1306: ThotBool isHTML;
1.1 cvs 1307: #endif
1308: {
1309: cssRule = SkipProperty (cssRule);
1310: return (cssRule);
1311: }
1312:
1313: /*----------------------------------------------------------------------
1.59 cvs 1314: ParseCSSListStyleImage: parse a CSS list-style-image
1.1 cvs 1315: attribute string.
1316: ----------------------------------------------------------------------*/
1317: #ifdef __STDC__
1.50 cvs 1318: static CHAR_T* ParseCSSListStyleImage (Element element, PSchema tsch,
1319: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1320: #else
1.50 cvs 1321: static CHAR_T* ParseCSSListStyleImage (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1322: Element element;
1323: PSchema tsch;
1324: PresentationContext context;
1.50 cvs 1325: CHAR_T* cssRule;
1.1 cvs 1326: CSSInfoPtr css;
1.14 cvs 1327: ThotBool isHTML;
1.1 cvs 1328: #endif
1329: {
1330: cssRule = SkipProperty (cssRule);
1331: return (cssRule);
1332: }
1333:
1334: /*----------------------------------------------------------------------
1.59 cvs 1335: ParseCSSListStylePosition: parse a CSS list-style-position
1.1 cvs 1336: attribute string.
1337: ----------------------------------------------------------------------*/
1338: #ifdef __STDC__
1.50 cvs 1339: static CHAR_T* ParseCSSListStylePosition (Element element, PSchema tsch,
1340: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1341: #else
1.50 cvs 1342: static CHAR_T* ParseCSSListStylePosition (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1343: Element element;
1344: PSchema tsch;
1345: PresentationContext context;
1.50 cvs 1346: CHAR_T* cssRule;
1.1 cvs 1347: CSSInfoPtr css;
1.14 cvs 1348: ThotBool isHTML;
1.1 cvs 1349: #endif
1350: {
1351: cssRule = SkipProperty (cssRule);
1352: return (cssRule);
1353: }
1354:
1355: /*----------------------------------------------------------------------
1.59 cvs 1356: ParseCSSListStyle: parse a CSS list-style
1.1 cvs 1357: attribute string.
1358: ----------------------------------------------------------------------*/
1359: #ifdef __STDC__
1.50 cvs 1360: static CHAR_T* ParseCSSListStyle (Element element, PSchema tsch,
1361: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1362: #else
1.50 cvs 1363: static CHAR_T* ParseCSSListStyle (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1364: Element element;
1365: PSchema tsch;
1366: PresentationContext context;
1.50 cvs 1367: CHAR_T* cssRule;
1.1 cvs 1368: CSSInfoPtr css;
1.14 cvs 1369: ThotBool isHTML;
1.1 cvs 1370: #endif
1371: {
1372: cssRule = SkipProperty (cssRule);
1373: return (cssRule);
1374: }
1375:
1376: /*----------------------------------------------------------------------
1.59 cvs 1377: ParseCSSTextAlign: parse a CSS text-align
1.1 cvs 1378: attribute string.
1379: ----------------------------------------------------------------------*/
1380: #ifdef __STDC__
1.50 cvs 1381: static CHAR_T* ParseCSSTextAlign (Element element, PSchema tsch,
1382: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1383: #else
1.50 cvs 1384: static CHAR_T* ParseCSSTextAlign (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1385: Element element;
1386: PSchema tsch;
1387: PresentationContext context;
1.50 cvs 1388: CHAR_T* cssRule;
1.1 cvs 1389: CSSInfoPtr css;
1.14 cvs 1390: ThotBool isHTML;
1.1 cvs 1391: #endif
1392: {
1393: PresentationValue align;
1394: PresentationValue justify;
1395:
1396: align.typed_data.value = 0;
1397: align.typed_data.unit = STYLE_UNIT_REL;
1398: align.typed_data.real = FALSE;
1399: justify.typed_data.value = 0;
1400: justify.typed_data.unit = STYLE_UNIT_REL;
1401: justify.typed_data.real = FALSE;
1402:
1.50 cvs 1403: cssRule = SkipWCBlanksAndComments (cssRule);
1404: if (!ustrncasecmp (cssRule, TEXT("left"), 4))
1.1 cvs 1405: {
1406: align.typed_data.value = AdjustLeft;
1407: cssRule = SkipWord (cssRule);
1408: }
1.50 cvs 1409: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
1.1 cvs 1410: {
1411: align.typed_data.value = AdjustRight;
1412: cssRule = SkipWord (cssRule);
1413: }
1.50 cvs 1414: else if (!ustrncasecmp (cssRule, TEXT("center"), 6))
1.1 cvs 1415: {
1416: align.typed_data.value = Centered;
1417: cssRule = SkipWord (cssRule);
1418: }
1.50 cvs 1419: else if (!ustrncasecmp (cssRule, TEXT("justify"), 7))
1.1 cvs 1420: {
1421: justify.typed_data.value = Justified;
1422: cssRule = SkipWord (cssRule);
1423: }
1424: else
1425: {
1426: fprintf (stderr, "invalid align value\n");
1427: return (cssRule);
1428: }
1429:
1430: /*
1431: * install the new presentation.
1432: */
1433: if (align.typed_data.value)
1434: {
1435: TtaSetStylePresentation (PRAdjust, element, tsch, context, align);
1436: }
1437: if (justify.typed_data.value)
1438: {
1439: TtaSetStylePresentation (PRJustify, element, tsch, context, justify);
1440: TtaSetStylePresentation (PRHyphenate, element, tsch, context, justify);
1441: }
1442: return (cssRule);
1443: }
1444:
1445: /*----------------------------------------------------------------------
1.59 cvs 1446: ParseCSSTextIndent: parse a CSS text-indent
1.1 cvs 1447: attribute string.
1448: ----------------------------------------------------------------------*/
1449: #ifdef __STDC__
1.50 cvs 1450: static CHAR_T* ParseCSSTextIndent (Element element, PSchema tsch,
1451: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1452: #else
1.50 cvs 1453: static CHAR_T* ParseCSSTextIndent (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1454: Element element;
1455: PSchema tsch;
1456: PresentationContext context;
1.56 cvs 1457: CHAR_T* cssRule;
1.1 cvs 1458: CSSInfoPtr css;
1.14 cvs 1459: ThotBool isHTML;
1.1 cvs 1460: #endif
1461: {
1462: PresentationValue pval;
1463:
1.50 cvs 1464: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 1465: cssRule = ParseCSSUnit (cssRule, &pval);
1466: if (pval.typed_data.unit == STYLE_UNIT_INVALID)
1467: return (cssRule);
1468: /* install the attribute */
1469: TtaSetStylePresentation (PRIndent, element, tsch, context, pval);
1470: return (cssRule);
1471: }
1472:
1473: /*----------------------------------------------------------------------
1.59 cvs 1474: ParseCSSTextTransform: parse a CSS text-transform
1.1 cvs 1475: attribute string.
1476: ----------------------------------------------------------------------*/
1477: #ifdef __STDC__
1.50 cvs 1478: static CHAR_T* ParseCSSTextTransform (Element element, PSchema tsch,
1479: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1480: #else
1.50 cvs 1481: static CHAR_T* ParseCSSTextTransform (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1482: Element element;
1483: PSchema tsch;
1484: PresentationContext context;
1.50 cvs 1485: CHAR_T* cssRule;
1.1 cvs 1486: CSSInfoPtr css;
1.14 cvs 1487: ThotBool isHTML;
1.1 cvs 1488: #endif
1489: {
1490: cssRule = SkipProperty (cssRule);
1491: return (cssRule);
1492: }
1493:
1494: /*----------------------------------------------------------------------
1.59 cvs 1495: ParseCSSVerticalAlign: parse a CSS vertical-align
1.1 cvs 1496: attribute string.
1497: ----------------------------------------------------------------------*/
1498: #ifdef __STDC__
1.50 cvs 1499: static CHAR_T* ParseCSSVerticalAlign (Element element, PSchema tsch,
1500: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1501: #else
1.50 cvs 1502: static CHAR_T* ParseCSSVerticalAlign (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1503: Element element;
1504: PSchema tsch;
1505: PresentationContext context;
1506: STRING cssRule;
1507: CSSInfoPtr css;
1.14 cvs 1508: ThotBool isHTML;
1.1 cvs 1509: #endif
1510: {
1511: cssRule = SkipProperty (cssRule);
1512: return (cssRule);
1513: }
1514:
1515: /*----------------------------------------------------------------------
1.59 cvs 1516: ParseCSSWhiteSpace: parse a CSS white-space
1.1 cvs 1517: attribute string.
1518: ----------------------------------------------------------------------*/
1519: #ifdef __STDC__
1.50 cvs 1520: static CHAR_T* ParseCSSWhiteSpace (Element element, PSchema tsch,
1521: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1522: #else
1.50 cvs 1523: static CHAR_T* ParseCSSWhiteSpace (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1524: Element element;
1525: PSchema tsch;
1526: PresentationContext context;
1527: STRING cssRule;
1528: CSSInfoPtr css;
1.14 cvs 1529: ThotBool isHTML;
1.1 cvs 1530: #endif
1531: {
1.50 cvs 1532: cssRule = SkipWCBlanksAndComments (cssRule);
1533: if (!ustrncasecmp (cssRule, TEXT("normal"), 6))
1.1 cvs 1534: cssRule = SkipWord (cssRule);
1.50 cvs 1535: else if (!ustrncasecmp (cssRule, TEXT("pre"), 3))
1.1 cvs 1536: cssRule = SkipWord (cssRule);
1537: else
1538: return (cssRule);
1539: return (cssRule);
1540: }
1541:
1542: /*----------------------------------------------------------------------
1.59 cvs 1543: ParseCSSWordSpacing: parse a CSS word-spacing
1.1 cvs 1544: attribute string.
1545: ----------------------------------------------------------------------*/
1546: #ifdef __STDC__
1.50 cvs 1547: static CHAR_T* ParseCSSWordSpacing (Element element, PSchema tsch,
1548: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1549: #else
1.50 cvs 1550: static CHAR_T* ParseCSSWordSpacing (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1551: Element element;
1552: PSchema tsch;
1553: PresentationContext context;
1554: STRING cssRule;
1555: CSSInfoPtr css;
1.14 cvs 1556: ThotBool isHTML;
1.1 cvs 1557: #endif
1558: {
1559: cssRule = SkipProperty (cssRule);
1560: return (cssRule);
1561: }
1562:
1563: /*----------------------------------------------------------------------
1.59 cvs 1564: ParseCSSLineSpacing: parse a CSS font leading string
1.25 cvs 1565: we expect the input string describing the attribute to be
1566: value% or value
1567: ----------------------------------------------------------------------*/
1568: #ifdef __STDC__
1.50 cvs 1569: static CHAR_T* ParseCSSLineSpacing (Element element, PSchema tsch,
1570: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.25 cvs 1571: #else
1.50 cvs 1572: static CHAR_T* ParseCSSLineSpacing (element, tsch, context, cssRule, css, isHTML)
1.25 cvs 1573: Element element;
1574: PSchema tsch;
1575: PresentationContext context;
1576: STRING cssRule;
1577: CSSInfoPtr css;
1578: ThotBool isHTML;
1579: #endif
1580: {
1581: PresentationValue lead;
1582:
1583: cssRule = ParseCSSUnit (cssRule, &lead);
1584: if (lead.typed_data.unit == STYLE_UNIT_INVALID)
1585: {
1586: /* invalid line spacing */
1587: return (cssRule);
1588: }
1589: /* install the new presentation */
1590: TtaSetStylePresentation (PRLineSpacing, element, tsch, context, lead);
1591: return (cssRule);
1592: }
1593:
1594: /*----------------------------------------------------------------------
1.59 cvs 1595: ParseCSSFontSize: parse a CSS font size attr string
1.1 cvs 1596: we expect the input string describing the attribute to be
1597: xx-small, x-small, small, medium, large, x-large, xx-large
1598: or an absolute size, or an imcrement relative to the parent
1599: ----------------------------------------------------------------------*/
1600: #ifdef __STDC__
1.50 cvs 1601: static CHAR_T* ParseCSSFontSize (Element element, PSchema tsch,
1602: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1603: #else
1.50 cvs 1604: static CHAR_T* ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1605: Element element;
1606: PSchema tsch;
1607: PresentationContext context;
1608: STRING cssRule;
1609: CSSInfoPtr css;
1.14 cvs 1610: ThotBool isHTML;
1.1 cvs 1611: #endif
1612: {
1613: PresentationValue pval;
1.50 cvs 1614: CHAR_T* ptr = NULL;
1.14 cvs 1615: ThotBool real;
1.1 cvs 1616:
1617: pval.typed_data.real = FALSE;
1.50 cvs 1618: cssRule = SkipWCBlanksAndComments (cssRule);
1619: if (!ustrncasecmp (cssRule, TEXT("larger"), 6))
1.1 cvs 1620: {
1621: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1622: pval.typed_data.value = 130;
1623: cssRule = SkipWord (cssRule);
1624: }
1.50 cvs 1625: else if (!ustrncasecmp (cssRule, TEXT("smaller"), 7))
1.1 cvs 1626: {
1627: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1628: pval.typed_data.value = 80;
1629: cssRule = SkipWord (cssRule);
1630: }
1.50 cvs 1631: else if (!ustrncasecmp (cssRule, TEXT("xx-small"), 8))
1.1 cvs 1632: {
1633: pval.typed_data.unit = STYLE_UNIT_REL;
1634: pval.typed_data.value = 1;
1635: cssRule = SkipWord (cssRule);
1636: }
1.50 cvs 1637: else if (!ustrncasecmp (cssRule, TEXT("x-small"), 7))
1.1 cvs 1638: {
1639: pval.typed_data.unit = STYLE_UNIT_REL;
1640: pval.typed_data.value = 2;
1641: cssRule = SkipWord (cssRule);
1642: }
1.50 cvs 1643: else if (!ustrncasecmp (cssRule, TEXT("small"), 5))
1.1 cvs 1644: {
1645: pval.typed_data.unit = STYLE_UNIT_REL;
1646: pval.typed_data.value = 3;
1647: cssRule = SkipWord (cssRule);
1648: }
1.50 cvs 1649: else if (!ustrncasecmp (cssRule, TEXT("medium"), 6))
1.1 cvs 1650: {
1651: pval.typed_data.unit = STYLE_UNIT_REL;
1652: pval.typed_data.value = 4;
1653: cssRule = SkipWord (cssRule);
1654: }
1.50 cvs 1655: else if (!ustrncasecmp (cssRule, TEXT("large"), 5))
1.1 cvs 1656: {
1657: pval.typed_data.unit = STYLE_UNIT_REL;
1658: pval.typed_data.value = 5;
1659: cssRule = SkipWord (cssRule);
1660: }
1.50 cvs 1661: else if (!ustrncasecmp (cssRule, TEXT("x-large"), 7))
1.1 cvs 1662: {
1663: pval.typed_data.unit = STYLE_UNIT_REL;
1664: pval.typed_data.value = 6;
1665: cssRule = SkipWord (cssRule);
1666: }
1.50 cvs 1667: else if (!ustrncasecmp (cssRule, TEXT("xx-large"), 8))
1.1 cvs 1668: {
1669: pval.typed_data.unit = STYLE_UNIT_REL;
1670: pval.typed_data.value = 7;
1671: cssRule = SkipWord (cssRule);
1672: }
1673: else
1674: {
1.25 cvs 1675: /* look for a '/' within the current cssRule */
1.50 cvs 1676: ptr = ustrchr (cssRule, TEXT('/'));
1.25 cvs 1677: if (ptr != NULL)
1678: {
1679: /* keep the line spacing rule */
1.50 cvs 1680: ptr[0] = WC_EOS;
1.25 cvs 1681: ptr = &ptr[1];
1682: }
1.1 cvs 1683: cssRule = ParseCSSUnit (cssRule, &pval);
1684: if (pval.typed_data.unit == STYLE_UNIT_INVALID ||
1685: pval.typed_data.value < 0)
1686: return (cssRule);
1687: if (pval.typed_data.unit == STYLE_UNIT_REL && pval.typed_data.value > 0)
1688: /* CSS relative sizes have to be higher than Thot ones */
1689: pval.typed_data.value += 1;
1690: else
1691: {
1692: real = pval.typed_data.real;
1693: if (pval.typed_data.unit == STYLE_UNIT_EM)
1694: {
1695: if (real)
1696: {
1697: pval.typed_data.value /= 10;
1.11 cvs 1698: pval.typed_data.real = FALSE;
1.1 cvs 1699: real = FALSE;
1700: }
1701: else
1702: pval.typed_data.value *= 100;
1703: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1704: }
1705: }
1.25 cvs 1706:
1.1 cvs 1707: }
1708:
1.25 cvs 1709: /* install the presentation style */
1.1 cvs 1710: TtaSetStylePresentation (PRSize, element, tsch, context, pval);
1.25 cvs 1711:
1712: if (ptr != NULL)
1713: cssRule = ParseCSSLineSpacing (element, tsch, context, ptr, css, isHTML);
1.1 cvs 1714: return (cssRule);
1715: }
1716:
1717: /*----------------------------------------------------------------------
1.59 cvs 1718: ParseCSSFontFamily: parse a CSS font family string
1.1 cvs 1719: we expect the input string describing the attribute to be
1720: a common generic font style name
1721: ----------------------------------------------------------------------*/
1722: #ifdef __STDC__
1.50 cvs 1723: static CHAR_T* ParseCSSFontFamily (Element element, PSchema tsch,
1724: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1725: #else
1.50 cvs 1726: static CHAR_T* ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1727: Element element;
1728: PSchema tsch;
1729: PresentationContext context;
1730: STRING cssRule;
1731: CSSInfoPtr css;
1.14 cvs 1732: ThotBool isHTML;
1.1 cvs 1733: #endif
1734: {
1735: PresentationValue font;
1.50 cvs 1736: CHAR_T quoteChar;
1.1 cvs 1737:
1738: font.typed_data.value = 0;
1739: font.typed_data.unit = STYLE_UNIT_REL;
1740: font.typed_data.real = FALSE;
1.50 cvs 1741: cssRule = SkipWCBlanksAndComments (cssRule);
1742: if (*cssRule == TEXT('"') || *cssRule == TEXT('\''))
1.1 cvs 1743: {
1744: quoteChar = *cssRule;
1745: cssRule++;
1746: }
1747: else
1.50 cvs 1748: quoteChar = WC_EOS;
1.1 cvs 1749:
1.50 cvs 1750: if (!ustrncasecmp (cssRule, TEXT("times"), 5))
1.1 cvs 1751: font.typed_data.value = STYLE_FONT_TIMES;
1.50 cvs 1752: else if (!ustrncasecmp (cssRule, TEXT("serif"), 5))
1.1 cvs 1753: font.typed_data.value = STYLE_FONT_TIMES;
1.50 cvs 1754: else if (!ustrncasecmp (cssRule, TEXT("helvetica"), 9) ||
1755: !ustrncasecmp (cssRule, TEXT("verdana"), 7))
1.1 cvs 1756: font.typed_data.value = STYLE_FONT_HELVETICA;
1.50 cvs 1757: else if (!ustrncasecmp (cssRule, TEXT("sans-serif"), 10))
1.1 cvs 1758: font.typed_data.value = STYLE_FONT_HELVETICA;
1.50 cvs 1759: else if (!ustrncasecmp (cssRule, TEXT("courier"), 7))
1.1 cvs 1760: font.typed_data.value = STYLE_FONT_COURIER;
1.50 cvs 1761: else if (!ustrncasecmp (cssRule, TEXT("monospace"), 9))
1.1 cvs 1762: font.typed_data.value = STYLE_FONT_COURIER;
1763: else
1764: /* unknown font name. Skip it */
1765: {
1.54 cvs 1766: if (quoteChar) {
1767: cssRule = SkipQuotedString (cssRule, quoteChar);
1768: } else
1.1 cvs 1769: cssRule = SkipWord (cssRule);
1.50 cvs 1770: cssRule = SkipWCBlanksAndComments (cssRule);
1771: if (*cssRule == TEXT(','))
1.1 cvs 1772: {
1773: cssRule++;
1774: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
1775: return (cssRule);
1776: }
1777: }
1778:
1779: if (font.typed_data.value != 0)
1780: {
1781: cssRule = SkipProperty (cssRule);
1782: /* install the new presentation */
1783: TtaSetStylePresentation (PRFont, element, tsch, context, font);
1784: }
1785: return (cssRule);
1786: }
1787:
1788: /*----------------------------------------------------------------------
1.59 cvs 1789: ParseCSSFontWeight: parse a CSS font weight string
1.1 cvs 1790: we expect the input string describing the attribute to be
1.20 cvs 1791: normal, bold, bolder, lighter, 100, 200, 300, ... 900, inherit.
1.1 cvs 1792: ----------------------------------------------------------------------*/
1793: #ifdef __STDC__
1.50 cvs 1794: static CHAR_T* ParseCSSFontWeight (Element element, PSchema tsch,
1795: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1796: #else
1.50 cvs 1797: static CHAR_T* ParseCSSFontWeight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1798: Element element;
1799: PSchema tsch;
1800: PresentationContext context;
1801: STRING cssRule;
1802: CSSInfoPtr css;
1.14 cvs 1803: ThotBool isHTML;
1.1 cvs 1804: #endif
1805: {
1.20 cvs 1806: PresentationValue weight;
1.1 cvs 1807:
1808: weight.typed_data.value = 0;
1809: weight.typed_data.unit = STYLE_UNIT_REL;
1810: weight.typed_data.real = FALSE;
1.50 cvs 1811: cssRule = SkipWCBlanksAndComments (cssRule);
1812: if (!ustrncasecmp (cssRule, TEXT("100"), 3) && !TtaIsAlpha (cssRule[3]))
1.1 cvs 1813: {
1814: weight.typed_data.value = -3;
1815: cssRule = SkipWord (cssRule);
1816: }
1.50 cvs 1817: else if (!ustrncasecmp (cssRule, TEXT("200"), 3) && !TtaIsAlpha (cssRule[3]))
1.1 cvs 1818: {
1819: weight.typed_data.value = -2;
1820: cssRule = SkipWord (cssRule);
1821: }
1.50 cvs 1822: else if (!ustrncasecmp (cssRule, TEXT("300"), 3) && !TtaIsAlpha (cssRule[3]))
1.1 cvs 1823: {
1824: weight.typed_data.value = -1;
1825: cssRule = SkipWord (cssRule);
1826: }
1.50 cvs 1827: else if (!ustrncasecmp (cssRule, TEXT("normal"), 6) || (!ustrncasecmp (cssRule, TEXT("400"), 3) && !TtaIsAlpha (cssRule[3])))
1.1 cvs 1828: {
1829: weight.typed_data.value = 0;
1830: cssRule = SkipWord (cssRule);
1831: }
1.50 cvs 1832: else if (!ustrncasecmp (cssRule, TEXT("500"), 3) && !TtaIsAlpha (cssRule[3]))
1.1 cvs 1833: {
1834: weight.typed_data.value = +1;
1835: cssRule = SkipWord (cssRule);
1836: }
1.50 cvs 1837: else if (!ustrncasecmp (cssRule, TEXT("600"), 3) && !TtaIsAlpha (cssRule[3]))
1.1 cvs 1838: {
1839: weight.typed_data.value = +2;
1840: cssRule = SkipWord (cssRule);
1841: }
1.50 cvs 1842: else if (!ustrncasecmp (cssRule, TEXT("bold"), 4) || (!ustrncasecmp (cssRule, TEXT("700"), 3) && !TtaIsAlpha (cssRule[3])))
1.1 cvs 1843: {
1844: weight.typed_data.value = +3;
1845: cssRule = SkipWord (cssRule);
1846: }
1.50 cvs 1847: else if (!ustrncasecmp (cssRule, TEXT("800"), 3) && !TtaIsAlpha (cssRule[3]))
1.1 cvs 1848: {
1849: weight.typed_data.value = +4;
1850: cssRule = SkipWord (cssRule);
1851: }
1.50 cvs 1852: else if (!ustrncasecmp (cssRule, TEXT("900"), 3) && !TtaIsAlpha (cssRule[3]))
1.1 cvs 1853: {
1854: weight.typed_data.value = +5;
1855: cssRule = SkipWord (cssRule);
1856: }
1.50 cvs 1857: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7) || !ustrncasecmp (cssRule, TEXT("bolder"), 6) || !ustrncasecmp (cssRule, TEXT("lighter"), 7))
1.1 cvs 1858: {
1859: /* not implemented */
1860: cssRule = SkipWord (cssRule);
1861: return (cssRule);
1862: }
1863: else
1864: return (cssRule);
1865:
1866: /*
1.20 cvs 1867: * Here we have to reduce since only two font weight values are supported
1.1 cvs 1868: * by the Thot presentation API.
1869: */
1.20 cvs 1870: if (weight.typed_data.value > 0)
1871: weight.typed_data.value = STYLE_WEIGHT_BOLD;
1872: else
1873: weight.typed_data.value = STYLE_WEIGHT_NORMAL;
1.1 cvs 1874:
1875: /* install the new presentation */
1.21 cvs 1876: TtaSetStylePresentation (PRWeight, element, tsch, context, weight);
1.1 cvs 1877: return (cssRule);
1878: }
1879:
1880: /*----------------------------------------------------------------------
1.59 cvs 1881: ParseCSSFontVariant: parse a CSS font variant string
1.1 cvs 1882: we expect the input string describing the attribute to be
1883: normal or small-caps
1884: ----------------------------------------------------------------------*/
1885: #ifdef __STDC__
1.50 cvs 1886: static CHAR_T* ParseCSSFontVariant (Element element, PSchema tsch,
1887: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1888: #else
1.50 cvs 1889: static CHAR_T* ParseCSSFontVariant (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1890: Element element;
1891: PSchema tsch;
1892: PresentationContext context;
1893: STRING cssRule;
1894: CSSInfoPtr css;
1.14 cvs 1895: ThotBool isHTML;
1.1 cvs 1896: #endif
1897: {
1898: PresentationValue style;
1899:
1900: style.typed_data.value = 0;
1901: style.typed_data.unit = STYLE_UNIT_REL;
1902: style.typed_data.real = FALSE;
1.50 cvs 1903: cssRule = SkipWCBlanksAndComments (cssRule);
1904: if (!ustrncasecmp (cssRule, TEXT("small-caps"), 10))
1.1 cvs 1905: {
1906: /* Not supported yet */
1907: cssRule = SkipWord (cssRule);
1908: }
1.50 cvs 1909: else if (!ustrncasecmp (cssRule, TEXT("normal"), 6))
1.1 cvs 1910: {
1911: /* Not supported yet */
1912: cssRule = SkipWord (cssRule);
1913: }
1.50 cvs 1914: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))
1.1 cvs 1915: {
1916: /* Not supported yet */
1917: cssRule = SkipWord (cssRule);
1918: }
1919: else
1920: return (cssRule);
1921:
1922: return (cssRule);
1923: }
1924:
1925:
1926: /*----------------------------------------------------------------------
1.59 cvs 1927: ParseCSSFontStyle: parse a CSS font style string
1.1 cvs 1928: we expect the input string describing the attribute to be
1929: italic, oblique or normal
1930: ----------------------------------------------------------------------*/
1931: #ifdef __STDC__
1.50 cvs 1932: static CHAR_T* ParseCSSFontStyle (Element element, PSchema tsch,
1933: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 1934: #else
1.50 cvs 1935: static CHAR_T* ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 1936: Element element;
1937: PSchema tsch;
1938: PresentationContext context;
1939: STRING cssRule;
1940: CSSInfoPtr css;
1.14 cvs 1941: ThotBool isHTML;
1.1 cvs 1942: #endif
1943: {
1944: PresentationValue style;
1945: PresentationValue size;
1946:
1947: style.typed_data.value = 0;
1948: style.typed_data.unit = STYLE_UNIT_REL;
1949: style.typed_data.real = FALSE;
1950: size.typed_data.value = 0;
1951: size.typed_data.unit = STYLE_UNIT_REL;
1952: size.typed_data.real = FALSE;
1.50 cvs 1953: cssRule = SkipWCBlanksAndComments (cssRule);
1954: if (!ustrncasecmp (cssRule, TEXT("italic"), 6))
1.1 cvs 1955: {
1956: style.typed_data.value = STYLE_FONT_ITALICS;
1957: cssRule = SkipWord (cssRule);
1958: }
1.50 cvs 1959: else if (!ustrncasecmp (cssRule, TEXT("oblique"), 7))
1.1 cvs 1960: {
1961: style.typed_data.value = STYLE_FONT_OBLIQUE;
1962: cssRule = SkipWord (cssRule);
1963: }
1.50 cvs 1964: else if (!ustrncasecmp (cssRule, TEXT("normal"), 6))
1.1 cvs 1965: {
1966: style.typed_data.value = STYLE_FONT_ROMAN;
1967: cssRule = SkipWord (cssRule);
1968: }
1969: else
1970: {
1971: /* invalid font style */
1972: return (cssRule);
1973: }
1974:
1975: /*
1976: * install the new presentation.
1977: */
1978: if (style.typed_data.value != 0)
1.20 cvs 1979: TtaSetStylePresentation (PRStyle, element, tsch, context, style);
1.1 cvs 1980: if (size.typed_data.value != 0)
1981: {
1982: PresentationValue previous_size;
1983:
1984: if (!TtaGetStylePresentation (PRSize, element, tsch, context, &previous_size))
1985: {
1986: /* !!!!!!!!!!!!!!!!!!!!!!!! Unite + relatif !!!!!!!!!!!!!!!! */
1987: size.typed_data.value += previous_size.typed_data.value;
1988: TtaSetStylePresentation (PRSize, element, tsch, context, size);
1989: }
1990: else
1991: {
1992: size.typed_data.value = 10;
1993: TtaSetStylePresentation (PRSize, element, tsch, context, size);
1994: }
1995: }
1996: return (cssRule);
1997: }
1998:
1999: /*----------------------------------------------------------------------
1.59 cvs 2000: ParseCSSFont: parse a CSS font attribute string
2001: we expect the input string describing the attribute to be
2002: !!!!!!
1.1 cvs 2003: ----------------------------------------------------------------------*/
2004: #ifdef __STDC__
1.50 cvs 2005: static CHAR_T* ParseCSSFont (Element element, PSchema tsch,
2006: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2007: #else
1.50 cvs 2008: static CHAR_T* ParseCSSFont (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2009: Element element;
2010: PSchema tsch;
2011: PresentationContext context;
2012: STRING cssRule;
2013: CSSInfoPtr css;
1.14 cvs 2014: ThotBool isHTML;
1.1 cvs 2015: #endif
2016: {
1.50 cvs 2017: CHAR_T* ptr;
1.1 cvs 2018:
1.50 cvs 2019: cssRule = SkipWCBlanksAndComments (cssRule);
2020: if (!ustrncasecmp (cssRule, TEXT("caption"), 7))
1.1 cvs 2021: ;
1.50 cvs 2022: else if (!ustrncasecmp (cssRule, TEXT("icon"), 4))
1.1 cvs 2023: ;
1.50 cvs 2024: else if (!ustrncasecmp (cssRule, TEXT("menu"), 4))
1.1 cvs 2025: ;
1.50 cvs 2026: else if (!ustrncasecmp (cssRule, TEXT("message-box"), 11))
1.1 cvs 2027: ;
1.50 cvs 2028: else if (!ustrncasecmp (cssRule, TEXT("small-caption"), 13))
1.1 cvs 2029: ;
1.50 cvs 2030: else if (!ustrncasecmp (cssRule, TEXT("status-bar"), 10))
1.1 cvs 2031: ;
2032: else
1.43 cvs 2033: {
1.72 cvs 2034: while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))
1.43 cvs 2035: {
1.72 cvs 2036: ptr = cssRule;
2037: cssRule = ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML);
2038: if (ptr == cssRule)
2039: cssRule = ParseCSSFontVariant (element, tsch, context, cssRule, css, isHTML);
2040: if (ptr == cssRule)
2041: cssRule = ParseCSSFontWeight (element, tsch, context, cssRule, css, isHTML);
2042: if (ptr == cssRule)
2043: cssRule = ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML);
2044: if (ptr == cssRule)
2045: cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
2046: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 2047: }
2048: }
2049: return (cssRule);
1.1 cvs 2050: }
2051:
2052: /*----------------------------------------------------------------------
1.59 cvs 2053: ParseCSSTextDecoration: parse a CSS text decor string
2054: we expect the input string describing the attribute to be
2055: underline, overline, line-through, box, shadowbox, box3d,
2056: cartouche, blink or none
1.1 cvs 2057: ----------------------------------------------------------------------*/
2058: #ifdef __STDC__
1.50 cvs 2059: static CHAR_T* ParseCSSTextDecoration (Element element, PSchema tsch,
2060: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2061: #else
1.50 cvs 2062: static CHAR_T* ParseCSSTextDecoration (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2063: Element element;
2064: PSchema tsch;
2065: PresentationContext context;
2066: STRING cssRule;
2067: CSSInfoPtr css;
1.14 cvs 2068: ThotBool isHTML;
1.1 cvs 2069: #endif
2070: {
2071: PresentationValue decor;
2072:
2073: decor.typed_data.value = 0;
2074: decor.typed_data.unit = STYLE_UNIT_REL;
2075: decor.typed_data.real = FALSE;
1.50 cvs 2076: cssRule = SkipWCBlanksAndComments (cssRule);
2077: if (!ustrncasecmp (cssRule, TEXT("underline"), strlen ("underline")))
1.1 cvs 2078: {
2079: decor.typed_data.value = Underline;
2080: cssRule = SkipWord (cssRule);
2081: }
1.50 cvs 2082: else if (!ustrncasecmp (cssRule, TEXT("overline"), strlen ("overline")))
1.1 cvs 2083: {
2084: decor.typed_data.value = Overline;
2085: cssRule = SkipWord (cssRule);
2086: }
1.50 cvs 2087: else if (!ustrncasecmp (cssRule, TEXT("line-through"), strlen ("line-through")))
1.1 cvs 2088: {
2089: decor.typed_data.value = CrossOut;
2090: cssRule = SkipWord (cssRule);
2091: }
1.50 cvs 2092: else if (!ustrncasecmp (cssRule, TEXT("box"), strlen ("box")))
1.1 cvs 2093: {
2094: /* the box text-decoration attribute is not yet supported */
2095: cssRule = SkipWord (cssRule);
2096: }
1.50 cvs 2097: else if (!ustrncasecmp (cssRule, TEXT("boxshadow"), strlen ("boxshadow")))
1.1 cvs 2098: {
2099: /* the boxshadow text-decoration attribute is not yet supported */
2100: cssRule = SkipWord (cssRule);
2101: }
1.50 cvs 2102: else if (!ustrncasecmp (cssRule, TEXT("box3d"), strlen ("box3d")))
1.1 cvs 2103: {
2104: /* the box3d text-decoration attribute is not yet supported */
2105: cssRule = SkipWord (cssRule);
2106: }
1.50 cvs 2107: else if (!ustrncasecmp (cssRule, TEXT("cartouche"), strlen ("cartouche")))
1.1 cvs 2108: {
2109: /*the cartouche text-decoration attribute is not yet supported */
2110: cssRule = SkipWord (cssRule);
2111: }
1.50 cvs 2112: else if (!ustrncasecmp (cssRule, TEXT("blink"), strlen ("blink")))
1.1 cvs 2113: {
2114: /*the blink text-decoration attribute will not be supported */
2115: cssRule = SkipWord (cssRule);
2116: }
1.50 cvs 2117: else if (!ustrncasecmp (cssRule, TEXT("none"), strlen ("none")))
1.1 cvs 2118: {
2119: decor.typed_data.value = NoUnderline;
2120: cssRule = SkipWord (cssRule);
2121: }
2122: else
2123: {
2124: fprintf (stderr, "invalid text decoration\n");
2125: return (cssRule);
2126: }
2127:
2128: /*
2129: * install the new presentation.
2130: */
2131: if (decor.typed_data.value)
2132: {
2133: TtaSetStylePresentation (PRUnderline, element, tsch, context, decor);
2134: }
2135: return (cssRule);
2136: }
2137:
2138: /*----------------------------------------------------------------------
1.59 cvs 2139: ParseCSSHeight: parse a CSS height attribute
1.1 cvs 2140: ----------------------------------------------------------------------*/
2141: #ifdef __STDC__
1.50 cvs 2142: static CHAR_T* ParseCSSHeight (Element element, PSchema tsch,
2143: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2144: #else
1.50 cvs 2145: static CHAR_T* ParseCSSHeight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2146: Element element;
2147: PSchema tsch;
2148: PresentationContext context;
2149: STRING cssRule;
2150: CSSInfoPtr css;
1.14 cvs 2151: ThotBool isHTML;
1.1 cvs 2152: #endif
2153: {
1.50 cvs 2154: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2155:
2156: /* first parse the attribute string */
1.50 cvs 2157: if (!ustrcasecmp (cssRule, TEXT("auto")))
1.1 cvs 2158: {
2159: cssRule = SkipWord (cssRule);
1.59 cvs 2160: /* ParseCSSHeight: auto */
1.1 cvs 2161: return (cssRule);
2162: }
2163: else
2164: cssRule = SkipProperty (cssRule);
2165: return (cssRule);
2166: }
2167:
2168: /*----------------------------------------------------------------------
1.59 cvs 2169: ParseCSSWidth: parse a CSS width attribute
1.1 cvs 2170: ----------------------------------------------------------------------*/
2171: #ifdef __STDC__
1.50 cvs 2172: static CHAR_T* ParseCSSWidth (Element element, PSchema tsch,
2173: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2174: #else
1.50 cvs 2175: static CHAR_T* ParseCSSWidth (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2176: Element element;
2177: PSchema tsch;
2178: PresentationContext context;
2179: STRING cssRule;
2180: CSSInfoPtr css;
1.14 cvs 2181: ThotBool isHTML;
1.1 cvs 2182: #endif
2183: {
1.50 cvs 2184: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2185:
2186: /* first parse the attribute string */
1.50 cvs 2187: if (!ustrcasecmp (cssRule, TEXT("auto")))
1.1 cvs 2188: {
2189: cssRule = SkipWord (cssRule);
2190: return (cssRule);
2191: }
2192: else
2193: cssRule = SkipProperty (cssRule);
2194: return (cssRule);
2195: }
2196:
2197: /*----------------------------------------------------------------------
1.59 cvs 2198: ParseCSSMarginTop: parse a CSS margin-top attribute
1.1 cvs 2199: ----------------------------------------------------------------------*/
2200: #ifdef __STDC__
1.50 cvs 2201: static CHAR_T* ParseCSSMarginTop (Element element, PSchema tsch,
2202: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2203: #else
1.50 cvs 2204: static CHAR_T* ParseCSSMarginTop (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2205: Element element;
2206: PSchema tsch;
2207: PresentationContext context;
2208: STRING cssRule;
2209: CSSInfoPtr css;
1.14 cvs 2210: ThotBool isHTML;
1.1 cvs 2211: #endif
2212: {
2213: PresentationValue margin;
2214:
1.50 cvs 2215: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2216: /* first parse the attribute string */
2217: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 2218: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
1.1 cvs 2219: {
1.40 cvs 2220: TtaSetStylePresentation (PRMarginTop, element, tsch, context, margin);
1.1 cvs 2221: if (margin.typed_data.value < 0)
2222: TtaSetStylePresentation (PRVertOverflow, element, tsch, context, margin);
2223: }
2224: return (cssRule);
2225: }
2226:
2227: /*----------------------------------------------------------------------
1.59 cvs 2228: ParseCSSMarginBottom: parse a CSS margin-bottom attribute
1.1 cvs 2229: ----------------------------------------------------------------------*/
2230: #ifdef __STDC__
1.50 cvs 2231: static CHAR_T* ParseCSSMarginBottom (Element element, PSchema tsch,
2232: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2233: #else
1.50 cvs 2234: static CHAR_T* ParseCSSMarginBottom (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2235: Element element;
2236: PSchema tsch;
2237: PresentationContext context;
2238: STRING cssRule;
2239: CSSInfoPtr css;
1.14 cvs 2240: ThotBool isHTML;
1.1 cvs 2241: #endif
2242: {
2243: PresentationValue margin;
2244:
1.50 cvs 2245: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2246: /* first parse the attribute string */
2247: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 2248: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
2249: TtaSetStylePresentation (PRMarginBottom, element, tsch, context, margin);
1.1 cvs 2250: return (cssRule);
2251: }
2252:
2253: /*----------------------------------------------------------------------
1.59 cvs 2254: ParseCSSMarginLeft: parse a CSS margin-left attribute string
1.1 cvs 2255: ----------------------------------------------------------------------*/
2256: #ifdef __STDC__
1.50 cvs 2257: static CHAR_T* ParseCSSMarginLeft (Element element, PSchema tsch,
2258: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2259: #else
1.50 cvs 2260: static CHAR_T* ParseCSSMarginLeft (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2261: Element element;
2262: PSchema tsch;
2263: PresentationContext context;
2264: STRING cssRule;
2265: CSSInfoPtr css;
1.14 cvs 2266: ThotBool isHTML;
1.1 cvs 2267: #endif
2268: {
2269: PresentationValue margin;
2270:
1.50 cvs 2271: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2272: /* first parse the attribute string */
2273: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 2274: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
1.1 cvs 2275: {
1.40 cvs 2276: TtaSetStylePresentation (PRMarginLeft, element, tsch, context, margin);
1.1 cvs 2277: if (margin.typed_data.value < 0)
2278: TtaSetStylePresentation (PRHorizOverflow, element, tsch, context, margin);
2279: }
2280: return (cssRule);
2281: }
2282:
2283: /*----------------------------------------------------------------------
1.59 cvs 2284: ParseCSSMarginRight: parse a CSS margin-right attribute string
1.1 cvs 2285: ----------------------------------------------------------------------*/
2286: #ifdef __STDC__
1.50 cvs 2287: static CHAR_T* ParseCSSMarginRight (Element element, PSchema tsch,
2288: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2289: #else
1.50 cvs 2290: static CHAR_T* ParseCSSMarginRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2291: Element element;
2292: PSchema tsch;
2293: PresentationContext context;
2294: STRING cssRule;
2295: CSSInfoPtr css;
1.14 cvs 2296: ThotBool isHTML;
1.1 cvs 2297: #endif
2298: {
2299: PresentationValue margin;
2300:
1.50 cvs 2301: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2302: /* first parse the attribute string */
2303: cssRule = ParseCSSUnit (cssRule, &margin);
1.43 cvs 2304: if (margin.typed_data.unit != STYLE_UNIT_INVALID)
2305: TtaSetStylePresentation (PRMarginRight, element, tsch, context, margin);
1.1 cvs 2306: return (cssRule);
2307: }
2308:
2309: /*----------------------------------------------------------------------
1.59 cvs 2310: ParseCSSMargin: parse a CSS margin attribute string
1.1 cvs 2311: ----------------------------------------------------------------------*/
2312: #ifdef __STDC__
1.50 cvs 2313: static CHAR_T* ParseCSSMargin (Element element, PSchema tsch,
2314: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2315: #else
1.50 cvs 2316: static CHAR_T* ParseCSSMargin (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2317: Element element;
2318: PSchema tsch;
2319: PresentationContext context;
2320: STRING cssRule;
2321: CSSInfoPtr css;
1.14 cvs 2322: ThotBool isHTML;
1.1 cvs 2323: #endif
2324: {
1.50 cvs 2325: CHAR_T *ptrT, *ptrR, *ptrB, *ptrL;
1.1 cvs 2326:
1.50 cvs 2327: ptrT = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2328: /* First parse Margin-Top */
2329: ptrR = ParseCSSMarginTop (element, tsch, context, ptrT, css, isHTML);
1.50 cvs 2330: ptrR = SkipWCBlanksAndComments (ptrR);
2331: if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))
1.1 cvs 2332: {
2333: cssRule = ptrR;
2334: /* apply the Margin-Top to all */
2335: ptrR = ParseCSSMarginRight (element, tsch, context, ptrT, css, isHTML);
2336: ptrR = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
2337: ptrR = ParseCSSMarginLeft (element, tsch, context, ptrT, css, isHTML);
2338: }
2339: else
2340: {
2341: /* parse Margin-Right */
2342: ptrB = ParseCSSMarginRight (element, tsch, context, ptrR, css, isHTML);
1.50 cvs 2343: ptrB = SkipWCBlanksAndComments (ptrB);
2344: if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))
1.1 cvs 2345: {
2346: cssRule = ptrB;
2347: /* apply the Margin-Top to Margin-Bottom */
2348: ptrB = ParseCSSMarginBottom (element, tsch, context, ptrT, css, isHTML);
2349: /* apply the Margin-Right to Margin-Left */
2350: ptrB = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2351: }
2352: else
2353: {
2354: /* parse Margin-Bottom */
2355: ptrL = ParseCSSMarginBottom (element, tsch, context, ptrB, css, isHTML);
1.50 cvs 2356: ptrL = SkipWCBlanksAndComments (ptrL);
2357: if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))
1.1 cvs 2358: {
2359: cssRule = ptrL;
2360: /* apply the Margin-Right to Margin-Left */
2361: ptrL = ParseCSSMarginLeft (element, tsch, context, ptrR, css, isHTML);
2362: }
2363: else
2364: /* parse Margin-Left */
2365: cssRule = ParseCSSMarginLeft (element, tsch, context, ptrL, css, isHTML);
1.50 cvs 2366: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2367: }
2368: }
2369: return (cssRule);
2370: }
2371:
2372: /*----------------------------------------------------------------------
1.59 cvs 2373: ParseCSSPaddingTop: parse a CSS PaddingTop attribute string
1.1 cvs 2374: ----------------------------------------------------------------------*/
2375: #ifdef __STDC__
1.50 cvs 2376: static CHAR_T* ParseCSSPaddingTop (Element element, PSchema tsch,
2377: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2378: #else
1.50 cvs 2379: static CHAR_T* ParseCSSPaddingTop (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2380: Element element;
2381: PSchema tsch;
2382: PresentationContext context;
2383: STRING cssRule;
2384: CSSInfoPtr css;
1.14 cvs 2385: ThotBool isHTML;
1.1 cvs 2386: #endif
2387: {
1.43 cvs 2388: PresentationValue padding;
2389:
1.50 cvs 2390: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 2391: /* first parse the attribute string */
2392: cssRule = ParseCSSUnit (cssRule, &padding);
2393: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2394: TtaSetStylePresentation (PRPaddingTop, element, tsch, context, padding);
1.1 cvs 2395: return (cssRule);
2396: }
2397:
2398: /*----------------------------------------------------------------------
1.59 cvs 2399: ParseCSSPaddingBottom: parse a CSS PaddingBottom attribute string
1.1 cvs 2400: ----------------------------------------------------------------------*/
2401: #ifdef __STDC__
1.50 cvs 2402: static CHAR_T* ParseCSSPaddingBottom (Element element, PSchema tsch,
2403: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2404: #else
1.50 cvs 2405: static CHAR_T* ParseCSSPaddingBottom (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2406: Element element;
2407: PSchema tsch;
2408: PresentationContext context;
2409: STRING cssRule;
2410: CSSInfoPtr css;
1.14 cvs 2411: ThotBool isHTML;
1.1 cvs 2412: #endif
2413: {
1.43 cvs 2414: PresentationValue padding;
2415:
1.50 cvs 2416: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 2417: /* first parse the attribute string */
2418: cssRule = ParseCSSUnit (cssRule, &padding);
2419: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2420: TtaSetStylePresentation (PRPaddingBottom, element, tsch, context, padding);
1.1 cvs 2421: return (cssRule);
2422: }
2423:
2424: /*----------------------------------------------------------------------
1.59 cvs 2425: ParseCSSPaddingLeft: parse a CSS PaddingLeft attribute string.
1.1 cvs 2426: ----------------------------------------------------------------------*/
2427: #ifdef __STDC__
1.50 cvs 2428: static CHAR_T* ParseCSSPaddingLeft (Element element, PSchema tsch,
2429: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2430: #else
1.50 cvs 2431: static CHAR_T* ParseCSSPaddingLeft (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2432: Element element;
2433: PSchema tsch;
2434: PresentationContext context;
2435: STRING cssRule;
2436: CSSInfoPtr css;
1.14 cvs 2437: ThotBool isHTML;
1.1 cvs 2438: #endif
2439: {
1.43 cvs 2440: PresentationValue padding;
2441:
1.50 cvs 2442: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 2443: /* first parse the attribute string */
2444: cssRule = ParseCSSUnit (cssRule, &padding);
2445: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2446: TtaSetStylePresentation (PRPaddingLeft, element, tsch, context, padding);
1.1 cvs 2447: return (cssRule);
2448: }
2449:
2450: /*----------------------------------------------------------------------
1.59 cvs 2451: ParseCSSPaddingRight: parse a CSS PaddingRight attribute string.
1.1 cvs 2452: ----------------------------------------------------------------------*/
2453: #ifdef __STDC__
1.50 cvs 2454: static CHAR_T* ParseCSSPaddingRight (Element element, PSchema tsch,
2455: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2456: #else
1.50 cvs 2457: static CHAR_T* ParseCSSPaddingRight (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2458: Element element;
2459: PSchema tsch;
2460: PresentationContext context;
2461: STRING cssRule;
2462: CSSInfoPtr css;
1.14 cvs 2463: ThotBool isHTML;
1.1 cvs 2464: #endif
2465: {
1.43 cvs 2466: PresentationValue padding;
2467:
1.50 cvs 2468: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 2469: /* first parse the attribute string */
2470: cssRule = ParseCSSUnit (cssRule, &padding);
2471: if (padding.typed_data.unit != STYLE_UNIT_INVALID)
2472: TtaSetStylePresentation (PRPaddingRight, element, tsch, context, padding);
1.1 cvs 2473: return (cssRule);
2474: }
2475:
2476: /*----------------------------------------------------------------------
1.59 cvs 2477: ParseCSSPadding: parse a CSS padding attribute string.
1.1 cvs 2478: ----------------------------------------------------------------------*/
2479: #ifdef __STDC__
1.50 cvs 2480: static CHAR_T* ParseCSSPadding (Element element, PSchema tsch,
2481: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2482: #else
1.50 cvs 2483: static CHAR_T* ParseCSSPadding (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2484: Element element;
2485: PSchema tsch;
2486: PresentationContext context;
2487: STRING cssRule;
2488: CSSInfoPtr css;
1.14 cvs 2489: ThotBool isHTML;
1.1 cvs 2490: #endif
2491: {
1.50 cvs 2492: CHAR_T *ptrT, *ptrR, *ptrB, *ptrL;
1.43 cvs 2493:
1.50 cvs 2494: ptrT = SkipWCBlanksAndComments (cssRule);
1.43 cvs 2495: /* First parse Padding-Top */
2496: ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
1.50 cvs 2497: ptrR = SkipWCBlanksAndComments (ptrR);
2498: if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))
1.43 cvs 2499: {
2500: cssRule = ptrR;
2501: /* apply the Padding-Top to all */
2502: ptrR = ParseCSSPaddingRight (element, tsch, context, ptrT, css, isHTML);
2503: ptrR = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
2504: ptrR = ParseCSSPaddingLeft (element, tsch, context, ptrT, css, isHTML);
2505: }
2506: else
2507: {
2508: /* parse Padding-Right */
2509: ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);
1.50 cvs 2510: ptrB = SkipWCBlanksAndComments (ptrB);
2511: if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))
1.43 cvs 2512: {
2513: cssRule = ptrB;
2514: /* apply the Padding-Top to Padding-Bottom */
2515: ptrB = ParseCSSPaddingBottom (element, tsch, context, ptrT, css, isHTML);
2516: /* apply the Padding-Right to Padding-Left */
2517: ptrB = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2518: }
2519: else
2520: {
2521: /* parse Padding-Bottom */
2522: ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);
1.50 cvs 2523: ptrL = SkipWCBlanksAndComments (ptrL);
2524: if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))
1.43 cvs 2525: {
2526: cssRule = ptrL;
2527: /* apply the Padding-Right to Padding-Left */
2528: ptrL = ParseCSSPaddingLeft (element, tsch, context, ptrR, css, isHTML);
2529: }
2530: else
2531: /* parse Padding-Left */
2532: cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);
1.50 cvs 2533: cssRule = SkipWCBlanksAndComments (cssRule);
1.43 cvs 2534: }
2535: }
1.1 cvs 2536: return (cssRule);
2537: }
2538:
2539: /*----------------------------------------------------------------------
1.59 cvs 2540: ParseCSSForeground: parse a CSS foreground attribute
1.1 cvs 2541: ----------------------------------------------------------------------*/
2542: #ifdef __STDC__
1.50 cvs 2543: static CHAR_T* ParseCSSForeground (Element element, PSchema tsch,
2544: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2545: #else
1.50 cvs 2546: static CHAR_T* ParseCSSForeground (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2547: Element element;
2548: PSchema tsch;
2549: PresentationContext context;
2550: STRING cssRule;
2551: CSSInfoPtr css;
1.14 cvs 2552: ThotBool isHTML;
1.1 cvs 2553: #endif
2554: {
2555: PresentationValue best;
2556:
2557: cssRule = ParseCSSColor (cssRule, &best);
1.25 cvs 2558: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2559: /* install the new presentation */
2560: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
1.1 cvs 2561: return (cssRule);
2562: }
2563:
2564: /*----------------------------------------------------------------------
1.59 cvs 2565: ParseCSSBackgroundColor: parse a CSS background color attribute
1.1 cvs 2566: ----------------------------------------------------------------------*/
2567: #ifdef __STDC__
1.50 cvs 2568: static CHAR_T* ParseCSSBackgroundColor (Element element, PSchema tsch,
2569: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2570: #else
1.50 cvs 2571: static CHAR_T* ParseCSSBackgroundColor (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2572: Element element;
2573: PSchema tsch;
2574: PresentationContext context;
1.50 cvs 2575: CHAR_T* cssRule;
1.1 cvs 2576: CSSInfoPtr css;
1.14 cvs 2577: ThotBool isHTML;
1.1 cvs 2578: #endif
2579: {
2580: PresentationValue best;
2581: unsigned int savedtype = 0;
1.14 cvs 2582: ThotBool moved;
1.1 cvs 2583:
2584: /* move the BODY rule to the HTML element */
2585: moved = (context->type == HTML_EL_BODY && isHTML);
2586: if (moved)
2587: {
2588: if (element)
2589: element = TtaGetMainRoot (context->doc);
2590: else
2591: {
2592: savedtype = context->type;
2593: context->type = HTML_EL_HTML;
2594: }
2595: }
2596:
2597: best.typed_data.unit = STYLE_UNIT_INVALID;
2598: best.typed_data.real = FALSE;
1.50 cvs 2599: if (!ustrncasecmp (cssRule, TEXT("transparent"), strlen ("transparent")))
1.1 cvs 2600: {
2601: best.typed_data.value = STYLE_PATTERN_NONE;
2602: best.typed_data.unit = STYLE_UNIT_REL;
2603: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
1.65 cvs 2604: cssRule = SkipWord (cssRule);
1.1 cvs 2605: }
2606: else
2607: {
2608: cssRule = ParseCSSColor (cssRule, &best);
2609: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2610: {
2611: /* install the new presentation. */
2612: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
1.59 cvs 2613: /* thot specificity: need to set fill pattern for background color */
1.1 cvs 2614: best.typed_data.value = STYLE_PATTERN_BACKGROUND;
2615: best.typed_data.unit = STYLE_UNIT_REL;
2616: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2617: best.typed_data.value = 1;
2618: best.typed_data.unit = STYLE_UNIT_REL;
2619: TtaSetStylePresentation (PRShowBox, element, tsch, context, best);
2620: }
2621: }
2622:
2623: /* restore the refered element */
2624: if (moved && !element)
2625: context->type = savedtype;
2626: return (cssRule);
2627: }
2628:
1.63 cvs 2629:
2630: /*----------------------------------------------------------------------
1.65 cvs 2631: ParseSVGStroke: parse a SVG stroke property
2632: ----------------------------------------------------------------------*/
2633: #ifdef __STDC__
2634: static CHAR_T* ParseSVGStroke (Element element, PSchema tsch,
2635: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
2636: #else
2637: static CHAR_T* ParseSVGStroke (element, tsch, context, cssRule, css, isHTML)
2638: Element element;
2639: PSchema tsch;
2640: PresentationContext context;
2641: CHAR_T* cssRule;
2642: CSSInfoPtr css;
2643: ThotBool isHTML;
2644: #endif
2645: {
2646: PresentationValue best;
2647:
2648: best.typed_data.unit = STYLE_UNIT_INVALID;
2649: best.typed_data.real = FALSE;
2650: if (!ustrncasecmp (cssRule, TEXT("none"), strlen ("none")))
2651: {
2652: best.typed_data.value = -2; /* -2 means transparent */
2653: best.typed_data.unit = STYLE_UNIT_REL;
2654: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2655: cssRule = SkipWord (cssRule);
2656: }
2657: else
2658: {
2659: cssRule = ParseCSSColor (cssRule, &best);
2660: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2661: /* install the new presentation */
2662: TtaSetStylePresentation (PRForeground, element, tsch, context, best);
2663: }
2664: return (cssRule);
2665: }
2666:
2667: /*----------------------------------------------------------------------
1.63 cvs 2668: ParseSVGFill: parse a SVG fill property
2669: ----------------------------------------------------------------------*/
2670: #ifdef __STDC__
2671: static CHAR_T* ParseSVGFill (Element element, PSchema tsch,
2672: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
2673: #else
2674: static CHAR_T* ParseSVGFill (element, tsch, context, cssRule, css, isHTML)
2675: Element element;
2676: PSchema tsch;
2677: PresentationContext context;
2678: CHAR_T* cssRule;
2679: CSSInfoPtr css;
2680: ThotBool isHTML;
2681: #endif
2682: {
2683: PresentationValue best;
2684:
2685: best.typed_data.unit = STYLE_UNIT_INVALID;
2686: best.typed_data.real = FALSE;
2687: if (!ustrncasecmp (cssRule, TEXT("none"), strlen ("none")))
2688: {
2689: best.typed_data.value = STYLE_PATTERN_NONE;
2690: best.typed_data.unit = STYLE_UNIT_REL;
2691: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
1.65 cvs 2692: cssRule = SkipWord (cssRule);
1.63 cvs 2693: }
2694: else
2695: {
2696: cssRule = ParseCSSColor (cssRule, &best);
2697: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2698: {
2699: /* install the new presentation. */
2700: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
2701: /* thot specificity: need to set fill pattern for background color */
2702: best.typed_data.value = STYLE_PATTERN_BACKGROUND;
2703: best.typed_data.unit = STYLE_UNIT_REL;
2704: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2705: }
2706: }
2707: return (cssRule);
2708: }
2709:
1.1 cvs 2710: /*----------------------------------------------------------------------
1.59 cvs 2711: ParseCSSBackgroundImageCallback: Callback called asynchronously by
2712: FetchImage when a background image has been fetched.
1.1 cvs 2713: ----------------------------------------------------------------------*/
2714: #ifdef __STDC__
1.50 cvs 2715: void ParseCSSBackgroundImageCallback (Document doc, Element element, STRING file, void *extra)
1.1 cvs 2716: #else
2717: void ParseCSSBackgroundImageCallback (doc, element, file, extra)
2718: Document doc;
2719: Element element;
2720: STRING file;
2721: void *extra;
2722: #endif
2723: {
1.34 cvs 2724: DisplayMode dispMode;
2725: BackgroundImageCallbackPtr callblock = (BackgroundImageCallbackPtr) extra;
2726: Element el;
2727: PSchema tsch;
2728: PresentationContext context;
2729: PresentationValue image;
2730: PresentationValue value;
1.1 cvs 2731:
1.34 cvs 2732: if (callblock == NULL)
2733: return;
1.1 cvs 2734:
1.34 cvs 2735: /* avoid too many redisplay */
2736: dispMode = TtaGetDisplayMode (doc);
2737: if (dispMode == DisplayImmediately)
2738: TtaSetDisplayMode (doc, DeferredDisplay);
2739:
2740: el = callblock->el;
2741: tsch = callblock->tsch;
2742: context = &callblock->context.specific;
2743:
2744: /* Ok the image was fetched, finish the background-image handling */
2745: image.pointer = file;
2746: TtaSetStylePresentation (PRBackgroundPicture, el, tsch, context, image);
1.1 cvs 2747:
1.70 cvs 2748: /* enforce the showbox */
1.34 cvs 2749: value.typed_data.value = 1;
2750: value.typed_data.unit = STYLE_UNIT_REL;
2751: value.typed_data.real = FALSE;
2752: TtaSetStylePresentation (PRShowBox, el, tsch, context, value);
2753:
2754: TtaFreeMemory (callblock);
2755: /* restore the display mode */
2756: if (dispMode == DisplayImmediately)
2757: TtaSetDisplayMode (doc, dispMode);
1.1 cvs 2758: }
2759:
2760:
2761: /*----------------------------------------------------------------------
2762: GetCSSBackgroundURL searches a CSS BackgroundImage url within
2763: the styleString.
2764: Returns NULL or a new allocated url string.
2765: ----------------------------------------------------------------------*/
2766: #ifdef __STDC__
1.50 cvs 2767: CHAR_T* GetCSSBackgroundURL (CHAR_T* styleString)
1.1 cvs 2768: #else
1.50 cvs 2769: CHAR_T* GetCSSBackgroundURL (styleString)
2770: CHAR_T* styleString;
1.1 cvs 2771: #endif
2772: {
1.50 cvs 2773: CHAR_T *b, *e, *ptr;
1.1 cvs 2774: int len;
2775:
2776: ptr = NULL;
1.50 cvs 2777: b = ustrstr (styleString, TEXT("url"));
1.1 cvs 2778: if (b != NULL)
2779: {
2780: b += 3;
1.50 cvs 2781: b = SkipWCBlanksAndComments (b);
2782: if (*b == TEXT('('))
1.1 cvs 2783: {
2784: b++;
1.50 cvs 2785: b = SkipWCBlanksAndComments (b);
1.1 cvs 2786: /*** Caution: Strings can either be written with double quotes or
2787: with single quotes. Only double quotes are handled here.
2788: Escaped quotes are not handled. See function SkipQuotedString */
1.50 cvs 2789: if (*b == TEXT('"'))
1.1 cvs 2790: {
2791: b++;
2792: /* search the url end */
2793: e = b;
1.50 cvs 2794: while (*e != WC_EOS && *e != TEXT('"'))
1.1 cvs 2795: e++;
2796: }
2797: else
2798: {
2799: /* search the url end */
2800: e = b;
1.50 cvs 2801: while (*e != WC_EOS && *e != TEXT(')'))
1.1 cvs 2802: e++;
2803: }
1.50 cvs 2804: if (*e != WC_EOS)
1.1 cvs 2805: {
2806: len = (int)(e - b);
1.50 cvs 2807: ptr = (CHAR_T*) TtaAllocString (len+1);
2808: ustrncpy (ptr, b, len);
2809: ptr[len] = WC_EOS;
1.1 cvs 2810: }
2811: }
2812: }
2813: return (ptr);
2814: }
2815:
2816:
2817: /*----------------------------------------------------------------------
1.59 cvs 2818: ParseCSSBackgroundImage: parse a CSS BackgroundImage attribute string.
1.1 cvs 2819: ----------------------------------------------------------------------*/
2820: #ifdef __STDC__
1.71 cvs 2821: static CHAR_T *ParseCSSBackgroundImage (Element element, PSchema tsch,
1.49 cvs 2822: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2823: #else
1.71 cvs 2824: static CHAR_T *ParseCSSBackgroundImage (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2825: Element element;
2826: PSchema tsch;
2827: PresentationContext context;
1.49 cvs 2828: CHAR_T* cssRule;
1.1 cvs 2829: CSSInfoPtr css;
1.14 cvs 2830: ThotBool isHTML;
1.1 cvs 2831: #endif
2832: {
1.49 cvs 2833: Element el;
2834: GenericContext gblock;
1.71 cvs 2835: PresentationContext sblock;
1.1 cvs 2836: BackgroundImageCallbackPtr callblock;
1.49 cvs 2837: PresentationValue image, value;
2838: CHAR_T* url;
2839: STRING bg_image;
2840: CHAR_T saved;
2841: CHAR_T* base;
2842: CHAR_T tempname[MAX_LENGTH];
2843: CHAR_T imgname[MAX_LENGTH];
2844: unsigned int savedtype = 0;
2845: ThotBool moved;
1.1 cvs 2846:
2847: /* default element for FetchImage */
2848: el = TtaGetMainRoot (context->doc);
2849: /* move the BODY rule to the HTML element */
2850: moved = (context->type == HTML_EL_BODY && isHTML);
2851: if (moved)
2852: {
2853: if (element)
2854: element = el;
2855: else
2856: {
2857: savedtype = context->type;
2858: context->type = HTML_EL_HTML;
2859: }
2860: }
2861: else if (element)
2862: el = element;
2863:
2864: url = NULL;
1.49 cvs 2865: cssRule = SkipWCBlanksAndComments (cssRule);
2866: if (!ustrncasecmp (cssRule, TEXT("url"), 3))
1.1 cvs 2867: {
2868: cssRule += 3;
1.49 cvs 2869: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2870: if (*cssRule == '(')
2871: {
2872: cssRule++;
1.49 cvs 2873: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2874: /*** Caution: Strings can either be written with double quotes or
2875: with single quotes. Only double quotes are handled here.
2876: Escaped quotes are not handled. See function SkipQuotedString */
2877: if (*cssRule == '"')
2878: {
2879: cssRule++;
2880: base = cssRule;
1.49 cvs 2881: while (*cssRule != WC_EOS && *cssRule != TEXT('"'))
1.1 cvs 2882: cssRule++;
2883: }
2884: else
2885: {
2886: base = cssRule;
2887: while (*cssRule != EOS && *cssRule != ')')
2888: cssRule++;
2889: }
2890: saved = *cssRule;
1.49 cvs 2891: *cssRule = WC_EOS;
2892: url = TtaWCSdup (base);
1.1 cvs 2893: *cssRule = saved;
2894: if (saved == '"')
2895: /* we need to skip two characters */
2896: cssRule++;
2897: }
2898: cssRule++;
2899:
2900: if (context->destroy)
2901: {
2902: /* remove the background image PRule */
2903: image.pointer = NULL;
2904: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, context, image);
2905: if (TtaGetStylePresentation (PRFillPattern, element, tsch, context, &value) < 0)
2906: {
2907: /* there is no FillPattern rule -> remove ShowBox rule */
2908: value.typed_data.value = 1;
2909: value.typed_data.unit = STYLE_UNIT_REL;
2910: value.typed_data.real = FALSE;
2911: TtaSetStylePresentation (PRShowBox, element, tsch, context, value);
2912: }
2913: }
2914: else if (url)
2915: {
1.30 cvs 2916: bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
1.17 cvs 2917: if (bg_image == NULL || !ustrcasecmp (bg_image, TEXT("yes")))
1.1 cvs 2918: {
2919: callblock = (BackgroundImageCallbackPtr) TtaGetMemory(sizeof(BackgroundImageCallbackBlock));
2920: if (callblock != NULL)
2921: {
2922: callblock->el = element;
2923: callblock->tsch = tsch;
2924: if (element == NULL)
1.18 cvs 2925: {
2926: gblock = (GenericContext) context;
2927: memcpy (&callblock->context.generic, gblock,
2928: sizeof (GenericContextBlock));
2929: }
2930: else
2931: {
2932: sblock = context;
2933: memcpy (&callblock->context.specific, sblock,
2934: sizeof(PresentationContextBlock));
2935: }
2936:
2937: /* check if the image url is related to an external CSS */
2938: if (css != NULL && css->category == CSS_EXTERNAL_STYLE)
2939: {
2940: NormalizeURL (url, 0, tempname, imgname, css->url);
2941: /* fetch and display background image of element */
1.49 cvs 2942: FetchImage (context->doc, el, tempname, AMAYA_LOAD_IMAGE, ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 2943: }
2944: else
1.49 cvs 2945: FetchImage (context->doc, el, url, AMAYA_LOAD_IMAGE, ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 2946: }
2947: }
2948:
2949: if (url)
2950: TtaFreeMemory (url);
2951: }
2952: }
2953:
2954: /* restore the refered element */
2955: if (moved && !element)
2956: context->type = savedtype;
2957: return (cssRule);
2958: }
2959:
2960: /*----------------------------------------------------------------------
1.59 cvs 2961: ParseCSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
1.18 cvs 2962: ----------------------------------------------------------------------*/
2963: #ifdef __STDC__
1.50 cvs 2964: static CHAR_T* ParseCSSBackgroundRepeat (Element element, PSchema tsch,
2965: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 2966: #else
1.50 cvs 2967: static CHAR_T* ParseCSSBackgroundRepeat (element, tsch, context, cssRule, css, isHTML)
1.18 cvs 2968: Element element;
2969: PSchema tsch;
2970: PresentationContext context;
1.50 cvs 2971: CHAR_T* cssRule;
1.18 cvs 2972: CSSInfoPtr css;
2973: ThotBool isHTML;
2974: #endif
2975: {
2976: PresentationValue repeat;
2977: unsigned int savedtype = 0;
2978: ThotBool moved;
2979:
2980: /* move the BODY rule to the HTML element */
2981: moved = (context->type == HTML_EL_BODY && isHTML);
2982: if (moved)
2983: {
2984: if (element)
2985: element = TtaGetMainRoot (context->doc);
2986: else
2987: {
2988: savedtype = context->type;
2989: context->type = HTML_EL_HTML;
2990: }
2991: }
2992:
2993: repeat.typed_data.value = STYLE_REALSIZE;
2994: repeat.typed_data.unit = STYLE_UNIT_REL;
2995: repeat.typed_data.real = FALSE;
1.50 cvs 2996: cssRule = SkipWCBlanksAndComments (cssRule);
2997: if (!ustrncasecmp (cssRule, TEXT("no-repeat"), 9))
1.18 cvs 2998: repeat.typed_data.value = STYLE_REALSIZE;
1.50 cvs 2999: else if (!ustrncasecmp (cssRule, TEXT("repeat-y"), 8))
1.18 cvs 3000: repeat.typed_data.value = STYLE_VREPEAT;
1.50 cvs 3001: else if (!ustrncasecmp (cssRule, TEXT("repeat-x"), 8))
1.18 cvs 3002: repeat.typed_data.value = STYLE_HREPEAT;
1.50 cvs 3003: else if (!ustrncasecmp (cssRule, TEXT("repeat"), 6))
1.18 cvs 3004: repeat.typed_data.value = STYLE_REPEAT;
3005: else
3006: return (cssRule);
3007:
3008: /* install the new presentation */
3009: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
3010: cssRule = SkipWord (cssRule);
3011:
3012: /* restore the refered element */
3013: if (moved && !element)
3014: context->type = savedtype;
3015: return (cssRule);
3016: }
3017:
3018: /*----------------------------------------------------------------------
1.59 cvs 3019: ParseCSSBackgroundAttachment: parse a CSS BackgroundAttachment
1.18 cvs 3020: attribute string.
3021: ----------------------------------------------------------------------*/
3022: #ifdef __STDC__
1.58 cvs 3023: static CHAR_T* ParseCSSBackgroundAttachment (Element element, PSchema tsch,
1.50 cvs 3024: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3025: #else
1.58 cvs 3026: static CHAR_T* ParseCSSBackgroundAttachment (element, tsch, context, cssRule, css, isHTML)
1.18 cvs 3027: Element element;
3028: PSchema tsch;
3029: PresentationContext context;
1.50 cvs 3030: CHAR_T* cssRule;
1.18 cvs 3031: CSSInfoPtr css;
3032: ThotBool isHTML;
3033: #endif
3034: {
3035: unsigned int savedtype = 0;
3036: ThotBool moved;
1.1 cvs 3037:
1.18 cvs 3038: /* move the BODY rule to the HTML element */
3039: moved = (context->type == HTML_EL_BODY && isHTML);
3040: if (moved)
3041: {
3042: if (element)
3043: element = TtaGetMainRoot (context->doc);
3044: else
3045: {
3046: savedtype = context->type;
3047: context->type = HTML_EL_HTML;
1.1 cvs 3048: }
3049: }
3050:
1.50 cvs 3051: cssRule = SkipWCBlanksAndComments (cssRule);
3052: if (!ustrncasecmp (cssRule, TEXT("scroll"), 6))
1.18 cvs 3053: cssRule = SkipWord (cssRule);
1.50 cvs 3054: else if (!ustrncasecmp (cssRule, TEXT("fixed"), 5))
1.18 cvs 3055: cssRule = SkipWord (cssRule);
3056:
1.1 cvs 3057: /* restore the refered element */
3058: if (moved && !element)
3059: context->type = savedtype;
1.18 cvs 3060: return (cssRule);
1.1 cvs 3061: }
3062:
3063: /*----------------------------------------------------------------------
1.59 cvs 3064: ParseCSSBackgroundPosition: parse a CSS BackgroundPosition
1.1 cvs 3065: attribute string.
3066: ----------------------------------------------------------------------*/
3067: #ifdef __STDC__
1.70 cvs 3068: static CHAR_T* ParseCSSBackgroundPosition (Element element, PSchema tsch,
1.50 cvs 3069: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 3070: #else
1.70 cvs 3071: static CHAR_T* ParseCSSBackgroundPosition (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 3072: Element element;
3073: PSchema tsch;
3074: PresentationContext context;
1.70 cvs 3075: CHAR_T *cssRule;
1.1 cvs 3076: CSSInfoPtr css;
1.14 cvs 3077: ThotBool isHTML;
1.1 cvs 3078: #endif
3079: {
1.18 cvs 3080: PresentationValue repeat;
3081: unsigned int savedtype = 0;
3082: ThotBool moved;
3083: ThotBool ok;
1.1 cvs 3084:
3085: /* move the BODY rule to the HTML element */
3086: moved = (context->type == HTML_EL_BODY && isHTML);
3087: if (moved)
3088: {
3089: if (element)
3090: element = TtaGetMainRoot (context->doc);
3091: else
3092: {
3093: savedtype = context->type;
3094: context->type = HTML_EL_HTML;
3095: }
3096: }
3097:
1.50 cvs 3098: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3099: ok = TRUE;
1.50 cvs 3100: if (!ustrncasecmp (cssRule, TEXT("left"), 4))
1.18 cvs 3101: cssRule = SkipWord (cssRule);
1.50 cvs 3102: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
1.18 cvs 3103: cssRule = SkipWord (cssRule);
1.50 cvs 3104: else if (!ustrncasecmp (cssRule, TEXT("center"), 6))
1.18 cvs 3105: cssRule = SkipWord (cssRule);
1.50 cvs 3106: else if (!ustrncasecmp (cssRule, TEXT("top"), 3))
1.18 cvs 3107: cssRule = SkipWord (cssRule);
1.50 cvs 3108: else if (!ustrncasecmp (cssRule, TEXT("bottom"), 6))
1.18 cvs 3109: cssRule = SkipWord (cssRule);
1.50 cvs 3110: else if (TtaIsDigit (*cssRule))
1.18 cvs 3111: cssRule = SkipWord (cssRule);
3112: else
3113: ok = FALSE;
3114:
3115: if (ok)
3116: {
3117: /* force realsize for the background image */
3118: repeat.typed_data.value = STYLE_REALSIZE;
3119: repeat.typed_data.unit = STYLE_UNIT_REL;
3120: repeat.typed_data.real = FALSE;
3121: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
3122: }
3123:
3124: /* restore the refered element */
3125: if (moved && !element)
3126: context->type = savedtype;
3127: return (cssRule);
3128: }
3129:
3130: /*----------------------------------------------------------------------
1.59 cvs 3131: ParseCSSBackground: parse a CSS background attribute
1.18 cvs 3132: ----------------------------------------------------------------------*/
3133: #ifdef __STDC__
1.50 cvs 3134: static CHAR_T* ParseCSSBackground (Element element, PSchema tsch,
3135: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3136: #else
1.50 cvs 3137: static CHAR_T* ParseCSSBackground (element, tsch, context, cssRule, css, isHTML)
1.18 cvs 3138: Element element;
3139: PSchema tsch;
3140: PresentationContext context;
1.50 cvs 3141: CHAR_T* cssRule;
1.18 cvs 3142: CSSInfoPtr css;
3143: ThotBool isHTML;
3144: #endif
3145: {
1.50 cvs 3146: CHAR_T* ptr;
1.18 cvs 3147:
1.50 cvs 3148: cssRule = SkipWCBlanksAndComments (cssRule);
3149: while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))
1.18 cvs 3150: {
1.71 cvs 3151: /* perhaps a Background Image */
1.50 cvs 3152: if (!ustrncasecmp (cssRule, TEXT("url"), 3))
1.63 cvs 3153: cssRule = ParseCSSBackgroundImage (element, tsch, context, cssRule,
3154: css, isHTML);
1.18 cvs 3155: /* perhaps a Background Attachment */
1.50 cvs 3156: else if (!ustrncasecmp (cssRule, TEXT("scroll"), 6) ||
3157: !ustrncasecmp (cssRule, TEXT("fixed"), 5))
1.63 cvs 3158: cssRule = ParseCSSBackgroundAttachment (element, tsch, context,
3159: cssRule, css, isHTML);
1.18 cvs 3160: /* perhaps a Background Repeat */
1.50 cvs 3161: else if (!ustrncasecmp (cssRule, TEXT("no-repeat"), 9) ||
3162: !ustrncasecmp (cssRule, TEXT("repeat-y"), 8) ||
3163: !ustrncasecmp (cssRule, TEXT("repeat-x"), 8) ||
3164: !ustrncasecmp (cssRule, TEXT("repeat"), 6))
1.63 cvs 3165: cssRule = ParseCSSBackgroundRepeat (element, tsch, context, cssRule,
3166: css, isHTML);
1.18 cvs 3167: /* perhaps a Background Position */
1.50 cvs 3168: else if (!ustrncasecmp (cssRule, TEXT("left"), 4) ||
3169: !ustrncasecmp (cssRule, TEXT("right"), 5) ||
3170: !ustrncasecmp (cssRule, TEXT("center"), 6) ||
3171: !ustrncasecmp (cssRule, TEXT("top"), 3) ||
3172: !ustrncasecmp (cssRule, TEXT("bottom"), 6) ||
3173: TtaIsDigit (*cssRule))
1.63 cvs 3174: cssRule = ParseCSSBackgroundPosition (element, tsch, context,
3175: cssRule, css, isHTML);
1.18 cvs 3176: /* perhaps a Background Color */
3177: else
3178: {
3179: /* check if the rule has been found */
3180: ptr = cssRule;
1.63 cvs 3181: cssRule = ParseCSSBackgroundColor (element, tsch, context, cssRule,
3182: css, isHTML);
1.43 cvs 3183: if (ptr == cssRule)
1.18 cvs 3184: /* rule not found */
3185: cssRule = SkipProperty (cssRule);
3186: }
1.50 cvs 3187: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3188: }
3189: return (cssRule);
3190: }
3191:
1.59 cvs 3192: /*----------------------------------------------------------------------
1.60 cvs 3193: ParseCSSPageBreakBefore: parse a CSS page-break-before attribute
1.59 cvs 3194: ----------------------------------------------------------------------*/
3195: #ifdef __STDC__
3196: static CHAR_T* ParseCSSPageBreakBefore (Element element, PSchema tsch,
3197: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
3198: #else
3199: static CHAR_T* ParseCSSPageBreakBefore (element, tsch, context, cssRule, css, isHTML)
3200: Element element;
3201: PSchema tsch;
3202: PresentationContext context;
3203: CHAR_T* cssRule;
3204: CSSInfoPtr css;
3205: ThotBool isHTML;
3206: #endif
3207: {
3208: PresentationValue page;
3209:
3210: page.typed_data.unit = STYLE_UNIT_INVALID;
3211: page.typed_data.real = FALSE;
3212: cssRule = SkipWCBlanksAndComments (cssRule);
3213: if (!ustrncasecmp (cssRule, TEXT("auto"), 4))
3214: {
3215: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3216: page.typed_data.value = STYLE_AUTO;
3217: }
3218: else if (!ustrncasecmp (cssRule, TEXT("always"), 6))
3219: {
3220: page.typed_data.unit = STYLE_UNIT_REL;
3221: page.typed_data.value = STYLE_ALWAYS;
3222: }
3223: else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))
3224: {
3225: page.typed_data.unit = STYLE_UNIT_REL;
3226: page.typed_data.value = STYLE_AVOID;
3227: }
3228: else if (!ustrncasecmp (cssRule, TEXT("left"), 4))
3229: {
3230: page.typed_data.unit = STYLE_UNIT_REL;
3231: page.typed_data.value = STYLE_PAGELEFT;
3232: }
3233: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
3234: {
3235: page.typed_data.unit = STYLE_UNIT_REL;
3236: page.typed_data.value = STYLE_PAGERIGHT;
3237: }
3238: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))
3239: {
3240: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3241: page.typed_data.value = STYLE_INHERIT;
3242: }
3243: cssRule = SkipWord (cssRule);
3244: /* install the new presentation */
3245: if (page.typed_data.unit == STYLE_UNIT_REL &&
3246: page.typed_data.value == STYLE_ALWAYS)
3247: TtaSetStylePresentation (PRPageBefore, element, tsch, context, page);
3248: return (cssRule);
3249: }
3250:
3251: /*----------------------------------------------------------------------
1.60 cvs 3252: ParseCSSPageBreakAfter: parse a CSS page-break-after attribute
1.59 cvs 3253: ----------------------------------------------------------------------*/
3254: #ifdef __STDC__
3255: static CHAR_T* ParseCSSPageBreakAfter (Element element, PSchema tsch,
3256: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
3257: #else
3258: static CHAR_T* ParseCSSPageBreakAfter (element, tsch, context, cssRule, css, isHTML)
3259: Element element;
3260: PSchema tsch;
3261: PresentationContext context;
3262: CHAR_T* cssRule;
3263: CSSInfoPtr css;
3264: ThotBool isHTML;
3265: #endif
3266: {
3267: PresentationValue page;
3268:
3269: page.typed_data.unit = STYLE_UNIT_INVALID;
3270: page.typed_data.real = FALSE;
3271: cssRule = SkipWCBlanksAndComments (cssRule);
3272: if (!ustrncasecmp (cssRule, TEXT("auto"), 4))
3273: {
3274: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3275: page.typed_data.value = STYLE_AUTO;
3276: }
3277: else if (!ustrncasecmp (cssRule, TEXT("always"), 6))
3278: {
3279: page.typed_data.unit = STYLE_UNIT_REL;
3280: page.typed_data.value = STYLE_ALWAYS;
3281: }
3282: else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))
3283: {
3284: page.typed_data.unit = STYLE_UNIT_REL;
3285: page.typed_data.value = STYLE_AVOID;
3286: }
3287: else if (!ustrncasecmp (cssRule, TEXT("left"), 4))
3288: {
3289: page.typed_data.unit = STYLE_UNIT_REL;
3290: page.typed_data.value = STYLE_PAGELEFT;
3291: }
3292: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
3293: {
3294: page.typed_data.unit = STYLE_UNIT_REL;
3295: page.typed_data.value = STYLE_PAGERIGHT;
3296: }
3297: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))
3298: {
3299: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3300: page.typed_data.value = STYLE_INHERIT;
3301: }
3302: cssRule = SkipWord (cssRule);
3303: /* install the new presentation */
3304: /*if (page.typed_data.unit == STYLE_UNIT_REL)
3305: TtaSetStylePresentation (PRPageAfter, element, tsch, context, page);*/
3306: return (cssRule);
3307: }
3308:
3309: /*----------------------------------------------------------------------
1.60 cvs 3310: ParseCSSPageBreakInside: parse a CSS page-break-inside attribute
1.59 cvs 3311: ----------------------------------------------------------------------*/
3312: #ifdef __STDC__
3313: static CHAR_T* ParseCSSPageBreakInside (Element element, PSchema tsch,
3314: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
3315: #else
3316: static CHAR_T* ParseCSSPageBreakInside (element, tsch, context, cssRule, css, isHTML)
3317: Element element;
3318: PSchema tsch;
3319: PresentationContext context;
3320: CHAR_T* cssRule;
3321: CSSInfoPtr css;
3322: ThotBool isHTML;
3323: #endif
3324: {
3325: PresentationValue page;
3326:
3327: page.typed_data.unit = STYLE_UNIT_INVALID;
3328: page.typed_data.real = FALSE;
3329: cssRule = SkipWCBlanksAndComments (cssRule);
3330: if (!ustrncasecmp (cssRule, TEXT("auto"), 4))
3331: {
3332: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3333: page.typed_data.value = STYLE_AUTO;
3334: }
3335: else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))
3336: {
3337: page.typed_data.unit = STYLE_UNIT_REL;
3338: page.typed_data.value = STYLE_AVOID;
3339: }
3340: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))
3341: {
3342: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3343: page.typed_data.value = STYLE_INHERIT;
3344: }
3345: cssRule = SkipWord (cssRule);
3346: /* install the new presentation */
3347: if (page.typed_data.unit == STYLE_UNIT_REL &&
3348: page.typed_data.value == STYLE_AVOID)
3349: TtaSetStylePresentation (PRPageInside, element, tsch, context, page);
3350: return (cssRule);
3351: }
1.18 cvs 3352:
3353:
1.60 cvs 3354: /*----------------------------------------------------------------------
1.63 cvs 3355: ParseSVGStrokeWidth: parse a SVG stroke-width property value.
1.60 cvs 3356: ----------------------------------------------------------------------*/
3357: #ifdef __STDC__
1.63 cvs 3358: static CHAR_T* ParseSVGStrokeWidth (Element element, PSchema tsch,
1.60 cvs 3359: PresentationContext context, CHAR_T* cssRule,
3360: CSSInfoPtr css, ThotBool isHTML)
3361: #else
1.63 cvs 3362: static CHAR_T* ParseSVGStrokeWidth (element, tsch, context, cssRule, css,
1.60 cvs 3363: isHTML)
3364: Element element;
3365: PSchema tsch;
3366: PresentationContext context;
3367: CHAR_T* cssRule;
3368: CSSInfoPtr css;
3369: ThotBool isHTML;
3370: #endif
3371: {
3372: PresentationValue width;
3373:
3374: cssRule = SkipWCBlanksAndComments (cssRule);
3375: width.typed_data.value = 0;
3376: width.typed_data.unit = STYLE_UNIT_INVALID;
3377: width.typed_data.real = FALSE;
3378: if (TtaIsDigit (*cssRule))
3379: cssRule = ParseCSSUnit (cssRule, &width);
3380: if (width.typed_data.unit != STYLE_UNIT_INVALID)
3381: {
3382: TtaSetStylePresentation (PRLineWeight, element, tsch, context, width);
3383: width.typed_data.value = 1;
3384: width.typed_data.unit = STYLE_UNIT_REL;
3385: }
3386: return (cssRule);
3387: }
3388:
1.18 cvs 3389: /************************************************************************
3390: * *
3391: * FUNCTIONS STYLE DECLARATIONS *
3392: * *
3393: ************************************************************************/
3394: /*
1.59 cvs 3395: * NOTE: Long attribute name MUST be placed before shortened ones !
1.18 cvs 3396: * e.g. "FONT-SIZE" must be placed before "FONT"
3397: */
3398: static CSSProperty CSSProperties[] =
3399: {
1.50 cvs 3400: {TEXT("font-family"), ParseCSSFontFamily},
3401: {TEXT("font-style"), ParseCSSFontStyle},
3402: {TEXT("font-variant"), ParseCSSFontVariant},
3403: {TEXT("font-weight"), ParseCSSFontWeight},
3404: {TEXT("font-size"), ParseCSSFontSize},
3405: {TEXT("font"), ParseCSSFont},
3406:
3407: {TEXT("color"), ParseCSSForeground},
3408: {TEXT("background-color"), ParseCSSBackgroundColor},
3409: {TEXT("background-image"), ParseCSSBackgroundImage},
3410: {TEXT("background-repeat"), ParseCSSBackgroundRepeat},
3411: {TEXT("background-attachment"), ParseCSSBackgroundAttachment},
3412: {TEXT("background-position"), ParseCSSBackgroundPosition},
3413: {TEXT("background"), ParseCSSBackground},
3414:
3415: {TEXT("word-spacing"), ParseCSSWordSpacing},
3416: {TEXT("letter-spacing"), ParseCSSLetterSpacing},
3417: {TEXT("text-decoration"), ParseCSSTextDecoration},
3418: {TEXT("vertical-align"), ParseCSSVerticalAlign},
3419: {TEXT("text-transform"), ParseCSSTextTransform},
3420: {TEXT("text-align"), ParseCSSTextAlign},
3421: {TEXT("text-indent"), ParseCSSTextIndent},
3422: {TEXT("line-height"), ParseCSSLineSpacing},
3423:
3424: {TEXT("margin-top"), ParseCSSMarginTop},
3425: {TEXT("margin-right"), ParseCSSMarginRight},
3426: {TEXT("margin-bottom"), ParseCSSMarginBottom},
3427: {TEXT("margin-left"), ParseCSSMarginLeft},
3428: {TEXT("margin"), ParseCSSMargin},
3429:
3430: {TEXT("padding-top"), ParseCSSPaddingTop},
3431: {TEXT("padding-right"), ParseCSSPaddingRight},
3432: {TEXT("padding-bottom"), ParseCSSPaddingBottom},
3433: {TEXT("padding-left"), ParseCSSPaddingLeft},
3434: {TEXT("padding"), ParseCSSPadding},
3435:
3436: {TEXT("border-top-width"), ParseCSSBorderTopWidth},
3437: {TEXT("border-right-width"), ParseCSSBorderRightWidth},
3438: {TEXT("border-bottom-width"), ParseCSSBorderBottomWidth},
3439: {TEXT("border-left-width"), ParseCSSBorderLeftWidth},
3440: {TEXT("border-width"), ParseCSSBorderWidth},
3441: {TEXT("border-top-color"), ParseCSSBorderColorTop},
3442: {TEXT("border-right-color"), ParseCSSBorderColorRight},
3443: {TEXT("border-bottom-color"), ParseCSSBorderColorBottom},
3444: {TEXT("border-left-color"), ParseCSSBorderColorLeft},
3445: {TEXT("border-color"), ParseCSSBorderColor},
3446: {TEXT("border-top-style"), ParseCSSBorderStyleTop},
3447: {TEXT("border-right-style"), ParseCSSBorderStyleRight},
3448: {TEXT("border-bottom-style"), ParseCSSBorderStyleBottom},
3449: {TEXT("border-left-style"), ParseCSSBorderStyleLeft},
3450: {TEXT("border-style"), ParseCSSBorderStyle},
3451: {TEXT("border-top"), ParseCSSBorderTop},
3452: {TEXT("border-right"), ParseCSSBorderRight},
3453: {TEXT("border-bottom"), ParseCSSBorderBottom},
3454: {TEXT("border-left"), ParseCSSBorderLeft},
3455: {TEXT("border"), ParseCSSBorder},
3456:
3457: {TEXT("width"), ParseCSSWidth},
3458: {TEXT("height"), ParseCSSHeight},
3459: {TEXT("float"), ParseCSSFloat},
3460: {TEXT("clear"), ParseCSSClear},
3461:
3462: {TEXT("display"), ParseCSSDisplay},
3463: {TEXT("white-space"), ParseCSSWhiteSpace},
3464:
3465: {TEXT("list-style-type"), ParseCSSListStyleType},
3466: {TEXT("list-style-image"), ParseCSSListStyleImage},
3467: {TEXT("list-style-position"), ParseCSSListStylePosition},
1.59 cvs 3468: {TEXT("list-style"), ParseCSSListStyle},
3469:
3470: {TEXT("page-break-before"), ParseCSSPageBreakBefore},
3471: {TEXT("page-break-after"), ParseCSSPageBreakAfter},
1.60 cvs 3472: {TEXT("page-break-inside"), ParseCSSPageBreakInside},
3473:
3474: /* SVG extensions */
1.63 cvs 3475: {TEXT("stroke-width"), ParseSVGStrokeWidth},
1.65 cvs 3476: {TEXT("stroke"), ParseSVGStroke},
1.63 cvs 3477: {TEXT("fill"), ParseSVGFill}
1.18 cvs 3478: };
3479: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
3480:
3481: /*----------------------------------------------------------------------
1.59 cvs 3482: ParseCSSRule: parse a CSS Style string
1.18 cvs 3483: we expect the input string describing the style to be of the
1.59 cvs 3484: form: PRORPERTY: DESCRIPTION [ ; PROPERTY: DESCRIPTION ] *
1.18 cvs 3485: but tolerate incorrect or incomplete input
3486: ----------------------------------------------------------------------*/
3487: #ifdef __STDC__
1.50 cvs 3488: static void ParseCSSRule (Element element, PSchema tsch, PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3489: #else
3490: static void ParseCSSRule (element, tsch, context, cssRule, css, isHTML)
3491: Element element;
3492: PSchema tsch;
3493: PresentationContext context;
1.50 cvs 3494: CHAR_T* cssRule;
1.18 cvs 3495: CSSInfoPtr css;
3496: ThotBool isHTML;
3497: #endif
3498: {
1.34 cvs 3499: DisplayMode dispMode;
1.50 cvs 3500: CHAR_T* p = NULL;
1.18 cvs 3501: int lg;
1.34 cvs 3502: unsigned int i;
1.61 cvs 3503: ElementType elType;
3504: ThotBool found, done;
1.18 cvs 3505:
1.34 cvs 3506: /* avoid too many redisplay */
3507: dispMode = TtaGetDisplayMode (context->doc);
3508: if (dispMode == DisplayImmediately)
3509: TtaSetDisplayMode (context->doc, DeferredDisplay);
3510:
1.50 cvs 3511: while (*cssRule != WC_EOS)
1.18 cvs 3512: {
1.50 cvs 3513: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3514:
3515: found = FALSE;
3516: /* look for the type of property */
3517: for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
3518: {
1.50 cvs 3519: lg = ustrlen (CSSProperties[i].name);
3520: if (!ustrncasecmp (cssRule, CSSProperties[i].name, lg))
1.18 cvs 3521: {
3522: cssRule += lg;
3523: found = TRUE;
3524: i--;
3525: }
3526: }
3527:
3528: if (i == NB_CSSSTYLEATTRIBUTE)
3529: cssRule = SkipProperty (cssRule);
3530: else
3531: {
3532: /* update index and skip the ":" indicator if present */
1.50 cvs 3533: cssRule = SkipWCBlanksAndComments (cssRule);
3534: if (*cssRule == TEXT(':'))
1.18 cvs 3535: {
3536: cssRule++;
1.50 cvs 3537: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3538: }
1.61 cvs 3539: /* try to parse the value associated with this property */
1.18 cvs 3540: if (CSSProperties[i].parsing_function != NULL)
3541: {
1.61 cvs 3542: done = FALSE;
3543: /* if it's the "fill" SVG property applied to a SVG text element,
3544: generate a Foreground P rule */
3545: if (!ustrcmp (CSSProperties[i].name, TEXT("fill")))
3546: {
3547: elType = TtaGetElementType (element);
1.62 cvs 3548: if (elType.ElTypeNum == GraphML_EL_text_ ||
3549: elType.ElTypeNum == GraphML_EL_tspan)
1.61 cvs 3550: if (!ustrcmp (TtaGetSSchemaName (elType.ElSSchema),
3551: TEXT("GraphML")))
3552: {
3553: p = ParseCSSForeground (element, tsch, context, cssRule,
3554: css, isHTML);
3555: done = TRUE;
3556: }
3557: }
3558: if (!done)
3559: p = CSSProperties[i].parsing_function (element, tsch, context,
3560: cssRule, css, isHTML);
1.34 cvs 3561: /* update index and skip the ";" separator if present */
3562: cssRule = p;
1.18 cvs 3563: }
3564: }
3565: /* next property */
1.50 cvs 3566: cssRule = SkipWCBlanksAndComments (cssRule);
3567: if (*cssRule == TEXT(',') || *cssRule == TEXT(';'))
1.18 cvs 3568: {
3569: cssRule++;
1.50 cvs 3570: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3571: }
3572: }
1.34 cvs 3573:
3574: /* restore the display mode */
3575: if (dispMode == DisplayImmediately)
3576: TtaSetDisplayMode (context->doc, dispMode);
1.18 cvs 3577: }
1.1 cvs 3578:
3579:
3580: /*----------------------------------------------------------------------
1.59 cvs 3581: PToCss: translate a PresentationSetting to the
1.18 cvs 3582: equivalent CSS string, and add it to the buffer given as the
1.67 cvs 3583: argument. It is used when extracting the CSS string from actual
3584: presentation.
3585: el is the element for which the style rule is generated
1.18 cvs 3586:
3587: All the possible values returned by the presentation drivers are
3588: described in thotlib/include/presentation.h
3589: -----------------------------------------------------------------------*/
1.1 cvs 3590: #ifdef __STDC__
1.67 cvs 3591: void PToCss (PresentationSetting settings, CHAR_T* buffer, int len, Element el)
1.1 cvs 3592: #else
1.67 cvs 3593: void PToCss (settings, buffer, len, el)
1.18 cvs 3594: PresentationSetting settings;
1.67 cvs 3595: CHAR_T* param;
3596: int len;
3597: Element el;
1.1 cvs 3598: #endif
3599: {
1.18 cvs 3600: float fval = 0;
3601: unsigned short red, green, blue;
3602: int add_unit = 0;
3603: unsigned int unit, i;
3604: ThotBool real = FALSE;
3605:
1.50 cvs 3606: buffer[0] = WC_EOS;
1.18 cvs 3607: if (len < 40)
3608: return;
3609:
3610: unit = settings->value.typed_data.unit;
3611: if (settings->value.typed_data.real)
3612: {
3613: real = TRUE;
3614: fval = (float) settings->value.typed_data.value;
3615: fval /= 1000;
3616: }
1.1 cvs 3617:
1.18 cvs 3618: switch (settings->type)
1.1 cvs 3619: {
1.18 cvs 3620: case PRVisibility:
3621: break;
3622: case PRFont:
3623: switch (settings->value.typed_data.value)
3624: {
3625: case STYLE_FONT_HELVETICA:
1.50 cvs 3626: ustrcpy (buffer, TEXT("font-family: helvetica"));
1.18 cvs 3627: break;
3628: case STYLE_FONT_TIMES:
1.50 cvs 3629: ustrcpy (buffer, TEXT("font-family: times"));
1.18 cvs 3630: break;
3631: case STYLE_FONT_COURIER:
1.50 cvs 3632: ustrcpy (buffer, TEXT("font-family: courier"));
1.18 cvs 3633: break;
3634: }
3635: break;
3636: case PRStyle:
3637: switch (settings->value.typed_data.value)
3638: {
3639: case STYLE_FONT_ROMAN:
1.50 cvs 3640: ustrcpy (buffer, TEXT("font-style: normal"));
1.18 cvs 3641: break;
3642: case STYLE_FONT_ITALICS:
1.50 cvs 3643: ustrcpy (buffer, TEXT("font-style: italic"));
1.18 cvs 3644: break;
3645: case STYLE_FONT_OBLIQUE:
1.50 cvs 3646: ustrcpy (buffer, TEXT("font-style: oblique"));
1.18 cvs 3647: break;
1.20 cvs 3648: }
3649: break;
3650: case PRWeight:
3651: switch (settings->value.typed_data.value)
3652: {
3653: case STYLE_WEIGHT_BOLD:
1.50 cvs 3654: ustrcpy (buffer, TEXT("font-weight: bold"));
1.20 cvs 3655: break;
3656: case STYLE_WEIGHT_NORMAL:
1.50 cvs 3657: ustrcpy (buffer, TEXT("font-weight: normal"));
1.18 cvs 3658: break;
3659: }
3660: break;
3661: case PRSize:
3662: if (unit == STYLE_UNIT_REL)
3663: {
3664: if (real)
3665: {
1.50 cvs 3666: usprintf (buffer, TEXT("font-size: %g"), fval);
1.18 cvs 3667: add_unit = 1;
3668: }
3669: else
3670: switch (settings->value.typed_data.value)
3671: {
3672: case 1:
1.50 cvs 3673: ustrcpy (buffer, TEXT("font-size: xx-small"));
1.18 cvs 3674: break;
3675: case 2:
1.50 cvs 3676: ustrcpy (buffer, TEXT("font-size: x-small"));
1.18 cvs 3677: break;
3678: case 3:
1.50 cvs 3679: ustrcpy (buffer, TEXT("font-size: small"));
1.18 cvs 3680: break;
3681: case 4:
1.50 cvs 3682: ustrcpy (buffer, TEXT("font-size: medium"));
1.18 cvs 3683: break;
3684: case 5:
1.50 cvs 3685: ustrcpy (buffer, TEXT("font-size: large"));
1.18 cvs 3686: break;
3687: case 6:
1.50 cvs 3688: ustrcpy (buffer, TEXT("font-size: x-large"));
1.18 cvs 3689: break;
3690: case 7:
3691: case 8:
3692: case 9:
3693: case 10:
3694: case 11:
3695: case 12:
1.50 cvs 3696: ustrcpy (buffer, TEXT("font-size: xx-large"));
1.18 cvs 3697: break;
3698: }
3699: }
3700: else
3701: {
3702: if (real)
1.50 cvs 3703: usprintf (buffer, TEXT("font-size: %g"), fval);
1.18 cvs 3704: else
1.67 cvs 3705: usprintf (buffer, TEXT("font-size: %d"),
3706: settings->value.typed_data.value);
1.18 cvs 3707: add_unit = 1;
3708: }
3709: break;
3710: case PRUnderline:
3711: switch (settings->value.typed_data.value)
3712: {
3713: case STYLE_UNDERLINE:
1.50 cvs 3714: ustrcpy (buffer, TEXT("text-decoration: underline"));
1.18 cvs 3715: break;
3716: case STYLE_OVERLINE:
1.50 cvs 3717: ustrcpy (buffer, TEXT("text-decoration: overline"));
1.18 cvs 3718: break;
3719: case STYLE_CROSSOUT:
1.50 cvs 3720: ustrcpy (buffer, TEXT("text-decoration: line-through"));
1.18 cvs 3721: break;
3722: }
3723: break;
3724: case PRIndent:
3725: if (real)
1.50 cvs 3726: usprintf (buffer, TEXT("text-indent: %g"), fval);
1.18 cvs 3727: else
1.67 cvs 3728: usprintf (buffer, TEXT("text-indent: %d"),
3729: settings->value.typed_data.value);
1.18 cvs 3730: add_unit = 1;
3731: break;
3732: case PRLineSpacing:
3733: if (real)
1.50 cvs 3734: usprintf (buffer, TEXT("line-height: %g"), fval);
1.1 cvs 3735: else
1.67 cvs 3736: usprintf (buffer, TEXT("line-height: %d"),
3737: settings->value.typed_data.value);
1.18 cvs 3738: add_unit = 1;
3739: break;
3740: case PRJustify:
3741: if (settings->value.typed_data.value == STYLE_JUSTIFIED)
1.50 cvs 3742: usprintf (buffer, TEXT("text-align: justify"));
1.18 cvs 3743: break;
3744: case PRAdjust:
3745: switch (settings->value.typed_data.value)
1.1 cvs 3746: {
1.18 cvs 3747: case STYLE_ADJUSTLEFT:
1.50 cvs 3748: ustrcpy (buffer, TEXT("text-align: left"));
1.18 cvs 3749: break;
3750: case STYLE_ADJUSTRIGHT:
1.50 cvs 3751: ustrcpy (buffer, TEXT("text-align: right"));
1.18 cvs 3752: break;
3753: case STYLE_ADJUSTCENTERED:
1.50 cvs 3754: ustrcpy (buffer, TEXT("text-align: center"));
1.18 cvs 3755: break;
3756: case STYLE_ADJUSTLEFTWITHDOTS:
1.50 cvs 3757: ustrcpy (buffer, TEXT("text-align: left"));
1.18 cvs 3758: break;
1.1 cvs 3759: }
1.18 cvs 3760: break;
3761: case PRHyphenate:
3762: break;
3763: case PRFillPattern:
3764: break;
3765: case PRBackground:
3766: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.67 cvs 3767: if (ustrcmp(TtaGetSSchemaName (TtaGetElementType(el).ElSSchema),
3768: TEXT("GraphML")) == 0)
3769: usprintf (buffer, TEXT("fill: #%02X%02X%02X"), red, green, blue);
3770: else
3771: usprintf (buffer, TEXT("background-color: #%02X%02X%02X"), red, green,
3772: blue);
1.18 cvs 3773: break;
3774: case PRForeground:
3775: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.67 cvs 3776: if (ustrcmp(TtaGetSSchemaName (TtaGetElementType(el).ElSSchema),
3777: TEXT("GraphML")) == 0)
3778: usprintf (buffer, TEXT("stroke: #%02X%02X%02X"), red, green, blue);
3779: else
3780: usprintf (buffer, TEXT("color: #%02X%02X%02X"), red, green, blue);
3781: break;
3782: case PRLineWeight:
1.69 cvs 3783: if (!ustrcmp(TtaGetSSchemaName (TtaGetElementType(el).ElSSchema), TEXT("GraphML")))
3784: {
3785: if (real)
3786: usprintf (buffer, TEXT("stroke-width: %g"), fval);
3787: else
3788: usprintf (buffer, TEXT("stroke-width: %d"),
3789: settings->value.typed_data.value);
3790: }
1.67 cvs 3791: add_unit = 1;
1.18 cvs 3792: break;
1.67 cvs 3793:
1.40 cvs 3794: case PRMarginTop:
1.18 cvs 3795: if (real)
1.50 cvs 3796: usprintf (buffer, TEXT("marging-top: %g"), fval);
1.18 cvs 3797: else
1.67 cvs 3798: usprintf (buffer, TEXT("marging-top: %d"),
3799: settings->value.typed_data.value);
1.18 cvs 3800: add_unit = 1;
3801: break;
1.40 cvs 3802: case PRMarginLeft:
1.18 cvs 3803: if (real)
1.50 cvs 3804: usprintf (buffer, TEXT("margin-left: %g"), fval);
1.18 cvs 3805: else
1.67 cvs 3806: usprintf (buffer, TEXT("margin-left: %d"),
3807: settings->value.typed_data.value);
1.18 cvs 3808: add_unit = 1;
3809: break;
3810: case PRHeight:
3811: if (real)
1.50 cvs 3812: usprintf (buffer, TEXT("height: %g"), fval);
1.18 cvs 3813: else
1.50 cvs 3814: usprintf (buffer, TEXT("height: %d"), settings->value.typed_data.value);
1.18 cvs 3815: add_unit = 1;
3816: break;
3817: case PRWidth:
3818: if (real)
1.50 cvs 3819: usprintf (buffer, TEXT("width: %g"), fval);
1.1 cvs 3820: else
1.50 cvs 3821: usprintf (buffer, TEXT("width: %d"), settings->value.typed_data.value);
1.18 cvs 3822: add_unit = 1;
3823: break;
3824: case PRLine:
3825: if (settings->value.typed_data.value == STYLE_INLINE)
1.50 cvs 3826: ustrcpy (buffer, TEXT("display: inline"));
1.18 cvs 3827: else if (settings->value.typed_data.value == STYLE_NOTINLINE)
1.50 cvs 3828: ustrcpy (buffer, TEXT("display: block"));
1.18 cvs 3829: break;
3830: case PRBackgroundPicture:
3831: if (settings->value.pointer != NULL)
1.67 cvs 3832: usprintf (buffer, TEXT("background-image: url(%s)"),
3833: (char*)(settings->value.pointer));
1.1 cvs 3834: else
1.50 cvs 3835: usprintf (buffer, TEXT("background-image: none"));
1.18 cvs 3836: break;
3837: case PRPictureMode:
3838: switch (settings->value.typed_data.value)
1.1 cvs 3839: {
1.18 cvs 3840: case STYLE_REALSIZE:
1.50 cvs 3841: usprintf (buffer, TEXT("background-repeat: no-repeat"));
1.18 cvs 3842: break;
3843: case STYLE_REPEAT:
1.50 cvs 3844: usprintf (buffer, TEXT("background-repeat: repeat"));
1.18 cvs 3845: break;
3846: case STYLE_VREPEAT:
1.50 cvs 3847: usprintf (buffer, TEXT("background-repeat: repeat-y"));
1.18 cvs 3848: break;
3849: case STYLE_HREPEAT:
1.50 cvs 3850: usprintf (buffer, TEXT("background-repeat: repeat-x"));
1.18 cvs 3851: break;
1.1 cvs 3852: }
1.18 cvs 3853: break;
3854: default:
3855: break;
1.1 cvs 3856: }
3857:
1.18 cvs 3858: if (add_unit)
1.1 cvs 3859: {
1.18 cvs 3860: /* add the unit string to the CSS string */
3861: for (i = 0; i < NB_UNITS; i++)
1.1 cvs 3862: {
1.18 cvs 3863: if (CSSUnitNames[i].unit == unit)
1.1 cvs 3864: {
1.50 cvs 3865: ustrcat (buffer, CSSUnitNames[i].sign);
1.18 cvs 3866: break;
1.1 cvs 3867: }
3868: }
3869: }
3870: }
3871:
3872: /*----------------------------------------------------------------------
1.59 cvs 3873: ParseHTMLSpecificStyle: parse and apply a CSS Style string.
1.18 cvs 3874: This function must be called when a specific style is applied to an
3875: element.
1.68 cvs 3876: The parameter isCSS is 1 when the specific presentation should be
3877: translated into a CSS rule, 0 if it should be translated into a
3878: presentation attribute.
1.1 cvs 3879: ----------------------------------------------------------------------*/
3880: #ifdef __STDC__
1.68 cvs 3881: void ParseHTMLSpecificStyle (Element el, CHAR_T* cssRule, Document doc, int isCSS, ThotBool destroy)
1.1 cvs 3882: #else
1.68 cvs 3883: void ParseHTMLSpecificStyle (el, cssRule, doc, isCSS, destroy)
1.1 cvs 3884: Element elem;
1.50 cvs 3885: CHAR_T* cssRule;
1.1 cvs 3886: Document doc;
1.68 cvs 3887: int isCSS;
1.14 cvs 3888: ThotBool destroy;
1.1 cvs 3889: #endif
3890: {
3891: PresentationContext context;
3892: ElementType elType;
1.14 cvs 3893: ThotBool isHTML;
1.1 cvs 3894:
3895: /* A rule applying to BODY is really meant to address HTML */
3896: elType = TtaGetElementType (el);
1.49 cvs 3897: isHTML = (ustrcmp (TtaGetSSchemaName (elType.ElSSchema), TEXT("HTML")) == 0);
1.1 cvs 3898: /* create the context of the Specific presentation driver */
3899: context = TtaGetSpecificStyleContext (doc);
3900: if (context == NULL)
3901: return;
3902: context->type = elType.ElTypeNum;
1.68 cvs 3903: context->cssLevel = isCSS;
1.1 cvs 3904: context->destroy = destroy;
3905: /* Call the parser */
3906: ParseCSSRule (el, NULL, (PresentationContext) context, cssRule, NULL, isHTML);
3907: /* free the context */
3908: TtaFreeMemory(context);
3909: }
3910:
1.68 cvs 3911:
1.1 cvs 3912: /*----------------------------------------------------------------------
1.59 cvs 3913: ParseGenericSelector: Create a generic context for a given
1.1 cvs 3914: selector string. If the selector is made of multiple comma-
3915: separated selector items, it parses them one at a time and
3916: return the end of the selector string to be handled or NULL
3917: ----------------------------------------------------------------------*/
3918: #ifdef __STDC__
1.50 cvs 3919: static CHAR_T* ParseGenericSelector (CHAR_T* selector, CHAR_T* cssRule,
1.1 cvs 3920: GenericContext ctxt, Document doc, CSSInfoPtr css)
3921: #else
1.50 cvs 3922: static CHAR_T* ParseGenericSelector (selector, cssRule, ctxt, doc, css)
3923: CHAR_T* selector;
3924: CHAR_T* cssRule;
1.1 cvs 3925: GenericContext ctxt;
3926: Document doc;
3927: CSSInfoPtr css;
3928: #endif
3929: {
3930: ElementType elType;
3931: PSchema tsch;
1.25 cvs 3932: AttributeType attrType;
1.49 cvs 3933: CHAR_T sel[MAX_ANCESTORS * 50];
3934: CHAR_T *deb, *cur;
3935: CHAR_T* structName;
3936: CHAR_T* names[MAX_ANCESTORS];
3937: CHAR_T* ids[MAX_ANCESTORS];
3938: CHAR_T* classes[MAX_ANCESTORS];
3939: CHAR_T* pseudoclasses[MAX_ANCESTORS];
3940: CHAR_T* attrs[MAX_ANCESTORS];
3941: CHAR_T* attrvals[MAX_ANCESTORS];
1.35 cvs 3942: int i, j, k, max, maxAttr;
1.25 cvs 3943: ThotBool isHTML;
1.1 cvs 3944:
1.50 cvs 3945: sel[0] = WC_EOS;
1.1 cvs 3946: for (i = 0; i < MAX_ANCESTORS; i++)
3947: {
1.25 cvs 3948: names[i] = NULL;
3949: ids[i] = NULL;
3950: classes[i] = NULL;
3951: pseudoclasses[i] = NULL;
3952: attrs[i] = NULL;
3953: attrvals[i] = NULL;
3954:
3955: ctxt->name[i] = 0;
3956: ctxt->names_nb[i] = 0;
3957: ctxt->attrType[i] = 0;
3958: ctxt->attrText[i] = NULL;
1.1 cvs 3959: }
1.25 cvs 3960: ctxt->box = 0;
3961: ctxt->type = 0;
1.68 cvs 3962: /* the priority level of the rule depends on the selector */
3963: ctxt->cssLevel = 0;
1.25 cvs 3964:
1.50 cvs 3965: selector = SkipWCBlanksAndComments (selector);
1.27 cvs 3966: cur = &sel[0];
1.25 cvs 3967: max = 0; /* number of loops */
1.1 cvs 3968: while (1)
3969: {
1.27 cvs 3970: deb = cur;
1.25 cvs 3971: /* copy an item of the selector into sel[] */
1.1 cvs 3972: /* put one word in the sel buffer */
1.50 cvs 3973: while (*selector != WC_EOS && *selector != TEXT(',') &&
3974: *selector != TEXT('.') && *selector != TEXT(':') &&
3975: *selector != TEXT('#') && !TtaIsWCBlank (selector))
3976: *cur++ = *selector++;
3977: *cur++ = WC_EOS; /* close the first string in sel[] */
3978: if (deb[0] != WC_EOS)
1.27 cvs 3979: names[0] = deb;
1.25 cvs 3980: else
1.27 cvs 3981: names[0] = NULL;
3982: classes[0] = NULL;
3983: pseudoclasses[0] = NULL;
3984: ids[0] = NULL;
3985: attrs[0] = NULL;
3986: attrvals[0] = NULL;
1.25 cvs 3987:
1.27 cvs 3988: /* now names[0] points to the beginning of the parsed item
1.25 cvs 3989: and cur to the next chain to be parsed */
1.50 cvs 3990: if (*selector == TEXT(':') || *selector == TEXT('.') || *selector == TEXT('#'))
1.25 cvs 3991: /* keep the element name which precedes the id or
3992: pseudo class or the class */
1.27 cvs 3993: deb = cur;
1.1 cvs 3994:
1.50 cvs 3995: if (*selector == TEXT('.'))
1.1 cvs 3996: {
1.25 cvs 3997: /* copy into sel[] the class */
1.27 cvs 3998: classes[0] = cur;
1.1 cvs 3999: selector++;
1.50 cvs 4000: while (*selector != WC_EOS && *selector != TEXT(',') &&
4001: *selector != TEXT('.') && *selector != TEXT(':') &&
4002: !TtaIsWCBlank (selector))
1.1 cvs 4003: *cur++ = *selector++;
1.50 cvs 4004: *cur++ = WC_EOS;
1.1 cvs 4005: }
1.50 cvs 4006: else if (*selector == TEXT(':'))
1.1 cvs 4007: {
1.25 cvs 4008: /* copy into sel[] the pseudoclass */
1.27 cvs 4009: pseudoclasses[0]= cur;
1.1 cvs 4010: selector++;
1.50 cvs 4011: while (*selector != WC_EOS && *selector != TEXT(',') &&
4012: *selector != TEXT('.') && *selector != TEXT(':') &&
4013: !TtaIsWCBlank (selector))
4014: *cur++ = *selector++;
4015: *cur++ = WC_EOS;
1.1 cvs 4016: }
1.50 cvs 4017: else if (*selector == TEXT('#'))
1.1 cvs 4018: {
1.25 cvs 4019: /* copy into sel[] the attribute */
1.27 cvs 4020: ids[0] = cur;
1.1 cvs 4021: selector++;
1.50 cvs 4022: while (*selector != WC_EOS && *selector != TEXT(',') &&
4023: *selector != TEXT('.') && *selector != TEXT(':') &&
4024: !TtaIsWCBlank (selector))
4025: *cur++ = *selector++;
4026: *cur++ = WC_EOS;
1.1 cvs 4027: }
1.50 cvs 4028: else if (*selector == TEXT('['))
1.1 cvs 4029: {
1.25 cvs 4030: /* copy into sel[] the attribute */
1.27 cvs 4031: attrs[0] = cur;
1.25 cvs 4032: selector++;
1.50 cvs 4033: while (*selector != WC_EOS && *selector != TEXT(']') && *selector != TEXT('='))
1.25 cvs 4034: *cur++ = *selector++;
1.50 cvs 4035: if (*cur == TEXT('='))
1.25 cvs 4036: {
4037: /* there is a value "xxxx" */
1.50 cvs 4038: *cur++ = WC_EOS;
4039: while (*selector != WC_EOS && *selector != TEXT(']') && *selector != TEXT('"'))
1.25 cvs 4040: selector++;
1.50 cvs 4041: if (*selector != WC_EOS)
1.25 cvs 4042: {
4043: /* we are now parsing the attribute value */
1.27 cvs 4044: attrvals[0] = cur;
1.25 cvs 4045: selector++;
1.50 cvs 4046: while (*selector != WC_EOS && *selector != TEXT('"'))
1.25 cvs 4047: *cur++ = *selector++;
1.50 cvs 4048: if (*selector != WC_EOS)
1.25 cvs 4049: selector++;
4050: }
4051: }
1.50 cvs 4052: *cur++ = WC_EOS;
1.1 cvs 4053: }
4054:
1.50 cvs 4055: selector = SkipWCBlanksAndComments (selector);
1.1 cvs 4056:
1.25 cvs 4057: /* is it a multi-level selector? */
1.50 cvs 4058: if (*selector == WC_EOS)
1.1 cvs 4059: /* end of the selector */
4060: break;
1.50 cvs 4061: else if (*selector == TEXT(','))
1.1 cvs 4062: {
4063: /* end of the current selector */
4064: selector++;
4065: break;
4066: }
1.25 cvs 4067: else
4068: {
4069: /* shifts the list to make room for the new name */
4070: max++; /* a new level in ancestor tables */
4071: if (max == MAX_ANCESTORS)
4072: /* abort the CSS parsing */
4073: return (selector);
4074: for (i = max; i > 0; i--)
4075: {
4076: names[i] = names[i - 1];
4077: ids[i] = ids[i - 1];
4078: classes[i] = classes[i - 1];
4079: attrs[i] = attrs[i - 1];
4080: attrvals[i] = attrvals[i - 1];
4081: pseudoclasses[i] = pseudoclasses[i - 1];
4082: }
4083: }
1.1 cvs 4084: }
4085:
4086: /* Now set up the context block */
1.25 cvs 4087: i = 0;
4088: k = 0;
4089: j = 0;
1.35 cvs 4090: maxAttr = 0;
1.25 cvs 4091: while (i <= max)
4092: {
4093: if (names[i])
4094: {
4095: /* get the new element type of this name */
4096: GIType (names[i], &elType, doc);
4097: if (i == 0)
4098: {
4099: /* Store the element type */
4100: ctxt->type = elType.ElTypeNum;
1.32 cvs 4101: ctxt->name[0] = elType.ElTypeNum;
4102: ctxt->names_nb[0] = 0;
1.25 cvs 4103: ctxt->schema = elType.ElSSchema;
1.27 cvs 4104: k++;
1.25 cvs 4105: }
4106: else if (elType.ElTypeNum != 0)
4107: {
4108: /* look at the current context to see if the type is already
4109: stored */
4110: j = 0;
1.32 cvs 4111: while (j < k && ctxt->name[j] != elType.ElTypeNum)
1.25 cvs 4112: j++;
4113: if (j == k)
4114: {
4115: /* add a new entry */
4116: k++;
4117: ctxt->name[j] = elType.ElTypeNum;
4118: if (j != 0)
4119: ctxt->names_nb[j] = 1;
4120: }
4121: else
4122: /* increment the number of ancestor levels */
4123: ctxt->names_nb[j]++;
4124: }
4125: else
4126: {
4127: /* add a new entry */
4128: j = k;
4129: k++;
4130: }
4131: }
1.1 cvs 4132: else
1.25 cvs 4133: {
4134: /* add a new entry */
4135: j = k;
4136: k++;
4137: }
4138:
1.35 cvs 4139: if (classes[i] || pseudoclasses[i] || ids[i] || attrs[i])
1.69 cvs 4140: {
4141: if (maxAttr > 0)
4142: /* Thot is not able to manage this kind of selector -> abort */
4143: return (selector);
4144: else
4145: maxAttr++;
4146: }
1.1 cvs 4147:
1.25 cvs 4148: /* store attributes information */
4149: if (classes[i])
4150: {
4151: ctxt->attrText[j] = classes[i];
4152: ctxt->attrType[j] = HTML_ATTR_Class;
4153: }
4154: else if (pseudoclasses[i])
4155: {
4156: ctxt->attrText[j] = pseudoclasses[i];
4157: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
4158: }
4159: else if (ids[i])
4160: {
4161: ctxt->attrText[j] = ids[i];
4162: ctxt->attrType[j] = HTML_ATTR_ID;
4163: }
4164: else if (attrs[i])
4165: {
4166: MapHTMLAttribute (attrs[i], &attrType, names[i], doc);
4167: ctxt->attrText[j] = attrvals[i];
4168: ctxt->attrType[j] = attrType.AttrTypeNum;
4169: }
4170: i++;
1.1 cvs 4171: }
4172:
1.25 cvs 4173: /* sort the list of ancestors by name order */
4174: max = k;
4175: i = 1;
4176: while (i < max)
1.28 cvs 4177: {
4178: for (k = i + 1; k < max; k++)
4179: if (ctxt->name[i] > ctxt->name[k])
4180: {
4181: j = ctxt->name[i];
4182: ctxt->name[i] = ctxt->name[k];
4183: ctxt->name[k] = j;
4184: j = ctxt->names_nb[i];
4185: ctxt->names_nb[i] = ctxt->names_nb[k];
4186: ctxt->names_nb[k] = j;
4187: j = ctxt->attrType[i];
4188: ctxt->attrType[i] = ctxt->attrType[k];
4189: ctxt->attrType[k] = j;
4190: cur = ctxt->attrText[i];
4191: ctxt->attrText[i] = ctxt->attrText[k];
4192: ctxt->attrText[k] = cur;
4193: }
4194: i++;
4195: }
1.25 cvs 4196:
4197: /* Get the schema name of the main element */
4198: if (ctxt->schema == NULL)
1.1 cvs 4199: ctxt->schema = TtaGetDocumentSSchema (doc);
1.49 cvs 4200: isHTML = (ustrcmp (TtaGetSSchemaName (ctxt->schema), TEXT("HTML")) == 0);
1.1 cvs 4201: tsch = GetPExtension (doc, ctxt->schema, css);
4202: structName = TtaGetSSchemaName (ctxt->schema);
4203: if (cssRule)
4204: ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
4205: return (selector);
4206: }
4207:
4208: /*----------------------------------------------------------------------
1.73 ! cvs 4209: ParseStyleDeclaration: parse a style declaration
! 4210: stored in the style element of a document
1.59 cvs 4211: We expect the style string to be of the form:
1.1 cvs 4212: [
4213: e.g: pinky, awful { color: pink, font-family: helvetica }
4214: ----------------------------------------------------------------------*/
4215: #ifdef __STDC__
1.50 cvs 4216: static void ParseStyleDeclaration (Element el, CHAR_T* cssRule, Document doc, CSSInfoPtr css, ThotBool destroy)
1.1 cvs 4217: #else
4218: static void ParseStyleDeclaration (el, cssRule, doc, css, destroy)
4219: Element el;
4220: STRING cssRule;
4221: Document doc;
4222: CSSInfoPtr css;
1.14 cvs 4223: ThotBool destroy;
1.1 cvs 4224: #endif
4225: {
1.50 cvs 4226: GenericContext ctxt;
4227: CHAR_T* decl_end;
4228: CHAR_T* sel_end;
4229: CHAR_T* selector;
4230: CHAR_T saved1;
4231: CHAR_T saved2;
1.1 cvs 4232:
4233: /* separate the selectors string */
1.50 cvs 4234: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 4235: decl_end = cssRule;
1.50 cvs 4236: while ((*decl_end != WC_EOS) && (*decl_end != TEXT('{')))
1.1 cvs 4237: decl_end++;
1.50 cvs 4238: if (*decl_end == WC_EOS)
1.1 cvs 4239: return;
4240: /* verify and clean the selector string */
4241: sel_end = decl_end - 1;
1.50 cvs 4242: while (*sel_end == WC_SPACE || *sel_end == WC_BSPACE ||
4243: *sel_end == WC_EOL || *sel_end == WC_CR)
1.1 cvs 4244: sel_end--;
4245: sel_end++;
4246: saved1 = *sel_end;
1.50 cvs 4247: *sel_end = WC_EOS;
1.1 cvs 4248: selector = cssRule;
4249:
4250: /* now, deal with the content ... */
4251: decl_end++;
4252: cssRule = decl_end;
1.50 cvs 4253: while (*decl_end != WC_EOS && *decl_end != TEXT('}'))
1.1 cvs 4254: decl_end++;
1.50 cvs 4255: if (*decl_end == WC_EOS)
1.1 cvs 4256: {
1.59 cvs 4257: fprintf (stderr, "Invalid STYLE declaration: %s\n", cssRule);
1.1 cvs 4258: return;
4259: }
4260: saved2 = *decl_end;
1.50 cvs 4261: *decl_end = WC_EOS;
1.1 cvs 4262:
4263: /*
4264: * parse the style attribute string and install the corresponding
4265: * presentation attributes on the new element
4266: */
4267: ctxt = TtaGetGenericStyleContext (doc);
4268: if (ctxt == NULL)
4269: return;
4270: ctxt->destroy = destroy;
4271:
1.50 cvs 4272: while ((selector != NULL) && (*selector != WC_EOS))
1.25 cvs 4273: selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css);
1.1 cvs 4274: TtaFreeMemory (ctxt);
4275:
4276: /* restore the string to its original form ! */
4277: *sel_end = saved1;
4278: *decl_end = saved2;
4279: }
4280:
4281: /************************************************************************
4282: * *
4283: * EVALUATION FUNCTIONS / CASCADING AND OVERLOADING *
4284: * *
4285: ************************************************************************/
4286:
4287: /*----------------------------------------------------------------------
1.59 cvs 4288: IsImplicitClassName: return wether the Class name is an
1.1 cvs 4289: implicit one, eg "H1" or "H2 EM" meaning it's a GI name
4290: or an HTML context name.
4291: ----------------------------------------------------------------------*/
4292: #ifdef __STDC__
1.50 cvs 4293: int IsImplicitClassName (CHAR_T* class, Document doc)
1.1 cvs 4294: #else
4295: int IsImplicitClassName (class, doc)
1.50 cvs 4296: CHAR_T* class;
1.1 cvs 4297: Document doc;
4298: #endif
4299: {
1.50 cvs 4300: CHAR_T name[200];
4301: CHAR_T* cur = name;
4302: CHAR_T* first;
4303: CHAR_T save;
1.47 cvs 4304: SSchema schema;
1.1 cvs 4305:
4306: /* make a local copy */
1.50 cvs 4307: ustrncpy (name, class, 199);
1.1 cvs 4308: name[199] = 0;
4309:
4310: /* loop looking if each word is a GI */
4311: while (*cur != 0)
4312: {
4313: first = cur;
4314: cur = SkipWord (cur);
4315: save = *cur;
4316: *cur = 0;
4317: schema = NULL;
4318: if (MapGI (first, &schema, doc) == -1)
4319: {
4320: return (0);
4321: }
4322: *cur = save;
1.50 cvs 4323: cur = SkipWCBlanksAndComments (cur);
1.1 cvs 4324: }
4325: return (1);
4326: }
4327:
4328: /************************************************************************
4329: * *
1.59 cvs 4330: * Functions Needed for support of HTML 3.2: translate to CSS equiv *
1.1 cvs 4331: * *
4332: ************************************************************************/
4333:
4334: /*----------------------------------------------------------------------
1.59 cvs 4335: HTMLSetBackgroundColor:
1.1 cvs 4336: ----------------------------------------------------------------------*/
4337: #ifdef __STDC__
1.50 cvs 4338: void HTMLSetBackgroundColor (Document doc, Element el, CHAR_T* color)
1.1 cvs 4339: #else
4340: void HTMLSetBackgroundColor (doc, el, color)
4341: Document doc;
4342: Element el;
1.50 cvs 4343: CHAR_T* color;
1.1 cvs 4344: #endif
4345: {
1.50 cvs 4346: CHAR_T css_command[100];
1.1 cvs 4347:
1.50 cvs 4348: usprintf (css_command, TEXT("background-color: %s"), color);
1.68 cvs 4349: ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
1.1 cvs 4350: }
4351:
4352: /*----------------------------------------------------------------------
1.59 cvs 4353: HTMLSetBackgroundImage:
1.1 cvs 4354: repeat = repeat value
4355: image = url of background image
4356: ----------------------------------------------------------------------*/
4357: #ifdef __STDC__
1.50 cvs 4358: void HTMLSetBackgroundImage (Document doc, Element el, int repeat, CHAR_T* image)
1.1 cvs 4359: #else
4360: void HTMLSetBackgroundImage (doc, el, repeat, image)
4361: Document doc;
4362: Element el;
4363: int repeat;
1.50 cvs 4364: CHAR_T* image;
1.1 cvs 4365: #endif
4366: {
1.50 cvs 4367: CHAR_T css_command[400];
1.1 cvs 4368:
4369: /******* check buffer overflow ********/
1.50 cvs 4370: usprintf (css_command, TEXT("background-image: url(%s); background-repeat: "), image);
1.1 cvs 4371: if (repeat == STYLE_REPEAT)
1.50 cvs 4372: ustrcat (css_command, TEXT("repeat"));
1.1 cvs 4373: else if (repeat == STYLE_HREPEAT)
1.50 cvs 4374: ustrcat (css_command, TEXT("repeat-x"));
1.1 cvs 4375: else if (repeat == STYLE_VREPEAT)
1.50 cvs 4376: ustrcat (css_command, TEXT("repeat-y"));
1.1 cvs 4377: else
1.50 cvs 4378: ustrcat (css_command, TEXT("no-repeat"));
1.68 cvs 4379: ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
1.1 cvs 4380: }
4381:
4382: /*----------------------------------------------------------------------
1.59 cvs 4383: HTMLSetForegroundColor:
1.1 cvs 4384: ----------------------------------------------------------------------*/
4385: #ifdef __STDC__
1.50 cvs 4386: void HTMLSetForegroundColor (Document doc, Element el, CHAR_T* color)
1.1 cvs 4387: #else
4388: void HTMLSetForegroundColor (doc, el, color)
4389: Document doc;
4390: Element el;
1.50 cvs 4391: CHAR_T* color;
1.1 cvs 4392: #endif
4393: {
1.50 cvs 4394: CHAR_T css_command[100];
1.1 cvs 4395:
1.50 cvs 4396: usprintf (css_command, TEXT("color: %s"), color);
1.68 cvs 4397: ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
1.1 cvs 4398: }
4399:
4400: /*----------------------------------------------------------------------
1.59 cvs 4401: HTMLResetBackgroundColor:
1.1 cvs 4402: ----------------------------------------------------------------------*/
4403: #ifdef __STDC__
4404: void HTMLResetBackgroundColor (Document doc, Element el)
4405: #else
4406: void HTMLResetBackgroundColor (doc, el)
4407: Document doc;
4408: Element el;
4409: #endif
4410: {
1.50 cvs 4411: CHAR_T css_command[100];
1.1 cvs 4412:
1.50 cvs 4413: usprintf (css_command, TEXT("background: red"));
1.68 cvs 4414: ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
1.1 cvs 4415: }
4416:
4417: /*----------------------------------------------------------------------
1.59 cvs 4418: HTMLResetBackgroundImage:
1.1 cvs 4419: ----------------------------------------------------------------------*/
4420: #ifdef __STDC__
4421: void HTMLResetBackgroundImage (Document doc, Element el)
4422: #else
4423: void HTMLResetBackgroundImage (doc, el)
4424: Document doc;
4425: Element el;
4426: #endif
4427: {
1.50 cvs 4428: CHAR_T css_command[1000];
1.1 cvs 4429:
1.50 cvs 4430: usprintf (css_command, TEXT("background-image: url(xx); background-repeat: repeat"));
1.68 cvs 4431: ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
1.1 cvs 4432: }
4433:
4434: /*----------------------------------------------------------------------
1.59 cvs 4435: HTMLResetForegroundColor:
1.1 cvs 4436: ----------------------------------------------------------------------*/
4437: #ifdef __STDC__
4438: void HTMLResetForegroundColor (Document doc, Element el)
4439: #else
4440: void HTMLResetForegroundColor (doc, el)
4441: Document doc;
4442: Element el;
4443: #endif
4444: {
1.50 cvs 4445: CHAR_T css_command[100];
1.1 cvs 4446:
1.36 cvs 4447: /* it's not necessary to well know the current color but it must be valid */
1.50 cvs 4448: usprintf (css_command, TEXT("color: red"));
1.68 cvs 4449: ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
1.1 cvs 4450: }
4451:
4452: /*----------------------------------------------------------------------
1.59 cvs 4453: HTMLSetAlinkColor:
1.1 cvs 4454: ----------------------------------------------------------------------*/
4455: #ifdef __STDC__
1.50 cvs 4456: void HTMLSetAlinkColor (Document doc, CHAR_T* color)
1.1 cvs 4457: #else
4458: void HTMLSetAlinkColor (doc, color)
4459: Document doc;
1.50 cvs 4460: CHAR_T* color;
1.1 cvs 4461: #endif
4462: {
1.50 cvs 4463: CHAR_T css_command[100];
1.1 cvs 4464:
1.59 cvs 4465: usprintf (css_command, TEXT("a:link { color: %s }"), color);
1.1 cvs 4466: ApplyCSSRules (NULL, css_command, doc, FALSE);
4467: }
4468:
4469: /*----------------------------------------------------------------------
1.59 cvs 4470: HTMLSetAactiveColor:
1.1 cvs 4471: ----------------------------------------------------------------------*/
4472: #ifdef __STDC__
1.50 cvs 4473: void HTMLSetAactiveColor (Document doc, CHAR_T* color)
1.1 cvs 4474: #else
4475: void HTMLSetAactiveColor (doc, color)
4476: Document doc;
1.50 cvs 4477: CHAR_T* color;
1.1 cvs 4478: #endif
4479: {
1.50 cvs 4480: CHAR_T css_command[100];
1.1 cvs 4481:
1.59 cvs 4482: usprintf (css_command, TEXT("a:active { color: %s }"), color);
1.1 cvs 4483: ApplyCSSRules (NULL, css_command, doc, FALSE);
4484: }
4485:
4486: /*----------------------------------------------------------------------
1.59 cvs 4487: HTMLSetAvisitedColor:
1.1 cvs 4488: ----------------------------------------------------------------------*/
4489: #ifdef __STDC__
1.50 cvs 4490: void HTMLSetAvisitedColor (Document doc, CHAR_T* color)
1.1 cvs 4491: #else
4492: void HTMLSetAvisitedColor (doc, color)
4493: Document doc;
1.50 cvs 4494: CHAR_T* color;
1.1 cvs 4495: #endif
4496: {
1.50 cvs 4497: CHAR_T css_command[100];
1.1 cvs 4498:
1.59 cvs 4499: usprintf (css_command, TEXT("a:visited { color: %s }"), color);
1.1 cvs 4500: ApplyCSSRules (NULL, css_command, doc, FALSE);
4501: }
4502:
4503: /*----------------------------------------------------------------------
1.59 cvs 4504: HTMLResetAlinkColor:
1.1 cvs 4505: ----------------------------------------------------------------------*/
4506: #ifdef __STDC__
4507: void HTMLResetAlinkColor (Document doc)
4508: #else
4509: void HTMLResetAlinkColor (doc)
4510: Document doc;
4511: #endif
4512: {
1.50 cvs 4513: CHAR_T css_command[100];
1.1 cvs 4514:
1.59 cvs 4515: usprintf (css_command, TEXT("a:link { color: red }"));
1.1 cvs 4516: ApplyCSSRules (NULL, css_command, doc, TRUE);
4517: }
4518:
4519: /*----------------------------------------------------------------------
1.59 cvs 4520: HTMLResetAactiveColor:
1.1 cvs 4521: ----------------------------------------------------------------------*/
4522: #ifdef __STDC__
4523: void HTMLResetAactiveColor (Document doc)
4524: #else
4525: void HTMLResetAactiveColor (doc)
4526: Document doc;
4527: #endif
4528: {
1.50 cvs 4529: CHAR_T css_command[100];
1.1 cvs 4530:
1.59 cvs 4531: usprintf (css_command, TEXT("a:active { color: red }"));
1.1 cvs 4532: ApplyCSSRules (NULL, css_command, doc, TRUE);
4533: }
4534:
4535: /*----------------------------------------------------------------------
1.59 cvs 4536: HTMLResetAvisitedColor:
1.1 cvs 4537: ----------------------------------------------------------------------*/
4538: #ifdef __STDC__
4539: void HTMLResetAvisitedColor (Document doc)
4540: #else
4541: void HTMLResetAvisitedColor (doc)
4542: Document doc;
4543: #endif
4544: {
1.50 cvs 4545: CHAR_T css_command[100];
1.1 cvs 4546:
1.59 cvs 4547: usprintf (css_command, TEXT("a:visited { color: red }"));
1.1 cvs 4548: ApplyCSSRules (NULL, css_command, doc, TRUE);
4549: }
4550:
4551: /*----------------------------------------------------------------------
1.73 ! cvs 4552: ApplyCSSRules: parse a CSS Style description stored in the
1.1 cvs 4553: header of a HTML document.
4554: ----------------------------------------------------------------------*/
4555: #ifdef __STDC__
1.50 cvs 4556: void ApplyCSSRules (Element el, CHAR_T* cssRule, Document doc, ThotBool destroy)
1.1 cvs 4557: #else
4558: void ApplyCSSRules (el, cssRule, doc, destroy)
4559: Element el;
1.50 cvs 4560: CHAR_T* cssRule;
1.1 cvs 4561: Document doc;
1.14 cvs 4562: ThotBool destroy;
1.1 cvs 4563: #endif
4564: {
4565: CSSInfoPtr css;
4566:
4567: css = SearchCSS (doc, NULL);
4568: if (css == NULL)
4569: /* create the document css */
4570: css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, NULL, NULL);
4571: ParseStyleDeclaration (el, cssRule, doc, css, destroy);
4572: }
4573:
4574: /*----------------------------------------------------------------------
1.59 cvs 4575: ReadCSSRules: is the front-end function called by the HTML parser
1.1 cvs 4576: when detecting a <STYLE TYPE="text/css"> indicating it's the
4577: beginning of a CSS fragment or when reading a file .css.
4578:
4579: The CSS parser has to handle <!-- ... --> constructs used to
4580: prevent prehistoric browser from displaying the CSS as a text
4581: content. It will stop on any sequence "<x" where x is different
4582: from ! and will return x as to the caller. Theorically x should
4583: be equal to / for the </STYLE> end of style.
4584:
4585: The parameter doc gives the document tree that contains CSS information.
4586: The parameter docRef gives the document to which CSS are to be applied.
4587: This function uses the current css context or creates it. It's able
1.23 cvs 4588: to work on the given buffer or call GetNextChar to read the parsed
1.1 cvs 4589: file.
4590: Parameter withUndo indicates whether the changes made in the document
4591: structure and content have to be registered in the Undo queue or not
4592: ----------------------------------------------------------------------*/
4593: #ifdef __STDC__
1.50 cvs 4594: CHAR_T ReadCSSRules (Document docRef, CSSInfoPtr css, CHAR_T* buffer, ThotBool withUndo)
1.1 cvs 4595: #else
1.50 cvs 4596: CHAR_T ReadCSSRules (docRef, css, buffer, withUndo)
1.1 cvs 4597: Document docRef;
4598: CSSInfoPtr css;
1.50 cvs 4599: CHAR_T* buffer;
1.14 cvs 4600: ThotBool withUndo;
1.1 cvs 4601: #endif
4602: {
1.50 cvs 4603: CHAR_T c;
4604: CHAR_T *cssRule, *base;
1.6 cvs 4605: DisplayMode dispMode;
1.19 cvs 4606: int index;
1.1 cvs 4607: int CSSindex;
4608: int CSScomment;
4609: int import;
4610: int openRule;
1.14 cvs 4611: ThotBool HTMLcomment;
4612: ThotBool toParse, eof;
1.36 cvs 4613: ThotBool ignoreMedia, media;
1.25 cvs 4614: ThotBool noRule;
1.1 cvs 4615:
4616: CSScomment = MAX_CSS_LENGTH;
4617: HTMLcomment = FALSE;
4618: CSSindex = 0;
4619: toParse = FALSE;
4620: noRule = FALSE;
1.36 cvs 4621: media = FALSE;
1.1 cvs 4622: ignoreMedia = FALSE;
4623: import = MAX_CSS_LENGTH;
4624: eof = FALSE;
4625: openRule = 0;
1.50 cvs 4626: c = WC_SPACE;
1.1 cvs 4627: index = 0;
1.6 cvs 4628: /* avoid too many redisplay */
4629: dispMode = TtaGetDisplayMode (docRef);
4630: if (dispMode == DisplayImmediately)
4631: TtaSetDisplayMode (docRef, DeferredDisplay);
1.18 cvs 4632:
4633: /* look for the CSS context */
4634: if (css == NULL)
4635: css = SearchCSS (docRef, NULL);
4636: if (css == NULL)
4637: css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL);
1.1 cvs 4638:
1.50 cvs 4639: while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof) {
4640: c = buffer[index++];
4641: eof = (c == WC_EOS);
4642: CSSbuffer[CSSindex] = c;
4643: if (CSScomment == MAX_CSS_LENGTH || c == TEXT('*') || c == TEXT('/') || c == TEXT('<')) {
4644: /* we're not within a comment or we're parsing * or / */
4645: switch (c) {
4646: case TEXT('@'): /* perhaps an import primitive */
4647: import = CSSindex;
4648: break;
4649: case TEXT(';'):
4650: if (import != MAX_CSS_LENGTH && !media) {
4651: if (ustrncasecmp (&CSSbuffer[import+1], TEXT("import"), 6))
4652: /* it's not an import */
4653: import = MAX_CSS_LENGTH;
4654: /* save the text */
4655: noRule = TRUE;
4656: }
4657: break;
4658: case TEXT('*'):
4659: if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 && CSSbuffer[CSSindex - 1] == TEXT('/'))
4660: /* start a comment */
4661: CSScomment = CSSindex - 1;
4662: break;
4663: case TEXT('/'):
4664: if (CSSindex > 1 && CSScomment != MAX_CSS_LENGTH && CSSbuffer[CSSindex - 1] == TEXT('*')) {
4665: /* close a comment:and ignore its contents */
4666: CSSindex = CSScomment - 1; /* will be incremented later */
4667: CSScomment = MAX_CSS_LENGTH;
4668: } else if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 && CSSbuffer[CSSindex - 1] == TEXT('<')) {
4669: /* this is the closing tag ! */
4670: CSSindex -= 2; /* remove </ from the CSS string */
4671: noRule = TRUE;
4672: }
4673: break;
4674: case TEXT('<'):
4675: if (CSScomment == MAX_CSS_LENGTH) {
4676: /* only if we're not parsing a comment */
4677: c = buffer[index++];
4678: eof = (c == WC_EOS);
4679: if (c == TEXT('!')) {
4680: /* CSS within an HTML comment */
4681: HTMLcomment = TRUE;
4682: CSSindex++;
4683: CSSbuffer[CSSindex] = c;
4684: } else if (c == WC_EOS)
4685: CSSindex++;
4686: }
4687: break;
4688: case TEXT('-'):
4689: if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == TEXT('-') && HTMLcomment)
4690: /* CSS within an HTML comment */
4691: noRule = TRUE;
4692: break;
4693: case TEXT('>'):
4694: if (HTMLcomment)
4695: noRule = TRUE;
4696: break;
4697: case TEXT(' '):
4698: if (import != MAX_CSS_LENGTH && openRule == 0)
4699: media = !ustrncmp (&CSSbuffer[import+1], TEXT("media"), 5);
4700: break;
4701: case TEXT('{'):
4702: openRule++;
4703: if (import != MAX_CSS_LENGTH && openRule == 1 && media) {
4704: /* is it the screen concerned? */
4705: CSSbuffer[CSSindex+1] = WC_EOS;
4706: if (TtaIsPrinting ())
4707: base = ustrstr (&CSSbuffer[import], TEXT("print"));
4708: else
4709: base = ustrstr (&CSSbuffer[import], TEXT("screen"));
4710: if (base == NULL)
4711: ignoreMedia = TRUE;
4712: noRule = TRUE;
4713: }
4714: break;
4715: case TEXT('}'):
4716: openRule--;
4717: if (import != MAX_CSS_LENGTH && openRule == 0) {
4718: import = MAX_CSS_LENGTH;
4719: noRule = TRUE;
4720: ignoreMedia = FALSE;
4721: media = FALSE;
4722: } else
4723: toParse = TRUE;
4724: break;
4725: default:
4726: break;
4727: }
4728: }
4729: if (c != WC_CR)
4730: CSSindex++;
4731:
4732: if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
4733: /* we're still parsing a comment: remove the text comment */
4734: CSSindex = CSScomment;
4735:
4736: if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule) {
4737: CSSbuffer[CSSindex] = WC_EOS;
4738: /* parse a not empty string */
4739: if (CSSindex > 0) {
4740: /* apply CSS rule if it's not just a saving of text */
4741: if (!noRule && !ignoreMedia)
4742: ParseStyleDeclaration (NULL, CSSbuffer, docRef, css, FALSE);
4743: else if (import != MAX_CSS_LENGTH && !ustrncasecmp (&CSSbuffer[import+1], TEXT("import"), 6)) {
4744: /* import section */
4745: cssRule = &CSSbuffer[import+7];
4746: cssRule = TtaSkipWCBlanks (cssRule);
4747: if (!ustrncasecmp (cssRule, TEXT("url"), 3)) {
4748: cssRule = &cssRule[3];
4749: cssRule = TtaSkipWCBlanks (cssRule);
4750: if (*cssRule == TEXT('(')) {
4751: cssRule++;
4752: cssRule = TtaSkipWCBlanks (cssRule);
4753: base = cssRule;
4754: while (*cssRule != WC_EOS && *cssRule != TEXT(')'))
4755: cssRule++;
4756: *cssRule = WC_EOS;
4757: LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
4758: }
4759: }
4760: /*** Caution: Strings can either be written with double quotes or
4761: with single quotes. Only double quotes are handled here.
4762: Escaped quotes are not handled. See function SkipQuotedString */
4763: else if (*cssRule == TEXT('"')) {
4764: cssRule++;
4765: base = cssRule;
4766: while (*cssRule != WC_EOS && *cssRule != TEXT('"'))
4767: cssRule++;
4768: *cssRule = WC_EOS;
4769: LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
4770: }
4771: import = MAX_CSS_LENGTH;
4772: }
4773: }
4774: toParse = FALSE;
4775: noRule = FALSE;
4776: CSSindex = 0;
4777: }
4778: }
1.6 cvs 4779: /* restore the display mode */
4780: if (dispMode == DisplayImmediately)
1.50 cvs 4781: TtaSetDisplayMode (docRef, dispMode);
1.1 cvs 4782: return (c);
4783: }
Webmaster