diff --git a/components/script/dom/elementinternals.rs b/components/script/dom/elementinternals.rs index bb3795b5bab..d2f019b4001 100644 --- a/components/script/dom/elementinternals.rs +++ b/components/script/dom/elementinternals.rs @@ -234,6 +234,7 @@ impl ElementInternalsMethods for ElementInternals { flags: &ValidityStateFlags, message: Option, anchor: Option<&HTMLElement>, + can_gc: CanGc, ) -> ErrorResult { // Steps 1-2: Check form-associated custom element if !self.is_target_form_associated() { @@ -253,7 +254,7 @@ impl ElementInternalsMethods for ElementInternals { // Step 4: For each entry `flag` → `value` of `flags`, set element's validity flag with the name // `flag` to `value`. self.validity_state().update_invalid_flags(bits); - self.validity_state().update_pseudo_classes(CanGc::note()); + self.validity_state().update_pseudo_classes(can_gc); // Step 5: Set element's validation message to the empty string if message is not given // or all of element's validity flags are false, or to message otherwise. @@ -309,7 +310,7 @@ impl ElementInternalsMethods for ElementInternals { } /// - fn GetLabels(&self) -> Fallible> { + fn GetLabels(&self, can_gc: CanGc) -> Fallible> { if !self.is_target_form_associated() { return Err(Error::NotSupported); } @@ -317,7 +318,7 @@ impl ElementInternalsMethods for ElementInternals { NodeList::new_labels_list( self.target_element.upcast::().owner_doc().window(), &self.target_element, - CanGc::note(), + can_gc, ) })) } diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 1ff9a7334be..a474cd30f95 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -2126,8 +2126,8 @@ impl GlobalScope { unsafe { SafeJSContext::from_ptr(cx) } } - pub(crate) fn crypto(&self) -> DomRoot { - self.crypto.or_init(|| Crypto::new(self, CanGc::note())) + pub(crate) fn crypto(&self, can_gc: CanGc) -> DomRoot { + self.crypto.or_init(|| Crypto::new(self, can_gc)) } pub(crate) fn live_devtools_updates(&self) -> bool { @@ -2994,6 +2994,7 @@ impl GlobalScope { device: WebGPUDevice, reason: DeviceLostReason, msg: String, + can_gc: CanGc, ) { let reason = match reason { DeviceLostReason::Unknown => GPUDeviceLostReason::Unknown, @@ -3007,7 +3008,7 @@ impl GlobalScope { .expect("GPUDevice should still be in devices hashmap") .root() { - device.lose(reason, msg, CanGc::note()); + device.lose(reason, msg, can_gc); } } diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 511d4fe7d95..5a59c9254a0 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -145,7 +145,7 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement { } // https://html.spec.whatwg.org/multipage/#dom-a-rellist - fn RelList(&self) -> DomRoot { + fn RelList(&self, can_gc: CanGc) -> DomRoot { self.rel_list.or_init(|| { DOMTokenList::new( self.upcast(), @@ -155,7 +155,7 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement { Atom::from("noreferrer"), Atom::from("opener"), ]), - CanGc::note(), + can_gc, ) }) } diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 1d80078b246..a9d94cbd7b2 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -362,7 +362,7 @@ impl HTMLAreaElementMethods for HTMLAreaElement { } /// - fn RelList(&self) -> DomRoot { + fn RelList(&self, can_gc: CanGc) -> DomRoot { self.rel_list.or_init(|| { DOMTokenList::new( self.upcast(), @@ -372,7 +372,7 @@ impl HTMLAreaElementMethods for HTMLAreaElement { Atom::from("noreferrer"), Atom::from("opener"), ]), - CanGc::note(), + can_gc, ) }) } diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index 6916bef126c..09d0ae6e73f 100644 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -261,7 +261,7 @@ impl VirtualMethods for HTMLButtonElement { el.check_ancestors_disabled_state_for_form_control(); }, } - el.update_sequentially_focusable_status(CanGc::note()); + el.update_sequentially_focusable_status(can_gc); self.validity_state() .perform_validation_and_update(ValidationFlags::all(), can_gc); }, diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 7d459349567..77e8b412146 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -323,7 +323,7 @@ impl HTMLCanvasElement { } #[cfg(feature = "webgpu")] - fn get_or_init_webgpu_context(&self) -> Option> { + fn get_or_init_webgpu_context(&self, can_gc: CanGc) -> Option> { if let Some(ctx) = self.context() { return match *ctx { CanvasContext::WebGPU(ref ctx) => Some(DomRoot::from_ref(ctx)), @@ -339,7 +339,7 @@ impl HTMLCanvasElement { .recv() .expect("Failed to get WebGPU channel") .map(|channel| { - let context = GPUCanvasContext::new(&global_scope, self, channel, CanGc::note()); + let context = GPUCanvasContext::new(&global_scope, self, channel, can_gc); *self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context))); context }) @@ -477,7 +477,7 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { // When setting the value of the width or height attribute, if the context mode of the canvas element // is set to placeholder, the user agent must throw an "InvalidStateError" DOMException and leave the // attribute's value unchanged. - fn SetWidth(&self, value: u32) -> Fallible<()> { + fn SetWidth(&self, value: u32, can_gc: CanGc) -> Fallible<()> { if let Some(CanvasContext::Placeholder(_)) = *self.context.borrow() { return Err(Error::InvalidState); } @@ -488,7 +488,7 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { value }; let element = self.upcast::(); - element.set_uint_attribute(&html5ever::local_name!("width"), value, CanGc::note()); + element.set_uint_attribute(&html5ever::local_name!("width"), value, can_gc); Ok(()) } @@ -496,7 +496,7 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { make_uint_getter!(Height, "height", DEFAULT_HEIGHT); // https://html.spec.whatwg.org/multipage/#dom-canvas-height - fn SetHeight(&self, value: u32) -> Fallible<()> { + fn SetHeight(&self, value: u32, can_gc: CanGc) -> Fallible<()> { if let Some(CanvasContext::Placeholder(_)) = *self.context.borrow() { return Err(Error::InvalidState); } @@ -507,7 +507,7 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { value }; let element = self.upcast::(); - element.set_uint_attribute(&html5ever::local_name!("height"), value, CanGc::note()); + element.set_uint_attribute(&html5ever::local_name!("height"), value, can_gc); Ok(()) } @@ -536,7 +536,7 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { .map(RenderingContext::WebGL2RenderingContext), #[cfg(feature = "webgpu")] "webgpu" => self - .get_or_init_webgpu_context() + .get_or_init_webgpu_context(can_gc) .map(RenderingContext::GPUCanvasContext), _ => None, }) @@ -647,7 +647,7 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { } /// - fn TransferControlToOffscreen(&self) -> Fallible> { + fn TransferControlToOffscreen(&self, can_gc: CanGc) -> Fallible> { if self.context.borrow().is_some() { // Step 1. // If this canvas element's context mode is not set to none, throw an "InvalidStateError" DOMException. @@ -665,7 +665,7 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement { self.Width().into(), self.Height().into(), Some(&Dom::from_ref(self)), - CanGc::note(), + can_gc, ); // Step 4. Set this canvas element's context mode to placeholder. *self.context.borrow_mut() = Some(CanvasContext::Placeholder(offscreen_canvas.as_traced())); diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 33a46af0ffe..227bdd2bdc1 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -954,7 +954,7 @@ impl WindowMethods for Window { // https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-GlobalCrypto fn Crypto(&self) -> DomRoot { - self.as_global_scope().crypto() + self.as_global_scope().crypto(CanGc::note()) } // https://html.spec.whatwg.org/multipage/#dom-frameelement diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index a857b261cd0..275a9cb0741 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -351,7 +351,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope { // https://html.spec.whatwg.org/multipage/#dfn-Crypto fn Crypto(&self) -> DomRoot { - self.upcast::().crypto() + self.upcast::().crypto(CanGc::note()) } // https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 5d6c1df578c..6cae83ebe95 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1948,7 +1948,7 @@ impl ScriptThread { msg, } => { let global = self.documents.borrow().find_global(pipeline_id).unwrap(); - global.gpu_device_lost(device, reason, msg); + global.gpu_device_lost(device, reason, msg, can_gc); }, WebGPUMsg::UncapturedError { device, diff --git a/components/script_bindings/codegen/Bindings.conf b/components/script_bindings/codegen/Bindings.conf index 3ade5db811a..d2ef9a769fa 100644 --- a/components/script_bindings/codegen/Bindings.conf +++ b/components/script_bindings/codegen/Bindings.conf @@ -226,7 +226,7 @@ DOMInterfaces = { }, 'ElementInternals': { - 'canGc': ['CheckValidity', 'ReportValidity'], + 'canGc': ['CheckValidity', 'GetLabels', 'SetValidity', 'ReportValidity'], }, 'EventSource': { @@ -319,11 +319,11 @@ DOMInterfaces = { }, "HTMLAnchorElement": { - "canGc": ["SetText","SetRel","SetHref", 'SetHash', 'SetHost', 'SetHostname', 'SetPassword', 'SetPathname', 'SetPort', 'SetProtocol', 'SetSearch', 'SetUsername'] + "canGc": ["SetText","SetRel","SetHref", 'SetHash', 'SetHost', 'SetHostname', 'SetPassword', 'SetPathname', 'SetPort', 'SetProtocol', 'SetSearch', 'SetUsername', 'RelList'] }, "HTMLAreaElement": { - "canGc": ['SetText', 'SetRel', 'SetHref', 'SetHash', 'SetHost', 'SetHostname', 'SetPassword', 'SetPathname', 'SetPort', 'SetProtocol', 'SetSearch', 'SetUsername'] + "canGc": ['SetText', 'SetRel', 'SetHref', 'SetHash', 'SetHost', 'SetHostname', 'SetPassword', 'SetPathname', 'SetPort', 'SetProtocol', 'SetSearch', 'SetUsername', 'RelList'] }, "HTMLBodyElement": { @@ -335,7 +335,7 @@ DOMInterfaces = { }, 'HTMLCanvasElement': { - 'canGc': ['CaptureStream', 'GetContext'], + 'canGc': ['CaptureStream', 'GetContext', 'SetHeight', 'SetWidth', 'TransferControlToOffscreen'], }, 'HTMLDialogElement': {