diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-08 21:31:53 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-08 21:31:53 +0200 |
commit | e04d68a03a32319904aff947dcff717ff5115e7d (patch) | |
tree | ca26e8b6f056e57a461d2b1a0b08558ae23b32d6 /Libraries | |
parent | 5042e560efa672cf89331ccf0cd1fd2817ea8bdb (diff) | |
download | serenity-e04d68a03a32319904aff947dcff717ff5115e7d.zip |
LibWeb: Remove unnecessary on_foo hooks from Frame
Frame can just call through the PageClient instead of using hooks.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibWeb/Frame/Frame.cpp | 3 | ||||
-rw-r--r-- | Libraries/LibWeb/Frame/Frame.h | 3 | ||||
-rw-r--r-- | Libraries/LibWeb/Loader/FrameLoader.cpp | 11 | ||||
-rw-r--r-- | Libraries/LibWeb/Page.cpp | 10 |
4 files changed, 5 insertions, 22 deletions
diff --git a/Libraries/LibWeb/Frame/Frame.cpp b/Libraries/LibWeb/Frame/Frame.cpp index 0393e667dc..64efa4a533 100644 --- a/Libraries/LibWeb/Frame/Frame.cpp +++ b/Libraries/LibWeb/Frame/Frame.cpp @@ -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) diff --git a/Libraries/LibWeb/Frame/Frame.h b/Libraries/LibWeb/Frame/Frame.h index e89f3063f6..3233831e48 100644 --- a/Libraries/LibWeb/Frame/Frame.h +++ b/Libraries/LibWeb/Frame/Frame.h @@ -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; } diff --git a/Libraries/LibWeb/Loader/FrameLoader.cpp b/Libraries/LibWeb/Loader/FrameLoader.cpp index e0cbcd8f66..54691e7eeb 100644 --- a/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -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() diff --git a/Libraries/LibWeb/Page.cpp b/Libraries/LibWeb/Page.cpp index 2d49245386..9a8b51ddb1 100644 --- a/Libraries/LibWeb/Page.cpp +++ b/Libraries/LibWeb/Page.cpp @@ -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() |