1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibWeb: Rename WebContentView => OutOfProcessWebView

This commit is contained in:
Andreas Kling 2020-08-17 16:20:47 +02:00
parent 56c3748dcc
commit b6e18133ae
10 changed files with 46 additions and 46 deletions

View file

@ -57,7 +57,7 @@
#include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Frame.h> #include <LibWeb/Page/Frame.h>
#include <LibWeb/InProcessWebView.h> #include <LibWeb/InProcessWebView.h>
#include <LibWeb/WebContentView.h> #include <LibWeb/OutOfProcessWebView.h>
namespace Browser { namespace Browser {
@ -85,7 +85,7 @@ Tab::Tab(Type type)
if (m_type == Type::InProcessWebView) if (m_type == Type::InProcessWebView)
m_page_view = widget.add<Web::InProcessWebView>(); m_page_view = widget.add<Web::InProcessWebView>();
else else
m_web_content_view = widget.add<WebContentView>(); m_web_content_view = widget.add<OutOfProcessWebView>();
m_go_back_action = GUI::CommonActions::make_go_back_action([this](auto&) { go_back(); }, this); 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); m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { go_forward(); }, this);

View file

@ -32,7 +32,7 @@
#include <LibHTTP/HttpJob.h> #include <LibHTTP/HttpJob.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
class WebContentView; class OutOfProcessWebView;
namespace Web { namespace Web {
class WebViewHooks; class WebViewHooks;
@ -88,7 +88,7 @@ private:
History m_history; History m_history;
RefPtr<Web::InProcessWebView> m_page_view; RefPtr<Web::InProcessWebView> m_page_view;
RefPtr<WebContentView> m_web_content_view; RefPtr<OutOfProcessWebView> m_web_content_view;
RefPtr<GUI::Action> m_go_back_action; RefPtr<GUI::Action> m_go_back_action;
RefPtr<GUI::Action> m_go_forward_action; RefPtr<GUI::Action> m_go_forward_action;

View file

@ -30,7 +30,7 @@
#include <LibGUI/StatusBar.h> #include <LibGUI/StatusBar.h>
#include <LibGUI/Widget.h> #include <LibGUI/Widget.h>
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <LibWeb/WebContentView.h> #include <LibWeb/OutOfProcessWebView.h>
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
@ -39,7 +39,7 @@ int main(int argc, char** argv)
auto& main_widget = window->set_main_widget<GUI::Widget>(); auto& main_widget = window->set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true); main_widget.set_fill_with_background_color(true);
main_widget.set_layout<GUI::VerticalBoxLayout>(); main_widget.set_layout<GUI::VerticalBoxLayout>();
auto& view = main_widget.add<WebContentView>(); auto& view = main_widget.add<OutOfProcessWebView>();
auto& statusbar = main_widget.add<GUI::StatusBar>(); auto& statusbar = main_widget.add<GUI::StatusBar>();
window->set_title("WebView"); window->set_title("WebView");
window->resize(640, 480); window->resize(640, 480);

View file

@ -38,9 +38,9 @@ The same basic concept applies to **ProtocolServer** and **ImageDecoder** as wel
![](classes.png) ![](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. 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.

View file

@ -155,6 +155,7 @@ set(SOURCES
Loader/ImageResource.cpp Loader/ImageResource.cpp
Loader/Resource.cpp Loader/Resource.cpp
Loader/ResourceLoader.cpp Loader/ResourceLoader.cpp
OutOfProcessWebView.cpp
Page/EventHandler.cpp Page/EventHandler.cpp
Page/Frame.cpp Page/Frame.cpp
Page/Page.cpp Page/Page.cpp
@ -168,7 +169,6 @@ set(SOURCES
StylePropertiesModel.cpp StylePropertiesModel.cpp
URLEncoder.cpp URLEncoder.cpp
WebContentClient.cpp WebContentClient.cpp
WebContentView.cpp
) )
set(GENERATED_SOURCES set(GENERATED_SOURCES

View file

@ -24,7 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "WebContentView.h" #include "OutOfProcessWebView.h"
#include "WebContentClient.h" #include "WebContentClient.h"
#include <AK/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibGUI/Painter.h> #include <LibGUI/Painter.h>
@ -32,24 +32,24 @@
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <LibGfx/SystemTheme.h> #include <LibGfx/SystemTheme.h>
WebContentView::WebContentView() OutOfProcessWebView::OutOfProcessWebView()
{ {
set_should_hide_unnecessary_scrollbars(true); set_should_hide_unnecessary_scrollbars(true);
m_client = WebContentClient::construct(*this); m_client = WebContentClient::construct(*this);
client().post_message(Messages::WebContentServer::UpdateSystemTheme(Gfx::current_system_theme_buffer_id())); 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; m_url = url;
client().post_message(Messages::WebContentServer::LoadURL(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); 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()); 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); GUI::ScrollableWidget::resize_event(event);
@ -76,27 +76,27 @@ void WebContentView::resize_event(GUI::ResizeEvent& event)
request_repaint(); 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())); 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())); 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())); 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())); client().post_message(Messages::WebContentServer::MouseMove(to_content_position(event.position()), event.button(), event.buttons(), event.modifiers()));
} }
void WebContentView::notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_id) void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_id)
{ {
if (m_back_bitmap->shbuf_id() == shbuf_id) { if (m_back_bitmap->shbuf_id() == shbuf_id) {
swap(m_back_bitmap, m_front_bitmap); swap(m_back_bitmap, m_front_bitmap);
@ -104,7 +104,7 @@ void WebContentView::notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_
} }
} }
void WebContentView::notify_server_did_invalidate_content_rect(Badge<WebContentClient>, [[maybe_unused]] const Gfx::IntRect& content_rect) void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge<WebContentClient>, [[maybe_unused]] const Gfx::IntRect& content_rect)
{ {
#ifdef DEBUG_SPAM #ifdef DEBUG_SPAM
dbg() << "server did invalidate content_rect: " << content_rect << ", current shbuf_id=" << m_bitmap->shbuf_id(); 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<WebContentC
request_repaint(); request_repaint();
} }
void WebContentView::notify_server_did_change_selection(Badge<WebContentClient>) void OutOfProcessWebView::notify_server_did_change_selection(Badge<WebContentClient>)
{ {
request_repaint(); request_repaint();
} }
void WebContentView::notify_server_did_layout(Badge<WebContentClient>, const Gfx::IntSize& content_size) void OutOfProcessWebView::notify_server_did_layout(Badge<WebContentClient>, const Gfx::IntSize& content_size)
{ {
set_content_size(content_size); set_content_size(content_size);
} }
void WebContentView::notify_server_did_change_title(Badge<WebContentClient>, const String& title) void OutOfProcessWebView::notify_server_did_change_title(Badge<WebContentClient>, const String& title)
{ {
if (on_title_change) if (on_title_change)
on_title_change(title); on_title_change(title);
} }
void WebContentView::notify_server_did_request_scroll_into_view(Badge<WebContentClient>, const Gfx::IntRect& rect) void OutOfProcessWebView::notify_server_did_request_scroll_into_view(Badge<WebContentClient>, const Gfx::IntRect& rect)
{ {
scroll_into_view(rect, true, true); scroll_into_view(rect, true, true);
} }
void WebContentView::notify_server_did_hover_link(Badge<WebContentClient>, const URL& url) void OutOfProcessWebView::notify_server_did_hover_link(Badge<WebContentClient>, const URL& url)
{ {
if (window()) if (window())
window()->set_override_cursor(GUI::StandardCursor::Hand); window()->set_override_cursor(GUI::StandardCursor::Hand);
@ -141,7 +141,7 @@ void WebContentView::notify_server_did_hover_link(Badge<WebContentClient>, const
on_link_hover(url); on_link_hover(url);
} }
void WebContentView::notify_server_did_unhover_link(Badge<WebContentClient>) void OutOfProcessWebView::notify_server_did_unhover_link(Badge<WebContentClient>)
{ {
if (window()) if (window())
window()->set_override_cursor(GUI::StandardCursor::None); window()->set_override_cursor(GUI::StandardCursor::None);
@ -149,48 +149,48 @@ void WebContentView::notify_server_did_unhover_link(Badge<WebContentClient>)
on_link_hover({}); on_link_hover({});
} }
void WebContentView::notify_server_did_click_link(Badge<WebContentClient>, const URL& url, const String& target, unsigned int modifiers) void OutOfProcessWebView::notify_server_did_click_link(Badge<WebContentClient>, const URL& url, const String& target, unsigned int modifiers)
{ {
if (on_link_click) if (on_link_click)
on_link_click(url, target, modifiers); on_link_click(url, target, modifiers);
} }
void WebContentView::notify_server_did_middle_click_link(Badge<WebContentClient>, const URL& url, const String& target, unsigned int modifiers) void OutOfProcessWebView::notify_server_did_middle_click_link(Badge<WebContentClient>, const URL& url, const String& target, unsigned int modifiers)
{ {
if (on_link_middle_click) if (on_link_middle_click)
on_link_middle_click(url, target, modifiers); on_link_middle_click(url, target, modifiers);
} }
void WebContentView::notify_server_did_start_loading(Badge<WebContentClient>, const URL& url) void OutOfProcessWebView::notify_server_did_start_loading(Badge<WebContentClient>, const URL& url)
{ {
if (on_load_start) if (on_load_start)
on_load_start(url); on_load_start(url);
} }
void WebContentView::notify_server_did_request_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position) void OutOfProcessWebView::notify_server_did_request_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position)
{ {
if (on_context_menu_request) if (on_context_menu_request)
on_context_menu_request(screen_relative_rect().location().translated(to_widget_position(content_position))); on_context_menu_request(screen_relative_rect().location().translated(to_widget_position(content_position)));
} }
void WebContentView::notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position, const URL& url, const String&, unsigned) void OutOfProcessWebView::notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position, const URL& url, const String&, unsigned)
{ {
if (on_link_context_menu_request) if (on_link_context_menu_request)
on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position))); 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())); client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
request_repaint(); 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())); 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; return *m_client;
} }

