Debian Codegraph @

src/tree_builder/types.rs

raw symbols SCIP
1 // Copyright 2014-2017 The html5ever Project Developers. See the
2 // COPYRIGHT file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 //! Types used within the tree builder code. Not exported to users.
11
12 use crate::tokenizer::states::RawKind;
13 use crate::tokenizer::Tag;
14
15 use crate::tendril::StrTendril;
16
17 #[derive(PartialEq, Eq, Copy, Clone, Debug)]
18 pub(crate) enum InsertionMode {
19 Initial,
20 BeforeHtml,
21 BeforeHead,
22 InHead,
23 InHeadNoscript,
24 AfterHead,
25 InBody,
26 Text,
27 InTable,
28 InTableText,
29 InCaption,
30 InColumnGroup,
31 InTableBody,
32 InRow,
33 InCell,
34 InSelect,
35 InSelectInTable,
36 InTemplate,
37 AfterBody,
38 InFrameset,
39 AfterFrameset,
40 AfterAfterBody,
41 AfterAfterFrameset,
42 }
43
44 #[derive(PartialEq, Eq, Copy, Clone, Debug)]
45 pub(crate) enum SplitStatus {
46 NotSplit,
47 Whitespace,
48 NotWhitespace,
49 }
50
51 /// A subset/refinement of `tokenizer::Token`. Everything else is handled
52 /// specially at the beginning of `process_token`.
53 #[derive(PartialEq, Eq, Clone, Debug)]
54 #[allow(clippy::enum_variant_names)]
55 pub(crate) enum Token {
56 Tag(Tag),
57 Comment(StrTendril),
58 Characters(SplitStatus, StrTendril),
59 NullCharacter,
60 Eof,
61 }
62
63 pub(crate) enum ProcessResult<Handle> {
64 Done,
65 DoneAckSelfClosing,
66 SplitWhitespace(StrTendril),
67 Reprocess(InsertionMode, Token),
68 #[allow(dead_code)] // FIXME
69 ReprocessForeign(Token),
70 Script(Handle),
71 ToPlaintext,
72 ToRawData(RawKind),
73 }
74
75 pub(crate) enum FormatEntry<Handle> {
76 Element(Handle, Tag),
77 Marker,
78 }
79
80 pub(crate) enum InsertionPoint<Handle> {
81 /// Insert as last child in this parent.
82 LastChild(Handle),
83 #[allow(dead_code)] // FIXME
84 /// Insert before this following sibling.
85 BeforeSibling(Handle),
86 /// Insertion point is decided based on existence of element's parent node.
87 TableFosterParenting {
88 element: Handle,
89 prev_element: Handle,
90 },
91 }