NetSurf
Macros | Functions | Variables
html.c File Reference

Implementation of HTML content handling. More...

#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <nsutils/time.h>
#include "utils/utils.h"
#include "utils/config.h"
#include "utils/corestrings.h"
#include "utils/http.h"
#include "utils/libdom.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/talloc.h"
#include "utils/utf8.h"
#include "utils/nsoption.h"
#include "utils/ascii.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
#include "netsurf/utf8.h"
#include "netsurf/keypress.h"
#include "netsurf/layout.h"
#include "netsurf/misc.h"
#include "content/hlcache.h"
#include "content/content_factory.h"
#include "content/textsearch.h"
#include "desktop/selection.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
#include "netsurf/bitmap.h"
#include "javascript/js.h"
#include "desktop/gui_internal.h"
#include "html/html.h"
#include "html/private.h"
#include "html/dom_event.h"
#include "html/css.h"
#include "html/object.h"
#include "html/html_save.h"
#include "html/interaction.h"
#include "html/box.h"
#include "html/box_construct.h"
#include "html/box_inspect.h"
#include "html/form_internal.h"
#include "html/imagemap.h"
#include "html/layout.h"
#include "html/textselection.h"
Include dependency graph for html.c:

Go to the source code of this file.

Macros

#define CHUNK   4096
 
#define ALWAYS_DUMP_FRAMESET   0
 
#define ALWAYS_DUMP_BOX   0
 

Functions

static bool fire_dom_event (dom_event *event, dom_node *target)
 Fire an event at the DOM. More...
 
bool fire_generic_dom_event (dom_string *type, dom_node *target, bool bubbles, bool cancelable)
 Construct an event and fire it at the DOM. More...
 
bool fire_dom_keyboard_event (dom_string *type, dom_node *target, bool bubbles, bool cancelable, uint32_t key)
 Construct a keyboard event and fire it at the DOM. More...
 
static void html_box_convert_done (html_content *c, bool success)
 Perform post-box-creation conversion of a document. More...
 
nserror html_proceed_to_done (html_content *html)
 Complete the HTML content state machine iff all scripts are finished. More...
 
static void html_get_dimensions (html_content *htmlc)
 
void html_finish_conversion (html_content *htmlc)
 Complete conversion of an HTML document. More...
 
static void html_document_user_data_handler (dom_node_operation operation, dom_string *key, void *data, struct dom_node *src, struct dom_node *dst)
 
static nserror html_create_html_data (html_content *c, const http_parameter *params)
 
