aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorchickenleaf <lashwinib@gmail.com>2024-10-16 08:20:28 +0530
committerGitHub <noreply@github.com>2024-10-16 02:50:28 +0000
commita2f81d69c1971f07c2af8633756953ddd70a1bb5 (patch)
treea0f3cc7e6939f3e588b14b49b483a2d31e0d1aa4 /components/script/dom
parent5b8fbb023dfba890c7744e826a077776516131c6 (diff)
downloadservo-a2f81d69c1971f07c2af8633756953ddd70a1bb5.tar.gz
servo-a2f81d69c1971f07c2af8633756953ddd70a1bb5.zip
CanGc fixes (#33852)
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/audiocontext.rs3
-rw-r--r--components/script/dom/baseaudiocontext.rs9
-rw-r--r--components/script/dom/bindings/codegen/Bindings.conf19
-rw-r--r--components/script/dom/document.rs7
-rw-r--r--components/script/dom/dommatrixreadonly.rs4
-rw-r--r--components/script/dom/dompoint.rs23
-rw-r--r--components/script/dom/domquad.rs27
-rw-r--r--components/script/dom/gainnode.rs3
-rw-r--r--components/script/dom/gamepad.rs2
-rw-r--r--components/script/dom/gamepadhapticactuator.rs6
-rw-r--r--components/script/dom/mediaelementaudiosourcenode.rs3
-rw-r--r--components/script/dom/mediametadata.rs4
-rw-r--r--components/script/dom/mediaquerylistevent.rs10
-rw-r--r--components/script/dom/mediasession.rs4
-rw-r--r--components/script/dom/mouseevent.rs4
-rw-r--r--components/script/dom/window.rs3
-rw-r--r--components/script/dom/xrinputsourcearray.rs5
-rw-r--r--components/script/dom/xrinputsourceschangeevent.rs11
-rw-r--r--components/script/dom/xrsession.rs6
19 files changed, 91 insertions, 62 deletions
diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs
index 62b574d10b7..f543260b7f0 100644
--- a/components/script/dom/audiocontext.rs
+++ b/components/script/dom/audiocontext.rs
@@ -265,10 +265,11 @@ impl AudioContextMethods for AudioContext {
fn CreateMediaElementSource(
&self,
media_element: &HTMLMediaElement,
+ can_gc: CanGc,
) -> Fallible<DomRoot<MediaElementAudioSourceNode>> {
let global = self.global();
let window = global.as_window();
- MediaElementAudioSourceNode::new(window, self, media_element)
+ MediaElementAudioSourceNode::new(window, self, media_element, can_gc)
}
/// <https://webaudio.github.io/web-audio-api/#dom-audiocontext-createmediastreamsource>
diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs
index 0542b8a6273..f47b2aaa1ce 100644
--- a/components/script/dom/baseaudiocontext.rs
+++ b/components/script/dom/baseaudiocontext.rs
@@ -357,8 +357,13 @@ impl BaseAudioContextMethods for BaseAudioContext {
}
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain>
- fn CreateGain(&self) -> Fallible<DomRoot<GainNode>> {
- GainNode::new(self.global().as_window(), self, &GainOptions::empty())
+ fn CreateGain(&self, can_gc: CanGc) -> Fallible<DomRoot<GainNode>> {
+ GainNode::new(
+ self.global().as_window(),
+ self,
+ &GainOptions::empty(),
+ can_gc,
+ )
}
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createpanner>
diff --git a/components/script/dom/bindings/codegen/Bindings.conf b/components/script/dom/bindings/codegen/Bindings.conf
index c9f0bfd0afe..7d41153cfd1 100644
--- a/components/script/dom/bindings/codegen/Bindings.conf
+++ b/components/script/dom/bindings/codegen/Bindings.conf
@@ -20,12 +20,12 @@ DOMInterfaces = {
'AudioContext': {
'inRealms': ['Close', 'Suspend'],
- 'canGc':['CreateMediaStreamDestination'],
+ 'canGc':['CreateMediaStreamDestination', 'CreateMediaElementSource'],
},
'BaseAudioContext': {
'inRealms': ['DecodeAudioData', 'Resume', 'ParseFromString', 'GetBounds', 'GetClientRects'],
- 'canGc': ['CreateOscillator', 'CreateStereoPanner'],
+ 'canGc': ['CreateOscillator', 'CreateStereoPanner', 'CreateGain'],
},
'Blob': {
@@ -73,6 +73,15 @@ DOMInterfaces = {
'canGc': ['FromMatrix', 'FromFloat32Array', 'FromFloat64Array'],
},
+'DOMQuad': {
+ 'canGc': ['FromRect', 'FromQuad'],
+},
+
+'DOMPoint': {
+ 'canGc': ['FromPoint'],
+},
+
+
'DOMMatrixReadOnly': {
'canGc': ['Multiply', 'Inverse', 'Scale', 'Translate', 'Rotate', 'RotateFromVector','FlipY', 'ScaleNonUniform', 'Scale3d', 'RotateAxisAngle', 'SkewX', 'SkewY', 'FlipX', 'TransformPoint', 'FromFloat32Array', 'FromFloat64Array','FromMatrix'],
},
@@ -145,6 +154,11 @@ DOMInterfaces = {
'canGc': ['Clone'],
},
+'MediaSession': {
+ 'canGc': ['GetMetadata'],
+},
+
+
'MediaQueryList': {
'weakReferenceable': True,
},
@@ -251,6 +265,7 @@ DOMInterfaces = {
'XRSession': {
'inRealms': ['RequestReferenceSpace', 'UpdateRenderState', 'UpdateTargetFrameRate'],
+ 'canGc': ['End'],
},
'XRSystem': {
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 60310ecc655..1ff44280888 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -4641,9 +4641,10 @@ impl DocumentMethods for Document {
"messageevent" => Ok(DomRoot::upcast(MessageEvent::new_uninitialized(
self.window.upcast(),
))),
- "mouseevent" | "mouseevents" => {
- Ok(DomRoot::upcast(MouseEvent::new_uninitialized(&self.window)))
- },
+ "mouseevent" | "mouseevents" => Ok(DomRoot::upcast(MouseEvent::new_uninitialized(
+ &self.window,
+ can_gc,
+ ))),
"storageevent" => Ok(DomRoot::upcast(StorageEvent::new_uninitialized(
&self.window,
"".into(),
diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs
index 3b8c1dae471..8abb924ec6d 100644
--- a/components/script/dom/dommatrixreadonly.rs
+++ b/components/script/dom/dommatrixreadonly.rs
@@ -759,7 +759,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
- fn TransformPoint(&self, point: &DOMPointInit, _can_gc: CanGc) -> DomRoot<DOMPoint> {
+ fn TransformPoint(&self, point: &DOMPointInit, can_gc: CanGc) -> DomRoot<DOMPoint> {
// Euclid always normalizes the homogeneous coordinate which is usually the right
// thing but may (?) not be compliant with the CSS matrix spec (or at least is
// probably not the behavior web authors will expect even if it is mathematically
@@ -772,7 +772,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
let z = point.x * mat.m13 + point.y * mat.m23 + point.z * mat.m33 + point.w * mat.m43;
let w = point.x * mat.m14 + point.y * mat.m24 + point.z * mat.m34 + point.w * mat.m44;
- DOMPoint::new(&self.global(), x, y, z, w)
+ DOMPoint::new(&self.global(), x, y, z, w, can_gc)
}
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-tofloat32array
diff --git a/components/script/dom/dompoint.rs b/components/script/dom/dompoint.rs
index 600f0f0e445..0e8d5ad1004 100644
--- a/components/script/dom/dompoint.rs
+++ b/components/script/dom/dompoint.rs
@@ -28,8 +28,15 @@ impl 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, CanGc::note())
+ pub fn new(
+ global: &GlobalScope,
+ x: f64,
+ y: f64,
+ z: f64,
+ w: f64,
+ can_gc: CanGc,
+ ) -> DomRoot<DOMPoint> {
+ Self::new_with_proto(global, None, x, y, z, w, can_gc)
}
fn new_with_proto(
@@ -49,8 +56,12 @@ impl DOMPoint {
)
}
- pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> DomRoot<DOMPoint> {
- DOMPoint::new(global, p.x, p.y, p.z, p.w)
+ pub fn new_from_init(
+ global: &GlobalScope,
+ p: &DOMPointInit,
+ can_gc: CanGc,
+ ) -> DomRoot<DOMPoint> {
+ DOMPoint::new(global, p.x, p.y, p.z, p.w, can_gc)
}
}
@@ -69,8 +80,8 @@ impl DOMPointMethods for DOMPoint {
}
// https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
- fn FromPoint(global: &GlobalScope, init: &DOMPointInit) -> DomRoot<Self> {
- Self::new_from_init(global, init)
+ fn FromPoint(global: &GlobalScope, init: &DOMPointInit, can_gc: CanGc) -> DomRoot<Self> {
+ Self::new_from_init(global, init, can_gc)
}
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
diff --git a/components/script/dom/domquad.rs b/components/script/dom/domquad.rs
index dbd78c94a18..3ceb00ab59c 100644
--- a/components/script/dom/domquad.rs
+++ b/components/script/dom/domquad.rs
@@ -79,39 +79,40 @@ impl DOMQuadMethods for DOMQuad {
Ok(DOMQuad::new_with_proto(
global,
proto,
- &DOMPoint::new_from_init(global, p1),
- &DOMPoint::new_from_init(global, p2),
- &DOMPoint::new_from_init(global, p3),
- &DOMPoint::new_from_init(global, p4),
+ &DOMPoint::new_from_init(global, p1, can_gc),
+ &DOMPoint::new_from_init(global, p2, can_gc),
+ &DOMPoint::new_from_init(global, p3, can_gc),
+ &DOMPoint::new_from_init(global, p4, can_gc),
can_gc,
))
}
// https://drafts.fxtf.org/geometry/#dom-domquad-fromrect
- fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> DomRoot<DOMQuad> {
+ fn FromRect(global: &GlobalScope, other: &DOMRectInit, can_gc: CanGc) -> DomRoot<DOMQuad> {
DOMQuad::new(
global,
- &DOMPoint::new(global, other.x, other.y, 0f64, 1f64),
- &DOMPoint::new(global, other.x + other.width, other.y, 0f64, 1f64),
+ &DOMPoint::new(global, other.x, other.y, 0f64, 1f64, can_gc),
+ &DOMPoint::new(global, other.x + other.width, other.y, 0f64, 1f64, can_gc),
&DOMPoint::new(
global,
other.x + other.width,
other.y + other.height,
0f64,
1f64,
+ can_gc,
),
- &DOMPoint::new(global, other.x, other.y + other.height, 0f64, 1f64),
+ &DOMPoint::new(global, other.x, other.y + other.height, 0f64, 1f64, can_gc),
)
}
// https://drafts.fxtf.org/geometry/#dom-domquad-fromquad
- fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> DomRoot<DOMQuad> {
+ fn FromQuad(global: &GlobalScope, other: &DOMQuadInit, can_gc: CanGc) -> DomRoot<DOMQuad> {
DOMQuad::new(
global,
- &DOMPoint::new_from_init(global, &other.p1),
- &DOMPoint::new_from_init(global, &other.p2),
- &DOMPoint::new_from_init(global, &other.p3),
- &DOMPoint::new_from_init(global, &other.p4),
+ &DOMPoint::new_from_init(global, &other.p1, can_gc),
+ &DOMPoint::new_from_init(global, &other.p2, can_gc),
+ &DOMPoint::new_from_init(global, &other.p3, can_gc),
+ &DOMPoint::new_from_init(global, &other.p4, can_gc),
)
}
diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs
index ee2e7c40ffb..aa03d616cd6 100644
--- a/components/script/dom/gainnode.rs
+++ b/components/script/dom/gainnode.rs
@@ -69,8 +69,9 @@ impl GainNode {
window: &Window,
context: &BaseAudioContext,
options: &GainOptions,
+ can_gc: CanGc,
) -> Fallible<DomRoot<GainNode>> {
- Self::new_with_proto(window, None, context, options, CanGc::note())
+ Self::new_with_proto(window, None, context, options, can_gc)
}
#[allow(crown::unrooted_must_root)]
diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs
index 7f69f69af84..106b37a908e 100644
--- a/components/script/dom/gamepad.rs
+++ b/components/script/dom/gamepad.rs
@@ -132,7 +132,7 @@ impl Gamepad {
) -> DomRoot<Gamepad> {
let button_list = GamepadButtonList::init_buttons(global);
let vibration_actuator =
- GamepadHapticActuator::new(global, gamepad_id, supported_haptic_effects);
+ GamepadHapticActuator::new(global, gamepad_id, supported_haptic_effects, can_gc);
let index = if xr { -1 } else { 0 };
let gamepad = reflect_dom_object_with_proto(
Box::new(Gamepad::new_inherited(
diff --git a/components/script/dom/gamepadhapticactuator.rs b/components/script/dom/gamepadhapticactuator.rs
index 008cc5c9216..54be5de11dd 100644
--- a/components/script/dom/gamepadhapticactuator.rs
+++ b/components/script/dom/gamepadhapticactuator.rs
@@ -109,14 +109,16 @@ impl GamepadHapticActuator {
global: &GlobalScope,
gamepad_index: u32,
supported_haptic_effects: GamepadSupportedHapticEffects,
+ can_gc: CanGc,
) -> DomRoot<GamepadHapticActuator> {
- Self::new_with_proto(global, gamepad_index, supported_haptic_effects)
+ Self::new_with_proto(global, gamepad_index, supported_haptic_effects, can_gc)
}
fn new_with_proto(
global: &GlobalScope,
gamepad_index: u32,
supported_haptic_effects: GamepadSupportedHapticEffects,
+ can_gc: CanGc,
) -> DomRoot<GamepadHapticActuator> {
reflect_dom_object_with_proto(
Box::new(GamepadHapticActuator::new_inherited(
@@ -125,7 +127,7 @@ impl GamepadHapticActuator {
)),
global,
None,
- CanGc::note(),
+ can_gc,
)
}
}
diff --git a/components/script/dom/mediaelementaudiosourcenode.rs b/components/script/dom/mediaelementaudiosourcenode.rs
index c7484ba62bf..007846bec29 100644
--- a/components/script/dom/mediaelementaudiosourcenode.rs
+++ b/components/script/dom/mediaelementaudiosourcenode.rs
@@ -58,8 +58,9 @@ impl MediaElementAudioSourceNode {
window: &Window,
context: &AudioContext,
media_element: &HTMLMediaElement,
+ can_gc: CanGc,
) -> Fallible<DomRoot<MediaElementAudioSourceNode>> {
- Self::new_with_proto(window, None, context, media_element, CanGc::note())
+ Self::new_with_proto(window, None, context, media_element, can_gc)
}
#[allow(crown::unrooted_must_root)]
diff --git a/components/script/dom/mediametadata.rs b/components/script/dom/mediametadata.rs
index f2ee1907f1b..fb642f08e32 100644
--- a/components/script/dom/mediametadata.rs
+++ b/components/script/dom/mediametadata.rs
@@ -37,8 +37,8 @@ impl MediaMetadata {
}
}
- pub fn new(global: &Window, init: &MediaMetadataInit) -> DomRoot<MediaMetadata> {
- Self::new_with_proto(global, None, init, CanGc::note())
+ pub fn new(global: &Window, init: &MediaMetadataInit, can_gc: CanGc) -> DomRoot<MediaMetadata> {
+ Self::new_with_proto(global, None, init, can_gc)
}
fn new_with_proto(
diff --git a/components/script/dom/mediaquerylistevent.rs b/components/script/dom/mediaquerylistevent.rs
index b7f07ad947a..6e141f2c108 100644
--- a/components/script/dom/mediaquerylistevent.rs
+++ b/components/script/dom/mediaquerylistevent.rs
@@ -53,16 +53,10 @@ impl MediaQueryListEvent {
cancelable: bool,
media: DOMString,
matches: bool,
+ can_gc: CanGc,
) -> DomRoot<MediaQueryListEvent> {
Self::new_with_proto(
- global,
- None,
- type_,
- bubbles,
- cancelable,
- media,
- matches,
- CanGc::note(),
+ global, None, type_, bubbles, cancelable, media, matches, can_gc,
)
}
diff --git a/components/script/dom/mediasession.rs b/components/script/dom/mediasession.rs
index 6fc045ca3eb..760a71e57d0 100644
--- a/components/script/dom/mediasession.rs
+++ b/components/script/dom/mediasession.rs
@@ -126,14 +126,14 @@ impl MediaSession {
impl MediaSessionMethods for MediaSession {
/// <https://w3c.github.io/mediasession/#dom-mediasession-metadata>
- fn GetMetadata(&self) -> Option<DomRoot<MediaMetadata>> {
+ fn GetMetadata(&self, can_gc: CanGc) -> Option<DomRoot<MediaMetadata>> {
if let Some(ref metadata) = *self.metadata.borrow() {
let mut init = MediaMetadataInit::empty();
init.title = DOMString::from_string(metadata.title.clone());
init.artist = DOMString::from_string(metadata.artist.clone());
init.album = DOMString::from_string(metadata.album.clone());
let global = self.global();
- Some(MediaMetadata::new(global.as_window(), &init))
+ Some(MediaMetadata::new(global.as_window(), &init, can_gc))
} else {
None
}
diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs
index ea9bf3595a8..9cde47fbe5b 100644
--- a/components/script/dom/mouseevent.rs
+++ b/components/script/dom/mouseevent.rs
@@ -75,8 +75,8 @@ impl MouseEvent {
}
}
- pub fn new_uninitialized(window: &Window) -> DomRoot<MouseEvent> {
- Self::new_uninitialized_with_proto(window, None, CanGc::note())
+ pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<MouseEvent> {
+ Self::new_uninitialized_with_proto(window, None, can_gc)
}
fn new_uninitialized_with_proto(
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 9d4e1d4e361..1741eddde25 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -2446,7 +2446,7 @@ impl Window {
/// Evaluate media query lists and report changes
/// <https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes>
- pub fn evaluate_media_queries_and_report_changes(&self) {
+ pub fn evaluate_media_queries_and_report_changes(&self, can_gc: CanGc) {
rooted_vec!(let mut mql_list);
self.media_query_lists.for_each(|mql| {
if let MediaQueryListMatchState::Changed = mql.evaluate_changes() {
@@ -2463,6 +2463,7 @@ impl Window {
false,
mql.Media(),
mql.Matches(),
+ can_gc,
);
event.upcast::<Event>().fire(mql.upcast::<EventTarget>());
}
diff --git a/components/script/dom/xrinputsourcearray.rs b/components/script/dom/xrinputsourcearray.rs
index e47ddefb24a..e47e686870d 100644
--- a/components/script/dom/xrinputsourcearray.rs
+++ b/components/script/dom/xrinputsourcearray.rs
@@ -60,13 +60,14 @@ impl XRInputSourceArray {
session,
&added,
&[],
+ can_gc,
);
// Release the refcell guard
drop(input_sources);
event.upcast::<Event>().fire(session.upcast());
}
- pub fn remove_input_source(&self, session: &XRSession, id: InputId) {
+ pub fn remove_input_source(&self, session: &XRSession, id: InputId, can_gc: CanGc) {
let mut input_sources = self.input_sources.borrow_mut();
let global = self.global();
let removed = if let Some(i) = input_sources.iter().find(|i| i.id() == id) {
@@ -84,6 +85,7 @@ impl XRInputSourceArray {
session,
&[],
&removed,
+ can_gc,
);
input_sources.retain(|i| i.id() != id);
// release the refcell guard
@@ -123,6 +125,7 @@ impl XRInputSourceArray {
session,
&added,
removed,
+ can_gc,
);
// release the refcell guard
drop(input_sources);
diff --git a/components/script/dom/xrinputsourceschangeevent.rs b/components/script/dom/xrinputsourceschangeevent.rs
index 368785acd1c..14fda803697 100644
--- a/components/script/dom/xrinputsourceschangeevent.rs
+++ b/components/script/dom/xrinputsourceschangeevent.rs
@@ -54,17 +54,10 @@ impl XRInputSourcesChangeEvent {
session: &XRSession,
added: &[DomRoot<XRInputSource>],
removed: &[DomRoot<XRInputSource>],
+ can_gc: CanGc,
) -> DomRoot<XRInputSourcesChangeEvent> {
Self::new_with_proto(
- global,
- None,
- type_,
- bubbles,
- cancelable,
- session,
- added,
- removed,
- CanGc::note(),
+ global, None, type_, bubbles, cancelable, session, added, removed, can_gc,
)
}
diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs
index bef11f43e97..ab89b6c0d1a 100644
--- a/components/script/dom/xrsession.rs
+++ b/components/script/dom/xrsession.rs
@@ -370,7 +370,7 @@ impl XRSession {
self.input_sources.add_input_sources(self, &[info], can_gc);
},
XREvent::RemoveInput(id) => {
- self.input_sources.remove_input_source(self, id);
+ self.input_sources.remove_input_source(self, id, can_gc);
},
XREvent::UpdateInput(id, source) => {
self.input_sources
@@ -878,7 +878,7 @@ impl XRSessionMethods for XRSession {
}
/// <https://immersive-web.github.io/webxr/#dom-xrsession-end>
- fn End(&self) -> Rc<Promise> {
+ fn End(&self, can_gc: CanGc) -> Rc<Promise> {
let global = self.global();
let p = Promise::new(&global);
if self.ended.get() && self.end_promises.borrow().is_empty() {
@@ -904,7 +904,7 @@ impl XRSessionMethods for XRSession {
// Disconnect any still-attached XRInputSources
for source in 0..self.input_sources.Length() {
self.input_sources
- .remove_input_source(self, InputId(source));
+ .remove_input_source(self, InputId(source), can_gc);
}
p
}