aboutsummaryrefslogtreecommitdiff
path: root/src/styleengine.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-05 14:43:11 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-05 14:43:11 +0100
commitaa70b2f628549b2426693572baf96fc71341c404 (patch)
tree541faf8eebe02ee5fd72052d8e8c2b5e4ca9333e /src/styleengine.cc
parentc6dac9cfdfb1b193c0680834fdfebfdb96edcb23 (diff)
reduce number of styleEngine::style0() calls
Rearrange code, so that for each new element, StyleEngine::setNonCssHints() is called before the first call to StyleEngine::style() or StyleEngine::wordStyle(). This avoids unnecessary CSS style computations which are expensive. Add an assertion to ensure this.
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r--src/styleengine.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc
index d9ec3ff2..cde1f926 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -488,9 +488,17 @@ Style * StyleEngine::style0 (CssPropertyList *nonCssProperties) {
CssPropertyList props, *styleAttributeProps = NULL;
const char *styleAttribute =
stack->getRef (stack->size () - 1)->styleAttribute;
-
// get previous style from the stack
StyleAttrs attrs = *stack->getRef (stack->size () - 2)->style;
+
+ // Ensure that StyleEngine::style0() has not been called before for
+ // this element.
+ // Style computation is expensive so limit it as much as possible.
+ // If this assertion is hit, you need to rearrange the code that is
+ // doing styleEngine calls to call setNonCssHints() before calling
+ // style() or wordStyle() for each new element.
+ assert (stack->getRef (stack->size () - 1)->style == NULL);
+
// reset values that are not inherited according to CSS
attrs.resetValues ();