Annotation of Amaya/amaya/styleparser.c, revision 1.318

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

Webmaster