13#include "../dlib/dlib.h"
21 fprintf (stderr,
"%s - %d\n",
32 for (
int i = 0; i <
size (); i++) {
51 for (
int i = 0; i <
size (); i++)
65 for (
int i = 0; i <
size (); i++) {
68 if (prop->
name == name) {
88 for (
int i = 0; i <
size (); i++) {
103 for (
int i = 0; i <
size (); i++)
129 int *matchCacheEntry;
142 node = docTree->
parent (node);
145 node = docTree->
sibling (node);
148 node = docTree->
parent (node);
152 n && n->
num > *matchCacheEntry; n = docTree->
parent (n))
153 if (sel->
match (n) &&
158 *matchCacheEntry = node->
num;
166 if (!node || !sel->
match (node))
186 if (
selectorList.getRef (i)->selector->getPseudoClass ())
201 spec +=
selectorList.getRef (i)->selector->specificity ();
213 fprintf (stderr,
"> ");
216 fprintf (stderr,
"\" \" ");
219 fprintf (stderr,
"+ ");
222 fprintf (stderr,
"? ");
228 fprintf (stderr,
"\n");
276 for (
int i = 0; i <
klass.
size (); i++) {
278 if (n->
klass != NULL) {
279 for (
int j = 0; j < n->
klass->
size (); j++) {
313 fprintf (stderr,
"Element %d, pseudo %s, id %s ",
315 fprintf (stderr,
"class ");
317 fprintf (stderr,
".%s",
klass.
get (i));
324 this->selector->
ref ();
358 while (i > 0 && rule->
specificity () <
get (i - 1)->specificity ()) {
380 if (ruleList == NULL) {
389 if (ruleList == NULL) {
419 static const int maxLists = 32;
421 int numLists = 0, index[maxLists] = {0};
427 if (ruleList[numLists])
432 for (
int i = 0; i < node->
klass->
size (); i++) {
433 if (i >= maxLists - 4) {
434 MSG_WARN(
"Maximum number of classes per element exceeded.\n");
441 if (ruleList[numLists])
447 if (ruleList[numLists])
451 if (ruleList[numLists])
459 int minSpec = 1 << 30;
460 int minPos = 1 << 30;
461 int minSpecIndex = -1;
463 for (
int i = 0; i < numLists; i++) {
466 if (rl && rl->
size () > index[i] &&
477 if (minSpecIndex >= 0) {
478 CssRule *rule = ruleList[minSpecIndex]->
get (index[minSpecIndex]);
479 rule->
apply(props, docTree, node, matchCache);
480 index[minSpecIndex]++;
491 matchCache.setSize (userAgentSheet.getRequiredMatchCache (), -1);
508 userAgentSheet.
apply (props, docTree, node, &matchCache);
513 nonCssHints->
apply (props);
518 tagStyle->
apply (props);
523 if (tagStyleImportant)
524 tagStyleImportant->
apply (props);
532 if (props->
size () > 0) {
538 _MSG_WARN (
"Ignoring unsafe author style that might reveal browsing history\n");
546 userAgentSheet.addRule (rule);
548 sheet[order].addRule (rule);
void apply(CssPropertyList *props, Doctree *docTree, DoctreeNode *node, CssPropertyList *tagStyle, CssPropertyList *tagStyleImportant, CssPropertyList *nonCssHints)
Apply a CSS context to a property list.
void addRule(CssSelector *sel, CssPropertyList *props, CssPrimaryOrder order)
static CssStyleSheet userAgentSheet
static const char * propertyNameString(CssPropertyName name)
A list of CssProperty objects.
void set(CssPropertyName name, CssValueType type, CssPropertyValue value)
Set property to a given name and type.
CssPropertyList(bool ownerOfStrings=false)
void apply(CssPropertyList *props)
Merge properties into argument property list.
This class holds a CSS property and value pair.
A CssSelector CssPropertyList pair.
void apply(CssPropertyList *props, Doctree *docTree, const DoctreeNode *node, MatchCache *matchCache) const
CssRule(CssSelector *selector, CssPropertyList *props, int pos)
CssSimpleSelector * top()
bool match(Doctree *dt, const DoctreeNode *node, int i, Combinator comb, MatchCache *matchCache)
Return whether selector matches at a given node in the document tree.
void addSimpleSelector(Combinator c)
lout::misc::SimpleVector< struct CombinatorAndSelector > selectorList
int getRequiredMatchCache()
void setMatchCacheOffset(int mo)
int specificity()
Return the specificity of the selector.
bool match(const DoctreeNode *node)
Return whether simple selector matches at a given node of the document tree.
int specificity()
Return the specificity of the simple selector.
void setSelect(SelectType t, const char *v)
lout::misc::SimpleVector< char * > * getClass()
lout::misc::SimpleVector< char * > klass
void insert(CssRule *rule)
void addRule(CssRule *rule)
Insert a rule into CssStyleSheet.
RuleList elementTable[ntags]
void apply(CssPropertyList *props, Doctree *docTree, const DoctreeNode *node, MatchCache *matchCache) const
Apply a stylesheet to a property list.
lout::misc::SimpleVector< char * > * klass
HTML document tree interface.
DoctreeNode * parent(const DoctreeNode *node)
DoctreeNode * sibling(const DoctreeNode *node)
void put(K *key, V *value)
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
void increase()
Increase the vector size by one.
void set(int i, T t)
Store an object in the vector.
T get(int i) const
Return the one element, explicitly.
int size() const
Return the number of elements put into this vector.
CssProperty * getRef(int i) const
Return the reference of one element.
An object::Object wrapper for constant strings (char*).
@ CSS_PROPERTY_BACKGROUND_IMAGE
@ CSS_TYPE_STRING
<string>
@ CSS_TYPE_SYMBOL
Symbols, which are directly copied (as opposed to CSS_TYPE_ENUM and CSS_TYPE_MULTI_ENUM).
@ CSS_PRIMARY_USER_IMPORTANT
@ CSS_PRIMARY_AUTHOR_IMPORTANT
int dStrAsciiCasecmp(const char *s1, const char *s2)
char * dStrdup(const char *s)
Anything related to Dillo Widget styles is defined here.
CssSimpleSelector * selector