webdriver: Get the window position as well as the size when resolving "Get Window Rect" (#37812)

1. Rename `GetWindowSize` to `GetWindowRect`
2. Return the WindowRect in device pixels correctly. Previously, it
returns `(0, 0, ScreenWidth, ScreenHeight)` which is a static value.
3. Add `fn window_rect` to `WindowPortsMethods`. Implement it for both
Headless Window and Headed Window.

Testing: Tested manually with powershell script. Result is now dynamic
and reflects the truth.
Fixes: Task 1 & 2 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-02 18:01:27 +08:00 committed by GitHub
parent 95d9d3a412
commit 94f35ba998
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 35 additions and 19 deletions

View file

@ -8,9 +8,9 @@ use std::cell::Cell;
use std::rc::Rc;
use euclid::num::Zero;
use euclid::{Length, Scale, Size2D};
use euclid::{Length, Point2D, Scale, Size2D};
use servo::servo_geometry::DeviceIndependentPixel;
use servo::webrender_api::units::{DeviceIntSize, DevicePixel};
use servo::webrender_api::units::{DeviceIntRect, DeviceIntSize, DevicePixel};
use servo::{RenderingContext, ScreenGeometry, SoftwareRenderingContext};
use winit::dpi::PhysicalSize;
@ -135,6 +135,10 @@ impl WindowPortsMethods for Window {
Length::zero()
}
fn window_rect(&self) -> DeviceIntRect {
DeviceIntRect::from_origin_and_size(Point2D::zero(), self.inner_size.get())
}
fn set_toolbar_height(&self, _height: Length<f32, DeviceIndependentPixel>) {
unimplemented!("headless Window only")
}