NetSurf
Functions
object.c File Reference

Processing for html content object operations. More...

#include <assert.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <nsutils/time.h>
#include "utils/corestrings.h"
#include "utils/config.h"
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/content.h"
#include "netsurf/misc.h"
#include "content/hlcache.h"
#include "css/utils.h"
#include "desktop/scrollbar.h"
#include "desktop/gui_internal.h"
#include "html/html.h"
#include "html/private.h"
#include "html/interaction.h"
#include "html/box.h"
#include "html/box_inspect.h"
#include "html/object.h"
Include dependency graph for object.c:

Go to the source code of this file.

Functions

static void html_object_refresh (void *p)
 schedule callback for object refresh More...
 
struct content_html_objecthtml_get_objects (hlcache_handle *h, unsigned int *n)
 Retrieve objects used by HTML document. More...
 
static void html_object_failed (struct box *box, html_content *content, bool background)
 Handle object fetching or loading failure. More...
 
static void html_object_done (struct box *box, hlcache_handle *object, bool background)
 Update a box whose content has completed rendering. More...
 
static nserror html_object_nobox_callback (hlcache_handle *object, const hlcache_event *event, void *pw)
 Callback for hlcache_handle_retrieve() for objects with no box. More...
 
static nserror html_object_callback (hlcache_handle *object, const hlcache_event *event, void *pw)
 Callback for hlcache_handle_retrieve() for objects with a box. More...
 
static bool html_replace_object (struct content_html_object *object, nsurl *url)
 Start a fetch for an object required by a page, replacing an existing object. More...
 
nserror html_object_open_objects (html_content *html, struct browser_window *bw)
 open content of content objects associated with a HTML content More...
 
nserror html_object_abort_objects (html_content *htmlc)
 abort any content objects that have not completed fetching. More...
 
nserror html_object_close_objects (html_content *html)
 close content of content objects associated with a HTML content More...
 
nserror html_object_free_objects (html_content *html)
 release memory of content objects associated with a HTML content More...
 
bool html_fetch_object (html_content *c, nsurl *url, struct box *box, content_type permitted_types, bool background)
 Start a fetch for an object required by a page. More...
 

Detailed Description

Processing for html content object operations.

Definition in file object.c.

Function Documentation

◆ html_fetch_object()

bool html_fetch_object ( struct html_content c,
struct nsurl url,
struct box box,
content_type  permitted_types,
bool  background 
)

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.

Parameters
ccontent of type CONTENT_HTML
urlURL of object to fetch
boxbox that will contain the object or NULL if none
permitted_typesbitmap of acceptable types
backgroundthis is a background image
Returns
true on success, false on memory exhaustion

Definition at line 710 of file object.c.

References html_content::aborted, content::active, box::background, html_content::base, hlcache_child_context::charset, content_html_object::content, content_get_url(), html_content::encoding, hlcache_handle_retrieve(), HLCACHE_RETRIEVE_SNIFF_TYPE, html_object_callback(), html_object_nobox_callback(), NSERROR_NOMEM, NSERROR_OK, NSLOG, html_content::num_objects, html_content::object_list, content_html_object::permitted_types, content::quirks, and hlcache_child_context::quirks.

Referenced by box_construct_element(), box_construct_marker(), box_embed(), box_image(), box_input(), box_object(), and html_process_inserted_img().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_get_objects()

struct content_html_object * html_get_objects ( hlcache_handle h,
unsigned int *  n 
)

Retrieve objects used by HTML document.

Parameters
hContent to retrieve objects from
nPointer to location to receive number of objects
Returns
Pointer to list of objects

Definition at line 60 of file object.c.

References hlcache_handle_get_content(), html_content::num_objects, and html_content::object_list.

Referenced by browser_window_reload(), and save_complete_save_html_objects().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_object_abort_objects()

nserror html_object_abort_objects ( struct html_content html)

abort any content objects that have not completed fetching.

Parameters
htmlThe html content to abort the objects from.
Returns
NSERROR_OK on success else appropriate error code.

Definition at line 621 of file object.c.

References content::active, html_content::base, content_html_object::box, content_html_object::content, content_get_status(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, hlcache_handle_abort(), hlcache_handle_release(), content_html_object::next, NSERROR_OK, NSLOG, and html_content::object_list.

Referenced by html_stop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_object_callback()

static nserror html_object_callback ( hlcache_handle object,
const hlcache_event event,
void *  pw 
)
static

Callback for hlcache_handle_retrieve() for objects with a box.

Definition at line 158 of file object.c.

References content::active, content::available_height, content::available_width, box::background, content_html_object::background, html_content::base, BOTTOM, content_html_object::box, box_coords(), box_visible(), html_content::bw, content_msg_data::caret, content_msg_data::clip, content_msg_data::content, content_html_object::content, html_drag_owner::content, html_selection_owner::content, html_focus_owner::content, content__get_height(), content__get_width(), content__reformat(), content_broadcast(), content_can_reformat(), content_get_height(), content_get_type(), content_get_width(), CONTENT_HTML, CONTENT_MSG_CARET, CONTENT_MSG_DONE, CONTENT_MSG_DRAG, CONTENT_MSG_DRAGSAVE, CONTENT_MSG_ERROR, CONTENT_MSG_GADGETCLICK, CONTENT_MSG_GETDIMS, CONTENT_MSG_GETTHREAD, CONTENT_MSG_LINK, CONTENT_MSG_LOADING, CONTENT_MSG_POINTER, CONTENT_MSG_READY, CONTENT_MSG_REDRAW, CONTENT_MSG_REFRESH, CONTENT_MSG_SAVELINK, CONTENT_MSG_SCROLL, CONTENT_MSG_SELECTION, CONTENT_MSG_SELECTMENU, content_open(), content_reformat(), content_set_done(), CONTENT_STATUS_DONE, CONTENT_STATUS_LOADING, CONTENT_STATUS_READY, hlcache_event::data, content_msg_data::delay, content_msg_data::drag, content_msg_data::dragsave, box::flags, guit, html_content::had_initial_layout, content_msg_data::height, box::height, height, hlcache_handle_release(), HTML_DRAG_CONTENT_SCROLL, HTML_DRAG_CONTENT_SELECTION, HTML_DRAG_NONE, HTML_FOCUS_CONTENT, html_object_done(), html_object_failed(), html_object_refresh(), HTML_SELECTION_CONTENT, HTML_SELECTION_NONE, html_set_drag_type(), html_set_focus(), html_set_selection(), LEFT, box::max_width, netsurf_table::misc, html_drag_owner::no_owner, html_selection_owner::none, NSERROR_OK, NSLOG, nsoption_bool, box::object_params, box::padding, content_html_object::parent, content_msg_data::pos, content_msg_data::rect, content_msg_data::redraw, content::reformat_time, REPLACE_DIM, RIGHT, gui_misc_table::schedule, content_msg_data::scroll, box::scroll_x, box::scroll_y, scrollbar_set(), content_msg_data::selection, content::status, box::style, TOP, content_msg_data::type, hlcache_event::type, html_content::unit_len_ctx, UNKNOWN_MAX_WIDTH, content_msg_data::width, box::width, width, content_msg_data::x, content_msg_data::x0, content_msg_data::y, and content_msg_data::y0.

Referenced by html_fetch_object(), and html_replace_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_object_close_objects()

nserror html_object_close_objects ( struct html_content html)

close content of content objects associated with a HTML content

Parameters
htmlThe html content to close the objects from.
Returns
NSERROR_OK on success else appropriate error code.

Definition at line 663 of file object.c.

References content_html_object::box, content_html_object::content, content_close(), content_get_type(), CONTENT_HTML, CONTENT_NONE, guit, html_object_refresh(), netsurf_table::misc, content_html_object::next, NSERROR_OK, html_content::object_list, and gui_misc_table::schedule.

Referenced by html_close().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_object_done()

static void html_object_done ( struct box box,
hlcache_handle object,
bool  background 
)
static

Update a box whose content has completed rendering.

Definition at line 92 of file object.c.

References box::background, BOX_BLOCK, BOX_TABLE, CLONE, box::flags, box::max_width, box::next, box::object, box::parent, REPLACE_DIM, box::type, and UNKNOWN_MAX_WIDTH.

Referenced by html_object_callback().

Here is the caller graph for this function:

◆ html_object_failed()

static void html_object_failed ( struct box box,
html_content content,
bool  background 
)
static

Handle object fetching or loading failure.

Parameters
boxbox containing object which failed to load
contentdocument of type CONTENT_HTML
backgroundthe object was the background image for the box

Definition at line 81 of file object.c.

Referenced by html_object_callback().

Here is the caller graph for this function:

◆ html_object_free_objects()

nserror html_object_free_objects ( struct html_content html)

release memory of content objects associated with a HTML content

The content objects contents should have been previously closed with html_object_close_objects().

Parameters
htmlThe html content to release the objects from.
Returns
NSERROR_OK on success else appropriate error code.

Definition at line 687 of file object.c.

References content_html_object::content, content_get_type(), CONTENT_HTML, guit, hlcache_handle_release(), html_object_refresh(), netsurf_table::misc, content_html_object::next, NSERROR_OK, NSLOG, html_content::object_list, and gui_misc_table::schedule.

Referenced by html_box_convert_done(), html_destroy(), and html_finish_conversion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_object_nobox_callback()

static nserror html_object_nobox_callback ( hlcache_handle object,
const hlcache_event event,
void *  pw 
)
static

Callback for hlcache_handle_retrieve() for objects with no box.

Definition at line 133 of file object.c.

References content_html_object::content, CONTENT_MSG_ERROR, hlcache_handle_release(), NSERROR_OK, and hlcache_event::type.

Referenced by html_fetch_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_object_open_objects()

nserror html_object_open_objects ( struct html_content html,
struct browser_window bw 
)

open content of content objects associated with a HTML content

Parameters
htmlThe html content to open the objects from.
bwBrowser window handle to open contents with.
Returns
NSERROR_OK on success else appropriate error code.

Definition at line 598 of file object.c.

References html_content::base, content_html_object::box, content_html_object::content, content_get_type(), CONTENT_NONE, content_open(), content_html_object::next, NSERROR_OK, html_content::object_list, and box::object_params.

Referenced by html_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_object_refresh()

static void html_object_refresh ( void *  p)
static

schedule callback for object refresh

Todo:
handle memory exhaustion

Definition at line 575 of file object.c.

References content_html_object::content, content_get_refresh_url(), content_get_type(), CONTENT_HTML, content_invalidate_reuse_data(), and html_replace_object().

Referenced by html_object_callback(), html_object_close_objects(), and html_object_free_objects().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ html_replace_object()

static bool html_replace_object ( struct content_html_object object,
nsurl url 
)
static

Start a fetch for an object required by a page, replacing an existing object.

Parameters
objectObject to replace
urlURL of object to fetch (copied)
Returns
true on success, false on memory exhaustion

Definition at line 523 of file object.c.

References content::active, html_content::base, content_html_object::box, hlcache_child_context::charset, content_html_object::content, content_get_status(), content_get_url(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, html_content::encoding, hlcache_handle_release(), hlcache_handle_retrieve(), HLCACHE_RETRIEVE_SNIFF_TYPE, html_object_callback(), NSERROR_OK, NSLOG, html_content::page, content_html_object::parent, content_html_object::permitted_types, content::quirks, hlcache_child_context::quirks, and content::status.

Referenced by html_object_refresh().

Here is the call graph for this function:
Here is the caller graph for this function: