Hubbub
in_select_in_table.c
Go to the documentation of this file.
1 /*
2  * This file is part of Hubbub.
3  * Licensed under the MIT License,
4  * http://www.opensource.org/licenses/mit-license.php
5  * Copyright 2008 Andrew Sidwell <takkaria@netsurf-browser.org>
6  */
7 
8 #include <assert.h>
9 #include <string.h>
10 
11 #include "treebuilder/modes.h"
12 #include "treebuilder/internal.h"
14 #include "utils/utils.h"
15 
16 
25  const hubbub_token *token)
26 {
27  bool handled = false;
28  hubbub_error err = HUBBUB_OK;
29 
30  if (token->type == HUBBUB_TOKEN_END_TAG ||
31  token->type == HUBBUB_TOKEN_START_TAG) {
33  &token->data.tag.name);
34 
35  if (type == CAPTION || type == TABLE || type == TBODY ||
36  type == TFOOT || type == THEAD || type == TR ||
37  type == TD || type == TH) {
40  handled = true;
41 
42  if ((token->type == HUBBUB_TOKEN_END_TAG &&
43  element_in_scope(treebuilder, type,
44  true)) ||
45  token->type == HUBBUB_TOKEN_START_TAG) {
48  element_stack_pop_until(treebuilder,
49  SELECT);
50  reset_insertion_mode(treebuilder);
51  err = HUBBUB_REPROCESS;
52  }
53  }
54  }
55 
56  if (!handled) {
57  err = handle_in_select(treebuilder, token);
58  }
59 
60  return err;
61 }
Definition: internal.h:25
hubbub_token_type type
The token type.
Definition: types.h:120
hubbub_error handle_in_select(hubbub_treebuilder *treebuilder, const hubbub_token *token)
Handle token in "in head" insertion mode.
Definition: in_select.c:24
Token data.
Definition: types.h:119
hubbub_string name
Tag name.
Definition: types.h:110
element_type
Definition: internal.h:13
Definition: internal.h:25
Definition: internal.h:25
Definition: internal.h:22
Definition: internal.h:22
hubbub_error handle_in_select_in_table(hubbub_treebuilder *treebuilder, const hubbub_token *token)
Handle token in "in select in table" insertion mode.
hubbub_error
Definition: errors.h:18
hubbub_error element_stack_pop_until(hubbub_treebuilder *treebuilder, element_type type)
Pop elements until an element of type "element" has been popped.
Definition: treebuilder.c:1162
Definition: internal.h:22
element_type type
Definition: treebuilder.c:26
No error.
Definition: errors.h:19
hubbub_tag tag
Definition: types.h:125
union hubbub_token::@3 data
Type-specific data.
uint32_t element_in_scope(hubbub_treebuilder *treebuilder, element_type type, bool in_table)
Determine if an element is in (table) scope.
Definition: treebuilder.c:500
element_type element_type_from_name(hubbub_treebuilder *treebuilder, const hubbub_string *tag_name)
Convert an element name into an element type.
Definition: treebuilder.c:987
Definition: internal.h:23
Treebuilder object.
Definition: internal.h:116
void reset_insertion_mode(hubbub_treebuilder *treebuilder)
Reset the insertion mode.
Definition: treebuilder.c:863