Annotation of Amaya/amaya/styleparser.c, revision 1.64
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__
! 325: CHAR_T* ParseCSSUnit (CHAR_T* cssRule, PresentationValue *pval)
! 326: #else
! 327: CHAR_T* ParseCSSUnit (cssRule, pval)
! 328: CHAR_T* cssRule;
! 329: PresentationValue *pval;
! 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;
485: return (cssRule);
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.1 cvs 698: return (cssRule);
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.42 cvs 724: return (cssRule);
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.42 cvs 750: return (cssRule);
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.1 cvs 776: return (cssRule);
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);
2615: }
2616: else
2617: {
2618: cssRule = ParseCSSColor (cssRule, &best);
2619: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2620: {
2621: /* install the new presentation. */
2622: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
1.59 cvs 2623: /* thot specificity: need to set fill pattern for background color */
1.1 cvs 2624: best.typed_data.value = STYLE_PATTERN_BACKGROUND;
2625: best.typed_data.unit = STYLE_UNIT_REL;
2626: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2627: best.typed_data.value = 1;
2628: best.typed_data.unit = STYLE_UNIT_REL;
2629: TtaSetStylePresentation (PRShowBox, element, tsch, context, best);
2630: }
2631: }
2632: cssRule = SkipWord (cssRule);
2633:
2634: /* restore the refered element */
2635: if (moved && !element)
2636: context->type = savedtype;
2637: return (cssRule);
2638: }
2639:
1.63 cvs 2640:
2641: /*----------------------------------------------------------------------
2642: ParseSVGFill: parse a SVG fill property
2643: ----------------------------------------------------------------------*/
2644: #ifdef __STDC__
2645: static CHAR_T* ParseSVGFill (Element element, PSchema tsch,
2646: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
2647: #else
2648: static CHAR_T* ParseSVGFill (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 = STYLE_PATTERN_NONE;
2664: best.typed_data.unit = STYLE_UNIT_REL;
2665: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2666: }
2667: else
2668: {
2669: cssRule = ParseCSSColor (cssRule, &best);
2670: if (best.typed_data.unit != STYLE_UNIT_INVALID)
2671: {
2672: /* install the new presentation. */
2673: TtaSetStylePresentation (PRBackground, element, tsch, context, best);
2674: /* thot specificity: need to set fill pattern for background color */
2675: best.typed_data.value = STYLE_PATTERN_BACKGROUND;
2676: best.typed_data.unit = STYLE_UNIT_REL;
2677: TtaSetStylePresentation (PRFillPattern, element, tsch, context, best);
2678: }
2679: }
2680: cssRule = SkipWord (cssRule);
2681: return (cssRule);
2682: }
2683:
1.1 cvs 2684: /*----------------------------------------------------------------------
1.59 cvs 2685: ParseCSSBackgroundImageCallback: Callback called asynchronously by
2686: FetchImage when a background image has been fetched.
1.1 cvs 2687: ----------------------------------------------------------------------*/
2688: #ifdef __STDC__
1.50 cvs 2689: void ParseCSSBackgroundImageCallback (Document doc, Element element, STRING file, void *extra)
1.1 cvs 2690: #else
2691: void ParseCSSBackgroundImageCallback (doc, element, file, extra)
2692: Document doc;
2693: Element element;
2694: STRING file;
2695: void *extra;
2696: #endif
2697: {
1.34 cvs 2698: DisplayMode dispMode;
2699: BackgroundImageCallbackPtr callblock = (BackgroundImageCallbackPtr) extra;
2700: Element el;
2701: PSchema tsch;
2702: PresentationContext context;
2703: PresentationValue image;
2704: PresentationValue repeat;
2705: PresentationValue value;
1.1 cvs 2706:
1.34 cvs 2707: if (callblock == NULL)
2708: return;
1.1 cvs 2709:
1.34 cvs 2710: /* avoid too many redisplay */
2711: dispMode = TtaGetDisplayMode (doc);
2712: if (dispMode == DisplayImmediately)
2713: TtaSetDisplayMode (doc, DeferredDisplay);
2714:
2715: el = callblock->el;
2716: tsch = callblock->tsch;
2717: context = &callblock->context.specific;
2718:
2719: /* Ok the image was fetched, finish the background-image handling */
2720: image.pointer = file;
2721: TtaSetStylePresentation (PRBackgroundPicture, el, tsch, context, image);
1.1 cvs 2722:
1.34 cvs 2723: /* If there is no default repeat mode, enforce a V-Repeat */
2724: if (TtaGetStylePresentation (PRPictureMode, el, tsch, context, &repeat) < 0)
2725: {
2726: repeat.typed_data.value = STYLE_REPEAT;
2727: repeat.typed_data.unit = STYLE_UNIT_REL;
2728: repeat.typed_data.real = FALSE;
2729: TtaSetStylePresentation (PRPictureMode, el, tsch, context, repeat);
2730: }
2731:
2732: /* If there is no default repeat mode, enforce a V-Repeat */
2733: value.typed_data.value = 1;
2734: value.typed_data.unit = STYLE_UNIT_REL;
2735: value.typed_data.real = FALSE;
2736: TtaSetStylePresentation (PRShowBox, el, tsch, context, value);
2737:
2738: TtaFreeMemory (callblock);
2739: /* restore the display mode */
2740: if (dispMode == DisplayImmediately)
2741: TtaSetDisplayMode (doc, dispMode);
1.1 cvs 2742: }
2743:
2744:
2745: /*----------------------------------------------------------------------
2746: GetCSSBackgroundURL searches a CSS BackgroundImage url within
2747: the styleString.
2748: Returns NULL or a new allocated url string.
2749: ----------------------------------------------------------------------*/
2750: #ifdef __STDC__
1.50 cvs 2751: CHAR_T* GetCSSBackgroundURL (CHAR_T* styleString)
1.1 cvs 2752: #else
1.50 cvs 2753: CHAR_T* GetCSSBackgroundURL (styleString)
2754: CHAR_T* styleString;
1.1 cvs 2755: #endif
2756: {
1.50 cvs 2757: CHAR_T *b, *e, *ptr;
1.1 cvs 2758: int len;
2759:
2760: ptr = NULL;
1.50 cvs 2761: b = ustrstr (styleString, TEXT("url"));
1.1 cvs 2762: if (b != NULL)
2763: {
2764: b += 3;
1.50 cvs 2765: b = SkipWCBlanksAndComments (b);
2766: if (*b == TEXT('('))
1.1 cvs 2767: {
2768: b++;
1.50 cvs 2769: b = SkipWCBlanksAndComments (b);
1.1 cvs 2770: /*** Caution: Strings can either be written with double quotes or
2771: with single quotes. Only double quotes are handled here.
2772: Escaped quotes are not handled. See function SkipQuotedString */
1.50 cvs 2773: if (*b == TEXT('"'))
1.1 cvs 2774: {
2775: b++;
2776: /* search the url end */
2777: e = b;
1.50 cvs 2778: while (*e != WC_EOS && *e != TEXT('"'))
1.1 cvs 2779: e++;
2780: }
2781: else
2782: {
2783: /* search the url end */
2784: e = b;
1.50 cvs 2785: while (*e != WC_EOS && *e != TEXT(')'))
1.1 cvs 2786: e++;
2787: }
1.50 cvs 2788: if (*e != WC_EOS)
1.1 cvs 2789: {
2790: len = (int)(e - b);
1.50 cvs 2791: ptr = (CHAR_T*) TtaAllocString (len+1);
2792: ustrncpy (ptr, b, len);
2793: ptr[len] = WC_EOS;
1.1 cvs 2794: }
2795: }
2796: }
2797: return (ptr);
2798: }
2799:
2800:
2801: /*----------------------------------------------------------------------
1.59 cvs 2802: ParseCSSBackgroundImage: parse a CSS BackgroundImage attribute string.
1.1 cvs 2803: ----------------------------------------------------------------------*/
2804: #ifdef __STDC__
1.49 cvs 2805: static CHAR_T* ParseCSSBackgroundImage (Element element, PSchema tsch,
2806: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 2807: #else
1.49 cvs 2808: static CHAR_T* ParseCSSBackgroundImage (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 2809: Element element;
2810: PSchema tsch;
2811: PresentationContext context;
1.49 cvs 2812: CHAR_T* cssRule;
1.1 cvs 2813: CSSInfoPtr css;
1.14 cvs 2814: ThotBool isHTML;
1.1 cvs 2815: #endif
2816: {
1.49 cvs 2817: Element el;
2818: GenericContext gblock;
2819: PresentationContextBlock* sblock;
1.1 cvs 2820: BackgroundImageCallbackPtr callblock;
1.49 cvs 2821: PresentationValue image, value;
2822: CHAR_T* url;
2823: STRING bg_image;
2824: CHAR_T saved;
2825: CHAR_T* base;
2826: CHAR_T tempname[MAX_LENGTH];
2827: CHAR_T imgname[MAX_LENGTH];
2828: unsigned int savedtype = 0;
2829: ThotBool moved;
1.1 cvs 2830:
2831: /* default element for FetchImage */
2832: el = TtaGetMainRoot (context->doc);
2833: /* move the BODY rule to the HTML element */
2834: moved = (context->type == HTML_EL_BODY && isHTML);
2835: if (moved)
2836: {
2837: if (element)
2838: element = el;
2839: else
2840: {
2841: savedtype = context->type;
2842: context->type = HTML_EL_HTML;
2843: }
2844: }
2845: else if (element)
2846: el = element;
2847:
2848: url = NULL;
1.49 cvs 2849: cssRule = SkipWCBlanksAndComments (cssRule);
2850: if (!ustrncasecmp (cssRule, TEXT("url"), 3))
1.1 cvs 2851: {
2852: cssRule += 3;
1.49 cvs 2853: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2854: if (*cssRule == '(')
2855: {
2856: cssRule++;
1.49 cvs 2857: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 2858: /*** Caution: Strings can either be written with double quotes or
2859: with single quotes. Only double quotes are handled here.
2860: Escaped quotes are not handled. See function SkipQuotedString */
2861: if (*cssRule == '"')
2862: {
2863: cssRule++;
2864: base = cssRule;
1.49 cvs 2865: while (*cssRule != WC_EOS && *cssRule != TEXT('"'))
1.1 cvs 2866: cssRule++;
2867: }
2868: else
2869: {
2870: base = cssRule;
2871: while (*cssRule != EOS && *cssRule != ')')
2872: cssRule++;
2873: }
2874: saved = *cssRule;
1.49 cvs 2875: *cssRule = WC_EOS;
2876: url = TtaWCSdup (base);
1.1 cvs 2877: *cssRule = saved;
2878: if (saved == '"')
2879: /* we need to skip two characters */
2880: cssRule++;
2881: }
2882: cssRule++;
2883:
2884: if (context->destroy)
2885: {
2886: /* remove the background image PRule */
2887: image.pointer = NULL;
2888: TtaSetStylePresentation (PRBackgroundPicture, element, tsch, context, image);
2889: if (TtaGetStylePresentation (PRFillPattern, element, tsch, context, &value) < 0)
2890: {
2891: /* there is no FillPattern rule -> remove ShowBox rule */
2892: value.typed_data.value = 1;
2893: value.typed_data.unit = STYLE_UNIT_REL;
2894: value.typed_data.real = FALSE;
2895: TtaSetStylePresentation (PRShowBox, element, tsch, context, value);
2896: }
2897: }
2898: else if (url)
2899: {
1.30 cvs 2900: bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
1.17 cvs 2901: if (bg_image == NULL || !ustrcasecmp (bg_image, TEXT("yes")))
1.1 cvs 2902: {
2903: callblock = (BackgroundImageCallbackPtr) TtaGetMemory(sizeof(BackgroundImageCallbackBlock));
2904: if (callblock != NULL)
2905: {
2906: callblock->el = element;
2907: callblock->tsch = tsch;
2908: if (element == NULL)
1.18 cvs 2909: {
2910: gblock = (GenericContext) context;
2911: memcpy (&callblock->context.generic, gblock,
2912: sizeof (GenericContextBlock));
2913: }
2914: else
2915: {
2916: sblock = context;
2917: memcpy (&callblock->context.specific, sblock,
2918: sizeof(PresentationContextBlock));
2919: }
2920:
2921: /* check if the image url is related to an external CSS */
2922: if (css != NULL && css->category == CSS_EXTERNAL_STYLE)
2923: {
2924: NormalizeURL (url, 0, tempname, imgname, css->url);
2925: /* fetch and display background image of element */
1.49 cvs 2926: FetchImage (context->doc, el, tempname, AMAYA_LOAD_IMAGE, ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 2927: }
2928: else
1.49 cvs 2929: FetchImage (context->doc, el, url, AMAYA_LOAD_IMAGE, ParseCSSBackgroundImageCallback, callblock);
1.18 cvs 2930: }
2931: }
2932:
2933: if (url)
2934: TtaFreeMemory (url);
2935: }
2936: }
2937:
2938: /* restore the refered element */
2939: if (moved && !element)
2940: context->type = savedtype;
2941: return (cssRule);
2942: }
2943:
2944: /*----------------------------------------------------------------------
1.59 cvs 2945: ParseCSSBackgroundRepeat: parse a CSS BackgroundRepeat attribute string.
1.18 cvs 2946: ----------------------------------------------------------------------*/
2947: #ifdef __STDC__
1.50 cvs 2948: static CHAR_T* ParseCSSBackgroundRepeat (Element element, PSchema tsch,
2949: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 2950: #else
1.50 cvs 2951: static CHAR_T* ParseCSSBackgroundRepeat (element, tsch, context, cssRule, css, isHTML)
1.18 cvs 2952: Element element;
2953: PSchema tsch;
2954: PresentationContext context;
1.50 cvs 2955: CHAR_T* cssRule;
1.18 cvs 2956: CSSInfoPtr css;
2957: ThotBool isHTML;
2958: #endif
2959: {
2960: PresentationValue repeat;
2961: unsigned int savedtype = 0;
2962: ThotBool moved;
2963:
2964: /* move the BODY rule to the HTML element */
2965: moved = (context->type == HTML_EL_BODY && isHTML);
2966: if (moved)
2967: {
2968: if (element)
2969: element = TtaGetMainRoot (context->doc);
2970: else
2971: {
2972: savedtype = context->type;
2973: context->type = HTML_EL_HTML;
2974: }
2975: }
2976:
2977: repeat.typed_data.value = STYLE_REALSIZE;
2978: repeat.typed_data.unit = STYLE_UNIT_REL;
2979: repeat.typed_data.real = FALSE;
1.50 cvs 2980: cssRule = SkipWCBlanksAndComments (cssRule);
2981: if (!ustrncasecmp (cssRule, TEXT("no-repeat"), 9))
1.18 cvs 2982: repeat.typed_data.value = STYLE_REALSIZE;
1.50 cvs 2983: else if (!ustrncasecmp (cssRule, TEXT("repeat-y"), 8))
1.18 cvs 2984: repeat.typed_data.value = STYLE_VREPEAT;
1.50 cvs 2985: else if (!ustrncasecmp (cssRule, TEXT("repeat-x"), 8))
1.18 cvs 2986: repeat.typed_data.value = STYLE_HREPEAT;
1.50 cvs 2987: else if (!ustrncasecmp (cssRule, TEXT("repeat"), 6))
1.18 cvs 2988: repeat.typed_data.value = STYLE_REPEAT;
2989: else
2990: return (cssRule);
2991:
2992: /* install the new presentation */
2993: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
2994: cssRule = SkipWord (cssRule);
2995:
2996: /* restore the refered element */
2997: if (moved && !element)
2998: context->type = savedtype;
2999: return (cssRule);
3000: }
3001:
3002: /*----------------------------------------------------------------------
1.59 cvs 3003: ParseCSSBackgroundAttachment: parse a CSS BackgroundAttachment
1.18 cvs 3004: attribute string.
3005: ----------------------------------------------------------------------*/
3006: #ifdef __STDC__
1.58 cvs 3007: static CHAR_T* ParseCSSBackgroundAttachment (Element element, PSchema tsch,
1.50 cvs 3008: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3009: #else
1.58 cvs 3010: static CHAR_T* ParseCSSBackgroundAttachment (element, tsch, context, cssRule, css, isHTML)
1.18 cvs 3011: Element element;
3012: PSchema tsch;
3013: PresentationContext context;
1.50 cvs 3014: CHAR_T* cssRule;
1.18 cvs 3015: CSSInfoPtr css;
3016: ThotBool isHTML;
3017: #endif
3018: {
3019: unsigned int savedtype = 0;
3020: ThotBool moved;
1.1 cvs 3021:
1.18 cvs 3022: /* move the BODY rule to the HTML element */
3023: moved = (context->type == HTML_EL_BODY && isHTML);
3024: if (moved)
3025: {
3026: if (element)
3027: element = TtaGetMainRoot (context->doc);
3028: else
3029: {
3030: savedtype = context->type;
3031: context->type = HTML_EL_HTML;
1.1 cvs 3032: }
3033: }
3034:
1.50 cvs 3035: cssRule = SkipWCBlanksAndComments (cssRule);
3036: if (!ustrncasecmp (cssRule, TEXT("scroll"), 6))
1.18 cvs 3037: cssRule = SkipWord (cssRule);
1.50 cvs 3038: else if (!ustrncasecmp (cssRule, TEXT("fixed"), 5))
1.18 cvs 3039: cssRule = SkipWord (cssRule);
3040:
1.1 cvs 3041: /* restore the refered element */
3042: if (moved && !element)
3043: context->type = savedtype;
1.18 cvs 3044: return (cssRule);
1.1 cvs 3045: }
3046:
3047: /*----------------------------------------------------------------------
1.59 cvs 3048: ParseCSSBackgroundPosition: parse a CSS BackgroundPosition
1.1 cvs 3049: attribute string.
3050: ----------------------------------------------------------------------*/
3051: #ifdef __STDC__
1.50 cvs 3052: static CHAR_T* ParseCSSBackgroundPosition (Element element, PSchema tsch,
3053: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.1 cvs 3054: #else
1.50 cvs 3055: static CHAR_T* ParseCSSBackgroundPosition (element, tsch, context, cssRule, css, isHTML)
1.1 cvs 3056: Element element;
3057: PSchema tsch;
3058: PresentationContext context;
1.50 cvs 3059: CHAR_T* cssRule;
1.1 cvs 3060: CSSInfoPtr css;
1.14 cvs 3061: ThotBool isHTML;
1.1 cvs 3062: #endif
3063: {
1.18 cvs 3064: PresentationValue repeat;
3065: unsigned int savedtype = 0;
3066: ThotBool moved;
3067: ThotBool ok;
1.1 cvs 3068:
3069: /* move the BODY rule to the HTML element */
3070: moved = (context->type == HTML_EL_BODY && isHTML);
3071: if (moved)
3072: {
3073: if (element)
3074: element = TtaGetMainRoot (context->doc);
3075: else
3076: {
3077: savedtype = context->type;
3078: context->type = HTML_EL_HTML;
3079: }
3080: }
3081:
1.50 cvs 3082: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3083: ok = TRUE;
1.50 cvs 3084: if (!ustrncasecmp (cssRule, TEXT("left"), 4))
1.18 cvs 3085: cssRule = SkipWord (cssRule);
1.50 cvs 3086: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
1.18 cvs 3087: cssRule = SkipWord (cssRule);
1.50 cvs 3088: else if (!ustrncasecmp (cssRule, TEXT("center"), 6))
1.18 cvs 3089: cssRule = SkipWord (cssRule);
1.50 cvs 3090: else if (!ustrncasecmp (cssRule, TEXT("top"), 3))
1.18 cvs 3091: cssRule = SkipWord (cssRule);
1.50 cvs 3092: else if (!ustrncasecmp (cssRule, TEXT("bottom"), 6))
1.18 cvs 3093: cssRule = SkipWord (cssRule);
1.50 cvs 3094: else if (TtaIsDigit (*cssRule))
1.18 cvs 3095: cssRule = SkipWord (cssRule);
3096: else
3097: ok = FALSE;
3098:
3099: if (ok)
3100: {
3101: /* force realsize for the background image */
3102: repeat.typed_data.value = STYLE_REALSIZE;
3103: repeat.typed_data.unit = STYLE_UNIT_REL;
3104: repeat.typed_data.real = FALSE;
3105: TtaSetStylePresentation (PRPictureMode, element, tsch, context, repeat);
3106: }
3107:
3108: /* restore the refered element */
3109: if (moved && !element)
3110: context->type = savedtype;
3111: return (cssRule);
3112: }
3113:
3114: /*----------------------------------------------------------------------
1.59 cvs 3115: ParseCSSBackground: parse a CSS background attribute
1.18 cvs 3116: ----------------------------------------------------------------------*/
3117: #ifdef __STDC__
1.50 cvs 3118: static CHAR_T* ParseCSSBackground (Element element, PSchema tsch,
3119: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3120: #else
1.50 cvs 3121: static CHAR_T* ParseCSSBackground (element, tsch, context, cssRule, css, isHTML)
1.18 cvs 3122: Element element;
3123: PSchema tsch;
3124: PresentationContext context;
1.50 cvs 3125: CHAR_T* cssRule;
1.18 cvs 3126: CSSInfoPtr css;
3127: ThotBool isHTML;
3128: #endif
3129: {
1.50 cvs 3130: CHAR_T* ptr;
1.18 cvs 3131:
1.50 cvs 3132: cssRule = SkipWCBlanksAndComments (cssRule);
3133: while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))
1.18 cvs 3134: {
3135: /* perhaps a Backgroud Image */
1.50 cvs 3136: if (!ustrncasecmp (cssRule, TEXT("url"), 3))
1.63 cvs 3137: cssRule = ParseCSSBackgroundImage (element, tsch, context, cssRule,
3138: css, isHTML);
1.18 cvs 3139: /* perhaps a Background Attachment */
1.50 cvs 3140: else if (!ustrncasecmp (cssRule, TEXT("scroll"), 6) ||
3141: !ustrncasecmp (cssRule, TEXT("fixed"), 5))
1.63 cvs 3142: cssRule = ParseCSSBackgroundAttachment (element, tsch, context,
3143: cssRule, css, isHTML);
1.18 cvs 3144: /* perhaps a Background Repeat */
1.50 cvs 3145: else if (!ustrncasecmp (cssRule, TEXT("no-repeat"), 9) ||
3146: !ustrncasecmp (cssRule, TEXT("repeat-y"), 8) ||
3147: !ustrncasecmp (cssRule, TEXT("repeat-x"), 8) ||
3148: !ustrncasecmp (cssRule, TEXT("repeat"), 6))
1.63 cvs 3149: cssRule = ParseCSSBackgroundRepeat (element, tsch, context, cssRule,
3150: css, isHTML);
1.18 cvs 3151: /* perhaps a Background Position */
1.50 cvs 3152: else if (!ustrncasecmp (cssRule, TEXT("left"), 4) ||
3153: !ustrncasecmp (cssRule, TEXT("right"), 5) ||
3154: !ustrncasecmp (cssRule, TEXT("center"), 6) ||
3155: !ustrncasecmp (cssRule, TEXT("top"), 3) ||
3156: !ustrncasecmp (cssRule, TEXT("bottom"), 6) ||
3157: TtaIsDigit (*cssRule))
1.63 cvs 3158: cssRule = ParseCSSBackgroundPosition (element, tsch, context,
3159: cssRule, css, isHTML);
1.18 cvs 3160: /* perhaps a Background Color */
3161: else
3162: {
3163: /* check if the rule has been found */
3164: ptr = cssRule;
1.63 cvs 3165: cssRule = ParseCSSBackgroundColor (element, tsch, context, cssRule,
3166: css, isHTML);
1.43 cvs 3167: if (ptr == cssRule)
1.18 cvs 3168: /* rule not found */
3169: cssRule = SkipProperty (cssRule);
3170: }
1.50 cvs 3171: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3172: }
3173: return (cssRule);
3174: }
3175:
1.59 cvs 3176: /*----------------------------------------------------------------------
1.60 cvs 3177: ParseCSSPageBreakBefore: parse a CSS page-break-before attribute
1.59 cvs 3178: ----------------------------------------------------------------------*/
3179: #ifdef __STDC__
3180: static CHAR_T* ParseCSSPageBreakBefore (Element element, PSchema tsch,
3181: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
3182: #else
3183: static CHAR_T* ParseCSSPageBreakBefore (element, tsch, context, cssRule, css, isHTML)
3184: Element element;
3185: PSchema tsch;
3186: PresentationContext context;
3187: CHAR_T* cssRule;
3188: CSSInfoPtr css;
3189: ThotBool isHTML;
3190: #endif
3191: {
3192: PresentationValue page;
3193:
3194: page.typed_data.unit = STYLE_UNIT_INVALID;
3195: page.typed_data.real = FALSE;
3196: cssRule = SkipWCBlanksAndComments (cssRule);
3197: if (!ustrncasecmp (cssRule, TEXT("auto"), 4))
3198: {
3199: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3200: page.typed_data.value = STYLE_AUTO;
3201: }
3202: else if (!ustrncasecmp (cssRule, TEXT("always"), 6))
3203: {
3204: page.typed_data.unit = STYLE_UNIT_REL;
3205: page.typed_data.value = STYLE_ALWAYS;
3206: }
3207: else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))
3208: {
3209: page.typed_data.unit = STYLE_UNIT_REL;
3210: page.typed_data.value = STYLE_AVOID;
3211: }
3212: else if (!ustrncasecmp (cssRule, TEXT("left"), 4))
3213: {
3214: page.typed_data.unit = STYLE_UNIT_REL;
3215: page.typed_data.value = STYLE_PAGELEFT;
3216: }
3217: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
3218: {
3219: page.typed_data.unit = STYLE_UNIT_REL;
3220: page.typed_data.value = STYLE_PAGERIGHT;
3221: }
3222: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))
3223: {
3224: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3225: page.typed_data.value = STYLE_INHERIT;
3226: }
3227: cssRule = SkipWord (cssRule);
3228: /* install the new presentation */
3229: if (page.typed_data.unit == STYLE_UNIT_REL &&
3230: page.typed_data.value == STYLE_ALWAYS)
3231: TtaSetStylePresentation (PRPageBefore, element, tsch, context, page);
3232: return (cssRule);
3233: }
3234:
3235: /*----------------------------------------------------------------------
1.60 cvs 3236: ParseCSSPageBreakAfter: parse a CSS page-break-after attribute
1.59 cvs 3237: ----------------------------------------------------------------------*/
3238: #ifdef __STDC__
3239: static CHAR_T* ParseCSSPageBreakAfter (Element element, PSchema tsch,
3240: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
3241: #else
3242: static CHAR_T* ParseCSSPageBreakAfter (element, tsch, context, cssRule, css, isHTML)
3243: Element element;
3244: PSchema tsch;
3245: PresentationContext context;
3246: CHAR_T* cssRule;
3247: CSSInfoPtr css;
3248: ThotBool isHTML;
3249: #endif
3250: {
3251: PresentationValue page;
3252:
3253: page.typed_data.unit = STYLE_UNIT_INVALID;
3254: page.typed_data.real = FALSE;
3255: cssRule = SkipWCBlanksAndComments (cssRule);
3256: if (!ustrncasecmp (cssRule, TEXT("auto"), 4))
3257: {
3258: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3259: page.typed_data.value = STYLE_AUTO;
3260: }
3261: else if (!ustrncasecmp (cssRule, TEXT("always"), 6))
3262: {
3263: page.typed_data.unit = STYLE_UNIT_REL;
3264: page.typed_data.value = STYLE_ALWAYS;
3265: }
3266: else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))
3267: {
3268: page.typed_data.unit = STYLE_UNIT_REL;
3269: page.typed_data.value = STYLE_AVOID;
3270: }
3271: else if (!ustrncasecmp (cssRule, TEXT("left"), 4))
3272: {
3273: page.typed_data.unit = STYLE_UNIT_REL;
3274: page.typed_data.value = STYLE_PAGELEFT;
3275: }
3276: else if (!ustrncasecmp (cssRule, TEXT("right"), 5))
3277: {
3278: page.typed_data.unit = STYLE_UNIT_REL;
3279: page.typed_data.value = STYLE_PAGERIGHT;
3280: }
3281: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))
3282: {
3283: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3284: page.typed_data.value = STYLE_INHERIT;
3285: }
3286: cssRule = SkipWord (cssRule);
3287: /* install the new presentation */
3288: /*if (page.typed_data.unit == STYLE_UNIT_REL)
3289: TtaSetStylePresentation (PRPageAfter, element, tsch, context, page);*/
3290: return (cssRule);
3291: }
3292:
3293: /*----------------------------------------------------------------------
1.60 cvs 3294: ParseCSSPageBreakInside: parse a CSS page-break-inside attribute
1.59 cvs 3295: ----------------------------------------------------------------------*/
3296: #ifdef __STDC__
3297: static CHAR_T* ParseCSSPageBreakInside (Element element, PSchema tsch,
3298: PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
3299: #else
3300: static CHAR_T* ParseCSSPageBreakInside (element, tsch, context, cssRule, css, isHTML)
3301: Element element;
3302: PSchema tsch;
3303: PresentationContext context;
3304: CHAR_T* cssRule;
3305: CSSInfoPtr css;
3306: ThotBool isHTML;
3307: #endif
3308: {
3309: PresentationValue page;
3310:
3311: page.typed_data.unit = STYLE_UNIT_INVALID;
3312: page.typed_data.real = FALSE;
3313: cssRule = SkipWCBlanksAndComments (cssRule);
3314: if (!ustrncasecmp (cssRule, TEXT("auto"), 4))
3315: {
3316: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3317: page.typed_data.value = STYLE_AUTO;
3318: }
3319: else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))
3320: {
3321: page.typed_data.unit = STYLE_UNIT_REL;
3322: page.typed_data.value = STYLE_AVOID;
3323: }
3324: else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))
3325: {
3326: /*page.typed_data.unit = STYLE_UNIT_REL;*/
3327: page.typed_data.value = STYLE_INHERIT;
3328: }
3329: cssRule = SkipWord (cssRule);
3330: /* install the new presentation */
3331: if (page.typed_data.unit == STYLE_UNIT_REL &&
3332: page.typed_data.value == STYLE_AVOID)
3333: TtaSetStylePresentation (PRPageInside, element, tsch, context, page);
3334: return (cssRule);
3335: }
1.18 cvs 3336:
3337:
1.60 cvs 3338: /*----------------------------------------------------------------------
1.63 cvs 3339: ParseSVGStrokeWidth: parse a SVG stroke-width property value.
1.60 cvs 3340: ----------------------------------------------------------------------*/
3341: #ifdef __STDC__
1.63 cvs 3342: static CHAR_T* ParseSVGStrokeWidth (Element element, PSchema tsch,
1.60 cvs 3343: PresentationContext context, CHAR_T* cssRule,
3344: CSSInfoPtr css, ThotBool isHTML)
3345: #else
1.63 cvs 3346: static CHAR_T* ParseSVGStrokeWidth (element, tsch, context, cssRule, css,
1.60 cvs 3347: isHTML)
3348: Element element;
3349: PSchema tsch;
3350: PresentationContext context;
3351: CHAR_T* cssRule;
3352: CSSInfoPtr css;
3353: ThotBool isHTML;
3354: #endif
3355: {
3356: PresentationValue width;
3357:
3358: cssRule = SkipWCBlanksAndComments (cssRule);
3359: width.typed_data.value = 0;
3360: width.typed_data.unit = STYLE_UNIT_INVALID;
3361: width.typed_data.real = FALSE;
3362: if (TtaIsDigit (*cssRule))
3363: cssRule = ParseCSSUnit (cssRule, &width);
3364: if (width.typed_data.unit != STYLE_UNIT_INVALID)
3365: {
3366: TtaSetStylePresentation (PRLineWeight, element, tsch, context, width);
3367: width.typed_data.value = 1;
3368: width.typed_data.unit = STYLE_UNIT_REL;
3369: }
3370: return (cssRule);
3371: }
3372:
1.18 cvs 3373: /************************************************************************
3374: * *
3375: * FUNCTIONS STYLE DECLARATIONS *
3376: * *
3377: ************************************************************************/
3378: /*
1.59 cvs 3379: * NOTE: Long attribute name MUST be placed before shortened ones !
1.18 cvs 3380: * e.g. "FONT-SIZE" must be placed before "FONT"
3381: */
3382: static CSSProperty CSSProperties[] =
3383: {
1.50 cvs 3384: {TEXT("font-family"), ParseCSSFontFamily},
3385: {TEXT("font-style"), ParseCSSFontStyle},
3386: {TEXT("font-variant"), ParseCSSFontVariant},
3387: {TEXT("font-weight"), ParseCSSFontWeight},
3388: {TEXT("font-size"), ParseCSSFontSize},
3389: {TEXT("font"), ParseCSSFont},
3390:
3391: {TEXT("color"), ParseCSSForeground},
3392: {TEXT("background-color"), ParseCSSBackgroundColor},
3393: {TEXT("background-image"), ParseCSSBackgroundImage},
3394: {TEXT("background-repeat"), ParseCSSBackgroundRepeat},
3395: {TEXT("background-attachment"), ParseCSSBackgroundAttachment},
3396: {TEXT("background-position"), ParseCSSBackgroundPosition},
3397: {TEXT("background"), ParseCSSBackground},
3398:
3399: {TEXT("word-spacing"), ParseCSSWordSpacing},
3400: {TEXT("letter-spacing"), ParseCSSLetterSpacing},
3401: {TEXT("text-decoration"), ParseCSSTextDecoration},
3402: {TEXT("vertical-align"), ParseCSSVerticalAlign},
3403: {TEXT("text-transform"), ParseCSSTextTransform},
3404: {TEXT("text-align"), ParseCSSTextAlign},
3405: {TEXT("text-indent"), ParseCSSTextIndent},
3406: {TEXT("line-height"), ParseCSSLineSpacing},
3407:
3408: {TEXT("margin-top"), ParseCSSMarginTop},
3409: {TEXT("margin-right"), ParseCSSMarginRight},
3410: {TEXT("margin-bottom"), ParseCSSMarginBottom},
3411: {TEXT("margin-left"), ParseCSSMarginLeft},
3412: {TEXT("margin"), ParseCSSMargin},
3413:
3414: {TEXT("padding-top"), ParseCSSPaddingTop},
3415: {TEXT("padding-right"), ParseCSSPaddingRight},
3416: {TEXT("padding-bottom"), ParseCSSPaddingBottom},
3417: {TEXT("padding-left"), ParseCSSPaddingLeft},
3418: {TEXT("padding"), ParseCSSPadding},
3419:
3420: {TEXT("border-top-width"), ParseCSSBorderTopWidth},
3421: {TEXT("border-right-width"), ParseCSSBorderRightWidth},
3422: {TEXT("border-bottom-width"), ParseCSSBorderBottomWidth},
3423: {TEXT("border-left-width"), ParseCSSBorderLeftWidth},
3424: {TEXT("border-width"), ParseCSSBorderWidth},
3425: {TEXT("border-top-color"), ParseCSSBorderColorTop},
3426: {TEXT("border-right-color"), ParseCSSBorderColorRight},
3427: {TEXT("border-bottom-color"), ParseCSSBorderColorBottom},
3428: {TEXT("border-left-color"), ParseCSSBorderColorLeft},
3429: {TEXT("border-color"), ParseCSSBorderColor},
3430: {TEXT("border-top-style"), ParseCSSBorderStyleTop},
3431: {TEXT("border-right-style"), ParseCSSBorderStyleRight},
3432: {TEXT("border-bottom-style"), ParseCSSBorderStyleBottom},
3433: {TEXT("border-left-style"), ParseCSSBorderStyleLeft},
3434: {TEXT("border-style"), ParseCSSBorderStyle},
3435: {TEXT("border-top"), ParseCSSBorderTop},
3436: {TEXT("border-right"), ParseCSSBorderRight},
3437: {TEXT("border-bottom"), ParseCSSBorderBottom},
3438: {TEXT("border-left"), ParseCSSBorderLeft},
3439: {TEXT("border"), ParseCSSBorder},
3440:
3441: {TEXT("width"), ParseCSSWidth},
3442: {TEXT("height"), ParseCSSHeight},
3443: {TEXT("float"), ParseCSSFloat},
3444: {TEXT("clear"), ParseCSSClear},
3445:
3446: {TEXT("display"), ParseCSSDisplay},
3447: {TEXT("white-space"), ParseCSSWhiteSpace},
3448:
3449: {TEXT("list-style-type"), ParseCSSListStyleType},
3450: {TEXT("list-style-image"), ParseCSSListStyleImage},
3451: {TEXT("list-style-position"), ParseCSSListStylePosition},
1.59 cvs 3452: {TEXT("list-style"), ParseCSSListStyle},
3453:
3454: {TEXT("page-break-before"), ParseCSSPageBreakBefore},
3455: {TEXT("page-break-after"), ParseCSSPageBreakAfter},
1.60 cvs 3456: {TEXT("page-break-inside"), ParseCSSPageBreakInside},
3457:
3458: /* SVG extensions */
1.63 cvs 3459: {TEXT("stroke-width"), ParseSVGStrokeWidth},
1.60 cvs 3460: {TEXT("stroke"), ParseCSSForeground},
1.63 cvs 3461: {TEXT("fill"), ParseSVGFill}
1.18 cvs 3462: };
3463: #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
3464:
3465: /*----------------------------------------------------------------------
1.59 cvs 3466: ParseCSSRule: parse a CSS Style string
1.18 cvs 3467: we expect the input string describing the style to be of the
1.59 cvs 3468: form: PRORPERTY: DESCRIPTION [ ; PROPERTY: DESCRIPTION ] *
1.18 cvs 3469: but tolerate incorrect or incomplete input
3470: ----------------------------------------------------------------------*/
3471: #ifdef __STDC__
1.50 cvs 3472: static void ParseCSSRule (Element element, PSchema tsch, PresentationContext context, CHAR_T* cssRule, CSSInfoPtr css, ThotBool isHTML)
1.18 cvs 3473: #else
3474: static void ParseCSSRule (element, tsch, context, cssRule, css, isHTML)
3475: Element element;
3476: PSchema tsch;
3477: PresentationContext context;
1.50 cvs 3478: CHAR_T* cssRule;
1.18 cvs 3479: CSSInfoPtr css;
3480: ThotBool isHTML;
3481: #endif
3482: {
1.34 cvs 3483: DisplayMode dispMode;
1.50 cvs 3484: CHAR_T* p = NULL;
1.18 cvs 3485: int lg;
1.34 cvs 3486: unsigned int i;
1.61 cvs 3487: ElementType elType;
3488: ThotBool found, done;
1.18 cvs 3489:
1.34 cvs 3490: /* avoid too many redisplay */
3491: dispMode = TtaGetDisplayMode (context->doc);
3492: if (dispMode == DisplayImmediately)
3493: TtaSetDisplayMode (context->doc, DeferredDisplay);
3494:
1.50 cvs 3495: while (*cssRule != WC_EOS)
1.18 cvs 3496: {
1.50 cvs 3497: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3498:
3499: found = FALSE;
3500: /* look for the type of property */
3501: for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
3502: {
1.50 cvs 3503: lg = ustrlen (CSSProperties[i].name);
3504: if (!ustrncasecmp (cssRule, CSSProperties[i].name, lg))
1.18 cvs 3505: {
3506: cssRule += lg;
3507: found = TRUE;
3508: i--;
3509: }
3510: }
3511:
3512: if (i == NB_CSSSTYLEATTRIBUTE)
3513: cssRule = SkipProperty (cssRule);
3514: else
3515: {
3516: /* update index and skip the ":" indicator if present */
1.50 cvs 3517: cssRule = SkipWCBlanksAndComments (cssRule);
3518: if (*cssRule == TEXT(':'))
1.18 cvs 3519: {
3520: cssRule++;
1.50 cvs 3521: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3522: }
1.61 cvs 3523: /* try to parse the value associated with this property */
1.18 cvs 3524: if (CSSProperties[i].parsing_function != NULL)
3525: {
1.61 cvs 3526: done = FALSE;
3527: /* if it's the "fill" SVG property applied to a SVG text element,
3528: generate a Foreground P rule */
3529: if (!ustrcmp (CSSProperties[i].name, TEXT("fill")))
3530: {
3531: elType = TtaGetElementType (element);
1.62 cvs 3532: if (elType.ElTypeNum == GraphML_EL_text_ ||
3533: elType.ElTypeNum == GraphML_EL_tspan)
1.61 cvs 3534: if (!ustrcmp (TtaGetSSchemaName (elType.ElSSchema),
3535: TEXT("GraphML")))
3536: {
3537: p = ParseCSSForeground (element, tsch, context, cssRule,
3538: css, isHTML);
3539: done = TRUE;
3540: }
3541: }
3542: if (!done)
3543: p = CSSProperties[i].parsing_function (element, tsch, context,
3544: cssRule, css, isHTML);
1.34 cvs 3545: /* update index and skip the ";" separator if present */
3546: cssRule = p;
1.18 cvs 3547: }
3548: }
3549: /* next property */
1.50 cvs 3550: cssRule = SkipWCBlanksAndComments (cssRule);
3551: if (*cssRule == TEXT(',') || *cssRule == TEXT(';'))
1.18 cvs 3552: {
3553: cssRule++;
1.50 cvs 3554: cssRule = SkipWCBlanksAndComments (cssRule);
1.18 cvs 3555: }
3556: }
1.34 cvs 3557:
3558: /* restore the display mode */
3559: if (dispMode == DisplayImmediately)
3560: TtaSetDisplayMode (context->doc, dispMode);
1.18 cvs 3561: }
1.1 cvs 3562:
3563:
3564: /*----------------------------------------------------------------------
1.59 cvs 3565: PToCss: translate a PresentationSetting to the
1.18 cvs 3566: equivalent CSS string, and add it to the buffer given as the
3567: argument. It is used when extracting the CSS string from actual
3568: presentation.
3569:
3570: All the possible values returned by the presentation drivers are
3571: described in thotlib/include/presentation.h
3572: -----------------------------------------------------------------------*/
1.1 cvs 3573: #ifdef __STDC__
1.50 cvs 3574: void PToCss (PresentationSetting settings, CHAR_T* buffer, int len)
1.1 cvs 3575: #else
1.18 cvs 3576: void PToCss (settings, buffer, len)
3577: PresentationSetting settings;
1.50 cvs 3578: CHAR_T* param;
1.18 cvs 3579: int len
1.1 cvs 3580: #endif
3581: {
1.18 cvs 3582: float fval = 0;
3583: unsigned short red, green, blue;
3584: int add_unit = 0;
3585: unsigned int unit, i;
3586: ThotBool real = FALSE;
3587:
1.50 cvs 3588: buffer[0] = WC_EOS;
1.18 cvs 3589: if (len < 40)
3590: return;
3591:
3592: unit = settings->value.typed_data.unit;
3593: if (settings->value.typed_data.real)
3594: {
3595: real = TRUE;
3596: fval = (float) settings->value.typed_data.value;
3597: fval /= 1000;
3598: }
1.1 cvs 3599:
1.18 cvs 3600: switch (settings->type)
1.1 cvs 3601: {
1.18 cvs 3602: case PRVisibility:
3603: break;
3604: case PRFont:
3605: switch (settings->value.typed_data.value)
3606: {
3607: case STYLE_FONT_HELVETICA:
1.50 cvs 3608: ustrcpy (buffer, TEXT("font-family: helvetica"));
1.18 cvs 3609: break;
3610: case STYLE_FONT_TIMES:
1.50 cvs 3611: ustrcpy (buffer, TEXT("font-family: times"));
1.18 cvs 3612: break;
3613: case STYLE_FONT_COURIER:
1.50 cvs 3614: ustrcpy (buffer, TEXT("font-family: courier"));
1.18 cvs 3615: break;
3616: }
3617: break;
3618: case PRStyle:
3619: switch (settings->value.typed_data.value)
3620: {
3621: case STYLE_FONT_ROMAN:
1.50 cvs 3622: ustrcpy (buffer, TEXT("font-style: normal"));
1.18 cvs 3623: break;
3624: case STYLE_FONT_ITALICS:
1.50 cvs 3625: ustrcpy (buffer, TEXT("font-style: italic"));
1.18 cvs 3626: break;
3627: case STYLE_FONT_OBLIQUE:
1.50 cvs 3628: ustrcpy (buffer, TEXT("font-style: oblique"));
1.18 cvs 3629: break;
1.20 cvs 3630: }
3631: break;
3632: case PRWeight:
3633: switch (settings->value.typed_data.value)
3634: {
3635: case STYLE_WEIGHT_BOLD:
1.50 cvs 3636: ustrcpy (buffer, TEXT("font-weight: bold"));
1.20 cvs 3637: break;
3638: case STYLE_WEIGHT_NORMAL:
1.50 cvs 3639: ustrcpy (buffer, TEXT("font-weight: normal"));
1.18 cvs 3640: break;
3641: }
3642: break;
3643: case PRSize:
3644: if (unit == STYLE_UNIT_REL)
3645: {
3646: if (real)
3647: {
1.50 cvs 3648: usprintf (buffer, TEXT("font-size: %g"), fval);
1.18 cvs 3649: add_unit = 1;
3650: }
3651: else
3652: switch (settings->value.typed_data.value)
3653: {
3654: case 1:
1.50 cvs 3655: ustrcpy (buffer, TEXT("font-size: xx-small"));
1.18 cvs 3656: break;
3657: case 2:
1.50 cvs 3658: ustrcpy (buffer, TEXT("font-size: x-small"));
1.18 cvs 3659: break;
3660: case 3:
1.50 cvs 3661: ustrcpy (buffer, TEXT("font-size: small"));
1.18 cvs 3662: break;
3663: case 4:
1.50 cvs 3664: ustrcpy (buffer, TEXT("font-size: medium"));
1.18 cvs 3665: break;
3666: case 5:
1.50 cvs 3667: ustrcpy (buffer, TEXT("font-size: large"));
1.18 cvs 3668: break;
3669: case 6:
1.50 cvs 3670: ustrcpy (buffer, TEXT("font-size: x-large"));
1.18 cvs 3671: break;
3672: case 7:
3673: case 8:
3674: case 9:
3675: case 10:
3676: case 11:
3677: case 12:
1.50 cvs 3678: ustrcpy (buffer, TEXT("font-size: xx-large"));
1.18 cvs 3679: break;
3680: }
3681: }
3682: else
3683: {
3684: if (real)
1.50 cvs 3685: usprintf (buffer, TEXT("font-size: %g"), fval);
1.18 cvs 3686: else
1.50 cvs 3687: usprintf (buffer, TEXT("font-size: %d"), settings->value.typed_data.value);
1.18 cvs 3688: add_unit = 1;
3689: }
3690: break;
3691: case PRUnderline:
3692: switch (settings->value.typed_data.value)
3693: {
3694: case STYLE_UNDERLINE:
1.50 cvs 3695: ustrcpy (buffer, TEXT("text-decoration: underline"));
1.18 cvs 3696: break;
3697: case STYLE_OVERLINE:
1.50 cvs 3698: ustrcpy (buffer, TEXT("text-decoration: overline"));
1.18 cvs 3699: break;
3700: case STYLE_CROSSOUT:
1.50 cvs 3701: ustrcpy (buffer, TEXT("text-decoration: line-through"));
1.18 cvs 3702: break;
3703: }
3704: break;
3705: case PRIndent:
3706: if (real)
1.50 cvs 3707: usprintf (buffer, TEXT("text-indent: %g"), fval);
1.18 cvs 3708: else
1.50 cvs 3709: usprintf (buffer, TEXT("text-indent: %d"), settings->value.typed_data.value);
1.18 cvs 3710: add_unit = 1;
3711: break;
3712: case PRLineSpacing:
3713: if (real)
1.50 cvs 3714: usprintf (buffer, TEXT("line-height: %g"), fval);
1.1 cvs 3715: else
1.50 cvs 3716: usprintf (buffer, TEXT("line-height: %d"), settings->value.typed_data.value);
1.18 cvs 3717: add_unit = 1;
3718: break;
3719: case PRJustify:
3720: if (settings->value.typed_data.value == STYLE_JUSTIFIED)
1.50 cvs 3721: usprintf (buffer, TEXT("text-align: justify"));
1.18 cvs 3722: break;
3723: case PRAdjust:
3724: switch (settings->value.typed_data.value)
1.1 cvs 3725: {
1.18 cvs 3726: case STYLE_ADJUSTLEFT:
1.50 cvs 3727: ustrcpy (buffer, TEXT("text-align: left"));
1.18 cvs 3728: break;
3729: case STYLE_ADJUSTRIGHT:
1.50 cvs 3730: ustrcpy (buffer, TEXT("text-align: right"));
1.18 cvs 3731: break;
3732: case STYLE_ADJUSTCENTERED:
1.50 cvs 3733: ustrcpy (buffer, TEXT("text-align: center"));
1.18 cvs 3734: break;
3735: case STYLE_ADJUSTLEFTWITHDOTS:
1.50 cvs 3736: ustrcpy (buffer, TEXT("text-align: left"));
1.18 cvs 3737: break;
1.1 cvs 3738: }
1.18 cvs 3739: break;
3740: case PRHyphenate:
3741: break;
3742: case PRFillPattern:
3743: break;
3744: case PRBackground:
3745: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.50 cvs 3746: usprintf (buffer, TEXT("background-color: #%02X%02X%02X"), red, green, blue);
1.18 cvs 3747: break;
3748: case PRForeground:
3749: TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
1.50 cvs 3750: usprintf (buffer, TEXT("color: #%02X%02X%02X"), red, green, blue);
1.18 cvs 3751: break;
1.40 cvs 3752: case PRMarginTop:
1.18 cvs 3753: if (real)
1.50 cvs 3754: usprintf (buffer, TEXT("marging-top: %g"), fval);
1.18 cvs 3755: else
1.50 cvs 3756: usprintf (buffer, TEXT("marging-top: %d"), settings->value.typed_data.value);
1.18 cvs 3757: add_unit = 1;
3758: break;
1.40 cvs 3759: case PRMarginLeft:
1.18 cvs 3760: if (real)
1.50 cvs 3761: usprintf (buffer, TEXT("margin-left: %g"), fval);
1.18 cvs 3762: else
1.50 cvs 3763: usprintf (buffer, TEXT("margin-left: %d"), settings->value.typed_data.value);
1.18 cvs 3764: add_unit = 1;
3765: break;
3766: case PRHeight:
3767: if (real)
1.50 cvs 3768: usprintf (buffer, TEXT("height: %g"), fval);
1.18 cvs 3769: else
1.50 cvs 3770: usprintf (buffer, TEXT("height: %d"), settings->value.typed_data.value);
1.18 cvs 3771: add_unit = 1;
3772: break;
3773: case PRWidth:
3774: if (real)
1.50 cvs 3775: usprintf (buffer, TEXT("width: %g"), fval);
1.1 cvs 3776: else
1.50 cvs 3777: usprintf (buffer, TEXT("width: %d"), settings->value.typed_data.value);
1.18 cvs 3778: add_unit = 1;
3779: break;
3780: case PRLine:
3781: if (settings->value.typed_data.value == STYLE_INLINE)
1.50 cvs 3782: ustrcpy (buffer, TEXT("display: inline"));
1.18 cvs 3783: else if (settings->value.typed_data.value == STYLE_NOTINLINE)
1.50 cvs 3784: ustrcpy (buffer, TEXT("display: block"));
1.18 cvs 3785: break;
3786: case PRBackgroundPicture:
3787: if (settings->value.pointer != NULL)
1.50 cvs 3788: usprintf (buffer, TEXT("background-image: url(%s)"), (char*)(settings->value.pointer));
1.1 cvs 3789: else
1.50 cvs 3790: usprintf (buffer, TEXT("background-image: none"));
1.18 cvs 3791: break;
3792: case PRPictureMode:
3793: switch (settings->value.typed_data.value)
1.1 cvs 3794: {
1.18 cvs 3795: case STYLE_REALSIZE:
1.50 cvs 3796: usprintf (buffer, TEXT("background-repeat: no-repeat"));
1.18 cvs 3797: break;
3798: case STYLE_REPEAT:
1.50 cvs 3799: usprintf (buffer, TEXT("background-repeat: repeat"));
1.18 cvs 3800: break;
3801: case STYLE_VREPEAT:
1.50 cvs 3802: usprintf (buffer, TEXT("background-repeat: repeat-y"));
1.18 cvs 3803: break;
3804: case STYLE_HREPEAT:
1.50 cvs 3805: usprintf (buffer, TEXT("background-repeat: repeat-x"));
1.18 cvs 3806: break;
1.1 cvs 3807: }
1.18 cvs 3808: break;
3809: default:
3810: break;
1.1 cvs 3811: }
3812:
1.18 cvs 3813: if (add_unit)
1.1 cvs 3814: {
1.18 cvs 3815: /* add the unit string to the CSS string */
3816: for (i = 0; i < NB_UNITS; i++)
1.1 cvs 3817: {
1.18 cvs 3818: if (CSSUnitNames[i].unit == unit)
1.1 cvs 3819: {
1.50 cvs 3820: ustrcat (buffer, CSSUnitNames[i].sign);
1.18 cvs 3821: break;
1.1 cvs 3822: }
3823: }
3824: }
3825: }
3826:
3827: /*----------------------------------------------------------------------
1.59 cvs 3828: ParseHTMLSpecificStyle: parse and apply a CSS Style string.
1.18 cvs 3829: This function must be called when a specific style is applied to an
3830: element.
1.1 cvs 3831: ----------------------------------------------------------------------*/
3832: #ifdef __STDC__
1.50 cvs 3833: void ParseHTMLSpecificStyle (Element el, CHAR_T* cssRule, Document doc, ThotBool destroy)
1.1 cvs 3834: #else
3835: void ParseHTMLSpecificStyle (el, cssRule, doc, destroy)
3836: Element elem;
1.50 cvs 3837: CHAR_T* cssRule;
1.1 cvs 3838: Document doc;
1.14 cvs 3839: ThotBool destroy;
1.1 cvs 3840: #endif
3841: {
3842: PresentationContext context;
3843: ElementType elType;
1.14 cvs 3844: ThotBool isHTML;
1.1 cvs 3845:
3846: /* A rule applying to BODY is really meant to address HTML */
3847: elType = TtaGetElementType (el);
1.49 cvs 3848: isHTML = (ustrcmp (TtaGetSSchemaName (elType.ElSSchema), TEXT("HTML")) == 0);
1.1 cvs 3849: /* create the context of the Specific presentation driver */
3850: context = TtaGetSpecificStyleContext (doc);
3851: if (context == NULL)
3852: return;
3853: context->type = elType.ElTypeNum;
3854: context->destroy = destroy;
3855: /* Call the parser */
3856: ParseCSSRule (el, NULL, (PresentationContext) context, cssRule, NULL, isHTML);
3857: /* free the context */
3858: TtaFreeMemory(context);
3859: }
3860:
3861: /*----------------------------------------------------------------------
1.59 cvs 3862: ParseGenericSelector: Create a generic context for a given
1.1 cvs 3863: selector string. If the selector is made of multiple comma-
3864: separated selector items, it parses them one at a time and
3865: return the end of the selector string to be handled or NULL
3866: ----------------------------------------------------------------------*/
3867: #ifdef __STDC__
1.50 cvs 3868: static CHAR_T* ParseGenericSelector (CHAR_T* selector, CHAR_T* cssRule,
1.1 cvs 3869: GenericContext ctxt, Document doc, CSSInfoPtr css)
3870: #else
1.50 cvs 3871: static CHAR_T* ParseGenericSelector (selector, cssRule, ctxt, doc, css)
3872: CHAR_T* selector;
3873: CHAR_T* cssRule;
1.1 cvs 3874: GenericContext ctxt;
3875: Document doc;
3876: CSSInfoPtr css;
3877: #endif
3878: {
3879: ElementType elType;
3880: PSchema tsch;
1.25 cvs 3881: AttributeType attrType;
1.49 cvs 3882: CHAR_T sel[MAX_ANCESTORS * 50];
3883: CHAR_T *deb, *cur;
3884: CHAR_T* structName;
3885: CHAR_T* names[MAX_ANCESTORS];
3886: CHAR_T* ids[MAX_ANCESTORS];
3887: CHAR_T* classes[MAX_ANCESTORS];
3888: CHAR_T* pseudoclasses[MAX_ANCESTORS];
3889: CHAR_T* attrs[MAX_ANCESTORS];
3890: CHAR_T* attrvals[MAX_ANCESTORS];
1.35 cvs 3891: int i, j, k, max, maxAttr;
1.25 cvs 3892: ThotBool isHTML;
1.1 cvs 3893:
1.50 cvs 3894: sel[0] = WC_EOS;
1.1 cvs 3895: for (i = 0; i < MAX_ANCESTORS; i++)
3896: {
1.25 cvs 3897: names[i] = NULL;
3898: ids[i] = NULL;
3899: classes[i] = NULL;
3900: pseudoclasses[i] = NULL;
3901: attrs[i] = NULL;
3902: attrvals[i] = NULL;
3903:
3904: ctxt->name[i] = 0;
3905: ctxt->names_nb[i] = 0;
3906: ctxt->attrType[i] = 0;
3907: ctxt->attrText[i] = NULL;
1.1 cvs 3908: }
1.25 cvs 3909: ctxt->box = 0;
3910: ctxt->type = 0;
3911:
1.50 cvs 3912: selector = SkipWCBlanksAndComments (selector);
1.27 cvs 3913: cur = &sel[0];
1.25 cvs 3914: max = 0; /* number of loops */
1.1 cvs 3915: while (1)
3916: {
1.27 cvs 3917: deb = cur;
1.25 cvs 3918: /* copy an item of the selector into sel[] */
1.1 cvs 3919: /* put one word in the sel buffer */
1.50 cvs 3920: while (*selector != WC_EOS && *selector != TEXT(',') &&
3921: *selector != TEXT('.') && *selector != TEXT(':') &&
3922: *selector != TEXT('#') && !TtaIsWCBlank (selector))
3923: *cur++ = *selector++;
3924: *cur++ = WC_EOS; /* close the first string in sel[] */
3925: if (deb[0] != WC_EOS)
1.27 cvs 3926: names[0] = deb;
1.25 cvs 3927: else
1.27 cvs 3928: names[0] = NULL;
3929: classes[0] = NULL;
3930: pseudoclasses[0] = NULL;
3931: ids[0] = NULL;
3932: attrs[0] = NULL;
3933: attrvals[0] = NULL;
1.25 cvs 3934:
1.27 cvs 3935: /* now names[0] points to the beginning of the parsed item
1.25 cvs 3936: and cur to the next chain to be parsed */
1.50 cvs 3937: if (*selector == TEXT(':') || *selector == TEXT('.') || *selector == TEXT('#'))
1.25 cvs 3938: /* keep the element name which precedes the id or
3939: pseudo class or the class */
1.27 cvs 3940: deb = cur;
1.1 cvs 3941:
1.50 cvs 3942: if (*selector == TEXT('.'))
1.1 cvs 3943: {
1.25 cvs 3944: /* copy into sel[] the class */
1.27 cvs 3945: classes[0] = cur;
1.1 cvs 3946: selector++;
1.50 cvs 3947: while (*selector != WC_EOS && *selector != TEXT(',') &&
3948: *selector != TEXT('.') && *selector != TEXT(':') &&
3949: !TtaIsWCBlank (selector))
1.1 cvs 3950: *cur++ = *selector++;
1.50 cvs 3951: *cur++ = WC_EOS;
1.1 cvs 3952: }
1.50 cvs 3953: else if (*selector == TEXT(':'))
1.1 cvs 3954: {
1.25 cvs 3955: /* copy into sel[] the pseudoclass */
1.27 cvs 3956: pseudoclasses[0]= cur;
1.1 cvs 3957: selector++;
1.50 cvs 3958: while (*selector != WC_EOS && *selector != TEXT(',') &&
3959: *selector != TEXT('.') && *selector != TEXT(':') &&
3960: !TtaIsWCBlank (selector))
3961: *cur++ = *selector++;
3962: *cur++ = WC_EOS;
1.1 cvs 3963: }
1.50 cvs 3964: else if (*selector == TEXT('#'))
1.1 cvs 3965: {
1.25 cvs 3966: /* copy into sel[] the attribute */
1.27 cvs 3967: ids[0] = cur;
1.1 cvs 3968: selector++;
1.50 cvs 3969: while (*selector != WC_EOS && *selector != TEXT(',') &&
3970: *selector != TEXT('.') && *selector != TEXT(':') &&
3971: !TtaIsWCBlank (selector))
3972: *cur++ = *selector++;
3973: *cur++ = WC_EOS;
1.1 cvs 3974: }
1.50 cvs 3975: else if (*selector == TEXT('['))
1.1 cvs 3976: {
1.25 cvs 3977: /* copy into sel[] the attribute */
1.27 cvs 3978: attrs[0] = cur;
1.25 cvs 3979: selector++;
1.50 cvs 3980: while (*selector != WC_EOS && *selector != TEXT(']') && *selector != TEXT('='))
1.25 cvs 3981: *cur++ = *selector++;
1.50 cvs 3982: if (*cur == TEXT('='))
1.25 cvs 3983: {
3984: /* there is a value "xxxx" */
1.50 cvs 3985: *cur++ = WC_EOS;
3986: while (*selector != WC_EOS && *selector != TEXT(']') && *selector != TEXT('"'))
1.25 cvs 3987: selector++;
1.50 cvs 3988: if (*selector != WC_EOS)
1.25 cvs 3989: {
3990: /* we are now parsing the attribute value */
1.27 cvs 3991: attrvals[0] = cur;
1.25 cvs 3992: selector++;
1.50 cvs 3993: while (*selector != WC_EOS && *selector != TEXT('"'))
1.25 cvs 3994: *cur++ = *selector++;
1.50 cvs 3995: if (*selector != WC_EOS)
1.25 cvs 3996: selector++;
3997: }
3998: }
1.50 cvs 3999: *cur++ = WC_EOS;
1.1 cvs 4000: }
4001:
1.50 cvs 4002: selector = SkipWCBlanksAndComments (selector);
1.1 cvs 4003:
1.25 cvs 4004: /* is it a multi-level selector? */
1.50 cvs 4005: if (*selector == WC_EOS)
1.1 cvs 4006: /* end of the selector */
4007: break;
1.50 cvs 4008: else if (*selector == TEXT(','))
1.1 cvs 4009: {
4010: /* end of the current selector */
4011: selector++;
4012: break;
4013: }
1.25 cvs 4014: else
4015: {
4016: /* shifts the list to make room for the new name */
4017: max++; /* a new level in ancestor tables */
4018: if (max == MAX_ANCESTORS)
4019: /* abort the CSS parsing */
4020: return (selector);
4021: for (i = max; i > 0; i--)
4022: {
4023: names[i] = names[i - 1];
4024: ids[i] = ids[i - 1];
4025: classes[i] = classes[i - 1];
4026: attrs[i] = attrs[i - 1];
4027: attrvals[i] = attrvals[i - 1];
4028: pseudoclasses[i] = pseudoclasses[i - 1];
4029: }
4030: }
1.1 cvs 4031: }
4032:
4033: /* Now set up the context block */
1.25 cvs 4034: i = 0;
4035: k = 0;
4036: j = 0;
1.35 cvs 4037: maxAttr = 0;
1.25 cvs 4038: while (i <= max)
4039: {
4040: if (names[i])
4041: {
4042: /* get the new element type of this name */
4043: GIType (names[i], &elType, doc);
4044: if (i == 0)
4045: {
4046: /* Store the element type */
4047: ctxt->type = elType.ElTypeNum;
1.32 cvs 4048: ctxt->name[0] = elType.ElTypeNum;
4049: ctxt->names_nb[0] = 0;
1.25 cvs 4050: ctxt->schema = elType.ElSSchema;
1.27 cvs 4051: k++;
1.25 cvs 4052: }
4053: else if (elType.ElTypeNum != 0)
4054: {
4055: /* look at the current context to see if the type is already
4056: stored */
4057: j = 0;
1.32 cvs 4058: while (j < k && ctxt->name[j] != elType.ElTypeNum)
1.25 cvs 4059: j++;
4060: if (j == k)
4061: {
4062: /* add a new entry */
4063: k++;
4064: ctxt->name[j] = elType.ElTypeNum;
4065: if (j != 0)
4066: ctxt->names_nb[j] = 1;
4067: }
4068: else
4069: /* increment the number of ancestor levels */
4070: ctxt->names_nb[j]++;
4071: }
4072: else
4073: {
4074: /* add a new entry */
4075: j = k;
4076: k++;
4077: }
4078: }
1.1 cvs 4079: else
1.25 cvs 4080: {
4081: /* add a new entry */
4082: j = k;
4083: k++;
4084: }
4085:
1.35 cvs 4086: if (classes[i] || pseudoclasses[i] || ids[i] || attrs[i])
4087: if (maxAttr > 0)
4088: /* Thot is not able to manage this kind of selector -> abort */
4089: return (selector);
4090: else
4091: maxAttr++;
1.1 cvs 4092:
1.25 cvs 4093: /* store attributes information */
4094: if (classes[i])
4095: {
4096: ctxt->attrText[j] = classes[i];
4097: ctxt->attrType[j] = HTML_ATTR_Class;
4098: }
4099: else if (pseudoclasses[i])
4100: {
4101: ctxt->attrText[j] = pseudoclasses[i];
4102: ctxt->attrType[j] = HTML_ATTR_PseudoClass;
4103: }
4104: else if (ids[i])
4105: {
4106: ctxt->attrText[j] = ids[i];
4107: ctxt->attrType[j] = HTML_ATTR_ID;
4108: }
4109: else if (attrs[i])
4110: {
4111: MapHTMLAttribute (attrs[i], &attrType, names[i], doc);
4112: ctxt->attrText[j] = attrvals[i];
4113: ctxt->attrType[j] = attrType.AttrTypeNum;
4114: }
4115: i++;
1.1 cvs 4116: }
4117:
1.25 cvs 4118: /* sort the list of ancestors by name order */
4119: max = k;
4120: i = 1;
4121: while (i < max)
1.28 cvs 4122: {
4123: for (k = i + 1; k < max; k++)
4124: if (ctxt->name[i] > ctxt->name[k])
4125: {
4126: j = ctxt->name[i];
4127: ctxt->name[i] = ctxt->name[k];
4128: ctxt->name[k] = j;
4129: j = ctxt->names_nb[i];
4130: ctxt->names_nb[i] = ctxt->names_nb[k];
4131: ctxt->names_nb[k] = j;
4132: j = ctxt->attrType[i];
4133: ctxt->attrType[i] = ctxt->attrType[k];
4134: ctxt->attrType[k] = j;
4135: cur = ctxt->attrText[i];
4136: ctxt->attrText[i] = ctxt->attrText[k];
4137: ctxt->attrText[k] = cur;
4138: }
4139: i++;
4140: }
1.25 cvs 4141:
4142: /* Get the schema name of the main element */
4143: if (ctxt->schema == NULL)
1.1 cvs 4144: ctxt->schema = TtaGetDocumentSSchema (doc);
1.49 cvs 4145: isHTML = (ustrcmp (TtaGetSSchemaName (ctxt->schema), TEXT("HTML")) == 0);
1.1 cvs 4146: tsch = GetPExtension (doc, ctxt->schema, css);
4147: structName = TtaGetSSchemaName (ctxt->schema);
4148: if (cssRule)
4149: ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
4150: return (selector);
4151: }
4152:
4153: /*----------------------------------------------------------------------
1.59 cvs 4154: ParseStyleDeclaration: parse one HTML style declaration
1.1 cvs 4155: stored in the header of a HTML document
1.59 cvs 4156: We expect the style string to be of the form:
1.1 cvs 4157: [
4158: e.g: pinky, awful { color: pink, font-family: helvetica }
4159: ----------------------------------------------------------------------*/
4160: #ifdef __STDC__
1.50 cvs 4161: static void ParseStyleDeclaration (Element el, CHAR_T* cssRule, Document doc, CSSInfoPtr css, ThotBool destroy)
1.1 cvs 4162: #else
4163: static void ParseStyleDeclaration (el, cssRule, doc, css, destroy)
4164: Element el;
4165: STRING cssRule;
4166: Document doc;
4167: CSSInfoPtr css;
1.14 cvs 4168: ThotBool destroy;
1.1 cvs 4169: #endif
4170: {
1.50 cvs 4171: GenericContext ctxt;
4172: CHAR_T* decl_end;
4173: CHAR_T* sel_end;
4174: CHAR_T* selector;
4175: CHAR_T saved1;
4176: CHAR_T saved2;
1.1 cvs 4177:
4178: /* separate the selectors string */
1.50 cvs 4179: cssRule = SkipWCBlanksAndComments (cssRule);
1.1 cvs 4180: decl_end = cssRule;
1.50 cvs 4181: while ((*decl_end != WC_EOS) && (*decl_end != TEXT('{')))
1.1 cvs 4182: decl_end++;
1.50 cvs 4183: if (*decl_end == WC_EOS)
1.1 cvs 4184: return;
4185: /* verify and clean the selector string */
4186: sel_end = decl_end - 1;
1.50 cvs 4187: while (*sel_end == WC_SPACE || *sel_end == WC_BSPACE ||
4188: *sel_end == WC_EOL || *sel_end == WC_CR)
1.1 cvs 4189: sel_end--;
4190: sel_end++;
4191: saved1 = *sel_end;
1.50 cvs 4192: *sel_end = WC_EOS;
1.1 cvs 4193: selector = cssRule;
4194:
4195: /* now, deal with the content ... */
4196: decl_end++;
4197: cssRule = decl_end;
1.50 cvs 4198: while (*decl_end != WC_EOS && *decl_end != TEXT('}'))
1.1 cvs 4199: decl_end++;
1.50 cvs 4200: if (*decl_end == WC_EOS)
1.1 cvs 4201: {
1.59 cvs 4202: fprintf (stderr, "Invalid STYLE declaration: %s\n", cssRule);
1.1 cvs 4203: return;
4204: }
4205: saved2 = *decl_end;
1.50 cvs 4206: *decl_end = WC_EOS;
1.1 cvs 4207:
4208: /*
4209: * parse the style attribute string and install the corresponding
4210: * presentation attributes on the new element
4211: */
4212: ctxt = TtaGetGenericStyleContext (doc);
4213: if (ctxt == NULL)
4214: return;
4215: ctxt->destroy = destroy;
4216:
1.50 cvs 4217: while ((selector != NULL) && (*selector != WC_EOS))
1.25 cvs 4218: selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css);
1.1 cvs 4219: TtaFreeMemory (ctxt);
4220:
4221: /* restore the string to its original form ! */
4222: *sel_end = saved1;
4223: *decl_end = saved2;
4224: }
4225:
4226: /************************************************************************
4227: * *
4228: * EVALUATION FUNCTIONS / CASCADING AND OVERLOADING *
4229: * *
4230: ************************************************************************/
4231:
4232: /*----------------------------------------------------------------------
1.59 cvs 4233: IsImplicitClassName: return wether the Class name is an
1.1 cvs 4234: implicit one, eg "H1" or "H2 EM" meaning it's a GI name
4235: or an HTML context name.
4236: ----------------------------------------------------------------------*/
4237: #ifdef __STDC__
1.50 cvs 4238: int IsImplicitClassName (CHAR_T* class, Document doc)
1.1 cvs 4239: #else
4240: int IsImplicitClassName (class, doc)
1.50 cvs 4241: CHAR_T* class;
1.1 cvs 4242: Document doc;
4243: #endif
4244: {
1.50 cvs 4245: CHAR_T name[200];
4246: CHAR_T* cur = name;
4247: CHAR_T* first;
4248: CHAR_T save;
1.47 cvs 4249: SSchema schema;
1.1 cvs 4250:
4251: /* make a local copy */
1.50 cvs 4252: ustrncpy (name, class, 199);
1.1 cvs 4253: name[199] = 0;
4254:
4255: /* loop looking if each word is a GI */
4256: while (*cur != 0)
4257: {
4258: first = cur;
4259: cur = SkipWord (cur);
4260: save = *cur;
4261: *cur = 0;
4262: schema = NULL;
4263: if (MapGI (first, &schema, doc) == -1)
4264: {
4265: return (0);
4266: }
4267: *cur = save;
1.50 cvs 4268: cur = SkipWCBlanksAndComments (cur);
1.1 cvs 4269: }
4270: return (1);
4271: }
4272:
4273: /************************************************************************
4274: * *
1.59 cvs 4275: * Functions Needed for support of HTML 3.2: translate to CSS equiv *
1.1 cvs 4276: * *
4277: ************************************************************************/
4278:
4279: /*----------------------------------------------------------------------
1.59 cvs 4280: HTMLSetBackgroundColor:
1.1 cvs 4281: ----------------------------------------------------------------------*/
4282: #ifdef __STDC__
1.50 cvs 4283: void HTMLSetBackgroundColor (Document doc, Element el, CHAR_T* color)
1.1 cvs 4284: #else
4285: void HTMLSetBackgroundColor (doc, el, color)
4286: Document doc;
4287: Element el;
1.50 cvs 4288: CHAR_T* color;
1.1 cvs 4289: #endif
4290: {
1.50 cvs 4291: CHAR_T css_command[100];
1.1 cvs 4292:
1.50 cvs 4293: usprintf (css_command, TEXT("background-color: %s"), color);
1.1 cvs 4294: ParseHTMLSpecificStyle (el, css_command, doc, FALSE);
4295: }
4296:
4297: /*----------------------------------------------------------------------
1.59 cvs 4298: HTMLSetBackgroundImage:
1.1 cvs 4299: repeat = repeat value
4300: image = url of background image
4301: ----------------------------------------------------------------------*/
4302: #ifdef __STDC__
1.50 cvs 4303: void HTMLSetBackgroundImage (Document doc, Element el, int repeat, CHAR_T* image)
1.1 cvs 4304: #else
4305: void HTMLSetBackgroundImage (doc, el, repeat, image)
4306: Document doc;
4307: Element el;
4308: int repeat;
1.50 cvs 4309: CHAR_T* image;
1.1 cvs 4310: #endif
4311: {
1.50 cvs 4312: CHAR_T css_command[400];
1.1 cvs 4313:
4314: /******* check buffer overflow ********/
1.50 cvs 4315: usprintf (css_command, TEXT("background-image: url(%s); background-repeat: "), image);
1.1 cvs 4316: if (repeat == STYLE_REPEAT)
1.50 cvs 4317: ustrcat (css_command, TEXT("repeat"));
1.1 cvs 4318: else if (repeat == STYLE_HREPEAT)
1.50 cvs 4319: ustrcat (css_command, TEXT("repeat-x"));
1.1 cvs 4320: else if (repeat == STYLE_VREPEAT)
1.50 cvs 4321: ustrcat (css_command, TEXT("repeat-y"));
1.1 cvs 4322: else
1.50 cvs 4323: ustrcat (css_command, TEXT("no-repeat"));
1.1 cvs 4324: ParseHTMLSpecificStyle (el, css_command, doc, FALSE);
4325: }
4326:
4327: /*----------------------------------------------------------------------
1.59 cvs 4328: HTMLSetForegroundColor:
1.1 cvs 4329: ----------------------------------------------------------------------*/
4330: #ifdef __STDC__
1.50 cvs 4331: void HTMLSetForegroundColor (Document doc, Element el, CHAR_T* color)
1.1 cvs 4332: #else
4333: void HTMLSetForegroundColor (doc, el, color)
4334: Document doc;
4335: Element el;
1.50 cvs 4336: CHAR_T* color;
1.1 cvs 4337: #endif
4338: {
1.50 cvs 4339: CHAR_T css_command[100];
1.1 cvs 4340:
1.50 cvs 4341: usprintf (css_command, TEXT("color: %s"), color);
1.1 cvs 4342: ParseHTMLSpecificStyle (el, css_command, doc, FALSE);
4343: }
4344:
4345: /*----------------------------------------------------------------------
1.59 cvs 4346: HTMLResetBackgroundColor:
1.1 cvs 4347: ----------------------------------------------------------------------*/
4348: #ifdef __STDC__
4349: void HTMLResetBackgroundColor (Document doc, Element el)
4350: #else
4351: void HTMLResetBackgroundColor (doc, el)
4352: Document doc;
4353: Element el;
4354: #endif
4355: {
1.50 cvs 4356: CHAR_T css_command[100];
1.1 cvs 4357:
1.50 cvs 4358: usprintf (css_command, TEXT("background: red"));
1.1 cvs 4359: ParseHTMLSpecificStyle (el, css_command, doc, TRUE);
4360: }
4361:
4362: /*----------------------------------------------------------------------
1.59 cvs 4363: HTMLResetBackgroundImage:
1.1 cvs 4364: ----------------------------------------------------------------------*/
4365: #ifdef __STDC__
4366: void HTMLResetBackgroundImage (Document doc, Element el)
4367: #else
4368: void HTMLResetBackgroundImage (doc, el)
4369: Document doc;
4370: Element el;
4371: #endif
4372: {
1.50 cvs 4373: CHAR_T css_command[1000];
1.1 cvs 4374:
1.50 cvs 4375: usprintf (css_command, TEXT("background-image: url(xx); background-repeat: repeat"));
1.1 cvs 4376: ParseHTMLSpecificStyle (el, css_command, doc, TRUE);
4377: }
4378:
4379: /*----------------------------------------------------------------------
1.59 cvs 4380: HTMLResetForegroundColor:
1.1 cvs 4381: ----------------------------------------------------------------------*/
4382: #ifdef __STDC__
4383: void HTMLResetForegroundColor (Document doc, Element el)
4384: #else
4385: void HTMLResetForegroundColor (doc, el)
4386: Document doc;
4387: Element el;
4388: #endif
4389: {
1.50 cvs 4390: CHAR_T css_command[100];
1.1 cvs 4391:
1.36 cvs 4392: /* it's not necessary to well know the current color but it must be valid */
1.50 cvs 4393: usprintf (css_command, TEXT("color: red"));
1.1 cvs 4394: ParseHTMLSpecificStyle (el, css_command, doc, TRUE);
4395: }
4396:
4397: /*----------------------------------------------------------------------
1.59 cvs 4398: HTMLSetAlinkColor:
1.1 cvs 4399: ----------------------------------------------------------------------*/
4400: #ifdef __STDC__
1.50 cvs 4401: void HTMLSetAlinkColor (Document doc, CHAR_T* color)
1.1 cvs 4402: #else
4403: void HTMLSetAlinkColor (doc, color)
4404: Document doc;
1.50 cvs 4405: CHAR_T* color;
1.1 cvs 4406: #endif
4407: {
1.50 cvs 4408: CHAR_T css_command[100];
1.1 cvs 4409:
1.59 cvs 4410: usprintf (css_command, TEXT("a:link { color: %s }"), color);
1.1 cvs 4411: ApplyCSSRules (NULL, css_command, doc, FALSE);
4412: }
4413:
4414: /*----------------------------------------------------------------------
1.59 cvs 4415: HTMLSetAactiveColor:
1.1 cvs 4416: ----------------------------------------------------------------------*/
4417: #ifdef __STDC__
1.50 cvs 4418: void HTMLSetAactiveColor (Document doc, CHAR_T* color)
1.1 cvs 4419: #else
4420: void HTMLSetAactiveColor (doc, color)
4421: Document doc;
1.50 cvs 4422: CHAR_T* color;
1.1 cvs 4423: #endif
4424: {
1.50 cvs 4425: CHAR_T css_command[100];
1.1 cvs 4426:
1.59 cvs 4427: usprintf (css_command, TEXT("a:active { color: %s }"), color);
1.1 cvs 4428: ApplyCSSRules (NULL, css_command, doc, FALSE);
4429: }
4430:
4431: /*----------------------------------------------------------------------
1.59 cvs 4432: HTMLSetAvisitedColor:
1.1 cvs 4433: ----------------------------------------------------------------------*/
4434: #ifdef __STDC__
1.50 cvs 4435: void HTMLSetAvisitedColor (Document doc, CHAR_T* color)
1.1 cvs 4436: #else
4437: void HTMLSetAvisitedColor (doc, color)
4438: Document doc;
1.50 cvs 4439: CHAR_T* color;
1.1 cvs 4440: #endif
4441: {
1.50 cvs 4442: CHAR_T css_command[100];
1.1 cvs 4443:
1.59 cvs 4444: usprintf (css_command, TEXT("a:visited { color: %s }"), color);
1.1 cvs 4445: ApplyCSSRules (NULL, css_command, doc, FALSE);
4446: }
4447:
4448: /*----------------------------------------------------------------------
1.59 cvs 4449: HTMLResetAlinkColor:
1.1 cvs 4450: ----------------------------------------------------------------------*/
4451: #ifdef __STDC__
4452: void HTMLResetAlinkColor (Document doc)
4453: #else
4454: void HTMLResetAlinkColor (doc)
4455: Document doc;
4456: #endif
4457: {
1.50 cvs 4458: CHAR_T css_command[100];
1.1 cvs 4459:
1.59 cvs 4460: usprintf (css_command, TEXT("a:link { color: red }"));
1.1 cvs 4461: ApplyCSSRules (NULL, css_command, doc, TRUE);
4462: }
4463:
4464: /*----------------------------------------------------------------------
1.59 cvs 4465: HTMLResetAactiveColor:
1.1 cvs 4466: ----------------------------------------------------------------------*/
4467: #ifdef __STDC__
4468: void HTMLResetAactiveColor (Document doc)
4469: #else
4470: void HTMLResetAactiveColor (doc)
4471: Document doc;
4472: #endif
4473: {
1.50 cvs 4474: CHAR_T css_command[100];
1.1 cvs 4475:
1.59 cvs 4476: usprintf (css_command, TEXT("a:active { color: red }"));
1.1 cvs 4477: ApplyCSSRules (NULL, css_command, doc, TRUE);
4478: }
4479:
4480: /*----------------------------------------------------------------------
1.59 cvs 4481: HTMLResetAvisitedColor:
1.1 cvs 4482: ----------------------------------------------------------------------*/
4483: #ifdef __STDC__
4484: void HTMLResetAvisitedColor (Document doc)
4485: #else
4486: void HTMLResetAvisitedColor (doc)
4487: Document doc;
4488: #endif
4489: {
1.50 cvs 4490: CHAR_T css_command[100];
1.1 cvs 4491:
1.59 cvs 4492: usprintf (css_command, TEXT("a:visited { color: red }"));
1.1 cvs 4493: ApplyCSSRules (NULL, css_command, doc, TRUE);
4494: }
4495:
4496: /*----------------------------------------------------------------------
4497: ApplyCSSRules: parse an CSS Style description stored in the
4498: header of a HTML document.
4499: ----------------------------------------------------------------------*/
4500: #ifdef __STDC__
1.50 cvs 4501: void ApplyCSSRules (Element el, CHAR_T* cssRule, Document doc, ThotBool destroy)
1.1 cvs 4502: #else
4503: void ApplyCSSRules (el, cssRule, doc, destroy)
4504: Element el;
1.50 cvs 4505: CHAR_T* cssRule;
1.1 cvs 4506: Document doc;
1.14 cvs 4507: ThotBool destroy;
1.1 cvs 4508: #endif
4509: {
4510: CSSInfoPtr css;
4511:
4512: css = SearchCSS (doc, NULL);
4513: if (css == NULL)
4514: /* create the document css */
4515: css = AddCSS (doc, doc, CSS_DOCUMENT_STYLE, NULL, NULL);
4516: ParseStyleDeclaration (el, cssRule, doc, css, destroy);
4517: }
4518:
4519: /*----------------------------------------------------------------------
1.59 cvs 4520: ReadCSSRules: is the front-end function called by the HTML parser
1.1 cvs 4521: when detecting a <STYLE TYPE="text/css"> indicating it's the
4522: beginning of a CSS fragment or when reading a file .css.
4523:
4524: The CSS parser has to handle <!-- ... --> constructs used to
4525: prevent prehistoric browser from displaying the CSS as a text
4526: content. It will stop on any sequence "<x" where x is different
4527: from ! and will return x as to the caller. Theorically x should
4528: be equal to / for the </STYLE> end of style.
4529:
4530: The parameter doc gives the document tree that contains CSS information.
4531: The parameter docRef gives the document to which CSS are to be applied.
4532: This function uses the current css context or creates it. It's able
1.23 cvs 4533: to work on the given buffer or call GetNextChar to read the parsed
1.1 cvs 4534: file.
4535: Parameter withUndo indicates whether the changes made in the document
4536: structure and content have to be registered in the Undo queue or not
4537: ----------------------------------------------------------------------*/
4538: #ifdef __STDC__
1.50 cvs 4539: CHAR_T ReadCSSRules (Document docRef, CSSInfoPtr css, CHAR_T* buffer, ThotBool withUndo)
1.1 cvs 4540: #else
1.50 cvs 4541: CHAR_T ReadCSSRules (docRef, css, buffer, withUndo)
1.1 cvs 4542: Document docRef;
4543: CSSInfoPtr css;
1.50 cvs 4544: CHAR_T* buffer;
1.14 cvs 4545: ThotBool withUndo;
1.1 cvs 4546: #endif
4547: {
1.50 cvs 4548: CHAR_T c;
4549: CHAR_T *cssRule, *base;
1.6 cvs 4550: DisplayMode dispMode;
1.19 cvs 4551: int index;
1.1 cvs 4552: int CSSindex;
4553: int CSScomment;
4554: int import;
4555: int openRule;
1.14 cvs 4556: ThotBool HTMLcomment;
4557: ThotBool toParse, eof;
1.36 cvs 4558: ThotBool ignoreMedia, media;
1.25 cvs 4559: ThotBool noRule;
1.1 cvs 4560:
4561: CSScomment = MAX_CSS_LENGTH;
4562: HTMLcomment = FALSE;
4563: CSSindex = 0;
4564: toParse = FALSE;
4565: noRule = FALSE;
1.36 cvs 4566: media = FALSE;
1.1 cvs 4567: ignoreMedia = FALSE;
4568: import = MAX_CSS_LENGTH;
4569: eof = FALSE;
4570: openRule = 0;
1.50 cvs 4571: c = WC_SPACE;
1.1 cvs 4572: index = 0;
1.6 cvs 4573: /* avoid too many redisplay */
4574: dispMode = TtaGetDisplayMode (docRef);
4575: if (dispMode == DisplayImmediately)
4576: TtaSetDisplayMode (docRef, DeferredDisplay);
1.18 cvs 4577:
4578: /* look for the CSS context */
4579: if (css == NULL)
4580: css = SearchCSS (docRef, NULL);
4581: if (css == NULL)
4582: css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL);
1.1 cvs 4583:
1.50 cvs 4584: while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof) {
4585: c = buffer[index++];
4586: eof = (c == WC_EOS);
4587: CSSbuffer[CSSindex] = c;
4588: if (CSScomment == MAX_CSS_LENGTH || c == TEXT('*') || c == TEXT('/') || c == TEXT('<')) {
4589: /* we're not within a comment or we're parsing * or / */
4590: switch (c) {
4591: case TEXT('@'): /* perhaps an import primitive */
4592: import = CSSindex;
4593: break;
4594: case TEXT(';'):
4595: if (import != MAX_CSS_LENGTH && !media) {
4596: if (ustrncasecmp (&CSSbuffer[import+1], TEXT("import"), 6))
4597: /* it's not an import */
4598: import = MAX_CSS_LENGTH;
4599: /* save the text */
4600: noRule = TRUE;
4601: }
4602: break;
4603: case TEXT('*'):
4604: if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 && CSSbuffer[CSSindex - 1] == TEXT('/'))
4605: /* start a comment */
4606: CSScomment = CSSindex - 1;
4607: break;
4608: case TEXT('/'):
4609: if (CSSindex > 1 && CSScomment != MAX_CSS_LENGTH && CSSbuffer[CSSindex - 1] == TEXT('*')) {
4610: /* close a comment:and ignore its contents */
4611: CSSindex = CSScomment - 1; /* will be incremented later */
4612: CSScomment = MAX_CSS_LENGTH;
4613: } else if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 && CSSbuffer[CSSindex - 1] == TEXT('<')) {
4614: /* this is the closing tag ! */
4615: CSSindex -= 2; /* remove </ from the CSS string */
4616: noRule = TRUE;
4617: }
4618: break;
4619: case TEXT('<'):
4620: if (CSScomment == MAX_CSS_LENGTH) {
4621: /* only if we're not parsing a comment */
4622: c = buffer[index++];
4623: eof = (c == WC_EOS);
4624: if (c == TEXT('!')) {
4625: /* CSS within an HTML comment */
4626: HTMLcomment = TRUE;
4627: CSSindex++;
4628: CSSbuffer[CSSindex] = c;
4629: } else if (c == WC_EOS)
4630: CSSindex++;
4631: }
4632: break;
4633: case TEXT('-'):
4634: if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == TEXT('-') && HTMLcomment)
4635: /* CSS within an HTML comment */
4636: noRule = TRUE;
4637: break;
4638: case TEXT('>'):
4639: if (HTMLcomment)
4640: noRule = TRUE;
4641: break;
4642: case TEXT(' '):
4643: if (import != MAX_CSS_LENGTH && openRule == 0)
4644: media = !ustrncmp (&CSSbuffer[import+1], TEXT("media"), 5);
4645: break;
4646: case TEXT('{'):
4647: openRule++;
4648: if (import != MAX_CSS_LENGTH && openRule == 1 && media) {
4649: /* is it the screen concerned? */
4650: CSSbuffer[CSSindex+1] = WC_EOS;
4651: if (TtaIsPrinting ())
4652: base = ustrstr (&CSSbuffer[import], TEXT("print"));
4653: else
4654: base = ustrstr (&CSSbuffer[import], TEXT("screen"));
4655: if (base == NULL)
4656: ignoreMedia = TRUE;
4657: noRule = TRUE;
4658: }
4659: break;
4660: case TEXT('}'):
4661: openRule--;
4662: if (import != MAX_CSS_LENGTH && openRule == 0) {
4663: import = MAX_CSS_LENGTH;
4664: noRule = TRUE;
4665: ignoreMedia = FALSE;
4666: media = FALSE;
4667: } else
4668: toParse = TRUE;
4669: break;
4670: default:
4671: break;
4672: }
4673: }
4674: if (c != WC_CR)
4675: CSSindex++;
4676:
4677: if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
4678: /* we're still parsing a comment: remove the text comment */
4679: CSSindex = CSScomment;
4680:
4681: if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule) {
4682: CSSbuffer[CSSindex] = WC_EOS;
4683: /* parse a not empty string */
4684: if (CSSindex > 0) {
4685: /* apply CSS rule if it's not just a saving of text */
4686: if (!noRule && !ignoreMedia)
4687: ParseStyleDeclaration (NULL, CSSbuffer, docRef, css, FALSE);
4688: else if (import != MAX_CSS_LENGTH && !ustrncasecmp (&CSSbuffer[import+1], TEXT("import"), 6)) {
4689: /* import section */
4690: cssRule = &CSSbuffer[import+7];
4691: cssRule = TtaSkipWCBlanks (cssRule);
4692: if (!ustrncasecmp (cssRule, TEXT("url"), 3)) {
4693: cssRule = &cssRule[3];
4694: cssRule = TtaSkipWCBlanks (cssRule);
4695: if (*cssRule == TEXT('(')) {
4696: cssRule++;
4697: cssRule = TtaSkipWCBlanks (cssRule);
4698: base = cssRule;
4699: while (*cssRule != WC_EOS && *cssRule != TEXT(')'))
4700: cssRule++;
4701: *cssRule = WC_EOS;
4702: LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
4703: }
4704: }
4705: /*** Caution: Strings can either be written with double quotes or
4706: with single quotes. Only double quotes are handled here.
4707: Escaped quotes are not handled. See function SkipQuotedString */
4708: else if (*cssRule == TEXT('"')) {
4709: cssRule++;
4710: base = cssRule;
4711: while (*cssRule != WC_EOS && *cssRule != TEXT('"'))
4712: cssRule++;
4713: *cssRule = WC_EOS;
4714: LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
4715: }
4716: import = MAX_CSS_LENGTH;
4717: }
4718: }
4719: toParse = FALSE;
4720: noRule = FALSE;
4721: CSSindex = 0;
4722: }
4723: }
1.6 cvs 4724: /* restore the display mode */
4725: if (dispMode == DisplayImmediately)
1.50 cvs 4726: TtaSetDisplayMode (docRef, dispMode);
1.1 cvs 4727: return (c);
4728: }
Webmaster