NetSurf
Functions | Variables
box_special.c File Reference

Implementation of special element handling conversion. More...

#include <string.h>
#include <stdbool.h>
#include <dom/dom.h>
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/talloc.h"
#include "utils/ascii.h"
#include "utils/nsurl.h"
#include "netsurf/plot_style.h"
#include "css/hints.h"
#include "desktop/frame_types.h"
#include "content/content_factory.h"
#include "html/html.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_textarea.h"
#include "html/form_internal.h"
Include dependency graph for box_special.c:

Go to the source code of this file.

Functions

static bool box_is_root (dom_node *n)
 determine if a box is the root node More...
 
static int box_object_talloc_destructor (struct object_params *o)
 Destructor for object_params, for <object> elements. More...
 
static struct frame_dimensionbox_parse_multi_lengths (const dom_string *ds, unsigned int *count)
 Parse a multi-length-list, as defined by HTML 4.01. More...
 
static int box_frames_talloc_destructor (struct content_html_frames *f)
 Destructor for content_html_frames, for frame elements. More...
 
static bool box_create_frameset (struct content_html_frames *f, dom_node *n, html_content *content)
 create a frameset box tree More...
 
static int box_iframes_talloc_destructor (struct content_html_iframe *f)
 Destructor for content_html_iframe, for <iframe> elements. More...
 
static bool box_get_attribute (dom_node *n, const char *attribute, void *context, char **value)
 Get the value of a dom node element's attribute. More...
 
static bool box_input_text (html_content *html, struct box *box, struct dom_node *node)
 Helper function for adding textarea widget to box. More...
 
static bool box_select_add_option (struct form_control *control, dom_node *n)
 Add an option to a form select control (helper function for box_select()). More...
 
bool convert_special_elements (dom_node *node, html_content *content, struct box *box, bool *convert_children)
 call an elements special conversion handler More...
 
Special case element handlers

These functions are called by box_construct_element() when an element is being converted, according to the entries in element_table.

The parameters are the xmlNode, the content for the document, and a partly filled in box structure for the element.

Return true on success, false on memory exhaustion. Set *convert_children to false if children of this element in the XML tree should be skipped (for example, if they have been processed in some special way already).

Elements ordered as in the HTML 4.01 specification. Section numbers in brackets [] refer to the spec.

