servoshell: Respond resize with authentic result and Adjust minimum window size (#38258)

- We no longer pretend that resize is always successful and simplify the
result computation.
- Adjust minimum window size to match other browsers and the test
expectation.
- Restrict some unnecessary access specifier.

Testing: ` ./mach test-wpt -r
"tests\wpt\tests\webdriver\tests\classic\set_window_rect\set.py"
--log-raw "D:\servo test log\set.txt" --product servodriver
{--headless}`
Fixes: #37804 as Task 8 is last task.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Euclid Ye 2025-07-25 10:31:18 +08:00 committed by GitHub
parent d39e701b46
commit 928934d4b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 37 deletions

View file

@ -21,11 +21,9 @@ use log::{info, trace, warn};
use net::protocols::ProtocolRegistry;
use servo::config::opts::Opts;
use servo::config::prefs::Preferences;
use servo::servo_geometry::convert_rect_to_css_pixel;
use servo::servo_url::ServoUrl;
use servo::user_content_manager::{UserContentManager, UserScript};
use servo::webrender_api::ScrollLocation;
use servo::webrender_api::units::DeviceIntRect;
use servo::{
EventLoopWaker, ImeEvent, InputEvent, KeyboardEvent, MouseButtonEvent, MouseMoveEvent,
WebDriverCommandMsg, WebDriverScriptCommand, WebDriverUserPromptAction, WheelDelta, WheelEvent,
@ -39,7 +37,6 @@ use winit::window::WindowId;
use super::app_state::AppState;
use super::events_loop::{AppEvent, EventLoopProxy, EventsLoop};
use super::geometry::winit_position_to_euclid_point;
use super::minibrowser::{Minibrowser, MinibrowserEvent};
use super::{headed_window, headless_window};
use crate::desktop::app_state::RunningAppState;
@ -410,32 +407,13 @@ impl App {
let requested_physical_rect =
(requested_rect.to_f32() * scale).round().to_i32();
// When None is returned, it means that the request went to the display system,
// and the actual size will be delivered later with the WindowEvent::Resized.
// Step 17. Set Width/Height.
let returned_size =
window.request_resize(&webview, requested_physical_rect.size());
// TODO: Handle None case. For now, we assume always succeed.
// In reality, the request may exceed available screen size.
window.request_resize(&webview, requested_physical_rect.size());
// Step 18. Set position of the window.
window.set_position(requested_physical_rect.min);
let result_physical_position = window
.winit_window()
.and_then(|window| window.outer_position().ok())
.map(winit_position_to_euclid_point)
.unwrap_or(requested_physical_rect.min);
let reply_rect = convert_rect_to_css_pixel(
DeviceIntRect::from_origin_and_size(
result_physical_position,
returned_size.unwrap_or(requested_physical_rect.size()),
),
scale,
);
if let Err(error) = size_sender.send(reply_rect) {
if let Err(error) = size_sender.send(window.window_rect()) {
warn!("Failed to send window size: {error}");
}
},