This repository was archived by the owner on Feb 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree_constructor.hpp
More file actions
94 lines (73 loc) · 2.53 KB
/
Copy pathtree_constructor.hpp
File metadata and controls
94 lines (73 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
/**
* Copyright (C) 2020 Tristan. All Rights Reserved.
* This file is licensed under the BSD 2-Clause license.
* See the COPYING file for licensing information.
*/
#include <map>
#include <memory>
namespace HTML {
class TreeConstructor;
}
#include "dom/element.hpp"
#include "dom/html_head_element.hpp"
#include "parser/html/constants.hpp"
#include "parser/html/insertion_mode.hpp"
#include "parser/html/token.hpp"
#include "tree/insertion_mode.hpp"
namespace HTML {
class TreeConstructor {
public: // Properties
Tokenizer::Context &context;
InsertionModeType currentMode;
std::vector<std::shared_ptr<DOM::Element> > openElementsStack;
std::map<InsertionModeType, std::shared_ptr<InsertionMode> > insertionModes;
bool executeScript{ false };
bool fosterParenting{ false };
std::shared_ptr<DOM::HTMLHeadElement> headElementPointer{ nullptr };
public: // Methods
explicit TreeConstructor(Tokenizer::Context &);
void
EmitCharacterToken(char);
void
EmitDoctypeQuirksToken();
void
EmitEOFToken();
void
EmitToken(HTML::Tokenizer::Token &);
std::shared_ptr<DOM::Element>
InsertElement(const Unicode::UString &tagName,
const Unicode::UString &nameSpace,
const std::map<Unicode::UString, Unicode::UString> &attributes);
std::shared_ptr<DOM::Element>
CreateElement(const Unicode::UString &localName,
const Unicode::UString &nameSpace,
std::optional<Unicode::UString> prefix,
std::optional<Unicode::UString> is,
bool synchronousCustomElementsFlag);
void
InsertComment(Unicode::UString &contents);
std::shared_ptr<DOM::Element>
CreateElementForToken(HTML::Tokenizer::StartTagToken &, const Unicode::UString &nameSpace);
void
InsertNodeInAppropriateLocation(const std::shared_ptr<DOM::Node> &node,
std::optional<std::shared_ptr<DOM::Node> > overrideTarget = {});
std::shared_ptr<DOM::Element>
InsertForeignElement(HTML::Tokenizer::StartTagToken &, const Unicode::UString &nameSpace);
inline std::shared_ptr<DOM::Element>
InsertHTMLElement(HTML::Tokenizer::StartTagToken &token) {
return InsertForeignElement(token, HTML::Constants::HTMLNamespace);
}
/**
* Specless; a helper function
*/
inline void
InsertSelfClosingToken(HTML::Tokenizer::StartTagToken &token) {
InsertHTMLElement(token);
openElementsStack.pop_back();
// """Acknowledge the token's self-closing flag, if it is set."""
// This line is redundant, because we already immediately pop off the
// element from the stack.
}
};
} // namespace HTML