From 850955053f55a97f932976783db8e7b2f19ee5f1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 9 Oct 2019 18:54:34 +0200 Subject: [PATCH] LibHTML: Rename Document::normalize() to fixup() and always do it Node.normalize() is a standard DOM API that coalesces Text nodes. To avoid clashing with that, rename it to fixup(). This patch also makes it happen automagically as part of parsing. --- Applications/Help/main.cpp | 1 - Libraries/LibHTML/DOM/Document.cpp | 2 +- Libraries/LibHTML/DOM/Document.h | 2 +- Libraries/LibHTML/HtmlView.cpp | 1 - Libraries/LibHTML/Parser/HTMLParser.cpp | 2 ++ Userland/html.cpp | 1 - 6 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index a4ed1c2d235..e6203e8a6b7 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -81,7 +81,6 @@ int main(int argc, char* argv[]) String html = md_document.render_to_html(); auto html_document = parse_html(html); - html_document->normalize(); html_view->set_document(html_document); String page_and_section = model->page_and_section(tree_view->selection().first()); diff --git a/Libraries/LibHTML/DOM/Document.cpp b/Libraries/LibHTML/DOM/Document.cpp index 5d6d45a9d88..5181d2da9be 100644 --- a/Libraries/LibHTML/DOM/Document.cpp +++ b/Libraries/LibHTML/DOM/Document.cpp @@ -27,7 +27,7 @@ StyleResolver& Document::style_resolver() return *m_style_resolver; } -void Document::normalize() +void Document::fixup() { if (is(first_child())) return; diff --git a/Libraries/LibHTML/DOM/Document.h b/Libraries/LibHTML/DOM/Document.h index bfef5ec43b2..485ed87cec9 100644 --- a/Libraries/LibHTML/DOM/Document.h +++ b/Libraries/LibHTML/DOM/Document.h @@ -28,7 +28,7 @@ public: URL complete_url(const String&) const; - void normalize(); + void fixup(); StyleResolver& style_resolver(); diff --git a/Libraries/LibHTML/HtmlView.cpp b/Libraries/LibHTML/HtmlView.cpp index ec471c18f17..b909fbb2bd0 100644 --- a/Libraries/LibHTML/HtmlView.cpp +++ b/Libraries/LibHTML/HtmlView.cpp @@ -182,7 +182,6 @@ void HtmlView::load(const URL& url) } auto document = parse_html(data, url); - document->normalize(); set_document(document); diff --git a/Libraries/LibHTML/Parser/HTMLParser.cpp b/Libraries/LibHTML/Parser/HTMLParser.cpp index d9fcde815ea..981f1827020 100644 --- a/Libraries/LibHTML/Parser/HTMLParser.cpp +++ b/Libraries/LibHTML/Parser/HTMLParser.cpp @@ -309,5 +309,7 @@ NonnullRefPtr parse_html(const StringView& html, const URL& url) fire_insertion_callbacks(*document); + document->fixup(); + return document; } diff --git a/Userland/html.cpp b/Userland/html.cpp index b2bf2ae691a..91cfdf6b1e2 100644 --- a/Userland/html.cpp +++ b/Userland/html.cpp @@ -35,7 +35,6 @@ int main(int argc, char** argv) String html = String::copy(f->read_all()); auto document = parse_html(html); - document->normalize(); auto window = GWindow::construct(); auto widget = HtmlView::construct();