diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/animationevent.rs | 9 | ||||
-rw-r--r-- | components/script/dom/baseaudiocontext.rs | 10 | ||||
-rw-r--r-- | components/script/dom/bindings/codegen/Bindings.conf | 6 | ||||
-rw-r--r-- | components/script/dom/document.rs | 12 | ||||
-rw-r--r-- | components/script/dom/focusevent.rs | 4 | ||||
-rw-r--r-- | components/script/dom/oscillatornode.rs | 3 | ||||
-rw-r--r-- | components/script/dom/resizeobserver.rs | 3 | ||||
-rw-r--r-- | components/script/dom/resizeobserversize.rs | 8 | ||||
-rw-r--r-- | components/script/dom/response.rs | 21 |
9 files changed, 55 insertions, 21 deletions
diff --git a/components/script/dom/animationevent.rs b/components/script/dom/animationevent.rs index 408b252bb45..c3a8655c496 100644 --- a/components/script/dom/animationevent.rs +++ b/components/script/dom/animationevent.rs @@ -38,8 +38,13 @@ impl AnimationEvent { } } - pub fn new(window: &Window, type_: Atom, init: &AnimationEventInit) -> DomRoot<AnimationEvent> { - Self::new_with_proto(window, None, type_, init, CanGc::note()) + pub fn new( + window: &Window, + type_: Atom, + init: &AnimationEventInit, + can_gc: CanGc, + ) -> DomRoot<AnimationEvent> { + Self::new_with_proto(window, None, type_, init, can_gc) } fn new_with_proto( diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index 7203e5fe1e5..82fa1152d91 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -66,6 +66,7 @@ use crate::dom::promise::Promise; use crate::dom::stereopannernode::StereoPannerNode; use crate::dom::window::Window; use crate::realms::InRealm; +use crate::script_runtime::CanGc; use crate::task_source::TaskSource; #[allow(dead_code)] @@ -346,8 +347,13 @@ impl BaseAudioContextMethods for BaseAudioContext { event_handler!(statechange, GetOnstatechange, SetOnstatechange); /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createoscillator> - fn CreateOscillator(&self) -> Fallible<DomRoot<OscillatorNode>> { - OscillatorNode::new(self.global().as_window(), self, &OscillatorOptions::empty()) + fn CreateOscillator(&self, can_gc: CanGc) -> Fallible<DomRoot<OscillatorNode>> { + OscillatorNode::new( + self.global().as_window(), + self, + &OscillatorOptions::empty(), + can_gc, + ) } /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain> diff --git a/components/script/dom/bindings/codegen/Bindings.conf b/components/script/dom/bindings/codegen/Bindings.conf index f826f0e9f42..a9c540a175e 100644 --- a/components/script/dom/bindings/codegen/Bindings.conf +++ b/components/script/dom/bindings/codegen/Bindings.conf @@ -25,6 +25,7 @@ DOMInterfaces = { 'BaseAudioContext': { 'inRealms': ['DecodeAudioData', 'Resume', 'ParseFromString', 'GetBounds', 'GetClientRects'], + 'canGc': ['CreateOscillator'], }, 'Blob': { @@ -189,6 +190,11 @@ DOMInterfaces = { 'weakReferenceable': True, }, +'Response': { + 'canGc': ['Error', 'Redirect', 'Clone'], +}, + + 'Selection': { 'canGc': ['Collapse', 'CollapseToEnd', 'CollapseToStart', 'Extend', 'SelectAllChildren', 'SetBaseAndExtent', 'SetPosition'], }, diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 01c24b6f681..e9b97d1c1a4 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2982,7 +2982,10 @@ impl Document { } /// <https://drafts.csswg.org/resize-observer/#broadcast-active-resize-observations> - pub(crate) fn broadcast_active_resize_observations(&self) -> ResizeObservationDepth { + pub(crate) fn broadcast_active_resize_observations( + &self, + can_gc: CanGc, + ) -> ResizeObservationDepth { let mut shallowest = ResizeObservationDepth::max(); // Breaking potential re-borrow cycle on `resize_observers`: // broadcasting resize observations calls into a JS callback, @@ -2993,7 +2996,7 @@ impl Document { .iter() .map(|obs| DomRoot::from_ref(&**obs)) { - observer.broadcast_active_resize_observations(&mut shallowest); + observer.broadcast_active_resize_observations(&mut shallowest, can_gc); } shallowest } @@ -4623,7 +4626,10 @@ impl DocumentMethods for Document { "events" | "event" | "htmlevents" | "svgevents" => { Ok(Event::new_uninitialized(self.window.upcast(), can_gc)) }, - "focusevent" => Ok(DomRoot::upcast(FocusEvent::new_uninitialized(&self.window))), + "focusevent" => Ok(DomRoot::upcast(FocusEvent::new_uninitialized( + &self.window, + can_gc, + ))), "hashchangeevent" => Ok(DomRoot::upcast(HashChangeEvent::new_uninitialized( &self.window, ))), diff --git a/components/script/dom/focusevent.rs b/components/script/dom/focusevent.rs index 965abe14208..d847f8a5492 100644 --- a/components/script/dom/focusevent.rs +++ b/components/script/dom/focusevent.rs @@ -35,8 +35,8 @@ impl FocusEvent { } } - pub fn new_uninitialized(window: &Window) -> DomRoot<FocusEvent> { - Self::new_uninitialized_with_proto(window, None, CanGc::note()) + pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<FocusEvent> { + Self::new_uninitialized_with_proto(window, None, can_gc) } pub fn new_uninitialized_with_proto( diff --git a/components/script/dom/oscillatornode.rs b/components/script/dom/oscillatornode.rs index 8b6a4861061..6ead040d873 100644 --- a/components/script/dom/oscillatornode.rs +++ b/components/script/dom/oscillatornode.rs @@ -91,8 +91,9 @@ impl OscillatorNode { window: &Window, context: &BaseAudioContext, options: &OscillatorOptions, + can_gc: CanGc, ) -> Fallible<DomRoot<OscillatorNode>> { - Self::new_with_proto(window, None, context, options, CanGc::note()) + Self::new_with_proto(window, None, context, options, can_gc) } #[allow(crown::unrooted_must_root)] diff --git a/components/script/dom/resizeobserver.rs b/components/script/dom/resizeobserver.rs index 62029a9b9ef..70589a51a79 100644 --- a/components/script/dom/resizeobserver.rs +++ b/components/script/dom/resizeobserver.rs @@ -93,6 +93,7 @@ impl ResizeObserver { pub fn broadcast_active_resize_observations( &self, shallowest_target_depth: &mut ResizeObservationDepth, + can_gc: CanGc, ) { let mut entries: Vec<DomRoot<ResizeObserverEntry>> = Default::default(); for (observation, target) in self.observation_targets.borrow_mut().iter_mut() { @@ -107,7 +108,7 @@ impl ResizeObserver { let height = box_size.height().to_f64_px(); let size_impl = ResizeObserverSizeImpl::new(width, height); let window = window_from_node(&**target); - let observer_size = ResizeObserverSize::new(&window, size_impl); + let observer_size = ResizeObserverSize::new(&window, size_impl, can_gc); // Note: content rect is built from content box size. let content_rect = DOMRectReadOnly::new( diff --git a/components/script/dom/resizeobserversize.rs b/components/script/dom/resizeobserversize.rs index 212744cf315..055472a3ca8 100644 --- a/components/script/dom/resizeobserversize.rs +++ b/components/script/dom/resizeobserversize.rs @@ -49,9 +49,13 @@ impl ResizeObserverSize { } } - pub fn new(window: &Window, size_impl: ResizeObserverSizeImpl) -> DomRoot<ResizeObserverSize> { + pub fn new( + window: &Window, + size_impl: ResizeObserverSizeImpl, + can_gc: CanGc, + ) -> DomRoot<ResizeObserverSize> { let observer_size = Box::new(ResizeObserverSize::new_inherited(size_impl)); - reflect_dom_object_with_proto(observer_size, window, None, CanGc::note()) + reflect_dom_object_with_proto(observer_size, window, None, can_gc) } } diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index 40f43daf869..6d483d925ae 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -72,8 +72,8 @@ impl Response { } // https://fetch.spec.whatwg.org/#dom-response - pub fn new(global: &GlobalScope) -> DomRoot<Response> { - Self::new_with_proto(global, None, CanGc::note()) + pub fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Response> { + Self::new_with_proto(global, None, can_gc) } fn new_with_proto( @@ -218,8 +218,8 @@ impl ResponseMethods for Response { } // https://fetch.spec.whatwg.org/#dom-response-error - fn Error(global: &GlobalScope) -> DomRoot<Response> { - let r = Response::new(global); + fn Error(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Response> { + let r = Response::new(global, can_gc); *r.response_type.borrow_mut() = DOMResponseType::Error; r.Headers().set_guard(Guard::Immutable); *r.status.borrow_mut() = HttpStatus::new_error(); @@ -227,7 +227,12 @@ impl ResponseMethods for Response { } // https://fetch.spec.whatwg.org/#dom-response-redirect - fn Redirect(global: &GlobalScope, url: USVString, status: u16) -> Fallible<DomRoot<Response>> { + fn Redirect( + global: &GlobalScope, + url: USVString, + status: u16, + can_gc: CanGc, + ) -> Fallible<DomRoot<Response>> { // Step 1 let base_url = global.api_base_url(); let parsed_url = base_url.join(&url.0); @@ -245,7 +250,7 @@ impl ResponseMethods for Response { // Step 4 // see Step 4 continued - let r = Response::new(global); + let r = Response::new(global, can_gc); // Step 5 *r.status.borrow_mut() = HttpStatus::new_raw(status, vec![]); @@ -306,14 +311,14 @@ impl ResponseMethods for Response { } // https://fetch.spec.whatwg.org/#dom-response-clone - fn Clone(&self) -> Fallible<DomRoot<Response>> { + fn Clone(&self, can_gc: CanGc) -> Fallible<DomRoot<Response>> { // Step 1 if self.is_locked() || self.is_disturbed() { return Err(Error::Type("cannot clone a disturbed response".to_string())); } // Step 2 - let new_response = Response::new(&self.global()); + let new_response = Response::new(&self.global(), can_gc); new_response.Headers().copy_from_headers(self.Headers())?; new_response.Headers().set_guard(self.Headers().get_guard()); |