mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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
|
@ -26,6 +26,7 @@ use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -96,7 +97,7 @@ impl AnalyserNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &AnalyserOptions,
|
options: &AnalyserOptions,
|
||||||
) -> Fallible<DomRoot<AnalyserNode>> {
|
) -> Fallible<DomRoot<AnalyserNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -105,9 +106,10 @@ impl AnalyserNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &AnalyserOptions,
|
options: &AnalyserOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<AnalyserNode>> {
|
) -> Fallible<DomRoot<AnalyserNode>> {
|
||||||
let (node, recv) = AnalyserNode::new_inherited(window, context, options)?;
|
let (node, recv) = AnalyserNode::new_inherited(window, context, options)?;
|
||||||
let object = reflect_dom_object_with_proto(Box::new(node), window, proto);
|
let object = reflect_dom_object_with_proto(Box::new(node), window, proto, can_gc);
|
||||||
let (source, canceller) = window
|
let (source, canceller) = window
|
||||||
.task_manager()
|
.task_manager()
|
||||||
.dom_manipulation_task_source_with_canceller();
|
.dom_manipulation_task_source_with_canceller();
|
||||||
|
@ -134,10 +136,11 @@ impl AnalyserNode {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &AnalyserOptions,
|
options: &AnalyserOptions,
|
||||||
) -> Fallible<DomRoot<AnalyserNode>> {
|
) -> Fallible<DomRoot<AnalyserNode>> {
|
||||||
AnalyserNode::new_with_proto(window, proto, context, options)
|
AnalyserNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_block(&self, block: Block) {
|
pub fn push_block(&self, block: Block) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct AnimationEvent {
|
pub struct AnimationEvent {
|
||||||
|
@ -38,7 +39,7 @@ impl AnimationEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window, type_: Atom, init: &AnimationEventInit) -> DomRoot<AnimationEvent> {
|
pub fn new(window: &Window, type_: Atom, init: &AnimationEventInit) -> DomRoot<AnimationEvent> {
|
||||||
Self::new_with_proto(window, None, type_, init)
|
Self::new_with_proto(window, None, type_, init, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -46,11 +47,13 @@ impl AnimationEvent {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
init: &AnimationEventInit,
|
init: &AnimationEventInit,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<AnimationEvent> {
|
) -> DomRoot<AnimationEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(AnimationEvent::new_inherited(init)),
|
Box::new(AnimationEvent::new_inherited(init)),
|
||||||
window,
|
window,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -63,10 +66,11 @@ impl AnimationEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &AnimationEventInit,
|
init: &AnimationEventInit,
|
||||||
) -> DomRoot<AnimationEvent> {
|
) -> DomRoot<AnimationEvent> {
|
||||||
AnimationEvent::new_with_proto(window, proto, Atom::from(type_), init)
|
AnimationEvent::new_with_proto(window, proto, Atom::from(type_), init, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
// Spec mandates at least [8000, 96000], we use [8000, 192000] to match Firefox
|
// Spec mandates at least [8000, 96000], we use [8000, 192000] to match Firefox
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer
|
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer
|
||||||
|
@ -89,6 +89,7 @@ impl AudioBuffer {
|
||||||
length,
|
length,
|
||||||
sample_rate,
|
sample_rate,
|
||||||
initial_data,
|
initial_data,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +101,10 @@ impl AudioBuffer {
|
||||||
length: u32,
|
length: u32,
|
||||||
sample_rate: f32,
|
sample_rate: f32,
|
||||||
initial_data: Option<&[Vec<f32>]>,
|
initial_data: Option<&[Vec<f32>]>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<AudioBuffer> {
|
) -> DomRoot<AudioBuffer> {
|
||||||
let buffer = AudioBuffer::new_inherited(number_of_channels, length, sample_rate);
|
let buffer = AudioBuffer::new_inherited(number_of_channels, length, sample_rate);
|
||||||
let buffer = reflect_dom_object_with_proto(Box::new(buffer), global, proto);
|
let buffer = reflect_dom_object_with_proto(Box::new(buffer), global, proto, can_gc);
|
||||||
buffer.set_initial_data(initial_data);
|
buffer.set_initial_data(initial_data);
|
||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
|
@ -112,6 +114,7 @@ impl AudioBuffer {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
options: &AudioBufferOptions,
|
options: &AudioBufferOptions,
|
||||||
) -> Fallible<DomRoot<AudioBuffer>> {
|
) -> Fallible<DomRoot<AudioBuffer>> {
|
||||||
if options.length == 0 ||
|
if options.length == 0 ||
|
||||||
|
@ -129,6 +132,7 @@ impl AudioBuffer {
|
||||||
options.length,
|
options.length,
|
||||||
*options.sampleRate,
|
*options.sampleRate,
|
||||||
None,
|
None,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct AudioBufferSourceNode {
|
pub struct AudioBufferSourceNode {
|
||||||
|
@ -100,7 +101,7 @@ impl AudioBufferSourceNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &AudioBufferSourceOptions,
|
options: &AudioBufferSourceOptions,
|
||||||
) -> Fallible<DomRoot<AudioBufferSourceNode>> {
|
) -> Fallible<DomRoot<AudioBufferSourceNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -109,19 +110,26 @@ impl AudioBufferSourceNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &AudioBufferSourceOptions,
|
options: &AudioBufferSourceOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<AudioBufferSourceNode>> {
|
) -> Fallible<DomRoot<AudioBufferSourceNode>> {
|
||||||
let node = AudioBufferSourceNode::new_inherited(window, context, options)?;
|
let node = AudioBufferSourceNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &AudioBufferSourceOptions,
|
options: &AudioBufferSourceOptions,
|
||||||
) -> Fallible<DomRoot<AudioBufferSourceNode>> {
|
) -> Fallible<DomRoot<AudioBufferSourceNode>> {
|
||||||
AudioBufferSourceNode::new_with_proto(window, proto, context, options)
|
AudioBufferSourceNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ use crate::dom::mediastreamtrackaudiosourcenode::MediaStreamTrackAudioSourceNode
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -86,10 +87,11 @@ impl AudioContext {
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
options: &AudioContextOptions,
|
options: &AudioContextOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<AudioContext>> {
|
) -> Fallible<DomRoot<AudioContext>> {
|
||||||
let pipeline_id = window.pipeline_id();
|
let pipeline_id = window.pipeline_id();
|
||||||
let context = AudioContext::new_inherited(options, pipeline_id)?;
|
let context = AudioContext::new_inherited(options, pipeline_id)?;
|
||||||
let context = reflect_dom_object_with_proto(Box::new(context), window, proto);
|
let context = reflect_dom_object_with_proto(Box::new(context), window, proto, can_gc);
|
||||||
context.resume();
|
context.resume();
|
||||||
Ok(context)
|
Ok(context)
|
||||||
}
|
}
|
||||||
|
@ -99,9 +101,10 @@ impl AudioContext {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
options: &AudioContextOptions,
|
options: &AudioContextOptions,
|
||||||
) -> Fallible<DomRoot<AudioContext>> {
|
) -> Fallible<DomRoot<AudioContext>> {
|
||||||
AudioContext::new(window, proto, options)
|
AudioContext::new(window, proto, options, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resume(&self) {
|
fn resume(&self) {
|
||||||
|
|
|
@ -2889,7 +2889,8 @@ class CGWrapMethod(CGAbstractMethod):
|
||||||
args = [Argument('SafeJSContext', 'cx'),
|
args = [Argument('SafeJSContext', 'cx'),
|
||||||
Argument('&GlobalScope', 'scope'),
|
Argument('&GlobalScope', 'scope'),
|
||||||
Argument('Option<HandleObject>', 'given_proto'),
|
Argument('Option<HandleObject>', 'given_proto'),
|
||||||
Argument(f"Box<{descriptor.concreteType}>", 'object')]
|
Argument(f"Box<{descriptor.concreteType}>", 'object'),
|
||||||
|
Argument('CanGc', '_can_gc')]
|
||||||
retval = f'DomRoot<{descriptor.concreteType}>'
|
retval = f'DomRoot<{descriptor.concreteType}>'
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||||
pub=True, unsafe=True)
|
pub=True, unsafe=True)
|
||||||
|
@ -3082,6 +3083,7 @@ impl DomObjectWrap for {name} {{
|
||||||
&GlobalScope,
|
&GlobalScope,
|
||||||
Option<HandleObject>,
|
Option<HandleObject>,
|
||||||
Box<Self>,
|
Box<Self>,
|
||||||
|
CanGc,
|
||||||
) -> Root<Dom<Self>> = Wrap;
|
) -> Root<Dom<Self>> = Wrap;
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
|
@ -3105,6 +3107,7 @@ impl DomObjectIteratorWrap for {name} {{
|
||||||
&GlobalScope,
|
&GlobalScope,
|
||||||
Option<HandleObject>,
|
Option<HandleObject>,
|
||||||
Box<IterableIterator<Self>>,
|
Box<IterableIterator<Self>>,
|
||||||
|
CanGc,
|
||||||
) -> Root<Dom<IterableIterator<Self>>> = Wrap;
|
) -> Root<Dom<IterableIterator<Self>>> = Wrap;
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
|
@ -6234,7 +6237,7 @@ if proto_result.is_err() {{
|
||||||
"""
|
"""
|
||||||
name = self.constructor.identifier.name
|
name = self.constructor.identifier.name
|
||||||
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
|
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
|
||||||
args = ["&global", "Some(desired_proto.handle())"]
|
args = ["&global", "Some(desired_proto.handle())", "CanGc::note()"]
|
||||||
constructorCall = CGMethodCall(args, nativeName, True,
|
constructorCall = CGMethodCall(args, nativeName, True,
|
||||||
self.descriptor, self.constructor)
|
self.descriptor, self.constructor)
|
||||||
return CGList([CGGeneric(preamble), constructorCall])
|
return CGList([CGGeneric(preamble), constructorCall])
|
||||||
|
|
|
@ -145,4 +145,5 @@ pub mod module {
|
||||||
pub use crate::dom::types::{AnalyserNode, AudioNode, BaseAudioContext, EventTarget};
|
pub use crate::dom::types::{AnalyserNode, AudioNode, BaseAudioContext, EventTarget};
|
||||||
pub use crate::mem::malloc_size_of_including_raw_self;
|
pub use crate::mem::malloc_size_of_including_raw_self;
|
||||||
pub use crate::realms::{AlreadyInRealm, InRealm};
|
pub use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
|
pub use crate::script_runtime::CanGc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::dom::bindings::reflector::{
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, Root};
|
use crate::dom::bindings::root::{Dom, DomRoot, Root};
|
||||||
use crate::dom::bindings::trace::{JSTraceable, RootedTraceableBox};
|
use crate::dom::bindings::trace::{JSTraceable, RootedTraceableBox};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
/// The values that an iterator will iterate over.
|
/// The values that an iterator will iterate over.
|
||||||
#[derive(JSTraceable, MallocSizeOf)]
|
#[derive(JSTraceable, MallocSizeOf)]
|
||||||
|
@ -126,6 +126,7 @@ impl<T: DomObjectIteratorWrap + JSTraceable + Iterable> DomObjectWrap for Iterab
|
||||||
&GlobalScope,
|
&GlobalScope,
|
||||||
Option<HandleObject>,
|
Option<HandleObject>,
|
||||||
Box<Self>,
|
Box<Self>,
|
||||||
|
CanGc,
|
||||||
) -> Root<Dom<Self>> = T::ITER_WRAP;
|
) -> Root<Dom<Self>> = T::ITER_WRAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::dom::bindings::root::{Dom, DomRoot, Root};
|
||||||
use crate::dom::bindings::trace::JSTraceable;
|
use crate::dom::bindings::trace::JSTraceable;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::realms::AlreadyInRealm;
|
use crate::realms::AlreadyInRealm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
/// Create the reflector for a new DOM object and yield ownership to the
|
/// Create the reflector for a new DOM object and yield ownership to the
|
||||||
/// reflector.
|
/// reflector.
|
||||||
|
@ -25,20 +25,29 @@ where
|
||||||
U: DerivedFrom<GlobalScope>,
|
U: DerivedFrom<GlobalScope>,
|
||||||
{
|
{
|
||||||
let global_scope = global.upcast();
|
let global_scope = global.upcast();
|
||||||
unsafe { T::WRAP(GlobalScope::get_cx(), global_scope, None, obj) }
|
unsafe {
|
||||||
|
T::WRAP(
|
||||||
|
GlobalScope::get_cx(),
|
||||||
|
global_scope,
|
||||||
|
None,
|
||||||
|
obj,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reflect_dom_object_with_proto<T, U>(
|
pub fn reflect_dom_object_with_proto<T, U>(
|
||||||
obj: Box<T>,
|
obj: Box<T>,
|
||||||
global: &U,
|
global: &U,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<T>
|
) -> DomRoot<T>
|
||||||
where
|
where
|
||||||
T: DomObject + DomObjectWrap,
|
T: DomObject + DomObjectWrap,
|
||||||
U: DerivedFrom<GlobalScope>,
|
U: DerivedFrom<GlobalScope>,
|
||||||
{
|
{
|
||||||
let global_scope = global.upcast();
|
let global_scope = global.upcast();
|
||||||
unsafe { T::WRAP(GlobalScope::get_cx(), global_scope, proto, obj) }
|
unsafe { T::WRAP(GlobalScope::get_cx(), global_scope, proto, obj, can_gc) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A struct to store a reference to the reflector of a DOM object.
|
/// A struct to store a reference to the reflector of a DOM object.
|
||||||
|
@ -131,6 +140,7 @@ pub trait DomObjectWrap: Sized + DomObject {
|
||||||
&GlobalScope,
|
&GlobalScope,
|
||||||
Option<HandleObject>,
|
Option<HandleObject>,
|
||||||
Box<Self>,
|
Box<Self>,
|
||||||
|
CanGc,
|
||||||
) -> Root<Dom<Self>>;
|
) -> Root<Dom<Self>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,5 +153,6 @@ pub trait DomObjectIteratorWrap: DomObjectWrap + JSTraceable + Iterable {
|
||||||
&GlobalScope,
|
&GlobalScope,
|
||||||
Option<HandleObject>,
|
Option<HandleObject>,
|
||||||
Box<IterableIterator<Self>>,
|
Box<IterableIterator<Self>>,
|
||||||
|
CanGc,
|
||||||
) -> Root<Dom<IterableIterator<Self>>>;
|
) -> Root<Dom<IterableIterator<Self>>>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct BiquadFilterNode {
|
pub struct BiquadFilterNode {
|
||||||
|
@ -117,7 +118,7 @@ impl BiquadFilterNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &BiquadFilterOptions,
|
options: &BiquadFilterOptions,
|
||||||
) -> Fallible<DomRoot<BiquadFilterNode>> {
|
) -> Fallible<DomRoot<BiquadFilterNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -126,19 +127,26 @@ impl BiquadFilterNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &BiquadFilterOptions,
|
options: &BiquadFilterOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<BiquadFilterNode>> {
|
) -> Fallible<DomRoot<BiquadFilterNode>> {
|
||||||
let node = BiquadFilterNode::new_inherited(window, context, options)?;
|
let node = BiquadFilterNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &BiquadFilterOptions,
|
options: &BiquadFilterOptions,
|
||||||
) -> Fallible<DomRoot<BiquadFilterNode>> {
|
) -> Fallible<DomRoot<BiquadFilterNode>> {
|
||||||
BiquadFilterNode::new_with_proto(window, proto, context, options)
|
BiquadFilterNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::readablestream::ReadableStream;
|
use crate::dom::readablestream::ReadableStream;
|
||||||
use crate::realms::{AlreadyInRealm, InRealm};
|
use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#blob
|
// https://w3c.github.io/FileAPI/#blob
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -42,16 +42,21 @@ pub struct Blob {
|
||||||
|
|
||||||
impl Blob {
|
impl Blob {
|
||||||
pub fn new(global: &GlobalScope, blob_impl: BlobImpl) -> DomRoot<Blob> {
|
pub fn new(global: &GlobalScope, blob_impl: BlobImpl) -> DomRoot<Blob> {
|
||||||
Self::new_with_proto(global, None, blob_impl)
|
Self::new_with_proto(global, None, blob_impl, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
blob_impl: BlobImpl,
|
blob_impl: BlobImpl,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Blob> {
|
) -> DomRoot<Blob> {
|
||||||
let dom_blob =
|
let dom_blob = reflect_dom_object_with_proto(
|
||||||
reflect_dom_object_with_proto(Box::new(Blob::new_inherited(&blob_impl)), global, proto);
|
Box::new(Blob::new_inherited(&blob_impl)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
);
|
||||||
global.track_blob(&dom_blob, blob_impl);
|
global.track_blob(&dom_blob, blob_impl);
|
||||||
dom_blob
|
dom_blob
|
||||||
}
|
}
|
||||||
|
@ -69,6 +74,7 @@ impl Blob {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
blobParts: Option<Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>>,
|
blobParts: Option<Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>>,
|
||||||
blobPropertyBag: &BlobBinding::BlobPropertyBag,
|
blobPropertyBag: &BlobBinding::BlobPropertyBag,
|
||||||
) -> Fallible<DomRoot<Blob>> {
|
) -> Fallible<DomRoot<Blob>> {
|
||||||
|
@ -83,7 +89,7 @@ impl Blob {
|
||||||
let type_string = normalize_type_string(blobPropertyBag.type_.as_ref());
|
let type_string = normalize_type_string(blobPropertyBag.type_.as_ref());
|
||||||
let blob_impl = BlobImpl::new_from_bytes(bytes, type_string);
|
let blob_impl = BlobImpl::new_from_bytes(bytes, type_string);
|
||||||
|
|
||||||
Ok(Blob::new_with_proto(global, proto, blob_impl))
|
Ok(Blob::new_with_proto(global, proto, blob_impl, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a slice to inner data, this might incur synchronous read and caching
|
/// Get a slice to inner data, this might incur synchronous read and caching
|
||||||
|
|
|
@ -19,6 +19,7 @@ use crate::dom::bluetoothdevice::BluetoothDevice;
|
||||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingevent
|
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingevent
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -62,6 +63,7 @@ impl BluetoothAdvertisingEvent {
|
||||||
appearance: Option<u16>,
|
appearance: Option<u16>,
|
||||||
txPower: Option<i8>,
|
txPower: Option<i8>,
|
||||||
rssi: Option<i8>,
|
rssi: Option<i8>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<BluetoothAdvertisingEvent> {
|
) -> DomRoot<BluetoothAdvertisingEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(BluetoothAdvertisingEvent::new_inherited(
|
Box::new(BluetoothAdvertisingEvent::new_inherited(
|
||||||
|
@ -69,6 +71,7 @@ impl BluetoothAdvertisingEvent {
|
||||||
)),
|
)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -81,6 +84,7 @@ impl BluetoothAdvertisingEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &BluetoothAdvertisingEventInit,
|
init: &BluetoothAdvertisingEventInit,
|
||||||
) -> Fallible<DomRoot<BluetoothAdvertisingEvent>> {
|
) -> Fallible<DomRoot<BluetoothAdvertisingEvent>> {
|
||||||
|
@ -102,6 +106,7 @@ impl BluetoothAdvertisingEvent {
|
||||||
appearance,
|
appearance,
|
||||||
txPower,
|
txPower,
|
||||||
rssi,
|
rssi,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::bindings::structuredclone;
|
use crate::dom::bindings::structuredclone;
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext as SafeJSContext;
|
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct BroadcastChannel {
|
pub struct BroadcastChannel {
|
||||||
|
@ -34,20 +34,23 @@ impl BroadcastChannel {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
) -> DomRoot<BroadcastChannel> {
|
) -> DomRoot<BroadcastChannel> {
|
||||||
BroadcastChannel::new(global, proto, name)
|
BroadcastChannel::new(global, proto, name, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(
|
fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<BroadcastChannel> {
|
) -> DomRoot<BroadcastChannel> {
|
||||||
let channel = reflect_dom_object_with_proto(
|
let channel = reflect_dom_object_with_proto(
|
||||||
Box::new(BroadcastChannel::new_inherited(name)),
|
Box::new(BroadcastChannel::new_inherited(name)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
global.track_broadcast_channel(&channel);
|
global.track_broadcast_channel(&channel);
|
||||||
channel
|
channel
|
||||||
|
|
|
@ -17,6 +17,7 @@ use crate::dom::bindings::error::{Error, Fallible};
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct ChannelMergerNode {
|
pub struct ChannelMergerNode {
|
||||||
|
@ -59,7 +60,7 @@ impl ChannelMergerNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ChannelMergerOptions,
|
options: &ChannelMergerOptions,
|
||||||
) -> Fallible<DomRoot<ChannelMergerNode>> {
|
) -> Fallible<DomRoot<ChannelMergerNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -68,19 +69,26 @@ impl ChannelMergerNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ChannelMergerOptions,
|
options: &ChannelMergerOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<ChannelMergerNode>> {
|
) -> Fallible<DomRoot<ChannelMergerNode>> {
|
||||||
let node = ChannelMergerNode::new_inherited(window, context, options)?;
|
let node = ChannelMergerNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ChannelMergerOptions,
|
options: &ChannelMergerOptions,
|
||||||
) -> Fallible<DomRoot<ChannelMergerNode>> {
|
) -> Fallible<DomRoot<ChannelMergerNode>> {
|
||||||
ChannelMergerNode::new_with_proto(window, proto, context, options)
|
ChannelMergerNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ use crate::dom::bindings::error::{Error, Fallible};
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct ChannelSplitterNode {
|
pub struct ChannelSplitterNode {
|
||||||
|
@ -61,7 +62,7 @@ impl ChannelSplitterNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ChannelSplitterOptions,
|
options: &ChannelSplitterOptions,
|
||||||
) -> Fallible<DomRoot<ChannelSplitterNode>> {
|
) -> Fallible<DomRoot<ChannelSplitterNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -70,18 +71,25 @@ impl ChannelSplitterNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ChannelSplitterOptions,
|
options: &ChannelSplitterOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<ChannelSplitterNode>> {
|
) -> Fallible<DomRoot<ChannelSplitterNode>> {
|
||||||
let node = ChannelSplitterNode::new_inherited(window, context, options)?;
|
let node = ChannelSplitterNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ChannelSplitterOptions,
|
options: &ChannelSplitterOptions,
|
||||||
) -> Fallible<DomRoot<ChannelSplitterNode>> {
|
) -> Fallible<DomRoot<ChannelSplitterNode>> {
|
||||||
ChannelSplitterNode::new_with_proto(window, proto, context, options)
|
ChannelSplitterNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct CloseEvent {
|
pub struct CloseEvent {
|
||||||
|
@ -46,7 +47,15 @@ impl CloseEvent {
|
||||||
reason: DOMString,
|
reason: DOMString,
|
||||||
) -> DomRoot<CloseEvent> {
|
) -> DomRoot<CloseEvent> {
|
||||||
Self::new_with_proto(
|
Self::new_with_proto(
|
||||||
global, None, type_, bubbles, cancelable, wasClean, code, reason,
|
global,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
wasClean,
|
||||||
|
code,
|
||||||
|
reason,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +69,10 @@ impl CloseEvent {
|
||||||
wasClean: bool,
|
wasClean: bool,
|
||||||
code: u16,
|
code: u16,
|
||||||
reason: DOMString,
|
reason: DOMString,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<CloseEvent> {
|
) -> DomRoot<CloseEvent> {
|
||||||
let event = Box::new(CloseEvent::new_inherited(wasClean, code, reason));
|
let event = Box::new(CloseEvent::new_inherited(wasClean, code, reason));
|
||||||
let ev = reflect_dom_object_with_proto(event, global, proto);
|
let ev = reflect_dom_object_with_proto(event, global, proto, can_gc);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
||||||
|
@ -73,6 +83,7 @@ impl CloseEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &CloseEventBinding::CloseEventInit,
|
init: &CloseEventBinding::CloseEventInit,
|
||||||
) -> Fallible<DomRoot<CloseEvent>> {
|
) -> Fallible<DomRoot<CloseEvent>> {
|
||||||
|
@ -87,6 +98,7 @@ impl CloseEvent {
|
||||||
init.wasClean,
|
init.wasClean,
|
||||||
init.code,
|
init.code,
|
||||||
init.reason.clone(),
|
init.reason.clone(),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::dom::characterdata::CharacterData;
|
||||||
use crate::dom::document::Document;
|
use crate::dom::document::Document;
|
||||||
use crate::dom::node::Node;
|
use crate::dom::node::Node;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
/// An HTML comment.
|
/// An HTML comment.
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -43,6 +44,7 @@ impl Comment {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
_can_gc: CanGc,
|
||||||
data: DOMString,
|
data: DOMString,
|
||||||
) -> Fallible<DomRoot<Comment>> {
|
) -> Fallible<DomRoot<Comment>> {
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
|
|
|
@ -15,6 +15,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::uievent::UIEvent;
|
use crate::dom::uievent::UIEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct CompositionEvent {
|
pub struct CompositionEvent {
|
||||||
|
@ -44,7 +45,15 @@ impl CompositionEvent {
|
||||||
data: DOMString,
|
data: DOMString,
|
||||||
) -> DomRoot<CompositionEvent> {
|
) -> DomRoot<CompositionEvent> {
|
||||||
Self::new_with_proto(
|
Self::new_with_proto(
|
||||||
window, None, type_, can_bubble, cancelable, view, detail, data,
|
window,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
can_bubble,
|
||||||
|
cancelable,
|
||||||
|
view,
|
||||||
|
detail,
|
||||||
|
data,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +67,7 @@ impl CompositionEvent {
|
||||||
view: Option<&Window>,
|
view: Option<&Window>,
|
||||||
detail: i32,
|
detail: i32,
|
||||||
data: DOMString,
|
data: DOMString,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<CompositionEvent> {
|
) -> DomRoot<CompositionEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(CompositionEvent {
|
Box::new(CompositionEvent {
|
||||||
|
@ -66,6 +76,7 @@ impl CompositionEvent {
|
||||||
}),
|
}),
|
||||||
window,
|
window,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
ev.uievent
|
ev.uievent
|
||||||
.InitUIEvent(type_, can_bubble, cancelable, view, detail);
|
.InitUIEvent(type_, can_bubble, cancelable, view, detail);
|
||||||
|
@ -76,6 +87,7 @@ impl CompositionEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &CompositionEventBinding::CompositionEventInit,
|
init: &CompositionEventBinding::CompositionEventInit,
|
||||||
) -> Fallible<DomRoot<CompositionEvent>> {
|
) -> Fallible<DomRoot<CompositionEvent>> {
|
||||||
|
@ -88,6 +100,7 @@ impl CompositionEvent {
|
||||||
init.parent.view.as_deref(),
|
init.parent.view.as_deref(),
|
||||||
init.parent.detail,
|
init.parent.detail,
|
||||||
init.data.clone(),
|
init.data.clone(),
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct ConstantSourceNode {
|
pub struct ConstantSourceNode {
|
||||||
|
@ -67,7 +68,7 @@ impl ConstantSourceNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ConstantSourceOptions,
|
options: &ConstantSourceOptions,
|
||||||
) -> Fallible<DomRoot<ConstantSourceNode>> {
|
) -> Fallible<DomRoot<ConstantSourceNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -76,19 +77,26 @@ impl ConstantSourceNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ConstantSourceOptions,
|
options: &ConstantSourceOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<ConstantSourceNode>> {
|
) -> Fallible<DomRoot<ConstantSourceNode>> {
|
||||||
let node = ConstantSourceNode::new_inherited(window, context, options)?;
|
let node = ConstantSourceNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &ConstantSourceOptions,
|
options: &ConstantSourceOptions,
|
||||||
) -> Fallible<DomRoot<ConstantSourceNode>> {
|
) -> Fallible<DomRoot<ConstantSourceNode>> {
|
||||||
ConstantSourceNode::new_with_proto(window, proto, context, options)
|
ConstantSourceNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::bindings::trace::RootedTraceableBox;
|
use crate::dom::bindings::trace::RootedTraceableBox;
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#interface-customevent
|
// https://dom.spec.whatwg.org/#interface-customevent
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -38,14 +38,20 @@ impl CustomEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<CustomEvent> {
|
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<CustomEvent> {
|
||||||
Self::new_uninitialized_with_proto(global, None)
|
Self::new_uninitialized_with_proto(global, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_uninitialized_with_proto(
|
fn new_uninitialized_with_proto(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<CustomEvent> {
|
) -> DomRoot<CustomEvent> {
|
||||||
reflect_dom_object_with_proto(Box::new(CustomEvent::new_inherited()), global, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(CustomEvent::new_inherited()),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(
|
fn new(
|
||||||
|
@ -55,8 +61,9 @@ impl CustomEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
detail: HandleValue,
|
detail: HandleValue,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<CustomEvent> {
|
) -> DomRoot<CustomEvent> {
|
||||||
let ev = CustomEvent::new_uninitialized_with_proto(global, proto);
|
let ev = CustomEvent::new_uninitialized_with_proto(global, proto, can_gc);
|
||||||
ev.init_custom_event(type_, bubbles, cancelable, detail);
|
ev.init_custom_event(type_, bubbles, cancelable, detail);
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
@ -65,6 +72,7 @@ impl CustomEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<CustomEventBinding::CustomEventInit>,
|
init: RootedTraceableBox<CustomEventBinding::CustomEventInit>,
|
||||||
) -> Fallible<DomRoot<CustomEvent>> {
|
) -> Fallible<DomRoot<CustomEvent>> {
|
||||||
|
@ -75,6 +83,7 @@ impl CustomEvent {
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
init.detail.handle(),
|
init.detail.handle(),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ use crate::dom::window::{ReflowReason, Window};
|
||||||
use crate::dom::windowproxy::WindowProxy;
|
use crate::dom::windowproxy::WindowProxy;
|
||||||
use crate::fetch::FetchCanceller;
|
use crate::fetch::FetchCanceller;
|
||||||
use crate::realms::{AlreadyInRealm, InRealm};
|
use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
use crate::script_runtime::{CanGc, CommonScriptMsg, ScriptThreadEventCategory};
|
||||||
use crate::script_thread::{MainThreadScriptMsg, ScriptThread};
|
use crate::script_thread::{MainThreadScriptMsg, ScriptThread};
|
||||||
use crate::stylesheet_set::StylesheetSetRef;
|
use crate::stylesheet_set::StylesheetSetRef;
|
||||||
use crate::task::TaskBox;
|
use crate::task::TaskBox;
|
||||||
|
@ -3409,6 +3409,7 @@ impl Document {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<Document>> {
|
) -> Fallible<DomRoot<Document>> {
|
||||||
let doc = window.Document();
|
let doc = window.Document();
|
||||||
let docloader = DocumentLoader::new(&doc.loader());
|
let docloader = DocumentLoader::new(&doc.loader());
|
||||||
|
@ -3428,6 +3429,7 @@ impl Document {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3464,6 +3466,7 @@ impl Document {
|
||||||
referrer_policy,
|
referrer_policy,
|
||||||
status_code,
|
status_code,
|
||||||
canceller,
|
canceller,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3484,6 +3487,7 @@ impl Document {
|
||||||
referrer_policy: Option<ReferrerPolicy>,
|
referrer_policy: Option<ReferrerPolicy>,
|
||||||
status_code: Option<u16>,
|
status_code: Option<u16>,
|
||||||
canceller: FetchCanceller,
|
canceller: FetchCanceller,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Document> {
|
) -> DomRoot<Document> {
|
||||||
let document = reflect_dom_object_with_proto(
|
let document = reflect_dom_object_with_proto(
|
||||||
Box::new(Document::new_inherited(
|
Box::new(Document::new_inherited(
|
||||||
|
@ -3504,6 +3508,7 @@ impl Document {
|
||||||
)),
|
)),
|
||||||
window,
|
window,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let node = document.upcast::<Node>();
|
let node = document.upcast::<Node>();
|
||||||
|
@ -4593,7 +4598,7 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createrange
|
// https://dom.spec.whatwg.org/#dom-document-createrange
|
||||||
fn CreateRange(&self) -> DomRoot<Range> {
|
fn CreateRange(&self) -> DomRoot<Range> {
|
||||||
Range::new_with_doc(self, None)
|
Range::new_with_doc(self, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createnodeiteratorroot-whattoshow-filter
|
// https://dom.spec.whatwg.org/#dom-document-createnodeiteratorroot-whattoshow-filter
|
||||||
|
|
|
@ -21,6 +21,7 @@ use crate::dom::htmlcollection::HTMLCollection;
|
||||||
use crate::dom::node::{window_from_node, Node};
|
use crate::dom::node::{window_from_node, Node};
|
||||||
use crate::dom::nodelist::NodeList;
|
use crate::dom::nodelist::NodeList;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#documentfragment
|
// https://dom.spec.whatwg.org/#documentfragment
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -58,6 +59,7 @@ impl DocumentFragment {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
_can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<DocumentFragment>> {
|
) -> Fallible<DomRoot<DocumentFragment>> {
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ use crate::dom::bindings::reflector::{
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
#[derive(Clone, Copy, Debug, Eq, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)]
|
#[derive(Clone, Copy, Debug, Eq, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)]
|
||||||
|
@ -150,6 +151,7 @@ impl DOMException {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
) -> Result<DomRoot<DOMException>, Error> {
|
) -> Result<DomRoot<DOMException>, Error> {
|
||||||
|
@ -157,6 +159,7 @@ impl DOMException {
|
||||||
Box::new(DOMException::new_inherited(message, name)),
|
Box::new(DOMException::new_inherited(message, name)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ use crate::dom::dommatrixreadonly::{
|
||||||
};
|
};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct DOMMatrix {
|
pub struct DOMMatrix {
|
||||||
|
@ -29,7 +30,7 @@ pub struct DOMMatrix {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
impl DOMMatrix {
|
impl DOMMatrix {
|
||||||
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
|
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
|
||||||
Self::new_with_proto(global, None, is2D, matrix)
|
Self::new_with_proto(global, None, is2D, matrix, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -38,9 +39,10 @@ impl DOMMatrix {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
is2D: bool,
|
is2D: bool,
|
||||||
matrix: Transform3D<f64>,
|
matrix: Transform3D<f64>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
let dommatrix = Self::new_inherited(is2D, matrix);
|
let dommatrix = Self::new_inherited(is2D, matrix);
|
||||||
reflect_dom_object_with_proto(Box::new(dommatrix), global, proto)
|
reflect_dom_object_with_proto(Box::new(dommatrix), global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self {
|
pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self {
|
||||||
|
@ -53,6 +55,7 @@ impl DOMMatrix {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
init: Option<StringOrUnrestrictedDoubleSequence>,
|
init: Option<StringOrUnrestrictedDoubleSequence>,
|
||||||
) -> Fallible<DomRoot<Self>> {
|
) -> Fallible<DomRoot<Self>> {
|
||||||
if init.is_none() {
|
if init.is_none() {
|
||||||
|
@ -61,6 +64,7 @@ impl DOMMatrix {
|
||||||
proto,
|
proto,
|
||||||
true,
|
true,
|
||||||
Transform3D::identity(),
|
Transform3D::identity(),
|
||||||
|
can_gc,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
match init.unwrap() {
|
match init.unwrap() {
|
||||||
|
@ -74,11 +78,11 @@ impl DOMMatrix {
|
||||||
return Ok(Self::new(global, true, Transform3D::identity()));
|
return Ok(Self::new(global, true, Transform3D::identity()));
|
||||||
}
|
}
|
||||||
transform_to_matrix(s.to_string())
|
transform_to_matrix(s.to_string())
|
||||||
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix))
|
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix, can_gc))
|
||||||
},
|
},
|
||||||
StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(ref entries) => {
|
StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(ref entries) => {
|
||||||
entries_to_matrix(&entries[..])
|
entries_to_matrix(&entries[..])
|
||||||
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix))
|
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix, can_gc))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +105,7 @@ impl DOMMatrix {
|
||||||
DOMMatrix::Constructor(
|
DOMMatrix::Constructor(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
|
CanGc::note(),
|
||||||
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -114,6 +119,7 @@ impl DOMMatrix {
|
||||||
DOMMatrix::Constructor(
|
DOMMatrix::Constructor(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
|
CanGc::note(),
|
||||||
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ use crate::dom::dommatrix::DOMMatrix;
|
||||||
use crate::dom::dompoint::DOMPoint;
|
use crate::dom::dompoint::DOMPoint;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -44,7 +44,7 @@ pub struct DOMMatrixReadOnly {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
impl DOMMatrixReadOnly {
|
impl DOMMatrixReadOnly {
|
||||||
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
|
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
|
||||||
Self::new_with_proto(global, None, is2D, matrix)
|
Self::new_with_proto(global, None, is2D, matrix, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -53,9 +53,10 @@ impl DOMMatrixReadOnly {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
is2D: bool,
|
is2D: bool,
|
||||||
matrix: Transform3D<f64>,
|
matrix: Transform3D<f64>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
let dommatrix = Self::new_inherited(is2D, matrix);
|
let dommatrix = Self::new_inherited(is2D, matrix);
|
||||||
reflect_dom_object_with_proto(Box::new(dommatrix), global, proto)
|
reflect_dom_object_with_proto(Box::new(dommatrix), global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self {
|
pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self {
|
||||||
|
@ -70,6 +71,7 @@ impl DOMMatrixReadOnly {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
init: Option<StringOrUnrestrictedDoubleSequence>,
|
init: Option<StringOrUnrestrictedDoubleSequence>,
|
||||||
) -> Fallible<DomRoot<Self>> {
|
) -> Fallible<DomRoot<Self>> {
|
||||||
if init.is_none() {
|
if init.is_none() {
|
||||||
|
@ -78,6 +80,7 @@ impl DOMMatrixReadOnly {
|
||||||
proto,
|
proto,
|
||||||
true,
|
true,
|
||||||
Transform3D::identity(),
|
Transform3D::identity(),
|
||||||
|
can_gc,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
match init.unwrap() {
|
match init.unwrap() {
|
||||||
|
@ -91,11 +94,11 @@ impl DOMMatrixReadOnly {
|
||||||
return Ok(Self::new(global, true, Transform3D::identity()));
|
return Ok(Self::new(global, true, Transform3D::identity()));
|
||||||
}
|
}
|
||||||
transform_to_matrix(s.to_string())
|
transform_to_matrix(s.to_string())
|
||||||
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix))
|
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix, can_gc))
|
||||||
},
|
},
|
||||||
StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(ref entries) => {
|
StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(ref entries) => {
|
||||||
entries_to_matrix(&entries[..])
|
entries_to_matrix(&entries[..])
|
||||||
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix))
|
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix, can_gc))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,6 +414,7 @@ impl DOMMatrixReadOnly {
|
||||||
DOMMatrixReadOnly::Constructor(
|
DOMMatrixReadOnly::Constructor(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
|
CanGc::note(),
|
||||||
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -425,6 +429,7 @@ impl DOMMatrixReadOnly {
|
||||||
DOMMatrixReadOnly::Constructor(
|
DOMMatrixReadOnly::Constructor(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
|
CanGc::note(),
|
||||||
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument};
|
use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument};
|
||||||
use crate::dom::servoparser::ServoParser;
|
use crate::dom::servoparser::ServoParser;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct DOMParser {
|
pub struct DOMParser {
|
||||||
|
@ -36,16 +37,22 @@ impl DOMParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(window: &Window, proto: Option<HandleObject>) -> DomRoot<DOMParser> {
|
fn new(window: &Window, proto: Option<HandleObject>, can_gc: CanGc) -> DomRoot<DOMParser> {
|
||||||
reflect_dom_object_with_proto(Box::new(DOMParser::new_inherited(window)), window, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(DOMParser::new_inherited(window)),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<DOMParser>> {
|
) -> Fallible<DomRoot<DOMParser>> {
|
||||||
Ok(DOMParser::new(window, proto))
|
Ok(DOMParser::new(window, proto, can_gc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
|
use crate::dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// http://dev.w3.org/fxtf/geometry/Overview.html#dompoint
|
// http://dev.w3.org/fxtf/geometry/Overview.html#dompoint
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -28,7 +29,7 @@ impl DOMPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPoint> {
|
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPoint> {
|
||||||
Self::new_with_proto(global, None, x, y, z, w)
|
Self::new_with_proto(global, None, x, y, z, w, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -38,19 +39,26 @@ impl DOMPoint {
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
w: f64,
|
w: f64,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<DOMPoint> {
|
) -> DomRoot<DOMPoint> {
|
||||||
reflect_dom_object_with_proto(Box::new(DOMPoint::new_inherited(x, y, z, w)), global, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(DOMPoint::new_inherited(x, y, z, w)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
w: f64,
|
w: f64,
|
||||||
) -> Fallible<DomRoot<DOMPoint>> {
|
) -> Fallible<DomRoot<DOMPoint>> {
|
||||||
Ok(DOMPoint::new_with_proto(global, proto, x, y, z, w))
|
Ok(DOMPoint::new_with_proto(global, proto, x, y, z, w, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
|
// https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly
|
// http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -37,7 +38,7 @@ impl DOMPointReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPointReadOnly> {
|
pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPointReadOnly> {
|
||||||
Self::new_with_proto(global, None, x, y, z, w)
|
Self::new_with_proto(global, None, x, y, z, w, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -47,23 +48,28 @@ impl DOMPointReadOnly {
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
w: f64,
|
w: f64,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<DOMPointReadOnly> {
|
) -> DomRoot<DOMPointReadOnly> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(DOMPointReadOnly::new_inherited(x, y, z, w)),
|
Box::new(DOMPointReadOnly::new_inherited(x, y, z, w)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
z: f64,
|
z: f64,
|
||||||
w: f64,
|
w: f64,
|
||||||
) -> Fallible<DomRoot<DOMPointReadOnly>> {
|
) -> Fallible<DomRoot<DOMPointReadOnly>> {
|
||||||
Ok(DOMPointReadOnly::new_with_proto(global, proto, x, y, z, w))
|
Ok(DOMPointReadOnly::new_with_proto(
|
||||||
|
global, proto, x, y, z, w, can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint
|
// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint
|
||||||
|
|
|
@ -14,6 +14,7 @@ use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::dompoint::DOMPoint;
|
use crate::dom::dompoint::DOMPoint;
|
||||||
use crate::dom::domrect::DOMRect;
|
use crate::dom::domrect::DOMRect;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#DOMQuad
|
// https://drafts.fxtf.org/geometry/#DOMQuad
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -44,7 +45,7 @@ impl DOMQuad {
|
||||||
p3: &DOMPoint,
|
p3: &DOMPoint,
|
||||||
p4: &DOMPoint,
|
p4: &DOMPoint,
|
||||||
) -> DomRoot<DOMQuad> {
|
) -> DomRoot<DOMQuad> {
|
||||||
Self::new_with_proto(global, None, p1, p2, p3, p4)
|
Self::new_with_proto(global, None, p1, p2, p3, p4, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -54,17 +55,20 @@ impl DOMQuad {
|
||||||
p2: &DOMPoint,
|
p2: &DOMPoint,
|
||||||
p3: &DOMPoint,
|
p3: &DOMPoint,
|
||||||
p4: &DOMPoint,
|
p4: &DOMPoint,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<DOMQuad> {
|
) -> DomRoot<DOMQuad> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(DOMQuad::new_inherited(p1, p2, p3, p4)),
|
Box::new(DOMQuad::new_inherited(p1, p2, p3, p4)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
p1: &DOMPointInit,
|
p1: &DOMPointInit,
|
||||||
p2: &DOMPointInit,
|
p2: &DOMPointInit,
|
||||||
p3: &DOMPointInit,
|
p3: &DOMPointInit,
|
||||||
|
@ -77,6 +81,7 @@ impl DOMQuad {
|
||||||
&DOMPoint::new_from_init(global, p2),
|
&DOMPoint::new_from_init(global, p2),
|
||||||
&DOMPoint::new_from_init(global, p3),
|
&DOMPoint::new_from_init(global, p3),
|
||||||
&DOMPoint::new_from_init(global, p4),
|
&DOMPoint::new_from_init(global, p4),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::domrectreadonly::DOMRectReadOnly;
|
use crate::dom::domrectreadonly::DOMRectReadOnly;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct DOMRect {
|
pub struct DOMRect {
|
||||||
|
@ -26,7 +27,7 @@ impl DOMRect {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> DomRoot<DOMRect> {
|
pub fn new(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> DomRoot<DOMRect> {
|
||||||
Self::new_with_proto(global, None, x, y, width, height)
|
Self::new_with_proto(global, None, x, y, width, height, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -36,11 +37,13 @@ impl DOMRect {
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
height: f64,
|
height: f64,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<DOMRect> {
|
) -> DomRoot<DOMRect> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(DOMRect::new_inherited(x, y, width, height)),
|
Box::new(DOMRect::new_inherited(x, y, width, height)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,12 +51,15 @@ impl DOMRect {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
height: f64,
|
height: f64,
|
||||||
) -> Fallible<DomRoot<DOMRect>> {
|
) -> Fallible<DomRoot<DOMRect>> {
|
||||||
Ok(DOMRect::new_with_proto(global, proto, x, y, width, height))
|
Ok(DOMRect::new_with_proto(
|
||||||
|
global, proto, x, y, width, height, can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct DOMRectReadOnly {
|
pub struct DOMRectReadOnly {
|
||||||
|
@ -40,11 +41,13 @@ impl DOMRectReadOnly {
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
height: f64,
|
height: f64,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<DOMRectReadOnly> {
|
) -> DomRoot<DOMRectReadOnly> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(DOMRectReadOnly::new_inherited(x, y, width, height)),
|
Box::new(DOMRectReadOnly::new_inherited(x, y, width, height)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,12 +55,15 @@ impl DOMRectReadOnly {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
height: f64,
|
height: f64,
|
||||||
) -> Fallible<DomRoot<DOMRectReadOnly>> {
|
) -> Fallible<DomRoot<DOMRectReadOnly>> {
|
||||||
Ok(DOMRectReadOnly::new(global, proto, x, y, width, height))
|
Ok(DOMRectReadOnly::new(
|
||||||
|
global, proto, x, y, width, height, can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_x(&self, value: f64) {
|
pub fn set_x(&self, value: f64) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::bindings::trace::RootedTraceableBox;
|
use crate::dom::bindings::trace::RootedTraceableBox;
|
||||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct ErrorEvent {
|
pub struct ErrorEvent {
|
||||||
|
@ -47,8 +47,12 @@ impl ErrorEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_uninitialized(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<ErrorEvent> {
|
fn new_uninitialized(
|
||||||
reflect_dom_object_with_proto(Box::new(ErrorEvent::new_inherited()), global, proto)
|
global: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<ErrorEvent> {
|
||||||
|
reflect_dom_object_with_proto(Box::new(ErrorEvent::new_inherited()), global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
@ -64,7 +68,17 @@ impl ErrorEvent {
|
||||||
error: HandleValue,
|
error: HandleValue,
|
||||||
) -> DomRoot<ErrorEvent> {
|
) -> DomRoot<ErrorEvent> {
|
||||||
Self::new_with_proto(
|
Self::new_with_proto(
|
||||||
global, None, type_, bubbles, cancelable, message, filename, lineno, colno, error,
|
global,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
message,
|
||||||
|
filename,
|
||||||
|
lineno,
|
||||||
|
colno,
|
||||||
|
error,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +94,9 @@ impl ErrorEvent {
|
||||||
lineno: u32,
|
lineno: u32,
|
||||||
colno: u32,
|
colno: u32,
|
||||||
error: HandleValue,
|
error: HandleValue,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<ErrorEvent> {
|
) -> DomRoot<ErrorEvent> {
|
||||||
let ev = ErrorEvent::new_uninitialized(global, proto);
|
let ev = ErrorEvent::new_uninitialized(global, proto, can_gc);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
||||||
|
@ -98,6 +113,7 @@ impl ErrorEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<ErrorEventBinding::ErrorEventInit>,
|
init: RootedTraceableBox<ErrorEventBinding::ErrorEventInit>,
|
||||||
) -> Fallible<DomRoot<ErrorEvent>> {
|
) -> Fallible<DomRoot<ErrorEvent>> {
|
||||||
|
@ -130,6 +146,7 @@ impl ErrorEvent {
|
||||||
line_num,
|
line_num,
|
||||||
col_num,
|
col_num,
|
||||||
init.error.handle(),
|
init.error.handle(),
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ use crate::dom::node::{Node, ShadowIncluding};
|
||||||
use crate::dom::performance::reduce_timing_resolution;
|
use crate::dom::performance::reduce_timing_resolution;
|
||||||
use crate::dom::virtualmethods::vtable_for;
|
use crate::dom::virtualmethods::vtable_for;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task::TaskOnce;
|
use crate::task::TaskOnce;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -76,14 +77,15 @@ impl Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<Event> {
|
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<Event> {
|
||||||
Self::new_uninitialized_with_proto(global, None)
|
Self::new_uninitialized_with_proto(global, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized_with_proto(
|
pub fn new_uninitialized_with_proto(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Event> {
|
) -> DomRoot<Event> {
|
||||||
reflect_dom_object_with_proto(Box::new(Event::new_inherited()), global, proto)
|
reflect_dom_object_with_proto(Box::new(Event::new_inherited()), global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
@ -92,7 +94,7 @@ impl Event {
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
) -> DomRoot<Event> {
|
) -> DomRoot<Event> {
|
||||||
Self::new_with_proto(global, None, type_, bubbles, cancelable)
|
Self::new_with_proto(global, None, type_, bubbles, cancelable, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -101,8 +103,9 @@ impl Event {
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Event> {
|
) -> DomRoot<Event> {
|
||||||
let event = Event::new_uninitialized_with_proto(global, proto);
|
let event = Event::new_uninitialized_with_proto(global, proto, can_gc);
|
||||||
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
|
@ -111,6 +114,7 @@ impl Event {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &EventBinding::EventInit,
|
init: &EventBinding::EventInit,
|
||||||
) -> Fallible<DomRoot<Event>> {
|
) -> Fallible<DomRoot<Event>> {
|
||||||
|
@ -122,6 +126,7 @@ impl Event {
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ use crate::dom::performanceresourcetiming::InitiatorType;
|
||||||
use crate::fetch::{create_a_potential_cors_request, FetchCanceller};
|
use crate::fetch::{create_a_potential_cors_request, FetchCanceller};
|
||||||
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::timers::OneshotTimerCallback;
|
use crate::timers::OneshotTimerCallback;
|
||||||
|
|
||||||
|
@ -470,11 +471,13 @@ impl EventSource {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
with_credentials: bool,
|
with_credentials: bool,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<EventSource> {
|
) -> DomRoot<EventSource> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(EventSource::new_inherited(url, with_credentials)),
|
Box::new(EventSource::new_inherited(url, with_credentials)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,6 +517,7 @@ impl EventSource {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
url: DOMString,
|
url: DOMString,
|
||||||
event_source_init: &EventSourceInit,
|
event_source_init: &EventSourceInit,
|
||||||
) -> Fallible<DomRoot<EventSource>> {
|
) -> Fallible<DomRoot<EventSource>> {
|
||||||
|
@ -531,6 +535,7 @@ impl EventSource {
|
||||||
proto,
|
proto,
|
||||||
url_record.clone(),
|
url_record.clone(),
|
||||||
event_source_init.withCredentials,
|
event_source_init.withCredentials,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
global.track_event_source(&ev);
|
global.track_event_source(&ev);
|
||||||
// Steps 6-7
|
// Steps 6-7
|
||||||
|
|
|
@ -55,6 +55,7 @@ use crate::dom::virtualmethods::VirtualMethods;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||||
use crate::realms::{enter_realm, InRealm};
|
use crate::realms::{enter_realm, InRealm};
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)]
|
#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
pub enum CommonEventHandler {
|
pub enum CommonEventHandler {
|
||||||
|
@ -360,16 +361,26 @@ impl EventTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<EventTarget> {
|
fn new(
|
||||||
reflect_dom_object_with_proto(Box::new(EventTarget::new_inherited()), global, proto)
|
global: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<EventTarget> {
|
||||||
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(EventTarget::new_inherited()),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<EventTarget>> {
|
) -> Fallible<DomRoot<EventTarget>> {
|
||||||
Ok(EventTarget::new(global, proto))
|
Ok(EventTarget::new(global, proto, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determine if there are any listeners for a given event type.
|
/// Determine if there are any listeners for a given event type.
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
// https://w3c.github.io/ServiceWorker/#extendable-event
|
// https://w3c.github.io/ServiceWorker/#extendable-event
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -39,7 +39,7 @@ impl ExtendableEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
) -> DomRoot<ExtendableEvent> {
|
) -> DomRoot<ExtendableEvent> {
|
||||||
Self::new_with_proto(worker, None, type_, bubbles, cancelable)
|
Self::new_with_proto(worker, None, type_, bubbles, cancelable, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -48,11 +48,13 @@ impl ExtendableEvent {
|
||||||
type_: Atom,
|
type_: Atom,
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<ExtendableEvent> {
|
) -> DomRoot<ExtendableEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(ExtendableEvent::new_inherited()),
|
Box::new(ExtendableEvent::new_inherited()),
|
||||||
worker,
|
worker,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -64,6 +66,7 @@ impl ExtendableEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
worker: &ServiceWorkerGlobalScope,
|
worker: &ServiceWorkerGlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ExtendableEventBinding::ExtendableEventInit,
|
init: &ExtendableEventBinding::ExtendableEventInit,
|
||||||
) -> Fallible<DomRoot<ExtendableEvent>> {
|
) -> Fallible<DomRoot<ExtendableEvent>> {
|
||||||
|
@ -73,6 +76,7 @@ impl ExtendableEvent {
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use crate::dom::extendableevent::ExtendableEvent;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::messageport::MessagePort;
|
use crate::dom::messageport::MessagePort;
|
||||||
use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -85,6 +85,7 @@ impl ExtendableMessageEvent {
|
||||||
origin,
|
origin,
|
||||||
lastEventId,
|
lastEventId,
|
||||||
ports,
|
ports,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,13 +100,14 @@ impl ExtendableMessageEvent {
|
||||||
origin: DOMString,
|
origin: DOMString,
|
||||||
lastEventId: DOMString,
|
lastEventId: DOMString,
|
||||||
ports: Vec<DomRoot<MessagePort>>,
|
ports: Vec<DomRoot<MessagePort>>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<ExtendableMessageEvent> {
|
) -> DomRoot<ExtendableMessageEvent> {
|
||||||
let ev = Box::new(ExtendableMessageEvent::new_inherited(
|
let ev = Box::new(ExtendableMessageEvent::new_inherited(
|
||||||
origin,
|
origin,
|
||||||
lastEventId,
|
lastEventId,
|
||||||
ports,
|
ports,
|
||||||
));
|
));
|
||||||
let ev = reflect_dom_object_with_proto(ev, global, proto);
|
let ev = reflect_dom_object_with_proto(ev, global, proto, can_gc);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
event.init_event(type_, bubbles, cancelable);
|
event.init_event(type_, bubbles, cancelable);
|
||||||
|
@ -118,6 +120,7 @@ impl ExtendableMessageEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
worker: &ServiceWorkerGlobalScope,
|
worker: &ServiceWorkerGlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<ExtendableMessageEventBinding::ExtendableMessageEventInit>,
|
init: RootedTraceableBox<ExtendableMessageEventBinding::ExtendableMessageEventInit>,
|
||||||
) -> Fallible<DomRoot<ExtendableMessageEvent>> {
|
) -> Fallible<DomRoot<ExtendableMessageEvent>> {
|
||||||
|
@ -132,6 +135,7 @@ impl ExtendableMessageEvent {
|
||||||
init.origin.clone(),
|
init.origin.clone(),
|
||||||
init.lastEventId.clone(),
|
init.lastEventId.clone(),
|
||||||
vec![],
|
vec![],
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(ev)
|
Ok(ev)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::blob::{blob_parts_to_bytes, normalize_type_string, Blob};
|
use crate::dom::blob::{blob_parts_to_bytes, normalize_type_string, Blob};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct File {
|
pub struct File {
|
||||||
|
@ -49,7 +50,7 @@ impl File {
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
modified: Option<i64>,
|
modified: Option<i64>,
|
||||||
) -> DomRoot<File> {
|
) -> DomRoot<File> {
|
||||||
Self::new_with_proto(global, None, blob_impl, name, modified)
|
Self::new_with_proto(global, None, blob_impl, name, modified, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -59,11 +60,13 @@ impl File {
|
||||||
blob_impl: BlobImpl,
|
blob_impl: BlobImpl,
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
modified: Option<i64>,
|
modified: Option<i64>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<File> {
|
) -> DomRoot<File> {
|
||||||
let file = reflect_dom_object_with_proto(
|
let file = reflect_dom_object_with_proto(
|
||||||
Box::new(File::new_inherited(&blob_impl, name, modified)),
|
Box::new(File::new_inherited(&blob_impl, name, modified)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
global.track_file(&file, blob_impl);
|
global.track_file(&file, blob_impl);
|
||||||
file
|
file
|
||||||
|
@ -96,6 +99,7 @@ impl File {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
fileBits: Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>,
|
fileBits: Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>,
|
||||||
filename: DOMString,
|
filename: DOMString,
|
||||||
filePropertyBag: &FileBinding::FilePropertyBag,
|
filePropertyBag: &FileBinding::FilePropertyBag,
|
||||||
|
@ -118,6 +122,7 @@ impl File {
|
||||||
BlobImpl::new_from_bytes(bytes, type_string),
|
BlobImpl::new_from_bytes(bytes, type_string),
|
||||||
replaced_filename,
|
replaced_filename,
|
||||||
modified,
|
modified,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::progressevent::ProgressEvent;
|
use crate::dom::progressevent::ProgressEvent;
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
use crate::task_source::file_reading::FileReadingTask;
|
use crate::task_source::file_reading::FileReadingTask;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
|
|
||||||
|
@ -153,16 +153,21 @@ impl FileReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<FileReader> {
|
fn new(
|
||||||
reflect_dom_object_with_proto(Box::new(FileReader::new_inherited()), global, proto)
|
global: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<FileReader> {
|
||||||
|
reflect_dom_object_with_proto(Box::new(FileReader::new_inherited()), global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<FileReader>> {
|
) -> Fallible<DomRoot<FileReader>> {
|
||||||
Ok(FileReader::new(global, proto))
|
Ok(FileReader::new(global, proto, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
//https://w3c.github.io/FileAPI/#dfn-error-steps
|
//https://w3c.github.io/FileAPI/#dfn-error-steps
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::blob::Blob;
|
use crate::dom::blob::Blob;
|
||||||
use crate::dom::filereader::FileReaderSharedFunctionality;
|
use crate::dom::filereader::FileReaderSharedFunctionality;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct FileReaderSync {
|
pub struct FileReaderSync {
|
||||||
|
@ -33,16 +33,26 @@ impl FileReaderSync {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<FileReaderSync> {
|
fn new(
|
||||||
reflect_dom_object_with_proto(Box::new(FileReaderSync::new_inherited()), global, proto)
|
global: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<FileReaderSync> {
|
||||||
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(FileReaderSync::new_inherited()),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<FileReaderSync>> {
|
) -> Fallible<DomRoot<FileReaderSync>> {
|
||||||
Ok(FileReaderSync::new(global, proto))
|
Ok(FileReaderSync::new(global, proto, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_blob_bytes(blob: &Blob) -> Result<Vec<u8>, Error> {
|
fn get_blob_bytes(blob: &Blob) -> Result<Vec<u8>, Error> {
|
||||||
|
|
|
@ -19,6 +19,7 @@ use crate::dom::event::{EventBubbles, EventCancelable};
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::uievent::UIEvent;
|
use crate::dom::uievent::UIEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct FocusEvent {
|
pub struct FocusEvent {
|
||||||
|
@ -35,14 +36,15 @@ impl FocusEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(window: &Window) -> DomRoot<FocusEvent> {
|
pub fn new_uninitialized(window: &Window) -> DomRoot<FocusEvent> {
|
||||||
Self::new_uninitialized_with_proto(window, None)
|
Self::new_uninitialized_with_proto(window, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized_with_proto(
|
pub fn new_uninitialized_with_proto(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<FocusEvent> {
|
) -> DomRoot<FocusEvent> {
|
||||||
reflect_dom_object_with_proto(Box::new(FocusEvent::new_inherited()), window, proto)
|
reflect_dom_object_with_proto(Box::new(FocusEvent::new_inherited()), window, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
@ -63,6 +65,7 @@ impl FocusEvent {
|
||||||
view,
|
view,
|
||||||
detail,
|
detail,
|
||||||
related_target,
|
related_target,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +79,9 @@ impl FocusEvent {
|
||||||
view: Option<&Window>,
|
view: Option<&Window>,
|
||||||
detail: i32,
|
detail: i32,
|
||||||
related_target: Option<&EventTarget>,
|
related_target: Option<&EventTarget>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<FocusEvent> {
|
) -> DomRoot<FocusEvent> {
|
||||||
let ev = FocusEvent::new_uninitialized_with_proto(window, proto);
|
let ev = FocusEvent::new_uninitialized_with_proto(window, proto, can_gc);
|
||||||
ev.upcast::<UIEvent>().InitUIEvent(
|
ev.upcast::<UIEvent>().InitUIEvent(
|
||||||
type_,
|
type_,
|
||||||
bool::from(can_bubble),
|
bool::from(can_bubble),
|
||||||
|
@ -93,6 +97,7 @@ impl FocusEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &FocusEventBinding::FocusEventInit,
|
init: &FocusEventBinding::FocusEventInit,
|
||||||
) -> Fallible<DomRoot<FocusEvent>> {
|
) -> Fallible<DomRoot<FocusEvent>> {
|
||||||
|
@ -107,6 +112,7 @@ impl FocusEvent {
|
||||||
init.parent.view.as_deref(),
|
init.parent.view.as_deref(),
|
||||||
init.parent.detail,
|
init.parent.detail,
|
||||||
init.relatedTarget.as_deref(),
|
init.relatedTarget.as_deref(),
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct FontFaceSet {
|
pub struct FontFaceSet {
|
||||||
|
@ -31,7 +32,12 @@ impl FontFaceSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<Self> {
|
pub fn new(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<Self> {
|
||||||
reflect_dom_object_with_proto(Box::new(FontFaceSet::new_inherited(global)), global, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(FontFaceSet::new_inherited(global)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fulfill_ready_promise_if_needed(&self) {
|
pub fn fulfill_ready_promise_if_needed(&self) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ use crate::dom::blob::Blob;
|
||||||
use crate::dom::file::File;
|
use crate::dom::file::File;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::htmlformelement::{FormDatum, FormDatumValue, HTMLFormElement};
|
use crate::dom::htmlformelement::{FormDatum, FormDatumValue, HTMLFormElement};
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct FormData {
|
pub struct FormData {
|
||||||
|
@ -45,18 +46,20 @@ impl FormData {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(form_datums: Option<Vec<FormDatum>>, global: &GlobalScope) -> DomRoot<FormData> {
|
pub fn new(form_datums: Option<Vec<FormDatum>>, global: &GlobalScope) -> DomRoot<FormData> {
|
||||||
Self::new_with_proto(form_datums, global, None)
|
Self::new_with_proto(form_datums, global, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
form_datums: Option<Vec<FormDatum>>,
|
form_datums: Option<Vec<FormDatum>>,
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<FormData> {
|
) -> DomRoot<FormData> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(FormData::new_inherited(form_datums)),
|
Box::new(FormData::new_inherited(form_datums)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,16 +68,22 @@ impl FormData {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
form: Option<&HTMLFormElement>,
|
form: Option<&HTMLFormElement>,
|
||||||
) -> Fallible<DomRoot<FormData>> {
|
) -> Fallible<DomRoot<FormData>> {
|
||||||
if let Some(opt_form) = form {
|
if let Some(opt_form) = form {
|
||||||
return match opt_form.get_form_dataset(None, None) {
|
return match opt_form.get_form_dataset(None, None) {
|
||||||
Some(form_datums) => Ok(FormData::new_with_proto(Some(form_datums), global, proto)),
|
Some(form_datums) => Ok(FormData::new_with_proto(
|
||||||
|
Some(form_datums),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)),
|
||||||
None => Err(Error::InvalidState),
|
None => Err(Error::InvalidState),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(FormData::new_with_proto(None, global, proto))
|
Ok(FormData::new_with_proto(None, global, proto, can_gc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::formdata::FormData;
|
use crate::dom::formdata::FormData;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct FormDataEvent {
|
pub struct FormDataEvent {
|
||||||
|
@ -33,7 +34,15 @@ impl FormDataEvent {
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
form_data: &FormData,
|
form_data: &FormData,
|
||||||
) -> DomRoot<FormDataEvent> {
|
) -> DomRoot<FormDataEvent> {
|
||||||
Self::new_with_proto(global, None, type_, can_bubble, cancelable, form_data)
|
Self::new_with_proto(
|
||||||
|
global,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
can_bubble,
|
||||||
|
cancelable,
|
||||||
|
form_data,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -43,6 +52,7 @@ impl FormDataEvent {
|
||||||
can_bubble: EventBubbles,
|
can_bubble: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
form_data: &FormData,
|
form_data: &FormData,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<FormDataEvent> {
|
) -> DomRoot<FormDataEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(FormDataEvent {
|
Box::new(FormDataEvent {
|
||||||
|
@ -51,6 +61,7 @@ impl FormDataEvent {
|
||||||
}),
|
}),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -64,6 +75,7 @@ impl FormDataEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &FormDataEventBinding::FormDataEventInit,
|
init: &FormDataEventBinding::FormDataEventInit,
|
||||||
) -> Fallible<DomRoot<FormDataEvent>> {
|
) -> Fallible<DomRoot<FormDataEvent>> {
|
||||||
|
@ -77,6 +89,7 @@ impl FormDataEvent {
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
&init.formData.clone(),
|
&init.formData.clone(),
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(event)
|
Ok(event)
|
||||||
|
|
|
@ -22,6 +22,7 @@ use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GainNode {
|
pub struct GainNode {
|
||||||
|
@ -69,7 +70,7 @@ impl GainNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &GainOptions,
|
options: &GainOptions,
|
||||||
) -> Fallible<DomRoot<GainNode>> {
|
) -> Fallible<DomRoot<GainNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -78,19 +79,26 @@ impl GainNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &GainOptions,
|
options: &GainOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<GainNode>> {
|
) -> Fallible<DomRoot<GainNode>> {
|
||||||
let node = GainNode::new_inherited(window, context, options)?;
|
let node = GainNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &GainOptions,
|
options: &GainOptions,
|
||||||
) -> Fallible<DomRoot<GainNode>> {
|
) -> Fallible<DomRoot<GainNode>> {
|
||||||
GainNode::new_with_proto(window, proto, context, options)
|
GainNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::dom::gamepadevent::{GamepadEvent, GamepadEventType};
|
||||||
use crate::dom::gamepadhapticactuator::GamepadHapticActuator;
|
use crate::dom::gamepadhapticactuator::GamepadHapticActuator;
|
||||||
use crate::dom::gamepadpose::GamepadPose;
|
use crate::dom::gamepadpose::GamepadPose;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
// This value is for determining when to consider a gamepad as having a user gesture
|
// This value is for determining when to consider a gamepad as having a user gesture
|
||||||
// from an axis tilt. This matches the threshold in Chromium.
|
// from an axis tilt. This matches the threshold in Chromium.
|
||||||
|
@ -142,6 +142,7 @@ impl Gamepad {
|
||||||
)),
|
)),
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
|
CanGc::note(),
|
||||||
);
|
);
|
||||||
gamepad.init_axes();
|
gamepad.init_axes();
|
||||||
gamepad
|
gamepad
|
||||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::event::Event;
|
||||||
use crate::dom::gamepad::Gamepad;
|
use crate::dom::gamepad::Gamepad;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GamepadEvent {
|
pub struct GamepadEvent {
|
||||||
|
@ -45,7 +46,15 @@ impl GamepadEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
gamepad: &Gamepad,
|
gamepad: &Gamepad,
|
||||||
) -> DomRoot<GamepadEvent> {
|
) -> DomRoot<GamepadEvent> {
|
||||||
Self::new_with_proto(global, None, type_, bubbles, cancelable, gamepad)
|
Self::new_with_proto(
|
||||||
|
global,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
gamepad,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -55,11 +64,13 @@ impl GamepadEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
gamepad: &Gamepad,
|
gamepad: &Gamepad,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<GamepadEvent> {
|
) -> DomRoot<GamepadEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(GamepadEvent::new_inherited(gamepad)),
|
Box::new(GamepadEvent::new_inherited(gamepad)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -86,6 +97,7 @@ impl GamepadEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &GamepadEventBinding::GamepadEventInit,
|
init: &GamepadEventBinding::GamepadEventInit,
|
||||||
) -> Fallible<DomRoot<GamepadEvent>> {
|
) -> Fallible<DomRoot<GamepadEvent>> {
|
||||||
|
@ -96,6 +108,7 @@ impl GamepadEvent {
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
&init.gamepad,
|
&init.gamepad,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::dom::bindings::utils::to_frozen_array;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::gamepad::GamepadTaskSource;
|
use crate::task_source::gamepad::GamepadTaskSource;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
|
@ -125,6 +125,7 @@ impl GamepadHapticActuator {
|
||||||
)),
|
)),
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
|
CanGc::note(),
|
||||||
);
|
);
|
||||||
haptic_actuator
|
haptic_actuator
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use super::bindings::utils::to_frozen_array;
|
||||||
use super::types::GPUCompilationMessage;
|
use super::types::GPUCompilationMessage;
|
||||||
use crate::dom::bindings::reflector::Reflector;
|
use crate::dom::bindings::reflector::Reflector;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUCompilationInfo {
|
pub struct GPUCompilationInfo {
|
||||||
|
@ -32,7 +32,12 @@ impl GPUCompilationInfo {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn new(global: &GlobalScope, msg: Vec<DomRoot<GPUCompilationMessage>>) -> DomRoot<Self> {
|
pub fn new(global: &GlobalScope, msg: Vec<DomRoot<GPUCompilationMessage>>) -> DomRoot<Self> {
|
||||||
reflect_dom_object_with_proto(Box::new(Self::new_inherited(msg)), global, None)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(Self::new_inherited(msg)),
|
||||||
|
global,
|
||||||
|
None,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from(global: &GlobalScope, error: Option<ShaderCompilationInfo>) -> DomRoot<Self> {
|
pub fn from(global: &GlobalScope, error: Option<ShaderCompilationInfo>) -> DomRoot<Self> {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUError {
|
pub struct GPUError {
|
||||||
|
@ -38,7 +39,12 @@ impl GPUError {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object_with_proto(Box::new(GPUError::new_inherited(message)), global, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(GPUError::new_inherited(message)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_error(global: &GlobalScope, error: Error) -> DomRoot<Self> {
|
pub fn from_error(global: &GlobalScope, error: Error) -> DomRoot<Self> {
|
||||||
|
@ -47,16 +53,19 @@ impl GPUError {
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
DOMString::from_string(msg),
|
DOMString::from_string(msg),
|
||||||
|
CanGc::note(),
|
||||||
)),
|
)),
|
||||||
Error::OutOfMemory(msg) => DomRoot::upcast(GPUOutOfMemoryError::new_with_proto(
|
Error::OutOfMemory(msg) => DomRoot::upcast(GPUOutOfMemoryError::new_with_proto(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
DOMString::from_string(msg),
|
DOMString::from_string(msg),
|
||||||
|
CanGc::note(),
|
||||||
)),
|
)),
|
||||||
Error::Internal(msg) => DomRoot::upcast(GPUInternalError::new_with_proto(
|
Error::Internal(msg) => DomRoot::upcast(GPUInternalError::new_with_proto(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
DOMString::from_string(msg),
|
DOMString::from_string(msg),
|
||||||
|
CanGc::note(),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUInternalError {
|
pub struct GPUInternalError {
|
||||||
|
@ -27,8 +28,14 @@ impl GPUInternalError {
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object_with_proto(Box::new(Self::new_inherited(message)), global, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(Self::new_inherited(message)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-GPUInternalError-GPUInternalError>
|
/// <https://gpuweb.github.io/gpuweb/#dom-GPUInternalError-GPUInternalError>
|
||||||
|
@ -36,8 +43,9 @@ impl GPUInternalError {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
Self::new_with_proto(global, proto, message)
|
Self::new_with_proto(global, proto, message, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUOutOfMemoryError {
|
pub struct GPUOutOfMemoryError {
|
||||||
|
@ -27,8 +28,14 @@ impl GPUOutOfMemoryError {
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object_with_proto(Box::new(Self::new_inherited(message)), global, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(Self::new_inherited(message)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-GPUOutOfMemoryError-GPUOutOfMemoryError>
|
/// <https://gpuweb.github.io/gpuweb/#dom-GPUOutOfMemoryError-GPUOutOfMemoryError>
|
||||||
|
@ -36,8 +43,9 @@ impl GPUOutOfMemoryError {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
Self::new_with_proto(global, proto, message)
|
Self::new_with_proto(global, proto, message, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::domexception::DOMException;
|
use crate::dom::domexception::DOMException;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#gpupipelineerror>
|
/// <https://gpuweb.github.io/gpuweb/#gpupipelineerror>
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -34,11 +35,13 @@ impl GPUPipelineError {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
reason: GPUPipelineErrorReason,
|
reason: GPUPipelineErrorReason,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(Self::new_inherited(message, reason)),
|
Box::new(Self::new_inherited(message, reason)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +50,7 @@ impl GPUPipelineError {
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
reason: GPUPipelineErrorReason,
|
reason: GPUPipelineErrorReason,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
Self::new_with_proto(global, None, message, reason)
|
Self::new_with_proto(global, None, message, reason, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpupipelineerror-constructor>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpupipelineerror-constructor>
|
||||||
|
@ -55,10 +58,11 @@ impl GPUPipelineError {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
options: &GPUPipelineErrorInit,
|
options: &GPUPipelineErrorInit,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
Self::new_with_proto(global, proto, message, options.reason)
|
Self::new_with_proto(global, proto, message, options.reason, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// manual hash derived
|
// manual hash derived
|
||||||
// TODO: allow derivables in bindings.conf
|
// TODO: allow derivables in bindings.conf
|
||||||
|
@ -102,6 +103,7 @@ impl GPUSupportedFeatures {
|
||||||
}),
|
}),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::gpuerror::GPUError;
|
use crate::dom::gpuerror::GPUError;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUUncapturedErrorEvent {
|
pub struct GPUUncapturedErrorEvent {
|
||||||
|
@ -37,7 +38,7 @@ impl GPUUncapturedErrorEvent {
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &GPUUncapturedErrorEventInit,
|
init: &GPUUncapturedErrorEventInit,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
Self::new_with_proto(global, None, type_, init)
|
Self::new_with_proto(global, None, type_, init, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -45,11 +46,13 @@ impl GPUUncapturedErrorEvent {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &GPUUncapturedErrorEventInit,
|
init: &GPUUncapturedErrorEventInit,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(GPUUncapturedErrorEvent::new_inherited(init)),
|
Box::new(GPUUncapturedErrorEvent::new_inherited(init)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
ev.event.init_event(
|
ev.event.init_event(
|
||||||
Atom::from(type_),
|
Atom::from(type_),
|
||||||
|
@ -64,10 +67,11 @@ impl GPUUncapturedErrorEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &GPUUncapturedErrorEventInit,
|
init: &GPUUncapturedErrorEventInit,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
GPUUncapturedErrorEvent::new_with_proto(global, proto, type_, init)
|
GPUUncapturedErrorEvent::new_with_proto(global, proto, type_, init, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUValidationError {
|
pub struct GPUValidationError {
|
||||||
|
@ -27,8 +28,14 @@ impl GPUValidationError {
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object_with_proto(Box::new(Self::new_inherited(message)), global, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(Self::new_inherited(message)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuvalidationerror-gpuvalidationerror>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpuvalidationerror-gpuvalidationerror>
|
||||||
|
@ -36,8 +43,9 @@ impl GPUValidationError {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
Self::new_with_proto(global, proto, message)
|
Self::new_with_proto(global, proto, message, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::{DOMString, USVString};
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#hashchangeevent
|
// https://html.spec.whatwg.org/multipage/#hashchangeevent
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -46,6 +47,7 @@ impl HashChangeEvent {
|
||||||
Box::new(HashChangeEvent::new_inherited(String::new(), String::new())),
|
Box::new(HashChangeEvent::new_inherited(String::new(), String::new())),
|
||||||
window,
|
window,
|
||||||
proto,
|
proto,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +59,16 @@ impl HashChangeEvent {
|
||||||
old_url: String,
|
old_url: String,
|
||||||
new_url: String,
|
new_url: String,
|
||||||
) -> DomRoot<HashChangeEvent> {
|
) -> DomRoot<HashChangeEvent> {
|
||||||
Self::new_with_proto(window, None, type_, bubbles, cancelable, old_url, new_url)
|
Self::new_with_proto(
|
||||||
|
window,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
old_url,
|
||||||
|
new_url,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -68,11 +79,13 @@ impl HashChangeEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
old_url: String,
|
old_url: String,
|
||||||
new_url: String,
|
new_url: String,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<HashChangeEvent> {
|
) -> DomRoot<HashChangeEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(HashChangeEvent::new_inherited(old_url, new_url)),
|
Box::new(HashChangeEvent::new_inherited(old_url, new_url)),
|
||||||
window,
|
window,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -85,6 +98,7 @@ impl HashChangeEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &HashChangeEventBinding::HashChangeEventInit,
|
init: &HashChangeEventBinding::HashChangeEventInit,
|
||||||
) -> Fallible<DomRoot<HashChangeEvent>> {
|
) -> Fallible<DomRoot<HashChangeEvent>> {
|
||||||
|
@ -96,6 +110,7 @@ impl HashChangeEvent {
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
init.oldURL.0.clone(),
|
init.oldURL.0.clone(),
|
||||||
init.newURL.0.clone(),
|
init.newURL.0.clone(),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::{is_token, ByteString};
|
use crate::dom::bindings::str::{is_token, ByteString};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct Headers {
|
pub struct Headers {
|
||||||
|
@ -50,11 +51,15 @@ impl Headers {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> DomRoot<Headers> {
|
pub fn new(global: &GlobalScope) -> DomRoot<Headers> {
|
||||||
Self::new_with_proto(global, None)
|
Self::new_with_proto(global, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<Headers> {
|
fn new_with_proto(
|
||||||
reflect_dom_object_with_proto(Box::new(Headers::new_inherited()), global, proto)
|
global: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<Headers> {
|
||||||
|
reflect_dom_object_with_proto(Box::new(Headers::new_inherited()), global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-headers
|
// https://fetch.spec.whatwg.org/#dom-headers
|
||||||
|
@ -62,9 +67,10 @@ impl Headers {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
init: Option<HeadersInit>,
|
init: Option<HeadersInit>,
|
||||||
) -> Fallible<DomRoot<Headers>> {
|
) -> Fallible<DomRoot<Headers>> {
|
||||||
let dom_headers_new = Headers::new_with_proto(global, proto);
|
let dom_headers_new = Headers::new_with_proto(global, proto, can_gc);
|
||||||
dom_headers_new.fill(init)?;
|
dom_headers_new.fill(init)?;
|
||||||
Ok(dom_headers_new)
|
Ok(dom_headers_new)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ use crate::dom::element::{CustomElementCreationMode, Element, ElementCreator};
|
||||||
use crate::dom::htmlmediaelement::HTMLMediaElement;
|
use crate::dom::htmlmediaelement::HTMLMediaElement;
|
||||||
use crate::dom::node::Node;
|
use crate::dom::node::Node;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLAudioElement {
|
pub struct HTMLAudioElement {
|
||||||
|
@ -55,6 +56,7 @@ impl HTMLAudioElement {
|
||||||
pub fn Audio(
|
pub fn Audio(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
_can_gc: CanGc,
|
||||||
src: Option<DOMString>,
|
src: Option<DOMString>,
|
||||||
) -> Fallible<DomRoot<HTMLAudioElement>> {
|
) -> Fallible<DomRoot<HTMLAudioElement>> {
|
||||||
let element = Element::create(
|
let element = Element::create(
|
||||||
|
|
|
@ -96,6 +96,7 @@ use crate::image_listener::{generate_cache_listener_for_element, ImageCacheListe
|
||||||
use crate::microtask::{Microtask, MicrotaskRunnable};
|
use crate::microtask::{Microtask, MicrotaskRunnable};
|
||||||
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
|
||||||
|
@ -1327,6 +1328,7 @@ impl HTMLImageElement {
|
||||||
pub fn Image(
|
pub fn Image(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
_can_gc: CanGc,
|
||||||
width: Option<u32>,
|
width: Option<u32>,
|
||||||
height: Option<u32>,
|
height: Option<u32>,
|
||||||
) -> Fallible<DomRoot<HTMLImageElement>> {
|
) -> Fallible<DomRoot<HTMLImageElement>> {
|
||||||
|
|
|
@ -35,6 +35,7 @@ use crate::dom::validation::Validatable;
|
||||||
use crate::dom::validitystate::ValidationFlags;
|
use crate::dom::validitystate::ValidationFlags;
|
||||||
use crate::dom::virtualmethods::VirtualMethods;
|
use crate::dom::virtualmethods::VirtualMethods;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLOptionElement {
|
pub struct HTMLOptionElement {
|
||||||
|
@ -86,6 +87,7 @@ impl HTMLOptionElement {
|
||||||
pub fn Option(
|
pub fn Option(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
_can_gc: CanGc,
|
||||||
text: DOMString,
|
text: DOMString,
|
||||||
value: Option<DOMString>,
|
value: Option<DOMString>,
|
||||||
default_selected: bool,
|
default_selected: bool,
|
||||||
|
|
|
@ -25,6 +25,7 @@ use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct IIRFilterNode {
|
pub struct IIRFilterNode {
|
||||||
|
@ -72,7 +73,7 @@ impl IIRFilterNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &IIRFilterOptions,
|
options: &IIRFilterOptions,
|
||||||
) -> Fallible<DomRoot<IIRFilterNode>> {
|
) -> Fallible<DomRoot<IIRFilterNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -81,19 +82,26 @@ impl IIRFilterNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &IIRFilterOptions,
|
options: &IIRFilterOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<IIRFilterNode>> {
|
) -> Fallible<DomRoot<IIRFilterNode>> {
|
||||||
let node = IIRFilterNode::new_inherited(window, context, options)?;
|
let node = IIRFilterNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &IIRFilterOptions,
|
options: &IIRFilterOptions,
|
||||||
) -> Fallible<DomRoot<IIRFilterNode>> {
|
) -> Fallible<DomRoot<IIRFilterNode>> {
|
||||||
IIRFilterNode::new_with_proto(window, proto, context, options)
|
IIRFilterNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::dom::bindings::error::{Error, Fallible};
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct ImageData {
|
pub struct ImageData {
|
||||||
|
@ -48,9 +48,16 @@ impl ImageData {
|
||||||
d.resize(len as usize, 0);
|
d.resize(len as usize, 0);
|
||||||
let data = CreateWith::Slice(&d[..]);
|
let data = CreateWith::Slice(&d[..]);
|
||||||
Uint8ClampedArray::create(*cx, data, js_object.handle_mut()).unwrap();
|
Uint8ClampedArray::create(*cx, data, js_object.handle_mut()).unwrap();
|
||||||
Self::new_with_jsobject(global, None, width, Some(height), js_object.get())
|
Self::new_with_jsobject(
|
||||||
|
global,
|
||||||
|
None,
|
||||||
|
width,
|
||||||
|
Some(height),
|
||||||
|
js_object.get(),
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Self::new_without_jsobject(global, None, width, height)
|
Self::new_without_jsobject(global, None, width, height, CanGc::note())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +69,7 @@ impl ImageData {
|
||||||
width: u32,
|
width: u32,
|
||||||
opt_height: Option<u32>,
|
opt_height: Option<u32>,
|
||||||
jsobject: *mut JSObject,
|
jsobject: *mut JSObject,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<ImageData>> {
|
) -> Fallible<DomRoot<ImageData>> {
|
||||||
let heap_typed_array = match new_initialized_heap_buffer_source::<ClampedU8>(
|
let heap_typed_array = match new_initialized_heap_buffer_source::<ClampedU8>(
|
||||||
HeapTypedArrayInit::Buffer(BufferSource::Uint8ClampedArray(Heap::boxed(jsobject))),
|
HeapTypedArrayInit::Buffer(BufferSource::Uint8ClampedArray(Heap::boxed(jsobject))),
|
||||||
|
@ -101,7 +109,9 @@ impl ImageData {
|
||||||
data: heap_typed_array,
|
data: heap_typed_array,
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(reflect_dom_object_with_proto(imagedata, global, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
imagedata, global, proto, can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_without_jsobject(
|
fn new_without_jsobject(
|
||||||
|
@ -109,6 +119,7 @@ impl ImageData {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<ImageData>> {
|
) -> Fallible<DomRoot<ImageData>> {
|
||||||
if width == 0 || height == 0 {
|
if width == 0 || height == 0 {
|
||||||
return Err(Error::IndexSize);
|
return Err(Error::IndexSize);
|
||||||
|
@ -131,17 +142,20 @@ impl ImageData {
|
||||||
data: heap_typed_array,
|
data: heap_typed_array,
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(reflect_dom_object_with_proto(imagedata, global, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
imagedata, global, proto, can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
/// <https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-3>
|
/// <https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-3>
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Fallible<DomRoot<Self>> {
|
) -> Fallible<DomRoot<Self>> {
|
||||||
Self::new_without_jsobject(global, proto, width, height)
|
Self::new_without_jsobject(global, proto, width, height, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-4>
|
/// <https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-4>
|
||||||
|
@ -150,11 +164,12 @@ impl ImageData {
|
||||||
cx: JSContext,
|
cx: JSContext,
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
jsobject: *mut JSObject,
|
jsobject: *mut JSObject,
|
||||||
width: u32,
|
width: u32,
|
||||||
opt_height: Option<u32>,
|
opt_height: Option<u32>,
|
||||||
) -> Fallible<DomRoot<Self>> {
|
) -> Fallible<DomRoot<Self>> {
|
||||||
Self::new_with_jsobject(global, proto, width, opt_height, jsobject)
|
Self::new_with_jsobject(global, proto, width, opt_height, jsobject, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Nothing must change the array on the JS side while the slice is live.
|
/// Nothing must change the array on the JS side while the slice is live.
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::uievent::UIEvent;
|
use crate::dom::uievent::UIEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct InputEvent {
|
pub struct InputEvent {
|
||||||
|
@ -33,6 +34,7 @@ impl InputEvent {
|
||||||
detail: i32,
|
detail: i32,
|
||||||
data: Option<DOMString>,
|
data: Option<DOMString>,
|
||||||
is_composing: bool,
|
is_composing: bool,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<InputEvent> {
|
) -> DomRoot<InputEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(InputEvent {
|
Box::new(InputEvent {
|
||||||
|
@ -42,6 +44,7 @@ impl InputEvent {
|
||||||
}),
|
}),
|
||||||
window,
|
window,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
ev.uievent
|
ev.uievent
|
||||||
.InitUIEvent(type_, can_bubble, cancelable, view, detail);
|
.InitUIEvent(type_, can_bubble, cancelable, view, detail);
|
||||||
|
@ -52,6 +55,7 @@ impl InputEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &InputEventBinding::InputEventInit,
|
init: &InputEventBinding::InputEventInit,
|
||||||
) -> Fallible<DomRoot<InputEvent>> {
|
) -> Fallible<DomRoot<InputEvent>> {
|
||||||
|
@ -65,6 +69,7 @@ impl InputEvent {
|
||||||
init.parent.detail,
|
init.parent.detail,
|
||||||
init.data.clone(),
|
init.data.clone(),
|
||||||
init.isComposing,
|
init.isComposing,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::uievent::UIEvent;
|
use crate::dom::uievent::UIEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct KeyboardEvent {
|
pub struct KeyboardEvent {
|
||||||
|
@ -54,14 +55,20 @@ impl KeyboardEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(window: &Window) -> DomRoot<KeyboardEvent> {
|
pub fn new_uninitialized(window: &Window) -> DomRoot<KeyboardEvent> {
|
||||||
Self::new_uninitialized_with_proto(window, None)
|
Self::new_uninitialized_with_proto(window, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_uninitialized_with_proto(
|
fn new_uninitialized_with_proto(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<KeyboardEvent> {
|
) -> DomRoot<KeyboardEvent> {
|
||||||
reflect_dom_object_with_proto(Box::new(KeyboardEvent::new_inherited()), window, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(KeyboardEvent::new_inherited()),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
@ -97,6 +104,7 @@ impl KeyboardEvent {
|
||||||
modifiers,
|
modifiers,
|
||||||
char_code,
|
char_code,
|
||||||
key_code,
|
key_code,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +125,9 @@ impl KeyboardEvent {
|
||||||
modifiers: Modifiers,
|
modifiers: Modifiers,
|
||||||
char_code: u32,
|
char_code: u32,
|
||||||
key_code: u32,
|
key_code: u32,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<KeyboardEvent> {
|
) -> DomRoot<KeyboardEvent> {
|
||||||
let ev = KeyboardEvent::new_uninitialized_with_proto(window, proto);
|
let ev = KeyboardEvent::new_uninitialized_with_proto(window, proto, can_gc);
|
||||||
ev.InitKeyboardEvent(
|
ev.InitKeyboardEvent(
|
||||||
type_,
|
type_,
|
||||||
can_bubble,
|
can_bubble,
|
||||||
|
@ -143,6 +152,7 @@ impl KeyboardEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &KeyboardEventBinding::KeyboardEventInit,
|
init: &KeyboardEventBinding::KeyboardEventInit,
|
||||||
) -> Fallible<DomRoot<KeyboardEvent>> {
|
) -> Fallible<DomRoot<KeyboardEvent>> {
|
||||||
|
@ -167,6 +177,7 @@ impl KeyboardEvent {
|
||||||
modifiers,
|
modifiers,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
*event.key.borrow_mut() = init.key.clone();
|
*event.key.borrow_mut() = init.key.clone();
|
||||||
Ok(event)
|
Ok(event)
|
||||||
|
|
|
@ -19,6 +19,7 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::htmlmediaelement::HTMLMediaElement;
|
use crate::dom::htmlmediaelement::HTMLMediaElement;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MediaElementAudioSourceNode {
|
pub struct MediaElementAudioSourceNode {
|
||||||
|
@ -57,7 +58,7 @@ impl MediaElementAudioSourceNode {
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
media_element: &HTMLMediaElement,
|
media_element: &HTMLMediaElement,
|
||||||
) -> Fallible<DomRoot<MediaElementAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaElementAudioSourceNode>> {
|
||||||
Self::new_with_proto(window, None, context, media_element)
|
Self::new_with_proto(window, None, context, media_element, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -66,19 +67,32 @@ impl MediaElementAudioSourceNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
media_element: &HTMLMediaElement,
|
media_element: &HTMLMediaElement,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<MediaElementAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaElementAudioSourceNode>> {
|
||||||
let node = MediaElementAudioSourceNode::new_inherited(context, media_element)?;
|
let node = MediaElementAudioSourceNode::new_inherited(context, media_element)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
options: &MediaElementAudioSourceOptions,
|
options: &MediaElementAudioSourceOptions,
|
||||||
) -> Fallible<DomRoot<MediaElementAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaElementAudioSourceNode>> {
|
||||||
MediaElementAudioSourceNode::new_with_proto(window, proto, context, &options.mediaElement)
|
MediaElementAudioSourceNode::new_with_proto(
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
context,
|
||||||
|
&options.mediaElement,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::mediasession::MediaSession;
|
use crate::dom::mediasession::MediaSession;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MediaMetadata {
|
pub struct MediaMetadata {
|
||||||
|
@ -37,15 +38,21 @@ impl MediaMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &Window, init: &MediaMetadataInit) -> DomRoot<MediaMetadata> {
|
pub fn new(global: &Window, init: &MediaMetadataInit) -> DomRoot<MediaMetadata> {
|
||||||
Self::new_with_proto(global, None, init)
|
Self::new_with_proto(global, None, init, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
global: &Window,
|
global: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
init: &MediaMetadataInit,
|
init: &MediaMetadataInit,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MediaMetadata> {
|
) -> DomRoot<MediaMetadata> {
|
||||||
reflect_dom_object_with_proto(Box::new(MediaMetadata::new_inherited(init)), global, proto)
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(MediaMetadata::new_inherited(init)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://w3c.github.io/mediasession/#dom-mediametadata-mediametadata>
|
/// <https://w3c.github.io/mediasession/#dom-mediametadata-mediametadata>
|
||||||
|
@ -53,9 +60,10 @@ impl MediaMetadata {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
init: &MediaMetadataInit,
|
init: &MediaMetadataInit,
|
||||||
) -> Fallible<DomRoot<MediaMetadata>> {
|
) -> Fallible<DomRoot<MediaMetadata>> {
|
||||||
Ok(MediaMetadata::new_with_proto(window, proto, init))
|
Ok(MediaMetadata::new_with_proto(window, proto, init, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn queue_update_metadata_algorithm(&self) {
|
fn queue_update_metadata_algorithm(&self) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylistevent-mediaquerylistevent
|
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylistevent-mediaquerylistevent
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -35,13 +36,14 @@ impl MediaQueryListEvent {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
media: DOMString,
|
media: DOMString,
|
||||||
matches: bool,
|
matches: bool,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MediaQueryListEvent> {
|
) -> DomRoot<MediaQueryListEvent> {
|
||||||
let ev = Box::new(MediaQueryListEvent {
|
let ev = Box::new(MediaQueryListEvent {
|
||||||
event: Event::new_inherited(),
|
event: Event::new_inherited(),
|
||||||
media,
|
media,
|
||||||
matches: Cell::new(matches),
|
matches: Cell::new(matches),
|
||||||
});
|
});
|
||||||
reflect_dom_object_with_proto(ev, global, proto)
|
reflect_dom_object_with_proto(ev, global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
@ -52,7 +54,16 @@ impl MediaQueryListEvent {
|
||||||
media: DOMString,
|
media: DOMString,
|
||||||
matches: bool,
|
matches: bool,
|
||||||
) -> DomRoot<MediaQueryListEvent> {
|
) -> DomRoot<MediaQueryListEvent> {
|
||||||
Self::new_with_proto(global, None, type_, bubbles, cancelable, media, matches)
|
Self::new_with_proto(
|
||||||
|
global,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
media,
|
||||||
|
matches,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -63,8 +74,9 @@ impl MediaQueryListEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
media: DOMString,
|
media: DOMString,
|
||||||
matches: bool,
|
matches: bool,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MediaQueryListEvent> {
|
) -> DomRoot<MediaQueryListEvent> {
|
||||||
let ev = MediaQueryListEvent::new_initialized(global, proto, media, matches);
|
let ev = MediaQueryListEvent::new_initialized(global, proto, media, matches, can_gc);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
event.init_event(type_, bubbles, cancelable);
|
event.init_event(type_, bubbles, cancelable);
|
||||||
|
@ -76,6 +88,7 @@ impl MediaQueryListEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &MediaQueryListEventInit,
|
init: &MediaQueryListEventInit,
|
||||||
) -> Fallible<DomRoot<MediaQueryListEvent>> {
|
) -> Fallible<DomRoot<MediaQueryListEvent>> {
|
||||||
|
@ -88,6 +101,7 @@ impl MediaQueryListEvent {
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
init.media.clone(),
|
init.media.clone(),
|
||||||
init.matches,
|
init.matches,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::mediastreamtrack::MediaStreamTrack;
|
use crate::dom::mediastreamtrack::MediaStreamTrack;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MediaStream {
|
pub struct MediaStream {
|
||||||
|
@ -34,11 +35,20 @@ impl MediaStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> DomRoot<MediaStream> {
|
pub fn new(global: &GlobalScope) -> DomRoot<MediaStream> {
|
||||||
Self::new_with_proto(global, None)
|
Self::new_with_proto(global, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<MediaStream> {
|
fn new_with_proto(
|
||||||
reflect_dom_object_with_proto(Box::new(MediaStream::new_inherited()), global, proto)
|
global: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<MediaStream> {
|
||||||
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(MediaStream::new_inherited()),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_single(
|
pub fn new_single(
|
||||||
|
@ -55,24 +65,27 @@ impl MediaStream {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &Window,
|
global: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<MediaStream>> {
|
) -> Fallible<DomRoot<MediaStream>> {
|
||||||
Ok(MediaStream::new_with_proto(&global.global(), proto))
|
Ok(MediaStream::new_with_proto(&global.global(), proto, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor_(
|
pub fn Constructor_(
|
||||||
_: &Window,
|
_: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
stream: &MediaStream,
|
stream: &MediaStream,
|
||||||
) -> Fallible<DomRoot<MediaStream>> {
|
) -> Fallible<DomRoot<MediaStream>> {
|
||||||
Ok(stream.clone_with_proto(proto))
|
Ok(stream.clone_with_proto(proto, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor__(
|
pub fn Constructor__(
|
||||||
global: &Window,
|
global: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
tracks: Vec<DomRoot<MediaStreamTrack>>,
|
tracks: Vec<DomRoot<MediaStreamTrack>>,
|
||||||
) -> Fallible<DomRoot<MediaStream>> {
|
) -> Fallible<DomRoot<MediaStream>> {
|
||||||
let new = MediaStream::new_with_proto(&global.global(), proto);
|
let new = MediaStream::new_with_proto(&global.global(), proto, can_gc);
|
||||||
for track in tracks {
|
for track in tracks {
|
||||||
// this is quadratic, but shouldn't matter much
|
// this is quadratic, but shouldn't matter much
|
||||||
// if this becomes a problem we can use a hash map
|
// if this becomes a problem we can use a hash map
|
||||||
|
@ -146,13 +159,13 @@ impl MediaStreamMethods for MediaStream {
|
||||||
|
|
||||||
/// <https://w3c.github.io/mediacapture-main/#dom-mediastream-clone>
|
/// <https://w3c.github.io/mediacapture-main/#dom-mediastream-clone>
|
||||||
fn Clone(&self) -> DomRoot<MediaStream> {
|
fn Clone(&self) -> DomRoot<MediaStream> {
|
||||||
self.clone_with_proto(None)
|
self.clone_with_proto(None, CanGc::note())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MediaStream {
|
impl MediaStream {
|
||||||
fn clone_with_proto(&self, proto: Option<HandleObject>) -> DomRoot<MediaStream> {
|
fn clone_with_proto(&self, proto: Option<HandleObject>, can_gc: CanGc) -> DomRoot<MediaStream> {
|
||||||
let new = MediaStream::new_with_proto(&self.global(), proto);
|
let new = MediaStream::new_with_proto(&self.global(), proto, can_gc);
|
||||||
for track in &*self.tracks.borrow() {
|
for track in &*self.tracks.borrow() {
|
||||||
new.add_track(track)
|
new.add_track(track)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject};
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::mediastream::MediaStream;
|
use crate::dom::mediastream::MediaStream;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MediaStreamAudioDestinationNode {
|
pub struct MediaStreamAudioDestinationNode {
|
||||||
|
@ -59,7 +60,7 @@ impl MediaStreamAudioDestinationNode {
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
options: &AudioNodeOptions,
|
options: &AudioNodeOptions,
|
||||||
) -> Fallible<DomRoot<MediaStreamAudioDestinationNode>> {
|
) -> Fallible<DomRoot<MediaStreamAudioDestinationNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -68,19 +69,26 @@ impl MediaStreamAudioDestinationNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
options: &AudioNodeOptions,
|
options: &AudioNodeOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<MediaStreamAudioDestinationNode>> {
|
) -> Fallible<DomRoot<MediaStreamAudioDestinationNode>> {
|
||||||
let node = MediaStreamAudioDestinationNode::new_inherited(context, options)?;
|
let node = MediaStreamAudioDestinationNode::new_inherited(context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
options: &AudioNodeOptions,
|
options: &AudioNodeOptions,
|
||||||
) -> Fallible<DomRoot<MediaStreamAudioDestinationNode>> {
|
) -> Fallible<DomRoot<MediaStreamAudioDestinationNode>> {
|
||||||
MediaStreamAudioDestinationNode::new_with_proto(window, proto, context, options)
|
MediaStreamAudioDestinationNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::mediastream::MediaStream;
|
use crate::dom::mediastream::MediaStream;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MediaStreamAudioSourceNode {
|
pub struct MediaStreamAudioSourceNode {
|
||||||
|
@ -55,7 +56,7 @@ impl MediaStreamAudioSourceNode {
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
stream: &MediaStream,
|
stream: &MediaStream,
|
||||||
) -> Fallible<DomRoot<MediaStreamAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaStreamAudioSourceNode>> {
|
||||||
Self::new_with_proto(window, None, context, stream)
|
Self::new_with_proto(window, None, context, stream, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -64,19 +65,32 @@ impl MediaStreamAudioSourceNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
stream: &MediaStream,
|
stream: &MediaStream,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<MediaStreamAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaStreamAudioSourceNode>> {
|
||||||
let node = MediaStreamAudioSourceNode::new_inherited(context, stream)?;
|
let node = MediaStreamAudioSourceNode::new_inherited(context, stream)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
options: &MediaStreamAudioSourceOptions,
|
options: &MediaStreamAudioSourceOptions,
|
||||||
) -> Fallible<DomRoot<MediaStreamAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaStreamAudioSourceNode>> {
|
||||||
MediaStreamAudioSourceNode::new_with_proto(window, proto, context, &options.mediaStream)
|
MediaStreamAudioSourceNode::new_with_proto(
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
context,
|
||||||
|
&options.mediaStream,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::mediastreamtrack::MediaStreamTrack;
|
use crate::dom::mediastreamtrack::MediaStreamTrack;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MediaStreamTrackAudioSourceNode {
|
pub struct MediaStreamTrackAudioSourceNode {
|
||||||
|
@ -46,7 +47,7 @@ impl MediaStreamTrackAudioSourceNode {
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
track: &MediaStreamTrack,
|
track: &MediaStreamTrack,
|
||||||
) -> Fallible<DomRoot<MediaStreamTrackAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaStreamTrackAudioSourceNode>> {
|
||||||
Self::new_with_proto(window, None, context, track)
|
Self::new_with_proto(window, None, context, track, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -55,15 +56,22 @@ impl MediaStreamTrackAudioSourceNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
track: &MediaStreamTrack,
|
track: &MediaStreamTrack,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<MediaStreamTrackAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaStreamTrackAudioSourceNode>> {
|
||||||
let node = MediaStreamTrackAudioSourceNode::new_inherited(context, track)?;
|
let node = MediaStreamTrackAudioSourceNode::new_inherited(context, track)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &AudioContext,
|
context: &AudioContext,
|
||||||
options: &MediaStreamTrackAudioSourceOptions,
|
options: &MediaStreamTrackAudioSourceOptions,
|
||||||
) -> Fallible<DomRoot<MediaStreamTrackAudioSourceNode>> {
|
) -> Fallible<DomRoot<MediaStreamTrackAudioSourceNode>> {
|
||||||
|
@ -72,6 +80,7 @@ impl MediaStreamTrackAudioSourceNode {
|
||||||
proto,
|
proto,
|
||||||
context,
|
context,
|
||||||
&options.mediaStreamTrack,
|
&options.mediaStreamTrack,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::messageport::MessagePort;
|
use crate::dom::messageport::MessagePort;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MessageChannel {
|
pub struct MessageChannel {
|
||||||
|
@ -24,12 +25,17 @@ impl MessageChannel {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MessageChannel> {
|
) -> DomRoot<MessageChannel> {
|
||||||
MessageChannel::new(global, proto)
|
MessageChannel::new(global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#dom-messagechannel>
|
/// <https://html.spec.whatwg.org/multipage/#dom-messagechannel>
|
||||||
fn new(incumbent: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<MessageChannel> {
|
fn new(
|
||||||
|
incumbent: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<MessageChannel> {
|
||||||
// Step 1
|
// Step 1
|
||||||
let port1 = MessagePort::new(incumbent);
|
let port1 = MessagePort::new(incumbent);
|
||||||
|
|
||||||
|
@ -47,6 +53,7 @@ impl MessageChannel {
|
||||||
Box::new(MessageChannel::new_inherited(&port1, &port2)),
|
Box::new(MessageChannel::new_inherited(&port1, &port2)),
|
||||||
incumbent,
|
incumbent,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::messageport::MessagePort;
|
use crate::dom::messageport::MessagePort;
|
||||||
use crate::dom::serviceworker::ServiceWorker;
|
use crate::dom::serviceworker::ServiceWorker;
|
||||||
use crate::dom::windowproxy::WindowProxy;
|
use crate::dom::windowproxy::WindowProxy;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[crown::unrooted_must_root_lint::must_root]
|
#[crown::unrooted_must_root_lint::must_root]
|
||||||
#[derive(JSTraceable, MallocSizeOf)]
|
#[derive(JSTraceable, MallocSizeOf)]
|
||||||
|
@ -92,12 +92,13 @@ impl MessageEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<MessageEvent> {
|
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<MessageEvent> {
|
||||||
Self::new_uninitialized_with_proto(global, None)
|
Self::new_uninitialized_with_proto(global, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_uninitialized_with_proto(
|
fn new_uninitialized_with_proto(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MessageEvent> {
|
) -> DomRoot<MessageEvent> {
|
||||||
MessageEvent::new_initialized(
|
MessageEvent::new_initialized(
|
||||||
global,
|
global,
|
||||||
|
@ -107,6 +108,7 @@ impl MessageEvent {
|
||||||
None,
|
None,
|
||||||
DOMString::new(),
|
DOMString::new(),
|
||||||
vec![],
|
vec![],
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +120,7 @@ impl MessageEvent {
|
||||||
source: Option<&WindowProxyOrMessagePortOrServiceWorker>,
|
source: Option<&WindowProxyOrMessagePortOrServiceWorker>,
|
||||||
lastEventId: DOMString,
|
lastEventId: DOMString,
|
||||||
ports: Vec<DomRoot<MessagePort>>,
|
ports: Vec<DomRoot<MessagePort>>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MessageEvent> {
|
) -> DomRoot<MessageEvent> {
|
||||||
let ev = Box::new(MessageEvent::new_inherited(
|
let ev = Box::new(MessageEvent::new_inherited(
|
||||||
origin,
|
origin,
|
||||||
|
@ -125,7 +128,7 @@ impl MessageEvent {
|
||||||
lastEventId,
|
lastEventId,
|
||||||
ports,
|
ports,
|
||||||
));
|
));
|
||||||
let ev = reflect_dom_object_with_proto(ev, global, proto);
|
let ev = reflect_dom_object_with_proto(ev, global, proto, can_gc);
|
||||||
ev.data.set(data.get());
|
ev.data.set(data.get());
|
||||||
|
|
||||||
ev
|
ev
|
||||||
|
@ -154,6 +157,7 @@ impl MessageEvent {
|
||||||
source,
|
source,
|
||||||
lastEventId,
|
lastEventId,
|
||||||
ports,
|
ports,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,9 +173,18 @@ impl MessageEvent {
|
||||||
source: Option<&WindowProxyOrMessagePortOrServiceWorker>,
|
source: Option<&WindowProxyOrMessagePortOrServiceWorker>,
|
||||||
lastEventId: DOMString,
|
lastEventId: DOMString,
|
||||||
ports: Vec<DomRoot<MessagePort>>,
|
ports: Vec<DomRoot<MessagePort>>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MessageEvent> {
|
) -> DomRoot<MessageEvent> {
|
||||||
let ev =
|
let ev = MessageEvent::new_initialized(
|
||||||
MessageEvent::new_initialized(global, proto, data, origin, source, lastEventId, ports);
|
global,
|
||||||
|
proto,
|
||||||
|
data,
|
||||||
|
origin,
|
||||||
|
source,
|
||||||
|
lastEventId,
|
||||||
|
ports,
|
||||||
|
can_gc,
|
||||||
|
);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
event.init_event(type_, bubbles, cancelable);
|
event.init_event(type_, bubbles, cancelable);
|
||||||
|
@ -182,6 +195,7 @@ impl MessageEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<MessageEventBinding::MessageEventInit>,
|
init: RootedTraceableBox<MessageEventBinding::MessageEventInit>,
|
||||||
) -> Fallible<DomRoot<MessageEvent>> {
|
) -> Fallible<DomRoot<MessageEvent>> {
|
||||||
|
@ -196,6 +210,7 @@ impl MessageEvent {
|
||||||
init.source.as_ref(),
|
init.source.as_ref(),
|
||||||
init.lastEventId.clone(),
|
init.lastEventId.clone(),
|
||||||
init.ports.clone(),
|
init.ports.clone(),
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(ev)
|
Ok(ev)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::node::Node;
|
use crate::dom::node::Node;
|
||||||
use crate::dom::uievent::UIEvent;
|
use crate::dom::uievent::UIEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct MouseEvent {
|
pub struct MouseEvent {
|
||||||
|
@ -75,14 +76,15 @@ impl MouseEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_uninitialized(window: &Window) -> DomRoot<MouseEvent> {
|
pub fn new_uninitialized(window: &Window) -> DomRoot<MouseEvent> {
|
||||||
Self::new_uninitialized_with_proto(window, None)
|
Self::new_uninitialized_with_proto(window, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_uninitialized_with_proto(
|
fn new_uninitialized_with_proto(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MouseEvent> {
|
) -> DomRoot<MouseEvent> {
|
||||||
reflect_dom_object_with_proto(Box::new(MouseEvent::new_inherited()), window, proto)
|
reflect_dom_object_with_proto(Box::new(MouseEvent::new_inherited()), window, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
@ -126,6 +128,7 @@ impl MouseEvent {
|
||||||
buttons,
|
buttons,
|
||||||
related_target,
|
related_target,
|
||||||
point_in_target,
|
point_in_target,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,8 +153,9 @@ impl MouseEvent {
|
||||||
buttons: u16,
|
buttons: u16,
|
||||||
related_target: Option<&EventTarget>,
|
related_target: Option<&EventTarget>,
|
||||||
point_in_target: Option<Point2D<f32>>,
|
point_in_target: Option<Point2D<f32>>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MouseEvent> {
|
) -> DomRoot<MouseEvent> {
|
||||||
let ev = MouseEvent::new_uninitialized_with_proto(window, proto);
|
let ev = MouseEvent::new_uninitialized_with_proto(window, proto, can_gc);
|
||||||
ev.InitMouseEvent(
|
ev.InitMouseEvent(
|
||||||
type_,
|
type_,
|
||||||
bool::from(can_bubble),
|
bool::from(can_bubble),
|
||||||
|
@ -181,6 +185,7 @@ impl MouseEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &MouseEventBinding::MouseEventInit,
|
init: &MouseEventBinding::MouseEventInit,
|
||||||
) -> Fallible<DomRoot<MouseEvent>> {
|
) -> Fallible<DomRoot<MouseEvent>> {
|
||||||
|
@ -206,6 +211,7 @@ impl MouseEvent {
|
||||||
init.buttons,
|
init.buttons,
|
||||||
init.relatedTarget.as_deref(),
|
init.relatedTarget.as_deref(),
|
||||||
None,
|
None,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ use crate::dom::mutationrecord::MutationRecord;
|
||||||
use crate::dom::node::{Node, ShadowIncluding};
|
use crate::dom::node::{Node, ShadowIncluding};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::microtask::Microtask;
|
use crate::microtask::Microtask;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -72,9 +73,10 @@ impl MutationObserver {
|
||||||
global: &Window,
|
global: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
callback: Rc<MutationCallback>,
|
callback: Rc<MutationCallback>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<MutationObserver> {
|
) -> DomRoot<MutationObserver> {
|
||||||
let boxed_observer = Box::new(MutationObserver::new_inherited(callback));
|
let boxed_observer = Box::new(MutationObserver::new_inherited(callback));
|
||||||
reflect_dom_object_with_proto(boxed_observer, global, proto)
|
reflect_dom_object_with_proto(boxed_observer, global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_inherited(callback: Rc<MutationCallback>) -> MutationObserver {
|
fn new_inherited(callback: Rc<MutationCallback>) -> MutationObserver {
|
||||||
|
@ -90,10 +92,11 @@ impl MutationObserver {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &Window,
|
global: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
callback: Rc<MutationCallback>,
|
callback: Rc<MutationCallback>,
|
||||||
) -> Fallible<DomRoot<MutationObserver>> {
|
) -> Fallible<DomRoot<MutationObserver>> {
|
||||||
global.set_exists_mut_observer();
|
global.set_exists_mut_observer();
|
||||||
let observer = MutationObserver::new_with_proto(global, proto, callback);
|
let observer = MutationObserver::new_with_proto(global, proto, callback, can_gc);
|
||||||
ScriptThread::add_mutation_observer(&observer);
|
ScriptThread::add_mutation_observer(&observer);
|
||||||
Ok(observer)
|
Ok(observer)
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ use crate::dom::svgsvgelement::{LayoutSVGSVGElementHelpers, SVGSVGElement};
|
||||||
use crate::dom::text::Text;
|
use crate::dom::text::Text;
|
||||||
use crate::dom::virtualmethods::{vtable_for, VirtualMethods};
|
use crate::dom::virtualmethods::{vtable_for, VirtualMethods};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1788,7 +1789,7 @@ impl Node {
|
||||||
N: DerivedFrom<Node> + DomObject + DomObjectWrap,
|
N: DerivedFrom<Node> + DomObject + DomObjectWrap,
|
||||||
{
|
{
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
reflect_dom_object_with_proto(node, window, proto)
|
reflect_dom_object_with_proto(node, window, proto, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_inherited(doc: &Document) -> Node {
|
pub fn new_inherited(doc: &Document) -> Node {
|
||||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct OfflineAudioCompletionEvent {
|
pub struct OfflineAudioCompletionEvent {
|
||||||
|
@ -40,7 +41,15 @@ impl OfflineAudioCompletionEvent {
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
rendered_buffer: &AudioBuffer,
|
rendered_buffer: &AudioBuffer,
|
||||||
) -> DomRoot<OfflineAudioCompletionEvent> {
|
) -> DomRoot<OfflineAudioCompletionEvent> {
|
||||||
Self::new_with_proto(window, None, type_, bubbles, cancelable, rendered_buffer)
|
Self::new_with_proto(
|
||||||
|
window,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
rendered_buffer,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -50,9 +59,10 @@ impl OfflineAudioCompletionEvent {
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
rendered_buffer: &AudioBuffer,
|
rendered_buffer: &AudioBuffer,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<OfflineAudioCompletionEvent> {
|
) -> DomRoot<OfflineAudioCompletionEvent> {
|
||||||
let event = Box::new(OfflineAudioCompletionEvent::new_inherited(rendered_buffer));
|
let event = Box::new(OfflineAudioCompletionEvent::new_inherited(rendered_buffer));
|
||||||
let ev = reflect_dom_object_with_proto(event, window, proto);
|
let ev = reflect_dom_object_with_proto(event, window, proto, can_gc);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
||||||
|
@ -64,6 +74,7 @@ impl OfflineAudioCompletionEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &OfflineAudioCompletionEventInit,
|
init: &OfflineAudioCompletionEventInit,
|
||||||
) -> Fallible<DomRoot<OfflineAudioCompletionEvent>> {
|
) -> Fallible<DomRoot<OfflineAudioCompletionEvent>> {
|
||||||
|
@ -76,6 +87,7 @@ impl OfflineAudioCompletionEvent {
|
||||||
bubbles,
|
bubbles,
|
||||||
cancelable,
|
cancelable,
|
||||||
&init.renderedBuffer,
|
&init.renderedBuffer,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ use crate::dom::offlineaudiocompletionevent::OfflineAudioCompletionEvent;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -77,6 +78,7 @@ impl OfflineAudioContext {
|
||||||
channel_count: u32,
|
channel_count: u32,
|
||||||
length: u32,
|
length: u32,
|
||||||
sample_rate: f32,
|
sample_rate: f32,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
||||||
if channel_count > MAX_CHANNEL_COUNT ||
|
if channel_count > MAX_CHANNEL_COUNT ||
|
||||||
channel_count == 0 ||
|
channel_count == 0 ||
|
||||||
|
@ -92,12 +94,14 @@ impl OfflineAudioContext {
|
||||||
Box::new(context),
|
Box::new(context),
|
||||||
window,
|
window,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
options: &OfflineAudioContextOptions,
|
options: &OfflineAudioContextOptions,
|
||||||
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
||||||
OfflineAudioContext::new(
|
OfflineAudioContext::new(
|
||||||
|
@ -106,17 +110,26 @@ impl OfflineAudioContext {
|
||||||
options.numberOfChannels,
|
options.numberOfChannels,
|
||||||
options.length,
|
options.length,
|
||||||
*options.sampleRate,
|
*options.sampleRate,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor_(
|
pub fn Constructor_(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
number_of_channels: u32,
|
number_of_channels: u32,
|
||||||
length: u32,
|
length: u32,
|
||||||
sample_rate: Finite<f32>,
|
sample_rate: Finite<f32>,
|
||||||
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
||||||
OfflineAudioContext::new(window, proto, number_of_channels, length, *sample_rate)
|
OfflineAudioContext::new(
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
number_of_channels,
|
||||||
|
length,
|
||||||
|
*sample_rate,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::htmlcanvaselement::HTMLCanvasElement;
|
use crate::dom::htmlcanvaselement::HTMLCanvasElement;
|
||||||
use crate::dom::offscreencanvasrenderingcontext2d::OffscreenCanvasRenderingContext2D;
|
use crate::dom::offscreencanvasrenderingcontext2d::OffscreenCanvasRenderingContext2D;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[crown::unrooted_must_root_lint::must_root]
|
#[crown::unrooted_must_root_lint::must_root]
|
||||||
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
||||||
|
@ -63,11 +63,13 @@ impl OffscreenCanvas {
|
||||||
width: u64,
|
width: u64,
|
||||||
height: u64,
|
height: u64,
|
||||||
placeholder: Option<&HTMLCanvasElement>,
|
placeholder: Option<&HTMLCanvasElement>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<OffscreenCanvas> {
|
) -> DomRoot<OffscreenCanvas> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(OffscreenCanvas::new_inherited(width, height, placeholder)),
|
Box::new(OffscreenCanvas::new_inherited(width, height, placeholder)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,10 +77,11 @@ impl OffscreenCanvas {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
width: u64,
|
width: u64,
|
||||||
height: u64,
|
height: u64,
|
||||||
) -> Fallible<DomRoot<OffscreenCanvas>> {
|
) -> Fallible<DomRoot<OffscreenCanvas>> {
|
||||||
let offscreencanvas = OffscreenCanvas::new(global, proto, width, height, None);
|
let offscreencanvas = OffscreenCanvas::new(global, proto, width, height, None, can_gc);
|
||||||
Ok(offscreencanvas)
|
Ok(offscreencanvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct OscillatorNode {
|
pub struct OscillatorNode {
|
||||||
|
@ -91,7 +92,7 @@ impl OscillatorNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &OscillatorOptions,
|
options: &OscillatorOptions,
|
||||||
) -> Fallible<DomRoot<OscillatorNode>> {
|
) -> Fallible<DomRoot<OscillatorNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -100,19 +101,26 @@ impl OscillatorNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &OscillatorOptions,
|
options: &OscillatorOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<OscillatorNode>> {
|
) -> Fallible<DomRoot<OscillatorNode>> {
|
||||||
let node = OscillatorNode::new_inherited(window, context, options)?;
|
let node = OscillatorNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &OscillatorOptions,
|
options: &OscillatorOptions,
|
||||||
) -> Fallible<DomRoot<OscillatorNode>> {
|
) -> Fallible<DomRoot<OscillatorNode>> {
|
||||||
OscillatorNode::new_with_proto(window, proto, context, options)
|
OscillatorNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#pagetransitionevent
|
// https://html.spec.whatwg.org/multipage/#pagetransitionevent
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -37,11 +38,13 @@ impl PageTransitionEvent {
|
||||||
fn new_uninitialized(
|
fn new_uninitialized(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<PageTransitionEvent> {
|
) -> DomRoot<PageTransitionEvent> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(PageTransitionEvent::new_inherited()),
|
Box::new(PageTransitionEvent::new_inherited()),
|
||||||
window,
|
window,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +55,15 @@ impl PageTransitionEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
persisted: bool,
|
persisted: bool,
|
||||||
) -> DomRoot<PageTransitionEvent> {
|
) -> DomRoot<PageTransitionEvent> {
|
||||||
Self::new_with_proto(window, None, type_, bubbles, cancelable, persisted)
|
Self::new_with_proto(
|
||||||
|
window,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
persisted,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -62,8 +73,9 @@ impl PageTransitionEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
persisted: bool,
|
persisted: bool,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<PageTransitionEvent> {
|
) -> DomRoot<PageTransitionEvent> {
|
||||||
let ev = PageTransitionEvent::new_uninitialized(window, proto);
|
let ev = PageTransitionEvent::new_uninitialized(window, proto, can_gc);
|
||||||
ev.persisted.set(persisted);
|
ev.persisted.set(persisted);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -76,6 +88,7 @@ impl PageTransitionEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &PageTransitionEventBinding::PageTransitionEventInit,
|
init: &PageTransitionEventBinding::PageTransitionEventInit,
|
||||||
) -> Fallible<DomRoot<PageTransitionEvent>> {
|
) -> Fallible<DomRoot<PageTransitionEvent>> {
|
||||||
|
@ -86,6 +99,7 @@ impl PageTransitionEvent {
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
init.persisted,
|
init.persisted,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct PannerNode {
|
pub struct PannerNode {
|
||||||
|
@ -184,7 +185,7 @@ impl PannerNode {
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &PannerOptions,
|
options: &PannerOptions,
|
||||||
) -> Fallible<DomRoot<PannerNode>> {
|
) -> Fallible<DomRoot<PannerNode>> {
|
||||||
Self::new_with_proto(window, None, context, options)
|
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -193,19 +194,26 @@ impl PannerNode {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &PannerOptions,
|
options: &PannerOptions,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<PannerNode>> {
|
) -> Fallible<DomRoot<PannerNode>> {
|
||||||
let node = PannerNode::new_inherited(window, context, options)?;
|
let node = PannerNode::new_inherited(window, context, options)?;
|
||||||
Ok(reflect_dom_object_with_proto(Box::new(node), window, proto))
|
Ok(reflect_dom_object_with_proto(
|
||||||
|
Box::new(node),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
context: &BaseAudioContext,
|
context: &BaseAudioContext,
|
||||||
options: &PannerOptions,
|
options: &PannerOptions,
|
||||||
) -> Fallible<DomRoot<PannerNode>> {
|
) -> Fallible<DomRoot<PannerNode>> {
|
||||||
PannerNode::new_with_proto(window, proto, context, options)
|
PannerNode::new_with_proto(window, proto, context, options, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::performance::PerformanceEntryList;
|
use crate::dom::performance::PerformanceEntryList;
|
||||||
use crate::dom::performanceentry::PerformanceEntry;
|
use crate::dom::performanceentry::PerformanceEntry;
|
||||||
use crate::dom::performanceobserverentrylist::PerformanceObserverEntryList;
|
use crate::dom::performanceobserverentrylist::PerformanceObserverEntryList;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
/// List of allowed performance entry types, in alphabetical order.
|
/// List of allowed performance entry types, in alphabetical order.
|
||||||
pub const VALID_ENTRY_TYPES: &[&str] = &[
|
pub const VALID_ENTRY_TYPES: &[&str] = &[
|
||||||
|
@ -71,7 +71,7 @@ impl PerformanceObserver {
|
||||||
callback: Rc<PerformanceObserverCallback>,
|
callback: Rc<PerformanceObserverCallback>,
|
||||||
entries: DOMPerformanceEntryList,
|
entries: DOMPerformanceEntryList,
|
||||||
) -> DomRoot<PerformanceObserver> {
|
) -> DomRoot<PerformanceObserver> {
|
||||||
Self::new_with_proto(global, None, callback, entries)
|
Self::new_with_proto(global, None, callback, entries, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -80,15 +80,17 @@ impl PerformanceObserver {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
callback: Rc<PerformanceObserverCallback>,
|
callback: Rc<PerformanceObserverCallback>,
|
||||||
entries: DOMPerformanceEntryList,
|
entries: DOMPerformanceEntryList,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<PerformanceObserver> {
|
) -> DomRoot<PerformanceObserver> {
|
||||||
let observer = PerformanceObserver::new_inherited(callback, DomRefCell::new(entries));
|
let observer = PerformanceObserver::new_inherited(callback, DomRefCell::new(entries));
|
||||||
reflect_dom_object_with_proto(Box::new(observer), global, proto)
|
reflect_dom_object_with_proto(Box::new(observer), global, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
callback: Rc<PerformanceObserverCallback>,
|
callback: Rc<PerformanceObserverCallback>,
|
||||||
) -> Fallible<DomRoot<PerformanceObserver>> {
|
) -> Fallible<DomRoot<PerformanceObserver>> {
|
||||||
Ok(PerformanceObserver::new_with_proto(
|
Ok(PerformanceObserver::new_with_proto(
|
||||||
|
@ -96,6 +98,7 @@ impl PerformanceObserver {
|
||||||
proto,
|
proto,
|
||||||
callback,
|
callback,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use crate::dom::bindings::trace::RootedTraceableBox;
|
||||||
use crate::dom::event::Event;
|
use crate::dom::event::Event;
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-popstateevent-interface
|
// https://html.spec.whatwg.org/multipage/#the-popstateevent-interface
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -38,8 +38,17 @@ impl PopStateEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_uninitialized(window: &Window, proto: Option<HandleObject>) -> DomRoot<PopStateEvent> {
|
fn new_uninitialized(
|
||||||
reflect_dom_object_with_proto(Box::new(PopStateEvent::new_inherited()), window, proto)
|
window: &Window,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<PopStateEvent> {
|
||||||
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(PopStateEvent::new_inherited()),
|
||||||
|
window,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(
|
fn new(
|
||||||
|
@ -49,8 +58,9 @@ impl PopStateEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
state: HandleValue,
|
state: HandleValue,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<PopStateEvent> {
|
) -> DomRoot<PopStateEvent> {
|
||||||
let ev = PopStateEvent::new_uninitialized(window, proto);
|
let ev = PopStateEvent::new_uninitialized(window, proto, can_gc);
|
||||||
ev.state.set(state.get());
|
ev.state.set(state.get());
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -63,6 +73,7 @@ impl PopStateEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<PopStateEventBinding::PopStateEventInit>,
|
init: RootedTraceableBox<PopStateEventBinding::PopStateEventInit>,
|
||||||
) -> Fallible<DomRoot<PopStateEvent>> {
|
) -> Fallible<DomRoot<PopStateEvent>> {
|
||||||
|
@ -73,11 +84,20 @@ impl PopStateEvent {
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
init.state.handle(),
|
init.state.handle(),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dispatch_jsval(target: &EventTarget, window: &Window, state: HandleValue) {
|
pub fn dispatch_jsval(target: &EventTarget, window: &Window, state: HandleValue) {
|
||||||
let event = PopStateEvent::new(window, None, atom!("popstate"), false, false, state);
|
let event = PopStateEvent::new(
|
||||||
|
window,
|
||||||
|
None,
|
||||||
|
atom!("popstate"),
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
state,
|
||||||
|
CanGc::note(),
|
||||||
|
);
|
||||||
event.upcast::<Event>().fire(target);
|
event.upcast::<Event>().fire(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct ProgressEvent {
|
pub struct ProgressEvent {
|
||||||
|
@ -53,6 +54,7 @@ impl ProgressEvent {
|
||||||
length_computable,
|
length_computable,
|
||||||
loaded,
|
loaded,
|
||||||
total,
|
total,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +68,7 @@ impl ProgressEvent {
|
||||||
length_computable: bool,
|
length_computable: bool,
|
||||||
loaded: u64,
|
loaded: u64,
|
||||||
total: u64,
|
total: u64,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<ProgressEvent> {
|
) -> DomRoot<ProgressEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(ProgressEvent::new_inherited(
|
Box::new(ProgressEvent::new_inherited(
|
||||||
|
@ -75,6 +78,7 @@ impl ProgressEvent {
|
||||||
)),
|
)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let event = ev.upcast::<Event>();
|
let event = ev.upcast::<Event>();
|
||||||
|
@ -87,6 +91,7 @@ impl ProgressEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &ProgressEventBinding::ProgressEventInit,
|
init: &ProgressEventBinding::ProgressEventInit,
|
||||||
) -> Fallible<DomRoot<ProgressEvent>> {
|
) -> Fallible<DomRoot<ProgressEvent>> {
|
||||||
|
@ -101,6 +106,7 @@ impl ProgressEvent {
|
||||||
init.lengthComputable,
|
init.lengthComputable,
|
||||||
init.loaded,
|
init.loaded,
|
||||||
init.total,
|
init.total,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(ev)
|
Ok(ev)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::dom::bindings::trace::RootedTraceableBox;
|
||||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct PromiseRejectionEvent {
|
pub struct PromiseRejectionEvent {
|
||||||
|
@ -60,6 +60,7 @@ impl PromiseRejectionEvent {
|
||||||
cancelable,
|
cancelable,
|
||||||
promise.promise_obj(),
|
promise.promise_obj(),
|
||||||
reason,
|
reason,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,11 +73,13 @@ impl PromiseRejectionEvent {
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
promise: HandleObject,
|
promise: HandleObject,
|
||||||
reason: HandleValue,
|
reason: HandleValue,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
Box::new(PromiseRejectionEvent::new_inherited()),
|
Box::new(PromiseRejectionEvent::new_inherited()),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
ev.promise.set(promise.get());
|
ev.promise.set(promise.get());
|
||||||
|
|
||||||
|
@ -93,6 +96,7 @@ impl PromiseRejectionEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: RootedTraceableBox<PromiseRejectionEventBinding::PromiseRejectionEventInit>,
|
init: RootedTraceableBox<PromiseRejectionEventBinding::PromiseRejectionEventInit>,
|
||||||
) -> Fallible<DomRoot<Self>> {
|
) -> Fallible<DomRoot<Self>> {
|
||||||
|
@ -108,6 +112,7 @@ impl PromiseRejectionEvent {
|
||||||
cancelable,
|
cancelable,
|
||||||
init.promise.handle(),
|
init.promise.handle(),
|
||||||
reason,
|
reason,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ use crate::dom::node::{Node, ShadowIncluding, UnbindContext};
|
||||||
use crate::dom::selection::Selection;
|
use crate::dom::selection::Selection;
|
||||||
use crate::dom::text::Text;
|
use crate::dom::text::Text;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct Range {
|
pub struct Range {
|
||||||
|
@ -71,9 +72,13 @@ impl Range {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_doc(document: &Document, proto: Option<HandleObject>) -> DomRoot<Range> {
|
pub fn new_with_doc(
|
||||||
|
document: &Document,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<Range> {
|
||||||
let root = document.upcast();
|
let root = document.upcast();
|
||||||
Range::new_with_proto(document, proto, root, 0, root, 0)
|
Range::new_with_proto(document, proto, root, 0, root, 0, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
@ -90,6 +95,7 @@ impl Range {
|
||||||
start_offset,
|
start_offset,
|
||||||
end_container,
|
end_container,
|
||||||
end_offset,
|
end_offset,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +106,7 @@ impl Range {
|
||||||
start_offset: u32,
|
start_offset: u32,
|
||||||
end_container: &Node,
|
end_container: &Node,
|
||||||
end_offset: u32,
|
end_offset: u32,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Range> {
|
) -> DomRoot<Range> {
|
||||||
let range = reflect_dom_object_with_proto(
|
let range = reflect_dom_object_with_proto(
|
||||||
Box::new(Range::new_inherited(
|
Box::new(Range::new_inherited(
|
||||||
|
@ -110,6 +117,7 @@ impl Range {
|
||||||
)),
|
)),
|
||||||
document.window(),
|
document.window(),
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
start_container.ranges().push(WeakRef::new(&range));
|
start_container.ranges().push(WeakRef::new(&range));
|
||||||
if start_container != end_container {
|
if start_container != end_container {
|
||||||
|
@ -120,9 +128,13 @@ impl Range {
|
||||||
|
|
||||||
/// <https://dom.spec.whatwg.org/#dom-range>
|
/// <https://dom.spec.whatwg.org/#dom-range>
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Constructor(window: &Window, proto: Option<HandleObject>) -> Fallible<DomRoot<Range>> {
|
pub fn Constructor(
|
||||||
|
window: &Window,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> Fallible<DomRoot<Range>> {
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
Ok(Range::new_with_doc(&document, proto))
|
Ok(Range::new_with_doc(&document, proto, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://dom.spec.whatwg.org/#contained>
|
/// <https://dom.spec.whatwg.org/#contained>
|
||||||
|
|
|
@ -38,7 +38,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::headers::{Guard, Headers};
|
use crate::dom::headers::{Guard, Headers};
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::readablestream::ReadableStream;
|
use crate::dom::readablestream::ReadableStream;
|
||||||
use crate::script_runtime::JSContext as SafeJSContext;
|
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
|
@ -59,8 +59,18 @@ impl Request {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(global: &GlobalScope, proto: Option<HandleObject>, url: ServoUrl) -> DomRoot<Request> {
|
fn new(
|
||||||
reflect_dom_object_with_proto(Box::new(Request::new_inherited(global, url)), global, proto)
|
global: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
url: ServoUrl,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<Request> {
|
||||||
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(Request::new_inherited(global, url)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-request
|
// https://fetch.spec.whatwg.org/#dom-request
|
||||||
|
@ -68,6 +78,7 @@ impl Request {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
mut input: RequestInfo,
|
mut input: RequestInfo,
|
||||||
init: RootedTraceableBox<RequestInit>,
|
init: RootedTraceableBox<RequestInit>,
|
||||||
) -> Fallible<DomRoot<Request>> {
|
) -> Fallible<DomRoot<Request>> {
|
||||||
|
@ -283,7 +294,7 @@ impl Request {
|
||||||
// Step 27 TODO: "If init["priority"] exists..."
|
// Step 27 TODO: "If init["priority"] exists..."
|
||||||
|
|
||||||
// Step 28
|
// Step 28
|
||||||
let r = Request::from_net_request(global, proto, request);
|
let r = Request::from_net_request(global, proto, request, can_gc);
|
||||||
|
|
||||||
// Step 29 TODO: "Set this's signal to new AbortSignal object..."
|
// Step 29 TODO: "Set this's signal to new AbortSignal object..."
|
||||||
// Step 30 TODO: "If signal is not null..."
|
// Step 30 TODO: "If signal is not null..."
|
||||||
|
@ -436,17 +447,18 @@ impl Request {
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
net_request: NetTraitsRequest,
|
net_request: NetTraitsRequest,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Request> {
|
) -> DomRoot<Request> {
|
||||||
let r = Request::new(global, proto, net_request.current_url());
|
let r = Request::new(global, proto, net_request.current_url(), can_gc);
|
||||||
*r.request.borrow_mut() = net_request;
|
*r.request.borrow_mut() = net_request;
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_from(r: &Request) -> Fallible<DomRoot<Request>> {
|
fn clone_from(r: &Request, can_gc: CanGc) -> Fallible<DomRoot<Request>> {
|
||||||
let req = r.request.borrow();
|
let req = r.request.borrow();
|
||||||
let url = req.url();
|
let url = req.url();
|
||||||
let headers_guard = r.Headers().get_guard();
|
let headers_guard = r.Headers().get_guard();
|
||||||
let r_clone = Request::new(&r.global(), None, url);
|
let r_clone = Request::new(&r.global(), None, url, can_gc);
|
||||||
r_clone.request.borrow_mut().pipeline_id = req.pipeline_id;
|
r_clone.request.borrow_mut().pipeline_id = req.pipeline_id;
|
||||||
{
|
{
|
||||||
let mut borrowed_r_request = r_clone.request.borrow_mut();
|
let mut borrowed_r_request = r_clone.request.borrow_mut();
|
||||||
|
@ -614,7 +626,7 @@ impl RequestMethods for Request {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
Request::clone_from(self)
|
Request::clone_from(self, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-body-text
|
// https://fetch.spec.whatwg.org/#dom-body-text
|
||||||
|
|
|
@ -24,6 +24,7 @@ use crate::dom::node::{window_from_node, Node};
|
||||||
use crate::dom::resizeobserverentry::ResizeObserverEntry;
|
use crate::dom::resizeobserverentry::ResizeObserverEntry;
|
||||||
use crate::dom::resizeobserversize::{ResizeObserverSize, ResizeObserverSizeImpl};
|
use crate::dom::resizeobserversize::{ResizeObserverSize, ResizeObserverSizeImpl};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
|
|
||||||
/// <https://drafts.csswg.org/resize-observer/#calculate-depth-for-node>
|
/// <https://drafts.csswg.org/resize-observer/#calculate-depth-for-node>
|
||||||
|
@ -61,9 +62,10 @@ impl ResizeObserver {
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
callback: Rc<ResizeObserverCallback>,
|
callback: Rc<ResizeObserverCallback>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<ResizeObserver> {
|
) -> DomRoot<ResizeObserver> {
|
||||||
let observer = Box::new(ResizeObserver::new_inherited(callback));
|
let observer = Box::new(ResizeObserver::new_inherited(callback));
|
||||||
reflect_dom_object_with_proto(observer, window, proto)
|
reflect_dom_object_with_proto(observer, window, proto, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://drafts.csswg.org/resize-observer/#dom-resizeobserver-resizeobserver>
|
/// <https://drafts.csswg.org/resize-observer/#dom-resizeobserver-resizeobserver>
|
||||||
|
@ -71,9 +73,10 @@ impl ResizeObserver {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
callback: Rc<ResizeObserverCallback>,
|
callback: Rc<ResizeObserverCallback>,
|
||||||
) -> DomRoot<ResizeObserver> {
|
) -> DomRoot<ResizeObserver> {
|
||||||
let rooted_observer = ResizeObserver::new(window, proto, callback);
|
let rooted_observer = ResizeObserver::new(window, proto, callback, can_gc);
|
||||||
let document = window.Document();
|
let document = window.Document();
|
||||||
document.add_resize_observer(&rooted_observer);
|
document.add_resize_observer(&rooted_observer);
|
||||||
rooted_observer
|
rooted_observer
|
||||||
|
@ -128,6 +131,7 @@ impl ResizeObserver {
|
||||||
box_size.origin.y.to_f64_px(),
|
box_size.origin.y.to_f64_px(),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
CanGc::note(),
|
||||||
);
|
);
|
||||||
let entry = ResizeObserverEntry::new(
|
let entry = ResizeObserverEntry::new(
|
||||||
&window,
|
&window,
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::dom::domrectreadonly::DOMRectReadOnly;
|
||||||
use crate::dom::element::Element;
|
use crate::dom::element::Element;
|
||||||
use crate::dom::resizeobserversize::ResizeObserverSize;
|
use crate::dom::resizeobserversize::ResizeObserverSize;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::JSContext as SafeJSContext;
|
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
|
||||||
|
|
||||||
/// <https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface>
|
/// <https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface>
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -73,7 +73,7 @@ impl ResizeObserverEntry {
|
||||||
content_box_size,
|
content_box_size,
|
||||||
device_pixel_content_box_size,
|
device_pixel_content_box_size,
|
||||||
));
|
));
|
||||||
reflect_dom_object_with_proto(entry, window, None)
|
reflect_dom_object_with_proto(entry, window, None, CanGc::note())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ use crate::dom::bindings::codegen::Bindings::ResizeObserverSizeBinding::ResizeOb
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
/// Non-DOM implementation backing `ResizeObserverSize`.
|
/// Non-DOM implementation backing `ResizeObserverSize`.
|
||||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
|
@ -50,7 +51,7 @@ impl ResizeObserverSize {
|
||||||
|
|
||||||
pub fn new(window: &Window, size_impl: ResizeObserverSizeImpl) -> DomRoot<ResizeObserverSize> {
|
pub fn new(window: &Window, size_impl: ResizeObserverSizeImpl) -> DomRoot<ResizeObserverSize> {
|
||||||
let observer_size = Box::new(ResizeObserverSize::new_inherited(size_impl));
|
let observer_size = Box::new(ResizeObserverSize::new_inherited(size_impl));
|
||||||
reflect_dom_object_with_proto(observer_size, window, None)
|
reflect_dom_object_with_proto(observer_size, window, None, CanGc::note())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::headers::{is_obs_text, is_vchar, Guard, Headers};
|
use crate::dom::headers::{is_obs_text, is_vchar, Guard, Headers};
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::readablestream::{ExternalUnderlyingSource, ReadableStream};
|
use crate::dom::readablestream::{ExternalUnderlyingSource, ReadableStream};
|
||||||
use crate::script_runtime::{JSContext as SafeJSContext, StreamConsumer};
|
use crate::script_runtime::{CanGc, JSContext as SafeJSContext, StreamConsumer};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
|
@ -77,17 +77,27 @@ impl Response {
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-response
|
// https://fetch.spec.whatwg.org/#dom-response
|
||||||
pub fn new(global: &GlobalScope) -> DomRoot<Response> {
|
pub fn new(global: &GlobalScope) -> DomRoot<Response> {
|
||||||
Self::new_with_proto(global, None)
|
Self::new_with_proto(global, None, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<Response> {
|
fn new_with_proto(
|
||||||
reflect_dom_object_with_proto(Box::new(Response::new_inherited(global)), global, proto)
|
global: &GlobalScope,
|
||||||
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<Response> {
|
||||||
|
reflect_dom_object_with_proto(
|
||||||
|
Box::new(Response::new_inherited(global)),
|
||||||
|
global,
|
||||||
|
proto,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#initialize-a-response
|
// https://fetch.spec.whatwg.org/#initialize-a-response
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
body: Option<BodyInit>,
|
body: Option<BodyInit>,
|
||||||
init: &ResponseBinding::ResponseInit,
|
init: &ResponseBinding::ResponseInit,
|
||||||
) -> Fallible<DomRoot<Response>> {
|
) -> Fallible<DomRoot<Response>> {
|
||||||
|
@ -107,7 +117,7 @@ impl Response {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let r = Response::new_with_proto(global, proto);
|
let r = Response::new_with_proto(global, proto, can_gc);
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
*r.status.borrow_mut() = Some(StatusCode::from_u16(init.status).unwrap());
|
*r.status.borrow_mut() = Some(StatusCode::from_u16(init.status).unwrap());
|
||||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::event::Event;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::rtcdatachannel::RTCDataChannel;
|
use crate::dom::rtcdatachannel::RTCDataChannel;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct RTCDataChannelEvent {
|
pub struct RTCDataChannelEvent {
|
||||||
|
@ -40,7 +41,15 @@ impl RTCDataChannelEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
channel: &RTCDataChannel,
|
channel: &RTCDataChannel,
|
||||||
) -> DomRoot<RTCDataChannelEvent> {
|
) -> DomRoot<RTCDataChannelEvent> {
|
||||||
Self::new_with_proto(global, None, type_, bubbles, cancelable, channel)
|
Self::new_with_proto(
|
||||||
|
global,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
channel,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -50,11 +59,13 @@ impl RTCDataChannelEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
channel: &RTCDataChannel,
|
channel: &RTCDataChannel,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<RTCDataChannelEvent> {
|
) -> DomRoot<RTCDataChannelEvent> {
|
||||||
let event = reflect_dom_object_with_proto(
|
let event = reflect_dom_object_with_proto(
|
||||||
Box::new(RTCDataChannelEvent::new_inherited(channel)),
|
Box::new(RTCDataChannelEvent::new_inherited(channel)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let event = event.upcast::<Event>();
|
let event = event.upcast::<Event>();
|
||||||
|
@ -67,6 +78,7 @@ impl RTCDataChannelEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &RTCDataChannelEventInit,
|
init: &RTCDataChannelEventInit,
|
||||||
) -> DomRoot<RTCDataChannelEvent> {
|
) -> DomRoot<RTCDataChannelEvent> {
|
||||||
|
@ -77,6 +89,7 @@ impl RTCDataChannelEvent {
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
&init.channel,
|
&init.channel,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::domexception::{DOMErrorName, DOMException};
|
use crate::dom::domexception::{DOMErrorName, DOMException};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct RTCError {
|
pub struct RTCError {
|
||||||
|
@ -43,7 +44,7 @@ impl RTCError {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, init: &RTCErrorInit, message: DOMString) -> DomRoot<RTCError> {
|
pub fn new(global: &GlobalScope, init: &RTCErrorInit, message: DOMString) -> DomRoot<RTCError> {
|
||||||
Self::new_with_proto(global, None, init, message)
|
Self::new_with_proto(global, None, init, message, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -51,11 +52,13 @@ impl RTCError {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
init: &RTCErrorInit,
|
init: &RTCErrorInit,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<RTCError> {
|
) -> DomRoot<RTCError> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(RTCError::new_inherited(global, init, message)),
|
Box::new(RTCError::new_inherited(global, init, message)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,10 +66,11 @@ impl RTCError {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
init: &RTCErrorInit,
|
init: &RTCErrorInit,
|
||||||
message: DOMString,
|
message: DOMString,
|
||||||
) -> DomRoot<RTCError> {
|
) -> DomRoot<RTCError> {
|
||||||
RTCError::new_with_proto(&window.global(), proto, init, message)
|
RTCError::new_with_proto(&window.global(), proto, init, message, can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::event::Event;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::rtcerror::RTCError;
|
use crate::dom::rtcerror::RTCError;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct RTCErrorEvent {
|
pub struct RTCErrorEvent {
|
||||||
|
@ -40,7 +41,15 @@ impl RTCErrorEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
error: &RTCError,
|
error: &RTCError,
|
||||||
) -> DomRoot<RTCErrorEvent> {
|
) -> DomRoot<RTCErrorEvent> {
|
||||||
Self::new_with_proto(global, None, type_, bubbles, cancelable, error)
|
Self::new_with_proto(
|
||||||
|
global,
|
||||||
|
None,
|
||||||
|
type_,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
error,
|
||||||
|
CanGc::note(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -50,11 +59,13 @@ impl RTCErrorEvent {
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
error: &RTCError,
|
error: &RTCError,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<RTCErrorEvent> {
|
) -> DomRoot<RTCErrorEvent> {
|
||||||
let event = reflect_dom_object_with_proto(
|
let event = reflect_dom_object_with_proto(
|
||||||
Box::new(RTCErrorEvent::new_inherited(error)),
|
Box::new(RTCErrorEvent::new_inherited(error)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
let event = event.upcast::<Event>();
|
let event = event.upcast::<Event>();
|
||||||
|
@ -67,6 +78,7 @@ impl RTCErrorEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &RTCErrorEventInit,
|
init: &RTCErrorEventInit,
|
||||||
) -> DomRoot<RTCErrorEvent> {
|
) -> DomRoot<RTCErrorEvent> {
|
||||||
|
@ -77,6 +89,7 @@ impl RTCErrorEvent {
|
||||||
init.parent.bubbles,
|
init.parent.bubbles,
|
||||||
init.parent.cancelable,
|
init.parent.cancelable,
|
||||||
&init.error,
|
&init.error,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct RTCIceCandidate {
|
pub struct RTCIceCandidate {
|
||||||
|
@ -54,6 +55,7 @@ impl RTCIceCandidate {
|
||||||
sdp_m_id,
|
sdp_m_id,
|
||||||
sdp_m_line_index,
|
sdp_m_line_index,
|
||||||
username_fragment,
|
username_fragment,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +66,7 @@ impl RTCIceCandidate {
|
||||||
sdp_m_id: Option<DOMString>,
|
sdp_m_id: Option<DOMString>,
|
||||||
sdp_m_line_index: Option<u16>,
|
sdp_m_line_index: Option<u16>,
|
||||||
username_fragment: Option<DOMString>,
|
username_fragment: Option<DOMString>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<RTCIceCandidate> {
|
) -> DomRoot<RTCIceCandidate> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(RTCIceCandidate::new_inherited(
|
Box::new(RTCIceCandidate::new_inherited(
|
||||||
|
@ -74,6 +77,7 @@ impl RTCIceCandidate {
|
||||||
)),
|
)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +85,7 @@ impl RTCIceCandidate {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
config: &RTCIceCandidateInit,
|
config: &RTCIceCandidateInit,
|
||||||
) -> Fallible<DomRoot<RTCIceCandidate>> {
|
) -> Fallible<DomRoot<RTCIceCandidate>> {
|
||||||
if config.sdpMid.is_none() && config.sdpMLineIndex.is_none() {
|
if config.sdpMid.is_none() && config.sdpMLineIndex.is_none() {
|
||||||
|
@ -95,6 +100,7 @@ impl RTCIceCandidate {
|
||||||
config.sdpMid.clone(),
|
config.sdpMid.clone(),
|
||||||
config.sdpMLineIndex,
|
config.sdpMLineIndex,
|
||||||
config.usernameFragment.clone(),
|
config.usernameFragment.clone(),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ use crate::dom::rtcsessiondescription::RTCSessionDescription;
|
||||||
use crate::dom::rtctrackevent::RTCTrackEvent;
|
use crate::dom::rtctrackevent::RTCTrackEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::realms::{enter_realm, InRealm};
|
use crate::realms::{enter_realm, InRealm};
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
use crate::task_source::networking::NetworkingTaskSource;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
@ -197,11 +198,13 @@ impl RTCPeerConnection {
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
config: &RTCConfiguration,
|
config: &RTCConfiguration,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<RTCPeerConnection> {
|
) -> DomRoot<RTCPeerConnection> {
|
||||||
let this = reflect_dom_object_with_proto(
|
let this = reflect_dom_object_with_proto(
|
||||||
Box::new(RTCPeerConnection::new_inherited()),
|
Box::new(RTCPeerConnection::new_inherited()),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
let signaller = this.make_signaller();
|
let signaller = this.make_signaller();
|
||||||
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
|
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
|
||||||
|
@ -232,9 +235,15 @@ impl RTCPeerConnection {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
config: &RTCConfiguration,
|
config: &RTCConfiguration,
|
||||||
) -> Fallible<DomRoot<RTCPeerConnection>> {
|
) -> Fallible<DomRoot<RTCPeerConnection>> {
|
||||||
Ok(RTCPeerConnection::new(&window.global(), proto, config))
|
Ok(RTCPeerConnection::new(
|
||||||
|
&window.global(),
|
||||||
|
proto,
|
||||||
|
config,
|
||||||
|
can_gc,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_webrtc_controller(&self) -> &DomRefCell<Option<WebRtcController>> {
|
pub fn get_webrtc_controller(&self) -> &DomRefCell<Option<WebRtcController>> {
|
||||||
|
@ -650,6 +659,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
let desc = RTCSessionDescription::Constructor(
|
let desc = RTCSessionDescription::Constructor(
|
||||||
this.global().as_window(),
|
this.global().as_window(),
|
||||||
None,
|
None,
|
||||||
|
CanGc::note(),
|
||||||
&desc,
|
&desc,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
this.local_description.set(Some(&desc));
|
this.local_description.set(Some(&desc));
|
||||||
|
@ -690,6 +700,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
let desc = RTCSessionDescription::Constructor(
|
let desc = RTCSessionDescription::Constructor(
|
||||||
this.global().as_window(),
|
this.global().as_window(),
|
||||||
None,
|
None,
|
||||||
|
CanGc::note(),
|
||||||
&desc,
|
&desc,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
this.remote_description.set(Some(&desc));
|
this.remote_description.set(Some(&desc));
|
||||||
|
|
|
@ -19,6 +19,7 @@ use crate::dom::event::Event;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::rtcicecandidate::RTCIceCandidate;
|
use crate::dom::rtcicecandidate::RTCIceCandidate;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct RTCPeerConnectionIceEvent {
|
pub struct RTCPeerConnectionIceEvent {
|
||||||
|
@ -46,7 +47,7 @@ impl RTCPeerConnectionIceEvent {
|
||||||
url: Option<DOMString>,
|
url: Option<DOMString>,
|
||||||
trusted: bool,
|
trusted: bool,
|
||||||
) -> DomRoot<RTCPeerConnectionIceEvent> {
|
) -> DomRoot<RTCPeerConnectionIceEvent> {
|
||||||
Self::new_with_proto(global, None, ty, candidate, url, trusted)
|
Self::new_with_proto(global, None, ty, candidate, url, trusted, CanGc::note())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_proto(
|
fn new_with_proto(
|
||||||
|
@ -56,11 +57,13 @@ impl RTCPeerConnectionIceEvent {
|
||||||
candidate: Option<&RTCIceCandidate>,
|
candidate: Option<&RTCIceCandidate>,
|
||||||
url: Option<DOMString>,
|
url: Option<DOMString>,
|
||||||
trusted: bool,
|
trusted: bool,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<RTCPeerConnectionIceEvent> {
|
) -> DomRoot<RTCPeerConnectionIceEvent> {
|
||||||
let e = reflect_dom_object_with_proto(
|
let e = reflect_dom_object_with_proto(
|
||||||
Box::new(RTCPeerConnectionIceEvent::new_inherited(candidate, url)),
|
Box::new(RTCPeerConnectionIceEvent::new_inherited(candidate, url)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
);
|
);
|
||||||
let evt = e.upcast::<Event>();
|
let evt = e.upcast::<Event>();
|
||||||
evt.init_event(ty, false, false); // XXXManishearth bubbles/cancelable?
|
evt.init_event(ty, false, false); // XXXManishearth bubbles/cancelable?
|
||||||
|
@ -72,6 +75,7 @@ impl RTCPeerConnectionIceEvent {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
ty: DOMString,
|
ty: DOMString,
|
||||||
init: &RTCPeerConnectionIceEventInit,
|
init: &RTCPeerConnectionIceEventInit,
|
||||||
) -> Fallible<DomRoot<RTCPeerConnectionIceEvent>> {
|
) -> Fallible<DomRoot<RTCPeerConnectionIceEvent>> {
|
||||||
|
@ -85,6 +89,7 @@ impl RTCPeerConnectionIceEvent {
|
||||||
.map(|x| &**x),
|
.map(|x| &**x),
|
||||||
init.url.as_ref().and_then(|x| x.clone()),
|
init.url.as_ref().and_then(|x| x.clone()),
|
||||||
false,
|
false,
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct RTCSessionDescription {
|
pub struct RTCSessionDescription {
|
||||||
|
@ -36,11 +37,13 @@ impl RTCSessionDescription {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
ty: RTCSdpType,
|
ty: RTCSdpType,
|
||||||
sdp: DOMString,
|
sdp: DOMString,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<RTCSessionDescription> {
|
) -> DomRoot<RTCSessionDescription> {
|
||||||
reflect_dom_object_with_proto(
|
reflect_dom_object_with_proto(
|
||||||
Box::new(RTCSessionDescription::new_inherited(ty, sdp)),
|
Box::new(RTCSessionDescription::new_inherited(ty, sdp)),
|
||||||
global,
|
global,
|
||||||
proto,
|
proto,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +51,7 @@ impl RTCSessionDescription {
|
||||||
pub fn Constructor(
|
pub fn Constructor(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
|
can_gc: CanGc,
|
||||||
config: &RTCSessionDescriptionInit,
|
config: &RTCSessionDescriptionInit,
|
||||||
) -> Fallible<DomRoot<RTCSessionDescription>> {
|
) -> Fallible<DomRoot<RTCSessionDescription>> {
|
||||||
Ok(RTCSessionDescription::new(
|
Ok(RTCSessionDescription::new(
|
||||||
|
@ -55,6 +59,7 @@ impl RTCSessionDescription {
|
||||||
proto,
|
proto,
|
||||||
config.type_,
|
config.type_,
|
||||||
config.sdp.clone(),
|
config.sdp.clone(),
|
||||||
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue