diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/html.cc | 33 | ||||
-rw-r--r-- | src/styleengine.cc | 10 | ||||
-rw-r--r-- | src/table.cc | 14 |
4 files changed, 36 insertions, 22 deletions
@@ -63,6 +63,7 @@ dillo-2.1 - Add support for font-size and font-weight enum values. - Added "font_max_size", "font_min_size" dillorc options. - Add workaround for fltk bug #2062. + - Reduce number of styleEngine::style0() calls. Patches: Johannes Hofmann +- Updated the GPL copyright note in the source files. Patch: Detlef Riekenberg diff --git a/src/html.cc b/src/html.cc index 0aad121b..c8d9e63f 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1712,6 +1712,9 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "vlink"))) html->visited_color = a_Html_color_parse(html, attrbuf, -1); + html->styleEngine->setNonCssHints (&props); + html->dw->setStyle (html->styleEngine->style ()); + if (prefs.contrast_visited_color) { /* get a color that has a "safe distance" from text, link and bg */ html->visited_color = @@ -1721,9 +1724,6 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) S_TOP(html)->current_bg_color); } - html->styleEngine->setNonCssHints (&props); - html->dw->setStyle (html->styleEngine->style ()); - S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_BODY; } @@ -1747,15 +1747,16 @@ static void Html_tag_open_p(DilloHtml *html, const char *tag, int tagsize) { CssPropertyList props; + a_Html_tag_set_align_attr (html, &props, tag, tagsize); + html->styleEngine->inheritBackgroundColor (); + html->styleEngine->setNonCssHints (&props); + if ((html->InFlags & IN_LI) && !html->WordAfterLI) { /* ignore first parbreak after an empty <LI> */ html->WordAfterLI = true; } else { DW2TB(html->dw)->addParbreak (9, html->styleEngine->wordStyle ()); } - a_Html_tag_set_align_attr (html, &props, tag, tagsize); - html->styleEngine->inheritBackgroundColor (); - html->styleEngine->setNonCssHints (&props); } /* @@ -2660,9 +2661,10 @@ static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize) size_bottom); } + html->styleEngine->setNonCssHints (&props); + DW2TB(html->dw)->addParbreak (5, html->styleEngine->wordStyle ()); - html->styleEngine->setNonCssHints (&props); hruler = new Ruler(); hruler->setStyle (html->styleEngine->style ()); DW2TB(html->dw)->addWidget (hruler, html->styleEngine->style ()); @@ -3337,7 +3339,6 @@ static void Html_parse_common_attrs(DilloHtml *html, char *tag, int tagsize) Html_check_name_val(html, attrbuf, "id"); html->styleEngine->setId(attrbuf); - Html_add_anchor(html, attrbuf); } if (tagsize >= 11 && (prefs.parse_embedded_css || prefs.load_stylesheets)) { @@ -3353,12 +3354,6 @@ static void Html_parse_common_attrs(DilloHtml *html, char *tag, int tagsize) html->styleEngine->setStyle (attrbuf); } - if (S_TOP(html)->parse_mode != DILLO_HTML_PARSE_MODE_PRE && - html->styleEngine->style ()->whiteSpace == WHITE_SPACE_PRE) { - S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_PRE; - html->pre_column = 0; - html->PreFirstChar = true; - } } /* @@ -3420,6 +3415,16 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize) if (html->stop_parser) break; + if (S_TOP(html)->parse_mode != DILLO_HTML_PARSE_MODE_PRE && + html->styleEngine->style ()->whiteSpace == WHITE_SPACE_PRE) { + S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_PRE; + html->pre_column = 0; + html->PreFirstChar = true; + } + + if (html->styleEngine->getId ()) + Html_add_anchor(html, html->styleEngine->getId ()); + /* Request inmediate close for elements with forbidden close tag. */ /* TODO: XHTML always requires close tags. A simple implementation * of the commented clause below will make it work. */ 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 (); diff --git a/src/table.cc b/src/table.cc index 34c0f13e..53325410 100644 --- a/src/table.cc +++ b/src/table.cc @@ -48,7 +48,6 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) int cssLength; #endif - DW2TB(html->dw)->addParbreak (0, html->styleEngine->wordStyle ()); #ifdef USE_TABLES if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "border"))) @@ -101,6 +100,8 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) html->styleEngine->setNonCssHints (&props); + DW2TB(html->dw)->addParbreak (0, html->styleEngine->wordStyle ()); + /* The style for the cells */ table_cell_props = new CssPropertyList (); if (border > 0) { @@ -172,17 +173,16 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) } } - html->styleEngine->inheritBackgroundColor (); - html->styleEngine->setNonCssHints (&props); - - ((dw::Table*)S_TOP(html)->table)->addRow (html->styleEngine->style ()); - if (a_Html_get_attr (html, tag, tagsize, "align")) { S_TOP(html)->cell_text_align_set = TRUE; a_Html_tag_set_align_attr (html, &props, tag, tagsize); - html->styleEngine->setNonCssHints (&props); } + html->styleEngine->inheritBackgroundColor (); + html->styleEngine->setNonCssHints (&props); + + ((dw::Table*)S_TOP(html)->table)->addRow (html->styleEngine->style ()); + table_cell_props = new CssPropertyList (*S_TOP(html)->table_cell_props); if (bgcolor != -1) { table_cell_props->set (CSS_PROPERTY_BACKGROUND_COLOR, |