servoshell: Make fn request_resize resize window w.r.t. outer_size accurately#37848
servoshell: Make fn request_resize resize window w.r.t. outer_size accurately#37848xiaochengh merged 2 commits intoservo:mainfrom
fn request_resize resize window w.r.t. outer_size accurately#37848Conversation
Signed-off-by: Euclid Ye <[email protected]>
|
🔨 Triggering try run (#16046257080) for Linux (WPT) |
|
Test results for linux-wpt from try job (#16046257080): Flaky unexpected result (23)
Stable unexpected results that are known to be intermittent (18)
|
|
✨ Try run (#16046257080) succeeded. |
Signed-off-by: Euclid Ye <[email protected]>
ae976ac to
7e1e81d
Compare
fn request_resize resize accuratelyfn request_resize resize window w.r.t. outer_size accurately
| /// 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) |
There was a problem hiding this comment.
This function is used for only two things:
- window.resizeTo
- WebDriver SetWindowRect
Both would request outer_size instead of inner_size
| let title_height = | ||
| self.winit_window.outer_size().height - self.winit_window.inner_size().height; |
There was a problem hiding this comment.
Should we calculate toolbar height in the same way as before? Since hidpi scale factor might be playing a role here.
There was a problem hiding this comment.
Not needed because inner_size already includes toolbar height.
There was a problem hiding this comment.
Then what does inner_size stand for? Window.innerHeight should not include toolbar, but viewport only.
There was a problem hiding this comment.
inner_size is the terminology used by winit. It is everything except the title and border from OS.
Window.innerHeight should not include toolbar, but viewport only.
Yes. This is already done correctly, except that they didn't include Scrollbar. But that is another story..
| let title_height = | ||
| self.winit_window.outer_size().height - self.winit_window.inner_size().height; |
…& Fix wrong usage of `innerHeight` & add new test (#37856) 1. rename original `window_resizeTo.html` to `window_resize_event.html` to reflect the purpose. Also change {innerWidth, innerHeight} to {outerWidth, outerHeight} to match spec. 2. Add a new test `window_resizeTo.html` for #37848 Testing: new test always fails because of #37824, which gives inaccurate outerHeight. Signed-off-by: Euclid Ye <[email protected]>

toolbar_heightis already part ofinner_size, caused wrongly calculatedouter_size. Even worse, it tried torequest_inner_sizewith the already wrongouter_size.This PR make sure resize is accurate by first calculate the title/border height, and then compute the
inner_sizeforrequest_inner_size. This is necessary because no directrequest_outer_sizeis available.Testing: As manually tested, set window size WebDriver command no longer overshoot. This is also shared by window.resizeTo JS method. WPT test would be necessary. (But that one is intermittent TIMEOUT. So created new one in #37856)
WebDriver test will be postponed after web-platform-tests/wpt#53421 is merged and synced to Servo.
Fixes: Task 3 of #37804