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:
parent
bc42144642
commit
b5e8f0ebfe
3 changed files with 12 additions and 5 deletions
|
@ -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()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue