NetSurf
|
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"
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_dimension * | box_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 |
Implementation of special element handling conversion.
Definition in file box_special.c.
|
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().
|
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().
|
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().
|
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().
|
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().
|
static |
create a frameset box tree
Definition at line 190 of file box_special.c.
References content_html_frames::border, content_html_frames::border_colour, box_create_frameset(), box_extract_link(), box_frames_talloc_destructor(), box_parse_multi_lengths(), BW_SCROLLING_AUTO, BW_SCROLLING_NO, BW_SCROLLING_YES, content_html_frames::children, content_html_frames::cols, content_html_frames::height, content_html_frames::margin_height, content_html_frames::margin_width, content_html_frames::name, content_html_frames::no_resize, nscss_color_to_ns, nscss_parse_colour(), nsurl_compare(), NSURL_COMPLETE, content_html_frames::rows, content_html_frames::scrolling, talloc_array, talloc_set_destructor, talloc_strdup(), type, frame_dimension::unit, content_html_frames::url, frame_dimension::value, and content_html_frames::width.
Referenced by box_create_frameset(), and box_frameset().
|
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().
|
static |
Destructor for content_html_frames, for frame elements.
f | The frame params being destroyed. |
Definition at line 175 of file box_special.c.
References nsurl_unref(), and content_html_frames::url.
Referenced by box_create_frameset().
|
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().
|
static |
Get the value of a dom node element's attribute.
n | dom element node |
attribute | name of attribute |
context | talloc context for result buffer |
value | updated to value, if the attribute is present |
Definition at line 516 of file box_special.c.
References result, and talloc_strdup().
Referenced by box_image(), and box_object().
|
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().
|
static |
Destructor for content_html_iframe, for <iframe> elements.
f | The iframe params being destroyed. |
Definition at line 492 of file box_special.c.
References nsurl_unref(), and content_html_iframe::url.
Referenced by box_iframe().
|
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().
|
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().
|
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().
|
inlinestatic |
determine if a box is the root node
n | node to check |
Definition at line 66 of file box_special.c.
Referenced by box_canvas(), box_embed(), box_iframe(), box_image(), box_input(), and box_object().
|
static |
Noscript element.
Definition at line 1388 of file box_special.c.
Referenced by convert_special_elements().
|
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().
|
static |
Destructor for object_params, for <object> elements.
o | The object params being destroyed. |
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().
|
static |
Parse a multi-length-list, as defined by HTML 4.01.
ds | dom string to parse |
count | updated to number of entries |
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().
|
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().
|
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().
|
static |
Add an option to a form select control (helper function for box_select()).
control | select containing the <option> |
n | xml element node for <option> |
Definition at line 601 of file box_special.c.
References cnv_space2nbsp(), form_add_option(), squash_whitespace(), and text().
Referenced by box_select().
|
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().
bool convert_special_elements | ( | dom_node * | node, |
html_content * | content, | ||
struct box * | box, | ||
bool * | convert_children | ||
) |
call an elements special conversion handler
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().
|
static |
Definition at line 57 of file box_special.c.
Referenced by box_image(), and box_input().