Diff for /Amaya/amaya/styleparser.c between versions 1.354 and 1.355

version 1.354, 2006/03/31 06:59:32 version 1.355, 2006/03/31 14:20:19
Line 5642  static char *ParseGenericSelector (char Line 5642  static char *ParseGenericSelector (char
   char              *deb, *cur, *sel, *next, c;    char              *deb, *cur, *sel, *next, c;
   char              *schemaName, *mappedName, *saveURL;    char              *schemaName, *mappedName, *saveURL;
   char              *names[MAX_ANCESTORS];    char              *names[MAX_ANCESTORS];
     ThotBool           pseudoFirstChild[MAX_ANCESTORS];
   ElemRel            rel[MAX_ANCESTORS];    ElemRel            rel[MAX_ANCESTORS];
   char              *attrnames[MAX_ANCESTORS];    char              *attrnames[MAX_ANCESTORS];
   int                attrnums[MAX_ANCESTORS];    int                attrnums[MAX_ANCESTORS];
Line 5665  static char *ParseGenericSelector (char Line 5666  static char *ParseGenericSelector (char
   for (i = 0; i < MAX_ANCESTORS; i++)    for (i = 0; i < MAX_ANCESTORS; i++)
     {      {
       names[i] = NULL;        names[i] = NULL;
         pseudoFirstChild[i] = FALSE;
       rel[i] = RelAncestor;        rel[i] = RelAncestor;
       attrnames[i] = NULL;        attrnames[i] = NULL;
       attrnums[i] = 0;        attrnums[i] = 0;
Line 5672  static char *ParseGenericSelector (char Line 5674  static char *ParseGenericSelector (char
       attrvals[i] = NULL;        attrvals[i] = NULL;
       attrmatch[i] = Txtmatch;        attrmatch[i] = Txtmatch;
       ctxt->name[i] = 0;        ctxt->name[i] = 0;
         ctxt->firstChild[i] = FALSE;
       ctxt->attrType[i] = 0;        ctxt->attrType[i] = 0;
       ctxt->attrLevel[i] = 0;        ctxt->attrLevel[i] = 0;
       ctxt->attrText[i] = NULL;        ctxt->attrText[i] = NULL;
Line 5812  static char *ParseGenericSelector (char Line 5815  static char *ParseGenericSelector (char
               *cur++ = EOS;                *cur++ = EOS;
               /* point to the pseudo-class or pseudo-element in sel[] if it's                /* point to the pseudo-class or pseudo-element in sel[] if it's
                  a valid name */                   a valid name */
               if (deb[0] <= 64)                if (!strcmp (deb, "first-child"))
                   /* first-child pseudo-class */
                 {                  {
                   CSSPrintError ("Invalid pseudo-element", deb);                    pseudoFirstChild[0] = TRUE;
                   DoApply = FALSE;                    specificity += 10;
                 }                  }
               else                else if (!strcmp (deb, "link") || !strcmp (deb, "visited"))
                   /* link or visited pseudo-classes */
                 {                  {
                   if (!strcmp (deb, "first-letter") ||                    nbattrs++;
                       !strcmp (deb, "first-line"))                    if (nbattrs == MAX_ANCESTORS)
                       /* abort parsing */
                     {                      {
                       if (doubleColon)                        CSSPrintError ("Selector too long", deb);
                         CSSPrintError ("Warning: \"::\" is CSS3 syntax", NULL);                        return (selector);
                       /* not supported */  
                       DoApply = FALSE;  
                     }                      }
                   else if (!strcmp (deb, "hover") ||                    for (i = nbattrs; i > 0; i--)
                            !strcmp (deb, "focus"))  
                     /* not supported */  
                     DoApply = FALSE;  
                   else  
                     specificity += 10;  
                   if (!strncmp (deb, "before", 6))  
                     {                      {
                       if (doubleColon)                        attrnames[i] = attrnames[i - 1];
                         CSSPrintError ("Warning: \"::before\" is CSS3 syntax",                        attrnums[i] = attrnums[i - 1];
                                      NULL);                        attrlevels[i] = attrlevels[i - 1];
                       ctxt->pseudo = PbBefore;                        attrvals[i] = attrvals[i - 1];
                     }                        attrmatch[i] = attrmatch[i - 1];
                   else if (!strncmp (deb, "after", 5))  
                     {  
                       if (doubleColon)  
                         CSSPrintError ("Warning: \"::after\" is CSS3 syntax",  
                                        NULL);  
                       ctxt->pseudo = PbAfter;  
                     }                      }
                   else if (!strncmp (deb, "lang", 4))                    attrnames[0] = NULL;
                     /* it's the lang pseudo-class */                    attrnums[0] = ATTR_PSEUDO;
                     attrlevels[0] = 0;
                     attrmatch[0] = Txtmatch;
                     attrvals[0] = deb;
                     specificity += 10;
                   }
                 else if (!strcmp (deb, "hover") || !strcmp (deb, "active") ||
                          !strcmp (deb, "focus"))
                   /* hover, active, focus pseudo-classes */
                   {
                     specificity += 10;
                     /* not supported */
                     DoApply = FALSE;
                   }
                 else if (!strncmp (deb, "lang", 4))
                   /* it's the lang pseudo-class */
                   {
                     if (deb[4] != '(' || deb[strlen(deb)-1] != ')')
                       /* at least one parenthesis is missing. Error */
                     {                      {
                       if (deb[4] != '(' || deb[strlen(deb)-1] != ')')                        CSSPrintError ("Invalid :lang pseudo-class", deb);
                         /* at least one parenthesis is missing. Error */                        DoApply = FALSE;
                         {  
                           CSSPrintError ("Invalid :lang pseudo-class", deb);  
                           DoApply = FALSE;  
                         }  
                       else  
                         /* simulate selector [lang|="xxx"] */  
                         {  
                           nbattrs++;  
                           if (nbattrs == MAX_ANCESTORS)  
                             /* abort parsing */  
                             {  
                               CSSPrintError ("Selector too long", deb);  
                               return (selector);  
                             }  
                           deb[strlen(deb)-1] = EOS;  
                           deb[4] = EOS;  
                           for (i = nbattrs; i > 0; i--)  
                             {  
                               attrnames[i] = attrnames[i - 1];  
                               attrnums[i] = attrnums[i - 1];  
                               attrlevels[i] = attrlevels[i - 1];  
                               attrvals[i] = attrvals[i - 1];  
                               attrmatch[i] = attrmatch[i - 1];  
                             }  
                           attrnames[0] = deb;  
                           attrnums[0] = 0;  
                           attrlevels[0] = 0;  
                           attrmatch[0] = Txtsubstring;  
                           attrvals[0] = &deb[5];  
                         }  
                     }                      }
                   else                    else
                       /* simulate selector [lang|="xxx"] */
                     {                      {
                       nbattrs++;                        nbattrs++;
                       if (nbattrs == MAX_ANCESTORS)                        if (nbattrs == MAX_ANCESTORS)
Line 5892  static char *ParseGenericSelector (char Line 5873  static char *ParseGenericSelector (char
                           CSSPrintError ("Selector too long", deb);                            CSSPrintError ("Selector too long", deb);
                           return (selector);                            return (selector);
                         }                          }
                         deb[strlen(deb)-1] = EOS;
                         deb[4] = EOS;
                       for (i = nbattrs; i > 0; i--)                        for (i = nbattrs; i > 0; i--)
                         {                          {
                           attrnames[i] = attrnames[i - 1];                            attrnames[i] = attrnames[i - 1];
Line 5900  static char *ParseGenericSelector (char Line 5883  static char *ParseGenericSelector (char
                           attrvals[i] = attrvals[i - 1];                            attrvals[i] = attrvals[i - 1];
                           attrmatch[i] = attrmatch[i - 1];                            attrmatch[i] = attrmatch[i - 1];
                         }                          }
                       attrnames[0] = NULL;                        attrnames[0] = deb;
                       attrnums[0] = ATTR_PSEUDO;                        attrnums[0] = 0;
                       attrlevels[0] = 0;                        attrlevels[0] = 0;
                       attrmatch[0] = Txtmatch;                        attrmatch[0] = Txtsubstring;
                       attrvals[0] = deb;                        attrvals[0] = &deb[5];
                         specificity += 10;
                     }                      }
                   if (names[0] && !strcmp (names[0], "*"))  
                     names[0] = NULL;  
                 }                  }
                 else if (!strcmp (deb, "first-line") ||
                          !strcmp (deb, "first-letter"))
                   /* pseudo-elements first-line or first-letter */
                   {
                     if (doubleColon)
                       CSSPrintError ("Warning: \"::\" is CSS3 syntax", NULL);
                     specificity += 1;
                     /* not supported */
                     DoApply = FALSE;
                   }
                 else if (!strncmp (deb, "before", 6))
                   /* pseudo-element before */
                   {
                     if (doubleColon)
                       CSSPrintError ("Warning: \"::before\" is CSS3 syntax",
                                      NULL);
                     ctxt->pseudo = PbBefore;
                     specificity += 1;
                   }
                 else if (!strncmp (deb, "after", 5))
                   /* pseudo-element after */
                   {
                     if (doubleColon)
                       CSSPrintError ("Warning: \"::after\" is CSS3 syntax",
                                      NULL);
                     ctxt->pseudo = PbAfter;
                     specificity += 1;
                   }
                 else
                   {
                     CSSPrintError ("Invalid pseudo-element", deb);
                     DoApply = FALSE;
                   }
                 if (names[0] && !strcmp (names[0], "*"))
                   names[0] = NULL;
             }              }
           else if (*selector == '#')            else if (*selector == '#')
             /* unique identifier */              /* unique identifier */
Line 6154  static char *ParseGenericSelector (char Line 6171  static char *ParseGenericSelector (char
           for (i = nbnames; i > 0; i--)            for (i = nbnames; i > 0; i--)
             {              {
               names[i] = names[i - 1];                names[i] = names[i - 1];
                 pseudoFirstChild[i] = pseudoFirstChild[i - 1];
               rel[i] = rel[i - 1];                rel[i] = rel[i - 1];
             }              }
           /* increase the level of all attributes */            /* increase the level of all attributes */
Line 6174  static char *ParseGenericSelector (char Line 6192  static char *ParseGenericSelector (char
   ctxt->schema = NULL;    ctxt->schema = NULL;
   ctxt->nbElem = nbnames;    ctxt->nbElem = nbnames;
   elType.ElSSchema = NULL;    elType.ElSSchema = NULL;
     elType.ElTypeNum = 0;
   schemaName = TtaGetSSchemaName(TtaGetDocumentSSchema (doc));    schemaName = TtaGetSSchemaName(TtaGetDocumentSSchema (doc));
   if (!strcmp (schemaName, "HTML"))    if (!strcmp (schemaName, "HTML"))
     xmlType = XHTML_TYPE;      xmlType = XHTML_TYPE;
Line 6190  static char *ParseGenericSelector (char Line 6209  static char *ParseGenericSelector (char
   while (i <= nbnames)    while (i <= nbnames)
     {      {
       ctxt->rel[i] = rel[i];        ctxt->rel[i] = rel[i];
       if (!names[i])        ctxt->firstChild[i] = pseudoFirstChild[i];
         if (!names[i] && i > 0)
         ctxt->name[i] = HTML_EL_ANY_TYPE;          ctxt->name[i] = HTML_EL_ANY_TYPE;
       else        else
         /* store element information */          /* store element information */
Line 6200  static char *ParseGenericSelector (char Line 6220  static char *ParseGenericSelector (char
             /* it's a generic XML document. Check the main document schema */              /* it's a generic XML document. Check the main document schema */
             {              {
               elType.ElSSchema = TtaGetDocumentSSchema (doc);                elType.ElSSchema = TtaGetDocumentSSchema (doc);
               TtaGetXmlElementType (names[i], &elType, &mappedName, doc);                elType.ElTypeNum = 0;
                 if (names[i])
                   TtaGetXmlElementType (names[i], &elType, &mappedName, doc);
               if (!elType.ElTypeNum)                if (!elType.ElTypeNum)
                 {                  {
                   if (!strcmp (names[i], "*"))                    if (!names[i] || !strcmp (names[i], "*"))
                     elType.ElTypeNum = HTML_EL_ANY_TYPE;                      elType.ElTypeNum = HTML_EL_ANY_TYPE;
                   else                    else
                     elType.ElSSchema = NULL;                      elType.ElSSchema = NULL;
Line 6211  static char *ParseGenericSelector (char Line 6233  static char *ParseGenericSelector (char
             }              }
           else            else
             {              {
               if (!strcmp (names[i], "*"))                if (!names[i] || !strcmp (names[i], "*"))
                 {                  {
                   elType.ElSSchema = TtaGetDocumentSSchema (doc);                    elType.ElSSchema = TtaGetDocumentSSchema (doc);
                   elType.ElTypeNum = HTML_EL_ANY_TYPE;                    elType.ElTypeNum = HTML_EL_ANY_TYPE;
Line 6226  static char *ParseGenericSelector (char Line 6248  static char *ParseGenericSelector (char
               if (elType.ElSSchema == NULL)                if (elType.ElSSchema == NULL)
                 {                  {
                   /* element name not found. Search in all loaded schemas */                    /* element name not found. Search in all loaded schemas */
                   TtaGetXmlElementType (names[i], &elType, NULL, doc);                    if (names[i])
                       TtaGetXmlElementType (names[i], &elType, NULL, doc);
                   if (elType.ElSSchema)                    if (elType.ElSSchema)
                     {                      {
                       /* the element type concerns an imported nature */                        /* the element type concerns an imported nature */
Line 6256  static char *ParseGenericSelector (char Line 6279  static char *ParseGenericSelector (char
                     {                      {
                       /* Creation of a new element type in the main schema */                        /* Creation of a new element type in the main schema */
                       elType.ElSSchema = TtaGetDocumentSSchema (doc);                        elType.ElSSchema = TtaGetDocumentSSchema (doc);
                       TtaAppendXmlElement (names[i], &elType, &mappedName, doc);                        if (names[i])
                           TtaAppendXmlElement (names[i], &elType, &mappedName,
                                                doc);
                     }                      }
 #endif /* XML_GENERIC */  #endif /* XML_GENERIC */
                   else                    else

Removed from v.1.354  
changed lines
  Added in v.1.355


Webmaster