php-internal-docs
8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
after_body.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
7
#include "
lexbor/html/tree/insertion_mode.h
"
8
#include "
lexbor/html/tree/open_elements.h
"
9
10
11
bool
12
lxb_html_tree_insertion_mode_after_body
(
lxb_html_tree_t
*tree,
13
lxb_html_token_t
*token)
14
{
15
switch
(token->
tag_id
) {
16
case
LXB_TAG__EM_COMMENT
: {
17
lxb_dom_comment_t
*comment;
18
lxb_dom_node_t
*html_node;
19
20
html_node =
lxb_html_tree_open_elements_first
(tree);
21
22
comment =
lxb_html_tree_insert_comment
(tree, token, html_node);
23
if
(comment ==
NULL
) {
24
return
lxb_html_tree_process_abort
(tree);
25
}
26
27
break
;
28
}
29
30
case
LXB_TAG__EM_DOCTYPE
:
31
lxb_html_tree_parse_error
(tree, token,
32
LXB_HTML_RULES_ERROR_DOTOAFBOMO
);
33
break
;
34
35
case
LXB_TAG_HTML
:
36
if
(token->
type
&
LXB_HTML_TOKEN_TYPE_CLOSE
)
37
{
38
if
(tree->
fragment
!=
NULL
) {
39
lxb_html_tree_parse_error
(tree, token,
40
LXB_HTML_RULES_ERROR_UNCLTO
);
41
return
true
;
42
}
43
44
tree->
mode
=
lxb_html_tree_insertion_mode_after_after_body
;
45
46
return
true
;
47
}
48
49
return
lxb_html_tree_insertion_mode_in_body
(tree, token);
50
51
case
LXB_TAG__END_OF_FILE
:
52
tree->
status
=
lxb_html_tree_stop_parsing
(tree);
53
if
(tree->
status
!=
LXB_STATUS_OK
) {
54
return
lxb_html_tree_process_abort
(tree);
55
}
56
57
break
;
58
59
case
LXB_TAG__TEXT
: {
60
lxb_html_token_t
ws_token = *token;
61
62
tree->
status
=
lxb_html_token_data_skip_ws_begin
(&ws_token);
63
if
(tree->
status
!=
LXB_STATUS_OK
) {
64
return
lxb_html_tree_process_abort
(tree);
65
}
66
67
if
(ws_token.
text_start
== ws_token.
text_end
) {
68
return
lxb_html_tree_insertion_mode_in_body
(tree, token);
69
}
70
}
71
/* fall through */
72
73
default
:
74
lxb_html_tree_parse_error
(tree, token,
LXB_HTML_RULES_ERROR_UNTO
);
75
76
tree->
mode
=
lxb_html_tree_insertion_mode_in_body
;
77
78
return
false
;
79
}
80
81
return
true
;
82
}
lxb_html_tree_insertion_mode_after_body
bool lxb_html_tree_insertion_mode_after_body(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition
after_body.c:12
LXB_STATUS_OK
@ LXB_STATUS_OK
Definition
base.h:49
lxb_dom_comment_t
struct lxb_dom_comment lxb_dom_comment_t
Definition
interface.h:49
lxb_dom_node_t
struct lxb_dom_node lxb_dom_node_t
Definition
interface.h:38
NULL
#define NULL
Definition
gdcache.h:45
lxb_html_tree_t
struct lxb_html_tree lxb_html_tree_t
Definition
base.h:28
lxb_html_token_data_skip_ws_begin
lxb_status_t lxb_html_token_data_skip_ws_begin(lxb_html_token_t *token)
Definition
token.c:179
LXB_HTML_TOKEN_TYPE_CLOSE
@ LXB_HTML_TOKEN_TYPE_CLOSE
Definition
token.h:27
LXB_HTML_RULES_ERROR_UNCLTO
@ LXB_HTML_RULES_ERROR_UNCLTO
Definition
error.h:24
LXB_HTML_RULES_ERROR_UNTO
@ LXB_HTML_RULES_ERROR_UNTO
Definition
error.h:22
LXB_HTML_RULES_ERROR_DOTOAFBOMO
@ LXB_HTML_RULES_ERROR_DOTOAFBOMO
Definition
error.h:86
insertion_mode.h
lxb_html_tree_insertion_mode_after_after_body
LXB_API bool lxb_html_tree_insertion_mode_after_after_body(lxb_html_tree_t *tree, lxb_html_token_t *token)
Definition
after_after_body.c:11
lxb_html_tree_insertion_mode_in_body
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
lxb_html_tree_process_abort
bool lxb_html_tree_process_abort(lxb_html_tree_t *tree)
Definition
tree.c:224
lxb_html_tree_insert_comment
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_html_tree_stop_parsing
lxb_status_t lxb_html_tree_stop_parsing(lxb_html_tree_t *tree)
Definition
tree.c:216
lxb_html_tree_parse_error
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
open_elements.h
lxb_html_tree_open_elements_first
lxb_inline lxb_dom_node_t * lxb_html_tree_open_elements_first(lxb_html_tree_t *tree)
Definition
open_elements.h:69
lxb_html_token_t
Definition
token.h:33
lxb_html_token_t::type
lxb_html_token_type_t type
Definition
token.h:49
lxb_html_token_t::text_end
const lxb_char_t * text_end
Definition
token.h:40
lxb_html_token_t::tag_id
lxb_tag_id_t tag_id
Definition
token.h:48
lxb_html_token_t::text_start
const lxb_char_t * text_start
Definition
token.h:39
lxb_html_tree::status
lxb_status_t status
Definition
tree.h:66
lxb_html_tree::mode
lxb_html_tree_insertion_mode_f mode
Definition
tree.h:62
lxb_html_tree::fragment
lxb_dom_node_t * fragment
Definition
tree.h:43
LXB_TAG__EM_DOCTYPE
@ LXB_TAG__EM_DOCTYPE
Definition
const.h:29
LXB_TAG__END_OF_FILE
@ LXB_TAG__END_OF_FILE
Definition
const.h:25
LXB_TAG_HTML
@ LXB_TAG_HTML
Definition
const.h:125
LXB_TAG__EM_COMMENT
@ LXB_TAG__EM_COMMENT
Definition
const.h:28
LXB_TAG__TEXT
@ LXB_TAG__TEXT
Definition
const.h:26
ext
dom
lexbor
lexbor
html
tree
insertion_mode
after_body.c
Generated on Sat Aug 23 2025 01:46:07 for php-internal-docs by
1.13.2