php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
in_table.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2020 Alexander Borisov
3 *
4 * Author: Alexander Borisov <borisov@lexbor.com>
5 */
6
10
11
12lxb_inline void
26
27lxb_inline bool
29 lxb_html_token_t *token)
30{
32
33 if (node->ns == LXB_NS_HTML &&
35 || node->local_name == LXB_TAG_TBODY
36 || node->local_name == LXB_TAG_TFOOT
37 || node->local_name == LXB_TAG_THEAD
38 || node->local_name == LXB_TAG_TR))
39 {
41 tree->pending_table.have_non_ws = false;
42
43 tree->original_mode = tree->mode;
45
46 return false;
47 }
48
50}
51
52lxb_inline bool
54 lxb_html_token_t *token)
55{
56 lxb_dom_comment_t *comment;
57
58 comment = lxb_html_tree_insert_comment(tree, token, NULL);
59 if (comment == NULL) {
61
62 return lxb_html_tree_process_abort(tree);
63 }
64
65 return true;
66}
67
68lxb_inline bool
76
77lxb_inline bool
101
102lxb_inline bool
104 lxb_html_token_t *token)
105{
106 lxb_html_element_t *element;
107
109
110 element = lxb_html_tree_insert_html_element(tree, token);
111 if (element == NULL) {
113
114 return lxb_html_tree_process_abort(tree);
115 }
116
118
119 return true;
120}
121
122lxb_inline bool
124 lxb_html_token_t *token)
125{
126 lxb_html_element_t *element;
127 lxb_html_token_t fake_token = {0};
128
130
131 fake_token.tag_id = LXB_TAG_COLGROUP;
132 fake_token.attr_first = NULL;
133 fake_token.attr_last = NULL;
134
135 element = lxb_html_tree_insert_html_element(tree, &fake_token);
136 if (element == NULL) {
138
139 return lxb_html_tree_process_abort(tree);
140 }
141
143
144 return false;
145}
146
147/*
148 * "tbody", "tfoot", "thead"
149 */
150lxb_inline bool
152 lxb_html_token_t *token)
153{
154 lxb_html_element_t *element;
155
157
158 element = lxb_html_tree_insert_html_element(tree, token);
159 if (element == NULL) {
161
162 return lxb_html_tree_process_abort(tree);
163 }
164
166
167 return true;
168}
169
170/*
171 * "td", "th", "tr"
172 */
173lxb_inline bool
175 lxb_html_token_t *token)
176{
177 lxb_html_element_t *element;
178 lxb_html_token_t fake_token = {0};
179
181
182 fake_token.tag_id = LXB_TAG_TBODY;
183 fake_token.attr_first = NULL;
184 fake_token.attr_last = NULL;
185
186 element = lxb_html_tree_insert_html_element(tree, &fake_token);
187 if (element == NULL) {
189
190 return lxb_html_tree_process_abort(tree);
191 }
192
194
195 return false;
196}
197
198lxb_inline bool
217
218lxb_inline bool
237
238/*
239 * "body", "caption", "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
240 * "thead", "tr"
241 */
242lxb_inline bool
250
251/*
252 * A start tag whose tag name is one of: "style", "script", "template"
253 * An end tag whose tag name is "template"
254 */
255lxb_inline bool
261
262lxb_inline bool
264 lxb_html_token_t *token)
265{
266 lxb_html_element_t *element;
268
269 while (attr != NULL) {
270
271 /* Name == "type" and value == "hidden" */
272 if (attr->name != NULL && attr->name->attr_id == LXB_DOM_ATTR_TYPE) {
273 if (attr->value_size == 6
275 (const lxb_char_t *) "hidden", 6))
276 {
277 goto have_hidden;
278 }
279 }
280
281 attr = attr->next;
282 }
283
285
286have_hidden:
287
289
290 element = lxb_html_tree_insert_html_element(tree, token);
291 if (element == NULL) {
293
294 return lxb_html_tree_process_abort(tree);
295 }
296
298 lxb_dom_interface_node(element),
299 true);
300
302
303 return true;
304}
305
306lxb_inline bool
308 lxb_html_token_t *token)
309{
310 lxb_dom_node_t *node;
311 lxb_html_element_t *element;
312
314
315 if (tree->form != NULL) {
316 return true;
317 }
318
321 if (node != NULL) {
322 return true;
323 }
324
325 element = lxb_html_tree_insert_html_element(tree, token);
326 if (element == NULL) {
328
329 return lxb_html_tree_process_abort(tree);
330 }
331
332 tree->form = lxb_html_interface_form(element);
333
335 lxb_dom_interface_node(element),
336 true);
337 return true;
338}
339
340lxb_inline bool
346
347bool
349 lxb_html_token_t *token)
350{
351 tree->foster_parenting = true;
352
354 if (tree->status != LXB_STATUS_OK) {
355 return lxb_html_tree_process_abort(tree);
356 }
357
358 tree->foster_parenting = false;
359
360 return true;
361}
362
363lxb_inline bool
369
370bool
372 lxb_html_token_t *token)
373{
374 if (token->type & LXB_HTML_TOKEN_TYPE_CLOSE) {
375 switch (token->tag_id) {
376 case LXB_TAG_TABLE:
378 token);
379 case LXB_TAG_BODY:
380 case LXB_TAG_CAPTION:
381 case LXB_TAG_COL:
382 case LXB_TAG_COLGROUP:
383 case LXB_TAG_HTML:
384 case LXB_TAG_TBODY:
385 case LXB_TAG_TD:
386 case LXB_TAG_TFOOT:
387 case LXB_TAG_TH:
388 case LXB_TAG_THEAD:
389 case LXB_TAG_TR:
391 token);
392 case LXB_TAG_TEMPLATE:
394 token);
395 default:
397 token);
398 }
399 }
400
401 switch (token->tag_id) {
402 case LXB_TAG__TEXT:
404
407
410
411 case LXB_TAG_CAPTION:
413
414 case LXB_TAG_COLGROUP:
416
417 case LXB_TAG_COL:
419
420 case LXB_TAG_TBODY:
421 case LXB_TAG_TFOOT:
422 case LXB_TAG_THEAD:
424
425 case LXB_TAG_TD:
426 case LXB_TAG_TH:
427 case LXB_TAG_TR:
429
430 case LXB_TAG_TABLE:
432
433 case LXB_TAG_STYLE:
434 case LXB_TAG_SCRIPT:
435 case LXB_TAG_TEMPLATE:
437 token);
438 case LXB_TAG_INPUT:
440
441 case LXB_TAG_FORM:
443
446 token);
447 default:
449 token);
450 }
451}
lxb_inline lxb_status_t lxb_html_tree_active_formatting_push_marker(lxb_html_tree_t *tree)
@ LXB_DOM_ATTR_TYPE
Definition attr_const.h:55
@ LXB_STATUS_ERROR_MEMORY_ALLOCATION
Definition base.h:51
@ LXB_STATUS_OK
Definition base.h:49
#define lxb_dom_interface_node(obj)
Definition interface.h:31
struct lxb_dom_comment lxb_dom_comment_t
Definition interface.h:49
struct lxb_dom_node lxb_dom_node_t
Definition interface.h:38
new_type attr
Definition ffi.c:4364
#define NULL
Definition gdcache.h:45
struct lxb_html_tree lxb_html_tree_t
Definition base.h:28
#define lxb_html_interface_form(obj)
Definition interface.h:40
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_DOTOINTAMO
Definition error.h:82
lxb_inline bool lxb_html_tree_insertion_mode_in_table_st_open_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:256
lxb_inline bool lxb_html_tree_insertion_mode_in_table_text_open(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:28
lxb_inline bool lxb_html_tree_insertion_mode_in_table_form(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:307
lxb_inline bool lxb_html_tree_insertion_mode_in_table_comment(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:53
lxb_inline void lxb_html_tree_clear_stack_back_to_table_context(lxb_html_tree_t *tree)
Definition in_table.c:13
lxb_inline bool lxb_html_tree_insertion_mode_in_table_anything_else_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:364
lxb_inline bool lxb_html_tree_insertion_mode_in_table_table_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:219
lxb_inline bool lxb_html_tree_insertion_mode_in_table_colgroup(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:103
lxb_inline bool lxb_html_tree_insertion_mode_in_table_caption(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:78
lxb_inline bool lxb_html_tree_insertion_mode_in_table_col(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:123
bool lxb_html_tree_insertion_mode_in_table(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:371
bool lxb_html_tree_insertion_mode_in_table_anything_else(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:348
lxb_inline bool lxb_html_tree_insertion_mode_in_table_doctype(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:69
lxb_inline bool lxb_html_tree_insertion_mode_in_table_bcht_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:243
lxb_inline bool lxb_html_tree_insertion_mode_in_table_end_of_file(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:341
lxb_inline bool lxb_html_tree_insertion_mode_in_table_table(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:199
lxb_inline bool lxb_html_tree_insertion_mode_in_table_tdthtr(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:174
lxb_inline bool lxb_html_tree_insertion_mode_in_table_input(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:263
lxb_inline bool lxb_html_tree_insertion_mode_in_table_tbtfth(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_table.c:151
LXB_API bool lxb_html_tree_insertion_mode_in_table_text(lxb_html_tree_t *tree, lxb_html_token_t *token)
LXB_API bool lxb_html_tree_insertion_mode_in_head(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_head.c:41
LXB_API bool lxb_html_tree_insertion_mode_in_caption(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_caption.c:113
LXB_API bool lxb_html_tree_insertion_mode_in_table_body(lxb_html_tree_t *tree, lxb_html_token_t *token)
LXB_API bool lxb_html_tree_insertion_mode_in_column_group(lxb_html_tree_t *tree, lxb_html_token_t *token)
LXB_API bool lxb_html_tree_insertion_mode_in_body(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_body.c:1685
bool lxb_html_tree_process_abort(lxb_html_tree_t *tree)
Definition tree.c:224
lxb_dom_comment_t * lxb_html_tree_insert_comment(lxb_html_tree_t *tree, lxb_html_token_t *token, lxb_dom_node_t *pos)
Definition tree.c:790
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
void lxb_html_tree_reset_insertion_mode_appropriately(lxb_html_tree_t *tree)
Definition tree.c:999
@ LXB_NS_HTML
Definition const.h:26
lxb_dom_node_t * lxb_html_tree_open_elements_find_reverse(lxb_html_tree_t *tree, lxb_tag_id_t tag_id, lxb_ns_id_t ns, size_t *return_index)
void lxb_html_tree_open_elements_pop_until_node(lxb_html_tree_t *tree, lxb_dom_node_t *node, bool exclude)
lxb_inline lxb_dom_node_t * lxb_html_tree_open_elements_pop(lxb_html_tree_t *tree)
zval * current
Definition session.c:1024
bool lexbor_str_data_ncasecmp(const lxb_char_t *first, const lxb_char_t *sec, size_t size)
Definition str.c:435
uintptr_t ns
Definition node.h:48
uintptr_t local_name
Definition node.h:46
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
lexbor_array_obj_t * text_list
Definition tree.h:34
lxb_html_tree_pending_table_t pending_table
Definition tree.h:51
lxb_html_tree_insertion_mode_f original_mode
Definition tree.h:63
lxb_html_form_element_t * form
Definition tree.h:45
lxb_status_t status
Definition tree.h:66
lxb_html_tree_insertion_mode_f mode
Definition tree.h:62
bool foster_parenting
Definition tree.h:55
@ LXB_TAG__EM_DOCTYPE
Definition const.h:29
@ LXB_TAG_COL
Definition const.h:64
@ LXB_TAG_TEMPLATE
Definition const.h:203
@ LXB_TAG__END_OF_FILE
Definition const.h:25
@ LXB_TAG_TD
Definition const.h:202
@ LXB_TAG_HTML
Definition const.h:125
@ LXB_TAG_THEAD
Definition const.h:208
@ LXB_TAG_INPUT
Definition const.h:130
@ LXB_TAG__EM_COMMENT
Definition const.h:28
@ LXB_TAG_FORM
Definition const.h:111
@ 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_SCRIPT
Definition const.h:185
@ LXB_TAG_TFOOT
Definition const.h:206
@ LXB_TAG_TH
Definition const.h:207
@ LXB_TAG_STYLE
Definition const.h:195
@ LXB_TAG_TR
Definition const.h:211
@ LXB_TAG__TEXT
Definition const.h:26
struct lxb_html_token_attr lxb_html_token_attr_t
Definition token_attr.h:22
lxb_inline lxb_dom_node_t * lxb_html_tree_current_node(lxb_html_tree_t *tree)
Definition tree.h:286
lxb_inline void lxb_html_tree_acknowledge_token_self_closing(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition tree.h:327
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
unsigned char lxb_char_t
Definition types.h:27