diff options
author | chickenleaf <lashwinib@gmail.com> | 2024-10-24 04:14:50 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-23 22:44:50 +0000 |
commit | bb4932026cef55aefd95a5a627a944e1ad26c6f2 (patch) | |
tree | 1bcdd4a258beb01c3eb788d94d3698e4d3ebb2b9 /components/script/dom/htmloptionscollection.rs | |
parent | 3ed778150fbaa2656d38e4cda8325797d14d27c1 (diff) | |
download | servo-bb4932026cef55aefd95a5a627a944e1ad26c6f2.tar.gz servo-bb4932026cef55aefd95a5a627a944e1ad26c6f2.zip |
cangc fixes in node.rs (#33984)
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
Diffstat (limited to 'components/script/dom/htmloptionscollection.rs')
-rw-r--r-- | components/script/dom/htmloptionscollection.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs index 58155ab3183..eca2d217a3f 100644 --- a/components/script/dom/htmloptionscollection.rs +++ b/components/script/dom/htmloptionscollection.rs @@ -26,6 +26,7 @@ use crate::dom::htmloptionelement::HTMLOptionElement; use crate::dom::htmlselectelement::HTMLSelectElement; use crate::dom::node::{document_from_node, Node}; use crate::dom::window::Window; +use crate::script_runtime::CanGc; #[dom_struct] pub struct HTMLOptionsCollection { @@ -53,12 +54,13 @@ impl HTMLOptionsCollection { ) } - fn add_new_elements(&self, count: u32) -> ErrorResult { + fn add_new_elements(&self, count: u32, can_gc: CanGc) -> ErrorResult { let root = self.upcast().root_node(); let document = document_from_node(&*root); for _ in 0..count { - let element = HTMLOptionElement::new(local_name!("option"), None, &document, None); + let element = + HTMLOptionElement::new(local_name!("option"), None, &document, None, can_gc); let node = element.upcast::<Node>(); root.AppendChild(node)?; } @@ -91,7 +93,12 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection { } // https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-setter - fn IndexedSetter(&self, index: u32, value: Option<&HTMLOptionElement>) -> ErrorResult { + fn IndexedSetter( + &self, + index: u32, + value: Option<&HTMLOptionElement>, + can_gc: CanGc, + ) -> ErrorResult { if let Some(value) = value { // Step 2 let length = self.upcast().Length(); @@ -101,7 +108,7 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection { // Step 4 if n > 0 { - self.add_new_elements(n as u32)?; + self.add_new_elements(n as u32, can_gc)?; } // Step 5 @@ -128,7 +135,7 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection { } /// <https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-length> - fn SetLength(&self, length: u32) { + fn SetLength(&self, length: u32, can_gc: CanGc) { let current_length = self.upcast().Length(); let delta = length as i32 - current_length as i32; match delta.cmp(&0) { @@ -140,7 +147,7 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection { }, Ordering::Greater => { // new length is higher - adding new option elements - self.add_new_elements(delta as u32).unwrap(); + self.add_new_elements(delta as u32, can_gc).unwrap(); }, _ => {}, } |