NetSurf
private.h
Go to the documentation of this file.
1/*
2 * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * Private data for text/html content.
22 */
23
24#ifndef NETSURF_HTML_PRIVATE_H
25#define NETSURF_HTML_PRIVATE_H
26
27#include <dom/bindings/hubbub/parser.h>
28
29#include "netsurf/types.h"
32
33
34struct gui_layout_table;
37struct selection;
38
39typedef enum {
40 HTML_DRAG_NONE, /** No drag */
41 HTML_DRAG_SELECTION, /** Own; Text selection */
42 HTML_DRAG_SCROLLBAR, /** Not own; drag in scrollbar widget */
43 HTML_DRAG_TEXTAREA_SELECTION, /** Not own; drag in textarea widget */
44 HTML_DRAG_TEXTAREA_SCROLLBAR, /** Not own; drag in textarea widget */
45 HTML_DRAG_CONTENT_SELECTION, /** Not own; drag in child content */
46 HTML_DRAG_CONTENT_SCROLL /** Not own; drag in child content */
48
49/**
50 * For drags we don't own
51 */
54 struct box *content;
56 struct box *textarea;
57};
58
59typedef enum {
60 HTML_SELECTION_NONE, /** No selection */
61 HTML_SELECTION_TEXTAREA, /** Selection in one of our textareas */
62 HTML_SELECTION_SELF, /** Selection in this html content */
63 HTML_SELECTION_CONTENT /** Selection in child content */
65
66/**
67 * For getting at selections in this content or things in this content
68 */
70 bool none;
71 struct box *textarea;
72 struct box *content;
73};
74
75typedef enum {
76 HTML_FOCUS_SELF, /**< Focus is our own */
77 HTML_FOCUS_CONTENT, /**< Focus belongs to child content */
78 HTML_FOCUS_TEXTAREA /**< Focus belongs to textarea */
80
81/**
82 * For directing input
83 */
85 bool self;
86 struct box *textarea;
87 struct box *content;
88};
89
90/**
91 * Data specific to CONTENT_HTML.
92 */
93typedef struct html_content {
94 struct content base;
95
96 dom_hubbub_parser *parser; /**< Parser object handle */
97 bool parse_completed; /**< Whether the parse has been completed */
98 bool conversion_begun; /**< Whether or not the conversion has begun */
99
100 /** Document tree */
101 dom_document *document;
102 /** Quirkyness of document */
103 dom_document_quirks_mode quirks;
104
105 /** Encoding of source, NULL if unknown. */
106 char *encoding;
107 /** Source of encoding information. */
108 dom_hubbub_encoding_source encoding_source;
109
110 /** Base URL (may be a copy of content->url). */
112 /** Base target */
114
115 /** Content has been aborted in the LOADING state */
117
118 /** Whether a meta refresh has been handled */
120
121 /** Whether a layout (reflow) is in progress */
123
124 /** Whether an initial layout has been done */
126
127 /** Whether scripts are enabled for this content */
129
130 /* Title element node */
131 dom_node *title;
132
133 /** A talloc context purely for the render box tree */
134 int *bctx;
135 /** A context pointer for the box conversion, NULL if no conversion
136 * is in progress.
137 */
139 /** Box tree, or NULL. */
140 struct box *layout;
141 /** Document background colour. */
143
144 /** Font callback table */
146
147 /** Number of entries in scripts */
148 unsigned int scripts_count;
149 /** Scripts */
151 /** javascript thread in use */
153
154 /** Number of entries in stylesheet_content. */
155 unsigned int stylesheet_count;
156 /** Stylesheets. Each may be NULL. */
158 /**< Style selection context */
159 css_select_ctx *select_ctx;
160 /**< Style selection media specification */
161 css_media media;
162 /** CSS length conversion context for document. */
163 css_unit_ctx unit_len_ctx;
164 /**< Universal selector */
165 lwc_string *universal;
166
167 /** Number of entries in object_list. */
168 unsigned int num_objects;
169 /** List of objects. */
171 /** Forms, in reverse order to document. */
172 struct form *forms;
173 /** Hash table of imagemaps. */
175
176 /** Browser window containing this document, or NULL if not open. */
178
179 /** Frameset information */
181
182 /** Inline frame information */
184
185 /** Content of type CONTENT_HTML containing this, or NULL if not an
186 * object within a page. */
188
189 /** Current drag type */
191 /** Widget capturing all mouse events */
193
194 /** Current selection state */
196 /** Current selection owner */
198
199 /** Current input focus target type */
201 /** Current input focus target */
203
204 /** HTML content's own text selection object */
205 struct selection *sel;
206
207 /**
208 * Open core-handled form SELECT menu, or NULL if none
209 * currently open.
210 */
212
214
215/**
216 * Render padding and margin box outlines in html_redraw().
217 */
218extern bool html_redraw_debug;
219
220
221/* in html/html.c */
222
223/**
224 * redraw a box
225 *
226 * \param htmlc HTML content
227 * \param box The box to redraw.
228 */
229void html__redraw_a_box(html_content *htmlc, struct box *box);
230
231
232/**
233 * Complete conversion of an HTML document
234 *
235 * \param htmlc Content to convert
236 */
238
239
240/**
241 * Test if an HTML content conversion can begin
242 *
243 * \param htmlc html content to test
244 * \return true iff the html content conversion can begin
245 */
247
248
249/**
250 * Begin conversion of an HTML document
251 *
252 * \param htmlc Content to convert
253 */
255
256
257/**
258 * execute some text as a script element
259 */
260bool html_exec(struct content *c, const char *src, size_t srclen);
261
262
263/**
264 * Attempt script execution for defer and async scripts
265 *
266 * execute scripts using algorithm found in:
267 * http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element
268 *
269 * \param htmlc html content.
270 * \param allow_defer allow deferred execution, if not, only async scripts.
271 * \return NSERROR_OK error code.
272 */
273nserror html_script_exec(html_content *htmlc, bool allow_defer);
274
275
276/**
277 * Free all script resources and references for a html content.
278 *
279 * \param htmlc html content.
280 * \return NSERROR_OK or error code.
281 */
283
284
285/**
286 * Check if any of the scripts loaded were insecure
287 */
289
290
291/**
292 * Complete the HTML content state machine *iff* all scripts are finished
293 */
295
296
297/* in html/redraw.c */
298bool html_redraw(struct content *c, struct content_redraw_data *data,
299 const struct rect *clip, const struct redraw_context *ctx);
300
301
302/* in html/redraw_border.c */
303bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
304 int p_width, int p_height, const struct rect *clip, float scale,
305 const struct redraw_context *ctx);
306
307
308bool html_redraw_inline_borders(struct box *box, struct rect b,
309 const struct rect *clip, float scale, bool first, bool last,
310 const struct redraw_context *ctx);
311
312
313/* in html/script.c */
314dom_hubbub_error html_process_script(void *ctx, dom_node *node);
315
316
317/* in html/forms.c */
318struct form *html_forms_get_forms(const char *docenc, dom_html_document *doc);
320 dom_node *node);
321
322
323/* in html/css_fetcher.c */
324/**
325 * Register the fetcher for the pseudo x-ns-css scheme.
326 *
327 * \return NSERROR_OK on successful registration or error code on failure.
328 */
330nserror html_css_fetcher_add_item(dom_string *data, struct nsurl *base_url,
331 uint32_t *key);
332
333
334/* Events */
335/**
336 * Construct an event and fire it at the DOM
337 *
338 */
339bool fire_generic_dom_event(dom_string *type, dom_node *target,
340 bool bubbles, bool cancelable);
341
342/**
343 * Construct a keyboard event and fire it at the DOM
344 */
345bool fire_dom_keyboard_event(dom_string *type, dom_node *target,
346 bool bubbles, bool cancelable, uint32_t key);
347
348/* Useful dom_string pointers */
349struct dom_string;
350
351extern struct dom_string *html_dom_string_map;
352extern struct dom_string *html_dom_string_id;
353extern struct dom_string *html_dom_string_name;
354extern struct dom_string *html_dom_string_area;
355extern struct dom_string *html_dom_string_a;
356extern struct dom_string *html_dom_string_nohref;
357extern struct dom_string *html_dom_string_href;
358extern struct dom_string *html_dom_string_target;
359extern struct dom_string *html_dom_string_shape;
360extern struct dom_string *html_dom_string_default;
361extern struct dom_string *html_dom_string_rect;
362extern struct dom_string *html_dom_string_rectangle;
363extern struct dom_string *html_dom_string_coords;
364extern struct dom_string *html_dom_string_circle;
365extern struct dom_string *html_dom_string_poly;
366extern struct dom_string *html_dom_string_polygon;
367extern struct dom_string *html_dom_string_text_javascript;
368extern struct dom_string *html_dom_string_type;
369extern struct dom_string *html_dom_string_src;
370
371#endif
Protected interface to Content handling.
nserror
Enumeration of error codes.
Definition: errors.h:29
const char * type
Definition: filetype.cpp:44
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
struct dom_string * html_dom_string_shape
struct dom_string * html_dom_string_href
dom_hubbub_error html_process_script(void *ctx, dom_node *node)
process script node parser callback
Definition: script.c:566
bool html_redraw_borders(struct box *box, int x_parent, int y_parent, int p_width, int p_height, const struct rect *clip, float scale, const struct redraw_context *ctx)
Draw borders for a box.
struct dom_string * html_dom_string_src
bool html_exec(struct content *c, const char *src, size_t srclen)
execute some text as a script element
Definition: html.c:2090
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: html.c:133
bool html_begin_conversion(html_content *htmlc)
Begin conversion of an HTML document.
Definition: html.c:833
struct dom_string * html_dom_string_id
struct html_content html_content
Data specific to CONTENT_HTML.
struct dom_string * html_dom_string_type
void html_finish_conversion(html_content *htmlc)
Complete conversion of an HTML document.
Definition: html.c:341
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).
Definition: redraw.c:1944
nserror html_css_fetcher_add_item(dom_string *data, struct nsurl *base_url, uint32_t *key)
Definition: css_fetcher.c:305
struct dom_string * html_dom_string_rectangle
html_drag_type
Definition: private.h:39
@ HTML_DRAG_SELECTION
No drag.
Definition: private.h:41
@ HTML_DRAG_CONTENT_SELECTION
Not own; drag in textarea widget.
Definition: private.h:45
@ HTML_DRAG_TEXTAREA_SELECTION
Not own; drag in scrollbar widget.
Definition: private.h:43
@ HTML_DRAG_NONE
Definition: private.h:40
@ HTML_DRAG_SCROLLBAR
Own; Text selection.
Definition: private.h:42
@ HTML_DRAG_TEXTAREA_SCROLLBAR
Not own; drag in textarea widget.
Definition: private.h:44
@ HTML_DRAG_CONTENT_SCROLL
Not own; drag in child content.
Definition: private.h:46
bool html_saw_insecure_scripts(html_content *htmlc)
Check if any of the scripts loaded were insecure.
Definition: script.c:611
nserror html_script_free(html_content *htmlc)
Free all script resources and references for a html content.
Definition: script.c:636
struct dom_string * html_dom_string_area
struct dom_string * html_dom_string_target
struct form * html_forms_get_forms(const char *docenc, dom_html_document *doc)
Definition: forms.c:126
struct dom_string * html_dom_string_coords
html_focus_type
Definition: private.h:75
@ HTML_FOCUS_SELF
Focus is our own.
Definition: private.h:76
@ HTML_FOCUS_TEXTAREA
Focus belongs to textarea.
Definition: private.h:78
@ HTML_FOCUS_CONTENT
Focus belongs to child content.
Definition: private.h:77
struct dom_string * html_dom_string_nohref
struct dom_string * html_dom_string_text_javascript
struct dom_string * html_dom_string_poly
html_selection_type
Definition: private.h:59
@ HTML_SELECTION_SELF
Selection in one of our textareas.
Definition: private.h:62
@ HTML_SELECTION_NONE
Definition: private.h:60
@ HTML_SELECTION_TEXTAREA
No selection.
Definition: private.h:61
@ HTML_SELECTION_CONTENT
Selection in this html content.
Definition: private.h:63
bool html_redraw_inline_borders(struct box *box, struct rect b, const struct rect *clip, float scale, bool first, bool last, const struct redraw_context *ctx)
Draw an inline's borders.
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: html.c:111
nserror html_css_fetcher_register(void)
Register the fetcher for the pseudo x-ns-css scheme.
Definition: css_fetcher.c:286
bool html_redraw_debug
Render padding and margin box outlines in html_redraw().
Definition: redraw.c:68
struct dom_string * html_dom_string_map
struct dom_string * html_dom_string_polygon
struct dom_string * html_dom_string_circle
struct dom_string * html_dom_string_a
struct form_control * html_forms_get_control_for_node(struct form *forms, dom_node *node)
Definition: forms.c:545
void html__redraw_a_box(html_content *htmlc, struct box *box)
redraw a box
Definition: html.c:1130
struct dom_string * html_dom_string_default
struct dom_string * html_dom_string_name
struct dom_string * html_dom_string_rect
nserror html_proceed_to_done(html_content *html)
Complete the HTML content state machine iff all scripts are finished.
Definition: html.c:285
bool html_can_begin_conversion(html_content *htmlc)
Test if an HTML content conversion can begin.
Definition: html.c:814
nserror html_script_exec(html_content *htmlc, bool allow_defer)
Attempt script execution for defer and async scripts.
Definition: script.c:59
Node in box tree.
Definition: box.h:177
Browser window data.
Frame tree (frameset or frame tag)
Definition: html.h:108
Inline frame list (iframe tag)
Definition: html.h:131
An object (img, object, etc.
Definition: html.h:93
parameters to content redraw
Definition: content.h:40
Content which corresponds to a single URL.
Form control.
Definition: form_internal.h:73
struct form_textarea_data data
void * node
Corresponding DOM node.
Definition: form_internal.h:74
struct html_content * html
HTML content containing control.
Definition: form_internal.h:77
HTML form.
Data specific to CONTENT_HTML.
Definition: private.h:93
dom_document_quirks_mode quirks
Quirkyness of document.
Definition: private.h:103
struct imagemap ** imagemaps
Hash table of imagemaps.
Definition: private.h:174
struct selection * sel
HTML content's own text selection object.
Definition: private.h:205
int * bctx
A talloc context purely for the render box tree.
Definition: private.h:134
struct content_html_object * object_list
List of objects.
Definition: private.h:170
struct content_html_frames * frameset
Frameset information.
Definition: private.h:180
union html_drag_owner drag_owner
Widget capturing all mouse events.
Definition: private.h:192
bool refresh
Whether a meta refresh has been handled.
Definition: private.h:119
dom_hubbub_parser * parser
Parser object handle.
Definition: private.h:96
colour background_colour
Document background colour.
Definition: private.h:142
html_focus_type focus_type
Current input focus target type.
Definition: private.h:200
char * encoding
Encoding of source, NULL if unknown.
Definition: private.h:106
struct browser_window * bw
Browser window containing this document, or NULL if not open.
Definition: private.h:177
unsigned int num_objects
Number of entries in object_list.
Definition: private.h:168
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
struct html_stylesheet * stylesheets
Stylesheets.
Definition: private.h:157
bool conversion_begun
Whether or not the conversion has begun.
Definition: private.h:98
struct form * forms
Forms, in reverse order to document.
Definition: private.h:172
html_drag_type drag_type
Current drag type.
Definition: private.h:190
union html_focus_owner focus_owner
Current input focus target.
Definition: private.h:202
char * base_target
Base target.
Definition: private.h:113
css_select_ctx * select_ctx
Style selection media specification.
Definition: private.h:159
css_media media
Definition: private.h:161
const struct gui_layout_table * font_func
Font callback table.
Definition: private.h:145
struct jsthread * jsthread
javascript thread in use
Definition: private.h:152
struct html_content * page
Content of type CONTENT_HTML containing this, or NULL if not an object within a page.
Definition: private.h:187
struct content_html_iframe * iframe
Inline frame information.
Definition: private.h:183
html_selection_type selection_type
Current selection state.
Definition: private.h:195
void * box_conversion_context
A context pointer for the box conversion, NULL if no conversion is in progress.
Definition: private.h:138
dom_hubbub_encoding_source encoding_source
Source of encoding information.
Definition: private.h:108
bool parse_completed
Whether the parse has been completed.
Definition: private.h:97
unsigned int scripts_count
Number of entries in scripts.
Definition: private.h:148
struct form_control * visible_select_menu
Open core-handled form SELECT menu, or NULL if none currently open.
Definition: private.h:211
union html_selection_owner selection_owner
Current selection owner.
Definition: private.h:197
bool enable_scripting
Whether scripts are enabled for this content.
Definition: private.h:128
struct content base
Definition: private.h:94
bool aborted
Content has been aborted in the LOADING state.
Definition: private.h:116
bool had_initial_layout
Whether an initial layout has been done.
Definition: private.h:125
css_unit_ctx unit_len_ctx
CSS length conversion context for document.
Definition: private.h:163
dom_node * title
Definition: private.h:131
struct box * layout
Box tree, or NULL.
Definition: private.h:140
unsigned int stylesheet_count
Number of entries in stylesheet_content.
Definition: private.h:155
bool reflowing
Whether a layout (reflow) is in progress.
Definition: private.h:122
lwc_string * universal
Definition: private.h:165
struct html_script * scripts
Scripts.
Definition: private.h:150
Container for scripts used by an HTML document.
Definition: html.h:69
Container for stylesheets used by an HTML document.
Definition: html.h:58
dukky javascript thread
Definition: dukky.c:70
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
scrollbar message context data
Definition: scrollbar.h:59
Scrollbar context.
Definition: scrollbar.c:44
NetSurf types.
uint32_t colour
Colour type: XBGR.
Definition: types.h:35
For drags we don't own.
Definition: private.h:52
bool no_owner
Definition: private.h:53
struct box * textarea
Definition: private.h:56
struct scrollbar * scrollbar
Definition: private.h:55
struct box * content
Definition: private.h:54
For directing input.
Definition: private.h:84
struct box * textarea
Definition: private.h:86
struct box * content
Definition: private.h:87
For getting at selections in this content or things in this content.
Definition: private.h:69
struct box * content
Definition: private.h:72
struct box * textarea
Definition: private.h:71
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357