From 986d4d5f82cfc96d9308e710aeeff0feac1bec4a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 1 May 2020 21:25:23 +0100 Subject: [PATCH] put html content handler object interface into its own header --- content/handlers/html/box_construct.c | 1 + content/handlers/html/box_special.c | 1 + content/handlers/html/html_internal.h | 19 ------ content/handlers/html/object.c | 15 +++-- content/handlers/html/object.h | 85 +++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 23 deletions(-) create mode 100644 content/handlers/html/object.h diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c index fba97641d..f1ea71d3b 100644 --- a/content/handlers/html/box_construct.c +++ b/content/handlers/html/box_construct.c @@ -38,6 +38,7 @@ #include "desktop/gui_internal.h" #include "html/html_internal.h" +#include "html/object.h" #include "html/box.h" #include "html/box_manipulate.h" #include "html/box_construct.h" diff --git a/content/handlers/html/box_special.c b/content/handlers/html/box_special.c index 9f4a51201..2d3bd054b 100644 --- a/content/handlers/html/box_special.c +++ b/content/handlers/html/box_special.c @@ -42,6 +42,7 @@ #include "html/html.h" #include "html/html_internal.h" +#include "html/object.h" #include "html/box.h" #include "html/box_manipulate.h" #include "html/box_construct.h" diff --git a/content/handlers/html/html_internal.h b/content/handlers/html/html_internal.h index 6b5533492..ae3182a07 100644 --- a/content/handlers/html/html_internal.h +++ b/content/handlers/html/html_internal.h @@ -367,25 +367,6 @@ nserror html_css_fetcher_register(void); nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url, uint32_t *key); -/* in html/html_object.c */ - -/** - * Start a fetch for an object required by a page. - * - * \param c content of type CONTENT_HTML - * \param url URL of object to fetch (copied) - * \param box box that will contain the object - * \param permitted_types bitmap of acceptable types - * \param background this is a background image - * \return true on success, false on memory exhaustion - */ -bool html_fetch_object(html_content *c, nsurl *url, struct box *box, content_type permitted_types, bool background); - -nserror html_object_free_objects(html_content *html); -nserror html_object_close_objects(html_content *html); -nserror html_object_open_objects(html_content *html, struct browser_window *bw); -nserror html_object_abort_objects(html_content *html); - /** * Complete the HTML content state machine *iff* all scripts are finished */ diff --git a/content/handlers/html/object.c b/content/handlers/html/object.c index c20118d69..e8cdc7db9 100644 --- a/content/handlers/html/object.c +++ b/content/handlers/html/object.c @@ -44,6 +44,7 @@ #include "html/box.h" #include "html/box_inspect.h" #include "html/html_internal.h" +#include "html/object.h" /* break reference loop */ static void html_object_refresh(void *p); @@ -489,6 +490,7 @@ html_object_callback(hlcache_handle *object, return NSERROR_OK; } + /** * Start a fetch for an object required by a page, replacing an existing object. * @@ -496,7 +498,6 @@ html_object_callback(hlcache_handle *object, * \param url URL of object to fetch (copied) * \return true on success, false on memory exhaustion */ - static bool html_replace_object(struct content_html_object *object, nsurl *url) { html_content *c; @@ -549,7 +550,6 @@ static bool html_replace_object(struct content_html_object *object, nsurl *url) /** * schedule callback for object refresh */ - static void html_object_refresh(void *p) { struct content_html_object *object = p; @@ -571,6 +571,8 @@ static void html_object_refresh(void *p) } } + +/* exported interface documented in html/object.h */ nserror html_object_open_objects(html_content *html, struct browser_window *bw) { struct content_html_object *object, *next; @@ -592,6 +594,8 @@ nserror html_object_open_objects(html_content *html, struct browser_window *bw) return NSERROR_OK; } + +/* exported interface documented in html/object.h */ nserror html_object_abort_objects(html_content *htmlc) { struct content_html_object *object; @@ -632,6 +636,8 @@ nserror html_object_abort_objects(html_content *htmlc) return NSERROR_OK; } + +/* exported interface documented in html/object.h */ nserror html_object_close_objects(html_content *html) { struct content_html_object *object, *next; @@ -654,6 +660,8 @@ nserror html_object_close_objects(html_content *html) return NSERROR_OK; } + +/* exported interface documented in html/object.h */ nserror html_object_free_objects(html_content *html) { while (html->object_list != NULL) { @@ -675,8 +683,7 @@ nserror html_object_free_objects(html_content *html) } - -/* exported interface documented in html/html_internal.h */ +/* exported interface documented in html/object.h */ bool html_fetch_object(html_content *c, nsurl *url, diff --git a/content/handlers/html/object.h b/content/handlers/html/object.h new file mode 100644 index 000000000..85734fd94 --- /dev/null +++ b/content/handlers/html/object.h @@ -0,0 +1,85 @@ +/* + * Copyright 2020 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file + * HTML content object interface + */ + +#ifndef NETSURF_HTML_OBJECT_H +#define NETSURF_HTML_OBJECT_H + +struct html_content; +struct browser_window; +struct box; + +/** + * Start a fetch for an object required by a page. + * + * The created content object is added to the HTML content which is + * updated as the fetch progresses. The box (if any) is updated when + * the object content becomes done. + * + * \param c content of type CONTENT_HTML + * \param url URL of object to fetch + * \param box box that will contain the object or NULL if none + * \param permitted_types bitmap of acceptable types + * \param background this is a background image + * \return true on success, false on memory exhaustion + */ +bool html_fetch_object(struct html_content *c, nsurl *url, struct box *box, content_type permitted_types, bool background); + +/** + * release memory of content objects associated with a HTML content + * + * The content objects contents should have been previously closed + * with html_object_close_objects(). + * + * \param html The html content to release the objects from. + * \return NSERROR_OK on success else appropriate error code. + */ +nserror html_object_free_objects(struct html_content *html); + +/** + * close content of content objects associated with a HTML content + * + * \param html The html content to close the objects from. + * \return NSERROR_OK on success else appropriate error code. + */ +nserror html_object_close_objects(struct html_content *html); + + +/** + * open content of content objects associated with a HTML content + * + * \param html The html content to open the objects from. + * \param bw Browser window handle to open contents with. + * \return NSERROR_OK on success else appropriate error code. + */ +nserror html_object_open_objects(struct html_content *html, struct browser_window *bw); + + +/** + * abort any content objects that have not completed fetching. + * + * \param html The html content to abort the objects from. + * \return NSERROR_OK on success else appropriate error code. + */ +nserror html_object_abort_objects(struct html_content *html); + +#endif