Hubbub
Data Structures | Macros | Functions | Variables
in_foreign_content.c File Reference
#include <assert.h>
#include <string.h>
#include "treebuilder/modes.h"
#include "treebuilder/internal.h"
#include "treebuilder/treebuilder.h"
#include "utils/utils.h"

Go to the source code of this file.

Data Structures

struct  case_changes
 Mapping table for case changes. More...
 

Macros

#define S(s)   s, SLEN(s)
 
#define S(s)   (uint8_t *) s, SLEN(s)
 

Functions

void adjust_mathml_attributes (hubbub_treebuilder *treebuilder, hubbub_tag *tag)
 Adjust MathML attributes. More...
 
void adjust_svg_attributes (hubbub_treebuilder *treebuilder, hubbub_tag *tag)
 Adjust SVG attributes. More...
 
void adjust_svg_tagname (hubbub_treebuilder *treebuilder, hubbub_tag *tag)
 Adjust SVG tagnmes. More...
 
void adjust_foreign_attributes (hubbub_treebuilder *treebuilder, hubbub_tag *tag)
 Adjust foreign attributes. More...
 
static bool element_in_scope_in_non_html_ns (hubbub_treebuilder *treebuilder)
 Returns true iff there is an element in scope that has a namespace other than the HTML namespace. More...
 
static hubbub_error process_as_in_secondary (hubbub_treebuilder *treebuilder, const hubbub_token *token)
 Process a token as if in the secondary insertion mode. More...
 
static void foreign_break_out (hubbub_treebuilder *treebuilder)
 Break out of foreign content as a result of certain start tags or EOF. More...
 
hubbub_error handle_in_foreign_content (hubbub_treebuilder *treebuilder, const hubbub_token *token)
 Handle tokens in "in foreign content" insertion mode. More...
 

Variables

static const case_changes svg_attributes []
 
static const case_changes svg_tagnames []
 

Macro Definition Documentation

◆ S [1/2]

#define S (   s)    s, SLEN(s)

Definition at line 219 of file in_foreign_content.c.

Referenced by adjust_foreign_attributes(), and handle_in_foreign_content().

◆ S [2/2]

#define S (   s)    (uint8_t *) s, SLEN(s)

Definition at line 219 of file in_foreign_content.c.

Function Documentation

◆ adjust_foreign_attributes()

void adjust_foreign_attributes ( hubbub_treebuilder treebuilder,
hubbub_tag tag 
)

Adjust foreign attributes.

Parameters
treebuilderTreebuilder instance
tagTag to adjust the attributes of

Definition at line 227 of file in_foreign_content.c.

References hubbub_tag::attributes, HUBBUB_NS_XLINK, HUBBUB_NS_XML, HUBBUB_NS_XMLNS, hubbub_string_match(), len, hubbub_string::len, hubbub_tag::n_attributes, name, hubbub_attribute::name, hubbub_attribute::ns, hubbub_string::ptr, S, SLEN, and UNUSED.

Referenced by handle_in_foreign_content(), and process_start_tag().

◆ adjust_mathml_attributes()

void adjust_mathml_attributes ( hubbub_treebuilder treebuilder,
hubbub_tag tag 
)

Adjust MathML attributes.

Parameters
treebuilderTreebuilder instance
tagTag to adjust the attributes of

Definition at line 144 of file in_foreign_content.c.

References hubbub_tag::attributes, hubbub_string_match(), len, hubbub_string::len, hubbub_tag::n_attributes, name, hubbub_attribute::name, hubbub_string::ptr, SLEN, and UNUSED.

Referenced by process_start_tag().

◆ adjust_svg_attributes()

void adjust_svg_attributes ( hubbub_treebuilder treebuilder,
hubbub_tag tag 
)

Adjust SVG attributes.

Parameters
treebuilderTreebuilder instance
tagTag to adjust the attributes of

Definition at line 169 of file in_foreign_content.c.

References hubbub_tag::attributes, hubbub_string_match(), len, hubbub_string::len, hubbub_tag::n_attributes, N_ELEMENTS, name, hubbub_attribute::name, hubbub_string::ptr, svg_attributes, and UNUSED.

