mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Remove unnecessary on_foo hooks from Frame
Frame can just call through the PageClient instead of using hooks.
This commit is contained in:
parent
5042e560ef
commit
e04d68a03a
Notes:
sideshowbarker
2024-07-19 05:44:42 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e04d68a03a3
4 changed files with 5 additions and 22 deletions
|
@ -66,8 +66,7 @@ void Frame::set_document(Document* document)
|
|||
if (m_document)
|
||||
m_document->attach_to_frame({}, *this);
|
||||
|
||||
if (on_set_document)
|
||||
on_set_document(m_document);
|
||||
page().client().page_did_set_document_in_main_frame(m_document);
|
||||
}
|
||||
|
||||
void Frame::set_size(const Gfx::Size& size)
|
||||
|
|
|
@ -60,10 +60,7 @@ public:
|
|||
|
||||
void set_needs_display(const Gfx::Rect&);
|
||||
|
||||
Function<void(const String&)> on_title_change;
|
||||
Function<void(const URL&)> on_load_start;
|
||||
Function<void(const Gfx::Bitmap&)> on_favicon_change;
|
||||
Function<void(Document*)> on_set_document;
|
||||
|
||||
void set_viewport_rect(const Gfx::Rect&);
|
||||
Gfx::Rect viewport_rect() const { return m_viewport_rect; }
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <LibWeb/Frame/Frame.h>
|
||||
#include <LibWeb/Loader/FrameLoader.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Page.h>
|
||||
#include <LibWeb/Parser/HTMLDocumentParser.h>
|
||||
#include <LibWeb/Parser/HTMLParser.h>
|
||||
|
||||
|
@ -151,8 +152,7 @@ bool FrameLoader::load(const URL& url)
|
|||
request.set_url(url);
|
||||
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
||||
|
||||
if (frame().on_load_start)
|
||||
frame().on_load_start(url);
|
||||
frame().page().client().page_did_start_loading(url);
|
||||
|
||||
if (url.protocol() != "file" && url.protocol() != "about") {
|
||||
URL favicon_url;
|
||||
|
@ -194,8 +194,7 @@ void FrameLoader::load_error_page(const URL& failed_url, const String& error)
|
|||
auto document = parse_html_document(html, failed_url);
|
||||
ASSERT(document);
|
||||
frame().set_document(document);
|
||||
if (frame().on_title_change)
|
||||
frame().on_title_change(document->title());
|
||||
frame().page().client().page_did_change_title(document->title());
|
||||
},
|
||||
[](auto error) {
|
||||
dbg() << "Failed to load error page: " << error;
|
||||
|
@ -228,12 +227,10 @@ void FrameLoader::resource_did_load()
|
|||
}
|
||||
|
||||
frame().set_document(document);
|
||||
frame().page().client().page_did_change_title(document->title());
|
||||
|
||||
if (!url.fragment().is_empty())
|
||||
frame().scroll_to_anchor(url.fragment());
|
||||
|
||||
if (frame().on_title_change)
|
||||
frame().on_title_change(document->title());
|
||||
}
|
||||
|
||||
void FrameLoader::resource_did_fail()
|
||||
|
|
|
@ -34,16 +34,6 @@ Page::Page(PageClient& client)
|
|||
: m_client(client)
|
||||
{
|
||||
m_main_frame = Frame::create(*this);
|
||||
|
||||
main_frame().on_set_document = [this](auto* document) {
|
||||
m_client.page_did_set_document_in_main_frame(document);
|
||||
};
|
||||
main_frame().on_title_change = [this](auto& title) {
|
||||
m_client.page_did_change_title(title);
|
||||
};
|
||||
main_frame().on_load_start = [this](auto& url) {
|
||||
m_client.page_did_start_loading(url);
|
||||
};
|
||||
}
|
||||
|
||||
Page::~Page()
|
||||
|
|
Loading…
Add table
Reference in a new issue