30#include <nsutils/time.h>
80#define ALWAYS_DUMP_FRAMESET 0
81#define ALWAYS_DUMP_BOX 0
84 "application/xhtml+xml",
102 exc = dom_event_target_dispatch_event(target, event, &
result);
103 if (exc != DOM_NO_ERR) {
112 bool bubbles,
bool cancelable)
118 exc = dom_event_create(&evt);
119 if (exc != DOM_NO_ERR)
return false;
120 exc = dom_event_init(evt,
type, bubbles, cancelable);
121 if (exc != DOM_NO_ERR) {
122 dom_event_unref(evt);
125 NSLOG(netsurf, INFO,
"Dispatching '%*s' against %p",
126 (
int)dom_string_length(
type), dom_string_data(
type), target);
128 dom_event_unref(evt);
134 bool bubbles,
bool cancelable, uint32_t key)
136 bool is_special = key <= 0x001F || (0x007F <= key && key <= 0x009F);
137 dom_string *dom_key = NULL;
138 dom_keyboard_event *evt;
145 dom_key = dom_string_ref(corestring_dom_Escape);
148 dom_key = dom_string_ref(corestring_dom_ArrowLeft);
151 dom_key = dom_string_ref(corestring_dom_ArrowRight);
154 dom_key = dom_string_ref(corestring_dom_ArrowUp);
157 dom_key = dom_string_ref(corestring_dom_ArrowDown);
160 dom_key = dom_string_ref(corestring_dom_PageUp);
163 dom_key = dom_string_ref(corestring_dom_PageDown);
166 dom_key = dom_string_ref(corestring_dom_Home);
169 dom_key = dom_string_ref(corestring_dom_End);
180 exc = dom_string_create((
const uint8_t *)utf8, strlen(utf8),
182 if (exc != DOM_NO_ERR) {
187 exc = dom_keyboard_event_create(&evt);
188 if (exc != DOM_NO_ERR) {
189 dom_string_unref(dom_key);
193 exc = dom_keyboard_event_init(evt,
type, bubbles, cancelable, NULL,
194 dom_key, NULL, DOM_KEY_LOCATION_STANDARD,
false,
195 false,
false,
false,
false,
false);
196 dom_string_unref(dom_key);
197 if (exc != DOM_NO_ERR) {
198 dom_event_unref(evt);
202 NSLOG(netsurf, INFO,
"Dispatching '%*s' against %p",
203 (
int)dom_string_length(
type), dom_string_data(
type), target);
206 dom_event_unref(evt);
222 NSLOG(netsurf, INFO,
"DOM to box conversion complete (content %p)", c);
227 if ((success ==
false) || (c->
aborted)) {
230 if (success ==
false) {
244#if ALWAYS_DUMP_FRAMESET
249 exc = dom_document_get_document_element(c->
document, (
void *) &html);
250 if ((exc != DOM_NO_ERR) || (html == NULL)) {
254 NSLOG(netsurf, INFO,
"error retrieving html element from dom");
263 NSLOG(netsurf, INFO,
"imagemap extraction failed");
267 dom_node_unref(html);
273 dom_hubbub_parser_destroy(c->
parser);
280 dom_node_unref(html);
299 NSLOG(netsurf, ERROR,
"Content status unexpectedly not LOADING/READY/DONE");
316 .viewport_height = &h,
323 w = css_unit_device2css_px(INTTOFIX(w), device_dpi);
324 h = css_unit_device2css_px(INTTOFIX(h), device_dpi);
326 htmlc->
media.width = w;
327 htmlc->
media.height = h;
333 f_size = FDIV(FMUL(F_96, FDIV(INTTOFIX(
nsoption_int(font_size)), F_10)), F_72);
334 f_min = FDIV(FMUL(F_96, FDIV(INTTOFIX(
nsoption_int(font_min_size)), F_10)), F_72);
367 "Ignoring style change: NS layout is static.");
389 NSLOG(netsurf, INFO,
"DOM to box (%p)", htmlc);
394 exc = dom_document_get_document_element(htmlc->
document, (
void *) &html);
395 if ((exc != DOM_NO_ERR) || (html == NULL)) {
396 NSLOG(netsurf, INFO,
"error retrieving html element from dom");
406 NSLOG(netsurf, INFO,
"box conversion failed");
407 dom_node_unref(html);
414 dom_node_unref(html);
420 dom_string *key,
void *data,
421 struct dom_node *
src,
422 struct dom_node *dst)
424 if (dom_string_isequal(corestring_dom___ns_key_html_content_data,
425 key) ==
false || data == NULL) {
430 case DOM_NODE_CLONED:
431 NSLOG(netsurf, INFO,
"Cloned");
433 case DOM_NODE_RENAMED:
434 NSLOG(netsurf, INFO,
"Renamed");
436 case DOM_NODE_IMPORTED:
437 NSLOG(netsurf, INFO,
"imported");
439 case DOM_NODE_ADOPTED:
440 NSLOG(netsurf, INFO,
"Adopted");
442 case DOM_NODE_DELETED:
446 NSLOG(netsurf, INFO,
"User data operation not handled.");
457 dom_hubbub_parser_params parse_params;
458 dom_hubbub_error error;
461 const char *prefer_color_mode = (
nsoption_bool(prefer_dark_mode)) ?
468 c->
quirks = DOM_DOCUMENT_QUIRKS_MODE_NONE;
482 c->
media.type = CSS_MEDIA_SCREEN;
506 if (lwc_intern_string(
"*",
SLEN(
"*"), &c->
universal) != lwc_error_ok) {
510 if (lwc_intern_string(prefer_color_mode, strlen(prefer_color_mode),
511 &c->
media.prefers_color_scheme) != lwc_error_ok) {
521 c->
encoding = strdup(lwc_string_data(charset));
523 lwc_string_unref(charset);
528 lwc_string_unref(c->
media.prefers_color_scheme);
529 c->
media.prefers_color_scheme = NULL;
538 parse_params.fix_enc =
true;
540 parse_params.msg = NULL;
542 parse_params.ctx = c;
545 error = dom_hubbub_parser_create(&parse_params,
548 if ((error != DOM_HUBBUB_OK) && (c->
encoding != NULL)) {
556 error = dom_hubbub_parser_create(&parse_params,
560 if (error != DOM_HUBBUB_OK) {
566 lwc_string_unref(c->
media.prefers_color_scheme);
567 c->
media.prefers_color_scheme = NULL;
572 err = dom_node_set_user_data(c->
document,
573 corestring_dom___ns_key_html_content_data,
575 (
void *) &old_node_data);
576 if (err != DOM_NO_ERR) {
577 dom_hubbub_parser_destroy(c->
parser);
584 lwc_string_unref(c->
media.prefers_color_scheme);
585 c->
media.prefers_color_scheme = NULL;
587 NSLOG(netsurf, INFO,
"Unable to set user data.");
591 assert(old_node_data == NULL);
606 lwc_string *imime_type,
609 const char *fallback_charset,
621 llcache, fallback_charset, quirks);
654 dom_hubbub_parser_params parse_params;
655 dom_hubbub_error error;
656 const char *encoding;
657 const uint8_t *source_data;
661 encoding = dom_hubbub_parser_get_encoding(html->
parser,
663 if (encoding == NULL) {
678 dom_hubbub_parser_destroy(html->
parser);
686 parse_params.fix_enc =
true;
688 parse_params.msg = NULL;
690 parse_params.ctx = html;
694 error = dom_hubbub_parser_create(&parse_params,
697 if (error != DOM_HUBBUB_OK) {
701 html->
encoding = strdup(
"Windows-1252");
707 error = dom_hubbub_parser_create(&parse_params,
711 if (error != DOM_HUBBUB_OK) {
723 error = dom_hubbub_parser_parse_chunk(html->
parser,
739 dom_hubbub_error dom_ret;
742 dom_ret = dom_hubbub_parser_parse_chunk(html->
parser,
743 (
const uint8_t *) data,
791 exc = dom_document_get_quirks_mode(htmlc->
document, &htmlc->
quirks);
792 if (exc == DOM_NO_ERR) {
794 NSLOG(netsurf, INFO,
"quirks set to %d", htmlc->
quirks);
840 dom_hubbub_error error;
854 NSLOG(netsurf, INFO,
"Completing parse (%p)", htmlc);
856 error = dom_hubbub_parser_completed(htmlc->
parser);
857 if (error == DOM_HUBBUB_HUBBUB_ERR_PAUSED && htmlc->
base.
active > 0) {
861 NSLOG(netsurf, INFO,
"Completing parse brought synchronous JS to light, cannot complete yet");
864 if (error != DOM_HUBBUB_OK) {
865 NSLOG(netsurf, INFO,
"Parsing failed");
877 NSLOG(netsurf, INFO,
"Can't begin conversion (%p)", htmlc);
884 NSLOG(netsurf, INFO,
"Conversion aborted (%p) (active: %u)",
903 const char *encoding;
905 encoding = dom_hubbub_parser_get_encoding(htmlc->
parser,
907 if (encoding == NULL) {
924 exc = dom_document_get_document_element(htmlc->
document, (
void *) &html);
925 if ((exc != DOM_NO_ERR) || (html == NULL)) {
926 NSLOG(netsurf, INFO,
"error retrieving html element from dom");
931 exc = dom_node_get_node_name(html, &
node_name);
932 if ((exc != DOM_NO_ERR) ||
934 (!dom_string_caseless_lwc_isequal(
node_name,
935 corestring_lwc_html))) {
936 NSLOG(netsurf, INFO,
"root element not html");
938 dom_node_unref(html);
945 (dom_html_document *) htmlc->
document);
946 for (f = htmlc->
forms; f != NULL; f = f->
prev) {
965 dom_node_unref(html);
977 dom_node_unref(html);
988 dom_node_unref(html);
994 dom_node_unref(html);
1042 NSLOG(netsurf, INFO,
"Unexpected status %d (%p)", c->
status,
1059 uint64_t ms_interval;
1061 nsu_getmonotonic_ms(&ms_before);
1065 htmlc->
unit_len_ctx.viewport_width = css_unit_device2css_px(
1067 htmlc->
unit_len_ctx.viewport_height = css_unit_device2css_px(
1094 nsu_getmonotonic_ms(&ms_after);
1096 ms_interval = (ms_after - ms_before) * 3;
1097 if (ms_interval < (
nsoption_uint(min_reflow_period) * 10)) {
1145 if (frameset->
name) {
1147 frameset->
name = NULL;
1149 if (frameset->
url) {
1151 frameset->
url = NULL;
1154 for (i = 0; i < (frameset->
rows * frameset->
cols); i++) {
1175 while ((iframe =
next) != NULL) {
1190 if (htmlc->
bctx != NULL) {
1207 NSLOG(netsurf, INFO,
"content %p", c);
1212 NSLOG(netsurf, CRITICAL,
"WARNING, Unable to cancel conversion context, browser may crash");
1219 for (f = html->
forms; f != NULL; f = g) {
1241 if (html->
parser != NULL) {
1242 dom_hubbub_parser_destroy(html->
parser);
1251 if (html->
title != NULL) {
1252 dom_node_unref(html->
title);
1276 if (html->
iframe != NULL) {
1292 if (html->
media.prefers_color_scheme != NULL) {
1293 lwc_string_unref(html->
media.prefers_color_scheme);
1294 html->
media.prefers_color_scheme = NULL;
1318 assert(0 &&
"html_clone should never be called");
1394 gadget->data.
text.ta);
1424 gadget->data.
text.ta);
1462 int box_x = 0, box_y = 0;
1465 &box_x, &box_y)) != NULL) {
1470 css_computed_visibility(
box->
style) == CSS_VISIBILITY_HIDDEN) {
1477 (
x - box_x) * scale,
1478 (
y - box_y) * scale,
1484 x - box_x,
y - box_y, data);
1493 const char *
target = NULL;
1540 int box_x = 0, box_y = 0;
1541 bool handled_scroll =
false;
1546 &box_x, &box_y)) != NULL) {
1550 CSS_VISIBILITY_HIDDEN)
1558 (
x - box_x) * scale,
1559 (
y - box_y) * scale,
1560 scrx, scry) ==
true)
1569 scrx, scry) ==
true)
1575 scrx, scry) ==
true)
1580 handled_scroll =
true;
1583 handled_scroll =
true;
1585 if (handled_scroll ==
true)
1598 dom_string *key,
void *_data,
struct dom_node *src,
1599 struct dom_node *dst)
1602 char *data = (
char *)_data;
1604 if (!dom_string_isequal(corestring_dom___ns_key_file_name_node_data,
1605 key) || data == NULL) {
1609 switch (operation) {
1610 case DOM_NODE_CLONED:
1611 if (dom_node_set_user_data(dst,
1612 corestring_dom___ns_key_file_name_node_data,
1614 &oldfile) == DOM_NO_ERR) {
1615 if (oldfile != NULL)
1620 case DOM_NODE_RENAMED:
1621 case DOM_NODE_IMPORTED:
1622 case DOM_NODE_ADOPTED:
1625 case DOM_NODE_DELETED:
1629 NSLOG(netsurf, INFO,
"User data operation not handled.");
1638 char *utf8_fn, *oldfile = NULL;
1645 NSLOG(netsurf, INFO,
1646 "utf8 to local encoding conversion failed");
1654 if (dom_node_set_user_data((dom_node *)file_box->
gadget->
node,
1655 corestring_dom___ns_key_file_name_node_data,
1657 &oldfile) == DOM_NO_ERR) {
1658 if (oldfile != NULL)
1689 struct box *file_box = NULL;
1690 struct box *text_box = NULL;
1691 int box_x = 0, box_y = 0;
1695 &box_x, &box_y)) != NULL) {
1699 css_computed_visibility(
box->
style) == CSS_VISIBILITY_HIDDEN)
1706 (
x - box_x) * scale,
1707 (
y - box_y) * scale,
1713 x - box_x,
y - box_y, file) ==
true)
1734 if (!file_box && !text_box)
1759 fp = fopen(file,
"rb");
1766 fseek(fp, 0, SEEK_END);
1767 file_len = ftell(fp);
1768 fseek(fp, 0, SEEK_SET);
1770 if ((
long)file_len == -1) {
1777 buffer = malloc(file_len + 1);
1785 if (file_len != fread(
buffer, 1, file_len, fp)) {
1804 NSLOG(netsurf, ERROR,
1805 "local to utf8 encoding failed (%s)",
1816 size = strlen(utf8_buff);
1864 assert(htmlc != NULL);
1867 assert(htmlc->
layout != NULL);
1872 NSLOG(netsurf, INFO,
"No document to dump");
1876 exc = dom_document_get_document_element(htmlc->
document, (
void *) &html);
1877 if ((exc != DOM_NO_ERR) || (html == NULL)) {
1878 NSLOG(netsurf, INFO,
"Unable to obtain root node");
1884 NSLOG(netsurf, INFO,
"DOM structure dump returning %d", ret);
1886 dom_node_unref(html);
1893#if ALWAYS_DUMP_FRAMESET
1902 int row,
col, index;
1903 const char *unit[] = {
"px",
"%",
"*"};
1904 const char *scrolling[] = {
"auto",
"yes",
"no"};
1908 fprintf(stderr,
"%p ", frame);
1910 fprintf(stderr,
"(%i %i) ", frame->
rows, frame->
cols);
1914 fprintf(stderr,
"(margin w%i h%i) ",
1918 fprintf(stderr,
"'%s' ", frame->
name);
1920 fprintf(stderr,
"<%s> ", frame->
url);
1923 fprintf(stderr,
"noresize ");
1924 fprintf(stderr,
"(scrolling %s) ", scrolling[frame->
scrolling]);
1926 fprintf(stderr,
"border %x ",
1929 fprintf(stderr,
"\n");
1932 for (row = 0; row != frame->
rows; row++) {
1934 for (i = 0; i != depth; i++)
1935 fprintf(stderr,
" ");
1936 fprintf(stderr,
"(%i %i): ", row,
col);
1937 index = (row * frame->
cols) +
col;
1938 html_dump_frameset(&frame->
children[index],
1990 static char enc_token[10] =
"Encoding0";
1992 assert(html != NULL);
2095 dom_html_body_element *body_node;
2096 dom_string *dom_src;
2097 dom_text *text_node;
2098 dom_node *spare_node;
2099 dom_html_script_element *script_node;
2102 NSLOG(netsurf, DEEPDEBUG,
"Unable to exec, no document");
2106 err = dom_string_create((
const uint8_t *)src, srclen, &dom_src);
2107 if (err != DOM_NO_ERR) {
2108 NSLOG(netsurf, DEEPDEBUG,
"Unable to exec, could not create string");
2112 err = dom_html_document_get_body(htmlc->
document, &body_node);
2113 if (err != DOM_NO_ERR) {
2114 NSLOG(netsurf, DEEPDEBUG,
"Unable to retrieve body element");
2118 err = dom_document_create_text_node(htmlc->
document, dom_src, &text_node);
2119 if (err != DOM_NO_ERR) {
2120 NSLOG(netsurf, DEEPDEBUG,
"Unable to exec, could not create text node");
2121 goto out_no_text_node;
2124 err = dom_document_create_element(htmlc->
document, corestring_dom_SCRIPT, &script_node);
2125 if (err != DOM_NO_ERR) {
2126 NSLOG(netsurf, DEEPDEBUG,
"Unable to exec, could not create script node");
2127 goto out_no_script_node;
2130 err = dom_node_append_child(script_node, text_node, &spare_node);
2131 if (err != DOM_NO_ERR) {
2132 NSLOG(netsurf, DEEPDEBUG,
"Unable to exec, could not insert code node into script node");
2133 goto out_unparented;
2135 dom_node_unref(spare_node);
2137 err = dom_node_append_child(body_node, script_node, &spare_node);
2138 if (err != DOM_NO_ERR) {
2139 NSLOG(netsurf, DEEPDEBUG,
"Unable to exec, could not insert script node into document body");
2140 goto out_unparented;
2142 dom_node_unref(spare_node);
2152 err = dom_node_get_parent_node(script_node, &spare_node);
2153 if (err == DOM_NO_ERR && spare_node != NULL) {
2154 dom_node *second_spare;
2155 err = dom_node_remove_child(spare_node, script_node, &second_spare);
2156 if (err == DOM_NO_ERR) {
2157 dom_node_unref(second_spare);
2159 dom_node_unref(spare_node);
2163 dom_node_unref(script_node);
2165 dom_node_unref(text_node);
2167 dom_node_unref(body_node);
2169 dom_string_unref(dom_src);
2182 while (obj != NULL) {
2245 unsigned match_length;
2246 unsigned match_offset;
2247 const char *new_text;
2260 match_offset = pos - cur->
text;
2271 new_text = pos + match_length;
2305 const char *pattern,
2311 if (html->
layout == NULL) {
2327 struct box *start_box,
2328 struct box *end_box,
2329 struct rect *bounds)
Helpers for ASCII string handling.
nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb, void **box_conversion_context)
Construct a box tree from a dom and html content.
nserror cancel_dom_to_box(void *box_conversion_context)
aborts any ongoing box construction
HTML Box tree construction interface.
struct box * box_at_point(const css_unit_ctx *unit_len_ctx, struct box *box, const int x, const int y, int *box_x, int *box_y)
Find the boxes at a point.
void box_coords(struct box *box, int *x, int *y)
Find the absolute coordinates of a box.
struct box * box_find_by_id(struct box *box, lwc_string *id)
Find a box based upon its id attribute.
void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
Print a box tree to a file.
HTML Box tree inspection interface.
Browser window creation and manipulation interface.
nserror browser_window_get_features(struct browser_window *bw, int x, int y, struct browser_window_features *data)
Get access to any page features at the given coordinates.
float browser_window_get_scale(struct browser_window *bw)
Gets the scale of a browser window.
bool browser_window_scroll_at_point(struct browser_window *bw, int x, int y, int scrx, int scry)
Send a scroll request to a browser window at a particular point.
bool browser_window_drop_file_at_point(struct browser_window *bw, int x, int y, char *file)
Drop a file onto a browser window at a particular point, or determine if a file may be dropped onto t...
static osspriteop_area * buffer
The buffer characteristics.
HTML content handler CSS interface.
bool layout_document(html_content *content, int width, int height)
Calculate positions of boxes in a document.
interface to HTML layout.
nserror html_object_abort_objects(html_content *htmlc)
abort any content objects that have not completed fetching.
nserror html_object_close_objects(html_content *html)
close content of content objects associated with a HTML content
nserror html_object_free_objects(html_content *html)
release memory of content objects associated with a HTML content
nserror html_object_open_objects(html_content *html, struct browser_window *bw)
open content of content objects associated with a HTML content
HTML content object interface.
nserror html_textselection_get_end(struct content *c, unsigned *end_idx)
get maximum index of text section.
nserror html_textselection_copy(struct content *c, unsigned start_idx, unsigned end_idx, struct selection_string *selstr)
nserror html_textselection_redraw(struct content *c, unsigned start_idx, unsigned end_idx)
HTML text selection handling.
char * content_get_selection(hlcache_handle *h)
Get a text selection from a content.
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
void content_request_redraw(struct hlcache_handle *h, int x, int y, int width, int height)
Request a redraw of an area of a content.
void content_clear_selection(hlcache_handle *h)
Tell a content that any selection it has, or one of its objects has, must be cleared.
void content_set_done(struct content *c)
Put a content in status CONTENT_STATUS_DONE.
bool content_saw_insecure_objects(struct hlcache_handle *h)
Determine if the content referred to any insecure objects.
nserror content__init(struct content *c, const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks)
bool content_scroll_at_point(struct hlcache_handle *h, int x, int y, int scrx, int scry)
scroll content at coordnate
nserror content_get_contextual_content(struct hlcache_handle *h, int x, int y, struct browser_window_features *data)
Get positional contextural information for a content.
void content_set_error(struct content *c)
Put a content in status CONTENT_STATUS_ERROR and unlock the content.
void content__request_redraw(struct content *c, int x, int y, int width, int height)
Request a redraw of an area of a content.
content_status content__get_status(struct content *c)
Retrieve status of content.
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
const uint8_t * content__get_source_data(struct content *c, size_t *size)
Retrieve source of content.
void content_set_ready(struct content *c)
Put a content in status CONTENT_STATUS_READY and unlock the content.
bool content_drop_file_at_point(struct hlcache_handle *h, int x, int y, char *file)
Drag and drop a file at coordinate.
void content_set_status(struct content *c, const char *status_message)
Updates content with new status.
void content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
Send an error message to all users.
nserror content_factory_register_handler(const char *mime_type, const content_handler *handler)
Register a handler with the content factory.
@ CONTENT_STATUS_READY
Some parts of content still being loaded, but can be displayed.
@ CONTENT_STATUS_DONE
Content has completed all processing.
@ CONTENT_STATUS_LOADING
Content is being fetched or converted and is not safe to display.
content_type
The type of a content.
@ CONTENT_HTML
content is HTML
@ CONTENT_MSG_GETDIMS
Get viewport dimensions.
@ CONTENT_MSG_STATUS
new status string
content_debug
Debugging dump operations.
@ CONTENT_DEBUG_RENDER
Debug the contents rendering.
content_encoding_type
Content encoding information types.
@ CONTENT_ENCODING_SOURCE
The content encoding source.
Useful interned string pointers (interface).
css_fixed nscss_screen_dpi
Screen DPI in fixed point units: defaults to 90, which RISC OS uses.
void selection_reinit(struct selection *s)
Initialise the selection object to use the given box subtree as its root, ie.
bool selection_clear(struct selection *s, bool redraw)
Clears the current selection, optionally causing the screen to be updated.
struct selection * selection_create(struct content *c)
Creates a new selection object associated with a browser window.
void selection_init(struct selection *s)
Initialise the selection object to use the given box subtree as its root, ie.
void selection_destroy(struct selection *s)
Destroys a selection object clearing it if nesessary.
char * selection_get_copy(struct selection *s)
Get copy of selection as string.
Text selection within browser windows (interface).
bool textarea_scroll(struct textarea *ta, int scrx, int scry)
Scroll a textarea by an amount.
bool textarea_clear_selection(struct textarea *ta)
Clear any selection in the textarea.
textarea_mouse_status textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
bool textarea_drop_text(struct textarea *ta, const char *text, size_t text_length)
Insert the text in a text area at the caret, replacing any selection.
char * textarea_get_selection(struct textarea *ta)
Get selected text.
Single/Multi-line UTF-8 text area interface.
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
HTML content DOM event handling interface.
nserror
Enumeration of error codes.
@ NSERROR_BAD_ENCODING
The character set is unknown.
@ NSERROR_BOX_CONVERT
Box conversion failed.
@ NSERROR_DOM
DOM call returned error.
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
@ NSERROR_STOPPED
Content conversion stopped.
@ NSERROR_ENCODING_CHANGE
The character changed.
@ NSERROR_INVALID
Invalid data.
@ NSERROR_NOMEM
Memory exhaustion.
#define NOF_ELEMENTS(array)
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
struct content * hlcache_handle_get_content(const hlcache_handle *handle)
Retrieve a content object from a cache handle.
High-level resource cache interface.
nserror html_css_init(void)
Initialise html content css handling.
nserror html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx)
create a new css selection context for an html content.
void html_css_fini(void)
Finalise html content css handling.
bool html_css_saw_insecure_stylesheets(html_content *html)
determine if any of the stylesheets were loaded insecurely
nserror html_css_free_stylesheets(html_content *html)
Free all css stylesheets associated with an HTML content.
nserror html_css_new_stylesheets(html_content *c)
Initialise core stylesheets for a content.
nserror html_css_quirks_stylesheets(html_content *c)
Initialise quirk stylesheets for a content.
static const content_handler html_content_handler
HTML content handler function table.
static void html_fini(void)
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,...
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.
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 cont...
bool html_exec(struct content *c, const char *src, size_t srclen)
execute some text as a script element
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.
bool html_begin_conversion(html_content *htmlc)
Begin conversion of an HTML document.
static content_type html_content_type(void)
Compute the type of a content.
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.
static void html_document_user_data_handler(dom_node_operation operation, dom_string *key, void *data, struct dom_node *src, struct dom_node *dst)
void html_redraw_a_box(hlcache_handle *h, struct box *box)
Redraw a box.
static void html_destroy(struct content *c)
Destroy a CONTENT_HTML and free all resources it owns.
void html_finish_conversion(html_content *htmlc)
Complete conversion of an HTML document.
void html__redraw_a_box(struct html_content *html, struct box *box)
Redraw a box.
nserror html_init(void)
initialise content handler
static bool html_saw_insecure_objects(struct content *c)
static nserror html_process_encoding_change(struct content *c, const char *data, unsigned int size)
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.
static bool html_convert(struct content *c)
Convert a CONTENT_HTML for display.
static nserror html_clone(const struct content *old, struct content **newc)
static void html_box_convert_done(html_content *c, bool success)
Perform post-box-creation conversion of a document.
static const char * html_types[]
static bool html_process_data(struct content *c, const char *data, unsigned int size)
Process data for CONTENT_HTML.
struct content_html_iframe * html_get_iframe(hlcache_handle *h)
Retrieve iframes used in an HTML document.
static void html_clear_selection(struct content *c)
Return an HTML content's selection context.
nsurl * html_get_base_url(hlcache_handle *h)
Retrieve an HTML content's base URL.
static void html_stop(struct content *c)
Stop loading a CONTENT_HTML.
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.
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.
bool fire_generic_dom_event(dom_string *type, dom_node *target, bool bubbles, bool cancelable)
Construct an event and fire it at the DOM.
static void html_free_layout(html_content *htmlc)
static void html_get_dimensions(html_content *htmlc)
dom_document * html_get_document(hlcache_handle *h)
Retrieve HTML document tree.
static void html__set_file_gadget_filename(struct content *c, struct form_control *gadget, const char *fn)
struct box * html_get_box_tree(hlcache_handle *h)
Retrieve box tree.
const char * html_get_base_target(hlcache_handle *h)
Retrieve an HTML content's base target.
bool html_get_id_offset(hlcache_handle *h, lwc_string *frag_id, int *x, int *y)
Retrieve layout coordinates of box with given id.
static nserror html_create_html_data(html_content *c, const http_parameter *params)
static void html_reformat(struct content *c, int width, int height)
Reformat a CONTENT_HTML to a new width.
static nserror html_debug_dump(struct content *c, FILE *f, enum content_debug op)
Dump debug info concerning the html_content.
static void html_destroy_frameset(struct content_html_frames *frameset)
static char * html_get_selection(struct content *c)
Return an HTML content's selection context.
nserror html_proceed_to_done(html_content *html)
Complete the HTML content state machine iff all scripts are finished.
static void html_destroy_iframe(struct content_html_iframe *iframe)
static const char * html_encoding(const struct content *c, enum content_encoding_type op)
Retrieve the charset of an HTML document.
bool html_can_begin_conversion(html_content *htmlc)
Test if an HTML content conversion can begin.
static nserror html_close(struct content *c)
Handle a window containing a CONTENT_HTML being closed.
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)
struct content_html_frames * html_get_frameset(hlcache_handle *h)
Retrieve framesets used in an HTML document.
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.
static bool fire_dom_event(dom_event *event, dom_node *target)
Fire an event at the DOM.
void html_set_file_gadget_filename(struct hlcache_handle *hl, struct form_control *gadget, const char *fn)
set filename on a file gadget
static nserror html_debug(struct content *c, enum content_debug op)
set debug status.
Interface to text/html content handler.
Interface to HTML content handler to save documents.
HTTP header parsing functions.
nsurl * imagemap_get(struct html_content *c, const char *key, unsigned long x, unsigned long y, unsigned long click_x, unsigned long click_y, const char **target)
Retrieve url associated with imagemap entry.
void imagemap_destroy(html_content *c)
Destroy hashtable of imagemaps.
nserror imagemap_extract(html_content *c)
Extract all imagemaps from a document tree.
Interface to HTML imagemap.
Generic bitmap handling interface.
Public content interface.
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Interface to platform-specific layout operation table.
Interface to platform-specific miscellaneous browser operation table.
@ BROWSER_MOUSE_PRESS_1
primary button pressed
Interface to platform-specific utf8 operations.
nserror html_mouse_track(struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse tracking (including drags) in an HTML content window.
bool html_keypress(struct content *c, uint32_t key)
Handle keypresses.
nserror html_mouse_action(struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse clicks and movements in an HTML content window.
HTML content user interaction handling.
Interface to javascript engine functions.
void js_destroythread(jsthread *thread)
Destroy a javascript thread.
bool js_fire_event(jsthread *thread, const char *type, struct dom_document *doc, struct dom_node *target)
fire an event at a dom node
nserror js_closethread(jsthread *thread)
Close a javascript thread.
Interface to key press operations.
nserror libdom_hubbub_error_to_nserror(dom_hubbub_error error)
Convert libdom hubbub binding errors to nserrors.
nserror libdom_dump_structure(dom_node *node, FILE *f, int depth)
Walk though a DOM (sub)tree, in depth first order, printing DOM structure.
libdom utilities (implementation).
static struct llcache_s * llcache
low level cache state
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
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.
nserror http_parameter_list_find_item(const http_parameter *list, lwc_string *name, lwc_string **value)
Find a named item in an HTTP parameter list.
#define NS_TRANSPARENT
Transparent colour value.
Private data for text/html content.
dom_hubbub_error html_process_script(void *ctx, dom_node *node)
process script node parser callback
bool html_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Draw a CONTENT_HTML using the current set of plotters (plot).
bool html_saw_insecure_scripts(html_content *htmlc)
Check if any of the scripts loaded were insecure.
nserror html_script_free(html_content *htmlc)
Free all script resources and references for a html content.
@ HTML_FOCUS_SELF
Focus is our own.
@ HTML_SELECTION_SELF
Selection in one of our textareas.
@ HTML_SELECTION_TEXTAREA
No selection.
@ HTML_SELECTION_CONTENT
Selection in this html content.
nserror html_script_exec(html_content *htmlc, bool allow_defer)
Attempt script execution for defer and async scripts.
static css_error node_name(void *pw, void *node, css_qname *qname)
Callback to retrieve a node's name.
Interface to utility string handling.
int width
border-width (pixels)
int descendant_y1
bottom edge of descendants
struct box_border border[4]
Border: TOP, RIGHT, BOTTOM, LEFT.
int width
Width of content box (excluding padding etc.).
struct scrollbar * scroll_x
Horizontal scroll.
size_t byte_offset
Byte offset within a textual representation of this content.
struct column * col
Array of table column data for TABLE only.
struct box * children
First child box, or NULL.
int height
Height of content box (excluding padding etc.).
int margin[4]
Margin: TOP, RIGHT, BOTTOM, LEFT.
char * usemap
(Image)map to use with this object, or NULL if none
const char * target
Link target, or NULL.
struct box * next
Next sibling box, or NULL.
struct scrollbar * scroll_y
Vertical scroll.
struct nsurl * href
Link, or NULL.
int descendant_x1
right edge of descendants
struct browser_window * iframe
Iframe's browser_window, or NULL if none.
css_computed_style * style
Style for this box.
size_t length
Length of text.
struct hlcache_handle * object
Object in this box (usually an image), or NULL if none.
char * text
Text, or NULL if none.
int padding[4]
Padding: TOP, RIGHT, BOTTOM, LEFT.
int x
Coordinate of left padding edge relative to parent box, or relative to ancestor that contains this bo...
struct form_control * gadget
Form control data, or NULL if not a form control.
int y
Coordinate of top padding edge, relative as for x.
Page features at a specific spatial location.
struct hlcache_handle * object
Object at position or NULL.
enum browser_window_features::@56 form_features
type of form feature.
struct nsurl * link
URL of a link or NULL.
Content operation function table.
Frame tree (frameset or frame tag)
char * name
frame margin height
int rows
number of columns in frameset
struct content_html_frames * children
frame border colour
int margin_width
frame width
struct nsurl * url
frame name (for targetting)
browser_scrolling scrolling
frame is not resizable
bool border
scrolling characteristics
colour border_colour
frame has a border
int margin_height
frame margin width
struct frame_dimension width
number of rows in frameset
struct frame_dimension height
frame width
Inline frame list (iframe tag)
struct content_html_iframe * next
frame border colour
struct nsurl * url
frame name (for targetting)
char * name
frame margin height
An object (img, object, etc.
struct content_html_object * next
Next in chain.
struct hlcache_handle * content
Content, or 0.
Content which corresponds to a single URL.
int height
Height dimension, if applicable.
int width
Width dimension, if applicable.
unsigned int active
Number of child fetches or conversions currently in progress.
content_status status
Current status.
unsigned int size
Estimated size of all data associated with this content.
uint64_t reformat_time
Earliest time to attempt a period reflow while fetching a page's objects.
struct nsurl * refresh
URL for refresh request.
enum frame_dimension::@63 unit
nserror(* local_to_utf8)(const char *string, size_t len, char **result)
Convert a string encoded in the system local encoding to UTF-8.
Data specific to CONTENT_HTML.
dom_document_quirks_mode quirks
Quirkyness of document.
struct imagemap ** imagemaps
Hash table of imagemaps.
struct selection * sel
HTML content's own text selection object.
int * bctx
A talloc context purely for the render box tree.
struct content_html_object * object_list
List of objects.
struct content_html_frames * frameset
Frameset information.
union html_drag_owner drag_owner
Widget capturing all mouse events.
bool refresh
Whether a meta refresh has been handled.
dom_hubbub_parser * parser
Parser object handle.
colour background_colour
Document background colour.
html_focus_type focus_type
Current input focus target type.
char * encoding
Encoding of source, NULL if unknown.
struct browser_window * bw
Browser window containing this document, or NULL if not open.
unsigned int num_objects
Number of entries in object_list.
dom_document * document
Document tree.
struct nsurl * base_url
Base URL (may be a copy of content->url).
struct html_stylesheet * stylesheets
Stylesheets.
bool conversion_begun
Whether or not the conversion has begun.
struct form * forms
Forms, in reverse order to document.
html_drag_type drag_type
Current drag type.
union html_focus_owner focus_owner
Current input focus target.
char * base_target
Base target.
css_select_ctx * select_ctx
Style selection media specification.
const struct gui_layout_table * font_func
Font callback table.
struct jsthread * jsthread
javascript thread in use
struct html_content * page
Content of type CONTENT_HTML containing this, or NULL if not an object within a page.
struct content_html_iframe * iframe
Inline frame information.
html_selection_type selection_type
Current selection state.
void * box_conversion_context
A context pointer for the box conversion, NULL if no conversion is in progress.
dom_hubbub_encoding_source encoding_source
Source of encoding information.
bool parse_completed
Whether the parse has been completed.
unsigned int scripts_count
Number of entries in scripts.
union html_selection_owner selection_owner
Current selection owner.
bool enable_scripting
Whether scripts are enabled for this content.
bool aborted
Content has been aborted in the LOADING state.
bool had_initial_layout
Whether an initial layout has been done.
css_unit_ctx unit_len_ctx
CSS length conversion context for document.
struct box * layout
Box tree, or NULL.
unsigned int stylesheet_count
Number of entries in stylesheet_content.
bool reflowing
Whether a layout (reflow) is in progress.
struct html_script * scripts
Scripts.
Representation of an HTTP parameter.
Handle to low-level cache object.
struct gui_layout_table * layout
Layout table.
struct gui_utf8_table * utf8
UTF8 table.
Parameters for object element and similar elements.
The context for a free text search.
int talloc_free(void *ptr)
const char * content_textsearch_find_pattern(const char *string, int s_len, const char *pattern, int p_len, bool case_sens, unsigned int *m_len)
Find the first occurrence of 'match' in 'string' and return its index.
nserror content_textsearch_add_match(struct textsearch_context *context, unsigned start_idx, unsigned end_idx, struct box *start_box, struct box *end_box)
Add a new entry to the list of matches.
Interface to HTML searching.
Extra data for some content_msg messages.
unsigned * viewport_width
browser_window_console_source src
The source of the logging.
struct content_msg_data::@102 getdims
CONTENT_MSG_GETDIMS - Get the viewport dimensions.
const char * explicit_status_text
CONTENT_MSG_STATUS - Status message update.
Option reading and saving interface.
#define nsoption_int(OPTION)
Get the value of an integer option.
#define nsoption_uint(OPTION)
Get the value of an unsigned integer option.
#define nsoption_bool(OPTION)
Get the value of a boolean option.
size_t utf8_from_ucs4(uint32_t c, char *s)
Convert a single UCS4 character into a UTF-8 multibyte sequence.
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.