Skip to content

Commit c8f6ee4

Browse files
yerkeTG199
authored andcommitted
add CanGc as argument to methods in DissimilarOriginWindow, DocumentFragment, DocumentType, DOMRect, DOMRectReadOnly, DOMStringMap (servo#36395)
add CanGc as argument to methods in DissimilarOriginWindow, DocumentFragment, DocumentType, DOMRect, DOMRectReadOnly, DOMStringMap Testing: These changes do not require tests because they are a refactor. Addressed part of servo#34573. Signed-off-by: Yerkebulan Tulibergenov <[email protected]>
1 parent 773d67f commit c8f6ee4

File tree

7 files changed

+31
-15
lines changed

7 files changed

+31
-15
lines changed

components/script/dom/dissimilaroriginwindow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ impl DissimilarOriginWindowMethods<crate::DomTypeHolder> for DissimilarOriginWin
190190
}
191191

192192
// https://html.spec.whatwg.org/multipage/#dom-location
193-
fn Location(&self) -> DomRoot<DissimilarOriginLocation> {
193+
fn Location(&self, can_gc: CanGc) -> DomRoot<DissimilarOriginLocation> {
194194
self.location
195-
.or_init(|| DissimilarOriginLocation::new(self, CanGc::note()))
195+
.or_init(|| DissimilarOriginLocation::new(self, can_gc))
196196
}
197197
}
198198

components/script/dom/documentfragment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ impl DocumentFragmentMethods<crate::DomTypeHolder> for DocumentFragment {
7676
}
7777

7878
// https://dom.spec.whatwg.org/#dom-parentnode-children
79-
fn Children(&self) -> DomRoot<HTMLCollection> {
79+
fn Children(&self, can_gc: CanGc) -> DomRoot<HTMLCollection> {
8080
let window = self.owner_window();
81-
HTMLCollection::children(&window, self.upcast(), CanGc::note())
81+
HTMLCollection::children(&window, self.upcast(), can_gc)
8282
}
8383

8484
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid

components/script/dom/documenttype.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl DocumentTypeMethods<crate::DomTypeHolder> for DocumentType {
103103
}
104104

105105
// https://dom.spec.whatwg.org/#dom-childnode-remove
106-
fn Remove(&self) {
107-
self.upcast::<Node>().remove_self(CanGc::note());
106+
fn Remove(&self, can_gc: CanGc) {
107+
self.upcast::<Node>().remove_self(can_gc);
108108
}
109109
}

components/script/dom/domrect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ impl DOMRectMethods<crate::DomTypeHolder> for DOMRect {
7575

7676
// https://drafts.fxtf.org/geometry/#dom-domrect-fromrect
7777
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
78-
fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> DomRoot<DOMRect> {
78+
fn FromRect(global: &GlobalScope, other: &DOMRectInit, can_gc: CanGc) -> DomRoot<DOMRect> {
7979
let rect = create_a_domrectreadonly_from_the_dictionary(other);
8080

81-
reflect_dom_object(Box::new(Self { rect }), global, CanGc::note())
81+
reflect_dom_object(Box::new(Self { rect }), global, can_gc)
8282
}
8383

8484
// https://drafts.fxtf.org/geometry/#dom-domrect-x

components/script/dom/domrectreadonly.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,14 @@ impl DOMRectReadOnlyMethods<crate::DomTypeHolder> for DOMRectReadOnly {
104104

105105
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-fromrect
106106
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
107-
fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> DomRoot<DOMRectReadOnly> {
107+
fn FromRect(
108+
global: &GlobalScope,
109+
other: &DOMRectInit,
110+
can_gc: CanGc,
111+
) -> DomRoot<DOMRectReadOnly> {
108112
let dom_rect = create_a_domrectreadonly_from_the_dictionary(other);
109113

110-
reflect_dom_object(Box::new(dom_rect), global, CanGc::note())
114+
reflect_dom_object(Box::new(dom_rect), global, can_gc)
111115
}
112116

113117
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-x

components/script/dom/domstringmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ impl DOMStringMap {
3939
// https://html.spec.whatwg.org/multipage/#domstringmap
4040
impl DOMStringMapMethods<crate::DomTypeHolder> for DOMStringMap {
4141
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-removeitem
42-
fn NamedDeleter(&self, name: DOMString) {
43-
self.element.delete_custom_attr(name, CanGc::note())
42+
fn NamedDeleter(&self, name: DOMString, can_gc: CanGc) {
43+
self.element.delete_custom_attr(name, can_gc)
4444
}
4545

4646
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-setitem

components/script_bindings/codegen/Bindings.conf

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,16 @@ DOMInterfaces = {
161161
'canGc': ['Close', 'CreateElement', 'CreateElementNS', 'ImportNode', 'SetTitle', 'Write', 'Writeln', 'CreateEvent', 'CreateRange', 'Open', 'Open_', 'CreateComment', 'CreateAttribute', 'CreateAttributeNS', 'CreateDocumentFragment', 'CreateTextNode', 'CreateCDATASection', 'CreateProcessingInstruction', 'Prepend', 'Append', 'ReplaceChildren', 'SetBgColor', 'SetFgColor', 'Fonts', 'ElementFromPoint', 'ElementsFromPoint', 'ExitFullscreen', 'CreateExpression', 'CreateNSResolver', 'Evaluate', 'StyleSheets', 'Implementation', 'GetElementsByTagName', 'GetElementsByTagNameNS', 'GetElementsByClassName', 'AdoptNode', 'CreateNodeIterator', 'SetBody', 'GetElementsByName', 'Images', 'Embeds', 'Plugins', 'Links', 'Forms', 'Scripts', 'Anchors', 'Applets', 'Children', 'GetSelection'],
162162
},
163163

164+
'DissimilarOriginWindow': {
165+
'canGc': ['Location']
166+
},
167+
164168
'DocumentFragment': {
165-
'canGc': ['Prepend', 'Append', 'ReplaceChildren']
169+
'canGc': ['Prepend', 'Append', 'ReplaceChildren', 'Children']
166170
},
167171

168172
'DocumentType': {
169-
'canGc': ['Before', 'After', 'ReplaceWith']
173+
'canGc': ['Before', 'After', 'Remove', 'ReplaceWith']
170174
},
171175

172176
'DOMImplementation': {
@@ -197,8 +201,16 @@ DOMInterfaces = {
197201
'canGc': ['FromRect', 'FromQuad', 'GetBounds'],
198202
},
199203

204+
'DOMRect': {
205+
'canGc': ['FromRect'],
206+
},
207+
208+
'DOMRectReadOnly': {
209+
'canGc': ['FromRect'],
210+
},
211+
200212
'DOMStringMap': {
201-
'canGc': ['NamedSetter']
213+
'canGc': ['NamedDeleter', 'NamedSetter']
202214
},
203215

204216
"DOMTokenList": {

0 commit comments

Comments
 (0)