1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:47:35 +00:00

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:
This commit is contained in:
Sam Atkins 2022-11-02 17:35:53 +00:00 committed by Linus Groh
parent 045aa8530c
commit 3c7bd5a317
27 changed files with 169 additions and 159 deletions

View file

@ -375,7 +375,7 @@ void BrowsingContext::set_needs_display(Gfx::IntRect const& rect)
if (is_top_level()) {
if (m_page)
m_page->client().page_did_invalidate(to_top_level_rect(rect));
m_page->client().page_did_invalidate(to_top_level_rect(rect.to_type<CSSPixels>()));
return;
}
@ -389,7 +389,7 @@ void BrowsingContext::scroll_to(Gfx::IntPoint position)
active_document()->force_layout();
if (m_page)
m_page->client().page_did_request_scroll_to(position);
m_page->client().page_did_request_scroll_to(position.to_type<CSSPixels>());
}
void BrowsingContext::scroll_to_anchor(DeprecatedString const& fragment)
@ -427,17 +427,17 @@ void BrowsingContext::scroll_to_anchor(DeprecatedString const& fragment)
}
if (m_page)
m_page->client().page_did_request_scroll_into_view(enclosing_int_rect(float_rect));
m_page->client().page_did_request_scroll_into_view(float_rect.to_type<CSSPixels>());
}
Gfx::IntRect BrowsingContext::to_top_level_rect(Gfx::IntRect const& a_rect)
CSSPixelRect BrowsingContext::to_top_level_rect(CSSPixelRect const& a_rect)
{
auto rect = a_rect;
rect.set_location(to_top_level_position(a_rect.location()));
return rect;
}
Gfx::IntPoint BrowsingContext::to_top_level_position(Gfx::IntPoint a_position)
CSSPixelPoint BrowsingContext::to_top_level_position(CSSPixelPoint a_position)
{
auto position = a_position;
for (auto ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
@ -447,7 +447,7 @@ Gfx::IntPoint BrowsingContext::to_top_level_position(Gfx::IntPoint a_position)
return {};
if (!ancestor->container()->layout_node())
return {};
position.translate_by(ancestor->container()->layout_node()->box_type_agnostic_position().to_type<int>());
position.translate_by(ancestor->container()->layout_node()->box_type_agnostic_position().to_type<CSSPixels>());
}
return position;
}

View file

@ -183,8 +183,8 @@ public:
HTML::BrowsingContextContainer* container() { return m_container; }
HTML::BrowsingContextContainer const* container() const { return m_container; }
Gfx::IntPoint to_top_level_position(Gfx::IntPoint);
Gfx::IntRect to_top_level_rect(Gfx::IntRect const&);
CSSPixelPoint to_top_level_position(CSSPixelPoint);
CSSPixelRect to_top_level_rect(CSSPixelRect const&);
DOM::Position const& cursor_position() const { return m_cursor_position; }
void set_cursor_position(DOM::Position);