diff options
author | Yerkebulan Tulibergenov <yerkebulan@gmail.com> | 2025-04-13 13:42:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-13 20:42:52 +0000 |
commit | 5d84acc06e2cb4ee6360059aa0497c6f013acbb8 (patch) | |
tree | 15b4e71b308d5cc9ac81ee9247d0a692abd96d93 /components/script | |
parent | d5284dfad9ee90a3cf689f41e8bddf8c98567a3f (diff) | |
download | servo-5d84acc06e2cb4ee6360059aa0497c6f013acbb8.tar.gz servo-5d84acc06e2cb4ee6360059aa0497c6f013acbb8.zip |
add CanGc as argument to methods in HTMLInputElement, HTMLLinkElement (#36504)
add CanGc as argument to methods in HTMLInputElement, HTMLLinkElement
Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573.
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/htmlinputelement.rs | 27 | ||||
-rw-r--r-- | components/script/dom/htmllinkelement.rs | 16 | ||||
-rw-r--r-- | components/script/dom/node.rs | 2 |
3 files changed, 21 insertions, 24 deletions
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<crate::DomTypeHolder> 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<DomRoot<NodeList>> { + fn GetLabels(&self, can_gc: CanGc) -> Option<DomRoot<NodeList>> { if self.input_type() == InputType::Hidden { None } else { @@ -1574,7 +1574,7 @@ impl HTMLInputElementMethods<crate::DomTypeHolder> for HTMLInputElement { NodeList::new_labels_list( self.upcast::<Node>().owner_doc().window(), self.upcast::<HTMLElement>(), - 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::<Node>(), - point_in_target, - CanGc::note(), - ); + let index = + window.text_index_query(self.upcast::<Node>(), 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::<ClipboardEvent>() { 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<DomRoot<CSSStyleSheet>> { + pub(crate) fn get_cssom_stylesheet(&self, can_gc: CanGc) -> Option<DomRoot<CSSStyleSheet>> { 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<crate::DomTypeHolder> for HTMLLinkElement { make_bool_setter!(SetDisabled, "disabled"); // https://html.spec.whatwg.org/multipage/#dom-link-rellist - fn RelList(&self) -> DomRoot<DOMTokenList> { + fn RelList(&self, can_gc: CanGc) -> DomRoot<DOMTokenList> { self.rel_list.or_init(|| { DOMTokenList::new( self.upcast(), @@ -624,7 +624,7 @@ impl HTMLLinkElementMethods<crate::DomTypeHolder> for HTMLLinkElement { Atom::from("prerender"), Atom::from("stylesheet"), ]), - CanGc::note(), + can_gc, ) }) } @@ -666,8 +666,8 @@ impl HTMLLinkElementMethods<crate::DomTypeHolder> for HTMLLinkElement { make_setter!(SetReferrerPolicy, "referrerpolicy"); // https://drafts.csswg.org/cssom/#dom-linkstyle-sheet - fn GetSheet(&self) -> Option<DomRoot<DOMStyleSheet>> { - self.get_cssom_stylesheet().map(DomRoot::upcast) + fn GetSheet(&self, can_gc: CanGc) -> Option<DomRoot<DOMStyleSheet>> { + 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::<HTMLStyleElement>() { node.get_cssom_stylesheet() } else if let Some(node) = self.downcast::<HTMLLinkElement>() { - node.get_cssom_stylesheet() + node.get_cssom_stylesheet(CanGc::note()) } else { None } |