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

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

Webmaster