@@ -2964,9 +2964,14 @@ impl Document {
2964
2964
2965
2965
/// <https://html.spec.whatwg.org/multipage/#the-end> step 3.
2966
2966
/// <https://html.spec.whatwg.org/multipage/#prepare-a-script> step 22.d.
2967
- pub ( crate ) fn deferred_script_loaded ( & self , element : & HTMLScriptElement , result : ScriptResult ) {
2967
+ pub ( crate ) fn deferred_script_loaded (
2968
+ & self ,
2969
+ element : & HTMLScriptElement ,
2970
+ result : ScriptResult ,
2971
+ can_gc : CanGc ,
2972
+ ) {
2968
2973
self . deferred_scripts . loaded ( element, result) ;
2969
- self . process_deferred_scripts ( CanGc :: note ( ) ) ;
2974
+ self . process_deferred_scripts ( can_gc ) ;
2970
2975
}
2971
2976
2972
2977
/// <https://html.spec.whatwg.org/multipage/#the-end> step 3.
@@ -4855,20 +4860,20 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
4855
4860
}
4856
4861
4857
4862
// https://drafts.csswg.org/cssom/#dom-document-stylesheets
4858
- fn StyleSheets ( & self ) -> DomRoot < StyleSheetList > {
4863
+ fn StyleSheets ( & self , can_gc : CanGc ) -> DomRoot < StyleSheetList > {
4859
4864
self . stylesheet_list . or_init ( || {
4860
4865
StyleSheetList :: new (
4861
4866
& self . window ,
4862
4867
StyleSheetListOwner :: Document ( Dom :: from_ref ( self ) ) ,
4863
- CanGc :: note ( ) ,
4868
+ can_gc ,
4864
4869
)
4865
4870
} )
4866
4871
}
4867
4872
4868
4873
// https://dom.spec.whatwg.org/#dom-document-implementation
4869
- fn Implementation ( & self ) -> DomRoot < DOMImplementation > {
4874
+ fn Implementation ( & self , can_gc : CanGc ) -> DomRoot < DOMImplementation > {
4870
4875
self . implementation
4871
- . or_init ( || DOMImplementation :: new ( self , CanGc :: note ( ) ) )
4876
+ . or_init ( || DOMImplementation :: new ( self , can_gc ) )
4872
4877
}
4873
4878
4874
4879
// https://dom.spec.whatwg.org/#dom-document-url
@@ -4996,7 +5001,11 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
4996
5001
}
4997
5002
4998
5003
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagname
4999
- fn GetElementsByTagName ( & self , qualified_name : DOMString ) -> DomRoot < HTMLCollection > {
5004
+ fn GetElementsByTagName (
5005
+ & self ,
5006
+ qualified_name : DOMString ,
5007
+ can_gc : CanGc ,
5008
+ ) -> DomRoot < HTMLCollection > {
5000
5009
let qualified_name = LocalName :: from ( & * qualified_name) ;
5001
5010
if let Some ( entry) = self . tag_map . borrow_mut ( ) . get ( & qualified_name) {
5002
5011
return DomRoot :: from_ref ( entry) ;
@@ -5005,7 +5014,7 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5005
5014
& self . window ,
5006
5015
self . upcast ( ) ,
5007
5016
qualified_name. clone ( ) ,
5008
- CanGc :: note ( ) ,
5017
+ can_gc ,
5009
5018
) ;
5010
5019
self . tag_map
5011
5020
. borrow_mut ( )
@@ -5018,27 +5027,24 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5018
5027
& self ,
5019
5028
maybe_ns : Option < DOMString > ,
5020
5029
tag_name : DOMString ,
5030
+ can_gc : CanGc ,
5021
5031
) -> DomRoot < HTMLCollection > {
5022
5032
let ns = namespace_from_domstring ( maybe_ns) ;
5023
5033
let local = LocalName :: from ( tag_name) ;
5024
5034
let qname = QualName :: new ( None , ns, local) ;
5025
5035
if let Some ( collection) = self . tagns_map . borrow ( ) . get ( & qname) {
5026
5036
return DomRoot :: from_ref ( collection) ;
5027
5037
}
5028
- let result = HTMLCollection :: by_qual_tag_name (
5029
- & self . window ,
5030
- self . upcast ( ) ,
5031
- qname. clone ( ) ,
5032
- CanGc :: note ( ) ,
5033
- ) ;
5038
+ let result =
5039
+ HTMLCollection :: by_qual_tag_name ( & self . window , self . upcast ( ) , qname. clone ( ) , can_gc) ;
5034
5040
self . tagns_map
5035
5041
. borrow_mut ( )
5036
5042
. insert ( qname, Dom :: from_ref ( & * result) ) ;
5037
5043
result
5038
5044
}
5039
5045
5040
5046
// https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
5041
- fn GetElementsByClassName ( & self , classes : DOMString ) -> DomRoot < HTMLCollection > {
5047
+ fn GetElementsByClassName ( & self , classes : DOMString , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5042
5048
let class_atoms: Vec < Atom > = split_html_space_chars ( & classes) . map ( Atom :: from) . collect ( ) ;
5043
5049
if let Some ( collection) = self . classes_map . borrow ( ) . get ( & class_atoms) {
5044
5050
return DomRoot :: from_ref ( collection) ;
@@ -5047,7 +5053,7 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5047
5053
& self . window ,
5048
5054
self . upcast ( ) ,
5049
5055
class_atoms. clone ( ) ,
5050
- CanGc :: note ( ) ,
5056
+ can_gc ,
5051
5057
) ;
5052
5058
self . classes_map
5053
5059
. borrow_mut ( )
@@ -5257,7 +5263,7 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5257
5263
}
5258
5264
5259
5265
// https://dom.spec.whatwg.org/#dom-document-adoptnode
5260
- fn AdoptNode ( & self , node : & Node ) -> Fallible < DomRoot < Node > > {
5266
+ fn AdoptNode ( & self , node : & Node , can_gc : CanGc ) -> Fallible < DomRoot < Node > > {
5261
5267
// Step 1.
5262
5268
if node. is :: < Document > ( ) {
5263
5269
return Err ( Error :: NotSupported ) ;
@@ -5269,7 +5275,7 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5269
5275
}
5270
5276
5271
5277
// Step 3.
5272
- Node :: adopt ( node, self , CanGc :: note ( ) ) ;
5278
+ Node :: adopt ( node, self , can_gc ) ;
5273
5279
5274
5280
// Step 4.
5275
5281
Ok ( DomRoot :: from_ref ( node) )
@@ -5358,8 +5364,9 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5358
5364
root : & Node ,
5359
5365
what_to_show : u32 ,
5360
5366
filter : Option < Rc < NodeFilter > > ,
5367
+ can_gc : CanGc ,
5361
5368
) -> DomRoot < NodeIterator > {
5362
- NodeIterator :: new ( self , root, what_to_show, filter, CanGc :: note ( ) )
5369
+ NodeIterator :: new ( self , root, what_to_show, filter, can_gc )
5363
5370
}
5364
5371
5365
5372
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
@@ -5476,7 +5483,7 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5476
5483
}
5477
5484
5478
5485
// https://html.spec.whatwg.org/multipage/#dom-document-body
5479
- fn SetBody ( & self , new_body : Option < & HTMLElement > ) -> ErrorResult {
5486
+ fn SetBody ( & self , new_body : Option < & HTMLElement > , can_gc : CanGc ) -> ErrorResult {
5480
5487
// Step 1.
5481
5488
let new_body = match new_body {
5482
5489
Some ( new_body) => new_body,
@@ -5502,7 +5509,7 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5502
5509
// Step 3.
5503
5510
( Some ( ref root) , Some ( child) ) => {
5504
5511
let root = root. upcast :: < Node > ( ) ;
5505
- root. ReplaceChild ( new_body. upcast ( ) , child. upcast ( ) , CanGc :: note ( ) )
5512
+ root. ReplaceChild ( new_body. upcast ( ) , child. upcast ( ) , can_gc )
5506
5513
. unwrap ( ) ;
5507
5514
} ,
5508
5515
@@ -5512,48 +5519,48 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5512
5519
// Step 5.
5513
5520
( Some ( ref root) , & None ) => {
5514
5521
let root = root. upcast :: < Node > ( ) ;
5515
- root. AppendChild ( new_body. upcast ( ) , CanGc :: note ( ) ) . unwrap ( ) ;
5522
+ root. AppendChild ( new_body. upcast ( ) , can_gc ) . unwrap ( ) ;
5516
5523
} ,
5517
5524
}
5518
5525
Ok ( ( ) )
5519
5526
}
5520
5527
5521
5528
// https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname
5522
- fn GetElementsByName ( & self , name : DOMString ) -> DomRoot < NodeList > {
5523
- NodeList :: new_elements_by_name_list ( self . window ( ) , self , name, CanGc :: note ( ) )
5529
+ fn GetElementsByName ( & self , name : DOMString , can_gc : CanGc ) -> DomRoot < NodeList > {
5530
+ NodeList :: new_elements_by_name_list ( self . window ( ) , self , name, can_gc )
5524
5531
}
5525
5532
5526
5533
// https://html.spec.whatwg.org/multipage/#dom-document-images
5527
- fn Images ( & self ) -> DomRoot < HTMLCollection > {
5534
+ fn Images ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5528
5535
self . images . or_init ( || {
5529
5536
HTMLCollection :: new_with_filter_fn (
5530
5537
& self . window ,
5531
5538
self . upcast ( ) ,
5532
5539
|element, _| element. is :: < HTMLImageElement > ( ) ,
5533
- CanGc :: note ( ) ,
5540
+ can_gc ,
5534
5541
)
5535
5542
} )
5536
5543
}
5537
5544
5538
5545
// https://html.spec.whatwg.org/multipage/#dom-document-embeds
5539
- fn Embeds ( & self ) -> DomRoot < HTMLCollection > {
5546
+ fn Embeds ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5540
5547
self . embeds . or_init ( || {
5541
5548
HTMLCollection :: new_with_filter_fn (
5542
5549
& self . window ,
5543
5550
self . upcast ( ) ,
5544
5551
|element, _| element. is :: < HTMLEmbedElement > ( ) ,
5545
- CanGc :: note ( ) ,
5552
+ can_gc ,
5546
5553
)
5547
5554
} )
5548
5555
}
5549
5556
5550
5557
// https://html.spec.whatwg.org/multipage/#dom-document-plugins
5551
- fn Plugins ( & self ) -> DomRoot < HTMLCollection > {
5552
- self . Embeds ( )
5558
+ fn Plugins ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5559
+ self . Embeds ( can_gc )
5553
5560
}
5554
5561
5555
5562
// https://html.spec.whatwg.org/multipage/#dom-document-links
5556
- fn Links ( & self ) -> DomRoot < HTMLCollection > {
5563
+ fn Links ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5557
5564
self . links . or_init ( || {
5558
5565
HTMLCollection :: new_with_filter_fn (
5559
5566
& self . window ,
@@ -5562,53 +5569,53 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5562
5569
( element. is :: < HTMLAnchorElement > ( ) || element. is :: < HTMLAreaElement > ( ) ) &&
5563
5570
element. has_attribute ( & local_name ! ( "href" ) )
5564
5571
} ,
5565
- CanGc :: note ( ) ,
5572
+ can_gc ,
5566
5573
)
5567
5574
} )
5568
5575
}
5569
5576
5570
5577
// https://html.spec.whatwg.org/multipage/#dom-document-forms
5571
- fn Forms ( & self ) -> DomRoot < HTMLCollection > {
5578
+ fn Forms ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5572
5579
self . forms . or_init ( || {
5573
5580
HTMLCollection :: new_with_filter_fn (
5574
5581
& self . window ,
5575
5582
self . upcast ( ) ,
5576
5583
|element, _| element. is :: < HTMLFormElement > ( ) ,
5577
- CanGc :: note ( ) ,
5584
+ can_gc ,
5578
5585
)
5579
5586
} )
5580
5587
}
5581
5588
5582
5589
// https://html.spec.whatwg.org/multipage/#dom-document-scripts
5583
- fn Scripts ( & self ) -> DomRoot < HTMLCollection > {
5590
+ fn Scripts ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5584
5591
self . scripts . or_init ( || {
5585
5592
HTMLCollection :: new_with_filter_fn (
5586
5593
& self . window ,
5587
5594
self . upcast ( ) ,
5588
5595
|element, _| element. is :: < HTMLScriptElement > ( ) ,
5589
- CanGc :: note ( ) ,
5596
+ can_gc ,
5590
5597
)
5591
5598
} )
5592
5599
}
5593
5600
5594
5601
// https://html.spec.whatwg.org/multipage/#dom-document-anchors
5595
- fn Anchors ( & self ) -> DomRoot < HTMLCollection > {
5602
+ fn Anchors ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5596
5603
self . anchors . or_init ( || {
5597
5604
HTMLCollection :: new_with_filter_fn (
5598
5605
& self . window ,
5599
5606
self . upcast ( ) ,
5600
5607
|element, _| {
5601
5608
element. is :: < HTMLAnchorElement > ( ) && element. has_attribute ( & local_name ! ( "href" ) )
5602
5609
} ,
5603
- CanGc :: note ( ) ,
5610
+ can_gc ,
5604
5611
)
5605
5612
} )
5606
5613
}
5607
5614
5608
5615
// https://html.spec.whatwg.org/multipage/#dom-document-applets
5609
- fn Applets ( & self ) -> DomRoot < HTMLCollection > {
5616
+ fn Applets ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5610
5617
self . applets
5611
- . or_init ( || HTMLCollection :: always_empty ( & self . window , self . upcast ( ) , CanGc :: note ( ) ) )
5618
+ . or_init ( || HTMLCollection :: always_empty ( & self . window , self . upcast ( ) , can_gc ) )
5612
5619
}
5613
5620
5614
5621
// https://html.spec.whatwg.org/multipage/#dom-document-location
@@ -5621,8 +5628,8 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
5621
5628
}
5622
5629
5623
5630
// https://dom.spec.whatwg.org/#dom-parentnode-children
5624
- fn Children ( & self ) -> DomRoot < HTMLCollection > {
5625
- HTMLCollection :: children ( & self . window , self . upcast ( ) , CanGc :: note ( ) )
5631
+ fn Children ( & self , can_gc : CanGc ) -> DomRoot < HTMLCollection > {
5632
+ HTMLCollection :: children ( & self . window , self . upcast ( ) , can_gc )
5626
5633
}
5627
5634
5628
5635
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
@@ -6192,12 +6199,9 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
6192
6199
}
6193
6200
6194
6201
// https://w3c.github.io/selection-api/#dom-document-getselection
6195
- fn GetSelection ( & self ) -> Option < DomRoot < Selection > > {
6202
+ fn GetSelection ( & self , can_gc : CanGc ) -> Option < DomRoot < Selection > > {
6196
6203
if self . has_browsing_context {
6197
- Some (
6198
- self . selection
6199
- . or_init ( || Selection :: new ( self , CanGc :: note ( ) ) ) ,
6200
- )
6204
+ Some ( self . selection . or_init ( || Selection :: new ( self , can_gc) ) )
6201
6205
} else {
6202
6206
None
6203
6207
}
0 commit comments