Skip to content

Commit

Permalink
LibWeb: Rename WebContentView => OutOfProcessWebView
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Aug 17, 2020
1 parent 56c3748 commit b6e1813
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions Applications/Browser/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Frame.h>
#include <LibWeb/InProcessWebView.h>
#include <LibWeb/WebContentView.h>
#include <LibWeb/OutOfProcessWebView.h>

namespace Browser {

Expand Down Expand Up @@ -85,7 +85,7 @@ Tab::Tab(Type type)
if (m_type == Type::InProcessWebView)
m_page_view = widget.add<Web::InProcessWebView>();
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_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { go_forward(); }, this);
Expand Down
4 changes: 2 additions & 2 deletions Applications/Browser/Tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <LibHTTP/HttpJob.h>
#include <LibWeb/Forward.h>

class WebContentView;
class OutOfProcessWebView;

namespace Web {
class WebViewHooks;
Expand Down Expand Up @@ -88,7 +88,7 @@ class Tab final : public GUI::Widget {
History m_history;

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_forward_action;
Expand Down
4 changes: 2 additions & 2 deletions Demos/WebView/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <LibGUI/StatusBar.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibWeb/WebContentView.h>
#include <LibWeb/OutOfProcessWebView.h>

int main(int argc, char** argv)
{
Expand All @@ -39,7 +39,7 @@ int main(int argc, char** argv)
auto& main_widget = window->set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true);
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>();
window->set_title("WebView");
window->resize(640, 480);
Expand Down
4 changes: 2 additions & 2 deletions Documentation/Browser/ProcessArchitecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibWeb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -168,7 +169,6 @@ set(SOURCES
StylePropertiesModel.cpp
URLEncoder.cpp
WebContentClient.cpp
WebContentView.cpp
)

set(GENERATED_SOURCES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "WebContentView.h"
#include "OutOfProcessWebView.h"
#include "WebContentClient.h"
#include <AK/SharedBuffer.h>
#include <LibGUI/Painter.h>
#include <LibGUI/ScrollBar.h>
#include <LibGUI/Window.h>
#include <LibGfx/SystemTheme.h>

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);

Expand All @@ -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);

Expand All @@ -76,121 +76,121 @@ 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<WebContentClient>, i32 shbuf_id)
void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_id)
{
if (m_back_bitmap->shbuf_id() == shbuf_id) {
swap(m_back_bitmap, m_front_bitmap);
update();
}
}

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
dbg() << "server did invalidate content_rect: " << content_rect << ", current shbuf_id=" << m_bitmap->shbuf_id();
#endif
request_repaint();
}

void WebContentView::notify_server_did_change_selection(Badge<WebContentClient>)
void OutOfProcessWebView::notify_server_did_change_selection(Badge<WebContentClient>)
{
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);
}

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)
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);
}

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())
window()->set_override_cursor(GUI::StandardCursor::Hand);
if (on_link_hover)
on_link_hover(url);
}

void WebContentView::notify_server_did_unhover_link(Badge<WebContentClient>)
void OutOfProcessWebView::notify_server_did_unhover_link(Badge<WebContentClient>)
{
if (window())
window()->set_override_cursor(GUI::StandardCursor::None);
if (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)
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)
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)
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)
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)
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand All @@ -59,7 +59,7 @@ class WebContentView final
void notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers);

private:
WebContentView();
OutOfProcessWebView();

// ^Widget
virtual bool accepts_focus() const override { return true; }
Expand Down
4 changes: 2 additions & 2 deletions Libraries/LibWeb/WebContentClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
*/

#include "WebContentClient.h"
#include "WebContentView.h"
#include "OutOfProcessWebView.h"
#include <AK/SharedBuffer.h>

WebContentClient::WebContentClient(WebContentView& view)
WebContentClient::WebContentClient(OutOfProcessWebView& view)
: IPC::ServerConnection<WebContentClientEndpoint, WebContentServerEndpoint>(*this, "/tmp/portal/webcontent")
, m_view(view)
{
Expand Down
6 changes: 3 additions & 3 deletions Libraries/LibWeb/WebContentClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <WebContent/WebContentClientEndpoint.h>
#include <WebContent/WebContentServerEndpoint.h>

class WebContentView;
class OutOfProcessWebView;

class WebContentClient
: public IPC::ServerConnection<WebContentClientEndpoint, WebContentServerEndpoint>
Expand All @@ -42,7 +42,7 @@ class WebContentClient
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;
Expand All @@ -59,5 +59,5 @@ class WebContentClient
virtual void handle(const Messages::WebContentClient::DidRequestContextMenu&) override;
virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override;

WebContentView& m_view;
OutOfProcessWebView& m_view;
};
4 changes: 2 additions & 2 deletions Services/WebContent/Documentation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b6e1813

Please sign in to comment.