NetSurf
Functions
dom_event.c File Reference

Implementation of HTML content DOM event handling. More...

#include <string.h>
#include "utils/config.h"
#include "utils/utils.h"
#include "utils/corestrings.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/ascii.h"
#include "utils/nsurl.h"
#include "content/content.h"
#include "javascript/js.h"
#include "netsurf/bitmap.h"
#include "html/private.h"
#include "html/object.h"
#include "html/css.h"
#include "html/box.h"
#include "html/box_construct.h"
#include "html/form_internal.h"
#include "html/dom_event.h"
Include dependency graph for dom_event.c:

Go to the source code of this file.

Functions

static bool html_process_inserted_base (html_content *htmlc, dom_node *node)
 process a base element being inserted into the DOM More...
 
static bool html_process_inserted_img (html_content *htmlc, dom_node *node)
 Process img element being inserted into the DOM. More...
 
static bool html_process_inserted_link (html_content *c, dom_node *node)
 process a LINK element being inserted into the DOM More...
 
static void dom_SCRIPT_showed_up (html_content *htmlc, dom_html_script_element *script)
 
static nserror html_process_inserted_meta (html_content *c, dom_node *n)
 process a META element being inserted into the DOM More...
 
static nserror html_process_inserted_title (html_content *htmlc, dom_node *node)
 Process title element being inserted into the DOM. More...
 
static bool html_process_title (html_content *c, dom_node *node)
 process title node More...
 
static void html_texty_element_update (html_content *htmlc, dom_node *node)
 Deal with input elements being modified by resyncing their gadget if they have one. More...
 
static void dom_default_action_DOMNodeInserted_cb (struct dom_event *evt, void *pw)
 callback for DOMNodeInserted end type More...
 
static void dom_default_action_DOMNodeInsertedIntoDocument_cb (struct dom_event *evt, void *pw)
 callback for DOMNodeInsertedIntoDocument end type More...
 
static void dom_default_action_DOMSubtreeModified_cb (struct dom_event *evt, void *pw)
 callback for DOMSubtreeModified end type More...
 
static void dom_default_action_finished_cb (struct dom_event *evt, void *pw)
 callback for default action finished More...
 
dom_default_action_callback html_dom_event_fetcher (dom_string *type, dom_default_action_phase phase, void **pw)
 html content DOM action callback function selector More...
 

Detailed Description

Implementation of HTML content DOM event handling.

Definition in file dom_event.c.

Function Documentation

◆ dom_default_action_DOMNodeInserted_cb()

static void dom_default_action_DOMNodeInserted_cb ( struct dom_event *  evt,
void *  pw 
)
static

callback for DOMNodeInserted end type

Definition at line 585 of file dom_event.c.

References html_content::base, content_broadcast(), CONTENT_MSG_GETTHREAD, dom_SCRIPT_showed_up(), html_content::enable_scripting, html_css_process_style(), html_process_inserted_base(), html_process_inserted_img(), html_process_inserted_link(), html_process_inserted_meta(), html_process_inserted_title(), js_handle_new_element(), content_msg_data::jsthread, html_content::jsthread, box::node, NSLOG, nsoption_bool, and type.

Referenced by html_dom_event_fetcher().

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

◆ dom_default_action_DOMNodeInsertedIntoDocument_cb()

static void dom_default_action_DOMNodeInsertedIntoDocument_cb ( struct dom_event *  evt,
void *  pw 
)
static

callback for DOMNodeInsertedIntoDocument end type

Definition at line 672 of file dom_event.c.

References dom_SCRIPT_showed_up(), fallthrough, and type.

Referenced by html_dom_event_fetcher().

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

◆ dom_default_action_DOMSubtreeModified_cb()

static void dom_default_action_DOMSubtreeModified_cb ( struct dom_event *  evt,
void *  pw 
)
static

callback for DOMSubtreeModified end type

Definition at line 709 of file dom_event.c.

References fallthrough, html_css_update_style(), html_process_title(), html_texty_element_update(), nsoption_bool, html_content::title, and type.

Referenced by html_dom_event_fetcher().

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

◆ dom_default_action_finished_cb()

static void dom_default_action_finished_cb ( struct dom_event *  evt,
void *  pw 
)
static

callback for default action finished

Definition at line 759 of file dom_event.c.

References js_event_cleanup(), and html_content::jsthread.

Referenced by html_dom_event_fetcher().

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

◆ dom_SCRIPT_showed_up()

static void dom_SCRIPT_showed_up ( html_content htmlc,
dom_html_script_element *  script 
)
static

Definition at line 258 of file dom_event.c.

References html_content::document, html_content::enable_scripting, html_process_script(), and NSLOG.

Referenced by dom_default_action_DOMNodeInserted_cb(), and dom_default_action_DOMNodeInsertedIntoDocument_cb().

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

◆ html_dom_event_fetcher()

dom_default_action_callback html_dom_event_fetcher ( dom_string *  type,
dom_default_action_phase  phase,
void **  pw 
)

html content DOM action callback function selector

selects a callback function for libdom to call based on the type and phase. dom_default_action_phase from events/document_event.h

The principle events are: DOMSubtreeModified DOMAttrModified DOMNodeInserted DOMNodeInsertedIntoDocument

Returns
callback function pointer or NULL for none

Definition at line 770 of file dom_event.c.

References dom_default_action_DOMNodeInserted_cb(), dom_default_action_DOMNodeInsertedIntoDocument_cb(), dom_default_action_DOMSubtreeModified_cb(), dom_default_action_finished_cb(), NSLOG, and type.

Referenced by html_create_html_data(), and html_process_encoding_change().

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

◆ html_process_inserted_base()

static bool html_process_inserted_base ( html_content htmlc,
dom_node *  node 
)
static

process a base element being inserted into the DOM

Parameters
htmlcThe html content containing the DOM
nodeThe DOM node being inserted
Returns
NSERROR_OK on success else appropriate error code

Definition at line 56 of file dom_event.c.

References html_content::base_target, html_content::base_url, NSERROR_OK, nsurl_create(), and nsurl_unref().

Referenced by dom_default_action_DOMNodeInserted_cb().

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

◆ html_process_inserted_img()

static bool html_process_inserted_img ( html_content htmlc,
dom_node *  node 
)
static

Process img element being inserted into the DOM.

Parameters
htmlcThe html content containing the DOM
nodeThe DOM node being inserted
Returns
NSERROR_OK on success else appropriate error code

Definition at line 119 of file dom_event.c.

References html_content::base_url, CONTENT_IMAGE, html_fetch_object(), NSERROR_OK, nsoption_bool, nsurl_join(), and nsurl_unref().

Referenced by dom_default_action_DOMNodeInserted_cb().

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

◆ html_process_inserted_link()

static bool html_process_inserted_link ( html_content c,
dom_node *  node 
)
static

process a LINK element being inserted into the DOM

Note
only the http-equiv attribute for refresh is currently considered
Parameters
htmlcThe html content containing the DOM
nThe DOM node being inserted
Returns
NSERROR_OK on success else appropriate error code

Definition at line 161 of file dom_event.c.

References html_content::base, html_content::base_url, content__add_rfc5988_link(), content_rfc5988_link::href, content_rfc5988_link::hreflang, html_css_process_link(), content_rfc5988_link::media, NSERROR_OK, nsurl_join(), nsurl_unref(), content_rfc5988_link::rel, content_rfc5988_link::sizes, and content_rfc5988_link::type.

Referenced by dom_default_action_DOMNodeInserted_cb().

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

◆ html_process_inserted_meta()

static nserror html_process_inserted_meta ( html_content c,
dom_node *  n 
)
static

process a META element being inserted into the DOM

Note
only the http-equiv attribute for refresh is currently considered
Parameters
htmlcThe html content containing the DOM
nThe DOM node being inserted
Returns
NSERROR_OK on success else appropriate error code

Definition at line 316 of file dom_event.c.

References ascii_is_space(), html_content::base, html_content::base_url, content_msg_data::content, content_broadcast(), content_get_url(), CONTENT_MSG_REFRESH, content_msg_data::delay, NSERROR_DOM, NSERROR_NOMEM, NSERROR_OK, nsurl_join(), nsurl_ref(), content::refresh, html_content::refresh, strndup(), and content_msg_data::url.

Referenced by dom_default_action_DOMNodeInserted_cb().

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

◆ html_process_inserted_title()

static nserror html_process_inserted_title ( html_content htmlc,
dom_node *  node 
)
static

Process title element being inserted into the DOM.

https://html.spec.whatwg.org/multipage/semantics.html#the-title-element

Parameters
htmlcThe html content containing the DOM
nodeThe DOM node being inserted
Returns
NSERROR_OK on success else appropriate error code

Definition at line 524 of file dom_event.c.

References NSERROR_OK, and html_content::title.

Referenced by dom_default_action_DOMNodeInserted_cb().

Here is the caller graph for this function:

◆ html_process_title()

static bool html_process_title ( html_content c,
dom_node *  node 
)
static

process title node

Definition at line 535 of file dom_event.c.

References html_content::base, content__set_title(), squash_whitespace(), and content_msg_data::title.

Referenced by dom_default_action_DOMSubtreeModified_cb().

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

◆ html_texty_element_update()

static void html_texty_element_update ( html_content htmlc,
dom_node *  node 
)
static

Deal with input elements being modified by resyncing their gadget if they have one.

Definition at line 566 of file dom_event.c.

References box_for_node(), form_gadget_sync_with_dom(), box::gadget, html__redraw_a_box(), and box::node.

Referenced by dom_default_action_DOMSubtreeModified_cb().

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