mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
Browser+LibWebView+WebContent: Add IPC to re[store,size,position] window
Requests to restore, resize, and reposition Browser windows will be coming from the WebContent process rather than the WebDriver process. Add hooks to propagate these requests back up to the Browser. The spec notes "The specification does not guarantee that the resulting window size will exactly match that which was requested", so these new methods return the actual new size/position.
This commit is contained in:
parent
71aba39562
commit
9505928fdb
7 changed files with 75 additions and 2 deletions
|
@ -401,6 +401,26 @@ void OutOfProcessWebView::notify_server_did_update_resource_count(i32 count_wait
|
|||
on_resource_status_change(count_waiting);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_restore_window()
|
||||
{
|
||||
if (on_restore_window)
|
||||
on_restore_window();
|
||||
}
|
||||
|
||||
Gfx::IntPoint OutOfProcessWebView::notify_server_did_request_reposition_window(Gfx::IntPoint const& position)
|
||||
{
|
||||
if (on_reposition_window)
|
||||
return on_reposition_window(position);
|
||||
return {};
|
||||
}
|
||||
|
||||
Gfx::IntSize OutOfProcessWebView::notify_server_did_request_resize_window(Gfx::IntSize const& size)
|
||||
{
|
||||
if (on_resize_window)
|
||||
return on_resize_window(size);
|
||||
return {};
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_file(Badge<WebContentClient>, String const& path, i32 request_id)
|
||||
{
|
||||
auto file = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window(), path);
|
||||
|
@ -642,14 +662,19 @@ void OutOfProcessWebView::focusout_event(GUI::FocusEvent&)
|
|||
client().async_set_has_focus(false);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_system_visibility_state(bool visible)
|
||||
{
|
||||
client().async_set_system_visibility_state(visible);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::show_event(GUI::ShowEvent&)
|
||||
{
|
||||
client().async_set_system_visibility_state(true);
|
||||
set_system_visibility_state(true);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::hide_event(GUI::HideEvent&)
|
||||
{
|
||||
client().async_set_system_visibility_state(false);
|
||||
set_system_visibility_state(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,6 +84,8 @@ public:
|
|||
void set_window_position(Gfx::IntPoint const&);
|
||||
void set_window_size(Gfx::IntSize const&);
|
||||
|
||||
void set_system_visibility_state(bool visible);
|
||||
|
||||
Gfx::ShareableBitmap take_screenshot() const;
|
||||
Gfx::ShareableBitmap take_element_screenshot(i32 element_id);
|
||||
Gfx::ShareableBitmap take_document_screenshot();
|
||||
|
@ -110,6 +112,9 @@ public:
|
|||
Function<String(const AK::URL& url, Web::Cookie::Source source)> on_get_cookie;
|
||||
Function<void(const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)> on_set_cookie;
|
||||
Function<void(i32 count_waiting)> on_resource_status_change;
|
||||
Function<void()> on_restore_window;
|
||||
Function<Gfx::IntPoint(Gfx::IntPoint const&)> on_reposition_window;
|
||||
Function<Gfx::IntSize(Gfx::IntSize const&)> on_resize_window;
|
||||
|
||||
private:
|
||||
OutOfProcessWebView();
|
||||
|
@ -167,6 +172,9 @@ private:
|
|||
virtual String notify_server_did_request_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::Source source) override;
|
||||
virtual void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) override;
|
||||
virtual void notify_server_did_update_resource_count(i32 count_waiting) override;
|
||||
virtual void notify_server_did_request_restore_window() override;
|
||||
virtual Gfx::IntPoint notify_server_did_request_reposition_window(Gfx::IntPoint const&) override;
|
||||
virtual Gfx::IntSize notify_server_did_request_resize_window(Gfx::IntSize const&) override;
|
||||
virtual void notify_server_did_request_file(Badge<WebContentClient>, String const& path, i32) override;
|
||||
|
||||
void request_repaint();
|
||||
|
|
|
@ -50,6 +50,9 @@ public:
|
|||
virtual String notify_server_did_request_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::Source source) = 0;
|
||||
virtual void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) = 0;
|
||||
virtual void notify_server_did_update_resource_count(i32 count_waiting) = 0;
|
||||
virtual void notify_server_did_request_restore_window() = 0;
|
||||
virtual Gfx::IntPoint notify_server_did_request_reposition_window(Gfx::IntPoint const&) = 0;
|
||||
virtual Gfx::IntSize notify_server_did_request_resize_window(Gfx::IntSize const&) = 0;
|
||||
virtual void notify_server_did_request_file(Badge<WebContentClient>, String const& path, i32) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -200,6 +200,21 @@ void WebContentClient::did_update_resource_count(i32 count_waiting)
|
|||
m_view.notify_server_did_update_resource_count(count_waiting);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_restore_window()
|
||||
{
|
||||
m_view.notify_server_did_request_restore_window();
|
||||
}
|
||||
|
||||
Messages::WebContentClient::DidRequestRepositionWindowResponse WebContentClient::did_request_reposition_window(Gfx::IntPoint const& position)
|
||||
{
|
||||
return m_view.notify_server_did_request_reposition_window(position);
|
||||
}
|
||||
|
||||
Messages::WebContentClient::DidRequestResizeWindowResponse WebContentClient::did_request_resize_window(Gfx::IntSize const& size)
|
||||
{
|
||||
return m_view.notify_server_did_request_resize_window(size);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_file(String const& path, i32 request_id)
|
||||
{
|
||||
m_view.notify_server_did_request_file({}, path, request_id);
|
||||
|
|
|
@ -61,6 +61,9 @@ private:
|
|||
virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(AK::URL const&, u8) override;
|
||||
virtual void did_set_cookie(AK::URL const&, Web::Cookie::ParsedCookie const&, u8) override;
|
||||
virtual void did_update_resource_count(i32 count_waiting) override;
|
||||
virtual void did_request_restore_window() override;
|
||||
virtual Messages::WebContentClient::DidRequestRepositionWindowResponse did_request_reposition_window(Gfx::IntPoint const&) override;
|
||||
virtual Messages::WebContentClient::DidRequestResizeWindowResponse did_request_resize_window(Gfx::IntSize const&) override;
|
||||
virtual void did_request_file(String const& path, i32) override;
|
||||
|
||||
ViewImplementation& m_view;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue