2011-05-07 00:40:09 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-05-26 13:18:41 +03:00
|
|
|
/**
|
|
|
|
* \file
|
2018-05-10 13:34:26 +03:00
|
|
|
* Private data for text/html content.
|
2011-05-07 00:40:09 +04:00
|
|
|
*/
|
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
#ifndef NETSURF_HTML_PRIVATE_H
|
|
|
|
#define NETSURF_HTML_PRIVATE_H
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2018-05-11 15:15:17 +03:00
|
|
|
#include <dom/bindings/hubbub/parser.h>
|
2016-05-26 13:18:41 +03:00
|
|
|
|
2018-05-11 15:15:17 +03:00
|
|
|
#include "netsurf/types.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "content/content_protected.h"
|
2020-05-23 23:17:42 +03:00
|
|
|
#include "content/handlers/css/utils.h"
|
2018-05-10 13:34:26 +03:00
|
|
|
|
2019-11-12 21:34:39 +03:00
|
|
|
|
2016-04-24 01:32:21 +03:00
|
|
|
struct gui_layout_table;
|
2018-05-11 15:15:17 +03:00
|
|
|
struct scrollbar_msg_data;
|
2019-11-12 21:34:39 +03:00
|
|
|
struct content_redraw_data;
|
2020-05-24 01:33:52 +03:00
|
|
|
struct selection;
|
2016-04-24 01:32:21 +03:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
typedef enum {
|
|
|
|
HTML_DRAG_NONE, /** No drag */
|
|
|
|
HTML_DRAG_SELECTION, /** Own; Text selection */
|
|
|
|
HTML_DRAG_SCROLLBAR, /** Not own; drag in scrollbar widget */
|
|
|
|
HTML_DRAG_TEXTAREA_SELECTION, /** Not own; drag in textarea widget */
|
|
|
|
HTML_DRAG_TEXTAREA_SCROLLBAR, /** Not own; drag in textarea widget */
|
|
|
|
HTML_DRAG_CONTENT_SELECTION, /** Not own; drag in child content */
|
|
|
|
HTML_DRAG_CONTENT_SCROLL /** Not own; drag in child content */
|
|
|
|
} html_drag_type;
|
2016-04-24 01:32:21 +03:00
|
|
|
|
2018-05-11 15:15:17 +03:00
|
|
|
/**
|
|
|
|
* For drags we don't own
|
|
|
|
*/
|
2013-02-08 17:22:53 +04:00
|
|
|
union html_drag_owner {
|
|
|
|
bool no_owner;
|
|
|
|
struct box *content;
|
|
|
|
struct scrollbar *scrollbar;
|
|
|
|
struct box *textarea;
|
2018-05-11 15:15:17 +03:00
|
|
|
};
|
2013-02-08 17:22:53 +04:00
|
|
|
|
2013-02-22 16:19:35 +04:00
|
|
|
typedef enum {
|
|
|
|
HTML_SELECTION_NONE, /** No selection */
|
|
|
|
HTML_SELECTION_TEXTAREA, /** Selection in one of our textareas */
|
|
|
|
HTML_SELECTION_SELF, /** Selection in this html content */
|
|
|
|
HTML_SELECTION_CONTENT /** Selection in child content */
|
|
|
|
} html_selection_type;
|
2018-05-11 15:15:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* For getting at selections in this content or things in this content
|
|
|
|
*/
|
2013-02-22 16:19:35 +04:00
|
|
|
union html_selection_owner {
|
|
|
|
bool none;
|
|
|
|
struct box *textarea;
|
|
|
|
struct box *content;
|
2018-05-11 15:15:17 +03:00
|
|
|
};
|
2013-02-22 16:19:35 +04:00
|
|
|
|
|
|
|
typedef enum {
|
2018-05-11 15:15:17 +03:00
|
|
|
HTML_FOCUS_SELF, /**< Focus is our own */
|
|
|
|
HTML_FOCUS_CONTENT, /**< Focus belongs to child content */
|
|
|
|
HTML_FOCUS_TEXTAREA /**< Focus belongs to textarea */
|
2013-02-22 16:19:35 +04:00
|
|
|
} html_focus_type;
|
2018-05-11 15:15:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* For directing input
|
|
|
|
*/
|
2013-02-22 16:19:35 +04:00
|
|
|
union html_focus_owner {
|
|
|
|
bool self;
|
|
|
|
struct box *textarea;
|
|
|
|
struct box *content;
|
2018-05-11 15:15:17 +03:00
|
|
|
};
|
2013-02-22 16:19:35 +04:00
|
|
|
|
2018-05-11 15:15:17 +03:00
|
|
|
/**
|
|
|
|
* Data specific to CONTENT_HTML.
|
|
|
|
*/
|
2011-05-07 00:40:09 +04:00
|
|
|
typedef struct html_content {
|
|
|
|
struct content base;
|
|
|
|
|
2012-07-14 03:33:15 +04:00
|
|
|
dom_hubbub_parser *parser; /**< Parser object handle */
|
2014-02-10 05:24:43 +04:00
|
|
|
bool parse_completed; /**< Whether the parse has been completed */
|
2019-05-04 14:18:21 +03:00
|
|
|
bool conversion_begun; /**< Whether or not the conversion has begun */
|
2012-07-14 03:33:15 +04:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
/** Document tree */
|
2012-03-24 03:18:04 +04:00
|
|
|
dom_document *document;
|
2011-05-07 00:40:09 +04:00
|
|
|
/** Quirkyness of document */
|
2012-07-14 19:13:21 +04:00
|
|
|
dom_document_quirks_mode quirks;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
|
|
|
/** Encoding of source, NULL if unknown. */
|
|
|
|
char *encoding;
|
|
|
|
/** Source of encoding information. */
|
2012-07-14 03:33:15 +04:00
|
|
|
dom_hubbub_encoding_source encoding_source;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
|
|
|
/** Base URL (may be a copy of content->url). */
|
2020-05-07 01:38:50 +03:00
|
|
|
struct nsurl *base_url;
|
2011-05-07 00:40:09 +04:00
|
|
|
/** Base target */
|
|
|
|
char *base_target;
|
|
|
|
|
2011-07-20 00:23:59 +04:00
|
|
|
/** Content has been aborted in the LOADING state */
|
|
|
|
bool aborted;
|
|
|
|
|
2013-05-23 02:57:59 +04:00
|
|
|
/** Whether a meta refresh has been handled */
|
|
|
|
bool refresh;
|
|
|
|
|
2014-09-27 12:57:26 +04:00
|
|
|
/** Whether a layout (reflow) is in progress */
|
|
|
|
bool reflowing;
|
|
|
|
|
2019-08-06 11:41:22 +03:00
|
|
|
/** Whether an initial layout has been done */
|
|
|
|
bool had_initial_layout;
|
|
|
|
|
2016-01-21 17:11:36 +03:00
|
|
|
/** Whether scripts are enabled for this content */
|
|
|
|
bool enable_scripting;
|
|
|
|
|
2013-05-23 18:02:15 +04:00
|
|
|
/* Title element node */
|
|
|
|
dom_node *title;
|
|
|
|
|
2018-05-10 13:34:26 +03:00
|
|
|
/** A talloc context purely for the render box tree */
|
2012-10-03 22:24:58 +04:00
|
|
|
int *bctx;
|
2019-08-23 23:58:07 +03:00
|
|
|
/** A context pointer for the box conversion, NULL if no conversion
|
|
|
|
* is in progress.
|
|
|
|
*/
|
|
|
|
void *box_conversion_context;
|
2011-05-07 00:40:09 +04:00
|
|
|
/** Box tree, or NULL. */
|
|
|
|
struct box *layout;
|
|
|
|
/** Document background colour. */
|
|
|
|
colour background_colour;
|
2016-04-24 01:32:21 +03:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
/** Font callback table */
|
2016-04-24 01:32:21 +03:00
|
|
|
const struct gui_layout_table *font_func;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2012-06-19 13:35:51 +04:00
|
|
|
/** Number of entries in scripts */
|
|
|
|
unsigned int scripts_count;
|
|
|
|
/** Scripts */
|
|
|
|
struct html_script *scripts;
|
2020-03-21 21:30:41 +03:00
|
|
|
/** javascript thread in use */
|
|
|
|
struct jsthread *jsthread;
|
2012-06-19 13:35:51 +04:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
/** Number of entries in stylesheet_content. */
|
|
|
|
unsigned int stylesheet_count;
|
|
|
|
/** Stylesheets. Each may be NULL. */
|
|
|
|
struct html_stylesheet *stylesheets;
|
|
|
|
/**< Style selection context */
|
|
|
|
css_select_ctx *select_ctx;
|
2019-05-04 14:02:55 +03:00
|
|
|
/**< Style selection media specification */
|
|
|
|
css_media media;
|
2021-03-29 12:45:59 +03:00
|
|
|
/** CSS length conversion context for document. */
|
|
|
|
css_unit_ctx unit_len_ctx;
|
2011-10-08 04:21:59 +04:00
|
|
|
/**< Universal selector */
|
|
|
|
lwc_string *universal;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
|
|
|
/** Number of entries in object_list. */
|
|
|
|
unsigned int num_objects;
|
|
|
|
/** List of objects. */
|
|
|
|
struct content_html_object *object_list;
|
|
|
|
/** Forms, in reverse order to document. */
|
|
|
|
struct form *forms;
|
|
|
|
/** Hash table of imagemaps. */
|
|
|
|
struct imagemap **imagemaps;
|
|
|
|
|
|
|
|
/** Browser window containing this document, or NULL if not open. */
|
|
|
|
struct browser_window *bw;
|
|
|
|
|
|
|
|
/** Frameset information */
|
|
|
|
struct content_html_frames *frameset;
|
|
|
|
|
|
|
|
/** Inline frame information */
|
|
|
|
struct content_html_iframe *iframe;
|
|
|
|
|
2018-05-10 13:34:26 +03:00
|
|
|
/** Content of type CONTENT_HTML containing this, or NULL if not an
|
2011-05-07 00:40:09 +04:00
|
|
|
* object within a page. */
|
|
|
|
struct html_content *page;
|
2011-06-28 02:21:15 +04:00
|
|
|
|
2013-02-22 16:19:35 +04:00
|
|
|
/** Current drag type */
|
2013-02-08 17:22:53 +04:00
|
|
|
html_drag_type drag_type;
|
|
|
|
/** Widget capturing all mouse events */
|
|
|
|
union html_drag_owner drag_owner;
|
2013-02-07 02:39:45 +04:00
|
|
|
|
2013-02-22 16:19:35 +04:00
|
|
|
/** Current selection state */
|
|
|
|
html_selection_type selection_type;
|
|
|
|
/** Current selection owner */
|
|
|
|
union html_selection_owner selection_owner;
|
|
|
|
|
|
|
|
/** Current input focus target type */
|
|
|
|
html_focus_type focus_type;
|
|
|
|
/** Current input focus target */
|
|
|
|
union html_focus_owner focus_owner;
|
|
|
|
|
|
|
|
/** HTML content's own text selection object */
|
2020-05-24 01:33:52 +03:00
|
|
|
struct selection *sel;
|
2013-02-22 16:19:35 +04:00
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
/**
|
|
|
|
* Open core-handled form SELECT menu, or NULL if none
|
|
|
|
* currently open.
|
|
|
|
*/
|
2011-06-28 15:15:39 +04:00
|
|
|
struct form_control *visible_select_menu;
|
2011-07-13 17:20:26 +04:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
} html_content;
|
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
/**
|
|
|
|
* Render padding and margin box outlines in html_redraw().
|
|
|
|
*/
|
2014-11-07 01:51:46 +03:00
|
|
|
extern bool html_redraw_debug;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-07-07 21:50:04 +04:00
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
/* in html/html.c */
|
2013-02-08 17:22:53 +04:00
|
|
|
|
2013-02-22 16:19:35 +04:00
|
|
|
/**
|
2020-05-02 22:47:53 +03:00
|
|
|
* redraw a box
|
2013-02-22 16:19:35 +04:00
|
|
|
*
|
2020-05-02 22:47:53 +03:00
|
|
|
* \param htmlc HTML content
|
|
|
|
* \param box The box to redraw.
|
2013-02-22 16:19:35 +04:00
|
|
|
*/
|
2020-05-02 22:47:53 +03:00
|
|
|
void html__redraw_a_box(html_content *htmlc, struct box *box);
|
|
|
|
|
2013-02-22 16:19:35 +04:00
|
|
|
|
2012-07-13 23:19:04 +04:00
|
|
|
/**
|
|
|
|
* Complete conversion of an HTML document
|
|
|
|
*
|
2014-11-12 22:31:39 +03:00
|
|
|
* \param htmlc Content to convert
|
2012-07-30 21:18:11 +04:00
|
|
|
*/
|
|
|
|
void html_finish_conversion(html_content *htmlc);
|
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
|
2013-03-18 18:48:00 +04:00
|
|
|
/**
|
|
|
|
* Test if an HTML content conversion can begin
|
|
|
|
*
|
|
|
|
* \param htmlc html content to test
|
|
|
|
* \return true iff the html content conversion can begin
|
|
|
|
*/
|
|
|
|
bool html_can_begin_conversion(html_content *htmlc);
|
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
|
2012-07-30 21:18:11 +04:00
|
|
|
/**
|
|
|
|
* Begin conversion of an HTML document
|
|
|
|
*
|
|
|
|
* \param htmlc Content to convert
|
2012-07-13 23:19:04 +04:00
|
|
|
*/
|
2012-07-30 21:18:11 +04:00
|
|
|
bool html_begin_conversion(html_content *htmlc);
|
2011-07-26 17:53:42 +04:00
|
|
|
|
2015-03-09 16:47:12 +03:00
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
/**
|
|
|
|
* execute some text as a script element
|
|
|
|
*/
|
2020-04-18 00:43:44 +03:00
|
|
|
bool html_exec(struct content *c, const char *src, size_t srclen);
|
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
|
2015-03-09 16:47:12 +03:00
|
|
|
/**
|
|
|
|
* Attempt script execution for defer and async scripts
|
|
|
|
*
|
|
|
|
* execute scripts using algorithm found in:
|
|
|
|
* http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element
|
|
|
|
*
|
|
|
|
* \param htmlc html content.
|
2019-05-04 14:18:21 +03:00
|
|
|
* \param allow_defer allow deferred execution, if not, only async scripts.
|
2015-03-09 16:47:12 +03:00
|
|
|
* \return NSERROR_OK error code.
|
|
|
|
*/
|
2019-05-04 14:18:21 +03:00
|
|
|
nserror html_script_exec(html_content *htmlc, bool allow_defer);
|
2015-03-09 16:47:12 +03:00
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
|
2015-03-09 16:47:12 +03:00
|
|
|
/**
|
|
|
|
* Free all script resources and references for a html content.
|
|
|
|
*
|
|
|
|
* \param htmlc html content.
|
|
|
|
* \return NSERROR_OK or error code.
|
|
|
|
*/
|
|
|
|
nserror html_script_free(html_content *htmlc);
|
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
|
2019-12-01 18:49:08 +03:00
|
|
|
/**
|
|
|
|
* Check if any of the scripts loaded were insecure
|
|
|
|
*/
|
|
|
|
bool html_saw_insecure_scripts(html_content *htmlc);
|
|
|
|
|
2013-02-24 17:15:05 +04:00
|
|
|
|
|
|
|
/**
|
2020-05-02 22:47:53 +03:00
|
|
|
* Complete the HTML content state machine *iff* all scripts are finished
|
2013-02-24 17:15:05 +04:00
|
|
|
*/
|
2020-05-02 22:47:53 +03:00
|
|
|
nserror html_proceed_to_done(html_content *html);
|
|
|
|
|
|
|
|
|
|
|
|
/* in html/redraw.c */
|
|
|
|
bool html_redraw(struct content *c, struct content_redraw_data *data,
|
|
|
|
const struct rect *clip, const struct redraw_context *ctx);
|
2013-02-24 17:15:05 +04:00
|
|
|
|
2019-12-01 18:49:08 +03:00
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
/* in html/redraw_border.c */
|
|
|
|
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);
|
2013-02-24 17:15:05 +04:00
|
|
|
|
|
|
|
|
2020-05-02 22:47:53 +03:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
/* in html/script.c */
|
|
|
|
dom_hubbub_error html_process_script(void *ctx, dom_node *node);
|
|
|
|
|
|
|
|
|
|
|
|
/* in html/forms.c */
|
|
|
|
struct form *html_forms_get_forms(const char *docenc, dom_html_document *doc);
|
|
|
|
struct form_control *html_forms_get_control_for_node(struct form *forms,
|
|
|
|
dom_node *node);
|
|
|
|
|
|
|
|
|
|
|
|
/* in html/css_fetcher.c */
|
2014-10-26 00:34:09 +04:00
|
|
|
/**
|
|
|
|
* Register the fetcher for the pseudo x-ns-css scheme.
|
|
|
|
*
|
|
|
|
* \return NSERROR_OK on successful registration or error code on failure.
|
|
|
|
*/
|
|
|
|
nserror html_css_fetcher_register(void);
|
2020-05-07 01:38:50 +03:00
|
|
|
nserror html_css_fetcher_add_item(dom_string *data, struct nsurl *base_url,
|
2013-02-27 07:55:48 +04:00
|
|
|
uint32_t *key);
|
2013-02-27 07:11:10 +04:00
|
|
|
|
2020-02-21 13:46:21 +03:00
|
|
|
|
2015-10-31 20:01:17 +03:00
|
|
|
/* Events */
|
|
|
|
/**
|
|
|
|
* Construct an event and fire it at the DOM
|
|
|
|
*
|
|
|
|
*/
|
2019-12-01 12:55:53 +03:00
|
|
|
bool fire_generic_dom_event(dom_string *type, dom_node *target,
|
2015-10-31 20:01:17 +03:00
|
|
|
bool bubbles, bool cancelable);
|
|
|
|
|
2019-12-01 21:24:33 +03:00
|
|
|
/**
|
|
|
|
* Construct a keyboard event and fire it at the DOM
|
|
|
|
*/
|
|
|
|
bool fire_dom_keyboard_event(dom_string *type, dom_node *target,
|
|
|
|
bool bubbles, bool cancelable, uint32_t key);
|
|
|
|
|
2012-03-25 19:07:08 +04:00
|
|
|
/* Useful dom_string pointers */
|
|
|
|
struct dom_string;
|
|
|
|
|
|
|
|
extern struct dom_string *html_dom_string_map;
|
|
|
|
extern struct dom_string *html_dom_string_id;
|
|
|
|
extern struct dom_string *html_dom_string_name;
|
|
|
|
extern struct dom_string *html_dom_string_area;
|
|
|
|
extern struct dom_string *html_dom_string_a;
|
|
|
|
extern struct dom_string *html_dom_string_nohref;
|
|
|
|
extern struct dom_string *html_dom_string_href;
|
|
|
|
extern struct dom_string *html_dom_string_target;
|
|
|
|
extern struct dom_string *html_dom_string_shape;
|
|
|
|
extern struct dom_string *html_dom_string_default;
|
|
|
|
extern struct dom_string *html_dom_string_rect;
|
|
|
|
extern struct dom_string *html_dom_string_rectangle;
|
|
|
|
extern struct dom_string *html_dom_string_coords;
|
|
|
|
extern struct dom_string *html_dom_string_circle;
|
|
|
|
extern struct dom_string *html_dom_string_poly;
|
|
|
|
extern struct dom_string *html_dom_string_polygon;
|
2012-07-13 23:19:04 +04:00
|
|
|
extern struct dom_string *html_dom_string_text_javascript;
|
|
|
|
extern struct dom_string *html_dom_string_type;
|
|
|
|
extern struct dom_string *html_dom_string_src;
|
2012-03-25 19:07:08 +04:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
#endif
|