put html content handler object interface into its own header

This commit is contained in:
Vincent Sanders 2020-05-01 21:25:23 +01:00
parent 479d0cb29a
commit 986d4d5f82
5 changed files with 98 additions and 23 deletions

View File

@ -38,6 +38,7 @@
#include "desktop/gui_internal.h" #include "desktop/gui_internal.h"
#include "html/html_internal.h" #include "html/html_internal.h"
#include "html/object.h"
#include "html/box.h" #include "html/box.h"
#include "html/box_manipulate.h" #include "html/box_manipulate.h"
#include "html/box_construct.h" #include "html/box_construct.h"

View File

@ -42,6 +42,7 @@
#include "html/html.h" #include "html/html.h"
#include "html/html_internal.h" #include "html/html_internal.h"
#include "html/object.h"
#include "html/box.h" #include "html/box.h"
#include "html/box_manipulate.h" #include "html/box_manipulate.h"
#include "html/box_construct.h" #include "html/box_construct.h"

View File

@ -367,25 +367,6 @@ nserror html_css_fetcher_register(void);
nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url, nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url,
uint32_t *key); 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 * Complete the HTML content state machine *iff* all scripts are finished
*/ */

View File

@ -44,6 +44,7 @@
#include "html/box.h" #include "html/box.h"
#include "html/box_inspect.h" #include "html/box_inspect.h"
#include "html/html_internal.h" #include "html/html_internal.h"
#include "html/object.h"
/* break reference loop */ /* break reference loop */
static void html_object_refresh(void *p); static void html_object_refresh(void *p);
@ -489,6 +490,7 @@ html_object_callback(hlcache_handle *object,
return NSERROR_OK; return NSERROR_OK;
} }
/** /**
* Start a fetch for an object required by a page, replacing an existing object. * 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) * \param url URL of object to fetch (copied)
* \return true on success, false on memory exhaustion * \return true on success, false on memory exhaustion
*/ */
static bool html_replace_object(struct content_html_object *object, nsurl *url) static bool html_replace_object(struct content_html_object *object, nsurl *url)
{ {
html_content *c; html_content *c;
@ -549,7 +550,6 @@ static bool html_replace_object(struct content_html_object *object, nsurl *url)
/** /**
* schedule callback for object refresh * schedule callback for object refresh
*/ */
static void html_object_refresh(void *p) static void html_object_refresh(void *p)
{ {
struct content_html_object *object = 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) nserror html_object_open_objects(html_content *html, struct browser_window *bw)
{ {
struct content_html_object *object, *next; 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; return NSERROR_OK;
} }
/* exported interface documented in html/object.h */
nserror html_object_abort_objects(html_content *htmlc) nserror html_object_abort_objects(html_content *htmlc)
{ {
struct content_html_object *object; struct content_html_object *object;
@ -632,6 +636,8 @@ nserror html_object_abort_objects(html_content *htmlc)
return NSERROR_OK; return NSERROR_OK;
} }
/* exported interface documented in html/object.h */
nserror html_object_close_objects(html_content *html) nserror html_object_close_objects(html_content *html)
{ {
struct content_html_object *object, *next; struct content_html_object *object, *next;
@ -654,6 +660,8 @@ nserror html_object_close_objects(html_content *html)
return NSERROR_OK; return NSERROR_OK;
} }
/* exported interface documented in html/object.h */
nserror html_object_free_objects(html_content *html) nserror html_object_free_objects(html_content *html)
{ {
while (html->object_list != NULL) { while (html->object_list != NULL) {
@ -675,8 +683,7 @@ nserror html_object_free_objects(html_content *html)
} }
/* exported interface documented in html/object.h */
/* exported interface documented in html/html_internal.h */
bool bool
html_fetch_object(html_content *c, html_fetch_object(html_content *c,
nsurl *url, nsurl *url,

View File

@ -0,0 +1,85 @@
/*
* Copyright 2020 Vincent Sanders <vince@netsurf-browser.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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