diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-10-30 12:54:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-30 11:54:13 +0000 |
commit | 850e59f98ec49dfc72ea9b71f8db7b6292f28d12 (patch) | |
tree | 1e4468913f53c073f58374e3b0a2763077ab025f /components/compositing/windowing.rs | |
parent | d877962ee8a5003b0a6eec9fb3d16f1b759a9f9e (diff) | |
download | servo-850e59f98ec49dfc72ea9b71f8db7b6292f28d12.tar.gz servo-850e59f98ec49dfc72ea9b71f8db7b6292f28d12.zip |
servoshell: Allow overriding screen resolution with a command-line argument (#34038)
There is a command-line argument to override the default window size,
but not one for overriding the default screen resolution. This is
important for testing pages that use screen size to have different
behavior.
In addition to adding the new option this change:
- Renames the `--resolution` command-line argument to `--window-size`
to remove ambiguity with the `--screen-size` argument.
- Passes the screen size as device independent (device pixels scaled by
HiDPI factor) to Servo internals. Not only it make it simpler to pass
the `--window-size` override, it makes more sense. Different screens
can have different HiDPI factors and these can be different from the
scale of the window. This makes the screen HiDPI factor totally
independent of the one that Servo uses for the window.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/compositing/windowing.rs')
-rw-r--r-- | components/compositing/windowing.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 30965214603..31c4380f8ba 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -17,7 +17,7 @@ use script_traits::{ GamepadEvent, MediaSessionActionType, MouseButton, TouchEventType, TouchId, TraversalDirection, WheelDelta, }; -use servo_geometry::DeviceIndependentPixel; +use servo_geometry::{DeviceIndependentIntRect, DeviceIndependentIntSize, DeviceIndependentPixel}; use servo_url::ServoUrl; use style_traits::DevicePixel; use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePoint, DeviceRect}; @@ -241,11 +241,11 @@ pub struct EmbedderCoordinates { /// The pixel density of the display. pub hidpi_factor: Scale<f32, DeviceIndependentPixel, DevicePixel>, /// Size of the screen. - pub screen_size: DeviceIntSize, + pub screen_size: DeviceIndependentIntSize, /// Size of the available screen space (screen without toolbars and docks). - pub available_screen_size: DeviceIntSize, + pub available_screen_size: DeviceIndependentIntSize, /// Position and size of the native window. - pub window_rect: DeviceIntRect, + pub window_rect: DeviceIndependentIntRect, /// Size of the GL buffer in the window. pub framebuffer: DeviceIntSize, /// Coordinates of the document within the framebuffer. @@ -278,23 +278,23 @@ impl EmbedderCoordinates { #[cfg(test)] mod test { - use euclid::{Point2D, Scale, Size2D}; + use euclid::{Box2D, Point2D, Scale, Size2D}; use webrender_api::units::DeviceIntRect; use super::EmbedderCoordinates; #[test] fn test() { - let pos = Point2D::zero(); - let viewport = Size2D::new(800, 600); - let screen = Size2D::new(1080, 720); + let screen_size = Size2D::new(1080, 720); + let viewport = Box2D::from_origin_and_size(Point2D::zero(), Size2D::new(800, 600)); + let window_rect = Box2D::from_origin_and_size(Point2D::zero(), Size2D::new(800, 600)); let coordinates = EmbedderCoordinates { hidpi_factor: Scale::new(1.), - screen_size: screen, - available_screen_size: screen, - window_rect: DeviceIntRect::from_origin_and_size(pos, viewport), - framebuffer: viewport, - viewport: DeviceIntRect::from_origin_and_size(pos, viewport), + screen_size, + available_screen_size: screen_size, + window_rect, + framebuffer: viewport.size(), + viewport, }; // Check if viewport conversion is correct. |