From df89f689f7ddcb082b4616c6e32cabbb859b3a11 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 25 Oct 2014 21:34:09 +0100 Subject: [PATCH] make the pseudo css fetcher report initialisation errors --- render/html_css.c | 4 +++- render/html_css_fetcher.c | 16 +++++++++------- render/html_internal.h | 7 ++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/render/html_css.c b/render/html_css.c index 3d9012ff3..89ab4477c 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -632,7 +632,9 @@ nserror html_css_init(void) { nserror error; - html_css_fetcher_register(); + error = html_css_fetcher_register(); + if (error != NSERROR_OK) + return error; error = nsurl_create("resource:default.css", &html_default_stylesheet_url); diff --git a/render/html_css_fetcher.c b/render/html_css_fetcher.c index 3df1528af..8ac9123b0 100644 --- a/render/html_css_fetcher.c +++ b/render/html_css_fetcher.c @@ -274,7 +274,8 @@ static void html_css_fetcher_poll(lwc_string *scheme) } while ( (c = next) != ring && ring != NULL); } -void html_css_fetcher_register(void) +/* exported interface documented in html_internal.h */ +nserror html_css_fetcher_register(void) { lwc_string *scheme; const struct fetcher_operation_table html_css_fetcher_ops = { @@ -289,16 +290,17 @@ void html_css_fetcher_register(void) }; if (lwc_intern_string("x-ns-css", SLEN("x-ns-css"), - &scheme) != lwc_error_ok) { - die("Failed to initialise the fetch module " - "(couldn't intern \"x-ns-css\")."); + &scheme) != lwc_error_ok) { + LOG(("could not intern \"x-ns-css\".")); + return NSERROR_INIT_FAILED; } - fetcher_add(scheme, &html_css_fetcher_ops); + return fetcher_add(scheme, &html_css_fetcher_ops); } -nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url, - uint32_t *key) +/* exported interface documented in html_internal.h */ +nserror +html_css_fetcher_add_item(dom_string *data, nsurl *base_url, uint32_t *key) { html_css_fetcher_item *item = malloc(sizeof(*item)); diff --git a/render/html_internal.h b/render/html_internal.h index 28522dc93..b57f240bd 100644 --- a/render/html_internal.h +++ b/render/html_internal.h @@ -293,7 +293,12 @@ nserror html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx); /* in render/html_css_fetcher.c */ -void html_css_fetcher_register(void); +/** + * Register the fetcher for the pseudo x-ns-css scheme. + * + * \return NSERROR_OK on successful registration or error code on failure. + */ +nserror html_css_fetcher_register(void); nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url, uint32_t *key);