diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-11-02 17:35:53 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-10 12:03:19 +0000 |
commit | 3c7bd5a317515ac572610eba2919c82dcd320a1e (patch) | |
tree | e716f6049c9bd58ba9f07c8d9fa9aaa42f23a39f /Userland/Services/WebContent | |
parent | 045aa8530c56b9a58f5e9150f17cb08e29bf5ab2 (diff) | |
download | serenity-3c7bd5a317515ac572610eba2919c82dcd320a1e.zip |
LibWeb+WebContent+headless-browser: Use CSSPixels for PageClient events
...and also for hit testing, which is involved in most of them.
Much of this is temporary conversions and other awkwardness, which
should resolve itself as the rest of LibWeb is converted to these new
types. Hopefully. :thousandyakstare:
Diffstat (limited to 'Userland/Services/WebContent')
-rw-r--r-- | Userland/Services/WebContent/ConnectionFromClient.cpp | 10 | ||||
-rw-r--r-- | Userland/Services/WebContent/PageHost.cpp | 34 | ||||
-rw-r--r-- | Userland/Services/WebContent/PageHost.h | 16 |
3 files changed, 32 insertions, 28 deletions
diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index bc56decb02..0e1f7bf59d 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -157,27 +157,27 @@ void ConnectionFromClient::flush_pending_paint_requests() void ConnectionFromClient::mouse_down(Gfx::IntPoint position, unsigned int button, unsigned int buttons, unsigned int modifiers) { - report_finished_handling_input_event(page().handle_mousedown(position, button, buttons, modifiers)); + report_finished_handling_input_event(page().handle_mousedown(position.to_type<Web::DevicePixels>(), button, buttons, modifiers)); } void ConnectionFromClient::mouse_move(Gfx::IntPoint position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers) { - report_finished_handling_input_event(page().handle_mousemove(position, buttons, modifiers)); + report_finished_handling_input_event(page().handle_mousemove(position.to_type<Web::DevicePixels>(), buttons, modifiers)); } void ConnectionFromClient::mouse_up(Gfx::IntPoint position, unsigned int button, unsigned int buttons, unsigned int modifiers) { - report_finished_handling_input_event(page().handle_mouseup(position, button, buttons, modifiers)); + report_finished_handling_input_event(page().handle_mouseup(position.to_type<Web::DevicePixels>(), button, buttons, modifiers)); } void ConnectionFromClient::mouse_wheel(Gfx::IntPoint position, unsigned int button, unsigned int buttons, unsigned int modifiers, i32 wheel_delta_x, i32 wheel_delta_y) { - report_finished_handling_input_event(page().handle_mousewheel(position, button, buttons, modifiers, wheel_delta_x, wheel_delta_y)); + report_finished_handling_input_event(page().handle_mousewheel(position.to_type<Web::DevicePixels>(), button, buttons, modifiers, wheel_delta_x, wheel_delta_y)); } void ConnectionFromClient::doubleclick(Gfx::IntPoint position, unsigned int button, unsigned int buttons, unsigned int modifiers) { - report_finished_handling_input_event(page().handle_doubleclick(position, button, buttons, modifiers)); + report_finished_handling_input_event(page().handle_doubleclick(position.to_type<Web::DevicePixels>(), button, buttons, modifiers)); } void ConnectionFromClient::key_down(i32 key, unsigned int modifiers, u32 code_point) diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 7275b7d111..71e4ffc5a3 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -26,7 +26,7 @@ PageHost::PageHost(ConnectionFromClient& client) { setup_palette(); m_invalidation_coalescing_timer = Web::Platform::Timer::create_single_shot(0, [this] { - m_client.async_did_invalidate_content_rect(m_invalidation_rect); + m_client.async_did_invalidate_content_rect({ m_invalidation_rect.x().value(), m_invalidation_rect.y().value(), m_invalidation_rect.width().value(), m_invalidation_rect.height().value() }); m_invalidation_rect = {}; }); } @@ -130,9 +130,9 @@ void PageHost::set_viewport_rect(Gfx::IntRect const& rect) page().top_level_browsing_context().set_viewport_rect(rect); } -void PageHost::page_did_invalidate(Gfx::IntRect const& content_rect) +void PageHost::page_did_invalidate(Web::CSSPixelRect const& content_rect) { - m_invalidation_rect = m_invalidation_rect.united(content_rect); + m_invalidation_rect = m_invalidation_rect.united(page().enclosing_device_rect(content_rect)); if (!m_invalidation_coalescing_timer->is_active()) m_invalidation_coalescing_timer->start(); } @@ -213,19 +213,23 @@ void PageHost::page_did_request_scroll(i32 x_delta, i32 y_delta) m_client.async_did_request_scroll(x_delta, y_delta); } -void PageHost::page_did_request_scroll_to(Gfx::IntPoint scroll_position) +void PageHost::page_did_request_scroll_to(Web::CSSPixelPoint scroll_position) { - m_client.async_did_request_scroll_to(scroll_position); + m_client.async_did_request_scroll_to({ scroll_position.x().value(), scroll_position.y().value() }); } -void PageHost::page_did_request_scroll_into_view(Gfx::IntRect const& rect) +void PageHost::page_did_request_scroll_into_view(Web::CSSPixelRect const& rect) { - m_client.async_did_request_scroll_into_view(rect); + auto device_pixel_rect = page().enclosing_device_rect(rect); + m_client.async_did_request_scroll_into_view({ device_pixel_rect.x().value(), + device_pixel_rect.y().value(), + device_pixel_rect.width().value(), + device_pixel_rect.height().value() }); } -void PageHost::page_did_enter_tooltip_area(Gfx::IntPoint content_position, DeprecatedString const& title) +void PageHost::page_did_enter_tooltip_area(Web::CSSPixelPoint content_position, DeprecatedString const& title) { - m_client.async_did_enter_tooltip_area(content_position, title); + m_client.async_did_enter_tooltip_area({ content_position.x().value(), content_position.y().value() }, title); } void PageHost::page_did_leave_tooltip_area() @@ -268,14 +272,14 @@ void PageHost::page_did_finish_loading(const URL& url) m_client.async_did_finish_loading(url); } -void PageHost::page_did_request_context_menu(Gfx::IntPoint content_position) +void PageHost::page_did_request_context_menu(Web::CSSPixelPoint content_position) { - m_client.async_did_request_context_menu(content_position); + m_client.async_did_request_context_menu(page().css_to_device_point(content_position).to_type<int>()); } -void PageHost::page_did_request_link_context_menu(Gfx::IntPoint content_position, const URL& url, DeprecatedString const& target, unsigned modifiers) +void PageHost::page_did_request_link_context_menu(Web::CSSPixelPoint content_position, URL const& url, DeprecatedString const& target, unsigned modifiers) { - m_client.async_did_request_link_context_menu(content_position, url, target, modifiers); + m_client.async_did_request_link_context_menu(page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers); } void PageHost::page_did_request_alert(DeprecatedString const& message) @@ -328,10 +332,10 @@ void PageHost::page_did_change_favicon(Gfx::Bitmap const& favicon) m_client.async_did_change_favicon(favicon.to_shareable_bitmap()); } -void PageHost::page_did_request_image_context_menu(Gfx::IntPoint content_position, const URL& url, DeprecatedString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer) +void PageHost::page_did_request_image_context_menu(Web::CSSPixelPoint content_position, URL const& url, DeprecatedString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer) { auto bitmap = bitmap_pointer ? bitmap_pointer->to_shareable_bitmap() : Gfx::ShareableBitmap(); - m_client.async_did_request_image_context_menu(content_position, url, target, modifiers, bitmap); + m_client.async_did_request_image_context_menu({ content_position.x().value(), content_position.y().value() }, url, target, modifiers, bitmap); } Vector<Web::Cookie::Cookie> PageHost::page_did_request_all_cookies(URL const& url) diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h index 94c8749b4a..fb0054226d 100644 --- a/Userland/Services/WebContent/PageHost.h +++ b/Userland/Services/WebContent/PageHost.h @@ -55,7 +55,7 @@ private: virtual Web::DevicePixelRect screen_rect() const override { return m_screen_rect; } virtual float device_pixels_per_css_pixel() const override { return m_screen_display_scale; } virtual Web::CSS::PreferredColorScheme preferred_color_scheme() const override { return m_preferred_color_scheme; } - virtual void page_did_invalidate(Gfx::IntRect const&) override; + virtual void page_did_invalidate(Web::CSSPixelRect const&) override; virtual void page_did_change_selection() override; virtual void page_did_request_cursor_change(Gfx::StandardCursor) override; virtual void page_did_layout() override; @@ -70,16 +70,16 @@ private: virtual Gfx::IntRect page_did_request_minimize_window() override; virtual Gfx::IntRect page_did_request_fullscreen_window() override; virtual void page_did_request_scroll(i32, i32) override; - virtual void page_did_request_scroll_to(Gfx::IntPoint) override; - virtual void page_did_request_scroll_into_view(Gfx::IntRect const&) override; - virtual void page_did_enter_tooltip_area(Gfx::IntPoint, DeprecatedString const&) override; + virtual void page_did_request_scroll_to(Web::CSSPixelPoint) override; + virtual void page_did_request_scroll_into_view(Web::CSSPixelRect const&) override; + virtual void page_did_enter_tooltip_area(Web::CSSPixelPoint, DeprecatedString const&) override; virtual void page_did_leave_tooltip_area() override; virtual void page_did_hover_link(const URL&) override; virtual void page_did_unhover_link() override; virtual void page_did_click_link(const URL&, DeprecatedString const& target, unsigned modifiers) override; virtual void page_did_middle_click_link(const URL&, DeprecatedString const& target, unsigned modifiers) override; - virtual void page_did_request_context_menu(Gfx::IntPoint) override; - virtual void page_did_request_link_context_menu(Gfx::IntPoint, const URL&, DeprecatedString const& target, unsigned modifiers) override; + virtual void page_did_request_context_menu(Web::CSSPixelPoint) override; + virtual void page_did_request_link_context_menu(Web::CSSPixelPoint, URL const&, DeprecatedString const& target, unsigned modifiers) override; virtual void page_did_start_loading(const URL&, bool) override; virtual void page_did_create_main_document() override; virtual void page_did_finish_loading(const URL&) override; @@ -90,7 +90,7 @@ private: virtual void page_did_request_accept_dialog() override; virtual void page_did_request_dismiss_dialog() override; virtual void page_did_change_favicon(Gfx::Bitmap const&) override; - virtual void page_did_request_image_context_menu(Gfx::IntPoint, const URL&, DeprecatedString const& target, unsigned modifiers, Gfx::Bitmap const*) override; + virtual void page_did_request_image_context_menu(Web::CSSPixelPoint, const URL&, DeprecatedString const& target, unsigned modifiers, Gfx::Bitmap const*) override; virtual Vector<Web::Cookie::Cookie> page_did_request_all_cookies(URL const&) override; virtual Optional<Web::Cookie::Cookie> page_did_request_named_cookie(URL const&, DeprecatedString const&) override; virtual DeprecatedString page_did_request_cookie(const URL&, Web::Cookie::Source) override; @@ -115,7 +115,7 @@ private: bool m_has_focus { false }; RefPtr<Web::Platform::Timer> m_invalidation_coalescing_timer; - Gfx::IntRect m_invalidation_rect; + Web::DevicePixelRect m_invalidation_rect; Web::CSS::PreferredColorScheme m_preferred_color_scheme { Web::CSS::PreferredColorScheme::Auto }; RefPtr<WebDriverConnection> m_webdriver; |