diff options
Diffstat (limited to 'src/css.cc')
-rw-r--r-- | src/css.cc | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -20,3 +20,44 @@ void CssProperty::apply (dw::core::style::StyleAttrs *styleAttrs) { break; } } + +void CssPropertyList::apply (dw::core::style::StyleAttrs *styleAttrs) { + for (int i = 0; i < size (); i++) + get (i)->apply (styleAttrs); +} + +bool CssSelector::match (Doctree *docTree) { + return tagIndex < 0 || tagIndex == docTree->top ()->tagIndex; +} + +void CssRule::apply (dw::core::style::StyleAttrs *styleAttrs, + Doctree *docTree) { + + if (selector->match (docTree)) + props->apply (styleAttrs); +} + +void CssStyleSheet::apply (dw::core::style::StyleAttrs *styleAttrs, + Doctree *docTree) { + + for (int i = 0; i < size (); i++) + get (i)->apply (styleAttrs, docTree); +} + +void CssContext::addRule (CssRule *rule, PrimaryOrder order) { + sheet[order].increase (); + sheet[order].set (sheet[order].size () - 1, rule); +}; + +void CssContext::apply (dw::core::style::StyleAttrs *styleAttrs, + Doctree *docTree, + CssPropertyList *tagStyle, CssPropertyList *nonCss) { + + sheet[USER_AGENT].apply (styleAttrs, docTree); + if (nonCss) + nonCss->apply (styleAttrs); + for (int o = USER; o <= USER_IMPORTANT; o++) + sheet[o].apply (styleAttrs, docTree); + if (tagStyle) + nonCss->apply (styleAttrs); +} |