php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
in_head_noscript.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
11static bool
12lxb_html_tree_insertion_mode_in_head_noscript_open(lxb_html_tree_t *tree,
13 lxb_html_token_t *token);
14
15static bool
16lxb_html_tree_insertion_mode_in_head_noscript_closed(lxb_html_tree_t *tree,
17 lxb_html_token_t *token);
18
19
20bool
22 lxb_html_token_t *token)
23{
24 if (token->type & LXB_HTML_TOKEN_TYPE_CLOSE) {
25 return lxb_html_tree_insertion_mode_in_head_noscript_closed(tree, token);
26 }
27
28 return lxb_html_tree_insertion_mode_in_head_noscript_open(tree, token);
29}
30
31lxb_inline bool
33 lxb_html_token_t *token);
34
35
36static bool
37lxb_html_tree_insertion_mode_in_head_noscript_open(lxb_html_tree_t *tree,
38 lxb_html_token_t *token)
39{
40 switch (token->tag_id) {
42 lxb_html_tree_parse_error(tree, token,
44 break;
45
46 case LXB_TAG_HTML:
47 return lxb_html_tree_insertion_mode_in_body(tree, token);
48
51 case LXB_TAG_BGSOUND:
52 case LXB_TAG_LINK:
53 case LXB_TAG_META:
55 case LXB_TAG_STYLE:
56 return lxb_html_tree_insertion_mode_in_head(tree, token);
57
58 case LXB_TAG_HEAD:
60 lxb_html_tree_parse_error(tree, token,
62 break;
63
64 /* CopyPast from "in head" insertion mode */
65 case LXB_TAG__TEXT: {
66 lxb_html_token_t ws_token = {0};
67
68 tree->status = lxb_html_token_data_split_ws_begin(token, &ws_token);
69 if (tree->status != LXB_STATUS_OK) {
70 return lxb_html_tree_process_abort(tree);
71 }
72
73 if (ws_token.text_start != ws_token.text_end) {
74 tree->status = lxb_html_tree_insert_character(tree, &ws_token,
75 NULL);
76 if (tree->status != LXB_STATUS_OK) {
77 return lxb_html_tree_process_abort(tree);
78 }
79 }
80
81 if (token->text_start == token->text_end) {
82 return true;
83 }
84 }
85 /* fall through */
86
87 default:
89 token);
90 }
91
92 return true;
93}
94
95static bool
96lxb_html_tree_insertion_mode_in_head_noscript_closed(lxb_html_tree_t *tree,
97 lxb_html_token_t *token)
98{
99 if(token->tag_id == LXB_TAG_BR) {
101 token);
102 }
103
105
106 return true;
107}
108
109lxb_inline bool
@ LXB_STATUS_OK
Definition base.h:49
#define NULL
Definition gdcache.h:45
struct lxb_html_tree lxb_html_tree_t
Definition base.h:28
lxb_status_t lxb_html_token_data_split_ws_begin(lxb_html_token_t *token, lxb_html_token_t *ws_token)
Definition token.c:232
@ LXB_HTML_TOKEN_TYPE_CLOSE
Definition token.h:27
@ LXB_HTML_RULES_ERROR_UNTO
Definition error.h:22
@ LXB_HTML_RULES_ERROR_DOTOINHENOMO
Definition error.h:54
bool lxb_html_tree_insertion_mode_in_head_noscript(lxb_html_tree_t *tree, lxb_html_token_t *token)
lxb_inline bool lxb_html_tree_insertion_mode_in_head_noscript_anything_else(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_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_status_t lxb_html_tree_insert_character(lxb_html_tree_t *tree, lxb_html_token_t *token, lxb_dom_node_t **ret_node)
Definition tree.c:669
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_inline lxb_dom_node_t * lxb_html_tree_open_elements_pop(lxb_html_tree_t *tree)
lxb_html_token_type_t type
Definition token.h:49
const lxb_char_t * text_end
Definition token.h:40
lxb_tag_id_t tag_id
Definition token.h:48
const lxb_char_t * text_start
Definition token.h:39
lxb_status_t status
Definition tree.h:66
lxb_html_tree_insertion_mode_f mode
Definition tree.h:62
@ LXB_TAG__EM_DOCTYPE
Definition const.h:29
@ LXB_TAG_NOSCRIPT
Definition const.h:163
@ LXB_TAG_HEAD
Definition const.h:121
@ LXB_TAG_HTML
Definition const.h:125
@ LXB_TAG_BGSOUND
Definition const.h:51
@ LXB_TAG__EM_COMMENT
Definition const.h:28
@ LXB_TAG_BASEFONT
Definition const.h:48
@ LXB_TAG_META
Definition const.h:148
@ LXB_TAG_LINK
Definition const.h:139
@ LXB_TAG_BR
Definition const.h:56
@ LXB_TAG_STYLE
Definition const.h:195
@ LXB_TAG_NOFRAMES
Definition const.h:162
@ LXB_TAG__TEXT
Definition const.h:26
#define lxb_inline
Definition types.h:21