From c4e3ba2dfba549320201e05300f271f68452b802 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 11 Apr 2023 19:01:49 -0400 Subject: [PATCH] LibWeb: Implement converting a DevicePixelRect to a CSSPixelRect Which also requires converting a DevicePixelSize to a CSSPixelSize. --- .../Libraries/LibWeb/Painting/PaintContext.cpp | 16 ++++++++++++++++ .../Libraries/LibWeb/Painting/PaintContext.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/Userland/Libraries/LibWeb/Painting/PaintContext.cpp b/Userland/Libraries/LibWeb/Painting/PaintContext.cpp index 3135070784..394ac15d50 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintContext.cpp @@ -124,4 +124,20 @@ CSSPixelPoint PaintContext::scale_to_css_point(DevicePixelPoint point) const }; } +CSSPixelSize PaintContext::scale_to_css_size(DevicePixelSize size) const +{ + return { + scale_to_css_pixels(size.width()), + scale_to_css_pixels(size.height()) + }; +} + +CSSPixelRect PaintContext::scale_to_css_rect(DevicePixelRect rect) const +{ + return { + scale_to_css_point(rect.location()), + scale_to_css_size(rect.size()) + }; +} + } diff --git a/Userland/Libraries/LibWeb/Painting/PaintContext.h b/Userland/Libraries/LibWeb/Painting/PaintContext.h index 39eca49b27..cf5ef72e25 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintContext.h +++ b/Userland/Libraries/LibWeb/Painting/PaintContext.h @@ -49,6 +49,8 @@ public: DevicePixelSize rounded_device_size(CSSPixelSize) const; CSSPixels scale_to_css_pixels(DevicePixels) const; CSSPixelPoint scale_to_css_point(DevicePixelPoint) const; + CSSPixelSize scale_to_css_size(DevicePixelSize) const; + CSSPixelRect scale_to_css_rect(DevicePixelRect) const; PaintContext clone(Gfx::Painter& painter) const {