diff options
-rw-r--r-- | components/script/animations.rs | 5 | ||||
-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 | ||||
-rw-r--r-- | components/script/fetch.rs | 2 | ||||
-rw-r--r-- | components/script/script_thread.rs | 10 |
12 files changed, 65 insertions, 28 deletions
diff --git a/components/script/animations.rs b/components/script/animations.rs index 03b860178fd..469a43a3904 100644 --- a/components/script/animations.rs +++ b/components/script/animations.rs @@ -33,6 +33,7 @@ use crate::dom::event::Event; use crate::dom::node::{from_untrusted_node_address, window_from_node, Node, NodeDamage}; use crate::dom::transitionevent::TransitionEvent; use crate::dom::window::Window; +use crate::script_runtime::CanGc; /// The set of animations for a document. #[derive(Default, JSTraceable, MallocSizeOf)] @@ -456,7 +457,7 @@ impl Animations { }); } - pub(crate) fn send_pending_events(&self, window: &Window) { + pub(crate) fn send_pending_events(&self, window: &Window, can_gc: CanGc) { // Take all of the events here, in case sending one of these events // triggers adding new events by forcing a layout. let events = std::mem::take(&mut *self.pending_events.borrow_mut()); @@ -517,7 +518,7 @@ impl Animations { elapsedTime: elapsed_time, pseudoElement: pseudo_element, }; - AnimationEvent::new(&window, event_atom, &event_init) + AnimationEvent::new(&window, event_atom, &event_init, can_gc) .upcast::<Event>() .fire(node.upcast()); } 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()); diff --git a/components/script/fetch.rs b/components/script/fetch.rs index 334805ec471..6037e3c0965 100644 --- a/components/script/fetch.rs +++ b/components/script/fetch.rs @@ -154,7 +154,7 @@ pub fn Fetch( // Step 7. Let responseObject be null. // NOTE: We do initialize the object earlier earlier so we can use it to track errors - let response = Response::new(global); + let response = Response::new(global, can_gc); response.Headers().set_guard(Guard::Immutable); // Step 2. Let requestObject be the result of invoking the initial value of Request as constructor diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 4514257c894..7030285ab60 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1707,7 +1707,7 @@ impl ScriptThread { } // Update animations and send events. - self.update_animations_and_send_events(); + self.update_animations_and_send_events(can_gc); // TODO(#31866): Implement "run the fullscreen steps" from // https://fullscreen.spec.whatwg.org/multipage/#run-the-fullscreen-steps. @@ -1723,7 +1723,7 @@ impl ScriptThread { let mut depth = Default::default(); while document.gather_active_resize_observations_at_depth(&depth) { // Note: this will reflow the doc. - depth = document.broadcast_active_resize_observations(); + depth = document.broadcast_active_resize_observations(can_gc); } if document.has_skipped_resize_observations() { @@ -2071,7 +2071,7 @@ impl ScriptThread { // Perform step 7.10 from https://html.spec.whatwg.org/multipage/#event-loop-processing-model. // Described at: https://drafts.csswg.org/web-animations-1/#update-animations-and-send-events - fn update_animations_and_send_events(&self) { + fn update_animations_and_send_events(&self, can_gc: CanGc) { for (_, document) in self.documents.borrow().iter() { document.update_animation_timeline(); document.maybe_mark_animating_nodes_as_dirty(); @@ -2079,7 +2079,9 @@ impl ScriptThread { for (_, document) in self.documents.borrow().iter() { let _realm = enter_realm(&*document); - document.animations().send_pending_events(document.window()); + document + .animations() + .send_pending_events(document.window(), can_gc); } } |