diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-11-01 21:43:04 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-11-08 09:28:00 +0100 |
commit | 2012be4a8bd97f2fd69f986c8fffb1af1eec21dc (patch) | |
tree | c9f1ef91146253f72987cb1436866523880965e0 /components/script/dom | |
parent | b1fd6237d1304f3d57abdafd3e6e738c1ece9f83 (diff) | |
download | servo-2012be4a8bd97f2fd69f986c8fffb1af1eec21dc.tar.gz servo-2012be4a8bd97f2fd69f986c8fffb1af1eec21dc.zip |
`cargo fix --edition-idioms`
Diffstat (limited to 'components/script/dom')
65 files changed, 230 insertions, 223 deletions
diff --git a/components/script/dom/abstractworkerglobalscope.rs b/components/script/dom/abstractworkerglobalscope.rs index ab919bd87c4..e01b98cf944 100644 --- a/components/script/dom/abstractworkerglobalscope.rs +++ b/components/script/dom/abstractworkerglobalscope.rs @@ -32,7 +32,7 @@ impl ScriptChan for SendableWorkerScriptChan { self.sender.send(msg).map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(SendableWorkerScriptChan { sender: self.sender.clone(), worker: self.worker.clone(), @@ -58,7 +58,7 @@ impl ScriptChan for WorkerThreadWorkerChan { self.sender.send(msg).map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(WorkerThreadWorkerChan { sender: self.sender.clone(), worker: self.worker.clone(), diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index 25b77e052e6..5318eb11e4d 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -78,14 +78,14 @@ where pub unsafe trait StableTraceObject { /// Returns a stable trace object which address won't change for the whole /// lifetime of the value. - fn stable_trace_object(&self) -> *const JSTraceable; + fn stable_trace_object(&self) -> *const dyn JSTraceable; } unsafe impl<T> StableTraceObject for Dom<T> where T: DomObject, { - fn stable_trace_object<'a>(&'a self) -> *const JSTraceable { + fn stable_trace_object<'a>(&'a self) -> *const dyn JSTraceable { // The JSTraceable impl for Reflector doesn't actually do anything, // so we need this shenanigan to actually trace the reflector of the // T pointer in Dom<T>. @@ -198,7 +198,7 @@ where /// See also [*Exact Stack Rooting - Storing a GCPointer on the CStack*] /// (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/GC/Exact_Stack_Rooting). pub struct RootCollection { - roots: UnsafeCell<Vec<*const JSTraceable>>, + roots: UnsafeCell<Vec<*const dyn JSTraceable>>, } thread_local!(static STACK_ROOTS: Cell<Option<*const RootCollection>> = Cell::new(None)); @@ -228,13 +228,13 @@ impl RootCollection { } /// Starts tracking a trace object. - unsafe fn root(&self, object: *const JSTraceable) { + unsafe fn root(&self, object: *const dyn JSTraceable) { debug_assert!(thread_state::get().is_script()); (*self.roots.get()).push(object); } /// Stops tracking a trace object, asserting if it isn't found. - unsafe fn unroot(&self, object: *const JSTraceable) { + unsafe fn unroot(&self, object: *const dyn JSTraceable) { debug_assert!(thread_state::get().is_script()); let roots = &mut *self.roots.get(); match roots.iter().rposition(|r| *r == object) { diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index d45bbdef121..d8d3000d037 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -375,7 +375,7 @@ unsafe_no_jsmanaged_fields!(usize, u8, u16, u32, u64); unsafe_no_jsmanaged_fields!(isize, i8, i16, i32, i64); unsafe_no_jsmanaged_fields!(Error); unsafe_no_jsmanaged_fields!(ServoUrl, ImmutableOrigin, MutableOrigin); -unsafe_no_jsmanaged_fields!(Image, ImageMetadata, ImageCache, PendingImageId); +unsafe_no_jsmanaged_fields!(Image, ImageMetadata, dyn ImageCache, PendingImageId); unsafe_no_jsmanaged_fields!(Metadata); unsafe_no_jsmanaged_fields!(NetworkError); unsafe_no_jsmanaged_fields!(Atom, Prefix, LocalName, Namespace, QualName); @@ -461,7 +461,7 @@ unsafe_no_jsmanaged_fields!(AudioBuffer); unsafe_no_jsmanaged_fields!(AudioContext<Backend>); unsafe_no_jsmanaged_fields!(NodeId); unsafe_no_jsmanaged_fields!(AnalysisEngine, DistanceModel, PanningModel, ParamType); -unsafe_no_jsmanaged_fields!(Player<Error = ServoMediaError>); +unsafe_no_jsmanaged_fields!(dyn Player<Error = ServoMediaError>); unsafe_no_jsmanaged_fields!(Mutex<MediaFrameRenderer>); unsafe_no_jsmanaged_fields!(RenderApiSender); @@ -497,7 +497,7 @@ where } // Safe thanks to the Send bound. -unsafe impl JSTraceable for Box<LayoutRPC + Send + 'static> { +unsafe impl JSTraceable for Box<dyn LayoutRPC + Send + 'static> { #[inline] unsafe fn trace(&self, _: *mut JSTracer) { // Do nothing @@ -733,7 +733,7 @@ where /// Holds a set of JSTraceables that need to be rooted struct RootedTraceableSet { - set: Vec<*const JSTraceable>, + set: Vec<*const dyn JSTraceable>, } thread_local!(/// TLV Holds a set of JSTraceables that need to be rooted @@ -744,7 +744,7 @@ impl RootedTraceableSet { RootedTraceableSet { set: vec![] } } - unsafe fn remove(traceable: *const JSTraceable) { + unsafe fn remove(traceable: *const dyn JSTraceable) { ROOTED_TRACEABLES.with(|ref traceables| { let mut traceables = traceables.borrow_mut(); let idx = match traceables.set.iter().rposition(|x| *x == traceable) { @@ -755,7 +755,7 @@ impl RootedTraceableSet { }); } - unsafe fn add(traceable: *const JSTraceable) { + unsafe fn add(traceable: *const dyn JSTraceable) { ROOTED_TRACEABLES.with(|ref traceables| { traceables.borrow_mut().set.push(traceable); }) diff --git a/components/script/dom/bindings/weakref.rs b/components/script/dom/bindings/weakref.rs index 6e46d0268df..2a9e176af6e 100644 --- a/components/script/dom/bindings/weakref.rs +++ b/components/script/dom/bindings/weakref.rs @@ -269,7 +269,7 @@ impl<T: WeakReferenceable> DerefMut for WeakRefVec<T> { /// An entry of a vector of weak references. Passed to the closure /// given to `WeakRefVec::update`. #[allow_unrooted_interior] -pub struct WeakRefEntry<'a, T: WeakReferenceable + 'a> { +pub struct WeakRefEntry<'a, T: WeakReferenceable> { vec: &'a mut WeakRefVec<T>, index: &'a mut usize, } diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 1bf2a09b50f..6dbd1a860c5 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -126,7 +126,7 @@ impl CanvasRenderingContext2D { pub fn new_inherited( global: &GlobalScope, canvas: Option<&HTMLCanvasElement>, - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, base_url: ServoUrl, size: Size2D<u32>, ) -> CanvasRenderingContext2D { diff --git a/components/script/dom/cssrule.rs b/components/script/dom/cssrule.rs index 51dc17d3343..65ff5393a89 100644 --- a/components/script/dom/cssrule.rs +++ b/components/script/dom/cssrule.rs @@ -44,25 +44,25 @@ impl CSSRule { } } - pub fn as_specific(&self) -> &SpecificCSSRule { + pub fn as_specific(&self) -> &dyn SpecificCSSRule { if let Some(rule) = self.downcast::<CSSStyleRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSFontFaceRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSKeyframesRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSMediaRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSNamespaceRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSViewportRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSKeyframeRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSImportRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSSupportsRule>() { - rule as &SpecificCSSRule + rule as &dyn SpecificCSSRule } else { unreachable!() } diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index afe0908c543..f9a3debe9b4 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -203,7 +203,7 @@ impl DedicatedWorkerGlobalScope { worker_url: ServoUrl, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, - parent_sender: Box<ScriptChan + Send>, + parent_sender: Box<dyn ScriptChan + Send>, own_sender: Sender<DedicatedWorkerScriptMsg>, receiver: Receiver<DedicatedWorkerScriptMsg>, timer_event_chan: IpcSender<TimerEvent>, @@ -233,7 +233,7 @@ impl DedicatedWorkerGlobalScope { worker_url: ServoUrl, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, - parent_sender: Box<ScriptChan + Send>, + parent_sender: Box<dyn ScriptChan + Send>, own_sender: Sender<DedicatedWorkerScriptMsg>, receiver: Receiver<DedicatedWorkerScriptMsg>, timer_event_chan: IpcSender<TimerEvent>, @@ -263,7 +263,7 @@ impl DedicatedWorkerGlobalScope { worker_url: ServoUrl, from_devtools_receiver: IpcReceiver<DevtoolScriptControlMsg>, worker: TrustedWorkerAddress, - parent_sender: Box<ScriptChan + Send>, + parent_sender: Box<dyn ScriptChan + Send>, own_sender: Sender<DedicatedWorkerScriptMsg>, receiver: Receiver<DedicatedWorkerScriptMsg>, worker_load_origin: WorkerScriptLoadOrigin, @@ -396,14 +396,14 @@ impl DedicatedWorkerGlobalScope { .expect("Thread spawning failed"); } - pub fn script_chan(&self) -> Box<ScriptChan + Send> { + pub fn script_chan(&self) -> Box<dyn ScriptChan + Send> { Box::new(WorkerThreadWorkerChan { sender: self.own_sender.clone(), worker: self.worker.borrow().as_ref().unwrap().clone(), }) } - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { + pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) { let (tx, rx) = channel(); let chan = Box::new(SendableWorkerScriptChan { sender: tx, diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 330a1194d90..4807f892607 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use crate::cookie_rs; +use cookie::Cookie; use crate::document_loader::{DocumentLoader, LoadType}; use crate::dom::activation::{synthetic_click_activation, ActivationSource}; use crate::dom::attr::Attr; @@ -3965,12 +3965,11 @@ impl DocumentMethods for Document { return Err(Error::Security); } - let cookies = - if let Some(cookie) = cookie_rs::Cookie::parse(cookie.to_string()).ok().map(Serde) { - vec![cookie] - } else { - vec![] - }; + let cookies = if let Some(cookie) = Cookie::parse(cookie.to_string()).ok().map(Serde) { + vec![cookie] + } else { + vec![] + }; let _ = self .window diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 8f65f49b7df..38e5b1ae3c0 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -2579,8 +2579,8 @@ impl ElementMethods for Element { } impl VirtualMethods for Element { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<Node>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<Node>() as &dyn VirtualMethods) } fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool { @@ -2941,31 +2941,31 @@ impl<'a> SelectorsElement for DomRoot<Element> { } impl Element { - pub fn as_maybe_activatable(&self) -> Option<&Activatable> { + pub fn as_maybe_activatable(&self) -> Option<&dyn Activatable> { let element = match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLInputElement, )) => { let element = self.downcast::<HTMLInputElement>().unwrap(); - Some(element as &Activatable) + Some(element as &dyn Activatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLButtonElement, )) => { let element = self.downcast::<HTMLButtonElement>().unwrap(); - Some(element as &Activatable) + Some(element as &dyn Activatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLAnchorElement, )) => { let element = self.downcast::<HTMLAnchorElement>().unwrap(); - Some(element as &Activatable) + Some(element as &dyn Activatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLLabelElement, )) => { let element = self.downcast::<HTMLLabelElement>().unwrap(); - Some(element as &Activatable) + Some(element as &dyn Activatable) }, _ => None, }; @@ -2978,50 +2978,50 @@ impl Element { }) } - pub fn as_stylesheet_owner(&self) -> Option<&StylesheetOwner> { + pub fn as_stylesheet_owner(&self) -> Option<&dyn StylesheetOwner> { if let Some(s) = self.downcast::<HTMLStyleElement>() { - return Some(s as &StylesheetOwner); + return Some(s as &dyn StylesheetOwner); } if let Some(l) = self.downcast::<HTMLLinkElement>() { - return Some(l as &StylesheetOwner); + return Some(l as &dyn StylesheetOwner); } None } // https://html.spec.whatwg.org/multipage/#category-submit - pub fn as_maybe_validatable(&self) -> Option<&Validatable> { + pub fn as_maybe_validatable(&self) -> Option<&dyn Validatable> { let element = match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLInputElement, )) => { let element = self.downcast::<HTMLInputElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLButtonElement, )) => { let element = self.downcast::<HTMLButtonElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLObjectElement, )) => { let element = self.downcast::<HTMLObjectElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLSelectElement, )) => { let element = self.downcast::<HTMLSelectElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTextAreaElement, )) => { let element = self.downcast::<HTMLTextAreaElement>().unwrap(); - Some(element as &Validatable) + Some(element as &dyn Validatable) }, _ => None, }; diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 3c1a1dd3381..a9cdbb07ea9 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -733,7 +733,7 @@ impl EventTargetMethods for EventTarget { } impl VirtualMethods for EventTarget { - fn super_type(&self) -> Option<&VirtualMethods> { + fn super_type(&self) -> Option<&dyn VirtualMethods> { None } } diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 96d4131f581..4b999d24ec0 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -463,7 +463,7 @@ impl GlobalScope { } /// `ScriptChan` to send messages to the event loop of this global scope. - pub fn script_chan(&self) -> Box<ScriptChan + Send> { + pub fn script_chan(&self) -> Box<dyn ScriptChan + Send> { if let Some(window) = self.downcast::<Window>() { return MainThreadScriptChan(window.main_thread_script_chan().clone()).clone(); } @@ -663,7 +663,7 @@ impl GlobalScope { /// Create a new sender/receiver pair that can be used to implement an on-demand /// event loop. Used for implementing web APIs that require blocking semantics /// without resorting to nested event loops. - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { + pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) { if let Some(window) = self.downcast::<Window>() { return window.new_script_pair(); } diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 73f16a8340a..efa96da7e0e 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -98,8 +98,8 @@ impl HTMLAnchorElement { } impl VirtualMethods for HTMLAnchorElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 1a167bd3b94..45532529808 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -285,8 +285,8 @@ impl HTMLAreaElement { } impl VirtualMethods for HTMLAreaElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs index 33ba9886b48..1fe171d5182 100644 --- a/components/script/dom/htmlbaseelement.rs +++ b/components/script/dom/htmlbaseelement.rs @@ -108,8 +108,8 @@ impl HTMLBaseElementMethods for HTMLBaseElement { } impl VirtualMethods for HTMLBaseElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index b3bf5e6a76e..fa368f11c12 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -135,8 +135,8 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<HTMLBodyElement> { } impl VirtualMethods for HTMLBodyElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool { diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index b954c4a7d34..2b58aaea7a0 100755 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -189,8 +189,8 @@ impl HTMLButtonElement { } impl VirtualMethods for HTMLButtonElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 0661f5717f0..2e86193c184 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -407,8 +407,8 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { } impl VirtualMethods for HTMLCanvasElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 99d3c4775b8..cc2256a6764 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -69,7 +69,10 @@ pub struct HTMLCollection { impl HTMLCollection { #[allow(unrooted_must_root)] - pub fn new_inherited(root: &Node, filter: Box<CollectionFilter + 'static>) -> HTMLCollection { + pub fn new_inherited( + root: &Node, + filter: Box<dyn CollectionFilter + 'static>, + ) -> HTMLCollection { HTMLCollection { reflector_: Reflector::new(), root: Dom::from_ref(root), @@ -99,7 +102,7 @@ impl HTMLCollection { pub fn new( window: &Window, root: &Node, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> DomRoot<HTMLCollection> { reflect_dom_object( Box::new(HTMLCollection::new_inherited(root, filter)), @@ -111,7 +114,7 @@ impl HTMLCollection { pub fn create( window: &Window, root: &Node, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> DomRoot<HTMLCollection> { HTMLCollection::new(window, root, filter) } diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index 80d4c1caa98..3f7021dc786 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -62,8 +62,8 @@ impl HTMLDetailsElementMethods for HTMLDetailsElement { } impl VirtualMethods for HTMLDetailsElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index c3702a0357a..93b8e099510 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -718,8 +718,8 @@ impl HTMLElement { } impl VirtualMethods for HTMLElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<Element>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<Element>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index 2026e7bd5e0..614bed522cd 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -95,8 +95,8 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement { } impl VirtualMethods for HTMLFieldSetElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index 0794e4ca432..bf65d411be5 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -74,8 +74,8 @@ impl HTMLFontElementMethods for HTMLFontElement { } impl VirtualMethods for HTMLFontElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool { diff --git a/components/script/dom/htmlformcontrolscollection.rs b/components/script/dom/htmlformcontrolscollection.rs index 57261fe26aa..b3a0ef2cede 100644 --- a/components/script/dom/htmlformcontrolscollection.rs +++ b/components/script/dom/htmlformcontrolscollection.rs @@ -25,7 +25,7 @@ pub struct HTMLFormControlsCollection { impl HTMLFormControlsCollection { fn new_inherited( root: &Node, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> HTMLFormControlsCollection { HTMLFormControlsCollection { collection: HTMLCollection::new_inherited(root, filter), @@ -35,7 +35,7 @@ impl HTMLFormControlsCollection { pub fn new( window: &Window, root: &Node, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> DomRoot<HTMLFormControlsCollection> { reflect_dom_object( Box::new(HTMLFormControlsCollection::new_inherited(root, filter)), diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index ba322aa20e9..fc9e4832fe5 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -1137,8 +1137,8 @@ pub trait FormControl: DomObject { } impl VirtualMethods for HTMLFormElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { @@ -1175,44 +1175,44 @@ impl VirtualMethods for HTMLFormElement { } pub trait FormControlElementHelpers { - fn as_maybe_form_control<'a>(&'a self) -> Option<&'a FormControl>; + fn as_maybe_form_control<'a>(&'a self) -> Option<&'a dyn FormControl>; } impl FormControlElementHelpers for Element { - fn as_maybe_form_control<'a>(&'a self) -> Option<&'a FormControl> { + fn as_maybe_form_control<'a>(&'a self) -> Option<&'a dyn FormControl> { let node = self.upcast::<Node>(); match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLButtonElement, - )) => Some(self.downcast::<HTMLButtonElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLButtonElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLFieldSetElement, - )) => Some(self.downcast::<HTMLFieldSetElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLFieldSetElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLImageElement, - )) => Some(self.downcast::<HTMLImageElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLImageElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLInputElement, - )) => Some(self.downcast::<HTMLInputElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLInputElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLLabelElement, - )) => Some(self.downcast::<HTMLLabelElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLLabelElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLLegendElement, - )) => Some(self.downcast::<HTMLLegendElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLLegendElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLObjectElement, - )) => Some(self.downcast::<HTMLObjectElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLObjectElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLOutputElement, - )) => Some(self.downcast::<HTMLOutputElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLOutputElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLSelectElement, - )) => Some(self.downcast::<HTMLSelectElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLSelectElement>().unwrap() as &dyn FormControl), NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTextAreaElement, - )) => Some(self.downcast::<HTMLTextAreaElement>().unwrap() as &FormControl), + )) => Some(self.downcast::<HTMLTextAreaElement>().unwrap() as &dyn FormControl), _ => None, } } diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index c3aa6812062..89834cde5fc 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -78,8 +78,8 @@ impl HTMLHeadElement { } impl VirtualMethods for HTMLHeadElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn bind_to_tree(&self, tree_in_doc: bool) { if let Some(ref s) = self.super_type() { diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index 1abb3727a8b..01b4e4f526c 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -95,8 +95,8 @@ impl HTMLHRLayoutHelpers for LayoutDom<HTMLHRElement> { } impl VirtualMethods for HTMLHRElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 83499448cdc..9cae4e83e7a 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -547,8 +547,8 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { } impl VirtualMethods for HTMLIFrameElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 05d1d2804e1..851f9971455 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -157,7 +157,7 @@ impl HTMLImageElement { /// The context required for asynchronously loading an external image. struct ImageContext { /// Reference to the script thread image cache. - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, /// Indicates whether the request failed, and why status: Result<(), NetworkError>, /// The cache ID for this request. @@ -229,7 +229,7 @@ impl HTMLImageElement { /// Update the current image with a valid URL. fn fetch_image(&self, img_url: &ServoUrl) { fn add_cache_listener_for_element( - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, id: PendingImageId, elem: &HTMLImageElement, ) { @@ -979,7 +979,7 @@ impl HTMLImageElement { fn react_to_environment_changes_sync_steps(&self, generation: u32) { // TODO reduce duplicacy of this code fn add_cache_listener_for_element( - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, id: PendingImageId, elem: &HTMLImageElement, selected_source: String, @@ -1576,8 +1576,8 @@ impl HTMLImageElementMethods for HTMLImageElement { } impl VirtualMethods for HTMLImageElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn adopting_steps(&self, old_doc: &Document) { diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index e0f50575a44..051acf352a2 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -1206,8 +1206,8 @@ impl HTMLInputElement { } impl VirtualMethods for HTMLInputElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index badc60b5243..7b7129c00ae 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -134,8 +134,8 @@ impl HTMLLabelElementMethods for HTMLLabelElement { } impl VirtualMethods for HTMLLabelElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs index 562c4675a58..345f1a62c55 100644 --- a/components/script/dom/htmllegendelement.rs +++ b/components/script/dom/htmllegendelement.rs @@ -52,8 +52,8 @@ impl HTMLLegendElement { } impl VirtualMethods for HTMLLegendElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn bind_to_tree(&self, tree_in_doc: bool) { diff --git a/components/script/dom/htmllielement.rs b/components/script/dom/htmllielement.rs index b1b913e86e9..cce6ae1f49e 100644 --- a/components/script/dom/htmllielement.rs +++ b/components/script/dom/htmllielement.rs @@ -54,8 +54,8 @@ impl HTMLLIElementMethods for HTMLLIElement { } impl VirtualMethods for HTMLLIElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 74d8e301cff..1efa6924fb8 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -177,8 +177,8 @@ fn is_favicon(value: &Option<String>) -> bool { } impl VirtualMethods for HTMLLinkElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 5182ac1f02d..b178b4b5801 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -1351,8 +1351,8 @@ impl HTMLMediaElementMethods for HTMLMediaElement { } impl VirtualMethods for HTMLMediaElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 7e975c440c9..f6e14f032a3 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -171,8 +171,8 @@ impl HTMLMetaElementMethods for HTMLMetaElement { } impl VirtualMethods for HTMLMetaElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn bind_to_tree(&self, tree_in_doc: bool) { diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index 896c5eb90d1..66076cf5d04 100755 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -114,8 +114,8 @@ impl Validatable for HTMLObjectElement { } impl VirtualMethods for HTMLObjectElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index 9c6b9e9695f..3a8c6b4fe48 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -63,8 +63,8 @@ impl HTMLOptGroupElementMethods for HTMLOptGroupElement { } impl VirtualMethods for HTMLOptGroupElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index a2d9e3609dd..7c17ffe7aa0 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -194,8 +194,8 @@ impl HTMLOptionElementMethods for HTMLOptionElement { } impl VirtualMethods for HTMLOptionElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs index 9ad4e7363d0..5c713fe3543 100644 --- a/components/script/dom/htmloptionscollection.rs +++ b/components/script/dom/htmloptionscollection.rs @@ -32,7 +32,7 @@ pub struct HTMLOptionsCollection { impl HTMLOptionsCollection { fn new_inherited( select: &HTMLSelectElement, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> HTMLOptionsCollection { HTMLOptionsCollection { collection: HTMLCollection::new_inherited(select.upcast(), filter), @@ -42,7 +42,7 @@ impl HTMLOptionsCollection { pub fn new( window: &Window, select: &HTMLSelectElement, - filter: Box<CollectionFilter + 'static>, + filter: Box<dyn CollectionFilter + 'static>, ) -> DomRoot<HTMLOptionsCollection> { reflect_dom_object( Box::new(HTMLOptionsCollection::new_inherited(select, filter)), diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index 1ca4cabba25..54ea702608c 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -71,8 +71,8 @@ impl HTMLOutputElementMethods for HTMLOutputElement { } impl VirtualMethods for HTMLOutputElement { - fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type<'b>(&'b self) -> Option<&'b dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 1cc66221848..47a4950b3d6 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -708,8 +708,8 @@ impl HTMLScriptElement { } impl VirtualMethods for HTMLScriptElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index aa8abc4feb2..c91b483e2d8 100755 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -354,8 +354,8 @@ impl HTMLSelectElementMethods for HTMLSelectElement { } impl VirtualMethods for HTMLSelectElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlsourceelement.rs b/components/script/dom/htmlsourceelement.rs index 4cdbba9f620..3defc6b235f 100644 --- a/components/script/dom/htmlsourceelement.rs +++ b/components/script/dom/htmlsourceelement.rs @@ -63,8 +63,8 @@ impl HTMLSourceElement { } impl VirtualMethods for HTMLSourceElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index ede2cb743a8..364640fa169 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -169,8 +169,8 @@ impl HTMLStyleElement { } impl VirtualMethods for HTMLStyleElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn children_changed(&self, mutation: &ChildrenMutation) { diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index ddf668bb4d4..f9ef8724b71 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -145,8 +145,8 @@ impl HTMLTableCellElementLayoutHelpers for LayoutDom<HTMLTableCellElement> { } impl VirtualMethods for HTMLTableCellElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index d921855ae66..5283d6a9361 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -447,8 +447,8 @@ impl HTMLTableElementLayoutHelpers for LayoutDom<HTMLTableElement> { } impl VirtualMethods for HTMLTableElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index 5255fdc0b0c..044e52f2389 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -165,8 +165,8 @@ impl HTMLTableRowElementLayoutHelpers for LayoutDom<HTMLTableRowElement> { } impl VirtualMethods for HTMLTableRowElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index f1422589c27..f12ed26ffc8 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -102,8 +102,8 @@ impl HTMLTableSectionElementLayoutHelpers for LayoutDom<HTMLTableSectionElement> } impl VirtualMethods for HTMLTableSectionElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index a080373af2c..7689e1efdc1 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -64,8 +64,8 @@ impl HTMLTemplateElementMethods for HTMLTemplateElement { } impl VirtualMethods for HTMLTemplateElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } /// <https://html.spec.whatwg.org/multipage/#template-adopting-steps> diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 05023ab683b..89ffff3e030 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -386,8 +386,8 @@ impl HTMLTextAreaElement { } impl VirtualMethods for HTMLTextAreaElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index da4414d9a91..9fdd1663ed6 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -60,8 +60,8 @@ impl HTMLTitleElementMethods for HTMLTitleElement { } impl VirtualMethods for HTMLTitleElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<HTMLElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods) } fn children_changed(&self, mutation: &ChildrenMutation) { diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 2c637f78a98..6854dd9d9cf 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -2616,8 +2616,8 @@ pub fn window_from_node<T: DerivedFrom<Node> + DomObject>(derived: &T) -> DomRoo } impl VirtualMethods for Node { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<EventTarget>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<EventTarget>() as &dyn VirtualMethods) } fn children_changed(&self, mutation: &ChildrenMutation) { diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index 91ceedaa576..6a9a517298f 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -131,7 +131,7 @@ impl PaintWorkletGlobalScope { unsafe { PaintWorkletGlobalScopeBinding::Wrap(runtime.cx(), global) } } - pub fn image_cache(&self) -> Arc<ImageCache> { + pub fn image_cache(&self) -> Arc<dyn ImageCache> { self.image_cache.clone() } @@ -396,7 +396,7 @@ impl PaintWorkletGlobalScope { } } - fn painter(&self, name: Atom) -> Box<Painter> { + fn painter(&self, name: Atom) -> Box<dyn Painter> { // Rather annoyingly we have to use a mutex here to make the painter Sync. struct WorkletPainter { name: Atom, diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 8358de2f49e..f9c2dba5f66 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -26,8 +26,8 @@ pub struct PromiseNativeHandler { impl PromiseNativeHandler { pub fn new( global: &GlobalScope, - resolve: Option<Box<Callback>>, - reject: Option<Box<Callback>>, + resolve: Option<Box<dyn Callback>>, + reject: Option<Box<dyn Callback>>, ) -> DomRoot<PromiseNativeHandler> { reflect_dom_object( Box::new(PromiseNativeHandler { @@ -40,7 +40,7 @@ impl PromiseNativeHandler { ) } - fn callback(callback: &Option<Box<Callback>>, cx: *mut JSContext, v: HandleValue) { + fn callback(callback: &Option<Box<dyn Callback>>, cx: *mut JSContext, v: HandleValue) { if let Some(ref callback) = *callback { callback.callback(cx, v) } diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index 06f11adaad8..c6f87f6e144 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -116,7 +116,7 @@ impl ScriptChan for ServiceWorkerChan { .map_err(|_| ()) } - fn clone(&self) -> Box<ScriptChan + Send> { + fn clone(&self) -> Box<dyn ScriptChan + Send> { Box::new(ServiceWorkerChan { sender: self.sender.clone(), }) @@ -412,7 +412,7 @@ impl ServiceWorkerGlobalScope { } } - pub fn script_chan(&self) -> Box<ScriptChan + Send> { + pub fn script_chan(&self) -> Box<dyn ScriptChan + Send> { Box::new(ServiceWorkerChan { sender: self.own_sender.clone(), }) diff --git a/components/script/dom/svgelement.rs b/components/script/dom/svgelement.rs index 39dbbf3b161..df138778166 100644 --- a/components/script/dom/svgelement.rs +++ b/components/script/dom/svgelement.rs @@ -29,7 +29,7 @@ impl SVGElement { } impl VirtualMethods for SVGElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<Element>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<Element>() as &dyn VirtualMethods) } } diff --git a/components/script/dom/svggraphicselement.rs b/components/script/dom/svggraphicselement.rs index 713efced553..b0a6590027b 100644 --- a/components/script/dom/svggraphicselement.rs +++ b/components/script/dom/svggraphicselement.rs @@ -42,7 +42,7 @@ impl SVGGraphicsElement { } impl VirtualMethods for SVGGraphicsElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<SVGElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<SVGElement>() as &dyn VirtualMethods) } } diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs index 60c90544aca..6ea48c344e6 100644 --- a/components/script/dom/svgsvgelement.rs +++ b/components/script/dom/svgsvgelement.rs @@ -75,8 +75,8 @@ impl LayoutSVGSVGElementHelpers for LayoutDom<SVGSVGElement> { } impl VirtualMethods for SVGSVGElement { - fn super_type(&self) -> Option<&VirtualMethods> { - Some(self.upcast::<SVGGraphicsElement>() as &VirtualMethods) + fn super_type(&self) -> Option<&dyn VirtualMethods> { + Some(self.upcast::<SVGGraphicsElement>() as &dyn VirtualMethods) } fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index e0f9af46b3b..b8baddb46ae 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -1028,7 +1028,7 @@ impl TestBindingMethods for TestBinding { handler: Rc<SimpleCallback>, } impl SimpleHandler { - fn new(callback: Rc<SimpleCallback>) -> Box<Callback> { + fn new(callback: Rc<SimpleCallback>) -> Box<dyn Callback> { Box::new(SimpleHandler { handler: callback }) } } diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 3e28f02587d..7e0f5ce28c9 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -59,7 +59,7 @@ use style::attr::AttrValue; pub trait VirtualMethods { /// Returns self as the superclass of the implementation for this trait, /// if any. - fn super_type(&self) -> Option<&VirtualMethods>; + fn super_type(&self) -> Option<&dyn VirtualMethods>; /// Called when attributes of a node are mutated. /// <https://dom.spec.whatwg.org/#attribute-is-set> @@ -152,120 +152,120 @@ pub trait VirtualMethods { /// method call on the trait object will invoke the corresponding method on the /// concrete type, propagating up the parent hierarchy unless otherwise /// interrupted. -pub fn vtable_for(node: &Node) -> &VirtualMethods { +pub fn vtable_for(node: &Node) -> &dyn VirtualMethods { match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => { - node.downcast::<HTMLAnchorElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLAnchorElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) => { - node.downcast::<HTMLAreaElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLAreaElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBaseElement)) => { - node.downcast::<HTMLBaseElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLBaseElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement)) => { - node.downcast::<HTMLBodyElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLBodyElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) => { - node.downcast::<HTMLButtonElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLButtonElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLCanvasElement)) => { - node.downcast::<HTMLCanvasElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLCanvasElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLDetailsElement)) => { - node.downcast::<HTMLDetailsElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLDetailsElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFieldSetElement)) => { - node.downcast::<HTMLFieldSetElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLFieldSetElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFontElement)) => { - node.downcast::<HTMLFontElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLFontElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFormElement)) => { - node.downcast::<HTMLFormElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLFormElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHeadElement)) => { - node.downcast::<HTMLHeadElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLHeadElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHRElement)) => { - node.downcast::<HTMLHRElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLHRElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLImageElement)) => { - node.downcast::<HTMLImageElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLImageElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLIFrameElement)) => { - node.downcast::<HTMLIFrameElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLIFrameElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => { - node.downcast::<HTMLInputElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLInputElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLabelElement)) => { - node.downcast::<HTMLLabelElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLLabelElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLIElement)) => { - node.downcast::<HTMLLIElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLLIElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => { - node.downcast::<HTMLLinkElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLLinkElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMediaElement(_))) => { - node.downcast::<HTMLMediaElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLMediaElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLMetaElement)) => { - node.downcast::<HTMLMetaElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLMetaElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLObjectElement)) => { - node.downcast::<HTMLObjectElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLObjectElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptGroupElement)) => { - node.downcast::<HTMLOptGroupElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLOptGroupElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) => { - node.downcast::<HTMLOptionElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLOptionElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOutputElement)) => { - node.downcast::<HTMLOutputElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLOutputElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLScriptElement)) => { - node.downcast::<HTMLScriptElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLScriptElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) => { - node.downcast::<HTMLSelectElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLSelectElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSourceElement)) => { - node.downcast::<HTMLSourceElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLSourceElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLStyleElement)) => { - node.downcast::<HTMLStyleElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLStyleElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableElement)) => { - node.downcast::<HTMLTableElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTableElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTableCellElement, - )) => node.downcast::<HTMLTableCellElement>().unwrap() as &VirtualMethods, + )) => node.downcast::<HTMLTableCellElement>().unwrap() as &dyn VirtualMethods, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableRowElement)) => { - node.downcast::<HTMLTableRowElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTableRowElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTableSectionElement, - )) => node.downcast::<HTMLTableSectionElement>().unwrap() as &VirtualMethods, + )) => node.downcast::<HTMLTableSectionElement>().unwrap() as &dyn VirtualMethods, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTemplateElement)) => { - node.downcast::<HTMLTemplateElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTemplateElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) => { - node.downcast::<HTMLTextAreaElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTextAreaElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTitleElement)) => { - node.downcast::<HTMLTitleElement>().unwrap() as &VirtualMethods + node.downcast::<HTMLTitleElement>().unwrap() as &dyn VirtualMethods }, NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement( SVGGraphicsElementTypeId::SVGSVGElement, - ))) => node.downcast::<SVGSVGElement>().unwrap() as &VirtualMethods, + ))) => node.downcast::<SVGSVGElement>().unwrap() as &dyn VirtualMethods, NodeTypeId::Element(ElementTypeId::Element) => { - node.downcast::<Element>().unwrap() as &VirtualMethods + node.downcast::<Element>().unwrap() as &dyn VirtualMethods }, - NodeTypeId::Element(_) => node.downcast::<HTMLElement>().unwrap() as &VirtualMethods, - _ => node as &VirtualMethods, + NodeTypeId::Element(_) => node.downcast::<HTMLElement>().unwrap() as &dyn VirtualMethods, + _ => node as &dyn VirtualMethods, } } diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs index 76c995068dc..8b91e0cbd07 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -139,7 +139,7 @@ impl WebGLExtensionFeatures { #[must_root] #[derive(JSTraceable, MallocSizeOf)] pub struct WebGLExtensions { - extensions: DomRefCell<HashMap<String, Box<WebGLExtensionWrapper>>>, + extensions: DomRefCell<HashMap<String, Box<dyn WebGLExtensionWrapper>>>, features: DomRefCell<WebGLExtensionFeatures>, webgl_version: WebGLVersion, } diff --git a/components/script/dom/webgl_extensions/wrapper.rs b/components/script/dom/webgl_extensions/wrapper.rs index 9918952dc73..11c9bac3d7e 100644 --- a/components/script/dom/webgl_extensions/wrapper.rs +++ b/components/script/dom/webgl_extensions/wrapper.rs @@ -25,7 +25,7 @@ pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { fn is_enabled(&self) -> bool; fn enable(&self, ext: &WebGLExtensions); fn name(&self) -> &'static str; - fn as_any(&self) -> &Any; + fn as_any(&self) -> &dyn Any; } #[must_root] @@ -85,7 +85,7 @@ where T::name() } - fn as_any<'a>(&'a self) -> &'a Any { + fn as_any<'a>(&'a self) -> &'a dyn Any { self } } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index c9ec7317a3c..9723395d0fa 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -384,7 +384,7 @@ impl Window { self.networking_task_source.clone() } - pub fn history_traversal_task_source(&self) -> Box<ScriptChan + Send> { + pub fn history_traversal_task_source(&self) -> Box<dyn ScriptChan + Send> { self.history_traversal_task_source.clone() } @@ -412,12 +412,12 @@ impl Window { self.parent_info } - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { + pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) { let (tx, rx) = channel(); (Box::new(SendableMainThreadScriptChan(tx)), Box::new(rx)) } - pub fn image_cache(&self) -> Arc<ImageCache> { + pub fn image_cache(&self) -> Arc<dyn ImageCache> { self.image_cache.clone() } @@ -446,7 +446,7 @@ impl Window { &self.bluetooth_extra_permission_data } - pub fn css_error_reporter(&self) -> Option<&ParseErrorReporter> { + pub fn css_error_reporter(&self) -> Option<&dyn ParseErrorReporter> { Some(&self.error_reporter) } @@ -1641,7 +1641,7 @@ impl Window { ) } - pub fn layout(&self) -> &LayoutRPC { + pub fn layout(&self) -> &dyn LayoutRPC { &*self.layout_rpc } @@ -2089,7 +2089,7 @@ impl Window { remote_event_task_source: RemoteEventTaskSource, websocket_task_source: WebsocketTaskSource, image_cache_chan: Sender<ImageCacheMsg>, - image_cache: Arc<ImageCache>, + image_cache: Arc<dyn ImageCache>, resource_threads: ResourceThreads, bluetooth_thread: IpcSender<BluetoothRequest>, mem_profiler_chan: MemProfilerChan, @@ -2112,7 +2112,7 @@ impl Window { webrender_document: DocumentId, webrender_api_sender: RenderApiSender, ) -> DomRoot<Self> { - let layout_rpc: Box<LayoutRPC + Send> = { + let layout_rpc: Box<dyn LayoutRPC + Send> = { let (rpc_send, rpc_recv) = channel(); layout_chan.send(Msg::GetRPC(rpc_send)).unwrap(); rpc_recv.recv().unwrap() diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index a9b1fc4aca4..015c18f2644 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -408,7 +408,7 @@ impl WorkerGlobalScope { } } - pub fn script_chan(&self) -> Box<ScriptChan + Send> { + pub fn script_chan(&self) -> Box<dyn ScriptChan + Send> { let dedicated = self.downcast::<DedicatedWorkerGlobalScope>(); let service_worker = self.downcast::<ServiceWorkerGlobalScope>(); if let Some(dedicated) = dedicated { @@ -444,7 +444,7 @@ impl WorkerGlobalScope { WebsocketTaskSource(self.script_chan(), self.pipeline_id()) } - pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) { + pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) { let dedicated = self.downcast::<DedicatedWorkerGlobalScope>(); if let Some(dedicated) = dedicated { return dedicated.new_script_pair(); diff --git a/components/script/dom/workletglobalscope.rs b/components/script/dom/workletglobalscope.rs index 9e672723c54..3d971390614 100644 --- a/components/script/dom/workletglobalscope.rs +++ b/components/script/dom/workletglobalscope.rs @@ -93,7 +93,12 @@ impl WorkletGlobalScope { } /// Register a paint worklet to the script thread. - pub fn register_paint_worklet(&self, name: Atom, properties: Vec<Atom>, painter: Box<Painter>) { + pub fn register_paint_worklet( + &self, + name: Atom, + properties: Vec<Atom>, + painter: Box<dyn Painter>, + ) { self.to_script_thread_sender .send(MainThreadScriptMsg::RegisterPaintWorklet { pipeline_id: self.globalscope.pipeline_id(), @@ -147,7 +152,7 @@ pub struct WorkletGlobalScopeInit { /// Message to send to the scheduler pub scheduler_chan: IpcSender<TimerSchedulerMsg>, /// The image cache - pub image_cache: Arc<ImageCache>, + pub image_cache: Arc<dyn ImageCache>, } /// <https://drafts.css-houdini.org/worklets/#worklet-global-scope-type> |