version 1.21, 1999/07/13 11:03:41
|
version 1.22, 1999/07/13 11:13:30
|
Line 337 PresentationValue *pval;
|
Line 337 PresentationValue *pval;
|
* * |
* * |
************************************************************************/ |
************************************************************************/ |
|
|
/*---------------------------------------------------------------------- |
|
GetCSSName : return a string corresponding to the CSS name of |
|
an element |
|
----------------------------------------------------------------------*/ |
|
#ifdef __STDC__ |
|
STRING GetCSSName (Element el, Document doc) |
|
#else |
|
STRING GetCSSName (el, doc) |
|
Element el; |
|
Document doc; |
|
#endif |
|
{ |
|
STRING res = GITagName (el); |
|
|
|
/* some kind of filtering is probably needed !!! */ |
|
if (res == NULL) |
|
return (TEXT("unknown")); |
|
return (res); |
|
} |
|
|
|
|
|
/************************************************************************ |
/************************************************************************ |
* * |
* * |
* CORE OF THE CSS PARSER : THESE TAKE THE CSS STRINGS * |
* CORE OF THE CSS PARSER : THESE TAKE THE CSS STRINGS * |
Line 3411 CSSInfoPtr css;
|
Line 3390 CSSInfoPtr css;
|
GIType (attrelemname, &elType, doc); |
GIType (attrelemname, &elType, doc); |
ctxt->attrelem = elType.ElTypeNum; |
ctxt->attrelem = elType.ElTypeNum; |
} |
} |
|
|
GIType (elem, &elType, doc); |
GIType (elem, &elType, doc); |
ctxt->type = elType.ElTypeNum; |
ctxt->type = elType.ElTypeNum; |
ctxt->schema = elType.ElSSchema; |
ctxt->schema = elType.ElSSchema; |
Line 3539 ThotBool destroy;
|
Line 3517 ThotBool destroy;
|
************************************************************************/ |
************************************************************************/ |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
EvaluateClassContext : gives a score for an element in a tree |
|
in function of a selector. Three argument enter in the |
|
evaluation process : |
|
- the class name associated to the element |
|
- the selector string associated to the rule |
|
- the element and it's place in the tree |
|
----------------------------------------------------------------------*/ |
|
#ifdef __STDC__ |
|
int EvaluateClassContext (Element el, STRING class, STRING selector, Document doc) |
|
#else |
|
int EvaluateClassContext (el, class, selector, doc) |
|
Element el; |
|
STRING class; |
|
STRING selector; |
|
Document doc; |
|
#endif |
|
{ |
|
Element father; |
|
STRING elHtmlName; |
|
STRING end_str; |
|
STRING sel = selector; |
|
int result = 0; |
|
|
|
elHtmlName = GetCSSName (el, doc); |
|
|
|
/* look for a selector (ELEM) */ |
|
selector = SkipBlanksAndComments (selector); |
|
if (*selector == '(') |
|
{ |
|
for (end_str = selector; *end_str; end_str++) |
|
if (*end_str == ')') |
|
break; |
|
if (*end_str != ')') |
|
fprintf (stderr, "Unmatched '(' in selector \"%s\"\n", sel); |
|
else |
|
{ |
|
/* |
|
* separate the father name, and evaluate it. |
|
*/ |
|
*end_str = 0; |
|
father = TtaGetParent (el); |
|
result = EvaluateClassContext (father, class, selector + 1, doc); |
|
*end_str = ')'; |
|
|
|
if (result) |
|
{ |
|
/* |
|
* verify that the end of the string match the current element. |
|
*/ |
|
if (EvaluateClassContext (el, class, end_str + 1, doc)) |
|
result *= 10; |
|
else |
|
result = 0; |
|
} |
|
} |
|
} |
|
if (!result) |
|
{ |
|
if (!ustrcasecmp (class, elHtmlName)) |
|
result = 1000; |
|
else if (!ustrcasecmp (class, selector)) |
|
result = 100; |
|
} |
|
return (result); |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
|
EvaluateClassSelector : gives a score for an element in a tree |
|
in function of a selector. Three arguments enter in the |
|
evaluation process: |
|
- the class name associated to the element |
|
- the selector string associated to the rule |
|
- the element and it's place in the tree |
|
----------------------------------------------------------------------*/ |
|
#ifdef __STDC__ |
|
int EvaluateClassSelector (Element el, STRING class, STRING selector, Document doc) |
|
#else |
|
int EvaluateClassSelector (el, class, selector, doc) |
|
Element el; |
|
STRING class; |
|
STRING selector; |
|
Document doc; |
|
#endif |
|
{ |
|
int l = ustrlen (class); |
|
int L = ustrlen (selector); |
|
int val = 0; |
|
|
|
val = EvaluateClassContext (el, class, selector, doc); |
|
if (val) |
|
return (val); |
|
|
|
if (L < l) |
|
return (0); |
|
|
|
/* |
|
* first approximation based on substrings .... :-( !!!!!!!!!! |
|
*/ |
|
while (*selector != 0) |
|
if ((*selector == *class) && (!ustrncmp (class, selector, l))) |
|
return (val = ((l * 1000) / L)); |
|
else |
|
selector++; |
|
|
|
return (val); |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
|
IsImplicitClassName : return wether the Class name is an |
IsImplicitClassName : return wether the Class name is an |
implicit one, eg "H1" or "H2 EM" meaning it's a GI name |
implicit one, eg "H1" or "H2 EM" meaning it's a GI name |
or an HTML context name. |
or an HTML context name. |