summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-10-08 21:03:16 +0100
committerAndreas Kling <kling@serenityos.org>2020-10-08 23:20:52 +0200
commita2a603d38a03cfd1e950b27376848c365a9a3f9c (patch)
tree17ed38023912334ea3835b009684089a428d828b
parente49ea1b5209f3b76c9caae317554a6a4a6188d5f (diff)
downloadserenity-a2a603d38a03cfd1e950b27376848c365a9a3f9c.zip
LibWeb: Add FrameLoader::load_html()
This moves responsibility for parsing and loading the document from InProcessWebView to FrameLoader, so can be re-used easily.
-rw-r--r--Libraries/LibWeb/InProcessWebView.cpp4
-rw-r--r--Libraries/LibWeb/Loader/FrameLoader.cpp8
-rw-r--r--Libraries/LibWeb/Loader/FrameLoader.h2
3 files changed, 11 insertions, 3 deletions
diff --git a/Libraries/LibWeb/InProcessWebView.cpp b/Libraries/LibWeb/InProcessWebView.cpp
index e13c902474..983e3bb024 100644
--- a/Libraries/LibWeb/InProcessWebView.cpp
+++ b/Libraries/LibWeb/InProcessWebView.cpp
@@ -364,9 +364,7 @@ void InProcessWebView::reload()
void InProcessWebView::load_html(const StringView& html, const URL& url)
{
- HTML::HTMLDocumentParser parser(html, "utf-8");
- parser.run(url);
- set_document(&parser.document());
+ page().main_frame().loader().load_html(html, url);
}
bool InProcessWebView::load(const URL& url)
diff --git a/Libraries/LibWeb/Loader/FrameLoader.cpp b/Libraries/LibWeb/Loader/FrameLoader.cpp
index fb8cc27920..79e3eb2baa 100644
--- a/Libraries/LibWeb/Loader/FrameLoader.cpp
+++ b/Libraries/LibWeb/Loader/FrameLoader.cpp
@@ -202,6 +202,14 @@ bool FrameLoader::load(const URL& url, Type type)
return load(request, type);
}
+void FrameLoader::load_html(const StringView& html, const URL& url)
+{
+ HTML::HTMLDocumentParser parser(html, "utf-8");
+ parser.run(url);
+ frame().set_document(&parser.document());
+ frame().page().client().page_did_change_title(document->title());
+}
+
void FrameLoader::load_error_page(const URL& failed_url, const String& error)
{
auto error_page_url = "file:///res/html/error.html";
diff --git a/Libraries/LibWeb/Loader/FrameLoader.h b/Libraries/LibWeb/Loader/FrameLoader.h
index 4e22ee11e1..3c4e77f459 100644
--- a/Libraries/LibWeb/Loader/FrameLoader.h
+++ b/Libraries/LibWeb/Loader/FrameLoader.h
@@ -47,6 +47,8 @@ public:
bool load(const URL&, Type);
bool load(const LoadRequest&, Type);
+ void load_html(const StringView&, const URL&);
+
Frame& frame() { return m_frame; }
const Frame& frame() const { return m_frame; }