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