NetSurf
Functions
box_construct.h File Reference

HTML Box tree construction interface. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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. More...
 
nserror cancel_dom_to_box (void *box_conversion_context)
 aborts any ongoing box construction More...
 
struct boxbox_for_node (struct dom_node *node)
 Retrieve the box for a dom node, if there is one. More...
 
bool box_extract_link (const struct html_content *content, const struct dom_string *dsrel, struct nsurl *base, struct nsurl **result)
 Extract a URL from a relative link, handling junk like whitespace and attempting to read a real URL from "javascript:" links. More...
 

Detailed Description

HTML Box tree construction interface.

This stage of rendering converts a tree of dom_nodes (produced by libdom) to a tree of struct box. The box tree represents the structure of the document as given by the CSS display and float properties.

For example, consider the following HTML:

<h1>Example Heading</h1>
<p>Example paragraph <em>with emphasised text</em> etc.</p>
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.
Definition: plot.c:978

This would produce approximately the following box tree with default CSS rules:

BOX_BLOCK (corresponds to h1)
BOX_INLINE "Example Heading"
BOX_INLINE "Example paragraph "
BOX_INLINE "with emphasised text" (em)
BOX_INLINE "etc."
@ BOX_BLOCK
Definition: box.h:56
@ BOX_INLINE_CONTAINER
Definition: box.h:57
@ BOX_INLINE
Definition: box.h:58
char to[32]
Encoding name to convert to.
Definition: utf8.c:144

Note that the em has been collapsed into the INLINE_CONTAINER.

If these CSS rules were applied:

h1 { display: table-cell }
p { display: table-cell }
em { float: left; width: 5em }
int width
Definition: gui.c:159

then the box tree would instead look like this:

BOX_INLINE "Example Heading"
BOX_INLINE "Example paragraph "
BOX_INLINE "with emphasised text"
BOX_INLINE "etc."
@ BOX_FLOAT_LEFT
Definition: box.h:63
@ BOX_TABLE_CELL
Definition: box.h:61
@ BOX_TABLE_ROW_GROUP
Definition: box.h:62
@ BOX_TABLE
Definition: box.h:59
@ BOX_TABLE_ROW
Definition: box.h:60

Here implied boxes have been added and a float is present.

Definition in file box_construct.h.

Function Documentation

◆ box_extract_link()

bool box_extract_link ( const struct html_content content,
const struct dom_string *  dsrel,
struct nsurl base,
struct nsurl **  result 
)

Extract a URL from a relative link, handling junk like whitespace and attempting to read a real URL from "javascript:" links.

Parameters
contenthtml content
dsrelrelative URL text taken from page
basebase for relative URLs
resultupdated to target URL on heap, unchanged if extract failed
Returns
true on success, false on memory exhaustion

◆ box_for_node()

struct box * box_for_node ( struct dom_node *  node)

Retrieve the box for a dom node, if there is one.

Parameters
nodeThe DOM node
Returns
The box if there is one

Definition at line 1370 of file box_construct.c.

Referenced by box_construct_element_after(), box_extract_properties(), html_texty_element_update(), and next_node().

Here is the caller graph for this function:

◆ cancel_dom_to_box()

nserror cancel_dom_to_box ( void *  box_conversion_context)

aborts any ongoing box construction

Definition at line 1352 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
ndom document
ccontent of type CONTENT_HTML to construct box tree in
cbcallback to report conversion completion
box_conversion_contextpointer that recives the conversion context
Returns
netsurf error code indicating status of call

Definition at line 1317 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().

Here is the call graph for this function:
Here is the caller graph for this function: