mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
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>
This commit is contained in:
parent
d877962ee8
commit
850e59f98e
14 changed files with 181 additions and 115 deletions
|
@ -63,7 +63,7 @@ use selectors::attr::CaseSensitivity;
|
|||
use servo_arc::Arc as ServoArc;
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::pref;
|
||||
use servo_geometry::{f32_rect_to_au_rect, MaxRect};
|
||||
use servo_geometry::{f32_rect_to_au_rect, DeviceIndependentIntRect, MaxRect};
|
||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
use style::dom::OpaqueNode;
|
||||
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
|
||||
|
@ -76,7 +76,7 @@ use style::str::HTML_SPACE_CHARACTERS;
|
|||
use style::stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||
use style_traits::{CSSPixel, DevicePixel, ParsingMode};
|
||||
use url::Position;
|
||||
use webrender_api::units::{DeviceIntRect, LayoutPixel};
|
||||
use webrender_api::units::LayoutPixel;
|
||||
use webrender_api::{DocumentId, ExternalScrollId};
|
||||
use webrender_traits::CrossProcessCompositorApi;
|
||||
|
||||
|
@ -1782,16 +1782,16 @@ impl Window {
|
|||
|
||||
fn client_window(&self) -> (Size2D<u32, CSSPixel>, Point2D<i32, CSSPixel>) {
|
||||
let timer_profile_chan = self.global().time_profiler_chan().clone();
|
||||
let (send, recv) = ProfiledIpc::channel::<DeviceIntRect>(timer_profile_chan).unwrap();
|
||||
let (send, recv) =
|
||||
ProfiledIpc::channel::<DeviceIndependentIntRect>(timer_profile_chan).unwrap();
|
||||
let _ = self
|
||||
.compositor_api
|
||||
.sender()
|
||||
.send(webrender_traits::CrossProcessCompositorMessage::GetClientWindowRect(send));
|
||||
let rect = recv.recv().unwrap_or_default();
|
||||
let dpr = self.device_pixel_ratio();
|
||||
let rect = recv.recv().unwrap_or_default().to_u32();
|
||||
(
|
||||
(rect.size().to_f32() / dpr).to_u32(),
|
||||
(rect.min.to_f32() / dpr).to_i32(),
|
||||
Size2D::new(rect.size().width, rect.size().height),
|
||||
Point2D::new(rect.min.x as i32, rect.min.y as i32),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue