servoshell: Consider window decorations when handling resize requests from web content (#38174)

Also fix some docs. This is used by JS `resizeTo`, `resizeBy` and
webdriver [set window
rect](https://w3c.github.io/webdriver/#set-window-rect).

Testing: Can now pass more tests for headed window.
Fixes: Well.. Originally the attempt is to address
https://github.com/servo/servo/issues/38093#issuecomment-3092284104. But
it turns out as a more general problem to be fixed in another PR.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Euclid Ye 2025-07-24 13:42:04 +08:00 committed by GitHub
parent f62aa8edc2
commit 0b8986c8da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 47 additions and 30 deletions

View file

@ -77,10 +77,10 @@ impl WindowPortsMethods for Window {
fn request_resize(
&self,
webview: &::servo::WebView,
size: DeviceIntSize,
outer_size: DeviceIntSize,
) -> Option<DeviceIntSize> {
// Surfman doesn't support zero-sized surfaces.
let new_size = DeviceIntSize::new(size.width.max(1), size.height.max(1));
let new_size = DeviceIntSize::new(outer_size.width.max(1), outer_size.height.max(1));
if self.inner_size.get() == new_size {
return Some(new_size);
}
@ -90,7 +90,11 @@ impl WindowPortsMethods for Window {
// Because we are managing the rendering surface ourselves, there will be no other
// notification (such as from the display manager) that it has changed size, so we
// must notify the compositor here.
webview.resize(PhysicalSize::new(size.width as u32, size.height as u32));
webview.move_resize(outer_size.to_f32().into());
webview.resize(PhysicalSize::new(
outer_size.width as u32,
outer_size.height as u32,
));
Some(new_size)
}