59 dom_string *atr_string;
62 exc = dom_element_get_attribute(node, corestring_dom_href, &atr_string);
63 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
69 dom_string_unref(atr_string);
84 exc = dom_element_get_attribute(node,
85 corestring_dom_target,
87 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
93 if (*dom_string_data(atr_string) !=
'_' ||
94 dom_string_caseless_lwc_isequal(atr_string,
95 corestring_lwc__blank) ||
96 dom_string_caseless_lwc_isequal(atr_string,
97 corestring_lwc__self) ||
98 dom_string_caseless_lwc_isequal(atr_string,
99 corestring_lwc__parent) ||
100 dom_string_caseless_lwc_isequal(atr_string,
101 corestring_lwc__top)) {
102 htmlc->
base_target = strdup(dom_string_data(atr_string));
104 dom_string_unref(atr_string);
132 exc = dom_element_get_attribute(node, corestring_dom_src, &src);
133 if (exc != DOM_NO_ERR || src == NULL) {
139 dom_string_unref(src);
142 dom_string_unref(src);
165 dom_string *atr_string;
176 exc = dom_element_get_attribute(node, corestring_dom_rel, &atr_string);
177 if ((exc != DOM_NO_ERR) || (atr_string == NULL)) {
181 exc = dom_string_intern(atr_string, &link.
rel);
182 dom_string_unref(atr_string);
183 if (exc != DOM_NO_ERR) {
188 exc = dom_element_get_attribute(node, corestring_dom_href, &atr_string);
189 if ((exc != DOM_NO_ERR) || (atr_string == NULL)) {
190 lwc_string_unref(link.
rel);
197 dom_string_unref(atr_string);
199 lwc_string_unref(link.
rel);
205 exc = dom_element_get_attribute(node,
206 corestring_dom_hreflang, &atr_string);
207 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
209 (void)dom_string_intern(atr_string, &link.
hreflang);
210 dom_string_unref(atr_string);
213 exc = dom_element_get_attribute(node,
214 corestring_dom_type, &atr_string);
215 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
217 (void)dom_string_intern(atr_string, &link.
type);
218 dom_string_unref(atr_string);
221 exc = dom_element_get_attribute(node,
222 corestring_dom_media, &atr_string);
223 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
225 (void)dom_string_intern(atr_string, &link.
media);
226 dom_string_unref(atr_string);
229 exc = dom_element_get_attribute(node,
230 corestring_dom_sizes, &atr_string);
231 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
233 (void)dom_string_intern(atr_string, &link.
sizes);
234 dom_string_unref(atr_string);
240 if (link.
sizes != NULL)
241 lwc_string_unref(link.
sizes);
242 if (link.
media != NULL)
243 lwc_string_unref(link.
media);
244 if (link.
type != NULL)
245 lwc_string_unref(link.
type);
250 lwc_string_unref(link.
rel);
261 dom_html_script_element_flags flags;
262 dom_hubbub_error res;
266 NSLOG(netsurf, INFO,
"Encountered a script, but scripting is off, ignoring");
270 NSLOG(netsurf, DEEPDEBUG,
"Encountered a script, node %p showed up", script);
272 exc = dom_html_script_element_get_flags(script, &flags);
273 if (exc != DOM_NO_ERR) {
274 NSLOG(netsurf, DEEPDEBUG,
"Unable to retrieve flags, giving up");
278 if (flags & DOM_HTML_SCRIPT_ELEMENT_FLAG_PARSER_INSERTED) {
279 NSLOG(netsurf, DEBUG,
"Script was parser inserted, skipping");
283 exc = dom_node_contains(htmlc->
document, script, &within);
284 if (exc != DOM_NO_ERR) {
285 NSLOG(netsurf, DEBUG,
"Unable to determine if script was within document, ignoring");
290 NSLOG(netsurf, DEBUG,
"Script was not within the document, ignoring for now");
295 if (res == DOM_HUBBUB_OK) {
296 NSLOG(netsurf, DEEPDEBUG,
"Inserted script has finished running");
298 if (res == (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED)) {
299 NSLOG(netsurf, DEEPDEBUG,
"Inserted script has launced asynchronously");
301 NSLOG(netsurf, DEEPDEBUG,
"Failure starting script");
319 const char *
url, *end, *refresh = NULL;
332 exc = dom_element_get_attribute(n, corestring_dom_http_equiv, &equiv);
333 if (exc != DOM_NO_ERR) {
341 if (!dom_string_caseless_lwc_isequal(equiv, corestring_lwc_refresh)) {
342 dom_string_unref(equiv);
346 dom_string_unref(equiv);
348 exc = dom_element_get_attribute(n, corestring_dom_content, &
content);
349 if (exc != DOM_NO_ERR) {
378 if (
url == end || (*
url <
'0' ||
'9' < *
url)) {
384 msg_data.
delay = (int) strtol(
url, &new_url, 10);
388 if (msg_data.
delay < 1) {
395 while (
url < end && ((
'0' <= *
url && *
url <=
'9') ||
406 if (
url < end && *
url ==
';')
426 if (
url <= end - 3) {
427 if (strncasecmp(
url,
"url", 3) == 0) {
466 if (
url < end && (*
url ==
'"' || *
url ==
'\'')) {
476 while (
url < end && *
url != quote)
488 if (new_url == NULL) {
526 if (htmlc->
title == NULL) {
528 htmlc->
title = dom_node_ref(node);
542 exc = dom_node_get_text_content(node, &
title);
543 if ((exc != DOM_NO_ERR) || (
title == NULL)) {
548 dom_string_unref(
title);
550 if (title_str == NULL) {
587 dom_event_target *
node;
592 exc = dom_event_get_target(evt, &
node);
593 if ((exc != DOM_NO_ERR) || (
node == NULL)) {
598 exc = dom_node_get_node_type(
node, &
type);
599 if ((exc == DOM_NO_ERR) && (
type == DOM_ELEMENT_NODE)) {
601 dom_html_element_type tag_type;
603 exc = dom_html_element_get_tag_type(
node, &tag_type);
604 if (exc != DOM_NO_ERR) {
605 tag_type = DOM_HTML_ELEMENT_TYPE__UNKNOWN;
609 case DOM_HTML_ELEMENT_TYPE_BASE:
613 case DOM_HTML_ELEMENT_TYPE_IMG:
617 case DOM_HTML_ELEMENT_TYPE_LINK:
621 case DOM_HTML_ELEMENT_TYPE_META:
625 case DOM_HTML_ELEMENT_TYPE_STYLE:
631 case DOM_HTML_ELEMENT_TYPE_SCRIPT:
633 (dom_html_script_element *)
node);
636 case DOM_HTML_ELEMENT_TYPE_TITLE:
654 "javascript context: %p (htmlc: %p)",
660 (dom_element *) node);
664 dom_node_unref(node);
676 dom_event_target *node;
680 exc = dom_event_get_target(evt, &node);
681 if ((exc == DOM_NO_ERR) && (node != NULL)) {
682 exc = dom_node_get_node_type(node, &
type);
683 if ((exc == DOM_NO_ERR) && (
type == DOM_ELEMENT_NODE)) {
685 dom_html_element_type tag_type;
687 exc = dom_html_element_get_tag_type(node, &tag_type);
688 if (exc != DOM_NO_ERR) {
689 tag_type = DOM_HTML_ELEMENT_TYPE__UNKNOWN;
693 case DOM_HTML_ELEMENT_TYPE_SCRIPT:
700 dom_node_unref(node);
711 dom_event_target *node;
716 exc = dom_event_get_target(evt, &node);
717 if ((exc == DOM_NO_ERR) && (node != NULL)) {
718 if (htmlc->
title == (dom_node *)node) {
721 dom_node_unref(node);
725 exc = dom_node_get_node_type(node, &
type);
726 if ((exc == DOM_NO_ERR) && (
type == DOM_ELEMENT_NODE)) {
728 dom_html_element_type tag_type;
730 exc = dom_html_element_get_tag_type(node, &tag_type);
731 if (exc != DOM_NO_ERR) {
732 tag_type = DOM_HTML_ELEMENT_TYPE__UNKNOWN;
736 case DOM_HTML_ELEMENT_TYPE_STYLE:
742 case DOM_HTML_ELEMENT_TYPE_TEXTAREA:
743 case DOM_HTML_ELEMENT_TYPE_INPUT:
750 dom_node_unref(node);
769dom_default_action_callback
771 dom_default_action_phase phase,
774 NSLOG(netsurf, DEEPDEBUG,
775 "phase:%d type:%s", phase, dom_string_data(
type));
777 if (phase == DOM_DEFAULT_ACTION_END) {
778 if (dom_string_isequal(
type, corestring_dom_DOMNodeInserted)) {
780 }
else if (dom_string_isequal(
type, corestring_dom_DOMNodeInsertedIntoDocument)) {
782 }
else if (dom_string_isequal(
type, corestring_dom_DOMSubtreeModified)) {
785 }
else if (phase == DOM_DEFAULT_ACTION_FINISHED) {
Helpers for ASCII string handling.
static bool ascii_is_space(char c)
Test whether a character is a whitespace character.
struct box * box_for_node(dom_node *n)
Retrieve the box for a dom node, if there is one.
HTML Box tree construction interface.
char * strndup(const char *s, size_t n)
Duplicate up to n characters of a string.
Content handling interface.
HTML content handler CSS interface.
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.
HTML content object interface.
bool content__add_rfc5988_link(struct content *c, const struct content_rfc5988_link *link)
associate a metadata link with a content.
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
bool content__set_title(struct content *c, const char *title)
Set title associated with content.
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
@ CONTENT_IMAGE
All images.
@ CONTENT_MSG_REFRESH
wants refresh
@ CONTENT_MSG_GETTHREAD
Javascript thread.
Useful interned string pointers (interface).
static nserror html_process_inserted_title(html_content *htmlc, dom_node *node)
Process title element being inserted into the DOM.
static void dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw)
callback for DOMSubtreeModified end type
static void dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw)
callback for DOMNodeInserted end type
static void dom_SCRIPT_showed_up(html_content *htmlc, dom_html_script_element *script)
static void dom_default_action_finished_cb(struct dom_event *evt, void *pw)
callback for default action finished
static bool html_process_title(html_content *c, dom_node *node)
process title node
static void dom_default_action_DOMNodeInsertedIntoDocument_cb(struct dom_event *evt, void *pw)
callback for DOMNodeInsertedIntoDocument end type
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
static bool html_process_inserted_img(html_content *htmlc, dom_node *node)
Process img element being inserted into the DOM.
static bool html_process_inserted_base(html_content *htmlc, dom_node *node)
process a base element being inserted into the DOM
static bool html_process_inserted_link(html_content *c, dom_node *node)
process a LINK element being inserted into the DOM
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.
static nserror html_process_inserted_meta(html_content *c, dom_node *n)
process a META element being inserted into the DOM
HTML content DOM event handling interface.
nserror
Enumeration of error codes.
@ NSERROR_DOM
DOM call returned error.
@ NSERROR_NOMEM
Memory exhaustion.
bool html_css_process_style(html_content *c, dom_node *node)
process a css style dom node
bool html_css_process_link(html_content *htmlc, dom_node *node)
process a css stylesheet dom LINK node
bool html_css_update_style(html_content *c, dom_node *style)
process a css style dom node update
void html__redraw_a_box(struct html_content *html, struct box *box)
Redraw a box.
Generic bitmap handling interface.
Interface to javascript engine functions.
void js_handle_new_element(jsthread *thread, struct dom_element *node)
Handle a new element being created.
void js_event_cleanup(jsthread *thread, struct dom_event *evt)
Handle an event propagation finished callback.
#define NSLOG(catname, level, logmsg, args...)
NetSurf URL handling (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
Join a base url to a relative link part, creating a new NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
Private data for text/html content.
dom_hubbub_error html_process_script(void *ctx, dom_node *node)
process script node parser callback
Interface to utility string handling.
char * squash_whitespace(const char *s)
Replace consecutive whitespace with a single space.
struct form_control * gadget
Form control data, or NULL if not a form control.
struct dom_node * node
DOM node that generated this box or NULL.
lwc_string * rel
the link relationship - must be present
struct nsurl * href
the link href - must be present
Content which corresponds to a single URL.
struct nsurl * refresh
URL for refresh request.
Data specific to CONTENT_HTML.
bool refresh
Whether a meta refresh has been handled.
dom_document * document
Document tree.
struct nsurl * base_url
Base URL (may be a copy of content->url).
char * base_target
Base target.
struct jsthread * jsthread
javascript thread in use
bool enable_scripting
Whether scripts are enabled for this content.
Extra data for some content_msg messages.
int delay
CONTENT_MSG_REFRESH - Minimum delay.
struct jsthread ** jsthread
CONTENT_MSG_GETTHREAD - Javascript context (thread)
struct hlcache_handle * content
if NULL, save the content generating the message
Option reading and saving interface.
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Interface to a number of general purpose functionality.
#define fallthrough
switch fall through