mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
CanGc fixes in components/script/dom (#33891)
Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
parent
9c893c7f4d
commit
f826698d6e
13 changed files with 49 additions and 25 deletions
|
@ -89,7 +89,7 @@ pub trait WorkerEventLoopMethods {
|
|||
type ControlMsg;
|
||||
type Event;
|
||||
fn task_queue(&self) -> &TaskQueue<Self::WorkerMsg>;
|
||||
fn handle_event(&self, event: Self::Event) -> bool;
|
||||
fn handle_event(&self, event: Self::Event, can_gc: CanGc) -> bool;
|
||||
fn handle_worker_post_event(&self, worker: &TrustedWorkerAddress) -> Option<AutoWorkerReset>;
|
||||
fn from_control_msg(msg: Self::ControlMsg) -> Self::Event;
|
||||
fn from_worker_msg(msg: Self::WorkerMsg) -> Self::Event;
|
||||
|
@ -143,7 +143,7 @@ pub fn run_worker_event_loop<T, WorkerMsg, Event>(
|
|||
// Step 3
|
||||
for event in sequential {
|
||||
let _realm = enter_realm(worker_scope);
|
||||
if !worker_scope.handle_event(event) {
|
||||
if !worker_scope.handle_event(event, can_gc) {
|
||||
// Shutdown
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -367,8 +367,13 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
|||
}
|
||||
|
||||
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createpanner>
|
||||
fn CreatePanner(&self) -> Fallible<DomRoot<PannerNode>> {
|
||||
PannerNode::new(self.global().as_window(), self, &PannerOptions::empty())
|
||||
fn CreatePanner(&self, can_gc: CanGc) -> Fallible<DomRoot<PannerNode>> {
|
||||
PannerNode::new(
|
||||
self.global().as_window(),
|
||||
self,
|
||||
&PannerOptions::empty(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createanalyser>
|
||||
|
@ -411,10 +416,14 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
|||
}
|
||||
|
||||
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelmerger>
|
||||
fn CreateChannelMerger(&self, count: u32) -> Fallible<DomRoot<ChannelMergerNode>> {
|
||||
fn CreateChannelMerger(
|
||||
&self,
|
||||
count: u32,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<ChannelMergerNode>> {
|
||||
let mut opts = ChannelMergerOptions::empty();
|
||||
opts.numberOfInputs = count;
|
||||
ChannelMergerNode::new(self.global().as_window(), self, &opts)
|
||||
ChannelMergerNode::new(self.global().as_window(), self, &opts, can_gc)
|
||||
}
|
||||
|
||||
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelsplitter>
|
||||
|
|
|
@ -25,7 +25,7 @@ DOMInterfaces = {
|
|||
|
||||
'BaseAudioContext': {
|
||||
'inRealms': ['DecodeAudioData', 'Resume', 'ParseFromString', 'GetBounds', 'GetClientRects'],
|
||||
'canGc': ['CreateOscillator', 'CreateStereoPanner', 'CreateGain', 'CreateIIRFilter', 'CreateBiquadFilter', 'CreateBufferSource', 'CreateAnalyser'],
|
||||
'canGc': ['CreateChannelMerger', 'CreateOscillator', 'CreateStereoPanner', 'CreateGain', 'CreateIIRFilter', 'CreateBiquadFilter', 'CreateBufferSource', 'CreateAnalyser', 'CreatePanner'],
|
||||
},
|
||||
|
||||
'Blob': {
|
||||
|
|
|
@ -61,8 +61,9 @@ impl ChannelMergerNode {
|
|||
window: &Window,
|
||||
context: &BaseAudioContext,
|
||||
options: &ChannelMergerOptions,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<ChannelMergerNode>> {
|
||||
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)]
|
||||
|
|
|
@ -212,7 +212,7 @@ impl WorkerEventLoopMethods for DedicatedWorkerGlobalScope {
|
|||
&self.task_queue
|
||||
}
|
||||
|
||||
fn handle_event(&self, event: MixedMessage) -> bool {
|
||||
fn handle_event(&self, event: MixedMessage, _can_gc: CanGc) -> bool {
|
||||
self.handle_mixed_message(event)
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ impl ExtendableMessageEvent {
|
|||
origin: DOMString,
|
||||
lastEventId: DOMString,
|
||||
ports: Vec<DomRoot<MessagePort>>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<ExtendableMessageEvent> {
|
||||
Self::new_with_proto(
|
||||
global,
|
||||
|
@ -86,7 +87,7 @@ impl ExtendableMessageEvent {
|
|||
origin,
|
||||
lastEventId,
|
||||
ports,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -126,6 +127,7 @@ impl ExtendableMessageEvent {
|
|||
scope: &GlobalScope,
|
||||
message: HandleValue,
|
||||
ports: Vec<DomRoot<MessagePort>>,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
let Extendablemessageevent = ExtendableMessageEvent::new(
|
||||
scope,
|
||||
|
@ -136,11 +138,12 @@ impl ExtendableMessageEvent {
|
|||
DOMString::new(),
|
||||
DOMString::new(),
|
||||
ports,
|
||||
can_gc,
|
||||
);
|
||||
Extendablemessageevent.upcast::<Event>().fire(target);
|
||||
}
|
||||
|
||||
pub fn dispatch_error(target: &EventTarget, scope: &GlobalScope) {
|
||||
pub fn dispatch_error(target: &EventTarget, scope: &GlobalScope, can_gc: CanGc) {
|
||||
let init = ExtendableMessageEventBinding::ExtendableMessageEventInit::empty();
|
||||
let ExtendableMsgEvent = ExtendableMessageEvent::new(
|
||||
scope,
|
||||
|
@ -151,6 +154,7 @@ impl ExtendableMessageEvent {
|
|||
init.origin.clone(),
|
||||
init.lastEventId.clone(),
|
||||
init.ports.clone(),
|
||||
can_gc,
|
||||
);
|
||||
ExtendableMsgEvent.upcast::<Event>().fire(target);
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ impl GPUMethods for GPU {
|
|||
}
|
||||
|
||||
impl AsyncWGPUListener for GPU {
|
||||
fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||
fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>, can_gc: CanGc) {
|
||||
match response {
|
||||
WebGPUResponse::Adapter(Ok(adapter)) => {
|
||||
let adapter = GPUAdapter::new(
|
||||
|
@ -158,6 +158,7 @@ impl AsyncWGPUListener for GPU {
|
|||
adapter.limits,
|
||||
adapter.adapter_info,
|
||||
adapter.adapter_id,
|
||||
can_gc,
|
||||
);
|
||||
promise.resolve_native(&adapter);
|
||||
},
|
||||
|
|
|
@ -77,8 +77,9 @@ impl GPUAdapter {
|
|||
limits: wgt::Limits,
|
||||
info: wgt::AdapterInfo,
|
||||
adapter: WebGPUAdapter,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<Self> {
|
||||
let features = GPUSupportedFeatures::Constructor(global, None, features).unwrap();
|
||||
let features = GPUSupportedFeatures::Constructor(global, None, features, can_gc).unwrap();
|
||||
let limits = GPUSupportedLimits::new(global, limits);
|
||||
let info = GPUAdapterInfo::new(global, info);
|
||||
reflect_dom_object(
|
||||
|
@ -195,7 +196,7 @@ impl GPUAdapterMethods for GPUAdapter {
|
|||
}
|
||||
|
||||
impl AsyncWGPUListener for GPUAdapter {
|
||||
fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||
fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>, can_gc: CanGc) {
|
||||
match response {
|
||||
WebGPUResponse::Device((device_id, queue_id, Ok(descriptor))) => {
|
||||
let device = GPUDevice::new(
|
||||
|
@ -208,6 +209,7 @@ impl AsyncWGPUListener for GPUAdapter {
|
|||
device_id,
|
||||
queue_id,
|
||||
descriptor.label.unwrap_or_default(),
|
||||
can_gc,
|
||||
);
|
||||
self.global().add_gpu_device(&device);
|
||||
promise.resolve_native(&device);
|
||||
|
@ -231,6 +233,7 @@ impl AsyncWGPUListener for GPUAdapter {
|
|||
device_id,
|
||||
queue_id,
|
||||
String::new(),
|
||||
can_gc,
|
||||
);
|
||||
device.lose(GPUDeviceLostReason::Unknown, e.to_string());
|
||||
promise.resolve_native(&device);
|
||||
|
|
|
@ -148,10 +148,11 @@ impl GPUDevice {
|
|||
device: webgpu::WebGPUDevice,
|
||||
queue: webgpu::WebGPUQueue,
|
||||
label: String,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<Self> {
|
||||
let queue = GPUQueue::new(global, channel.clone(), queue);
|
||||
let limits = GPUSupportedLimits::new(global, limits);
|
||||
let features = GPUSupportedFeatures::Constructor(global, None, features).unwrap();
|
||||
let features = GPUSupportedFeatures::Constructor(global, None, features, can_gc).unwrap();
|
||||
let lost_promise = Promise::new(global);
|
||||
let device = reflect_dom_object(
|
||||
Box::new(GPUDevice::new_inherited(
|
||||
|
|
|
@ -50,6 +50,7 @@ impl GPUSupportedFeatures {
|
|||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
features: Features,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<GPUSupportedFeatures> {
|
||||
let mut set = IndexSet::new();
|
||||
if features.contains(Features::DEPTH_CLIP_CONTROL) {
|
||||
|
@ -103,7 +104,7 @@ impl GPUSupportedFeatures {
|
|||
}),
|
||||
global,
|
||||
proto,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -112,8 +113,9 @@ impl GPUSupportedFeatures {
|
|||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
features: Features,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<GPUSupportedFeatures>> {
|
||||
Ok(GPUSupportedFeatures::new(global, proto, features))
|
||||
Ok(GPUSupportedFeatures::new(global, proto, features, can_gc))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -184,8 +184,9 @@ impl PannerNode {
|
|||
window: &Window,
|
||||
context: &BaseAudioContext,
|
||||
options: &PannerOptions,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<PannerNode>> {
|
||||
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)]
|
||||
|
|
|
@ -70,8 +70,9 @@ impl PerformanceObserver {
|
|||
global: &GlobalScope,
|
||||
callback: Rc<PerformanceObserverCallback>,
|
||||
entries: DOMPerformanceEntryList,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<PerformanceObserver> {
|
||||
Self::new_with_proto(global, None, callback, entries, CanGc::note())
|
||||
Self::new_with_proto(global, None, callback, entries, can_gc)
|
||||
}
|
||||
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
|
|
|
@ -191,8 +191,8 @@ impl WorkerEventLoopMethods for ServiceWorkerGlobalScope {
|
|||
&self.task_queue
|
||||
}
|
||||
|
||||
fn handle_event(&self, event: MixedMessage) -> bool {
|
||||
self.handle_mixed_message(event)
|
||||
fn handle_event(&self, event: MixedMessage, can_gc: CanGc) -> bool {
|
||||
self.handle_mixed_message(event, can_gc)
|
||||
}
|
||||
|
||||
fn handle_worker_post_event(&self, _worker: &TrustedWorkerAddress) -> Option<AutoWorkerReset> {
|
||||
|
@ -411,7 +411,7 @@ impl ServiceWorkerGlobalScope {
|
|||
.expect("Thread spawning failed")
|
||||
}
|
||||
|
||||
fn handle_mixed_message(&self, msg: MixedMessage) -> bool {
|
||||
fn handle_mixed_message(&self, msg: MixedMessage, can_gc: CanGc) -> bool {
|
||||
match msg {
|
||||
MixedMessage::Devtools(msg) => match msg {
|
||||
DevtoolScriptControlMsg::EvaluateJS(_pipe_id, string, sender) => {
|
||||
|
@ -423,7 +423,7 @@ impl ServiceWorkerGlobalScope {
|
|||
_ => debug!("got an unusable devtools control message inside the worker!"),
|
||||
},
|
||||
MixedMessage::ServiceWorker(msg) => {
|
||||
self.handle_script_event(msg);
|
||||
self.handle_script_event(msg, can_gc);
|
||||
},
|
||||
MixedMessage::Control(ServiceWorkerControlMsg::Exit) => {
|
||||
return false;
|
||||
|
@ -437,7 +437,7 @@ impl ServiceWorkerGlobalScope {
|
|||
false
|
||||
}
|
||||
|
||||
fn handle_script_event(&self, msg: ServiceWorkerScriptMsg) {
|
||||
fn handle_script_event(&self, msg: ServiceWorkerScriptMsg, can_gc: CanGc) {
|
||||
use self::ServiceWorkerScriptMsg::*;
|
||||
|
||||
match msg {
|
||||
|
@ -453,9 +453,10 @@ impl ServiceWorkerGlobalScope {
|
|||
scope.upcast(),
|
||||
message.handle(),
|
||||
ports,
|
||||
can_gc,
|
||||
);
|
||||
} else {
|
||||
ExtendableMessageEvent::dispatch_error(target, scope.upcast());
|
||||
ExtendableMessageEvent::dispatch_error(target, scope.upcast(), can_gc);
|
||||
}
|
||||
},
|
||||
CommonWorker(WorkerScriptMsg::Common(msg)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue