From b083a233d8482ed7106d7a102866ee0dd42acc94 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 12 Oct 2019 23:26:47 +0200 Subject: LibHTML: Add Comment and CharacterData nodes and improve HTML parsing This patch adds the CharacterData subclass of Node, which is now the parent class of Text and a new Comment class. A Comment node is one of these in HTML: Since these occur somewhat frequently on the web, we need to be able to parse them. This patch also adds a child rejection mechanism to the DOM tree. Nodes can now override is_child_allowed(Node) and return false if they don't want a particular Node to become a child of theirs. This is used to prevent Document from taking on unwanted children. --- Base/home/anon/www/welcome.html | 2 ++ Libraries/LibHTML/DOM/CharacterData.cpp | 11 ++++++ Libraries/LibHTML/DOM/CharacterData.h | 25 ++++++++++++++ Libraries/LibHTML/DOM/Comment.cpp | 11 ++++++ Libraries/LibHTML/DOM/Comment.h | 18 ++++++++++ Libraries/LibHTML/DOM/Document.cpp | 17 ++++++++++ Libraries/LibHTML/DOM/Document.h | 2 ++ Libraries/LibHTML/DOM/DocumentType.h | 2 +- Libraries/LibHTML/DOM/Node.h | 5 +++ Libraries/LibHTML/DOM/Text.cpp | 3 +- Libraries/LibHTML/DOM/Text.h | 10 ++---- Libraries/LibHTML/Dump.cpp | 3 ++ Libraries/LibHTML/Makefile.shared | 2 ++ Libraries/LibHTML/Parser/HTMLParser.cpp | 59 ++++++++++++++++++++++++++------- Libraries/LibHTML/TreeNode.h | 13 ++++++-- 15 files changed, 158 insertions(+), 25 deletions(-) create mode 100644 Libraries/LibHTML/DOM/CharacterData.cpp create mode 100644 Libraries/LibHTML/DOM/CharacterData.h create mode 100644 Libraries/LibHTML/DOM/Comment.cpp create mode 100644 Libraries/LibHTML/DOM/Comment.h diff --git a/Base/home/anon/www/welcome.html b/Base/home/anon/www/welcome.html index 24602f109e..5f6739bd16 100644 --- a/Base/home/anon/www/welcome.html +++ b/Base/home/anon/www/welcome.html @@ -1,6 +1,8 @@ + Welcome! +