2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
2020-05-28 20:40:53 +02:00
|
|
|
|
2019-09-25 12:44:22 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-10-05 10:16:27 +02:00
|
|
|
#include <AK/URL.h>
|
2021-05-03 20:31:58 +02:00
|
|
|
#include <LibGUI/AbstractScrollableWidget.h>
|
2021-04-04 00:12:37 +02:00
|
|
|
#include <LibGUI/Desktop.h>
|
2020-03-07 10:32:51 +01:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
2020-07-28 19:27:41 +02:00
|
|
|
#include <LibWeb/Page/Page.h>
|
2020-07-06 21:18:16 +02:00
|
|
|
#include <LibWeb/WebViewHooks.h>
|
2019-09-25 12:44:22 +03:00
|
|
|
|
2020-03-07 10:27:02 +01:00
|
|
|
namespace Web {
|
|
|
|
|
|
2020-08-17 15:58:29 +02:00
|
|
|
class InProcessWebView final
|
2021-05-03 20:31:58 +02:00
|
|
|
: public GUI::AbstractScrollableWidget
|
2020-07-06 21:18:16 +02:00
|
|
|
, public WebViewHooks
|
2020-06-08 20:31:49 +02:00
|
|
|
, public PageClient {
|
2020-08-17 15:58:29 +02:00
|
|
|
C_OBJECT(InProcessWebView);
|
2020-06-07 14:40:38 +02:00
|
|
|
|
2019-09-25 12:44:22 +03:00
|
|
|
public:
|
2020-08-17 15:58:29 +02:00
|
|
|
virtual ~InProcessWebView() override;
|
2019-09-25 12:44:22 +03:00
|
|
|
|
2020-06-21 21:37:07 +02:00
|
|
|
void load_html(const StringView&, const URL&);
|
2020-06-06 13:02:44 +02:00
|
|
|
void load_empty_document();
|
2020-05-27 21:57:30 +02:00
|
|
|
|
2020-07-26 19:37:56 +02:00
|
|
|
DOM::Document* document();
|
|
|
|
|
const DOM::Document* document() const;
|
2020-06-06 13:02:44 +02:00
|
|
|
|
2020-07-26 19:37:56 +02:00
|
|
|
void set_document(DOM::Document*);
|
2019-09-25 12:44:22 +03:00
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
const Layout::InitialContainingBlockBox* layout_root() const;
|
|
|
|
|
Layout::InitialContainingBlockBox* layout_root();
|
2019-10-13 12:34:25 +02:00
|
|
|
|
2019-10-05 10:16:27 +02:00
|
|
|
void reload();
|
2020-06-06 13:02:44 +02:00
|
|
|
bool load(const URL&);
|
2019-10-05 10:16:27 +02:00
|
|
|
|
|
|
|
|
URL url() const;
|
|
|
|
|
|
2019-10-12 15:02:53 +02:00
|
|
|
void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
|
|
|
|
|
|
2020-07-03 20:35:19 +02:00
|
|
|
String selected_text() const;
|
2020-07-03 20:54:53 +02:00
|
|
|
void select_all();
|
2020-07-03 20:35:19 +02:00
|
|
|
|
2020-06-08 20:31:49 +02:00
|
|
|
private:
|
2020-08-17 15:58:29 +02:00
|
|
|
InProcessWebView();
|
2019-09-25 12:44:22 +03:00
|
|
|
|
2020-06-08 20:31:49 +02:00
|
|
|
Page& page() { return *m_page; }
|
|
|
|
|
const Page& page() const { return *m_page; }
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual void resize_event(GUI::ResizeEvent&) override;
|
|
|
|
|
virtual void paint_event(GUI::PaintEvent&) override;
|
|
|
|
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
|
|
|
|
virtual void mousedown_event(GUI::MouseEvent&) override;
|
|
|
|
|
virtual void mouseup_event(GUI::MouseEvent&) override;
|
2021-02-22 19:45:41 +01:00
|
|
|
virtual void mousewheel_event(GUI::MouseEvent&) override;
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual void keydown_event(GUI::KeyEvent&) override;
|
2020-05-10 21:03:37 +02:00
|
|
|
virtual void drop_event(GUI::DropEvent&) override;
|
2019-09-25 12:44:22 +03:00
|
|
|
|
2019-12-18 20:54:23 +01:00
|
|
|
virtual void did_scroll() override;
|
|
|
|
|
|
2020-06-08 20:31:49 +02:00
|
|
|
// ^Web::PageClient
|
2021-01-30 23:15:40 +01:00
|
|
|
virtual bool is_multi_process() const override { return false; }
|
2021-05-03 20:31:58 +02:00
|
|
|
virtual Gfx::Palette palette() const override { return GUI::AbstractScrollableWidget::palette(); }
|
2021-04-04 00:12:37 +02:00
|
|
|
virtual Gfx::IntRect screen_rect() const override { return GUI::Desktop::the().rect(); }
|
2020-06-08 20:31:49 +02:00
|
|
|
virtual void page_did_change_title(const String&) override;
|
2021-05-30 12:36:53 +02:00
|
|
|
virtual void page_did_set_document_in_top_level_browsing_context(DOM::Document*) override;
|
2020-06-08 20:31:49 +02:00
|
|
|
virtual void page_did_start_loading(const URL&) override;
|
2020-12-08 21:44:42 +01:00
|
|
|
virtual void page_did_finish_loading(const URL&) override;
|
2020-06-08 20:31:49 +02:00
|
|
|
virtual void page_did_change_selection() override;
|
2020-09-10 19:25:13 +02:00
|
|
|
virtual void page_did_request_cursor_change(Gfx::StandardCursor) override;
|
2020-06-27 14:21:58 -06:00
|
|
|
virtual void page_did_request_context_menu(const Gfx::IntPoint&) override;
|
2020-07-06 20:00:56 +02:00
|
|
|
virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers) override;
|
2020-10-02 19:01:51 +02:00
|
|
|
virtual void page_did_request_image_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers, const Gfx::Bitmap*) override;
|
2020-07-06 19:41:10 +02:00
|
|
|
virtual void page_did_click_link(const URL&, const String& target, unsigned modifiers) override;
|
|
|
|
|
virtual void page_did_middle_click_link(const URL&, const String& target, unsigned modifiers) override;
|
2020-06-10 10:57:59 +02:00
|
|
|
virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) override;
|
2020-06-08 20:31:49 +02:00
|
|
|
virtual void page_did_leave_tooltip_area() override;
|
|
|
|
|
virtual void page_did_hover_link(const URL&) override;
|
|
|
|
|
virtual void page_did_unhover_link() override;
|
2020-06-10 10:57:59 +02:00
|
|
|
virtual void page_did_invalidate(const Gfx::IntRect&) override;
|
2020-06-08 21:35:31 +02:00
|
|
|
virtual void page_did_change_favicon(const Gfx::Bitmap&) override;
|
2020-06-23 18:02:08 +02:00
|
|
|
virtual void page_did_layout() override;
|
2020-07-05 14:50:38 +02:00
|
|
|
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override;
|
2020-09-12 11:56:13 +02:00
|
|
|
virtual void page_did_request_alert(const String&) override;
|
2021-02-10 08:37:13 +01:00
|
|
|
virtual bool page_did_request_confirm(const String&) override;
|
2021-02-20 12:05:18 +01:00
|
|
|
virtual String page_did_request_prompt(const String&, const String&) override;
|
2021-04-13 17:30:41 -04:00
|
|
|
virtual String page_did_request_cookie(const URL&, Cookie::Source) override;
|
2021-04-15 10:36:20 -04:00
|
|
|
virtual void page_did_set_cookie(const URL&, const Cookie::ParsedCookie&, Cookie::Source) override;
|
2020-05-27 21:57:30 +02:00
|
|
|
|
2019-09-25 12:44:22 +03:00
|
|
|
void layout_and_sync_size();
|
|
|
|
|
|
2019-10-12 15:02:53 +02:00
|
|
|
bool m_should_show_line_box_borders { false };
|
2020-06-08 20:31:49 +02:00
|
|
|
|
|
|
|
|
NonnullOwnPtr<Page> m_page;
|
2019-09-25 12:44:22 +03:00
|
|
|
};
|
2020-03-07 10:27:02 +01:00
|
|
|
|
|
|
|
|
}
|