[OH] Provide correct geometry offset and fix available screen dimensions (#36915)

This commit corrects the geometry details provided under the OH platform
by getting the offset from the OS. OH port provides correct offset and
available space.

Fixes: #36466

---------

Signed-off-by: Astraea Quinn Skoutelli <astraea.quinn.skoutelli@huawei.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
This commit is contained in:
Astraea Quinn S 2025-05-09 17:07:49 +02:00 committed by GitHub
parent 2aaf9695df
commit 366515f256
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 6 deletions

View file

@ -38,6 +38,14 @@ impl Coordinates {
viewport: Rect::new(Point2D::new(x, y), Size2D::new(width, height)),
}
}
pub fn origin(&self) -> Point2D<i32, DevicePixel> {
self.viewport.origin
}
pub fn size(&self) -> Size2D<i32, DevicePixel> {
self.viewport.size
}
}
pub(super) struct ServoWindowCallbacks {
@ -115,11 +123,13 @@ impl ServoDelegate for ServoShellServoDelegate {
impl WebViewDelegate for RunningAppState {
fn screen_geometry(&self, _webview: WebView) -> Option<ScreenGeometry> {
let coord = self.callbacks.coordinates.borrow();
let screen_size = DeviceIntSize::new(coord.viewport.size.width, coord.viewport.size.height);
let offset = coord.origin();
let available_size = coord.size();
let screen_size = coord.size();
Some(ScreenGeometry {
size: screen_size,
available_size: screen_size,
offset: Point2D::zero(),
available_size,
offset,
})
}