summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-12-30 00:41:36 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-12-30 00:41:36 +0100
commit1e8a589bcd72bfd5045302698409d23070060507 (patch)
tree6ac3fea9241bf0728e5c4ff99ab3b90f60b8cab2 /src
parentfb503884d404da8796bd88d77389f3227b6651e8 (diff)
simplify CssContext a bit
Diffstat (limited to 'src')
-rw-r--r--src/css.cc24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/css.cc b/src/css.cc
index 1e703f2e..4149fc8c 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -501,10 +501,8 @@ void CssStyleSheet::apply (CssPropertyList *props,
CssContext::CssContext () {
pos = 0;
- memset (sheet, 0, sizeof(sheet));
- sheet[CSS_PRIMARY_USER_AGENT] = new CssStyleSheet ();
- sheet[CSS_PRIMARY_USER] = new CssStyleSheet ();
- sheet[CSS_PRIMARY_USER_IMPORTANT] = new CssStyleSheet ();
+ for (int i = 0; i < CSS_PRIMARY_LAST; i++)
+ sheet[i] = new CssStyleSheet ();
buildUserAgentStyle ();
buildUserStyle ();
@@ -528,29 +526,24 @@ void CssContext::apply (CssPropertyList *props, Doctree *docTree,
DoctreeNode *node,
CssPropertyList *tagStyle, CssPropertyList *tagStyleImportant,
CssPropertyList *nonCssHints) {
- if (sheet[CSS_PRIMARY_USER_AGENT])
- sheet[CSS_PRIMARY_USER_AGENT]->apply (props, docTree, node);
- if (sheet[CSS_PRIMARY_USER])
- sheet[CSS_PRIMARY_USER]->apply (props, docTree, node);
+ sheet[CSS_PRIMARY_USER_AGENT]->apply (props, docTree, node);
+ sheet[CSS_PRIMARY_USER]->apply (props, docTree, node);
if (nonCssHints)
nonCssHints->apply (props);
- if (sheet[CSS_PRIMARY_AUTHOR])
- sheet[CSS_PRIMARY_AUTHOR]->apply (props, docTree, node);
+ sheet[CSS_PRIMARY_AUTHOR]->apply (props, docTree, node);
if (tagStyle)
tagStyle->apply (props);
- if (sheet[CSS_PRIMARY_AUTHOR_IMPORTANT])
- sheet[CSS_PRIMARY_AUTHOR_IMPORTANT]->apply (props, docTree, node);
+ sheet[CSS_PRIMARY_AUTHOR_IMPORTANT]->apply (props, docTree, node);
if (tagStyleImportant)
tagStyleImportant->apply (props);
- if (sheet[CSS_PRIMARY_USER_IMPORTANT])
- sheet[CSS_PRIMARY_USER_IMPORTANT]->apply (props, docTree, node);
+ sheet[CSS_PRIMARY_USER_IMPORTANT]->apply (props, docTree, node);
}
void CssContext::addRule (CssSelector *sel, CssPropertyList *props,
@@ -559,9 +552,6 @@ void CssContext::addRule (CssSelector *sel, CssPropertyList *props,
if (props->size () > 0) {
CssRule *rule = new CssRule (sel, props, pos++);
- if (sheet[order] == NULL)
- sheet[order] = new CssStyleSheet ();
-
sheet[order]->addRule (rule);
}
}