From 5930e4bcc46f8e49c34e5630cf875f2b055502ff Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 18 Mar 2013 14:48:00 +0000 Subject: Fix bug where html conversion began before STYLE element fetch had been launched. --- render/html.c | 21 +++++++++++++++++++-- render/html_css.c | 2 +- render/html_internal.h | 8 ++++++++ render/html_script.c | 4 ++-- 4 files changed, 30 insertions(+), 5 deletions(-) (limited to 'render') diff --git a/render/html.c b/render/html.c index ad7ab9997..0f854bc67 100644 --- a/render/html.c +++ b/render/html.c @@ -1121,13 +1121,30 @@ static bool html_convert(struct content *c) /* if there are no active fetches in progress no scripts are * being fetched or they completed already. - */ - if (htmlc->base.active == 0) { + */ + if (html_can_begin_conversion(htmlc)) { return html_begin_conversion(htmlc); } return true; } +/* Exported interface documented in html_internal.h */ +bool html_can_begin_conversion(html_content *htmlc) +{ + unsigned int i; + bool got_modified_stylesheet = false; + + for (i = 0; i != htmlc->stylesheet_count; i++) { + if (htmlc->stylesheets[i].modified) + got_modified_stylesheet = true; + } + + if (htmlc->base.active != 0 || got_modified_stylesheet) + return false; + + return true; +} + bool html_begin_conversion(html_content *htmlc) { diff --git a/render/html_css.c b/render/html_css.c index a2e3a1be0..6242f9da7 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -143,7 +143,7 @@ html_convert_css_callback(hlcache_handle *css, assert(0); } - if (parent->base.active == 0) { + if (html_can_begin_conversion(parent)) { html_begin_conversion(parent); } diff --git a/render/html_internal.h b/render/html_internal.h index 90f014307..a78dc8f8a 100644 --- a/render/html_internal.h +++ b/render/html_internal.h @@ -220,6 +220,14 @@ void html_set_search(struct content *c, struct search_context *s); */ void html_finish_conversion(html_content *htmlc); +/** + * Test if an HTML content conversion can begin + * + * \param htmlc html content to test + * \return true iff the html content conversion can begin + */ +bool html_can_begin_conversion(html_content *htmlc); + /** * Begin conversion of an HTML document * diff --git a/render/html_script.c b/render/html_script.c index 9c14e84ce..89d67413e 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -255,7 +255,7 @@ convert_script_defer_cb(hlcache_handle *script, /* if there are no active fetches remaining begin post parse * conversion */ - if (parent->base.active == 0) { + if (html_can_begin_conversion(parent)) { html_begin_conversion(parent); } @@ -349,7 +349,7 @@ convert_script_sync_cb(hlcache_handle *script, /* if there are no active fetches remaining begin post parse * conversion */ - if (parent->base.active == 0) { + if (html_can_begin_conversion(parent)) { html_begin_conversion(parent); } -- cgit v1.2.3