static bool box_a (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 special element handler for Anchor [12.2]. More...
 
static bool box_body (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Document body special element handler [7.5.1]. More...
 
static bool box_br (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 special element handler for forced line break [9.3.2]. More...
 
static bool box_button (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 special element handler for Push button [17.5]. More...
 
static bool box_canvas (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Canvas element. More...
 
static bool box_embed (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Embedded object (not in any HTML specification: see http://wp.netscape.com/assist/net_sites/new_html3_prop.html ) More...
 
static bool box_frameset (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Window subdivision [16.2.1]. More...
 
static bool box_iframe (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Inline subwindow [16.5]. More...
 
static bool box_image (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Embedded image [13.2]. More...
 
static bool box_input (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Form control [17.4]. More...
 
static bool box_noscript (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Noscript element. More...
 
static bool box_object (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Generic embedded object [13.3]. More...
 
static bool box_pre (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Preformatted text [9.3.4]. More...
 
static bool box_select (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Option selector [17.6]. More...
 
static bool box_textarea (dom_node *n, html_content *content, struct box *box, bool *convert_children)
 Multi-line text field [17.7]. More...
 

Variables

static const content_type image_types = CONTENT_IMAGE
 

Detailed Description

Implementation of special element handling conversion.

Definition in file box_special.c.

Function Documentation

◆ box_a()

static bool box_a ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

special element handler for Anchor [12.2].

Definition at line 683 of file box_special.c.

References box_extract_link(), box::href, box::id, nsurl_unref(), talloc_strdup(), and box::target.

Referenced by convert_special_elements().

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

◆ box_body()

static bool box_body ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Document body special element handler [7.5.1].

Definition at line 763 of file box_special.c.

References NS_TRANSPARENT, nscss_color_is_transparent, nscss_color_to_ns, and box::style.

Referenced by convert_special_elements().

Here is the caller graph for this function:

◆ box_br()

static bool box_br ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

special element handler for forced line break [9.3.2].

Definition at line 785 of file box_special.c.

References BOX_BR, and box::type.

Referenced by convert_special_elements().

Here is the caller graph for this function:

◆ box_button()

static bool box_button ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

special element handler for Push button [17.5].

Definition at line 799 of file box_special.c.

References form_control::box, BOX_INLINE_BLOCK, box::flags, box::gadget, form_control::html, html_forms_get_control_for_node(), IS_REPLACED, and box::type.

Referenced by box_input(), and convert_special_elements().

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

◆ box_canvas()

static bool box_canvas ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Canvas element.

Definition at line 827 of file box_special.c.

References box_is_root(), box::flags, IS_REPLACED, ns_computed_display(), REPLACE_DIM, and box::style.

Referenced by convert_special_elements().

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

◆ box_create_frameset()

static bool box_create_frameset ( struct content_html_frames f,
dom_node *  n,
html_content content 
)
static

◆ box_embed()

static bool box_embed ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Embedded object (not in any HTML specification: see http://wp.netscape.com/assist/net_sites/new_html3_prop.html )

Definition at line 854 of file box_special.c.

References box_extract_link(), box_is_root(), box_object_talloc_destructor(), object_params::classid, object_params::codebase, object_params::codetype, CONTENT_ANY, object_params::data, box::flags, html_fetch_object(), IS_REPLACED, object_param::name, object_param::next, ns_computed_display(), nsurl_compare(), NSURL_COMPLETE, box::object_params, object_params::params, box::style, talloc, talloc_set_destructor, talloc_strdup(), object_param::type, object_params::type, object_param::value, and object_param::valuetype.

Referenced by convert_special_elements().

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

◆ box_frames_talloc_destructor()

static int box_frames_talloc_destructor ( struct content_html_frames f)
static

Destructor for content_html_frames, for frame elements.

Parameters
fThe frame params being destroyed.
Returns
0 to allow talloc to continue destroying the tree.

Definition at line 175 of file box_special.c.

References nsurl_unref(), and content_html_frames::url.

Referenced by box_create_frameset().

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

◆ box_frameset()

static bool box_frameset ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Window subdivision [16.2.1].

Definition at line 988 of file box_special.c.

References box_create_frameset(), BOX_NONE, NSLOG, talloc_zero, and box::type.

Referenced by convert_special_elements().

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

◆ box_get_attribute()

static bool box_get_attribute ( dom_node *  n,
const char *  attribute,
void *  context,
char **  value 
)
static

Get the value of a dom node element's attribute.

Parameters
ndom element node
attributename of attribute
contexttalloc context for result buffer
valueupdated to value, if the attribute is present
Returns
true on success, false if attribute present but memory exhausted
Note
returning true does not imply that the attribute was found. If the attribute was not found, *value will be unchanged.

Definition at line 516 of file box_special.c.

References result, and talloc_strdup().

Referenced by box_image(), and box_object().

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

◆ box_iframe()

static bool box_iframe ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Inline subwindow [16.5].

Definition at line 1027 of file box_special.c.

References content_html_iframe::border, content_html_iframe::border_colour, content_html_iframe::box, box_extract_link(), box_iframes_talloc_destructor(), box_is_root(), BW_SCROLLING_AUTO, BW_SCROLLING_NO, BW_SCROLLING_YES, box::flags, IFRAME, IS_REPLACED, content_html_iframe::margin_height, content_html_iframe::margin_width, content_html_iframe::name, content_html_iframe::next, ns_computed_display(), nscss_color_to_ns, nscss_parse_colour(), nsurl_compare(), NSURL_COMPLETE, nsurl_unref(), content_html_iframe::scrolling, box::style, talloc, talloc_set_destructor, talloc_strdup(), and content_html_iframe::url.

Referenced by convert_special_elements().

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

◆ box_iframes_talloc_destructor()

static int box_iframes_talloc_destructor ( struct content_html_iframe f)
static

Destructor for content_html_iframe, for <iframe> elements.

Parameters
fThe iframe params being destroyed.
Returns
0 to allow talloc to continue destroying the tree.

Definition at line 492 of file box_special.c.

References nsurl_unref(), and content_html_iframe::url.

Referenced by box_iframe().

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

◆ box_image()

static bool box_image ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Embedded image [13.2].

Definition at line 1152 of file box_special.c.

References box_extract_link(), box_get_attribute(), box_is_root(), box::flags, html_fetch_object(), image_types, IS_REPLACED, box::length, ns_computed_display(), nsoption_bool, nsurl_unref(), REPLACE_DIM, squash_whitespace(), box::style, talloc_strdup(), box::text, content_html_iframe::url, and box::usemap.

Referenced by convert_special_elements().

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

◆ box_input()

static bool box_input ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Form control [17.4].

Definition at line 1235 of file box_special.c.

References form_control::box, box_add_child(), box_button(), box_create(), BOX_INLINE_BLOCK, BOX_INLINE_CONTAINER, box_input_text(), box_is_root(), BOX_NONE, BOX_TEXT, box::flags, box::gadget, GADGET_IMAGE, GADGET_RESET, GADGET_SUBMIT, form_control::html, html_fetch_object(), html_forms_get_control_for_node(), image_types, IS_REPLACED, box::length, messages_get(), ns_computed_display(), NSERROR_OK, nsoption_bool, nsurl_compare(), NSURL_COMPLETE, nsurl_join(), nsurl_unref(), box::style, talloc_strdup(), box::text, box::title, box::type, form_control::type, type, and form_control::value.

Referenced by convert_special_elements().

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

◆ box_input_text()

static bool box_input_text ( html_content html,
struct box box,
struct dom_node *  node 
)
static

Helper function for adding textarea widget to box.

This is a load of hacks to ensure boxes replaced with textareas can be handled by the layout code.

Definition at line 560 of file box_special.c.

References html_content::bctx, box_add_child(), BOX_BLOCK, box_create(), BOX_INLINE_BLOCK, BOX_INLINE_CONTAINER, BOX_TEXT, box_textarea_create_textarea(), box::node, box::style, talloc_strdup(), box::text, box::title, and box::type.

Referenced by box_input(), and box_textarea().

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

◆ box_is_root()

static bool box_is_root ( dom_node *  n)
inlinestatic

determine if a box is the root node

Parameters
nnode to check
Returns
true if node is root else false.

Definition at line 66 of file box_special.c.

References parent, and type.

Referenced by box_canvas(), box_embed(), box_iframe(), box_image(), box_input(), and box_object().

Here is the caller graph for this function:

◆ box_noscript()

static bool box_noscript ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Noscript element.

Definition at line 1388 of file box_special.c.

Referenced by convert_special_elements().

Here is the caller graph for this function:

◆ box_object()

static bool box_object ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Generic embedded object [13.3].

Definition at line 1406 of file box_special.c.

References box_extract_link(), box_get_attribute(), box_is_root(), box_object_talloc_destructor(), object_params::classid, object_params::codebase, object_params::codetype, CONTENT_ANY, content_factory_type_from_mime_type(), CONTENT_NONE, object_params::data, box::flags, html_fetch_object(), IS_REPLACED, object_param::name, object_param::next, ns_computed_display(), nsurl_compare(), NSURL_COMPLETE, nsurl_ref(), box::object_params, object_params::params, box::style, talloc, talloc_set_destructor, talloc_strdup(), object_param::type, object_params::type, type, box::usemap, object_param::value, and object_param::valuetype.

Referenced by convert_special_elements().

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

◆ box_object_talloc_destructor()

static int box_object_talloc_destructor ( struct object_params o)
static

Destructor for object_params, for <object> elements.

Parameters
oThe object params being destroyed.
Returns
0 to allow talloc to continue destroying the tree.

Definition at line 98 of file box_special.c.

References object_params::classid, object_params::codebase, object_params::data, and nsurl_unref().

Referenced by box_embed(), and box_object().

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

◆ box_parse_multi_lengths()

static struct frame_dimension * box_parse_multi_lengths ( const dom_string *  ds,
unsigned int *  count 
)
static

Parse a multi-length-list, as defined by HTML 4.01.

Parameters
dsdom string to parse
countupdated to number of entries
Returns
array of struct box_multi_length, or 0 on memory exhaustion

Definition at line 119 of file box_special.c.

References ascii_is_space(), count(), frame_dimension::FRAME_DIMENSION_PERCENT, frame_dimension::FRAME_DIMENSION_PIXELS, frame_dimension::FRAME_DIMENSION_RELATIVE, frame_dimension::unit, and frame_dimension::value.

Referenced by box_create_frameset().

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

◆ box_pre()

static bool box_pre ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Preformatted text [9.3.4].

Definition at line 1649 of file box_special.c.

References box::flags, and PRE_STRIP.

Referenced by convert_special_elements().

Here is the caller graph for this function:

◆ box_select()

static bool box_select ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Option selector [17.6].

Definition at line 1663 of file box_special.c.

References form_control::box, box_add_child(), box_create(), BOX_INLINE_BLOCK, BOX_INLINE_CONTAINER, box_select_add_option(), BOX_TEXT, form_control::data, box::flags, form_free_control(), box::gadget, form_control::html, html_forms_get_control_for_node(), IS_REPLACED, box::length, messages_get(), form_control::name, form_control::next, box::style, talloc_strdup(), box::text, box::title, and box::type.

Referenced by convert_special_elements().

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

◆ box_select_add_option()

static bool box_select_add_option ( struct form_control control,
dom_node *  n 
)
static

Add an option to a form select control (helper function for box_select()).

Parameters
controlselect containing the <option>
nxml element node for <option>
Returns
true on success, false on memory exhaustion

Definition at line 601 of file box_special.c.

References cnv_space2nbsp(), form_add_option(), squash_whitespace(), and text().

Referenced by box_select().

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

◆ box_textarea()

static bool box_textarea ( dom_node *  n,
html_content content,
struct box box,
bool *  convert_children 
)
static

Multi-line text field [17.7].

Definition at line 1826 of file box_special.c.

References form_control::box, box_input_text(), box::flags, box::gadget, form_control::html, html_forms_get_control_for_node(), and IS_REPLACED.

Referenced by convert_special_elements().

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

◆ convert_special_elements()

bool convert_special_elements ( dom_node *  node,
html_content content,
struct box box,
bool *  convert_children 
)

call an elements special conversion handler

Returns
true if box construction should continue else false on error.

Definition at line 1855 of file box_special.c.

References box_a(), box_body(), box_br(), box_button(), box_canvas(), box_embed(), box_frameset(), box_iframe(), box_image(), box_input(), box_noscript(), box_object(), box_pre(), box_select(), box_textarea(), and form_control::node.

Referenced by box_construct_element().

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

Variable Documentation

◆ image_types

const content_type image_types = CONTENT_IMAGE
static

Definition at line 57 of file box_special.c.

Referenced by box_image(), and box_input().