php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
in_select.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
9
10
11lxb_inline bool
13 lxb_html_token_t *token)
14{
15 lexbor_str_t str;
16
17 if (token->null_count != 0) {
18 lxb_html_tree_parse_error(tree, token,
20
23 }
24 else {
25 tree->status = lxb_html_token_make_text(token, &str,
27 }
28
29 if (tree->status != LXB_STATUS_OK) {
30 return lxb_html_tree_process_abort(tree);
31 }
32
33 /* Can be zero only if all NULL are gone */
34 if (str.length == 0) {
35 lexbor_str_destroy(&str, tree->document->dom_document.text, false);
36
37 return true;
38 }
39
41 if (tree->status != LXB_STATUS_OK) {
42 return lxb_html_tree_process_abort(tree);
43 }
44
45 return true;
46}
47
48lxb_inline bool
50 lxb_html_token_t *token)
51{
52 lxb_dom_comment_t *comment;
53
54 comment = lxb_html_tree_insert_comment(tree, token, NULL);
55 if (comment == NULL) {
57
58 return lxb_html_tree_process_abort(tree);
59 }
60
61 return true;
62}
63
64lxb_inline bool
72
73lxb_inline bool
79
80lxb_inline bool
82 lxb_html_token_t *token)
83{
84 lxb_html_element_t *element;
86
89 }
90
91 element = lxb_html_tree_insert_html_element(tree, token);
92 if (element == NULL) {
94
95 return lxb_html_tree_process_abort(tree);
96 }
97
98 return true;
99}
100
101lxb_inline bool
103 lxb_html_token_t *token)
104{
105 lxb_html_element_t *element;
107
110 }
111
112 node = lxb_html_tree_current_node(tree);
113
116 }
117
118 element = lxb_html_tree_insert_html_element(tree, token);
119 if (element == NULL) {
121
122 return lxb_html_tree_process_abort(tree);
123 }
124
125 return true;
126}
127
128lxb_inline bool
130 lxb_html_token_t *token)
131{
132 lxb_html_element_t *element;
134
137 }
138
139 node = lxb_html_tree_current_node(tree);
140
143 }
144
145 element = lxb_html_tree_insert_html_element(tree, token);
146 if (element == NULL) {
148
149 return lxb_html_tree_process_abort(tree);
150 }
151
153
155
156 return true;
157}
158
159lxb_inline bool
161 lxb_html_token_t *token)
162{
164
166 && tree->open_elements->length > 1)
167 {
169 tree->open_elements->length - 2);
170 if (node != NULL && lxb_html_tree_node_is(node, LXB_TAG_OPTGROUP)) {
172 }
173 }
174
175 node = lxb_html_tree_current_node(tree);
176
177 if (lxb_html_tree_node_is(node, LXB_TAG_OPTGROUP) == false) {
178 lxb_html_tree_parse_error(tree, token,
180 return true;
181 }
182
184
185 return true;
186}
187
188lxb_inline bool
190 lxb_html_token_t *token)
191{
193
194 if (lxb_html_tree_node_is(node, LXB_TAG_OPTION) == false) {
195 lxb_html_tree_parse_error(tree, token,
197 return true;
198 }
199
201
202 return true;
203}
204
205lxb_inline bool
226
227lxb_inline bool
248
249/*
250 * "input", "keygen", "textarea"
251 */
252lxb_inline bool
273
274/*
275 * A start tag whose tag name is one of: "script", "template"
276 * An end tag whose tag name is "template"
277 */
278lxb_inline bool
284
285lxb_inline bool
291
292lxb_inline bool
300
301lxb_inline bool
309
310bool
312 lxb_html_token_t *token)
313{
314 if (token->type & LXB_HTML_TOKEN_TYPE_CLOSE) {
315 switch (token->tag_id) {
316 case LXB_TAG_OPTGROUP:
318 token);
319 case LXB_TAG_OPTION:
321 token);
322 case LXB_TAG_SELECT:
324 token);
325 case LXB_TAG_TEMPLATE:
327 token);
328 default:
330 token);
331 }
332 }
333
334 switch (token->tag_id) {
335 case LXB_TAG__TEXT:
337
340
343
344 case LXB_TAG_HTML:
346
347 case LXB_TAG_OPTION:
349
350 case LXB_TAG_OPTGROUP:
352
353 case LXB_TAG_HR:
355
356 case LXB_TAG_SELECT:
358
359 case LXB_TAG_INPUT:
360 case LXB_TAG_KEYGEN:
361 case LXB_TAG_TEXTAREA:
363
364 case LXB_TAG_SCRIPT:
365 case LXB_TAG_TEMPLATE:
367 token);
370 token);
371 default:
373 token);
374 }
375}
@ LXB_STATUS_ERROR_MEMORY_ALLOCATION
Definition base.h:51
@ LXB_STATUS_OK
Definition base.h:49
struct lxb_dom_comment lxb_dom_comment_t
Definition interface.h:49
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_SELECT
Definition tag.h:32
lxb_status_t lxb_html_token_make_text_drop_null(lxb_html_token_t *token, lexbor_str_t *str, lexbor_mraw_t *mraw)
Definition token.c:110
lxb_status_t lxb_html_token_make_text(lxb_html_token_t *token, lexbor_str_t *str, lexbor_mraw_t *mraw)
Definition token.c:91
@ LXB_HTML_TOKEN_TYPE_CLOSE
Definition token.h:27
@ LXB_HTML_RULES_ERROR_NUCH
Definition error.h:26
@ LXB_HTML_RULES_ERROR_UNCLTO
Definition error.h:24
@ LXB_HTML_RULES_ERROR_UNELINOPELST
Definition error.h:66
@ LXB_HTML_RULES_ERROR_UNTO
Definition error.h:22
@ LXB_HTML_RULES_ERROR_DOTOINSEMO
Definition error.h:84
lxb_inline bool lxb_html_tree_insertion_mode_in_select_html(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:74
lxb_inline bool lxb_html_tree_insertion_mode_in_select_end_of_file(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:286
lxb_inline bool lxb_html_tree_insertion_mode_in_select_ikt(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:253
lxb_inline bool lxb_html_tree_insertion_mode_in_select_anything_else(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:293
lxb_inline bool lxb_html_tree_insertion_mode_in_select_comment(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:49
lxb_inline bool lxb_html_tree_insertion_mode_in_select_option_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:189
lxb_inline bool lxb_html_tree_insertion_mode_in_select_doctype(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:65
lxb_inline bool lxb_html_tree_insertion_mode_in_select_text(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:12
lxb_inline bool lxb_html_tree_insertion_mode_in_select_hr(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:129
bool lxb_html_tree_insertion_mode_in_select(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:311
lxb_inline bool lxb_html_tree_insertion_mode_in_select_optgroup(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:102
lxb_inline bool lxb_html_tree_insertion_mode_in_select_select(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:228
lxb_inline bool lxb_html_tree_insertion_mode_in_select_option(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:81
lxb_inline bool lxb_html_tree_insertion_mode_in_select_st_open_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:279
lxb_inline bool lxb_html_tree_insertion_mode_in_select_select_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:206
lxb_inline bool lxb_html_tree_insertion_mode_in_select_anything_else_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:302
lxb_inline bool lxb_html_tree_insertion_mode_in_select_optgroup_closed(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition in_select.c:160
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_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_status_t lxb_html_tree_insert_character_for_data(lxb_html_tree_t *tree, lexbor_str_t *str, lxb_dom_node_t **ret_node)
Definition tree.c:697
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
void lxb_html_tree_open_elements_pop_until_tag_id(lxb_html_tree_t *tree, lxb_tag_id_t tag_id, lxb_ns_id_t ns, bool exclude)
lxb_inline lxb_dom_node_t * lxb_html_tree_open_elements_get(lxb_html_tree_t *tree, size_t idx)
lxb_inline lxb_dom_node_t * lxb_html_tree_open_elements_pop(lxb_html_tree_t *tree)
lexbor_str_t * lexbor_str_destroy(lexbor_str_t *str, lexbor_mraw_t *mraw, bool destroy_obj)
Definition str.c:76
size_t length
Definition array.h:20
size_t length
Definition str.h:48
lexbor_mraw_t * text
Definition document.h:54
lxb_dom_document_t dom_document
Definition document.h:58
lxb_html_token_type_t type
Definition token.h:49
size_t null_count
Definition token.h:47
lxb_tag_id_t tag_id
Definition token.h:48
lxb_status_t status
Definition tree.h:66
lexbor_array_t * open_elements
Definition tree.h:47
lxb_html_document_t * document
Definition tree.h:42
@ LXB_TAG_OPTION
Definition const.h:167
@ LXB_TAG__EM_DOCTYPE
Definition const.h:29
@ LXB_TAG_TEMPLATE
Definition const.h:203
@ LXB_TAG_HR
Definition const.h:124
@ LXB_TAG__END_OF_FILE
Definition const.h:25
@ LXB_TAG_OPTGROUP
Definition const.h:166
@ LXB_TAG_HTML
Definition const.h:125
@ LXB_TAG_INPUT
Definition const.h:130
@ LXB_TAG__EM_COMMENT
Definition const.h:28
@ LXB_TAG_KEYGEN
Definition const.h:134
@ LXB_TAG_SCRIPT
Definition const.h:185
@ LXB_TAG_TEXTAREA
Definition const.h:204
@ LXB_TAG__TEXT
Definition const.h:26
@ LXB_TAG_SELECT
Definition const.h:187
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 bool lxb_html_tree_node_is(lxb_dom_node_t *node, lxb_tag_id_t tag_id)
Definition tree.h:280
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