mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 00:35:06 +00:00
LibWeb: Add FrameLoader::load_html()
This moves responsibility for parsing and loading the document from InProcessWebView to FrameLoader, so can be re-used easily.
This commit is contained in:
parent
e49ea1b520
commit
a2a603d38a
3 changed files with 11 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue