mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
servoshell: Add window position for headless window (#38249)
Add virtual `window_position` to headless window so that `moveTo` and WebDriver window command can work properly. Testing: `./mach test-wpt -r "tests\wpt\tests\webdriver\tests\classic\set_window_rect\set.py" --product servodriver --headless` Fixes: Task 7 of #37804. --------- Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
parent
4c7797a7ab
commit
3bc104c8e4
2 changed files with 16 additions and 45 deletions
|
@ -10,9 +10,9 @@ use std::rc::Rc;
|
||||||
use euclid::num::Zero;
|
use euclid::num::Zero;
|
||||||
use euclid::{Length, Point2D, Scale, Size2D};
|
use euclid::{Length, Point2D, Scale, Size2D};
|
||||||
use servo::servo_geometry::{
|
use servo::servo_geometry::{
|
||||||
DeviceIndependentIntRect, DeviceIndependentPixel, convert_size_to_css_pixel,
|
DeviceIndependentIntRect, DeviceIndependentPixel, convert_rect_to_css_pixel,
|
||||||
};
|
};
|
||||||
use servo::webrender_api::units::{DeviceIntSize, DevicePixel};
|
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel};
|
||||||
use servo::{RenderingContext, ScreenGeometry, SoftwareRenderingContext};
|
use servo::{RenderingContext, ScreenGeometry, SoftwareRenderingContext};
|
||||||
use winit::dpi::PhysicalSize;
|
use winit::dpi::PhysicalSize;
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ pub struct Window {
|
||||||
device_pixel_ratio_override: Option<Scale<f32, DeviceIndependentPixel, DevicePixel>>,
|
device_pixel_ratio_override: Option<Scale<f32, DeviceIndependentPixel, DevicePixel>>,
|
||||||
inner_size: Cell<DeviceIntSize>,
|
inner_size: Cell<DeviceIntSize>,
|
||||||
screen_size: Size2D<i32, DevicePixel>,
|
screen_size: Size2D<i32, DevicePixel>,
|
||||||
|
// virtual top-left position of the window in device pixels.
|
||||||
|
window_position: Cell<Point2D<i32, DevicePixel>>,
|
||||||
rendering_context: Rc<SoftwareRenderingContext>,
|
rendering_context: Rc<SoftwareRenderingContext>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@ impl Window {
|
||||||
device_pixel_ratio_override,
|
device_pixel_ratio_override,
|
||||||
inner_size: Cell::new(inner_size),
|
inner_size: Cell::new(inner_size),
|
||||||
screen_size,
|
screen_size,
|
||||||
|
window_position: Cell::new(Point2D::zero()),
|
||||||
rendering_context: Rc::new(rendering_context),
|
rendering_context: Rc::new(rendering_context),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,10 +73,17 @@ impl WindowPortsMethods for Window {
|
||||||
ScreenGeometry {
|
ScreenGeometry {
|
||||||
size: self.screen_size,
|
size: self.screen_size,
|
||||||
available_size: self.screen_size,
|
available_size: self.screen_size,
|
||||||
window_rect: self.inner_size.get().into(),
|
window_rect: DeviceIntRect::from_origin_and_size(
|
||||||
|
self.window_position.get(),
|
||||||
|
self.inner_size.get(),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_position(&self, point: DeviceIntPoint) {
|
||||||
|
self.window_position.set(point);
|
||||||
|
}
|
||||||
|
|
||||||
fn request_resize(
|
fn request_resize(
|
||||||
&self,
|
&self,
|
||||||
webview: &::servo::WebView,
|
webview: &::servo::WebView,
|
||||||
|
@ -142,12 +152,9 @@ impl WindowPortsMethods for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window_rect(&self) -> DeviceIndependentIntRect {
|
fn window_rect(&self) -> DeviceIndependentIntRect {
|
||||||
let inner_size = self.inner_size.get();
|
convert_rect_to_css_pixel(
|
||||||
let scale = self.hidpi_scale_factor();
|
DeviceIntRect::from_origin_and_size(self.window_position.get(), self.inner_size.get()),
|
||||||
|
self.hidpi_scale_factor(),
|
||||||
DeviceIndependentIntRect::from_origin_and_size(
|
|
||||||
Point2D::zero(),
|
|
||||||
convert_size_to_css_pixel(inner_size, scale),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,44 +5,8 @@
|
||||||
[test_restore_from_maximized]
|
[test_restore_from_maximized]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[test_x_y_floats]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_partial_input[rect2\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_partial_input[rect3\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_partial_input[rect4\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_partial_input[rect5\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_partial_input[rect6\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_partial_input[rect7\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_set_to_available_size]
|
[test_set_to_available_size]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[test_set_smaller_than_minimum_browser_size]
|
[test_set_smaller_than_minimum_browser_size]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[test_x_y]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_x_as_current]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_y_as_current]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_negative_x_y]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_response_payload]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue