diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index d110bbfcdce..d37d4d80f07 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -517,6 +517,7 @@ impl UnprivilegedPipelineContent { webgl_chan: self.webgl_chan, webvr_chan: self.webvr_chan, webrender_document: self.webrender_document, + webrender_api_sender: self.webrender_api_sender.clone(), }, self.load_data.clone(), ); diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index ff905ab55b5..b6c7a460103 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -132,7 +132,9 @@ use time; use timers::{IsInterval, TimerCallback}; use url::Position; use webdriver_handlers::jsval_to_webdriver; -use webrender_api::{ExternalScrollId, DeviceIntPoint, DeviceUintSize, DocumentId}; +use webrender_api::{ + DeviceIntPoint, DeviceUintSize, DocumentId, ExternalScrollId, RenderApiSender, +}; use webvr_traits::WebVRMsg; /// Current state of the window object @@ -308,6 +310,17 @@ pub struct Window { /// Flag to identify whether mutation observers are present(true)/absent(false) exists_mut_observer: Cell, + /// Webrender API Sender + #[ignore_malloc_size_of = "defined in webrender_api"] + webrender_api_sender: RenderApiSender, +} + +// FIXME(victor): this doesn't belong here +#[allow(unsafe_code)] +unsafe impl ::dom::bindings::trace::JSTraceable for RenderApiSender { + unsafe fn trace(&self, _trc: *mut ::js::jsapi::JSTracer) { + // Do nothing + } } impl Window { @@ -483,6 +496,10 @@ impl Window { } self.add_pending_reflow(); } + + pub fn get_webrender_api_sender(&self) -> RenderApiSender { + self.webrender_api_sender.clone() + } } // https://html.spec.whatwg.org/multipage/#atob @@ -2083,6 +2100,7 @@ impl Window { webvr_chan: Option>, microtask_queue: Rc, webrender_document: DocumentId, + webrender_api_sender: RenderApiSender, ) -> DomRoot { let layout_rpc: Box = { let (rpc_send, rpc_recv) = channel(); @@ -2161,6 +2179,7 @@ impl Window { paint_worklet: Default::default(), webrender_document, exists_mut_observer: Cell::new(false), + webrender_api_sender, }); unsafe { WindowBinding::Wrap(runtime.cx(), win) } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 748b6fc63e4..687dd32e1df 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -130,7 +130,7 @@ use time::{get_time, precise_time_ns, Tm}; use url::Position; use url::percent_encoding::percent_decode; use webdriver_handlers; -use webrender_api::DocumentId; +use webrender_api::{DocumentId, RenderApiSender}; use webvr_traits::{WebVREvent, WebVRMsg}; pub type ImageCacheMsg = (PipelineId, PendingImageResponse); @@ -591,6 +591,9 @@ pub struct ScriptThread { /// The Webrender Document ID associated with this thread. webrender_document: DocumentId, + + /// FIXME(victor): + webrender_api_sender: RenderApiSender, } /// In the event of thread panic, all data on the stack runs its destructor. However, there @@ -1063,6 +1066,7 @@ impl ScriptThread { custom_element_reaction_stack: CustomElementReactionStack::new(), webrender_document: state.webrender_document, + webrender_api_sender: state.webrender_api_sender, } } @@ -2584,6 +2588,7 @@ impl ScriptThread { self.webvr_chan.clone(), self.microtask_queue.clone(), self.webrender_document, + self.webrender_api_sender.clone(), ); // Initialize the browsing context for the window. diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 6c087690b5f..60b62f6b270 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -72,7 +72,9 @@ use style_traits::CSSPixel; use style_traits::SpeculativePainter; use style_traits::cursor::CursorKind; use webdriver_msg::{LoadStatus, WebDriverScriptCommand}; -use webrender_api::{ExternalScrollId, DevicePixel, DeviceUintSize, DocumentId, ImageKey}; +use webrender_api::{ + DevicePixel, DeviceUintSize, DocumentId, ExternalScrollId, ImageKey, RenderApiSender, +}; use webvr_traits::{WebVREvent, WebVRMsg}; pub use script_msg::{LayoutMsg, ScriptMsg, EventResult, LogEntry}; @@ -588,6 +590,8 @@ pub struct InitialScriptState { pub webvr_chan: Option>, /// The Webrender document ID associated with this thread. pub webrender_document: DocumentId, + /// FIXME(victor): The Webrender API sender in this constellation's pipeline + pub webrender_api_sender: RenderApiSender, } /// This trait allows creating a `ScriptThread` without depending on the `script`