NetSurf
Functions
html_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/box.h"
#include "html/box_inspect.h"
#include "html/html_internal.h"
Include dependency graph for html_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_callback (hlcache_handle *object, const hlcache_event *event, void *pw)
 Callback for hlcache_handle_retrieve() for objects. 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)
 
nserror html_object_abort_objects (html_content *htmlc)
 
nserror html_object_close_objects (html_content *html)
 
nserror html_object_free_objects (html_content *html)
 
bool html_fetch_object (html_content *c, nsurl *url, struct box *box, content_type permitted_types, int available_width, int available_height, bool background)
 Start a fetch for an object required by a page. More...
 

Detailed Description

Processing for html content object operations.

Definition in file html_object.c.

Function Documentation

◆ html_fetch_object()

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

Start a fetch for an object required by a page.

Parameters
ccontent of type CONTENT_HTML
urlURL of object to fetch (copied)
boxbox that will contain the object
permitted_typesbitmap of acceptable types
available_widthestimate of width of object
available_heightestimate of height of object
backgroundthis is a background image
Returns
true on success, false on memory exhaustion

Definition at line 680 of file html_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(), NSERROR_NOMEM, NSERROR_OK, NSLOG, html_content::num_objects, html_content::object_list, content_html_object::permitted_types, hlcache_child_context::quirks, and content::quirks.

Referenced by box_construct_element(), box_construct_marker(), box_embed(), box_image(), box_input(), box_object(), and html_process_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 58 of file html_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 ( html_content htmlc)

Definition at line 595 of file html_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.

Definition at line 131 of file html_object.c.

References content::active, content::available_height, content::available_width, content_html_object::background, box::background, html_content::base, BOTTOM, content_html_object::box, box_coords(), box_visible(), html_content::bw, content_msg_data::caret, html_drag_owner::content, html_selection_owner::content, html_focus_owner::content, content_html_object::content, content_msg_data::content, content__get_height(), content__get_width(), content__reformat(), content_add_error(), 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, height, box::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, html_content::len_ctx, box::max_width, netsurf_table::misc, html_drag_owner::no_owner, html_selection_owner::none, nscss_len2px(), 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, hlcache_event::type, content_msg_data::type, UNKNOWN_MAX_WIDTH, content_msg_data::width, width, box::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 ( html_content html)

Definition at line 635 of file html_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 90 of file html_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 79 of file html_object.c.

Referenced by html_object_callback().

Here is the caller graph for this function:

◆ html_object_free_objects()

nserror html_object_free_objects ( html_content html)

Definition at line 657 of file html_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_open_objects()

nserror html_object_open_objects ( html_content html,
struct browser_window bw 
)

Definition at line 574 of file html_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 553 of file html_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 500 of file html_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, hlcache_child_context::quirks, content::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: