mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 17:55:08 +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
|
@ -248,6 +248,22 @@ Tab::Tab(BrowserWindow& window)
|
|||
update_status({}, count_waiting);
|
||||
};
|
||||
|
||||
view().on_restore_window = [this]() {
|
||||
this->window().show();
|
||||
this->window().move_to_front();
|
||||
m_web_content_view->set_system_visibility_state(true);
|
||||
};
|
||||
|
||||
view().on_reposition_window = [this](Gfx::IntPoint const& position) {
|
||||
this->window().move_to(position);
|
||||
return this->window().position();
|
||||
};
|
||||
|
||||
view().on_resize_window = [this](Gfx::IntSize const& size) {
|
||||
this->window().resize(size);
|
||||
return this->window().size();
|
||||
};
|
||||
|
||||
m_link_context_menu = GUI::Menu::construct();
|
||||
auto link_default_action = GUI::Action::create("&Open", g_icon_bag.go_to, [this](auto&) {
|
||||
view().on_link_click(m_link_context_menu_url, "", 0);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -38,6 +38,9 @@ endpoint WebContentClient
|
|||
did_request_cookie(URL url, u8 source) => (String cookie)
|
||||
did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) =|
|
||||
did_update_resource_count(i32 count_waiting) =|
|
||||
did_request_restore_window() =|
|
||||
did_request_reposition_window(Gfx::IntPoint position) => (Gfx::IntPoint window_position)
|
||||
did_request_resize_window(Gfx::IntSize size) => (Gfx::IntSize window_size)
|
||||
did_request_file(String path, i32 request_id) =|
|
||||
|
||||
did_output_js_console_message(i32 message_index) =|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue