Stash the ViewportDescription to |webview|

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
This commit is contained in:
Shubham Gupta 2025-03-27 22:59:33 +08:00
parent 4c12008f58
commit e0803c1420
2 changed files with 14 additions and 2 deletions

View file

@ -973,7 +973,11 @@ impl IOCompositor {
warn!("Sending response to get screen size failed ({error:?}).");
}
},
CompositorMsg::Viewport(_webview_id, _viewport_description) => {},
CompositorMsg::Viewport(webview_id, viewport_description) => {
if let Some(webview) = self.webview_renderers.get_mut(webview_id) {
webview.set_viewport_description(viewport_description);
}
},
}
}

View file

@ -8,6 +8,7 @@ use std::collections::{HashMap, VecDeque};
use std::rc::Rc;
use base::id::{PipelineId, WebViewId};
use compositing_traits::viewport_description::ViewportDescription;
use compositing_traits::{SendableFrameTree, WebViewTrait};
use constellation_traits::{EmbedderToConstellationMessage, ScrollState, WindowSizeType};
use embedder_traits::{
@ -58,7 +59,7 @@ pub(crate) struct ScrollResult {
pub offset: LayoutVector2D,
}
#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
pub(crate) enum PinchZoomResult {
DidPinchZoom,
DidNotPinchZoom,
@ -102,6 +103,8 @@ pub(crate) struct WebViewRenderer {
pending_point_input_events: RefCell<VecDeque<InputEvent>>,
/// WebRender is not ready between `SendDisplayList` and `WebRenderFrameReady` messages.
pub webrender_frame_ready: Cell<bool>,
/// Viewport Description
viewport_description: Option<ViewportDescription>,
}
impl Drop for WebViewRenderer {
@ -138,6 +141,7 @@ impl WebViewRenderer {
animating: false,
pending_point_input_events: Default::default(),
webrender_frame_ready: Cell::default(),
viewport_description: None,
}
}
@ -1042,6 +1046,10 @@ impl WebViewRenderer {
let screen_geometry = self.webview.screen_geometry().unwrap_or_default();
(screen_geometry.available_size.to_f32() / self.hidpi_scale_factor).to_i32()
}
pub fn set_viewport_description(&mut self, viewport_description: ViewportDescription) {
self.viewport_description = Some(viewport_description);
}
}
#[derive(Clone, Copy, Debug, PartialEq)]