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>
This commit is contained in:
Jonathan Schwender 2025-01-29 16:45:17 +01:00 committed by GitHub
parent f6d1b30e97
commit 53fcc98585
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 87 additions and 31 deletions

View file

@ -15,7 +15,7 @@ use servo::compositing::windowing::{
};
use servo::euclid::{Box2D, Point2D, Rect, Scale, Size2D, Vector2D};
use servo::servo_geometry::DeviceIndependentPixel;
use servo::webrender_api::units::DevicePixel;
use servo::webrender_api::units::{DevicePixel, DeviceRect};
use servo::webrender_api::ScrollLocation;
use servo::webrender_traits::SurfmanRenderingContext;
use servo::{
@ -222,8 +222,16 @@ impl ServoGlue {
/// Let Servo know that the window has been resized.
pub fn resize(&mut self, coordinates: Coordinates) {
info!("resize");
info!("resize to {:?}", coordinates);
let size = coordinates.viewport.size;
let _ = self
.rendering_context
.resize(Size2D::new(size.width, size.height))
.inspect_err(|e| error!("Failed to resize rendering context: {e:?}"));
*self.callbacks.coordinates.borrow_mut() = coordinates;
self.active_webview().notify_rendering_context_resized();
self.active_webview()
.move_resize(DeviceRect::from_size(size.to_f32()));
self.maybe_perform_updates()
}
@ -638,10 +646,12 @@ impl ServoGlue {
EmbedderMsg::Keyboard(..) => {
error!("Received unexpected keyboard event");
},
EmbedderMsg::ResizeTo(size) => {
error!("Received resize event (to {size:?}). Currently only the user can resize windows");
},
EmbedderMsg::Status(..) |
EmbedderMsg::SelectFiles(..) |
EmbedderMsg::MoveTo(..) |
EmbedderMsg::ResizeTo(..) |
EmbedderMsg::SetCursor(..) |
EmbedderMsg::NewFavicon(..) |
EmbedderMsg::HeadParsed |