aboutsummaryrefslogtreecommitdiff
path: root/src/css.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/css.cc')
-rw-r--r--src/css.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/css.cc b/src/css.cc
index 4cc9f59e..d01093b0 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -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);
+}