diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-08 20:31:49 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-08 21:12:20 +0200 |
commit | 92392398a22d5dfde6099fd21d14b5cadcbfd969 (patch) | |
tree | 005719faee765a87f63227d410890a02e949fedb /Libraries/LibWeb/PageView.h | |
parent | 5072d4e02d914a6d7d09b3ebb79ead2230997a21 (diff) | |
download | serenity-92392398a22d5dfde6099fd21d14b5cadcbfd969.zip |
LibWeb: Add Page abstraction between PageView and main Frame
* A PageView is a view onto a Page object.
* A Page always has a main Frame (root of Frame tree.)
* Page has a PageClient. PageView is a PageClient.
The goal here is to allow building another kind of view onto
a Page while keeping the rest of LibWeb intact.
Diffstat (limited to 'Libraries/LibWeb/PageView.h')
-rw-r--r-- | Libraries/LibWeb/PageView.h | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/Libraries/LibWeb/PageView.h b/Libraries/LibWeb/PageView.h index f91f097044..bf646fd849 100644 --- a/Libraries/LibWeb/PageView.h +++ b/Libraries/LibWeb/PageView.h @@ -29,11 +29,13 @@ #include <AK/URL.h> #include <LibGUI/ScrollableWidget.h> #include <LibWeb/DOM/Document.h> -#include <LibWeb/Forward.h> +#include <LibWeb/Page.h> namespace Web { -class PageView : public GUI::ScrollableWidget { +class PageView final + : public GUI::ScrollableWidget + , public PageClient { C_OBJECT(PageView); public: @@ -52,9 +54,6 @@ public: const LayoutDocument* layout_root() const; LayoutDocument* layout_root(); - Web::Frame& main_frame() { return *m_main_frame; } - const Web::Frame& main_frame() const { return *m_main_frame; } - void reload(); bool load(const URL&); void scroll_to_anchor(const StringView&); @@ -75,17 +74,12 @@ public: virtual bool accepts_focus() const override { return true; } - void notify_link_click(Badge<EventHandler>, Web::Frame&, const String& href, const String& target, unsigned modifiers); - void notify_link_middle_click(Badge<EventHandler>, Web::Frame&, const String& href, const String& target, unsigned modifiers); - void notify_link_context_menu_request(Badge<EventHandler>, Web::Frame&, const Gfx::Point& content_position, const String& href, const String& target, unsigned modifiers); - void notify_link_hover(Badge<EventHandler>, Web::Frame&, const String& href); - void notify_tooltip_area_enter(Badge<EventHandler>, Web::Frame&, const Gfx::Point& content_position, const String& title); - void notify_tooltip_area_leave(Badge<EventHandler>, Web::Frame&); - void notify_needs_display(Badge<Web::Frame>, Web::Frame&, const Gfx::Rect&); - -protected: +private: PageView(); + Page& page() { return *m_page; } + const Page& page() const { return *m_page; } + virtual void resize_event(GUI::ResizeEvent&) override; virtual void paint_event(GUI::PaintEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override; @@ -94,17 +88,29 @@ protected: virtual void keydown_event(GUI::KeyEvent&) override; virtual void drop_event(GUI::DropEvent&) override; -private: virtual void did_scroll() override; - Gfx::Point to_screen_position(const Web::Frame&, const Gfx::Point&) const; - Gfx::Rect to_widget_rect(const Web::Frame&, const Gfx::Rect&) const; + // ^Web::PageClient + virtual void page_did_change_title(const String&) override; + virtual void page_did_set_document_in_main_frame(Document*) override; + virtual void page_did_start_loading(const URL&) override; + virtual void page_did_change_selection() override; + virtual void page_did_request_cursor_change(GUI::StandardCursor) override; + virtual void page_did_request_link_context_menu(const Gfx::Point&, const String& href, const String& target, unsigned modifiers) override; + virtual void page_did_click_link(const String& href, const String& target, unsigned modifiers) override; + virtual void page_did_middle_click_link(const String& href, const String& target, unsigned modifiers) override; + virtual void page_did_enter_tooltip_area(const Gfx::Point&, const String&) override; + virtual void page_did_leave_tooltip_area() override; + virtual void page_did_hover_link(const URL&) override; + virtual void page_did_unhover_link() override; + virtual void page_did_request_scroll_to_anchor(const String& fragment) override; + virtual void page_did_invalidate(const Gfx::Rect&) override; void layout_and_sync_size(); - RefPtr<Web::Frame> m_main_frame; - bool m_should_show_line_box_borders { false }; + + NonnullOwnPtr<Page> m_page; }; } |