static nserror html_create (const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
 Create a CONTENT_HTML. More...
 
static nserror html_process_encoding_change (struct content *c, const char *data, unsigned int size)
 
static bool html_process_data (struct content *c, const char *data, unsigned int size)
 Process data for CONTENT_HTML. More...
 
static bool html_convert (struct content *c)
 Convert a CONTENT_HTML for display. More...
 
bool html_can_begin_conversion (html_content *htmlc)
 Test if an HTML content conversion can begin. More...
 
bool html_begin_conversion (html_content *htmlc)
 Begin conversion of an HTML document. More...
 
static void html_stop (struct content *c)
 Stop loading a CONTENT_HTML. More...
 
static void html_reformat (struct content *c, int width, int height)
 Reformat a CONTENT_HTML to a new width. More...
 
void html_redraw_a_box (hlcache_handle *h, struct box *box)
 Redraw a box. More...
 
void html__redraw_a_box (struct html_content *html, struct box *box)
 Redraw a box. More...
 
static void html_destroy_frameset (struct content_html_frames *frameset)
 
static void html_destroy_iframe (struct content_html_iframe *iframe)
 
static void html_free_layout (html_content *htmlc)
 
static void html_destroy (struct content *c)
 Destroy a CONTENT_HTML and free all resources it owns. More...
 
static nserror html_clone (const struct content *old, struct content **newc)
 
static nserror html_open (struct content *c, struct browser_window *bw, struct content *page, struct object_params *params)
 Handle a window containing a CONTENT_HTML being opened. More...
 
static nserror html_close (struct content *c)
 Handle a window containing a CONTENT_HTML being closed. More...
 
static void html_clear_selection (struct content *c)
 Return an HTML content's selection context. More...
 
static char * html_get_selection (struct content *c)
 Return an HTML content's selection context. More...
 
static nserror html_get_contextual_content (struct content *c, int x, int y, struct browser_window_features *data)
 Get access to any content, link URLs and objects (images) currently at the given (x, y) coordinates. More...
 
static bool html_scroll_at_point (struct content *c, int x, int y, int scrx, int scry)
 Scroll deepest thing within the content which can be scrolled at given point. More...
 
static void html__dom_user_data_handler (dom_node_operation operation, dom_string *key, void *_data, struct dom_node *src, struct dom_node *dst)
 Helper for file gadgets to store their filename unencoded on the dom node associated with the gadget. More...
 
static void html__set_file_gadget_filename (struct content *c, struct form_control *gadget, const char *fn)
 
void html_set_file_gadget_filename (struct hlcache_handle *hl, struct form_control *gadget, const char *fn)
 set filename on a file gadget More...
 
static bool html_drop_file_at_point (struct content *c, int x, int y, char *file)
 Drop a file onto a content at a particular point, or determine if a file may be dropped onto the content at given point. More...
 
static nserror html_debug (struct content *c, enum content_debug op)
 set debug status. More...
 
static nserror html_debug_dump (struct content *c, FILE *f, enum content_debug op)
 Dump debug info concerning the html_content. More...
 
dom_document * html_get_document (hlcache_handle *h)
 Retrieve HTML document tree. More...
 
struct boxhtml_get_box_tree (hlcache_handle *h)
 Retrieve box tree. More...
 
static const char * html_encoding (const struct content *c, enum content_encoding_type op)
 Retrieve the charset of an HTML document. More...
 
struct content_html_frameshtml_get_frameset (hlcache_handle *h)
 Retrieve framesets used in an HTML document. More...
 
struct content_html_iframehtml_get_iframe (hlcache_handle *h)
 Retrieve iframes used in an HTML document. More...
 
nsurlhtml_get_base_url (hlcache_handle *h)
 Retrieve an HTML content's base URL. More...
 
const char * html_get_base_target (hlcache_handle *h)
 Retrieve an HTML content's base target. More...
 
bool html_get_id_offset (hlcache_handle *h, lwc_string *frag_id, int *x, int *y)
 Retrieve layout coordinates of box with given id. More...
 
bool html_exec (struct content *c, const char *src, size_t srclen)
 execute some text as a script element More...
 
static bool html_saw_insecure_objects (struct content *c)
 
static content_type html_content_type (void)
 Compute the type of a content. More...
 
static void html_fini (void)
 
static nserror find_occurrences_html_box (const char *pattern, int p_len, struct box *cur, bool case_sens, struct textsearch_context *context)
 Finds all occurrences of a given string in an html box. More...
 
static nserror html_textsearch_find (struct content *c, struct textsearch_context *context, const char *pattern, int p_len, bool csens)
 Finds all occurrences of a given string in the html box tree. More...
 
static nserror html_textsearch_bounds (struct content *c, unsigned start_idx, unsigned end_idx, struct box *start_box, struct box *end_box, struct rect *bounds)
 
nserror html_init (void)
 initialise content handler More...
 

Variables

static const char * html_types []
 
static const content_handler html_content_handler
 HTML content handler function table. More...
 

Detailed Description

Implementation of HTML content handling.

Definition in file html.c.

Macro Definition Documentation

◆ ALWAYS_DUMP_BOX

#define ALWAYS_DUMP_BOX   0

Definition at line 81 of file html.c.

◆ ALWAYS_DUMP_FRAMESET

#define ALWAYS_DUMP_FRAMESET   0

Definition at line 80 of file html.c.

◆ CHUNK

#define CHUNK   4096

Definition at line 75 of file html.c.

Function Documentation

◆ find_occurrences_html_box()

static nserror find_occurrences_html_box ( const char *  pattern,
int  p_len,
struct box cur,
bool  case_sens,
struct textsearch_context context 
)
static

Finds all occurrences of a given string in an html box.

Parameters
patternthe string pattern to search for
p_lenpattern length
curpointer to the current box
case_senswhether to perform a case sensitive search
contextThe search context to add the entry to.
Returns
true on success, false on memory allocation failure

Definition at line 2230 of file html.c.

References box::byte_offset, box::children, content_textsearch_add_match(), content_textsearch_find_pattern(), find_occurrences_html_box(), box::length, box::next, NSERROR_OK, box::object, box::text, and text().

Referenced by find_occurrences_html_box(), and html_textsearch_find().

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

◆ fire_dom_event()

static bool fire_dom_event ( dom_event *  event,
dom_node *  target 
)
static

Fire an event at the DOM.

Helper that swallows DOM errors.

Parameters
[in]eventthe event to fire at the DOM
[in]targetthe event target
Returns
true on success

Definition at line 97 of file html.c.

References result.

Referenced by fire_dom_keyboard_event(), and fire_generic_dom_event().

Here is the caller graph for this function:

◆ fire_dom_keyboard_event()

bool fire_dom_keyboard_event ( dom_string *  type,
dom_node *  target,
bool  bubbles,
bool  cancelable,
uint32_t  key 
)

Construct a keyboard event and fire it at the DOM.

Definition at line 133 of file html.c.

References fire_dom_event(), NS_KEY_DOWN, NS_KEY_ESCAPE, NS_KEY_LEFT, NS_KEY_PAGE_DOWN, NS_KEY_PAGE_UP, NS_KEY_RIGHT, NS_KEY_TEXT_END, NS_KEY_TEXT_START, NS_KEY_UP, NSLOG, result, type, and utf8_from_ucs4().

Referenced by html_keypress().

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

◆ fire_generic_dom_event()

bool fire_generic_dom_event ( dom_string *  type,
dom_node *  target,
bool  bubbles,
bool  cancelable 
)

Construct an event and fire it at the DOM.

Definition at line 111 of file html.c.

References fire_dom_event(), NSLOG, result, and type.

Referenced by mouse_action_drag_none().

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

◆ html__dom_user_data_handler()

static void html__dom_user_data_handler ( dom_node_operation  operation,
dom_string *  key,
void *  _data,
struct dom_node *  src,
struct dom_node *  dst 
)
static

Helper for file gadgets to store their filename unencoded on the dom node associated with the gadget.

Todo:
Get rid of this crap eventually

Definition at line 1597 of file html.c.

References html__dom_user_data_handler(), and NSLOG.

Referenced by html__dom_user_data_handler(), and html__set_file_gadget_filename().

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

◆ html__redraw_a_box()

void html__redraw_a_box ( struct html_content html,
struct box box 
)

Redraw a box.

redraw a box

Parameters
htmlcontent containing the box, of type CONTENT_HTML
boxbox to redraw.

Definition at line 1130 of file html.c.

References BOTTOM, box_coords(), content__request_redraw(), box::height, LEFT, box::padding, RIGHT, TOP, box::width, box::x, and box::y.

Referenced by form__select_process_selection(), form_radio_set(), gadget_mouse_action(), html__set_file_gadget_filename(), html_overflow_scroll_callback(), and html_texty_element_update().

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

◆ html__set_file_gadget_filename()

static void html__set_file_gadget_filename ( struct content c,
struct form_control gadget,
const char *  fn 
)
static

Definition at line 1634 of file html.c.

References form_control::box, form_gadget_update_value(), box::gadget, guit, html__dom_user_data_handler(), html__redraw_a_box(), gui_utf8_table::local_to_utf8, form_control::node, NSERROR_BAD_ENCODING, NSERROR_OK, NSLOG, and netsurf_table::utf8.

Referenced by html_drop_file_at_point(), and html_set_file_gadget_filename().

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

◆ html_begin_conversion()

bool html_begin_conversion ( html_content htmlc)

Begin conversion of an HTML document.

Parameters
htmlcContent to convert

Definition at line 833 of file html.c.

References html_content::aborted, form::action, content::active, html_content::base, html_content::base_url, content_broadcast_error(), content_get_url(), content_set_error(), html_content::conversion_begun, html_content::document, form::document_charset, html_content::encoding, html_content::encoding_source, html_content::forms, html_can_begin_conversion(), html_finish_conversion(), html_forms_get_forms(), html_script_exec(), libdom_hubbub_error_to_nserror(), node_name(), NSERROR_DOM, NSERROR_NOMEM, NSERROR_OK, NSERROR_STOPPED, NSLOG, nsurl_access(), nsurl_join(), nsurl_unref(), html_content::parse_completed, html_content::parser, and form::prev.

Referenced by convert_script_async_cb(), convert_script_defer_cb(), convert_script_sync_cb(), html_convert(), and html_convert_css_callback().

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

◆ html_box_convert_done()

static void html_box_convert_done ( html_content c,
bool  success 
)
static

Perform post-box-creation conversion of a document.

Parameters
cHTML content to complete conversion of
successWhether box tree construction was successful
Todo:
should this call html_object_free_objects(c); like the other error paths

Definition at line 216 of file html.c.

References html_content::aborted, html_content::base, html_content::box_conversion_context, box_dump(), box::children, content_broadcast_error(), content_set_error(), content_set_ready(), html_content::document, html_content::frameset, html_object_free_objects(), html_proceed_to_done(), imagemap_extract(), html_content::layout, NSERROR_BOX_CONVERT, NSERROR_DOM, NSERROR_OK, NSERROR_STOPPED, NSLOG, and html_content::parser.

Referenced by html_finish_conversion().

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

◆ html_can_begin_conversion()

bool html_can_begin_conversion ( html_content htmlc)

Test if an HTML content conversion can begin.

Parameters
htmlchtml content to test
Returns
true iff the html content conversion can begin

Definition at line 814 of file html.c.

References content::active, html_content::base, html_stylesheet::modified, html_content::stylesheet_count, and html_content::stylesheets.

Referenced by convert_script_async_cb(), convert_script_defer_cb(), convert_script_sync_cb(), html_begin_conversion(), html_convert(), and html_convert_css_callback().

Here is the caller graph for this function:

◆ html_clear_selection()

static void html_clear_selection ( struct content c)
static

Return an HTML content's selection context.

Definition at line 1383 of file html.c.

References html_selection_owner::content, content_clear_selection(), HTML_SELECTION_CONTENT, HTML_SELECTION_NONE, HTML_SELECTION_SELF, HTML_SELECTION_TEXTAREA, html_selection_owner::none, box::object, html_content::sel, selection_clear(), html_content::selection_owner, html_content::selection_type, box::text, html_selection_owner::textarea, and textarea_clear_selection().

Here is the call graph for this function:

◆ html_clone()

static nserror html_clone ( const struct content old,
struct content **  newc 
)
static
Todo:
Clone HTML specifics

Definition at line 1311 of file html.c.

◆ html_close()

static nserror html_close ( struct content c)
static

Handle a window containing a CONTENT_HTML being closed.

Definition at line 1357 of file html.c.

References html_content::bw, html_object_close_objects(), js_closethread(), html_content::jsthread, NSERROR_OK, html_content::sel, and selection_clear().

Here is the call graph for this function:

◆ html_content_type()

static content_type html_content_type ( void  )
static

Compute the type of a content.

Returns
CONTENT_HTML

Definition at line 2208 of file html.c.

References CONTENT_HTML.

◆ html_convert()

static bool html_convert ( struct content c)
static

Convert a CONTENT_HTML for display.

The following steps are carried out in order:

  • parsing to an XML tree is completed
  • stylesheets are fetched
  • the XML tree is converted to a box tree and object fetches are started

On exit, the content status will be either CONTENT_STATUS_DONE if the document is completely loaded or CONTENT_STATUS_READY if objects are still being fetched.

Definition at line 777 of file html.c.

References content::active, html_content::base, html_content::document, html_begin_conversion(), html_can_begin_conversion(), html_css_quirks_stylesheets(), NSLOG, and html_content::quirks.

Here is the call graph for this function:

◆ html_create()

static nserror html_create ( const content_handler handler,
lwc_string *  imime_type,
const http_parameter params,
llcache_handle llcache,
const char *  fallback_charset,
bool  quirks,
struct content **  c 
)
static

Create a CONTENT_HTML.

The content_html_data structure is initialized and the HTML parser is created.

Definition at line 605 of file html.c.

References html_content::base, content__init(), content_broadcast_error(), html_create_html_data(), html_css_new_stylesheets(), llcache, NSERROR_NOMEM, and NSERROR_OK.

Here is the call graph for this function:

◆ html_create_html_data()

static nserror html_create_html_data ( html_content c,
const http_parameter params 
)
static

Definition at line 453 of file html.c.

References html_content::aborted, content::active, html_content::background_colour, html_content::base, html_content::base_target, html_content::base_url, html_content::bctx, html_content::bw, content_get_url(), html_content::conversion_begun, html_content::document, html_content::drag_owner, html_content::drag_type, html_content::enable_scripting, html_content::encoding, html_content::encoding_source, html_content::focus_owner, html_content::focus_type, html_content::font_func, html_content::forms, html_content::frameset, guit, html_document_user_data_handler(), html_dom_event_fetcher(), HTML_DRAG_NONE, HTML_FOCUS_SELF, html_process_script(), HTML_SELECTION_NONE, http_parameter_list_find_item(), html_content::iframe, html_content::imagemaps, html_content::jsthread, html_content::layout, netsurf_table::layout, libdom_hubbub_error_to_nserror(), html_content::media, html_drag_owner::no_owner, html_selection_owner::none, NS_TRANSPARENT, NSERROR_DOM, NSERROR_NOMEM, NSERROR_OK, NSLOG, nsoption_bool, nsurl_ref(), nsurl_unref(), html_content::num_objects, html_content::object_list, html_content::page, html_content::parse_completed, html_content::parser, html_content::quirks, html_content::reflowing, html_content::refresh, html_content::scripts, html_content::scripts_count, html_content::sel, html_content::select_ctx, selection_create(), html_content::selection_owner, html_content::selection_type, html_focus_owner::self, SLEN, html_content::stylesheet_count, html_content::stylesheets, html_content::title, and html_content::universal.

Referenced by html_create().

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

◆ html_debug()

static nserror html_debug ( struct content c,
enum content_debug  op 
)
static

set debug status.

Parameters
cThe content to debug
opThe debug operation type

Definition at line 1841 of file html.c.

References html_redraw_debug, and NSERROR_OK.

◆ html_debug_dump()

static nserror html_debug_dump ( struct content c,
FILE *  f,
enum content_debug  op 
)
static

Dump debug info concerning the html_content.

Parameters
cThe content to debug
fThe file to dump to
opThe debug dump type

Definition at line 1857 of file html.c.

References box_dump(), CONTENT_DEBUG_RENDER, html_content::document, html_content::layout, libdom_dump_structure(), NSERROR_DOM, NSERROR_OK, and NSLOG.

Here is the call graph for this function:

◆ html_destroy()

static void html_destroy ( struct content c)
static

◆ html_destroy_frameset()

static void html_destroy_frameset ( struct content_html_frames frameset)
static

Definition at line 1141 of file html.c.

References content_html_frames::children, content_html_frames::cols, html_destroy_frameset(), content_html_frames::name, nsurl_unref(), content_html_frames::rows, talloc_free(), and content_html_frames::url.

Referenced by html_destroy(), and html_destroy_frameset().

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

◆ html_destroy_iframe()

static void html_destroy_iframe ( struct content_html_iframe iframe)
static

Definition at line 1171 of file html.c.

References content_html_iframe::name, content_html_iframe::next, nsurl_unref(), talloc_free(), and content_html_iframe::url.

Referenced by html_destroy().

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

◆ html_document_user_data_handler()

static void html_document_user_data_handler ( dom_node_operation  operation,
dom_string *  key,
void *  data,
struct dom_node *  src,
struct dom_node *  dst 
)
static

Definition at line 419 of file html.c.

References NSLOG.

Referenced by html_create_html_data().

Here is the caller graph for this function:

◆ html_drop_file_at_point()

static bool html_drop_file_at_point ( struct content c,
int  x,
int  y,
char *  file 
)
static

Drop a file onto a content at a particular point, or determine if a file may be dropped onto the content at given point.

Parameters
chtml content to look inside
xx-coordinate of point of interest
yy-coordinate of point of interest
filepath to file to be dropped, or NULL to know if drop allowed
Returns
true iff file drop has been handled, or if drop possible (NULL file)

Definition at line 1683 of file html.c.

References box_at_point(), box_coords(), BROWSER_MOUSE_PRESS_1, browser_window_drop_file_at_point(), browser_window_get_scale(), buffer, content_drop_file_at_point(), form_control::data, box::gadget, GADGET_FILE, GADGET_PASSWORD, GADGET_TEXTAREA, GADGET_TEXTBOX, guit, html__set_file_gadget_filename(), box::iframe, html_content::layout, gui_utf8_table::local_to_utf8, messages_get_errorcode(), box::next, NSERROR_BAD_ENCODING, NSERROR_OK, NSLOG, box::object, box::style, textarea_drop_text(), textarea_mouse_action(), form_control::type, html_content::unit_len_ctx, netsurf_table::utf8, box::x, and box::y.

Here is the call graph for this function:

◆ html_encoding()

static const char * html_encoding ( const struct content c,
enum content_encoding_type  op 
)
static

Retrieve the charset of an HTML document.

Parameters
cContent to retrieve charset from
opThe content encoding operation to perform.
Returns
Pointer to charset, or NULL

Definition at line 1987 of file html.c.

References CONTENT_ENCODING_SOURCE, html_content::encoding, html_content::encoding_source, and messages_get().

Here is the call graph for this function:

◆ html_exec()

bool html_exec ( struct content c,
const char *  src,
size_t  srclen 
)

execute some text as a script element

Definition at line 2090 of file html.c.

References html_content::document, NSLOG, and result.

Referenced by mouse_action_drag_none().

Here is the caller graph for this function:

◆ html_fini()

static void html_fini ( void  )
static

Definition at line 2214 of file html.c.

References html_css_fini().

Referenced by html_init().

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

◆ html_finish_conversion()

void html_finish_conversion ( html_content htmlc)

Complete conversion of an HTML document.

Parameters
htmlcContent to convert

Definition at line 341 of file html.c.

References html_content::aborted, html_content::base, html_content::box_conversion_context, content_broadcast(), content_broadcast_error(), CONTENT_MSG_STATUS, content_set_error(), content_set_status(), html_content::document, dom_to_box(), content_msg_data::explicit_status_text, html_box_convert_done(), html_css_new_selection_context(), html_get_dimensions(), html_object_free_objects(), js_fire_event(), html_content::jsthread, messages_get(), NSERROR_DOM, NSERROR_OK, NSERROR_STOPPED, NSLOG, and html_content::select_ctx.

Referenced by html_begin_conversion().

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

◆ html_free_layout()

static void html_free_layout ( html_content htmlc)
static

Definition at line 1188 of file html.c.

References html_content::bctx, and talloc_free().

Referenced by html_destroy().

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

◆ html_get_base_target()

const char * html_get_base_target ( hlcache_handle h)

Retrieve an HTML content's base target.

obtain html base target from handle

Parameters
hContent to retrieve base target from
Returns
Pointer to target, or NULL if none

Definition at line 2054 of file html.c.

References html_content::base_target, and hlcache_handle_get_content().

Referenced by browser_window_find_target().

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

◆ html_get_base_url()

nsurl * html_get_base_url ( hlcache_handle h)

Retrieve an HTML content's base URL.

get the base url of an html content from a handle

Parameters
hContent to retrieve base target from
Returns
Pointer to URL

Definition at line 2039 of file html.c.

References html_content::base_url, and hlcache_handle_get_content().

Referenced by save_complete_save_html_document().

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

◆ html_get_box_tree()

struct box * html_get_box_tree ( hlcache_handle h)

Retrieve box tree.

get the render box tree of a html content from a handle

Parameters
hHTML content to retrieve tree from
Returns
Pointer to box tree
Todo:
This API must die, as must all use of the box tree outside of HTML content handler

Definition at line 1971 of file html.c.

References hlcache_handle_get_content(), and html_content::layout.

Referenced by html_get_id_offset(), layout_minmax_block(), and save_as_text().

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

◆ html_get_contextual_content()

static nserror html_get_contextual_content ( struct content c,
int  x,
int  y,
struct browser_window_features data 
)
static

Get access to any content, link URLs and objects (images) currently at the given (x, y) coordinates.

Parameters
[in]chtml content to look inside
[in]xx-coordinate of point of interest
[in]yy-coordinate of point of interest
[out]dataPositional features struct to be updated with any relevent content, or set to NULL if none.
Returns
NSERROR_OK on success else appropriate error code.

Definition at line 1455 of file html.c.

References box_at_point(), browser_window_get_features(), browser_window_get_scale(), content_get_contextual_content(), browser_window_features::form_features, box::gadget, GADGET_FILE, GADGET_PASSWORD, GADGET_TEXTAREA, GADGET_TEXTBOX, box::href, box::iframe, imagemap_get(), html_content::layout, browser_window_features::link, box::next, NSERROR_OK, box::object, browser_window_features::object, box::style, box::target, form_control::type, html_content::unit_len_ctx, box::usemap, box::x, and box::y.

Here is the call graph for this function:

◆ html_get_dimensions()

static void html_get_dimensions ( html_content htmlc)
static
Todo:
Change nsoption font sizes to px.

Definition at line 306 of file html.c.

References html_content::base, content_broadcast(), CONTENT_MSG_GETDIMS, content_msg_data::getdims, html_content::media, nscss_screen_dpi, nsoption_int, html_content::unit_len_ctx, and content_msg_data::viewport_width.

Referenced by html_finish_conversion().

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

◆ html_get_document()

dom_document * html_get_document ( hlcache_handle h)

Retrieve HTML document tree.

get the dom document of a html content from a handle

Parameters
hHTML content to retrieve document tree from
Returns
Pointer to document tree

Definition at line 1953 of file html.c.

References html_content::document, and hlcache_handle_get_content().

Referenced by save_complete_save_html_document().

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

◆ html_get_frameset()

struct content_html_frames * html_get_frameset ( hlcache_handle h)

Retrieve framesets used in an HTML document.

obtain html frame content from handle

Parameters
hContent to inspect
Returns
Pointer to framesets, or NULL if none

Definition at line 2009 of file html.c.

References html_content::frameset, and hlcache_handle_get_content().

Referenced by browser_window_create_frameset(), and browser_window_recalculate_frameset().

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

◆ html_get_id_offset()

bool html_get_id_offset ( hlcache_handle h,
lwc_string *  frag_id,
int *  x,
int *  y 
)

Retrieve layout coordinates of box with given id.

get the offset within the docuemnt of a fragment id

Parameters
hHTML document to search
frag_idString containing an element id
xUpdated to global x coord iff id found
yUpdated to global y coord iff id found
Returns
true iff id found

Definition at line 2073 of file html.c.

References box_coords(), box_find_by_id(), content_get_type(), CONTENT_HTML, html_get_box_tree(), box::x, and box::y.

Referenced by frag_scroll().

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

◆ html_get_iframe()

struct content_html_iframe * html_get_iframe ( hlcache_handle h)

Retrieve iframes used in an HTML document.

obtain html iframe content from handle

Parameters
hContent to inspect
Returns
Pointer to iframes, or NULL if none

Definition at line 2024 of file html.c.

References hlcache_handle_get_content(), and html_content::iframe.

Referenced by browser_window_create_iframes().

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

◆ html_get_selection()

static char * html_get_selection ( struct content c)
static

Return an HTML content's selection context.

Definition at line 1417 of file html.c.

References html_selection_owner::content, content_get_selection(), HTML_SELECTION_CONTENT, HTML_SELECTION_NONE, HTML_SELECTION_SELF, HTML_SELECTION_TEXTAREA, html_selection_owner::none, box::object, html_content::sel, selection_get_copy(), html_content::selection_owner, html_content::selection_type, box::text, html_selection_owner::textarea, and textarea_get_selection().

Here is the call graph for this function:

◆ html_init()

nserror html_init ( void  )

initialise content handler

Returns
NSERROR_OK on success otherwise appropriate error code

Definition at line 2382 of file html.c.

References content_factory_register_handler(), html_content_handler, html_css_init(), html_fini(), html_types, NOF_ELEMENTS, and NSERROR_OK.

Referenced by netsurf_init().

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

◆ html_open()

static nserror html_open ( struct content c,
struct browser_window bw,
struct content page,
struct object_params params 
)
static

Handle a window containing a CONTENT_HTML being opened.

Definition at line 1329 of file html.c.

References html_content::bw, html_content::drag_owner, html_content::drag_type, HTML_DRAG_NONE, html_object_open_objects(), HTML_SELECTION_NONE, html_drag_owner::no_owner, html_selection_owner::none, NSERROR_OK, html_content::page, html_content::sel, selection_init(), html_content::selection_owner, and html_content::selection_type.

Here is the call graph for this function:

◆ html_proceed_to_done()

nserror html_proceed_to_done ( html_content html)

Complete the HTML content state machine iff all scripts are finished.

Definition at line 285 of file html.c.

References content::active, html_content::base, content__get_status(), content_set_done(), CONTENT_STATUS_DONE, CONTENT_STATUS_LOADING, CONTENT_STATUS_READY, NSERROR_OK, NSERROR_UNKNOWN, and NSLOG.

Referenced by html_box_convert_done(), and html_script_exec().

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

◆ html_process_data()

static bool html_process_data ( struct content c,
const char *  data,
unsigned int  size 
)
static

Process data for CONTENT_HTML.

Definition at line 736 of file html.c.

References content_broadcast_error(), html_process_encoding_change(), libdom_hubbub_error_to_nserror(), NSERROR_ENCODING_CHANGE, NSERROR_OK, html_content::parser, and content::size.

Here is the call graph for this function:

◆ html_process_encoding_change()

static nserror html_process_encoding_change ( struct content c,
const char *  data,
unsigned int  size 
)
static

Definition at line 649 of file html.c.

References content__get_source_data(), html_content::document, html_content::enable_scripting, html_content::encoding, html_content::encoding_source, html_dom_event_fetcher(), html_process_script(), libdom_hubbub_error_to_nserror(), NSERROR_NOMEM, and html_content::parser.

Referenced by html_process_data().

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

◆ html_redraw_a_box()

void html_redraw_a_box ( hlcache_handle h,
struct box box 
)

Redraw a box.

redraw a specific box

Parameters
hcontent containing the box, of type CONTENT_HTML
boxbox to redraw

Definition at line 1111 of file html.c.

References BOTTOM, box_coords(), content_request_redraw(), box::height, LEFT, box::padding, RIGHT, TOP, box::width, box::x, and box::y.

Referenced by browser_window_invalidate_iframe(), and browser_window_scroll_callback().

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

◆ html_reformat()

static void html_reformat ( struct content c,
int  width,
int  height 
)
static

Reformat a CONTENT_HTML to a new width.

Definition at line 1053 of file html.c.

References box::border, BOTTOM, box::descendant_x1, box::descendant_y1, html_content::had_initial_layout, content::height, box::height, height, html_content::layout, layout_document(), LEFT, box::margin, nsoption_uint, box::padding, html_content::reflowing, content::reformat_time, RIGHT, html_content::sel, selection_reinit(), box::style, TOP, html_content::unit_len_ctx, content::width, box_border::width, box::width, width, box::x, and box::y.

Here is the call graph for this function:

◆ html_saw_insecure_objects()

static bool html_saw_insecure_objects ( struct content c)
static

Definition at line 2176 of file html.c.

References content_html_object::content, content_saw_insecure_objects(), html_css_saw_insecure_stylesheets(), html_saw_insecure_scripts(), content_html_object::next, and html_content::object_list.

Here is the call graph for this function:

◆ html_scroll_at_point()

static bool html_scroll_at_point ( struct content c,
int  x,
int  y,
int  scrx,
int  scry 
)
static

Scroll deepest thing within the content which can be scrolled at given point.

Parameters
chtml content to look inside
xx-coordinate of point of interest
yy-coordinate of point of interest
scrxnumber of px try to scroll something in x direction
scrynumber of px try to scroll something in y direction
Returns
true iff scroll was consumed by something in the content

Definition at line 1534 of file html.c.

References box_at_point(), browser_window_get_scale(), browser_window_scroll_at_point(), content_scroll_at_point(), form_control::data, box::gadget, GADGET_PASSWORD, GADGET_TEXTAREA, GADGET_TEXTBOX, box::iframe, html_content::layout, box::next, box::object, box::scroll_x, box::scroll_y, scrollbar_scroll(), box::style, textarea_scroll(), form_control::type, html_content::unit_len_ctx, box::x, and box::y.

Here is the call graph for this function:

◆ html_set_file_gadget_filename()

void html_set_file_gadget_filename ( struct hlcache_handle hl,
struct form_control gadget,
const char *  fn 
)

set filename on a file gadget

used by core browser

Definition at line 1666 of file html.c.

References box::gadget, hl, hlcache_handle_get_content(), and html__set_file_gadget_filename().

Referenced by browser_window_set_gadget_filename().

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

◆ html_stop()

static void html_stop ( struct content c)
static

Stop loading a CONTENT_HTML.

called when the content is aborted. This must clean up any state created during the fetch.

Definition at line 1011 of file html.c.

References html_content::aborted, content::active, content_set_done(), CONTENT_STATUS_DONE, CONTENT_STATUS_LOADING, CONTENT_STATUS_READY, html_object_abort_objects(), js_closethread(), html_content::jsthread, NSLOG, and content::status.

Here is the call graph for this function:

◆ html_textsearch_bounds()

static nserror html_textsearch_bounds ( struct content c,
unsigned  start_idx,
unsigned  end_idx,
struct box start_box,
struct box end_box,
struct rect bounds 
)
static

Definition at line 2324 of file html.c.

References box_coords(), box::height, NSERROR_OK, box::width, rect::x0, rect::x1, rect::y0, and rect::y1.

Here is the call graph for this function:

◆ html_textsearch_find()

static nserror html_textsearch_find ( struct content c,
struct textsearch_context context,
const char *  pattern,
int  p_len,
bool  csens 
)
static

Finds all occurrences of a given string in the html box tree.

Parameters
patternthe string pattern to search for
p_lenpattern length
cThe content to search
csenswhether to perform a case sensitive search
contextThe search context to add the entry to.
Returns
true on success, false on memory allocation failure

Definition at line 2303 of file html.c.

References find_occurrences_html_box(), html_content::layout, and NSERROR_INVALID.

Here is the call graph for this function:

Variable Documentation

◆ html_content_handler

const content_handler html_content_handler
static

HTML content handler function table.

Definition at line 2346 of file html.c.

Referenced by html_init().

◆ html_types

const char* html_types[]
static
Initial value:
= {
"application/xhtml+xml",
"text/html"
}

Definition at line 83 of file html.c.

Referenced by html_init().