diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-25 00:27:41 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-25 00:27:41 +0100 |
commit | 5036b888ac9d3e67a0e57153b8e009eccd248f9d (patch) | |
tree | d1e98c1a89bd9100bf71a343c833d1b5b7ebadc4 /Libraries/LibHTML | |
parent | f2d1e591b6339b106fccc9052573302b0876796f (diff) | |
download | serenity-5036b888ac9d3e67a0e57153b8e009eccd248f9d.zip |
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.
Diffstat (limited to 'Libraries/LibHTML')
-rw-r--r-- | Libraries/LibHTML/DOM/Document.h | 5 | ||||
-rw-r--r-- | Libraries/LibHTML/Parser/HTMLParser.cpp | 1 |
2 files changed, 6 insertions, 0 deletions
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<const Element*> 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<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override; @@ -106,6 +109,8 @@ private: Color m_visited_link_color { Color::Magenta }; RefPtr<CTimer> 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<Document> 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; |