1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

Ladybird/Qt: Move positional device pixel ratio adjustment to a helper

The code to convert a Gfx::IntPoint to a QPoint adjusted for the device
pixel ratio is a bit of a mouthful, and will be needed outside of Tab,
so move it to a helper that can be reused.
This commit is contained in:
Timothy Flynn 2024-03-10 22:15:06 -04:00 committed by Andreas Kling
parent bc42144642
commit b5e8f0ebfe
3 changed files with 12 additions and 5 deletions

View file

@ -644,6 +644,11 @@ Web::DevicePixelRect WebContentView::viewport_rect() const
return m_viewport_rect.to_type<Web::DevicePixels>();
}
QPoint WebContentView::map_point_to_global_position(Gfx::IntPoint position) const
{
return mapToGlobal(QPoint { position.x(), position.y() } / device_pixel_ratio());
}
Gfx::IntPoint WebContentView::to_content_position(Gfx::IntPoint widget_position) const
{
return widget_position.translated(max(0, horizontalScrollBar()->value()), max(0, verticalScrollBar()->value()));