php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
in_table_body.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2019 Alexander Borisov
3 *
4 * Author: Alexander Borisov <borisov@lexbor.com>
5 */
6
9
10
11static void
12lxb_html_tree_clear_stack_back_to_table_body(lxb_html_tree_t *tree)
13{
15
16 while ((current->local_name != LXB_TAG_TBODY
17 && current->local_name != LXB_TAG_TFOOT
18 && current->local_name != LXB_TAG_THEAD
19 && current->local_name != LXB_TAG_TEMPLATE
20 && current->local_name != LXB_TAG_HTML)
21 || current->ns != LXB_NS_HTML)
22 {
25 }
26}
27
28lxb_inline bool
30 lxb_html_token_t *token)
31{
32 lxb_html_element_t *element;
33
34 lxb_html_tree_clear_stack_back_to_table_body(tree);
35
36 element = lxb_html_tree_insert_html_element(tree, token);
37 if (element == NULL) {
39
40 return lxb_html_tree_process_abort(tree);
41 }
42
44
45 return true;
46}
47
48/*
49 * "th", "td"
50 */
51lxb_inline bool
53 lxb_html_token_t *token)
54{
55 lxb_html_token_t fake_token;
56 lxb_html_element_t *element;
57
59
60 lxb_html_tree_clear_stack_back_to_table_body(tree);
61
62 fake_token = *token;
63
64 fake_token.tag_id = LXB_TAG_TR;
65 fake_token.attr_first = NULL;
66 fake_token.attr_last = NULL;
67
68 element = lxb_html_tree_insert_html_element(tree, &fake_token);
69 if (element == NULL) {
71
72 return lxb_html_tree_process_abort(tree);
73 }
74
76
77 return false;
78}
79
80/*
81 * "tbody", "tfoot", "thead"
82 */
83lxb_inline bool
85 lxb_html_token_t *token)
86{
87 lxb_dom_node_t *node;
88
91 if (node == NULL) {
93
94 return true;
95 }
96
97 lxb_html_tree_clear_stack_back_to_table_body(tree);
99
101
102 return true;
103}
104
105/*
106 * A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody",
107 * "tfoot", "thead"
108 * An end tag whose tag name is "table"
109 */
110lxb_inline bool
112 lxb_html_token_t *token)
113{
114 lxb_dom_node_t *node;
115
117 if (node == NULL) {
119
120 return true;
121 }
122
123 lxb_html_tree_clear_stack_back_to_table_body(tree);
125
127
128 return false;
129}
130
131/*
132 * "body", "caption", "col", "colgroup", "html", "td", "th", "tr"
133 */
134lxb_inline bool
142
143lxb_inline bool
149
150lxb_inline bool
157
158bool
160 lxb_html_token_t *token)
161{
162 if (token->type & LXB_HTML_TOKEN_TYPE_CLOSE) {
163 switch (token->tag_id) {
164 case LXB_TAG_TBODY:
165 case LXB_TAG_TFOOT:
166 case LXB_TAG_THEAD:
168 token);
169 case LXB_TAG_TABLE:
171 token);
172 case LXB_TAG_BODY:
173 case LXB_TAG_CAPTION:
174 case LXB_TAG_COL:
175 case LXB_TAG_COLGROUP:
176 case LXB_TAG_HTML:
177 case LXB_TAG_TD:
178 case LXB_TAG_TH:
179 case LXB_TAG_TR:
181 token);
182 default:
184 token);
185 }
186 }
187
188 switch (token->tag_id) {
189 case LXB_TAG_TR:
191
192 case LXB_TAG_TH:
193 case LXB_TAG_TD:
195
196 case LXB_TAG_CAPTION:
197 case LXB_TAG_COL:
198 case LXB_TAG_COLGROUP:
199 case LXB_TAG_TBODY:
200 case LXB_TAG_TFOOT:
201 case LXB_TAG_THEAD:
203 token);
204 default:
206 token);
207 }
208}
@ LXB_STATUS_ERROR_MEMORY_ALLOCATION
Definition base.h:51
struct lxb_dom_node lxb_dom_node_t
Definition interface.h:38
#define NULL
Definition gdcache.h:45
struct lxb_html_tree lxb_html_tree_t
Definition base.h:28
struct lxb_html_element lxb_html_element_t
Definition interface.h:111
@ LXB_HTML_TAG_CATEGORY_SCOPE_TABLE
Definition tag.h:31
@ LXB_HTML_TOKEN_TYPE_CLOSE
Definition token.h:27
@ LXB_HTML_RULES_ERROR_UNCLTO
Definition error.h:24
@ LXB_HTML_RULES_ERROR_UNTO
Definition error.h:22
@ LXB_HTML_RULES_ERROR_MIELINSC
Definition error.h:72
lxb_inline bool lxb_html_tree_insertion_mode_in_table_body_anything_else(lxb_html_tree_t *tree, lxb_html_token_t *token)
bool lxb_html_tree_insertion_mode_in_table_body(lxb_html_tree_t *tree, lxb_html_token_t *token)
lxb_inline bool lxb_html_tree_insertion_mode_in_table_body_tbtfth_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
lxb_inline bool lxb_html_tree_insertion_mode_in_table_body_tr(lxb_html_tree_t *tree, lxb_html_token_t *token)
lxb_inline bool lxb_html_tree_insertion_mode_in_table_body_thtd(lxb_html_tree_t *tree, lxb_html_token_t *token)
lxb_inline bool lxb_html_tree_insertion_mode_in_table_body_bcht_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
lxb_inline bool lxb_html_tree_insertion_mode_in_table_body_anything_else_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
lxb_inline bool lxb_html_tree_insertion_mode_in_table_body_ct_open_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
LXB_API bool lxb_html_tree_insertion_mode_in_table(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:371
LXB_API bool lxb_html_tree_insertion_mode_in_row(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_row.c:162
bool lxb_html_tree_process_abort(lxb_html_tree_t *tree)
Definition tree.c:224
lxb_dom_node_t * lxb_html_tree_element_in_scope_tbody_thead_tfoot(lxb_html_tree_t *tree)
Definition tree.c:1242
lxb_dom_node_t * lxb_html_tree_element_in_scope(lxb_html_tree_t *tree, lxb_tag_id_t tag_id, lxb_ns_id_t ns, lxb_html_tag_category_t ct)
Definition tree.c:1152
void lxb_html_tree_parse_error(lxb_html_tree_t *tree, lxb_html_token_t *token, lxb_html_tree_error_id_t id)
Definition tree.c:237
@ LXB_NS_HTML
Definition const.h:26
lxb_inline lxb_dom_node_t * lxb_html_tree_open_elements_pop(lxb_html_tree_t *tree)
zval * current
Definition session.c:1024
lxb_html_token_type_t type
Definition token.h:49
lxb_tag_id_t tag_id
Definition token.h:48
lxb_html_token_attr_t * attr_first
Definition token.h:42
lxb_html_token_attr_t * attr_last
Definition token.h:43
lxb_status_t status
Definition tree.h:66
lxb_html_tree_insertion_mode_f mode
Definition tree.h:62
@ LXB_TAG_COL
Definition const.h:64
@ LXB_TAG_TEMPLATE
Definition const.h:203
@ LXB_TAG_TD
Definition const.h:202
@ LXB_TAG_HTML
Definition const.h:125
@ LXB_TAG_THEAD
Definition const.h:208
@ LXB_TAG_CAPTION
Definition const.h:59
@ LXB_TAG_BODY
Definition const.h:55
@ LXB_TAG_TBODY
Definition const.h:201
@ LXB_TAG_COLGROUP
Definition const.h:65
@ LXB_TAG_TABLE
Definition const.h:200
@ LXB_TAG_TFOOT
Definition const.h:206
@ LXB_TAG_TH
Definition const.h:207
@ LXB_TAG_TR
Definition const.h:211
lxb_inline lxb_dom_node_t * lxb_html_tree_current_node(lxb_html_tree_t *tree)
Definition tree.h:286
lxb_inline lxb_html_element_t * lxb_html_tree_insert_html_element(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition tree.h:307
#define lxb_inline
Definition types.h:21