Rewild Your Web
web browser dweb
at main 132 lines 5.2 kB view raw
1--- original 2+++ modified 3@@ -10,7 +10,7 @@ 4 use base::Epoch; 5 use base::id::{PainterId, PipelineId, WebViewId}; 6 use crossbeam_channel::Sender; 7-use embedder_traits::{AnimationState, EventLoopWaker}; 8+use embedder_traits::{AnimationState, EventLoopWaker, InputEventAndId}; 9 use euclid::{Rect, Scale, Size2D}; 10 use log::warn; 11 use malloc_size_of_derive::MallocSizeOf; 12@@ -39,7 +39,7 @@ 13 use profile_traits::mem::{OpaqueSender, ReportsChan}; 14 use serde::{Deserialize, Serialize}; 15 pub use webrender_api::ExternalImageSource; 16-use webrender_api::units::{DevicePixel, LayoutVector2D, TexelRect}; 17+use webrender_api::units::{DevicePixel, DeviceRect, LayoutVector2D, TexelRect}; 18 use webrender_api::{ 19 BuiltDisplayList, BuiltDisplayListDescriptor, ExternalImage, ExternalImageData, 20 ExternalImageHandler, ExternalImageId, ExternalScrollId, FontInstanceFlags, FontInstanceKey, 21@@ -187,6 +187,45 @@ 22 ScreenshotReadinessReponse(WebViewId, FxHashMap<PipelineId, Epoch>), 23 /// The candidate of largest-contentful-paint 24 SendLCPCandidate(LCPCandidate, WebViewId, PipelineId, Epoch), 25+ /// Update the position and size of an embedded webview within its parent webview. 26+ /// Used for routing input events to embedded webviews. 27+ UpdateEmbeddedWebViewRect { 28+ /// The embedded webview's ID. 29+ embedded_webview_id: WebViewId, 30+ /// The parent webview that contains this embedded webview. 31+ parent_webview_id: WebViewId, 32+ /// The rect of the embedded webview in device pixels, relative to the parent webview's origin. 33+ rect: DeviceRect, 34+ }, 35+ /// Remove tracking for an embedded webview (called when the iframe is removed). 36+ RemoveEmbeddedWebView(WebViewId), 37+ /// Set whether an embedded webview is hidden (called when display:none is set on the iframe). 38+ SetEmbeddedWebViewHidden { 39+ /// The embedded webview's ID. 40+ embedded_webview_id: WebViewId, 41+ /// The parent webview that contains this embedded webview. 42+ parent_webview_id: WebViewId, 43+ /// Whether the embedded webview should be hidden. 44+ hidden: bool, 45+ }, 46+ /// Take an encoded screenshot of an embedded webview. The screenshot is captured, encoded 47+ /// to the specified format, and sent back via the provided IPC sender. 48+ TakeEncodedScreenshot( 49+ WebViewId, 50+ embedder_traits::EmbeddedWebViewScreenshotRequest, 51+ GenericCallback< 52+ Result< 53+ embedder_traits::EmbeddedWebViewScreenshotResult, 54+ embedder_traits::EmbeddedWebViewScreenshotError, 55+ >, 56+ >, 57+ ), 58+ /// Forward an input event to an embedded webview. This is sent from the Constellation 59+ /// after the parent webview's script thread determined via DOM hit testing that the 60+ /// event target is an embedded iframe element. 61+ ForwardInputEventToEmbeddedWebView(WebViewId, InputEventAndId), 62+ /// Set page zoom for a webview. 63+ SetPageZoom(WebViewId, f32), 64 } 65 66 impl Debug for PaintMessage { 67@@ -540,6 +579,65 @@ 68 source, 69 )); 70 } 71+ 72+ /// Update the position and size of an embedded webview within its parent webview. 73+ /// This is used for routing input events to embedded webviews. 74+ pub fn update_embedded_webview_rect( 75+ &self, 76+ embedded_webview_id: WebViewId, 77+ parent_webview_id: WebViewId, 78+ rect: DeviceRect, 79+ ) { 80+ let _ = self.0.send(PaintMessage::UpdateEmbeddedWebViewRect { 81+ embedded_webview_id, 82+ parent_webview_id, 83+ rect, 84+ }); 85+ } 86+ 87+ /// Remove tracking for an embedded webview (called when the iframe is removed). 88+ pub fn remove_embedded_webview(&self, embedded_webview_id: WebViewId) { 89+ let _ = self 90+ .0 91+ .send(PaintMessage::RemoveEmbeddedWebView(embedded_webview_id)); 92+ } 93+ 94+ /// Set whether an embedded webview is hidden (called when display:none is set on the iframe). 95+ pub fn set_embedded_webview_hidden( 96+ &self, 97+ embedded_webview_id: WebViewId, 98+ parent_webview_id: WebViewId, 99+ hidden: bool, 100+ ) { 101+ let _ = self.0.send(PaintMessage::SetEmbeddedWebViewHidden { 102+ embedded_webview_id, 103+ parent_webview_id, 104+ hidden, 105+ }); 106+ } 107+ 108+ /// Take an encoded screenshot of an embedded webview. The screenshot is captured, 109+ /// encoded to the specified format (PNG, JPEG, or WebP), and sent back via the 110+ /// provided IPC callback. 111+ pub fn request_encoded_screenshot( 112+ &self, 113+ webview_id: WebViewId, 114+ request: embedder_traits::EmbeddedWebViewScreenshotRequest, 115+ response_sender: GenericCallback< 116+ Result< 117+ embedder_traits::EmbeddedWebViewScreenshotResult, 118+ embedder_traits::EmbeddedWebViewScreenshotError, 119+ >, 120+ >, 121+ ) { 122+ if let Err(error) = self.0.send(PaintMessage::TakeEncodedScreenshot( 123+ webview_id, 124+ request, 125+ response_sender, 126+ )) { 127+ warn!("Error sending TakeEncodedScreenshot: {error}"); 128+ } 129+ } 130 } 131 132 #[derive(Clone)]