diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index e12ad21631a..42165499032 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -1566,7 +1566,7 @@ impl HTMLInputElementMethods for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#dom-lfe-labels // Different from make_labels_getter because this one // conditionally returns null. - fn GetLabels(&self) -> Option> { + fn GetLabels(&self, can_gc: CanGc) -> Option> { if self.input_type() == InputType::Hidden { None } else { @@ -1574,7 +1574,7 @@ impl HTMLInputElementMethods for HTMLInputElement { NodeList::new_labels_list( self.upcast::().owner_doc().window(), self.upcast::(), - CanGc::note(), + can_gc, ) })) } @@ -2378,7 +2378,7 @@ impl VirtualMethods for HTMLInputElement { el.set_read_write_state(read_write); } - el.update_sequentially_focusable_status(CanGc::note()); + el.update_sequentially_focusable_status(can_gc); }, local_name!("checked") if !self.checked_changed.get() => { let checked_state = match mutation { @@ -2416,7 +2416,7 @@ impl VirtualMethods for HTMLInputElement { if new_type == InputType::File { let window = self.owner_window(); - let filelist = FileList::new(&window, vec![], CanGc::note()); + let filelist = FileList::new(&window, vec![], can_gc); self.filelist.set(Some(&filelist)); } @@ -2425,7 +2425,7 @@ impl VirtualMethods for HTMLInputElement { // Step 1 (&ValueMode::Value, false, ValueMode::Default) | (&ValueMode::Value, false, ValueMode::DefaultOn) => { - self.SetValue(old_idl_value, CanGc::note()) + self.SetValue(old_idl_value, can_gc) .expect("Failed to set input value on type change to a default ValueMode."); }, @@ -2437,7 +2437,7 @@ impl VirtualMethods for HTMLInputElement { .map_or(DOMString::from(""), |a| { DOMString::from(a.summarize().value) }), - CanGc::note(), + can_gc, ) .expect( "Failed to set input value on type change to ValueMode::Value.", @@ -2449,7 +2449,7 @@ impl VirtualMethods for HTMLInputElement { (_, _, ValueMode::Filename) if old_value_mode != ValueMode::Filename => { - self.SetValue(DOMString::from(""), CanGc::note()) + self.SetValue(DOMString::from(""), can_gc) .expect("Failed to set input value on type change to ValueMode::Filename."); }, _ => {}, @@ -2642,11 +2642,8 @@ impl VirtualMethods for HTMLInputElement { // now. if let Some(point_in_target) = mouse_event.point_in_target() { let window = self.owner_window(); - let index = window.text_index_query( - self.upcast::(), - point_in_target, - CanGc::note(), - ); + let index = + window.text_index_query(self.upcast::(), point_in_target, can_gc); // Position the caret at the click position or at the end of the current // value. let edit_point_index = match index { @@ -2672,7 +2669,7 @@ impl VirtualMethods for HTMLInputElement { let action = self.textinput.borrow_mut().handle_keydown(keyevent); match action { TriggerDefaultAction => { - self.implicit_submission(CanGc::note()); + self.implicit_submission(can_gc); }, DispatchInput => { self.value_dirty.set(true); @@ -2725,7 +2722,7 @@ impl VirtualMethods for HTMLInputElement { } } else if let Some(clipboard_event) = event.downcast::() { if !event.DefaultPrevented() { - handle_text_clipboard_action(self, &self.textinput, clipboard_event, CanGc::note()); + handle_text_clipboard_action(self, &self.textinput, clipboard_event, can_gc); } } @@ -2988,7 +2985,7 @@ impl Activatable for HTMLInputElement { form_owner.submit( SubmittedFrom::NotFromForm, FormSubmitterElement::Input(self), - CanGc::note(), + can_gc, ) } }, diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index ed1fcf1349d..07d7a5d7305 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -179,7 +179,7 @@ impl HTMLLinkElement { self.stylesheet.borrow().clone() } - pub(crate) fn get_cssom_stylesheet(&self) -> Option> { + pub(crate) fn get_cssom_stylesheet(&self, can_gc: CanGc) -> Option> { self.get_stylesheet().map(|sheet| { self.cssom_stylesheet.or_init(|| { CSSStyleSheet::new( @@ -189,7 +189,7 @@ impl HTMLLinkElement { None, // todo handle location None, // todo handle title sheet, - CanGc::note(), + can_gc, ) }) }) @@ -541,7 +541,7 @@ impl StylesheetOwner for HTMLLinkElement { } fn referrer_policy(&self) -> ReferrerPolicy { - if self.RelList().Contains("noreferrer".into()) { + if self.RelList(CanGc::note()).Contains("noreferrer".into()) { return ReferrerPolicy::NoReferrer; } @@ -549,7 +549,7 @@ impl StylesheetOwner for HTMLLinkElement { } fn set_origin_clean(&self, origin_clean: bool) { - if let Some(stylesheet) = self.get_cssom_stylesheet() { + if let Some(stylesheet) = self.get_cssom_stylesheet(CanGc::note()) { stylesheet.set_origin_clean(origin_clean); } } @@ -602,7 +602,7 @@ impl HTMLLinkElementMethods for HTMLLinkElement { make_bool_setter!(SetDisabled, "disabled"); // https://html.spec.whatwg.org/multipage/#dom-link-rellist - fn RelList(&self) -> DomRoot { + fn RelList(&self, can_gc: CanGc) -> DomRoot { self.rel_list.or_init(|| { DOMTokenList::new( self.upcast(), @@ -624,7 +624,7 @@ impl HTMLLinkElementMethods for HTMLLinkElement { Atom::from("prerender"), Atom::from("stylesheet"), ]), - CanGc::note(), + can_gc, ) }) } @@ -666,8 +666,8 @@ impl HTMLLinkElementMethods for HTMLLinkElement { make_setter!(SetReferrerPolicy, "referrerpolicy"); // https://drafts.csswg.org/cssom/#dom-linkstyle-sheet - fn GetSheet(&self) -> Option> { - self.get_cssom_stylesheet().map(DomRoot::upcast) + fn GetSheet(&self, can_gc: CanGc) -> Option> { + self.get_cssom_stylesheet(can_gc).map(DomRoot::upcast) } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 016787799c6..bcaff69adb9 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1367,7 +1367,7 @@ impl Node { if let Some(node) = self.downcast::() { node.get_cssom_stylesheet() } else if let Some(node) = self.downcast::() { - node.get_cssom_stylesheet() + node.get_cssom_stylesheet(CanGc::note()) } else { None } diff --git a/components/script_bindings/codegen/Bindings.conf b/components/script_bindings/codegen/Bindings.conf index 867cb381c86..26a38d03561 100644 --- a/components/script_bindings/codegen/Bindings.conf +++ b/components/script_bindings/codegen/Bindings.conf @@ -375,11 +375,11 @@ DOMInterfaces = { }, 'HTMLInputElement': { - 'canGc': ['ReportValidity', 'SetValue', 'SetValueAsNumber', 'SetValueAsDate', 'StepUp', 'StepDown', 'CheckValidity', 'ReportValidity', 'SelectFiles'], + 'canGc': ['ReportValidity', 'SetValue', 'SetValueAsNumber', 'SetValueAsDate', 'StepUp', 'StepDown', 'CheckValidity', 'ReportValidity', 'SelectFiles', 'GetLabels'], }, 'HTMLLinkElement': { - 'canGc': ['SetRel', 'SetCrossOrigin'], + 'canGc': ['GetSheet', 'SetRel', 'SetCrossOrigin', 'RelList'], }, 'HTMLMediaElement': {