NetSurf
|
Implementation of conversion from DOM tree to box tree. More...
#include <string.h>
#include <dom/dom.h>
#include "utils/errors.h"
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/talloc.h"
#include "utils/ascii.h"
#include "utils/nsurl.h"
#include "utils/utils.h"
#include "netsurf/misc.h"
#include "css/select.h"
#include "desktop/gui_internal.h"
#include "html/private.h"
#include "html/object.h"
#include "html/box.h"
#include "html/box_manipulate.h"
#include "html/box_construct.h"
#include "html/box_special.h"
#include "html/box_normalise.h"
#include "html/form_internal.h"
Go to the source code of this file.
Data Structures | |
struct | box_construct_ctx |
Context for box tree construction. More... | |
struct | box_construct_props |
Transient properties for construction of current node. More... | |
Functions | |
static bool | box_is_root (dom_node *n) |
determine if a box is the root node More... | |
static void | box_extract_properties (dom_node *n, struct box_construct_props *props) |
Extract transient construction properties. More... | |
static css_select_results * | box_get_style (html_content *c, const css_computed_style *parent_style, const css_computed_style *root_style, dom_node *n) |
Get the style for an element. More... | |
static void | box_construct_generate (dom_node *n, html_content *content, struct box *box, const css_computed_style *style) |
Construct the box required for a generated element. More... | |
static bool | box_construct_marker (struct box *box, const char *title, struct box_construct_ctx *ctx, struct box *parent) |
Construct a list marker box. More... | |
static bool | box__style_is_float (const struct box *box) |
static bool | box__is_flex (const struct box *box) |
static bool | box__containing_block_is_flex (const struct box_construct_props *props) |
static bool | box_construct_element (struct box_construct_ctx *ctx, bool *convert_children) |
Construct the box tree for an XML element. More... | |
static void | box_construct_element_after (dom_node *n, html_content *content) |
Complete construction of the box tree for an element. More... | |
static dom_node * | next_node (dom_node *n, html_content *content, bool convert_children) |
Find the next node in the DOM tree, completing element construction where appropriate. More... | |
static void | box_text_transform (char *s, unsigned int len, enum css_text_transform_e tt) |
Apply the CSS text-transform property to given text for its ASCII chars. More... | |
static bool | box_construct_text (struct box_construct_ctx *ctx) |
Construct the box tree for an XML text node. More... | |
static void | convert_xml_to_box (struct box_construct_ctx *ctx) |
Convert an ELEMENT node to a box tree fragment, then schedule conversion of the next ELEMENT node. More... | |
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. More... | |
nserror | cancel_dom_to_box (void *box_conversion_context) |
aborts any ongoing box construction More... | |
struct box * | box_for_node (dom_node *n) |
Retrieve the box for a dom node, if there is one. More... | |
bool | box_extract_link (const html_content *content, const dom_string *dsrel, nsurl *base, nsurl **result) |
Variables | |
static const content_type | image_types = CONTENT_IMAGE |
static const box_type | box_map [] |
Implementation of conversion from DOM tree to box tree.
Definition in file box_construct.c.
|
inlinestatic |
Definition at line 457 of file box_construct.c.
References box__is_flex(), and box_construct_props::containing_block.
Referenced by box_construct_element().
|
inlinestatic |
Definition at line 452 of file box_construct.c.
References BOX_FLEX, BOX_INLINE_FLEX, and box::type.
Referenced by box__containing_block_is_flex().
|
inlinestatic |
Definition at line 446 of file box_construct.c.
References box::style.
Referenced by box_construct_element().
|
static |
Construct the box tree for an XML element.
ctx | Tree construction context |
convert_children | Whether to convert children |
Definition at line 472 of file box_construct.c.
References box_construct_ctx::bctx, form_control::box, box__containing_block_is_flex(), box__style_is_float(), box_add_child(), BOX_BLOCK, BOX_BR, box_construct_generate(), box_construct_marker(), box_create(), box_extract_properties(), BOX_FLEX, BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, box_get_style(), BOX_INLINE, BOX_INLINE_BLOCK, BOX_INLINE_CONTAINER, BOX_INLINE_FLEX, box_map, BOX_NONE, clamp, box::columns, box_construct_props::containing_block, box_construct_ctx::content, CONVERT_CHILDREN, convert_special_elements(), box::flags, box::gadget, box_construct_props::href, html_fetch_object(), image_types, box_construct_props::inline_container, IS_REPLACED, box_construct_ctx::n, box::node, box_construct_props::node_is_root, ns_computed_display(), ns_computed_display_static(), NSERROR_OK, nsoption_bool, nsurl_create(), nsurl_unref(), box_construct_props::parent_style, box_construct_ctx::root_box, box::rows, squash_whitespace(), box::style, box::styles, talloc_strdup(), box_construct_props::target, box_construct_props::title, and box::type.
Referenced by convert_xml_to_box().
|
static |
Complete construction of the box tree for an element.
n | DOM node to construct for |
content | Containing document |
This will be called after all children of an element have been processed
Definition at line 773 of file box_construct.c.
References box_add_child(), BOX_BR, box_construct_generate(), box_create(), box_extract_properties(), box_for_node(), BOX_INLINE, BOX_INLINE_CONTAINER, BOX_INLINE_END, box_construct_props::containing_block, CONVERT_CHILDREN, box::flags, box::href, box::id, box_construct_props::inline_container, box::inline_end, IS_REPLACED, box::style, box::styles, box::target, box::title, and box::type.
Referenced by next_node().
|
static |
Construct the box required for a generated element.
n | XML node of type XML_ELEMENT_NODE |
content | Content of type CONTENT_HTML that is being processed |
box | Box which may have generated content |
style | Complete computed style for pseudo element, or NULL |
Definition at line 313 of file box_construct.c.
References box_add_child(), BOX_BLOCK, box_create(), box_is_root(), box_map, ns_computed_display(), box::style, and box::type.
Referenced by box_construct_element(), and box_construct_element_after().
|
static |
Construct a list marker box.
box | Box to attach marker to |
title | Current title attribute |
ctx | Box construction context |
parent | Current block-level container |
Definition at line 368 of file box_construct.c.
References box_construct_ctx::bctx, BOX_BLOCK, box_create(), box_construct_ctx::content, html_fetch_object(), image_types, box::length, box::list_marker, NSERROR_OK, nsoption_bool, nsurl_create(), nsurl_unref(), box::parent, box::style, box::text, box::title, and box::type.
Referenced by box_construct_element().
|
static |
Construct the box tree for an XML text node.
ctx | Tree construction context |
Definition at line 993 of file box_construct.c.
References box_construct_ctx::bctx, box_add_child(), box_create(), box_extract_properties(), BOX_INLINE_CONTAINER, BOX_TEXT, box_text_transform(), box_construct_props::containing_block, box::flags, box_construct_props::href, box_construct_props::inline_container, box::last, box::length, box_construct_ctx::n, box_construct_props::parent_style, PRE_STRIP, box::prev, box::space, squash_whitespace(), talloc_strdup(), box_construct_props::target, box::text, text(), box_construct_props::title, box::type, and UNKNOWN_WIDTH.
Referenced by convert_xml_to_box().
bool box_extract_link | ( | const html_content * | content, |
const dom_string * | dsrel, | ||
nsurl * | base, | ||
nsurl ** | result | ||
) |
Definition at line 1388 of file box_construct.c.
References ascii_is_space(), base, NSERROR_OK, nsurl_join(), and result.
Referenced by box_a(), box_create_frameset(), box_embed(), box_iframe(), box_image(), box_object(), and imagemap_addtolist().
|
static |
Extract transient construction properties.
n | Current DOM node to convert |
props | Property object to populate |
Definition at line 155 of file box_construct.c.
References BOX_BR, box_for_node(), BOX_INLINE, BOX_INLINE_CONTAINER, box_is_root(), box_construct_props::containing_block, box::href, box_construct_props::href, box_construct_props::inline_container, box::last, box_construct_props::node_is_root, parent_node(), box_construct_props::parent_style, box::style, box::target, box_construct_props::target, box::title, box_construct_props::title, and box::type.
Referenced by box_construct_element(), box_construct_element_after(), and box_construct_text().
struct box * box_for_node | ( | struct dom_node * | node | ) |
Retrieve the box for a dom node, if there is one.
node | The DOM node |
Definition at line 1373 of file box_construct.c.
Referenced by box_construct_element_after(), box_extract_properties(), html_texty_element_update(), and next_node().
|
static |
Get the style for an element.
c | content of type CONTENT_HTML that is being processed |
parent_style | style at this point in xml tree, or NULL for root |
root_style | root node's style, or NULL for root |
n | node in xml tree |
Definition at line 248 of file box_construct.c.
References nscss_select_ctx::base_url, html_content::base_url, nscss_select_ctx::ctx, html_content::encoding, html_content::media, nscss_create_inline_style(), nscss_get_style(), nsoption_bool, nsurl_access(), nscss_select_ctx::parent_style, nscss_select_ctx::quirks, html_content::quirks, nscss_select_ctx::root_style, html_content::select_ctx, box::styles, html_content::unit_len_ctx, nscss_select_ctx::universal, and html_content::universal.
Referenced by box_construct_element().
|
inlinestatic |
determine if a box is the root node
n | node to check |
Definition at line 123 of file box_construct.c.
Referenced by box_construct_generate(), box_extract_properties(), and next_node().
|
static |
Apply the CSS text-transform property to given text for its ASCII chars.
s | string to transform |
len | length of s |
tt | transform type |
Definition at line 957 of file box_construct.c.
References ascii_is_space(), ascii_to_lower(), and ascii_to_upper().
Referenced by box_construct_text().
nserror cancel_dom_to_box | ( | void * | box_conversion_context | ) |
aborts any ongoing box construction
Definition at line 1355 of file box_construct.c.
References convert_xml_to_box(), guit, netsurf_table::misc, box_construct_ctx::n, NSERROR_OK, and gui_misc_table::schedule.
Referenced by html_destroy().
|
static |
Convert an ELEMENT node to a box tree fragment, then schedule conversion of the next ELEMENT node.
Definition at line 1234 of file box_construct.c.
References BOX_BLOCK, box_construct_element(), box_construct_text(), box_normalise_block(), box_construct_ctx::cb, box_construct_ctx::content, convert_xml_to_box(), guit, html_content::layout, netsurf_table::misc, box_construct_ctx::n, box::next, next_node(), box::parent, root, box_construct_ctx::root_box, gui_misc_table::schedule, and type.
Referenced by cancel_dom_to_box(), convert_xml_to_box(), and dom_to_box().
nserror dom_to_box | ( | struct dom_node * | n, |
struct html_content * | c, | ||
box_construct_complete_cb | cb, | ||
void ** | box_conversion_context | ||
) |
Construct a box tree from a dom and html content.
n | dom document |
c | content of type CONTENT_HTML to construct box tree in |
cb | callback to report conversion completion |
box_conversion_context | pointer that recives the conversion context |
Definition at line 1320 of file box_construct.c.
References box_construct_ctx::bctx, html_content::bctx, box_construct_ctx::cb, box_construct_ctx::content, convert_xml_to_box(), guit, netsurf_table::misc, box_construct_ctx::n, NSERROR_NOMEM, box_construct_ctx::root_box, gui_misc_table::schedule, and talloc_zero.
Referenced by html_finish_conversion().
|
static |
Find the next node in the DOM tree, completing element construction where appropriate.
n | Current node |
content | Containing content |
convert_children | Whether to consider children of n |
Definition at line 845 of file box_construct.c.
References box_construct_element_after(), box_for_node(), box_is_root(), box::next, and parent.
Referenced by convert_xml_to_box(), and libdom_find_first_element().
|
static |
Definition at line 92 of file box_construct.c.
Referenced by box_construct_element(), and box_construct_generate().
|
static |
Definition at line 88 of file box_construct.c.
Referenced by box_construct_element(), box_construct_marker(), and mimesniff__compute_image().