Referenced by handle_in_foreign_content(), and process_start_tag().

◆ adjust_svg_tagname()

void adjust_svg_tagname ( hubbub_treebuilder treebuilder,
hubbub_tag tag 
)

Adjust SVG tagnmes.

Parameters
treebuilderTreebuilder instance
tagTag to adjust the name of

Definition at line 199 of file in_foreign_content.c.

References hubbub_string_match(), len, hubbub_string::len, N_ELEMENTS, name, hubbub_tag::name, hubbub_string::ptr, svg_tagnames, and UNUSED.

Referenced by handle_in_foreign_content().

◆ element_in_scope_in_non_html_ns()

static bool element_in_scope_in_non_html_ns ( hubbub_treebuilder treebuilder)
static

Returns true iff there is an element in scope that has a namespace other than the HTML namespace.

Definition at line 301 of file in_foreign_content.c.

References hubbub_treebuilder::context, hubbub_treebuilder_context::current_node, hubbub_treebuilder_context::element_stack, HUBBUB_NS_HTML, is_scoping_element(), TABLE, and element_context::type.

Referenced by process_as_in_secondary().

◆ foreign_break_out()

static void foreign_break_out ( hubbub_treebuilder treebuilder)
static

◆ handle_in_foreign_content()

hubbub_error handle_in_foreign_content ( hubbub_treebuilder treebuilder,
const hubbub_token token 
)

Handle tokens in "in foreign content" insertion mode.

Parameters
treebuilderThe treebuilder instance
tokenThe token to process
Returns
True to reprocess the token, false otherwise
Todo:
parse error
Todo:
ack sc flag

Definition at line 390 of file in_foreign_content.c.

References adjust_foreign_attributes(), adjust_svg_attributes(), adjust_svg_tagname(), ANNOTATION_XML, append_text(), hubbub_tag::attributes, B, BIG, BLOCKQUOTE, BODY, BR, CENTER, hubbub_token::character, CODE, hubbub_treebuilder::context, hubbub_treebuilder_context::current_node, current_node(), hubbub_token::data, DD, DESC, DIV, DL, DT, hubbub_treebuilder_context::element_stack, element_type_from_name(), EM, EMBED, FONT, foreign_break_out(), FOREIGNOBJECT, H1, H2, H3, H4, H5, H6, HEAD, HR, HUBBUB_NS_HTML, HUBBUB_NS_MATHML, HUBBUB_NS_SVG, HUBBUB_OK, HUBBUB_REPROCESS, hubbub_string_match(), HUBBUB_TOKEN_CHARACTER, HUBBUB_TOKEN_COMMENT, HUBBUB_TOKEN_DOCTYPE, HUBBUB_TOKEN_END_TAG, HUBBUB_TOKEN_EOF, HUBBUB_TOKEN_START_TAG, I, IMG, insert_element(), len, hubbub_string::len, LI, LISTING, MALIGNMARK, MENU, META, MGLYPH, MI, MN, MO, MS, MTEXT, hubbub_tag::n_attributes, name, hubbub_attribute::name, hubbub_tag::name, NOBR, element_context::node, element_context::ns, hubbub_tag::ns, OL, P, PRE, process_as_in_secondary(), process_comment_append(), hubbub_string::ptr, RUBY, S, hubbub_tag::self_closing, SLEN, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, SVG, TABLE, hubbub_token::tag, TITLE, TT, type, hubbub_token::type, U, UL, and VAR.

Referenced by hubbub_treebuilder_token_handler().

◆ process_as_in_secondary()

static hubbub_error process_as_in_secondary ( hubbub_treebuilder treebuilder,
const hubbub_token token 
)
static

Variable Documentation

◆ svg_attributes

const case_changes svg_attributes[]
static

Definition at line 32 of file in_foreign_content.c.

Referenced by adjust_svg_attributes().

◆ svg_tagnames

const case_changes svg_tagnames[]
static

Definition at line 97 of file in_foreign_content.c.

Referenced by adjust_svg_tagname().