mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Start marking functions that can transitively trigger a GC (#33144)
* Mark JS reflector wrappers as CanGc. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Propagate CanGc from reflect_dom_object_with_proto. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Mark DOM constructors as GC operations. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
9a1051c917
commit
60ef6bc461
140 changed files with 1336 additions and 304 deletions
|
@ -23,6 +23,7 @@ use crate::dom::blob::Blob;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::urlhelper::UrlHelper;
|
||||
use crate::dom::urlsearchparams::URLSearchParams;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
/// <https://url.spec.whatwg.org/#url>
|
||||
#[dom_struct]
|
||||
|
@ -46,8 +47,13 @@ impl URL {
|
|||
}
|
||||
}
|
||||
|
||||
fn new(global: &GlobalScope, proto: Option<HandleObject>, url: ServoUrl) -> DomRoot<URL> {
|
||||
reflect_dom_object_with_proto(Box::new(URL::new_inherited(url)), global, proto)
|
||||
fn new(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
url: ServoUrl,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<URL> {
|
||||
reflect_dom_object_with_proto(Box::new(URL::new_inherited(url)), global, proto, can_gc)
|
||||
}
|
||||
|
||||
pub fn query_pairs(&self) -> Vec<(String, String)> {
|
||||
|
@ -79,6 +85,7 @@ impl URL {
|
|||
pub fn Constructor(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
can_gc: CanGc,
|
||||
url: USVString,
|
||||
base: Option<USVString>,
|
||||
) -> Fallible<DomRoot<URL>> {
|
||||
|
@ -113,7 +120,7 @@ impl URL {
|
|||
// Step 7. Set this’s query object’s URL object to this.
|
||||
|
||||
// Step 4. Set this’s URL to parsedURL.
|
||||
Ok(URL::new(global, proto, parsed_url))
|
||||
Ok(URL::new(global, proto, parsed_url, can_gc))
|
||||
}
|
||||
|
||||
/// <https://url.spec.whatwg.org/#dom-url-canparse>
|
||||
|
@ -152,7 +159,7 @@ impl URL {
|
|||
// These steps are all handled while mapping the Result to an Option<ServoUrl>.
|
||||
// Regarding initialization, the same condition should apply here as stated in the comments
|
||||
// in Self::Constructor above - construct it on-demand inside `URL::SearchParams`.
|
||||
Some(URL::new(global, None, parsed_url.ok()?))
|
||||
Some(URL::new(global, None, parsed_url.ok()?, CanGc::note()))
|
||||
}
|
||||
|
||||
/// <https://w3c.github.io/FileAPI/#dfn-createObjectURL>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue