diff options
-rw-r--r-- | render/html.c | 35 | ||||
-rw-r--r-- | render/html_css.c | 42 | ||||
-rw-r--r-- | render/html_internal.h | 1 |
3 files changed, 55 insertions, 23 deletions
diff --git a/render/html.c b/render/html.c index 2e4e4dd04..7414ceda0 100644 --- a/render/html.c +++ b/render/html.c @@ -287,6 +287,12 @@ dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw) * selects a callback function for libdom to call based on the type and phase. * dom_default_action_phase from events/document_event.h * + * The principle events are: + * DOMSubtreeModified + * DOMAttrModified + * DOMNodeInserted + * DOMNodeInsertedIntoDocument + * * @return callback function pointer or NULL for none */ static dom_default_action_callback @@ -1508,10 +1514,30 @@ static void html_object_refresh(void *p) static bool html_convert(struct content *c) { html_content *htmlc = (html_content *) c; + dom_exception exc; /* returned by libdom functions */ + + /* The quirk check and associated stylesheet fetch is "safe" + * once the root node has been inserted into the document + * which must have happened by this point in the parse. + * + * faliure to retrive the quirk mode or to start the + * stylesheet fetch is non fatal as this "only" affects the + * render and it would annoy the user to fail the entire + * render for want of a quirks stylesheet. + */ + exc = dom_document_get_quirks_mode(htmlc->document, &htmlc->quirks); + if (exc == DOM_NO_ERR) { + html_css_quirks_stylesheets(htmlc); + LOG(("quirks set to %d", htmlc->quirks)); + } htmlc->base.active--; /* the html fetch is no longer active */ LOG(("%d fetches active", htmlc->base.active)); + /* The parse cannot be completed here because it may be paused + * untill all the resources being fetched have completed. + */ + /* if there are no active fetches in progress no scripts are * being fetched or they completed already. */ @@ -1549,7 +1575,6 @@ html_begin_conversion(html_content *htmlc) return false; } - /* complete script execution */ html_scripts_exec(htmlc); @@ -1557,14 +1582,6 @@ html_begin_conversion(html_content *htmlc) * the Document. */ - /* quirks mode */ - exc = dom_document_get_quirks_mode(htmlc->document, &htmlc->quirks); - if (exc != DOM_NO_ERR) { - LOG(("error retrieving quirks")); - /** @todo should this be fatal to the conversion? */ - } - LOG(("quirks set to %d", htmlc->quirks)); - /* get encoding */ if (htmlc->encoding == NULL) { const char *encoding; diff --git a/render/html_css.c b/render/html_css.c index babe052ce..e14a781f0 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -184,6 +184,34 @@ nserror html_css_free_stylesheets(html_content *html) } /* exported interface documented in render/html_internal.h */ +nserror html_css_quirks_stylesheets(html_content *c) +{ + nserror ns_error = NSERROR_OK; + hlcache_child_context child; + + assert(c->stylesheets != NULL); + + if (c->quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL) { + child.charset = c->encoding; + child.quirks = c->base.quirks; + + ns_error = hlcache_handle_retrieve(html_quirks_stylesheet_url, + 0, content_get_url(&c->base), NULL, + html_convert_css_callback, c, &child, + CONTENT_CSS, + &c->stylesheets[STYLESHEET_QUIRKS].data.external); + if (ns_error != NSERROR_OK) { + return ns_error; + } + + c->base.active++; + LOG(("%d fetches active", c->base.active)); + } + + return ns_error; +} + +/* exported interface documented in render/html_internal.h */ nserror html_css_new_stylesheets(html_content *c) { nserror ns_error; @@ -226,20 +254,6 @@ nserror html_css_new_stylesheets(html_content *c) c->base.active++; LOG(("%d fetches active", c->base.active)); - if (c->quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL) { - ns_error = hlcache_handle_retrieve(html_quirks_stylesheet_url, - 0, content_get_url(&c->base), NULL, - html_convert_css_callback, c, &child, - CONTENT_CSS, - &c->stylesheets[STYLESHEET_QUIRKS].data.external); - if (ns_error != NSERROR_OK) { - return ns_error; - } - - c->base.active++; - LOG(("%d fetches active", c->base.active)); - - } if (nsoption_bool(block_ads)) { ns_error = hlcache_handle_retrieve(html_adblock_stylesheet_url, diff --git a/render/html_internal.h b/render/html_internal.h index 2dd1c5190..4c43345a2 100644 --- a/render/html_internal.h +++ b/render/html_internal.h @@ -266,6 +266,7 @@ void html_css_fini(void); * \return nserror */ nserror html_css_new_stylesheets(html_content *c); +nserror html_css_quirks_stylesheets(html_content *c); nserror html_css_free_stylesheets(html_content *html); bool html_css_process_link(html_content *htmlc, dom_node *node); |