LibWeb: Support comments in the "in head" insertion mode
This commit is contained in:
parent
20911efd4d
commit
af8a9331b2
Notes:
sideshowbarker
2024-07-19 06:10:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/af8a9331b20
2 changed files with 17 additions and 3 deletions
|
@ -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&);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue