mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:58:12 +00:00
LibWeb: Add HTMLToken(Type) constructor and use it
This commit is contained in:
parent
f2e3c770f9
commit
25cba4387b
2 changed files with 10 additions and 6 deletions
|
@ -62,20 +62,25 @@ public:
|
||||||
|
|
||||||
static HTMLToken make_character(u32 code_point)
|
static HTMLToken make_character(u32 code_point)
|
||||||
{
|
{
|
||||||
HTMLToken token;
|
HTMLToken token { Type::Character };
|
||||||
token.m_type = Type::Character;
|
|
||||||
token.set_code_point(code_point);
|
token.set_code_point(code_point);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HTMLToken make_start_tag(FlyString const& tag_name)
|
static HTMLToken make_start_tag(FlyString const& tag_name)
|
||||||
{
|
{
|
||||||
HTMLToken token;
|
HTMLToken token { Type::StartTag };
|
||||||
token.m_type = Type::StartTag;
|
|
||||||
token.set_tag_name(tag_name);
|
token.set_tag_name(tag_name);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HTMLToken() = default;
|
||||||
|
|
||||||
|
HTMLToken(Type type)
|
||||||
|
: m_type(type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool is_doctype() const { return m_type == Type::DOCTYPE; }
|
bool is_doctype() const { return m_type == Type::DOCTYPE; }
|
||||||
bool is_start_tag() const { return m_type == Type::StartTag; }
|
bool is_start_tag() const { return m_type == Type::StartTag; }
|
||||||
bool is_end_tag() const { return m_type == Type::EndTag; }
|
bool is_end_tag() const { return m_type == Type::EndTag; }
|
||||||
|
|
|
@ -2665,8 +2665,7 @@ bool HTMLTokenizer::consume_next_if_match(StringView const& string, CaseSensitiv
|
||||||
|
|
||||||
void HTMLTokenizer::create_new_token(HTMLToken::Type type)
|
void HTMLTokenizer::create_new_token(HTMLToken::Type type)
|
||||||
{
|
{
|
||||||
m_current_token = {};
|
m_current_token = { type };
|
||||||
m_current_token.m_type = type;
|
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case HTMLToken::Type::StartTag:
|
case HTMLToken::Type::StartTag:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue