From b6e18133aec38b9f0fff2770fd08b07821b2c37b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 17 Aug 2020 16:20:47 +0200 Subject: [PATCH] LibWeb: Rename WebContentView => OutOfProcessWebView --- Applications/Browser/Tab.cpp | 4 +- Applications/Browser/Tab.h | 4 +- Demos/WebView/main.cpp | 4 +- Documentation/Browser/ProcessArchitecture.md | 4 +- Libraries/LibWeb/CMakeLists.txt | 2 +- ...ontentView.cpp => OutOfProcessWebView.cpp} | 52 +++++++++---------- ...WebContentView.h => OutOfProcessWebView.h} | 8 +-- Libraries/LibWeb/WebContentClient.cpp | 4 +- Libraries/LibWeb/WebContentClient.h | 6 +-- Services/WebContent/Documentation.txt | 4 +- 10 files changed, 46 insertions(+), 46 deletions(-) rename Libraries/LibWeb/{WebContentView.cpp => OutOfProcessWebView.cpp} (69%) rename Libraries/LibWeb/{WebContentView.h => OutOfProcessWebView.h} (96%) diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index f313e58d5ba..7c3f9c7c75d 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -57,7 +57,7 @@ #include #include #include -#include +#include namespace Browser { @@ -85,7 +85,7 @@ Tab::Tab(Type type) if (m_type == Type::InProcessWebView) m_page_view = widget.add(); else - m_web_content_view = widget.add(); + m_web_content_view = widget.add(); m_go_back_action = GUI::CommonActions::make_go_back_action([this](auto&) { go_back(); }, this); m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { go_forward(); }, this); diff --git a/Applications/Browser/Tab.h b/Applications/Browser/Tab.h index b689a7756db..2db9cfcf6c7 100644 --- a/Applications/Browser/Tab.h +++ b/Applications/Browser/Tab.h @@ -32,7 +32,7 @@ #include #include -class WebContentView; +class OutOfProcessWebView; namespace Web { class WebViewHooks; @@ -88,7 +88,7 @@ private: History m_history; RefPtr m_page_view; - RefPtr m_web_content_view; + RefPtr m_web_content_view; RefPtr m_go_back_action; RefPtr m_go_forward_action; diff --git a/Demos/WebView/main.cpp b/Demos/WebView/main.cpp index d33e8a272ae..e50b7b7db0d 100644 --- a/Demos/WebView/main.cpp +++ b/Demos/WebView/main.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include int main(int argc, char** argv) { @@ -39,7 +39,7 @@ int main(int argc, char** argv) auto& main_widget = window->set_main_widget(); main_widget.set_fill_with_background_color(true); main_widget.set_layout(); - auto& view = main_widget.add(); + auto& view = main_widget.add(); auto& statusbar = main_widget.add(); window->set_title("WebView"); window->resize(640, 480); diff --git a/Documentation/Browser/ProcessArchitecture.md b/Documentation/Browser/ProcessArchitecture.md index 4d630752c1b..9437840c1eb 100644 --- a/Documentation/Browser/ProcessArchitecture.md +++ b/Documentation/Browser/ProcessArchitecture.md @@ -38,9 +38,9 @@ The same basic concept applies to **ProtocolServer** and **ImageDecoder** as wel ![](classes.png) -In the GUI application process, a `WebContentView` widget is placed somewhere in a window, and it takes care of spawning all of the helper processes, etc. +In the GUI application process, a `OutOfProcessWebView` widget is placed somewhere in a window, and it takes care of spawning all of the helper processes, etc. -Internally, the `WebContentView` has a `WebContentClient` object that implements the client side of the **WebContent** IPC protocol. +Internally, the `OutOfProcessWebView` has a `WebContentClient` object that implements the client side of the **WebContent** IPC protocol. The `WebContentClient` speaks to a `WebContent::ClientConnection` in the **WebContent** process. Internally, the `WebContent::ClientConnection` has a `WebContent::PageHost` which hosts the **LibWeb** engine's main `Web::Page` object. diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index b1e8baf9d03..22ab8b6af92 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -155,6 +155,7 @@ set(SOURCES Loader/ImageResource.cpp Loader/Resource.cpp Loader/ResourceLoader.cpp + OutOfProcessWebView.cpp Page/EventHandler.cpp Page/Frame.cpp Page/Page.cpp @@ -168,7 +169,6 @@ set(SOURCES StylePropertiesModel.cpp URLEncoder.cpp WebContentClient.cpp - WebContentView.cpp ) set(GENERATED_SOURCES diff --git a/Libraries/LibWeb/WebContentView.cpp b/Libraries/LibWeb/OutOfProcessWebView.cpp similarity index 69% rename from Libraries/LibWeb/WebContentView.cpp rename to Libraries/LibWeb/OutOfProcessWebView.cpp index e2552f35d9f..53edfd5fec4 100644 --- a/Libraries/LibWeb/WebContentView.cpp +++ b/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "WebContentView.h" +#include "OutOfProcessWebView.h" #include "WebContentClient.h" #include #include @@ -32,24 +32,24 @@ #include #include -WebContentView::WebContentView() +OutOfProcessWebView::OutOfProcessWebView() { set_should_hide_unnecessary_scrollbars(true); m_client = WebContentClient::construct(*this); client().post_message(Messages::WebContentServer::UpdateSystemTheme(Gfx::current_system_theme_buffer_id())); } -WebContentView::~WebContentView() +OutOfProcessWebView::~OutOfProcessWebView() { } -void WebContentView::load(const URL& url) +void OutOfProcessWebView::load(const URL& url) { m_url = url; client().post_message(Messages::WebContentServer::LoadURL(url)); } -void WebContentView::paint_event(GUI::PaintEvent& event) +void OutOfProcessWebView::paint_event(GUI::PaintEvent& event) { GUI::ScrollableWidget::paint_event(event); @@ -62,7 +62,7 @@ void WebContentView::paint_event(GUI::PaintEvent& event) painter.blit({ 0, 0 }, *m_front_bitmap, m_front_bitmap->rect()); } -void WebContentView::resize_event(GUI::ResizeEvent& event) +void OutOfProcessWebView::resize_event(GUI::ResizeEvent& event) { GUI::ScrollableWidget::resize_event(event); @@ -76,27 +76,27 @@ void WebContentView::resize_event(GUI::ResizeEvent& event) request_repaint(); } -void WebContentView::keydown_event(GUI::KeyEvent& event) +void OutOfProcessWebView::keydown_event(GUI::KeyEvent& event) { client().post_message(Messages::WebContentServer::KeyDown(event.key(), event.modifiers(), event.code_point())); } -void WebContentView::mousedown_event(GUI::MouseEvent& event) +void OutOfProcessWebView::mousedown_event(GUI::MouseEvent& event) { client().post_message(Messages::WebContentServer::MouseDown(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers())); } -void WebContentView::mouseup_event(GUI::MouseEvent& event) +void OutOfProcessWebView::mouseup_event(GUI::MouseEvent& event) { client().post_message(Messages::WebContentServer::MouseUp(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers())); } -void WebContentView::mousemove_event(GUI::MouseEvent& event) +void OutOfProcessWebView::mousemove_event(GUI::MouseEvent& event) { client().post_message(Messages::WebContentServer::MouseMove(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers())); } -void WebContentView::notify_server_did_paint(Badge, i32 shbuf_id) +void OutOfProcessWebView::notify_server_did_paint(Badge, i32 shbuf_id) { if (m_back_bitmap->shbuf_id() == shbuf_id) { swap(m_back_bitmap, m_front_bitmap); @@ -104,7 +104,7 @@ void WebContentView::notify_server_did_paint(Badge, i32 shbuf_ } } -void WebContentView::notify_server_did_invalidate_content_rect(Badge, [[maybe_unused]] const Gfx::IntRect& content_rect) +void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge, [[maybe_unused]] const Gfx::IntRect& content_rect) { #ifdef DEBUG_SPAM dbg() << "server did invalidate content_rect: " << content_rect << ", current shbuf_id=" << m_bitmap->shbuf_id(); @@ -112,28 +112,28 @@ void WebContentView::notify_server_did_invalidate_content_rect(Badge) +void OutOfProcessWebView::notify_server_did_change_selection(Badge) { request_repaint(); } -void WebContentView::notify_server_did_layout(Badge, const Gfx::IntSize& content_size) +void OutOfProcessWebView::notify_server_did_layout(Badge, const Gfx::IntSize& content_size) { set_content_size(content_size); } -void WebContentView::notify_server_did_change_title(Badge, const String& title) +void OutOfProcessWebView::notify_server_did_change_title(Badge, const String& title) { if (on_title_change) on_title_change(title); } -void WebContentView::notify_server_did_request_scroll_into_view(Badge, const Gfx::IntRect& rect) +void OutOfProcessWebView::notify_server_did_request_scroll_into_view(Badge, const Gfx::IntRect& rect) { scroll_into_view(rect, true, true); } -void WebContentView::notify_server_did_hover_link(Badge, const URL& url) +void OutOfProcessWebView::notify_server_did_hover_link(Badge, const URL& url) { if (window()) window()->set_override_cursor(GUI::StandardCursor::Hand); @@ -141,7 +141,7 @@ void WebContentView::notify_server_did_hover_link(Badge, const on_link_hover(url); } -void WebContentView::notify_server_did_unhover_link(Badge) +void OutOfProcessWebView::notify_server_did_unhover_link(Badge) { if (window()) window()->set_override_cursor(GUI::StandardCursor::None); @@ -149,48 +149,48 @@ void WebContentView::notify_server_did_unhover_link(Badge) on_link_hover({}); } -void WebContentView::notify_server_did_click_link(Badge, const URL& url, const String& target, unsigned int modifiers) +void OutOfProcessWebView::notify_server_did_click_link(Badge, const URL& url, const String& target, unsigned int modifiers) { if (on_link_click) on_link_click(url, target, modifiers); } -void WebContentView::notify_server_did_middle_click_link(Badge, const URL& url, const String& target, unsigned int modifiers) +void OutOfProcessWebView::notify_server_did_middle_click_link(Badge, const URL& url, const String& target, unsigned int modifiers) { if (on_link_middle_click) on_link_middle_click(url, target, modifiers); } -void WebContentView::notify_server_did_start_loading(Badge, const URL& url) +void OutOfProcessWebView::notify_server_did_start_loading(Badge, const URL& url) { if (on_load_start) on_load_start(url); } -void WebContentView::notify_server_did_request_context_menu(Badge, const Gfx::IntPoint& content_position) +void OutOfProcessWebView::notify_server_did_request_context_menu(Badge, const Gfx::IntPoint& content_position) { if (on_context_menu_request) on_context_menu_request(screen_relative_rect().location().translated(to_widget_position(content_position))); } -void WebContentView::notify_server_did_request_link_context_menu(Badge, const Gfx::IntPoint& content_position, const URL& url, const String&, unsigned) +void OutOfProcessWebView::notify_server_did_request_link_context_menu(Badge, const Gfx::IntPoint& content_position, const URL& url, const String&, unsigned) { if (on_link_context_menu_request) on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position))); } -void WebContentView::did_scroll() +void OutOfProcessWebView::did_scroll() { client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect())); request_repaint(); } -void WebContentView::request_repaint() +void OutOfProcessWebView::request_repaint() { client().post_message(Messages::WebContentServer::Paint(m_back_bitmap->rect().translated(horizontal_scrollbar().value(), vertical_scrollbar().value()), m_back_bitmap->shbuf_id())); } -WebContentClient& WebContentView::client() +WebContentClient& OutOfProcessWebView::client() { return *m_client; } diff --git a/Libraries/LibWeb/WebContentView.h b/Libraries/LibWeb/OutOfProcessWebView.h similarity index 96% rename from Libraries/LibWeb/WebContentView.h rename to Libraries/LibWeb/OutOfProcessWebView.h index c77e3aabcd4..506f46cdaac 100644 --- a/Libraries/LibWeb/WebContentView.h +++ b/Libraries/LibWeb/OutOfProcessWebView.h @@ -33,13 +33,13 @@ class WebContentClient; -class WebContentView final +class OutOfProcessWebView final : public GUI::ScrollableWidget , public Web::WebViewHooks { - C_OBJECT(WebContentView); + C_OBJECT(OutOfProcessWebView); public: - virtual ~WebContentView() override; + virtual ~OutOfProcessWebView() override; URL url() const { return m_url; } void load(const URL&); @@ -59,7 +59,7 @@ public: void notify_server_did_request_link_context_menu(Badge, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers); private: - WebContentView(); + OutOfProcessWebView(); // ^Widget virtual bool accepts_focus() const override { return true; } diff --git a/Libraries/LibWeb/WebContentClient.cpp b/Libraries/LibWeb/WebContentClient.cpp index 8482dabd96b..9605070a510 100644 --- a/Libraries/LibWeb/WebContentClient.cpp +++ b/Libraries/LibWeb/WebContentClient.cpp @@ -25,10 +25,10 @@ */ #include "WebContentClient.h" -#include "WebContentView.h" +#include "OutOfProcessWebView.h" #include -WebContentClient::WebContentClient(WebContentView& view) +WebContentClient::WebContentClient(OutOfProcessWebView& view) : IPC::ServerConnection(*this, "/tmp/portal/webcontent") , m_view(view) { diff --git a/Libraries/LibWeb/WebContentClient.h b/Libraries/LibWeb/WebContentClient.h index 8852e14ca5b..d4fd342b01c 100644 --- a/Libraries/LibWeb/WebContentClient.h +++ b/Libraries/LibWeb/WebContentClient.h @@ -31,7 +31,7 @@ #include #include -class WebContentView; +class OutOfProcessWebView; class WebContentClient : public IPC::ServerConnection @@ -42,7 +42,7 @@ public: virtual void handshake() override; private: - WebContentClient(WebContentView&); + WebContentClient(OutOfProcessWebView&); virtual void handle(const Messages::WebContentClient::DidPaint&) override; virtual void handle(const Messages::WebContentClient::DidFinishLoad&) override; @@ -59,5 +59,5 @@ private: virtual void handle(const Messages::WebContentClient::DidRequestContextMenu&) override; virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override; - WebContentView& m_view; + OutOfProcessWebView& m_view; }; diff --git a/Services/WebContent/Documentation.txt b/Services/WebContent/Documentation.txt index 9f218480010..e82190106a4 100644 --- a/Services/WebContent/Documentation.txt +++ b/Services/WebContent/Documentation.txt @@ -4,9 +4,9 @@ Multi-process model: Server Client -WebContent GUI process (WebContentView embedder) +WebContent GUI process (OutOfProcessWebView embedder) - WebContentView (this is a GUI::Widget) + OutOfProcessWebView (this is a GUI::Widget) WebContent::ClientConnection <---> WebContentClient WebContent::PageHost (Web::PageClient) Web::Page