Commit 75c52710 authored by Daniel Libby's avatar Daniel Libby Committed by Commit Bot

Respect emulation scale for window segments

We should not be using the original root window segments when none
are passed to the emulator, since these are based off of the DIPs the
widget is occupying, which doesn't take into account the emulator
scale (zoom drop down menu).

Instead, just emulate a single segment that is the same as the
emulated widget size, which takes the scale into account when emulated
width/height are not specified.

Bug: 1119306

Change-Id: Ic6ab80517989309f697036da873af3448981ad16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2350763Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Daniel Libby <dlibby@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#799682}
parent a980e70b
......@@ -131,13 +131,17 @@ void RenderWidgetScreenMetricsEmulator::Apply() {
delegate_->SetScreenRects(gfx::Rect(widget_pos, widget_size),
gfx::Rect(window_pos, window_size));
// If there are no emulated window segments, use the original ones - when we
// switch from having them to having none, we need to fallback to the original
// value. If there never were any emulated segments this is a no-op.
bool emulated_window_segments = emulation_params_.window_segments.size();
delegate_->SetRootWindowSegments(emulated_window_segments
? emulation_params_.window_segments
: original_root_window_segments_);
// If there are no emulated window segments, use the emulated widget size
// instead. When we switch from emulated segments to not having any, we should
// have a single segment that matches the widget size.
bool has_emulated_segments = emulation_params_.window_segments.size();
if (has_emulated_segments) {
delegate_->SetRootWindowSegments(emulation_params_.window_segments);
} else {
std::vector<gfx::Rect> emulated_segments{
{0, 0, widget_size.width(), widget_size.height()}};
delegate_->SetRootWindowSegments(emulated_segments);
}
blink::ScreenInfo screen_info = original_screen_info();
screen_info.device_scale_factor = device_scale_factor;
......
......@@ -15,13 +15,13 @@ Iframe segments:
2
0 0 390 600
410 0 390 600
Unspecified display feature
Unspecified display feature with scale
Main frame segments:
1
0 0 800 600
0 0 1600 1200
Iframe segments:
1
0 0 800 600
0 0 1600 1200
Stacked segments
Main frame segments:
2
......
......@@ -7,7 +7,7 @@
deviceScaleFactor: 2,
mobile: false,
fitWindow: false,
scale: 2,
scale: 0.5,
screenWidth: 1200,
screenHeight: 1000,
positionX: 110,
......@@ -30,12 +30,20 @@
await session.protocol.Emulation.setDeviceMetricsOverride(deviceMetrics);
testRunner.log(await session.evaluate(`dumpWindowSegments()`));
testRunner.log("Unspecified display feature");
testRunner.log("Unspecified display feature with scale");
delete deviceMetrics.displayFeature;
// Setting width/height to 0 indicates that the widget should have an
// emulated size based on the size of the widget in DIP, but takes the
// scale into account. Given a scale of 0.5, we expect the window
// segment (and window itself) dimensions to double.
deviceMetrics.width = 0;
deviceMetrics.height = 0;
await session.protocol.Emulation.setDeviceMetricsOverride(deviceMetrics);
testRunner.log(await session.evaluate(`dumpWindowSegments()`));
testRunner.log("Stacked segments");
deviceMetrics.width = 800;
deviceMetrics.height = 600;
deviceMetrics.displayFeature = {
orientation: "horizontal",
offset: 290,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment