aboutsummaryrefslogtreecommitdiffstats
path: root/ports/servoshell/egl/ohos
diff options
context:
space:
mode:
authorJonathan Schwender <55576758+jschwe@users.noreply.github.com>2025-01-29 16:45:17 +0100
committerGitHub <noreply@github.com>2025-01-29 15:45:17 +0000
commit53fcc98585807b43e049718b1d04d89733cc846a (patch)
tree6fa4db8aca4f3ab9562c6f4e59a0ca97429d1d8c /ports/servoshell/egl/ohos
parentf6d1b30e9785414562f22cf6ee545d7f3387d779 (diff)
downloadservo-53fcc98585807b43e049718b1d04d89733cc846a.tar.gz
servo-53fcc98585807b43e049718b1d04d89733cc846a.zip
ohos: Support resizing the surface (#35158)
A window resize requires to also resize the webview, otherwise it will stay at the original size. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Diffstat (limited to 'ports/servoshell/egl/ohos')
-rw-r--r--ports/servoshell/egl/ohos/simpleservo.rs33
1 files changed, 14 insertions, 19 deletions
diff --git a/ports/servoshell/egl/ohos/simpleservo.rs b/ports/servoshell/egl/ohos/simpleservo.rs
index 3498531a949..ff0a37c6105 100644
--- a/ports/servoshell/egl/ohos/simpleservo.rs
+++ b/ports/servoshell/egl/ohos/simpleservo.rs
@@ -9,7 +9,6 @@ use std::rc::Rc;
use log::{debug, info};
use servo::compositing::CompositeTarget;
-use servo::euclid::Size2D;
use servo::webrender_traits::SurfmanRenderingContext;
/// The EventLoopWaker::wake function will be called from any thread.
/// It will be called to notify embedder that some events are available,
@@ -17,7 +16,7 @@ use servo::webrender_traits::SurfmanRenderingContext;
pub use servo::EventLoopWaker;
use servo::{self, resources, Servo};
use surfman::{Connection, SurfaceType};
-use xcomponent_sys::{OH_NativeXComponent, OH_NativeXComponent_GetXComponentSize};
+use xcomponent_sys::OH_NativeXComponent;
use crate::egl::host_trait::HostTrait;
use crate::egl::ohos::resources::ResourceReaderInstance;
@@ -68,24 +67,13 @@ pub fn init(
.create_adapter()
.or(Err("Failed to create adapter"))?;
- let mut width: u64 = 0;
- let mut height: u64 = 0;
- let res = unsafe {
- OH_NativeXComponent_GetXComponentSize(
- xcomponent,
- native_window,
- &mut width as *mut _,
- &mut height as *mut _,
- )
+ let Ok(window_size) = (unsafe { super::get_xcomponent_size(xcomponent, native_window) }) else {
+ return Err("Failed to get xcomponent size");
};
- assert_eq!(res, 0, "OH_NativeXComponent_GetXComponentSize failed");
- let width: i32 = width.try_into().expect("Width too large");
- let height: i32 = height.try_into().expect("Height too large");
- debug!("Creating surfman widget with width {width} and height {height}");
- let native_widget = unsafe {
- connection.create_native_widget_from_ptr(native_window, Size2D::new(width, height))
- };
+ debug!("Creating surfman widget with {window_size:?}");
+ let native_widget =
+ unsafe { connection.create_native_widget_from_ptr(native_window, window_size) };
let surface_type = SurfaceType::Widget { native_widget };
info!("Creating rendering context");
@@ -102,7 +90,14 @@ pub fn init(
let window_callbacks = Rc::new(ServoWindowCallbacks::new(
callbacks,
- RefCell::new(Coordinates::new(0, 0, width, height, width, height)),
+ RefCell::new(Coordinates::new(
+ 0,
+ 0,
+ window_size.width,
+ window_size.height,
+ window_size.width,
+ window_size.height,
+ )),
options.display_density as f32,
));