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

LibWeb+LibWebView+WebContent: Add IPC to receive window position/size

This information will have to come from the Browser application. This
adds IPCs to receive that information when it is available or changes.
This commit is contained in:
Timothy Flynn 2022-11-01 14:55:53 -04:00 committed by Linus Groh
parent f7e747b68e
commit 6aea60e6ee
8 changed files with 51 additions and 0 deletions

View file

@ -16,6 +16,8 @@
#include <Kernel/API/KeyCode.h>
#include <LibGfx/Forward.h>
#include <LibGfx/Palette.h>
#include <LibGfx/Point.h>
#include <LibGfx/Size.h>
#include <LibGfx/StandardCursor.h>
#include <LibJS/Heap/Handle.h>
#include <LibWeb/CSS/PreferredColorScheme.h>
@ -72,6 +74,12 @@ public:
bool is_webdriver_active() const { return m_is_webdriver_active; }
void set_is_webdriver_active(bool b) { m_is_webdriver_active = b; }
Gfx::IntPoint const& window_position() const { return m_window_position; }
void set_window_position(Gfx::IntPoint const& position) { m_window_position = position; }
Gfx::IntSize const& window_size() const { return m_window_size; }
void set_window_size(Gfx::IntSize const& size) { m_window_size = size; }
private:
PageClient& m_client;
@ -86,6 +94,9 @@ private:
// https://w3c.github.io/webdriver/#dfn-webdriver-active-flag
// The webdriver-active flag is set to true when the user agent is under remote control. It is initially false.
bool m_is_webdriver_active { false };
Gfx::IntPoint m_window_position {};
Gfx::IntSize m_window_size {};
};
class PageClient {

View file

@ -575,6 +575,16 @@ void OutOfProcessWebView::set_is_webdriver_active(bool is_webdriver_enabled)
client().async_set_is_webdriver_active(is_webdriver_enabled);
}
void OutOfProcessWebView::set_window_position(Gfx::IntPoint const& position)
{
client().async_set_window_position(position);
}
void OutOfProcessWebView::set_window_size(Gfx::IntSize const& size)
{
client().async_set_window_size(size);
}
void OutOfProcessWebView::focusin_event(GUI::FocusEvent&)
{
client().async_set_has_focus(true);

View file

@ -72,6 +72,9 @@ public:
void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
void set_is_webdriver_active(bool);
void set_window_position(Gfx::IntPoint const&);
void set_window_size(Gfx::IntSize const&);
Function<void(Gfx::IntPoint const& screen_position)> on_context_menu_request;
Function<void(const AK::URL&, String const& target, unsigned modifiers)> on_link_click;
Function<void(const AK::URL&, Gfx::IntPoint const& screen_position)> on_link_context_menu_request;

View file

@ -655,6 +655,16 @@ void ConnectionFromClient::set_is_webdriver_active(bool is_webdriver_active)
m_page_host->set_is_webdriver_active(is_webdriver_active);
}
void ConnectionFromClient::set_window_position(Gfx::IntPoint const& position)
{
m_page_host->set_window_position(position);
}
void ConnectionFromClient::set_window_size(Gfx::IntSize const& size)
{
m_page_host->set_window_size(size);
}
Messages::WebContentServer::GetLocalStorageEntriesResponse ConnectionFromClient::get_local_storage_entries()
{
auto* document = page().top_level_browsing_context().active_document();

View file

@ -72,6 +72,8 @@ private:
virtual void set_has_focus(bool) override;
virtual void set_is_scripting_enabled(bool) override;
virtual void set_is_webdriver_active(bool) override;
virtual void set_window_position(Gfx::IntPoint const&) override;
virtual void set_window_size(Gfx::IntSize const&) override;
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
virtual void set_system_visibility_state(bool visible) override;

View file

@ -76,6 +76,16 @@ void PageHost::set_is_webdriver_active(bool is_webdriver_active)
page().set_is_webdriver_active(is_webdriver_active);
}
void PageHost::set_window_position(Gfx::IntPoint const& position)
{
page().set_window_position(position);
}
void PageHost::set_window_size(Gfx::IntSize const& size)
{
page().set_window_size(size);
}
Web::Layout::InitialContainingBlock* PageHost::layout_root()
{
auto* document = page().top_level_browsing_context().active_document();

View file

@ -35,6 +35,8 @@ public:
void set_has_focus(bool);
void set_is_scripting_enabled(bool);
void set_is_webdriver_active(bool);
void set_window_position(Gfx::IntPoint const&);
void set_window_size(Gfx::IntSize const&);
private:
// ^PageClient

View file

@ -60,6 +60,9 @@ endpoint WebContentServer
set_is_scripting_enabled(bool is_scripting_enabled) =|
set_is_webdriver_active(bool is_webdriver_active) =|
set_window_position(Gfx::IntPoint position) =|
set_window_size(Gfx::IntSize size) =|
get_local_storage_entries() => (OrderedHashMap<String,String> entries)
get_session_storage_entries() => (OrderedHashMap<String,String> entries)