From 5036b888ac9d3e67a0e57153b8e009eccd248f9d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 25 Nov 2019 00:27:41 +0100 Subject: LibHTML: Store the HTML parser input along with the created Document This will allow us to "view source" later on, long after parsing has finished and turned it into a DOM. --- Libraries/LibHTML/DOM/Document.h | 5 +++++ Libraries/LibHTML/Parser/HTMLParser.cpp | 1 + 2 files changed, 6 insertions(+) (limited to 'Libraries/LibHTML') diff --git a/Libraries/LibHTML/DOM/Document.h b/Libraries/LibHTML/DOM/Document.h index 85595e43eb..5b1487d0c1 100644 --- a/Libraries/LibHTML/DOM/Document.h +++ b/Libraries/LibHTML/DOM/Document.h @@ -89,6 +89,9 @@ public: const Element* get_element_by_id(const String&) const; Vector get_elements_by_name(const String&) const; + const String& source() const { return m_source; } + void set_source(const String& source) { m_source = source; } + private: virtual RefPtr create_layout_node(const StyleProperties* parent_style) const override; @@ -106,6 +109,8 @@ private: Color m_visited_link_color { Color::Magenta }; RefPtr m_style_update_timer; + + String m_source; }; template<> diff --git a/Libraries/LibHTML/Parser/HTMLParser.cpp b/Libraries/LibHTML/Parser/HTMLParser.cpp index ef28a97cc2..722350929f 100644 --- a/Libraries/LibHTML/Parser/HTMLParser.cpp +++ b/Libraries/LibHTML/Parser/HTMLParser.cpp @@ -334,6 +334,7 @@ RefPtr parse_html_document(const StringView& html, const URL& url) { auto document = adopt(*new Document); document->set_url(url); + document->set_source(html); if (!parse_html_document(html, *document, *document)) return nullptr; -- cgit v1.2.3