mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 23:25:20 +00:00
LibWeb: Support comments in the "in head" insertion mode
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <AK/Utf32View.h>
|
||||
#include <LibWeb/DOM/Comment.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/DocumentType.h>
|
||||
#include <LibWeb/DOM/ElementFactory.h>
|
||||
@@ -34,9 +35,9 @@
|
||||
#include <LibWeb/Parser/HTMLDocumentParser.h>
|
||||
#include <LibWeb/Parser/HTMLToken.h>
|
||||
|
||||
#define TODO() \
|
||||
do { \
|
||||
ASSERT_NOT_REACHED(); \
|
||||
#define TODO() \
|
||||
do { \
|
||||
ASSERT_NOT_REACHED(); \
|
||||
} while (0)
|
||||
|
||||
namespace Web {
|
||||
@@ -179,6 +180,13 @@ void HTMLDocumentParser::handle_before_head(HTMLToken& token)
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
void HTMLDocumentParser::insert_comment(HTMLToken& token)
|
||||
{
|
||||
auto data = token.m_comment_or_character.data.to_string();
|
||||
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
|
||||
adjusted_insertion_location->append_child(adopt(*new Comment(document(), data)));
|
||||
}
|
||||
|
||||
void HTMLDocumentParser::handle_in_head(HTMLToken& token)
|
||||
{
|
||||
if (token.is_parser_whitespace()) {
|
||||
@@ -186,6 +194,11 @@ void HTMLDocumentParser::handle_in_head(HTMLToken& token)
|
||||
return;
|
||||
}
|
||||
|
||||
if (token.is_comment()) {
|
||||
insert_comment(token);
|
||||
return;
|
||||
}
|
||||
|
||||
if (token.is_start_tag() && token.tag_name() == "title") {
|
||||
insert_html_element(token);
|
||||
m_tokenizer.switch_to({}, HTMLTokenizer::State::RCDATA);
|
||||
|
||||
@@ -96,6 +96,7 @@ private:
|
||||
RefPtr<Element> insert_html_element(HTMLToken&);
|
||||
Element& current_node();
|
||||
void insert_character(u32 data);
|
||||
void insert_comment(HTMLToken&);
|
||||
void reconstruct_the_active_formatting_elements();
|
||||
void process_using_the_rules_for(InsertionMode, HTMLToken&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user