aboutsummaryrefslogtreecommitdiff
path: root/src/styleengine.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-13 09:02:41 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-13 09:02:41 +0100
commitc510c7315258501f7f43902589203b06fbc72b9a (patch)
tree404c6a20cf323dd582e3ddf4bb29e56ab34d08fc /src/styleengine.cc
parent1b38c3eeac1bb16030323cb68859adb00bf98004 (diff)
initial implementation of a CSS selector matching optimization
The idea is to avoid repeated checks of CssSimpleSelector against the same part of the doctree. E.g .navigation * { background-color:green } Would result in checking for class="navigation" all the way down to the document root for all elements. The optimization shortcuts this, for parts of the doctree that have been checked before.
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r--src/styleengine.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc
index bd5c60ed..7dcd3dd5 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -23,6 +23,7 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) {
stack = new lout::misc::SimpleVector <Node> (1);
cssContext = new CssContext ();
this->layout = layout;
+ num = 0;
stack->increase ();
Node *n = stack->getRef (stack->size () - 1);
@@ -37,7 +38,8 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) {
style_attrs.font = Font::create (layout, &font_attrs);
style_attrs.color = Color::create (layout, 0);
style_attrs.backgroundColor = Color::create (layout, 0xffffff);
-
+
+ n->num = num++;
n->style = Style::create (layout, &style_attrs);
n->wordStyle = NULL;
n->pseudo = NULL;
@@ -62,6 +64,7 @@ void StyleEngine::startElement (int element) {
stack->increase ();
Node *n = stack->getRef (stack->size () - 1);
+ n->num = num++;
n->style = NULL;
n->wordStyle = NULL;
n->depth = stack->size () - 1;