NetSurf
dom_event.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 Michael Drake <tlsa@netsurf-browser.org>
3 * Copyright 2020 Vincent Sanders <vince@netsurf-browser.org>
4 *
5 * This file is part of NetSurf, http://www.netsurf-browser.org/
6 *
7 * NetSurf is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * NetSurf is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/**
21 * \file
22 * Implementation of HTML content DOM event handling.
23 */
24
25#include <string.h>
26
27#include "utils/config.h"
28#include "utils/utils.h"
29#include "utils/corestrings.h"
30#include "utils/nsoption.h"
31#include "utils/log.h"
32#include "utils/ascii.h"
33#include "utils/string.h"
34#include "utils/nsurl.h"
35#include "content/content.h"
36#include "javascript/js.h"
37
38#include "netsurf/bitmap.h"
39
40#include "html/private.h"
41#include "html/object.h"
42#include "html/css.h"
43#include "html/box.h"
44#include "html/box_construct.h"
45#include "html/form_internal.h"
46#include "html/dom_event.h"
47
48
49/**
50 * process a base element being inserted into the DOM
51 *
52 * \param htmlc The html content containing the DOM
53 * \param node The DOM node being inserted
54 * \return NSERROR_OK on success else appropriate error code
55 */
56static bool html_process_inserted_base(html_content *htmlc, dom_node *node)
57{
58 dom_exception exc; /* returned by libdom functions */
59 dom_string *atr_string;
60
61 /* get href attribute if present */
62 exc = dom_element_get_attribute(node, corestring_dom_href, &atr_string);
63 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
64 nsurl *url;
65 nserror error;
66
67 /* get url from string */
68 error = nsurl_create(dom_string_data(atr_string), &url);
69 dom_string_unref(atr_string);
70 if (error == NSERROR_OK) {
71 if (htmlc->base_url != NULL) {
72 nsurl_unref(htmlc->base_url);
73 }
74 htmlc->base_url = url;
75 }
76 }
77
78
79 /* get target attribute if present and not already set */
80 if (htmlc->base_target != NULL) {
81 return true;
82 }
83
84 exc = dom_element_get_attribute(node,
85 corestring_dom_target,
86 &atr_string);
87 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
88 /* Validation rules from the HTML5 spec for the base element:
89 * The target must be one of _blank, _self, _parent, or
90 * _top or any identifier which does not begin with an
91 * underscore
92 */
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));
103 }
104 dom_string_unref(atr_string);
105 }
106
107 return true;
108}
109
110
111
112/**
113 * Process img element being inserted into the DOM.
114 *
115 * \param htmlc The html content containing the DOM
116 * \param node The DOM node being inserted
117 * \return NSERROR_OK on success else appropriate error code
118 */
119static bool html_process_inserted_img(html_content *htmlc, dom_node *node)
120{
121 dom_string *src;
122 nsurl *url;
123 nserror err;
124 dom_exception exc;
125 bool success;
126
127 /* Do nothing if foreground images are disabled */
128 if (nsoption_bool(foreground_images) == false) {
129 return true;
130 }
131
132 exc = dom_element_get_attribute(node, corestring_dom_src, &src);
133 if (exc != DOM_NO_ERR || src == NULL) {
134 return true;
135 }
136
137 err = nsurl_join(htmlc->base_url, dom_string_data(src), &url);
138 if (err != NSERROR_OK) {
139 dom_string_unref(src);
140 return false;
141 }
142 dom_string_unref(src);
143
144 /* Speculatively fetch the image */
145 success = html_fetch_object(htmlc, url, NULL, CONTENT_IMAGE, false);
146 nsurl_unref(url);
147
148 return success;
149}
150
151
152/**
153 * process a LINK element being inserted into the DOM
154 *
155 * \note only the http-equiv attribute for refresh is currently considered
156 *
157 * \param htmlc The html content containing the DOM
158 * \param n The DOM node being inserted
159 * \return NSERROR_OK on success else appropriate error code
160 */
161static bool html_process_inserted_link(html_content *c, dom_node *node)
162{
163 struct content_rfc5988_link link; /* the link added to the content */
164 dom_exception exc; /* returned by libdom functions */
165 dom_string *atr_string;
166 nserror error;
167
168 /* Handle stylesheet loading */
169 html_css_process_link(c, (dom_node *)node);
170
171 /* try Generic link handling */
172
173 memset(&link, 0, sizeof(struct content_rfc5988_link));
174
175 /* check that the relation exists - w3c spec says must be present */
176 exc = dom_element_get_attribute(node, corestring_dom_rel, &atr_string);
177 if ((exc != DOM_NO_ERR) || (atr_string == NULL)) {
178 return false;
179 }
180 /* get a lwc string containing the link relation */
181 exc = dom_string_intern(atr_string, &link.rel);
182 dom_string_unref(atr_string);
183 if (exc != DOM_NO_ERR) {
184 return false;
185 }
186
187 /* check that the href exists - w3c spec says must be present */
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);
191 return false;
192 }
193
194 /* get nsurl */
195 error = nsurl_join(c->base_url, dom_string_data(atr_string),
196 &link.href);
197 dom_string_unref(atr_string);
198 if (error != NSERROR_OK) {
199 lwc_string_unref(link.rel);
200 return false;
201 }
202
203 /* look for optional properties -- we don't care if internment fails */
204
205 exc = dom_element_get_attribute(node,
206 corestring_dom_hreflang, &atr_string);
207 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
208 /* get a lwc string containing the href lang */
209 (void)dom_string_intern(atr_string, &link.hreflang);
210 dom_string_unref(atr_string);
211 }
212
213 exc = dom_element_get_attribute(node,
214 corestring_dom_type, &atr_string);
215 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
216 /* get a lwc string containing the type */
217 (void)dom_string_intern(atr_string, &link.type);
218 dom_string_unref(atr_string);
219 }
220
221 exc = dom_element_get_attribute(node,
222 corestring_dom_media, &atr_string);
223 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
224 /* get a lwc string containing the media */
225 (void)dom_string_intern(atr_string, &link.media);
226 dom_string_unref(atr_string);
227 }
228
229 exc = dom_element_get_attribute(node,
230 corestring_dom_sizes, &atr_string);
231 if ((exc == DOM_NO_ERR) && (atr_string != NULL)) {
232 /* get a lwc string containing the sizes */
233 (void)dom_string_intern(atr_string, &link.sizes);
234 dom_string_unref(atr_string);
235 }
236
237 /* add to content */
239
240 lwc_string_unref(link.sizes);
241 lwc_string_unref(link.media);
242 lwc_string_unref(link.type);
243 lwc_string_unref(link.hreflang);
244
245 nsurl_unref(link.href);
246 lwc_string_unref(link.rel);
247
248 return true;
249}
250
251
252/* handler for a SCRIPT which has been added to a tree */
253static void
254dom_SCRIPT_showed_up(html_content *htmlc, dom_html_script_element *script)
255{
256 dom_exception exc;
257 dom_html_script_element_flags flags;
258 dom_hubbub_error res;
259 bool within;
260
261 if (!htmlc->enable_scripting) {
262 NSLOG(netsurf, INFO, "Encountered a script, but scripting is off, ignoring");
263 return;
264 }
265
266 NSLOG(netsurf, DEEPDEBUG, "Encountered a script, node %p showed up", script);
267
268 exc = dom_html_script_element_get_flags(script, &flags);
269 if (exc != DOM_NO_ERR) {
270 NSLOG(netsurf, DEEPDEBUG, "Unable to retrieve flags, giving up");
271 return;
272 }
273
274 if (flags & DOM_HTML_SCRIPT_ELEMENT_FLAG_PARSER_INSERTED) {
275 NSLOG(netsurf, DEBUG, "Script was parser inserted, skipping");
276 return;
277 }
278
279 exc = dom_node_contains(htmlc->document, script, &within);
280 if (exc != DOM_NO_ERR) {
281 NSLOG(netsurf, DEBUG, "Unable to determine if script was within document, ignoring");
282 return;
283 }
284
285 if (!within) {
286 NSLOG(netsurf, DEBUG, "Script was not within the document, ignoring for now");
287 return;
288 }
289
290 res = html_process_script(htmlc, (dom_node *) script);
291 if (res == DOM_HUBBUB_OK) {
292 NSLOG(netsurf, DEEPDEBUG, "Inserted script has finished running");
293 } else {
294 if (res == (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED)) {
295 NSLOG(netsurf, DEEPDEBUG, "Inserted script has launced asynchronously");
296 } else {
297 NSLOG(netsurf, DEEPDEBUG, "Failure starting script");
298 }
299 }
300}
301
302
303/**
304 * process a META element being inserted into the DOM
305 *
306 * \note only the http-equiv attribute for refresh is currently considered
307 *
308 * \param htmlc The html content containing the DOM
309 * \param n The DOM node being inserted
310 * \return NSERROR_OK on success else appropriate error code
311 */
313{
314 union content_msg_data msg_data;
315 const char *url, *end, *refresh = NULL;
316 char *new_url;
317 char quote = '\0';
318 dom_string *equiv, *content;
319 dom_exception exc;
320 nsurl *nsurl;
321 nserror error = NSERROR_OK;
322
323 if (c->refresh) {
324 /* refresh already delt with */
325 return NSERROR_OK;
326 }
327
328 exc = dom_element_get_attribute(n, corestring_dom_http_equiv, &equiv);
329 if (exc != DOM_NO_ERR) {
330 return NSERROR_DOM;
331 }
332
333 if (equiv == NULL) {
334 return NSERROR_OK;
335 }
336
337 if (!dom_string_caseless_lwc_isequal(equiv, corestring_lwc_refresh)) {
338 dom_string_unref(equiv);
339 return NSERROR_OK;
340 }
341
342 dom_string_unref(equiv);
343
344 exc = dom_element_get_attribute(n, corestring_dom_content, &content);
345 if (exc != DOM_NO_ERR) {
346 return NSERROR_DOM;
347 }
348
349 if (content == NULL) {
350 return NSERROR_OK;
351 }
352
353 end = dom_string_data(content) + dom_string_byte_length(content);
354
355 /* content := *LWS intpart fracpart? *LWS [';' *LWS *1url *LWS]
356 * intpart := 1*DIGIT
357 * fracpart := 1*('.' | DIGIT)
358 * url := "url" *LWS '=' *LWS (url-nq | url-sq | url-dq)
359 * url-nq := *urlchar
360 * url-sq := "'" *(urlchar | '"') "'"
361 * url-dq := '"' *(urlchar | "'") '"'
362 * urlchar := [#x9#x21#x23-#x26#x28-#x7E] | nonascii
363 * nonascii := [#x80-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF]
364 */
365
366 url = dom_string_data(content);
367
368 /* *LWS */
369 while (url < end && ascii_is_space(*url)) {
370 url++;
371 }
372
373 /* intpart */
374 if (url == end || (*url < '0' || '9' < *url)) {
375 /* Empty content, or invalid timeval */
376 dom_string_unref(content);
377 return NSERROR_OK;
378 }
379
380 msg_data.delay = (int) strtol(url, &new_url, 10);
381 /* a very small delay and self-referencing URL can cause a loop
382 * that grinds machines to a halt. To prevent this we set a
383 * minimum refresh delay of 1s. */
384 if (msg_data.delay < 1) {
385 msg_data.delay = 1;
386 }
387
388 url = new_url;
389
390 /* fracpart? (ignored, as delay is integer only) */
391 while (url < end && (('0' <= *url && *url <= '9') ||
392 *url == '.')) {
393 url++;
394 }
395
396 /* *LWS */
397 while (url < end && ascii_is_space(*url)) {
398 url++;
399 }
400
401 /* ';' */
402 if (url < end && *url == ';')
403 url++;
404
405 /* *LWS */
406 while (url < end && ascii_is_space(*url)) {
407 url++;
408 }
409
410 if (url == end) {
411 /* Just delay specified, so refresh current page */
412 dom_string_unref(content);
413
415
417
418 return NSERROR_OK;
419 }
420
421 /* "url" */
422 if (url <= end - 3) {
423 if (strncasecmp(url, "url", 3) == 0) {
424 url += 3;
425 } else {
426 /* Unexpected input, ignore this header */
427 dom_string_unref(content);
428 return NSERROR_OK;
429 }
430 } else {
431 /* Insufficient input, ignore this header */
432 dom_string_unref(content);
433 return NSERROR_OK;
434 }
435
436 /* *LWS */
437 while (url < end && ascii_is_space(*url)) {
438 url++;
439 }
440
441 /* '=' */
442 if (url < end) {
443 if (*url == '=') {
444 url++;
445 } else {
446 /* Unexpected input, ignore this header */
447 dom_string_unref(content);
448 return NSERROR_OK;
449 }
450 } else {
451 /* Insufficient input, ignore this header */
452 dom_string_unref(content);
453 return NSERROR_OK;
454 }
455
456 /* *LWS */
457 while (url < end && ascii_is_space(*url)) {
458 url++;
459 }
460
461 /* '"' or "'" */
462 if (url < end && (*url == '"' || *url == '\'')) {
463 quote = *url;
464 url++;
465 }
466
467 /* Start of URL */
468 refresh = url;
469
470 if (quote != 0) {
471 /* url-sq | url-dq */
472 while (url < end && *url != quote)
473 url++;
474 } else {
475 /* url-nq */
476 while (url < end && !ascii_is_space(*url))
477 url++;
478 }
479
480 /* '"' or "'" or *LWS (we don't care) */
481 if (url > refresh) {
482 /* There's a URL */
483 new_url = strndup(refresh, url - refresh);
484 if (new_url == NULL) {
485 dom_string_unref(content);
486 return NSERROR_NOMEM;
487 }
488
489 error = nsurl_join(c->base_url, new_url, &nsurl);
490 if (error == NSERROR_OK) {
491 /* broadcast valid refresh url */
492
493 c->base.refresh = nsurl;
494
497 &msg_data);
498 c->refresh = true;
499 }
500
501 free(new_url);
502
503 }
504
505 dom_string_unref(content);
506
507 return error;
508}
509
510
511/**
512 * Process title element being inserted into the DOM.
513 *
514 * https://html.spec.whatwg.org/multipage/semantics.html#the-title-element
515 *
516 * \param htmlc The html content containing the DOM
517 * \param node The DOM node being inserted
518 * \return NSERROR_OK on success else appropriate error code
519 */
521{
522 if (htmlc->title == NULL) {
523 /* only the first title is considered */
524 htmlc->title = dom_node_ref(node);
525 }
526 return NSERROR_OK;
527}
528
529
530/** process title node */
531static bool html_process_title(html_content *c, dom_node *node)
532{
533 dom_exception exc; /* returned by libdom functions */
534 dom_string *title;
535 char *title_str;
536 bool success;
537
538 exc = dom_node_get_text_content(node, &title);
539 if ((exc != DOM_NO_ERR) || (title == NULL)) {
540 return false;
541 }
542
543 title_str = squash_whitespace(dom_string_data(title));
544 dom_string_unref(title);
545
546 if (title_str == NULL) {
547 return false;
548 }
549
550 success = content__set_title(&c->base, title_str);
551
552 free(title_str);
553
554 return success;
555}
556
557
558/**
559 * Deal with input elements being modified by resyncing their gadget
560 * if they have one.
561 */
562static void html_texty_element_update(html_content *htmlc, dom_node *node)
563{
564 struct box *box = box_for_node(node);
565 if (box == NULL) {
566 return; /* No Box (yet?) so no gadget to update */
567 }
568 if (box->gadget == NULL) {
569 return; /* No gadget yet (under construction perhaps?) */
570 }
572 /* And schedule a redraw for the box */
573 html__redraw_a_box(htmlc, box);
574}
575
576
577/**
578 * callback for DOMNodeInserted end type
579 */
580static void
581dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw)
582{
583 dom_event_target *node;
584 dom_node_type type;
585 dom_exception exc;
586 html_content *htmlc = pw;
587
588 exc = dom_event_get_target(evt, &node);
589 if ((exc != DOM_NO_ERR) || (node == NULL)) {
590 /* failed to obtain the event target node */
591 return;
592 }
593
594 exc = dom_node_get_node_type(node, &type);
595 if ((exc == DOM_NO_ERR) && (type == DOM_ELEMENT_NODE)) {
596 /* an element node has been inserted */
597 dom_html_element_type tag_type;
598
599 exc = dom_html_element_get_tag_type(node, &tag_type);
600 if (exc != DOM_NO_ERR) {
601 tag_type = DOM_HTML_ELEMENT_TYPE__UNKNOWN;
602 }
603
604 switch (tag_type) {
605 case DOM_HTML_ELEMENT_TYPE_BASE:
606 html_process_inserted_base(htmlc, (dom_node *)node);
607 break;
608
609 case DOM_HTML_ELEMENT_TYPE_IMG:
610 html_process_inserted_img(htmlc, (dom_node *)node);
611 break;
612
613 case DOM_HTML_ELEMENT_TYPE_LINK:
614 html_process_inserted_link(htmlc, (dom_node *)node);
615 break;
616
617 case DOM_HTML_ELEMENT_TYPE_META:
618 html_process_inserted_meta(htmlc, (dom_node *)node);
619 break;
620
621 case DOM_HTML_ELEMENT_TYPE_STYLE:
622 if (nsoption_bool(author_level_css)) {
623 html_css_process_style(htmlc, (dom_node *)node);
624 }
625 break;
626
627 case DOM_HTML_ELEMENT_TYPE_SCRIPT:
629 (dom_html_script_element *)node);
630 break;
631
632 case DOM_HTML_ELEMENT_TYPE_TITLE:
633 html_process_inserted_title(htmlc, (dom_node *)node);
634 break;
635
636 default:
637 break;
638 }
639
640 if (htmlc->enable_scripting) {
641 /* ensure javascript context is available */
642 if (htmlc->jsthread == NULL) {
643 union content_msg_data msg_data;
644
645 msg_data.jsthread = &htmlc->jsthread;
646 content_broadcast(&htmlc->base,
648 &msg_data);
649 NSLOG(netsurf, INFO,
650 "javascript context: %p (htmlc: %p)",
651 htmlc->jsthread,
652 htmlc);
653 }
654 if (htmlc->jsthread != NULL) {
656 (dom_element *) node);
657 }
658 }
659 }
660 dom_node_unref(node);
661}
662
663
664/**
665 * callback for DOMNodeInsertedIntoDocument end type
666 */
667static void
669 void *pw)
670{
671 html_content *htmlc = pw;
672 dom_event_target *node;
673 dom_node_type type;
674 dom_exception exc;
675
676 exc = dom_event_get_target(evt, &node);
677 if ((exc == DOM_NO_ERR) && (node != NULL)) {
678 exc = dom_node_get_node_type(node, &type);
679 if ((exc == DOM_NO_ERR) && (type == DOM_ELEMENT_NODE)) {
680 /* an element node has been modified */
681 dom_html_element_type tag_type;
682
683 exc = dom_html_element_get_tag_type(node, &tag_type);
684 if (exc != DOM_NO_ERR) {
685 tag_type = DOM_HTML_ELEMENT_TYPE__UNKNOWN;
686 }
687
688 switch (tag_type) {
689 case DOM_HTML_ELEMENT_TYPE_SCRIPT:
690 dom_SCRIPT_showed_up(htmlc, (dom_html_script_element *) node);
692 default:
693 break;
694 }
695 }
696 dom_node_unref(node);
697 }
698}
699
700
701/**
702 * callback for DOMSubtreeModified end type
703 */
704static void
705dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw)
706{
707 dom_event_target *node;
708 dom_node_type type;
709 dom_exception exc;
710 html_content *htmlc = pw;
711
712 exc = dom_event_get_target(evt, &node);
713 if ((exc == DOM_NO_ERR) && (node != NULL)) {
714 if (htmlc->title == (dom_node *)node) {
715 /* Node is our title node */
716 html_process_title(htmlc, (dom_node *)node);
717 dom_node_unref(node);
718 return;
719 }
720
721 exc = dom_node_get_node_type(node, &type);
722 if ((exc == DOM_NO_ERR) && (type == DOM_ELEMENT_NODE)) {
723 /* an element node has been modified */
724 dom_html_element_type tag_type;
725
726 exc = dom_html_element_get_tag_type(node, &tag_type);
727 if (exc != DOM_NO_ERR) {
728 tag_type = DOM_HTML_ELEMENT_TYPE__UNKNOWN;
729 }
730
731 switch (tag_type) {
732 case DOM_HTML_ELEMENT_TYPE_STYLE:
733 if (nsoption_bool(author_level_css)) {
735 (dom_node *)node);
736 }
737 break;
738 case DOM_HTML_ELEMENT_TYPE_TEXTAREA:
739 case DOM_HTML_ELEMENT_TYPE_INPUT:
740 html_texty_element_update(htmlc, (dom_node *)node);
742 default:
743 break;
744 }
745 }
746 dom_node_unref(node);
747 }
748}
749
750
751/**
752 * callback for default action finished
753 */
754static void
755dom_default_action_finished_cb(struct dom_event *evt, void *pw)
756{
757 html_content *htmlc = pw;
758
759 if (htmlc->jsthread != NULL)
760 js_event_cleanup(htmlc->jsthread, evt);
761}
762
763
764/* exported interface documented in html/dom_event.c */
765dom_default_action_callback
767 dom_default_action_phase phase,
768 void **pw)
769{
770 NSLOG(netsurf, DEEPDEBUG,
771 "phase:%d type:%s", phase, dom_string_data(type));
772
773 if (phase == DOM_DEFAULT_ACTION_END) {
774 if (dom_string_isequal(type, corestring_dom_DOMNodeInserted)) {
776 } else if (dom_string_isequal(type, corestring_dom_DOMNodeInsertedIntoDocument)) {
778 } else if (dom_string_isequal(type, corestring_dom_DOMSubtreeModified)) {
780 }
781 } else if (phase == DOM_DEFAULT_ACTION_FINISHED) {
783 }
784 return NULL;
785}
Helpers for ASCII string handling.
static bool ascii_is_space(char c)
Test whether a character is a whitespace character.
Definition: ascii.h:40
Box interface.
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.
Definition: utils.c:332
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.
Definition: object.c:710
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.
Definition: content.c:993
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
Definition: content.c:752
bool content__set_title(struct content *c, const char *title)
Set title associated with content.
Definition: content.c:1082
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
Definition: content.c:1043
@ CONTENT_IMAGE
All images.
Definition: content_type.h:67
@ CONTENT_MSG_REFRESH
wants refresh
Definition: content_type.h:137
@ CONTENT_MSG_GETTHREAD
Javascript thread.
Definition: content_type.h:146
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.
Definition: dom_event.c:520
static void dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw)
callback for DOMSubtreeModified end type
Definition: dom_event.c:705
static void dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw)
callback for DOMNodeInserted end type
Definition: dom_event.c:581
static void dom_SCRIPT_showed_up(html_content *htmlc, dom_html_script_element *script)
Definition: dom_event.c:254
static void dom_default_action_finished_cb(struct dom_event *evt, void *pw)
callback for default action finished
Definition: dom_event.c:755
static bool html_process_title(html_content *c, dom_node *node)
process title node
Definition: dom_event.c:531
static void dom_default_action_DOMNodeInsertedIntoDocument_cb(struct dom_event *evt, void *pw)
callback for DOMNodeInsertedIntoDocument end type
Definition: dom_event.c:668
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
Definition: dom_event.c:766
static bool html_process_inserted_img(html_content *htmlc, dom_node *node)
Process img element being inserted into the DOM.
Definition: dom_event.c:119
static bool html_process_inserted_base(html_content *htmlc, dom_node *node)
process a base element being inserted into the DOM
Definition: dom_event.c:56
static bool html_process_inserted_link(html_content *c, dom_node *node)
process a LINK element being inserted into the DOM
Definition: dom_event.c:161
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.
Definition: dom_event.c:562
static nserror html_process_inserted_meta(html_content *c, dom_node *n)
process a META element being inserted into the DOM
Definition: dom_event.c:312
HTML content DOM event handling interface.
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_DOM
DOM call returned error.
Definition: errors.h:52
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
const char * type
Definition: filetype.cpp:44
void form_gadget_sync_with_dom(struct form_control *control)
Synchronise this gadget with its associated DOM node.
Definition: form.c:2170
Interface to form handling functions internal to HTML content handler.
bool html_css_process_style(html_content *c, dom_node *node)
process a css style dom node
Definition: css.c:352
bool html_css_process_link(html_content *htmlc, dom_node *node)
process a css stylesheet dom LINK node
Definition: css.c:385
bool html_css_update_style(html_content *c, dom_node *style)
process a css style dom node update
Definition: css.c:323
void html__redraw_a_box(struct html_content *html, struct box *box)
Redraw a box.
Definition: html.c:1130
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.
Definition: dukky.c:1471
void js_event_cleanup(jsthread *thread, struct dom_event *evt)
Handle an event propagation finished callback.
Definition: dukky.c:1551
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
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.
Definition: nsurl.h:31
Private data for text/html content.
dom_hubbub_error html_process_script(void *ctx, dom_node *node)
process script node parser callback
Definition: script.c:566
Interface to utility string handling.
char * squash_whitespace(const char *s)
Replace consecutive whitespace with a single space.
Definition: utils.c:38
Node in box tree.
Definition: box.h:177
struct form_control * gadget
Form control data, or NULL if not a form control.
Definition: box.h:423
struct dom_node * node
DOM node that generated this box or NULL.
Definition: box.h:191
Content which corresponds to a single URL.
struct nsurl * refresh
URL for refresh request.
Data specific to CONTENT_HTML.
Definition: private.h:93
bool refresh
Whether a meta refresh has been handled.
Definition: private.h:119
dom_document * document
Document tree.
Definition: private.h:101
struct nsurl * base_url
Base URL (may be a copy of content->url).
Definition: private.h:111
char * base_target
Base target.
Definition: private.h:113
struct jsthread * jsthread
javascript thread in use
Definition: private.h:152
bool enable_scripting
Whether scripts are enabled for this content.
Definition: private.h:128
struct content base
Definition: private.h:94
dom_node * title
Definition: private.h:131
Extra data for some content_msg messages.
Definition: content.h:60
int delay
CONTENT_MSG_REFRESH - Minimum delay.
Definition: content.h:116
const char * title
Definition: content.h:186
struct jsthread ** jsthread
CONTENT_MSG_GETTHREAD - Javascript context (thread)
Definition: content.h:143
struct hlcache_handle * content
if NULL, save the content generating the message
Definition: content.h:178
struct nsurl * url
Definition: content.h:185
Option reading and saving interface.
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:308
Interface to a number of general purpose functionality.
#define fallthrough
switch fall through
Definition: utils.h:119