version 1.24, 1999/08/27 09:23:58
|
version 1.25, 1999/09/10 07:37:11
|
Line 18
|
Line 18
|
#include "amaya.h" |
#include "amaya.h" |
#include "css.h" |
#include "css.h" |
#include "undo.h" |
#include "undo.h" |
|
#include "fetchHTMLname.h" |
|
|
typedef struct _BackgroundImageCallbackBlock |
typedef struct _BackgroundImageCallbackBlock |
{ |
{ |
Line 62 typedef STRING (*PropertyParser) ();
|
Line 63 typedef STRING (*PropertyParser) ();
|
typedef struct CSSProperty |
typedef struct CSSProperty |
{ |
{ |
STRING name; |
STRING name; |
PropertyParser parsing_function; |
PropertyParser parsing_function; |
} |
} |
CSSProperty; |
CSSProperty; |
|
|
Line 976 ThotBool isHTML;
|
Line 977 ThotBool isHTML;
|
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
|
ParseCSSLineSpacing : parse a CSS font leading string |
|
we expect the input string describing the attribute to be |
|
value% or value |
|
----------------------------------------------------------------------*/ |
|
#ifdef __STDC__ |
|
static STRING ParseCSSLineSpacing (Element element, PSchema tsch, |
|
PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML) |
|
#else |
|
static STRING ParseCSSLineSpacing (element, tsch, context, cssRule, css, isHTML) |
|
Element element; |
|
PSchema tsch; |
|
PresentationContext context; |
|
STRING cssRule; |
|
CSSInfoPtr css; |
|
ThotBool isHTML; |
|
#endif |
|
{ |
|
PresentationValue lead; |
|
|
|
cssRule = ParseCSSUnit (cssRule, &lead); |
|
if (lead.typed_data.unit == STYLE_UNIT_INVALID) |
|
{ |
|
/* invalid line spacing */ |
|
return (cssRule); |
|
} |
|
/* install the new presentation */ |
|
TtaSetStylePresentation (PRLineSpacing, element, tsch, context, lead); |
|
return (cssRule); |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
ParseCSSFontSize : parse a CSS font size attr string |
ParseCSSFontSize : parse a CSS font size attr string |
we expect the input string describing the attribute to be |
we expect the input string describing the attribute to be |
xx-small, x-small, small, medium, large, x-large, xx-large |
xx-small, x-small, small, medium, large, x-large, xx-large |
Line 995 ThotBool isHTML;
|
Line 1027 ThotBool isHTML;
|
#endif |
#endif |
{ |
{ |
PresentationValue pval; |
PresentationValue pval; |
|
STRING ptr = NULL; |
ThotBool real; |
ThotBool real; |
|
|
pval.typed_data.real = FALSE; |
pval.typed_data.real = FALSE; |
Line 1055 ThotBool isHTML;
|
Line 1088 ThotBool isHTML;
|
} |
} |
else |
else |
{ |
{ |
|
/* look for a '/' within the current cssRule */ |
|
ptr = ustrchr (cssRule, TEXT('/')); |
|
if (ptr != NULL) |
|
{ |
|
/* keep the line spacing rule */ |
|
ptr[0] = EOS; |
|
ptr = &ptr[1]; |
|
} |
cssRule = ParseCSSUnit (cssRule, &pval); |
cssRule = ParseCSSUnit (cssRule, &pval); |
if (pval.typed_data.unit == STYLE_UNIT_INVALID || |
if (pval.typed_data.unit == STYLE_UNIT_INVALID || |
pval.typed_data.value < 0) |
pval.typed_data.value < 0) |
Line 1078 ThotBool isHTML;
|
Line 1119 ThotBool isHTML;
|
pval.typed_data.unit = STYLE_UNIT_PERCENT; |
pval.typed_data.unit = STYLE_UNIT_PERCENT; |
} |
} |
} |
} |
|
|
} |
} |
|
|
/* install the attribute */ |
/* install the presentation style */ |
TtaSetStylePresentation (PRSize, element, tsch, context, pval); |
TtaSetStylePresentation (PRSize, element, tsch, context, pval); |
|
|
|
if (ptr != NULL) |
|
cssRule = ParseCSSLineSpacing (element, tsch, context, ptr, css, isHTML); |
return (cssRule); |
return (cssRule); |
} |
} |
|
|
Line 1431 ThotBool isHTML;
|
Line 1476 ThotBool isHTML;
|
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
ParseCSSLineSpacing : parse a CSS font leading string |
|
we expect the input string describing the attribute to be |
|
value% or value |
|
----------------------------------------------------------------------*/ |
|
#ifdef __STDC__ |
|
static STRING ParseCSSLineSpacing (Element element, PSchema tsch, |
|
PresentationContext context, STRING cssRule, CSSInfoPtr css, ThotBool isHTML) |
|
#else |
|
static STRING ParseCSSLineSpacing (element, tsch, context, cssRule, css, isHTML) |
|
Element element; |
|
PSchema tsch; |
|
PresentationContext context; |
|
STRING cssRule; |
|
CSSInfoPtr css; |
|
ThotBool isHTML; |
|
#endif |
|
{ |
|
PresentationValue lead; |
|
|
|
cssRule = ParseCSSUnit (cssRule, &lead); |
|
if (lead.typed_data.unit == STYLE_UNIT_INVALID) |
|
{ |
|
/* invalid line spacing */ |
|
return (cssRule); |
|
} |
|
/* |
|
* install the new presentation. |
|
*/ |
|
TtaSetStylePresentation (PRLineSpacing, element, tsch, context, lead); |
|
return (cssRule); |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
|
ParseCSSTextDecoration : parse a CSS text decor string |
ParseCSSTextDecoration : parse a CSS text decor string |
we expect the input string describing the attribute to be |
we expect the input string describing the attribute to be |
underline, overline, line-through, box, shadowbox, box3d, |
underline, overline, line-through, box, shadowbox, box3d, |
Line 1701 PresentationValue *val;
|
Line 1713 PresentationValue *val;
|
} |
} |
|
|
if (failed) |
if (failed) |
val->typed_data.value = 0; |
{ |
|
val->typed_data.value = 0; |
|
val->typed_data.unit = STYLE_UNIT_INVALID; |
|
} |
else |
else |
{ |
{ |
best = TtaGetThotColor (redval, greenval, blueval); |
best = TtaGetThotColor (redval, greenval, blueval); |
Line 2075 ThotBool isHTML;
|
Line 2090 ThotBool isHTML;
|
PresentationValue best; |
PresentationValue best; |
|
|
cssRule = ParseCSSColor (cssRule, &best); |
cssRule = ParseCSSColor (cssRule, &best); |
|
if (best.typed_data.unit != STYLE_UNIT_INVALID) |
if (best.typed_data.unit == STYLE_UNIT_INVALID) |
/* install the new presentation */ |
{ |
TtaSetStylePresentation (PRForeground, element, tsch, context, best); |
return (cssRule); |
|
} |
|
/* |
|
* install the new presentation. |
|
*/ |
|
TtaSetStylePresentation (PRForeground, element, tsch, context, best); |
|
return (cssRule); |
return (cssRule); |
} |
} |
|
|
Line 2287 ThotBool isHTML;
|
Line 2296 ThotBool isHTML;
|
PresentationValue image, value; |
PresentationValue image, value; |
STRING url; |
STRING url; |
STRING bg_image; |
STRING bg_image; |
CHAR_T saved; |
CHAR_T saved; |
STRING base; |
STRING base; |
CHAR_T tempname[MAX_LENGTH]; |
CHAR_T tempname[MAX_LENGTH]; |
CHAR_T imgname[MAX_LENGTH]; |
CHAR_T imgname[MAX_LENGTH]; |
unsigned int savedtype = 0; |
unsigned int savedtype = 0; |
ThotBool moved; |
ThotBool moved; |
|
|
Line 3097 ThotBool destroy;
|
Line 3106 ThotBool destroy;
|
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
ParseHTMLGenericSelector : Create a generic context for a given |
ParseGenericSelector : Create a generic context for a given |
selector string. If the selector is made of multiple comma- |
selector string. If the selector is made of multiple comma- |
separated selector items, it parses them one at a time and |
separated selector items, it parses them one at a time and |
return the end of the selector string to be handled or NULL |
return the end of the selector string to be handled or NULL |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
static STRING ParseHTMLGenericSelector (STRING selector, STRING cssRule, |
static STRING ParseGenericSelector (STRING selector, STRING cssRule, |
GenericContext ctxt, Document doc, CSSInfoPtr css) |
GenericContext ctxt, Document doc, CSSInfoPtr css) |
#else |
#else |
static STRING ParseHTMLGenericSelector (selector, cssRule, ctxt, doc, css) |
static STRING ParseGenericSelector (selector, cssRule, ctxt, doc, css) |
STRING selector; |
STRING selector; |
STRING cssRule; |
STRING cssRule; |
GenericContext ctxt; |
GenericContext ctxt; |
Line 3116 CSSInfoPtr css;
|
Line 3125 CSSInfoPtr css;
|
{ |
{ |
ElementType elType; |
ElementType elType; |
PSchema tsch; |
PSchema tsch; |
CHAR_T sel[150]; |
AttributeType attrType; |
CHAR_T class[150]; |
CHAR_T sel[MAX_ANCESTORS * 50]; |
CHAR_T pseudoclass[150]; |
STRING deb, cur; |
CHAR_T id[150]; |
STRING structName; |
CHAR_T attrelemname[150]; |
STRING names[MAX_ANCESTORS]; |
STRING deb; |
STRING ids[MAX_ANCESTORS]; |
STRING elem, structName; |
STRING classes[MAX_ANCESTORS]; |
STRING cur; |
STRING pseudoclasses[MAX_ANCESTORS]; |
STRING ancestors[MAX_ANCESTORS]; |
STRING attrs[MAX_ANCESTORS]; |
int i, j; |
STRING attrvals[MAX_ANCESTORS]; |
ThotBool isHTML, classOnly; |
int i, j, k, max; |
|
ThotBool isHTML; |
|
|
sel[0] = EOS; |
sel[0] = EOS; |
class[0] = EOS; |
|
pseudoclass[0] = EOS; |
|
id[0] = EOS; |
|
classOnly = FALSE; |
|
attrelemname[0] = EOS; |
|
deb = cur = elem = &sel[0]; |
|
for (i = 0; i < MAX_ANCESTORS; i++) |
for (i = 0; i < MAX_ANCESTORS; i++) |
{ |
{ |
ancestors[i] = NULL; |
names[i] = NULL; |
ctxt->ancestors[i] = 0; |
ids[i] = NULL; |
ctxt->ancestors_nb[i] = 0; |
classes[i] = NULL; |
|
pseudoclasses[i] = NULL; |
|
attrs[i] = NULL; |
|
attrvals[i] = NULL; |
|
|
|
ctxt->name[i] = 0; |
|
ctxt->names_nb[i] = 0; |
|
ctxt->attrType[i] = 0; |
|
ctxt->attrText[i] = NULL; |
} |
} |
|
ctxt->box = 0; |
/* first format the first selector item, uniformizing blanks */ |
ctxt->type = 0; |
|
|
selector = SkipBlanksAndComments (selector); |
selector = SkipBlanksAndComments (selector); |
|
deb = cur = &sel[0]; |
|
max = 0; /* number of loops */ |
while (1) |
while (1) |
{ |
{ |
|
/* copy an item of the selector into sel[] */ |
cur = deb; |
cur = deb; |
/* put one word in the sel buffer */ |
/* put one word in the sel buffer */ |
while (*selector != EOS && *selector != ',' && |
while (*selector != EOS && *selector != ',' && |
*selector != '.' && *selector != ':' && |
*selector != '.' && *selector != ':' && |
*selector != '#' && !TtaIsBlank (selector)) |
*selector != '#' && !TtaIsBlank (selector)) |
*cur++ = *selector++; |
*cur++ = *selector++; |
*cur++ = EOS; |
*cur++ = EOS; /* close the first string in sel[] */ |
|
if (deb[0] != EOS) |
/* now deb points to the parsed type and cur to the next chain to be parsed */ |
names[max] = deb; |
elem = deb; |
else |
|
names[max] = NULL; |
|
classes[max] = NULL; |
|
pseudoclasses[max] = NULL; |
|
ids[max] = NULL; |
|
attrs[max] = NULL; |
|
attrvals[max] = NULL; |
|
|
|
/* now names[max] points to the beginning of the parsed item |
|
and cur to the next chain to be parsed */ |
if (*selector == ':' || *selector == '.' || *selector == '#') |
if (*selector == ':' || *selector == '.' || *selector == '#') |
/* keep the name as attrelemname */ |
/* keep the element name which precedes the id or |
ustrcpy (attrelemname, elem); |
pseudo class or the class */ |
deb = cur; |
deb = cur; |
|
|
if (*selector == '.') |
if (*selector == '.') |
{ |
{ |
/* read the class id : only one allowed by selector */ |
/* copy into sel[] the class */ |
class[0] = EOS; |
classes[max] = cur; |
cur = class; |
|
classOnly = (elem == NULL || *elem == EOS); |
|
selector++; |
selector++; |
while (*selector != EOS && *selector != ',' && |
while (*selector != EOS && *selector != ',' && |
*selector != '.' && *selector != ':' && |
*selector != '.' && *selector != ':' && |
Line 3176 CSSInfoPtr css;
|
Line 3199 CSSInfoPtr css;
|
} |
} |
else if (*selector == ':') |
else if (*selector == ':') |
{ |
{ |
/* read the pseudoclass id : only one allowed by selector */ |
/* copy into sel[] the pseudoclass */ |
pseudoclass[0] = EOS; |
pseudoclasses[max]= cur; |
cur = pseudoclass; |
|
selector++; |
selector++; |
while (*selector != EOS && *selector != ',' && |
while (*selector != EOS && *selector != ',' && |
*selector != '.' && *selector != ':' && |
*selector != '.' && *selector != ':' && |
Line 3189 CSSInfoPtr css;
|
Line 3211 CSSInfoPtr css;
|
} |
} |
else if (*selector == '#') |
else if (*selector == '#') |
{ |
{ |
/* read the id : only one allowed by selector */ |
/* copy into sel[] the attribute */ |
id[0] = EOS; |
ids[max] = cur; |
cur = &id[0]; |
|
selector++; |
selector++; |
while (*selector != EOS && *selector != ',' && |
while (*selector != EOS && *selector != ',' && |
*selector != '.' && *selector != ':' && |
*selector != '.' && *selector != ':' && |
Line 3200 CSSInfoPtr css;
|
Line 3221 CSSInfoPtr css;
|
*cur++ = EOS; |
*cur++ = EOS; |
cur = deb; |
cur = deb; |
} |
} |
else if (TtaIsBlank (selector)) |
else if (*selector == '[') |
{ |
{ |
selector = SkipBlanksAndComments (selector); |
/* copy into sel[] the attribute */ |
/* Thot can not take class and pseudoclass into account for |
attrs[max] = cur; |
ancestors. Ignore this selector */ |
selector++; |
class[0] = EOS; |
while (*selector != EOS && *selector != ']' && *selector != '=') |
pseudoclass[0] = EOS; |
*cur++ = *selector++; |
id[0] = EOS; |
if (*cur == '=') |
if (attrelemname[0] != EOS) |
{ |
{ |
/* there is a value "xxxx" */ |
ancestors[0] = NULL; |
*cur++ = EOS; |
while (*selector != EOS && *selector != ',') |
while (*selector != EOS && *selector != ']' && *selector != '"') |
selector++; |
selector++; |
break; |
if (*selector != EOS) |
} |
{ |
|
/* we are now parsing the attribute value */ |
|
attrvals[max] = cur; |
|
selector++; |
|
while (*selector != EOS && *selector != '"') |
|
*cur++ = *selector++; |
|
if (*selector != EOS) |
|
selector++; |
|
} |
|
} |
|
*cur++ = EOS; |
|
cur = deb; |
} |
} |
|
|
/* store elem in the list if the string is non-empty */ |
if (TtaIsBlank (selector)) |
if (*elem != EOS) |
|
{ |
{ |
/* shifts the list to make room for the new elem */ |
selector = SkipBlanksAndComments (selector); |
for (i = MAX_ANCESTORS - 1; i > 0; i--) |
while (*selector != EOS && *selector != ',') |
if (ancestors[i - 1] != NULL) |
selector++; |
ancestors[i] = ancestors[i - 1]; |
|
/* store the new elem */ |
|
ancestors[0] = elem; |
|
} |
} |
|
|
/* why did we stop ? */ |
/* is it a multi-level selector? */ |
if (*selector == EOS) |
if (*selector == EOS) |
/* end of the selector */ |
/* end of the selector */ |
break; |
break; |
Line 3238 CSSInfoPtr css;
|
Line 3266 CSSInfoPtr css;
|
selector++; |
selector++; |
break; |
break; |
} |
} |
|
else |
|
{ |
|
/* shifts the list to make room for the new name */ |
|
max++; /* a new level in ancestor tables */ |
|
if (max == MAX_ANCESTORS) |
|
/* abort the CSS parsing */ |
|
return (selector); |
|
for (i = max; i > 0; i--) |
|
{ |
|
names[i] = names[i - 1]; |
|
ids[i] = ids[i - 1]; |
|
classes[i] = classes[i - 1]; |
|
attrs[i] = attrs[i - 1]; |
|
attrvals[i] = attrvals[i - 1]; |
|
pseudoclasses[i] = pseudoclasses[i - 1]; |
|
} |
|
} |
} |
} |
|
|
/* Now set up the context block */ |
/* Now set up the context block */ |
ctxt->box = 0; |
i = 0; |
elem = ancestors[0]; |
k = 0; |
if (elem == NULL || elem[0] == EOS) |
j = 0; |
{ |
while (i <= max) |
if (class[0] != EOS) |
{ |
elem = &class[0]; |
if (names[i]) |
else if (pseudoclass[0] != EOS) |
{ |
elem = &pseudoclass[0]; |
/* get the new element type of this name */ |
else if (id[0] != EOS) |
GIType (names[i], &elType, doc); |
elem = &id[0]; |
if (i == 0) |
|
{ |
|
/* Store the element type */ |
|
ctxt->type = elType.ElTypeNum; |
|
ctxt->schema = elType.ElSSchema; |
|
} |
|
else if (elType.ElTypeNum != 0) |
|
{ |
|
/* look at the current context to see if the type is already |
|
stored */ |
|
j = 0; |
|
while (j < k && ctxt->name[j] != ctxt->name[i]) |
|
j++; |
|
if (j == k) |
|
{ |
|
/* add a new entry */ |
|
k++; |
|
ctxt->name[j] = elType.ElTypeNum; |
|
if (j != 0) |
|
ctxt->names_nb[j] = 1; |
|
} |
|
else |
|
/* increment the number of ancestor levels */ |
|
ctxt->names_nb[j]++; |
|
} |
|
else |
|
{ |
|
/* add a new entry */ |
|
j = k; |
|
k++; |
|
} |
|
} |
else |
else |
|
{ |
|
/* add a new entry */ |
|
j = k; |
|
k++; |
|
} |
|
|
|
if (i > 0 && (classes[i] || pseudoclasses[i] || ids[i] || attrs[i])) |
|
/* Thot is not able to manage this kind of selector |
|
-> abort the CSS parsing */ |
return (selector); |
return (selector); |
} |
|
|
|
if (class[0] != EOS) |
/* store attributes information */ |
{ |
if (classes[i]) |
ctxt->class = class; |
{ |
ctxt->classattr = HTML_ATTR_Class; |
ctxt->attrText[j] = classes[i]; |
} |
ctxt->attrType[j] = HTML_ATTR_Class; |
else if (pseudoclass[0] != EOS) |
} |
{ |
else if (pseudoclasses[i]) |
ctxt->class = pseudoclass; |
{ |
ctxt->classattr = HTML_ATTR_PseudoClass; |
ctxt->attrText[j] = pseudoclasses[i]; |
} |
ctxt->attrType[j] = HTML_ATTR_PseudoClass; |
else if (id[0] != EOS) |
} |
{ |
else if (ids[i]) |
ctxt->class = id; |
{ |
ctxt->classattr = HTML_ATTR_ID; |
ctxt->attrText[j] = ids[i]; |
} |
ctxt->attrType[j] = HTML_ATTR_ID; |
else |
} |
{ |
else if (attrs[i]) |
ctxt->class = NULL; |
{ |
ctxt->classattr = 0; |
MapHTMLAttribute (attrs[i], &attrType, names[i], doc); |
|
ctxt->attrText[j] = attrvals[i]; |
|
ctxt->attrType[j] = attrType.AttrTypeNum; |
|
} |
|
i++; |
} |
} |
|
|
ctxt->type = ctxt->attr = ctxt->attrval = ctxt->attrelem = 0; |
/* sort the list of ancestors by name order */ |
if (attrelemname[0] != EOS) |
max = k; |
{ |
i = 1; |
GIType (attrelemname, &elType, doc); |
while (i < max) |
ctxt->attrelem = elType.ElTypeNum; |
for (k = i + 1; k < max; k++) |
} |
if (ctxt->name[i] > ctxt->name[k]) |
GIType (elem, &elType, doc); |
{ |
ctxt->type = elType.ElTypeNum; |
j = ctxt->name[i]; |
ctxt->schema = elType.ElSSchema; |
ctxt->name[i] = ctxt->name[k]; |
if (elType.ElSSchema == NULL) |
ctxt->name[k] = j; |
|
j = ctxt->names_nb[i]; |
|
ctxt->names_nb[i] = ctxt->names_nb[k]; |
|
ctxt->names_nb[k] = j; |
|
j = ctxt->attrType[i]; |
|
ctxt->attrType[i] = ctxt->attrType[k]; |
|
ctxt->attrType[k] = j; |
|
cur = ctxt->attrText[i]; |
|
ctxt->attrText[i] = ctxt->attrText[k]; |
|
ctxt->attrText[k] = cur; |
|
} |
|
|
|
/* Get the schema name of the main element */ |
|
if (ctxt->schema == NULL) |
ctxt->schema = TtaGetDocumentSSchema (doc); |
ctxt->schema = TtaGetDocumentSSchema (doc); |
isHTML = (ustrcmp(TtaGetSSchemaName (ctxt->schema), TEXT("HTML")) == 0); |
isHTML = (ustrcmp(TtaGetSSchemaName (ctxt->schema), TEXT("HTML")) == 0); |
tsch = GetPExtension (doc, ctxt->schema, css); |
tsch = GetPExtension (doc, ctxt->schema, css); |
structName = TtaGetSSchemaName (ctxt->schema); |
structName = TtaGetSSchemaName (ctxt->schema); |
if (ctxt->type == 0 && ctxt->attr == 0 && |
|
ctxt->attrval == 0 && ctxt->classattr == 0) |
|
{ |
|
ctxt->class = elem; |
|
ctxt->classattr = HTML_ATTR_Class; |
|
} |
|
|
|
if (classOnly) |
|
i = 0; |
|
else |
|
i = 1; |
|
while (i < MAX_ANCESTORS && ancestors[i] != NULL) |
|
{ |
|
GIType (ancestors[i], &elType, doc); |
|
if (elType.ElTypeNum != 0) |
|
{ |
|
for (j = 0; j < MAX_ANCESTORS; j++) |
|
{ |
|
if (ctxt->ancestors[j] == 0) |
|
{ |
|
ctxt->ancestors[j] = elType.ElTypeNum; |
|
ctxt->ancestors_nb[j] = 0; |
|
break; |
|
} |
|
if (ctxt->ancestors[j] == elType.ElTypeNum) |
|
{ |
|
ctxt->ancestors_nb[j]++; |
|
break; |
|
} |
|
} |
|
} |
|
i++; |
|
} |
|
|
|
if (cssRule) |
if (cssRule) |
ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML); |
ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML); |
return (selector); |
return (selector); |
Line 3394 ThotBool destroy;
|
Line 3461 ThotBool destroy;
|
ctxt->destroy = destroy; |
ctxt->destroy = destroy; |
|
|
while ((selector != NULL) && (*selector != EOS)) |
while ((selector != NULL) && (*selector != EOS)) |
selector = ParseHTMLGenericSelector (selector, cssRule, ctxt, doc, css); |
selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css); |
TtaFreeMemory (ctxt); |
TtaFreeMemory (ctxt); |
|
|
/* restore the string to its original form ! */ |
/* restore the string to its original form ! */ |
Line 3421 STRING class;
|
Line 3488 STRING class;
|
Document doc; |
Document doc; |
#endif |
#endif |
{ |
{ |
CHAR_T name[200]; |
CHAR_T name[200]; |
STRING cur = &name[0], first; |
STRING cur = name, first; |
CHAR_T save; |
CHAR_T save; |
SSchema schema; |
SSchema schema; |
|
|
/* make a local copy */ |
/* make a local copy */ |
Line 3733 ThotBool withUndo;
|
Line 3800 ThotBool withUndo;
|
ThotBool HTMLcomment; |
ThotBool HTMLcomment; |
ThotBool toParse, eof; |
ThotBool toParse, eof; |
ThotBool ignoreMedia; |
ThotBool ignoreMedia; |
ThotBool noRule, CSSparsing; |
ThotBool noRule; |
|
|
CSScomment = MAX_CSS_LENGTH; |
CSScomment = MAX_CSS_LENGTH; |
HTMLcomment = FALSE; |
HTMLcomment = FALSE; |
CSSindex = 0; |
CSSindex = 0; |
CSSparsing = TRUE; |
|
toParse = FALSE; |
toParse = FALSE; |
noRule = FALSE; |
noRule = FALSE; |
ignoreMedia = FALSE; |
ignoreMedia = FALSE; |
Line 3758 ThotBool withUndo;
|
Line 3824 ThotBool withUndo;
|
if (css == NULL) |
if (css == NULL) |
css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL); |
css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL); |
|
|
while (CSSindex < MAX_CSS_LENGTH && c != EOS && CSSparsing && !eof) |
while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof) |
{ |
{ |
c = buffer[index++]; |
c = buffer[index++]; |
eof = (c == EOS); |
eof = (c == EOS); |
Line 3793 ThotBool withUndo;
|
Line 3859 ThotBool withUndo;
|
CSScomment != MAX_CSS_LENGTH && |
CSScomment != MAX_CSS_LENGTH && |
CSSbuffer[CSSindex - 1] == '*') |
CSSbuffer[CSSindex - 1] == '*') |
{ |
{ |
/* close a comment */ |
/* close a comment:and ignore its contents */ |
cur = TtaSkipBlanks (CSSbuffer); |
CSSindex = CSScomment - 1; /* will be incremented later */ |
if (cur == &CSSbuffer[CSScomment]) |
|
/* the CSS buffer includes only a comment */ |
|
noRule = TRUE; |
|
/* other comments are managed later */ |
|
CSScomment = MAX_CSS_LENGTH; |
CSScomment = MAX_CSS_LENGTH; |
} |
} |
else if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '<') |
else if (CSScomment == MAX_CSS_LENGTH && |
|
CSSindex > 0 && |
|
CSSbuffer[CSSindex - 1] == '<') |
{ |
{ |
/* this is the closing tag ! */ |
/* this is the closing tag ! */ |
CSSparsing = FALSE; |
|
CSSindex -= 2; /* remove </ from the CSS string */ |
CSSindex -= 2; /* remove </ from the CSS string */ |
noRule = TRUE; |
noRule = TRUE; |
} |
} |
break; |
break; |
case '<': |
case '<': |
c = buffer[index++]; |
if (CSScomment == MAX_CSS_LENGTH) |
eof = (c == EOS); |
|
if (c == '!' && CSScomment == MAX_CSS_LENGTH) |
|
{ |
|
/* CSS within an HTML comment */ |
|
HTMLcomment = TRUE; |
|
CSSindex++; |
|
CSSbuffer[CSSindex] = c; |
|
} |
|
else if (c == '/') |
|
{ |
{ |
CSSindex--; |
/* only if we're not parsing a comment */ |
/* Ok we consider this as a closing tag ! */ |
c = buffer[index++]; |
CSSparsing = FALSE; |
eof = (c == EOS); |
|
if (c == '!') |
|
{ |
|
/* CSS within an HTML comment */ |
|
HTMLcomment = TRUE; |
|
CSSindex++; |
|
CSSbuffer[CSSindex] = c; |
|
} |
|
else if (c == EOS) |
|
CSSindex++; |
} |
} |
else if (c == EOS) |
|
CSSindex++; |
|
break; |
break; |
case '-': |
case '-': |
if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' && HTMLcomment) |
if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' && HTMLcomment) |
Line 3843 ThotBool withUndo;
|
Line 3904 ThotBool withUndo;
|
{ |
{ |
/* is it the screen concerned? */ |
/* is it the screen concerned? */ |
CSSbuffer[CSSindex+1] = EOS; |
CSSbuffer[CSSindex+1] = EOS; |
base = ustrstr (&CSSbuffer[import], TEXT("screen")); |
if (TtaIsPrinting ()) |
|
base = ustrstr (&CSSbuffer[import], TEXT("print")); |
|
else |
|
base = ustrstr (&CSSbuffer[import], TEXT("screen")); |
if (base == NULL) |
if (base == NULL) |
ignoreMedia = TRUE; |
ignoreMedia = TRUE; |
noRule = TRUE; |
noRule = TRUE; |
Line 3872 ThotBool withUndo;
|
Line 3936 ThotBool withUndo;
|
if (c != __CR__) |
if (c != __CR__) |
CSSindex++; |
CSSindex++; |
|
|
if (CSSindex >= MAX_CSS_LENGTH || !CSSparsing || toParse || noRule) |
if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule) |
{ |
{ |
|
if (CSScomment < MAX_CSS_LENGTH) |
|
{ |
|
/* we're still parsing a comment: remove the text comment */ |
|
CSSindex = CSScomment; |
|
/* set the origin of the comment in the next buffer */ |
|
CSScomment = 0; |
|
} |
CSSbuffer[CSSindex] = EOS; |
CSSbuffer[CSSindex] = EOS; |
/* parse a not empty string */ |
/* parse a not empty string */ |
if (CSSindex > 0) |
if (CSSindex > 0) |