servoshell: Make fn request_resize resize window w.r.t. outer_size accurately (#37848)

`toolbar_height` is already part of `inner_size`, caused wrongly
calculated `outer_size`. Even worse, it tried to `request_inner_size`
with the already wrong `outer_size`.

This PR make sure resize is accurate by first calculate the title/border
height, and then compute the `inner_size` for `request_inner_size`. This
is necessary because no direct `request_outer_size` is available.

Testing: As manually tested, set window size WebDriver command no longer
overshoot. This is also shared by
[window.resizeTo](https://drafts.csswg.org/cssom-view/#dom-window-resizeto)
JS method. WPT test would be necessary. (But that one is intermittent
TIMEOUT. So created new one in
https://github.com/servo/servo/pull/37856)
 
WebDriver test will be postponed after
https://github.com/web-platform-tests/wpt/pull/53421 is merged and
synced to Servo.

Fixes: Task 3 of https://github.com/servo/servo/issues/37804

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-07-04 16:10:58 +08:00 committed by GitHub
parent a990ff82b9
commit aaf04883dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 11 deletions

View file

@ -26,8 +26,9 @@ pub trait WindowPortsMethods {
fn get_fullscreen(&self) -> bool;
fn handle_winit_event(&self, state: Rc<RunningAppState>, event: winit::event::WindowEvent);
fn set_title(&self, _title: &str) {}
/// Request a new inner size for the window, not including external decorations.
fn request_resize(&self, webview: &WebView, inner_size: DeviceIntSize)
/// Request a new outer size for the window, including external decorations.
/// This should be the same as `window.outerWidth` and `window.outerHeight``
fn request_resize(&self, webview: &WebView, outer_size: DeviceIntSize)
-> Option<DeviceIntSize>;
fn set_position(&self, _point: DeviceIntPoint) {}
fn set_fullscreen(&self, _state: bool) {}