View file

@ -33,13 +33,13 @@
class WebContentClient; class WebContentClient;
class WebContentView final class OutOfProcessWebView final
: public GUI::ScrollableWidget : public GUI::ScrollableWidget
, public Web::WebViewHooks { , public Web::WebViewHooks {
C_OBJECT(WebContentView); C_OBJECT(OutOfProcessWebView);
public: public:
virtual ~WebContentView() override; virtual ~OutOfProcessWebView() override;
URL url() const { return m_url; } URL url() const { return m_url; }
void load(const URL&); void load(const URL&);
@ -59,7 +59,7 @@ public:
void notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers); void notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers);
private: private:
WebContentView(); OutOfProcessWebView();
// ^Widget // ^Widget
virtual bool accepts_focus() const override { return true; } virtual bool accepts_focus() const override { return true; }

View file

@ -25,10 +25,10 @@
*/ */
#include "WebContentClient.h" #include "WebContentClient.h"
#include "WebContentView.h" #include "OutOfProcessWebView.h"
#include <AK/SharedBuffer.h> #include <AK/SharedBuffer.h>
WebContentClient::WebContentClient(WebContentView& view) WebContentClient::WebContentClient(OutOfProcessWebView& view)
: IPC::ServerConnection<WebContentClientEndpoint, WebContentServerEndpoint>(*this, "/tmp/portal/webcontent") : IPC::ServerConnection<WebContentClientEndpoint, WebContentServerEndpoint>(*this, "/tmp/portal/webcontent")
, m_view(view) , m_view(view)
{ {

View file

@ -31,7 +31,7 @@
#include <WebContent/WebContentClientEndpoint.h> #include <WebContent/WebContentClientEndpoint.h>
#include <WebContent/WebContentServerEndpoint.h> #include <WebContent/WebContentServerEndpoint.h>
class WebContentView; class OutOfProcessWebView;
class WebContentClient class WebContentClient
: public IPC::ServerConnection<WebContentClientEndpoint, WebContentServerEndpoint> : public IPC::ServerConnection<WebContentClientEndpoint, WebContentServerEndpoint>
@ -42,7 +42,7 @@ public:
virtual void handshake() override; virtual void handshake() override;
private: private:
WebContentClient(WebContentView&); WebContentClient(OutOfProcessWebView&);
virtual void handle(const Messages::WebContentClient::DidPaint&) override; virtual void handle(const Messages::WebContentClient::DidPaint&) override;
virtual void handle(const Messages::WebContentClient::DidFinishLoad&) 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::DidRequestContextMenu&) override;
virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override; virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override;
WebContentView& m_view; OutOfProcessWebView& m_view;
}; };

View file

@ -4,9 +4,9 @@ Multi-process model:
Server Client 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::ClientConnection <---> WebContentClient
WebContent::PageHost (Web::PageClient) WebContent::PageHost (Web::PageClient)
Web::Page Web::Page