diff options
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r-- | components/script/dom/globalscope.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index f803d6228b7..1330021035a 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -20,6 +20,7 @@ use crate::dom::errorevent::ErrorEvent; use crate::dom::event::{Event, EventBubbles, EventCancelable, EventStatus}; use crate::dom::eventsource::EventSource; use crate::dom::eventtarget::EventTarget; +use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; use crate::dom::performance::Performance; use crate::dom::window::Window; use crate::dom::workerglobalscope::WorkerGlobalScope; @@ -51,6 +52,7 @@ use js::rust::{get_object_class, CompileOptionsWrapper, ParentRuntime, Runtime}; use js::rust::{HandleValue, MutableHandleValue}; use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; use msg::constellation_msg::PipelineId; +use net_traits::image_cache::ImageCache; use net_traits::{CoreResourceThread, IpcSend, ResourceThreads}; use profile_traits::{mem as profile_mem, time as profile_time}; use script_traits::{MsDuration, ScriptToConstellationChan, TimerEvent}; @@ -376,6 +378,19 @@ impl GlobalScope { &self.origin } + pub fn image_cache(&self) -> Arc<dyn ImageCache> { + if let Some(window) = self.downcast::<Window>() { + return window.image_cache(); + } + if let Some(worker) = self.downcast::<DedicatedWorkerGlobalScope>() { + return worker.image_cache(); + } + if let Some(worker) = self.downcast::<PaintWorkletGlobalScope>() { + return worker.image_cache(); + } + unreachable!(); + } + /// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url) /// for this global scope. pub fn api_base_url(&self) -> ServoUrl { |