mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
refactor: add CanGc as argument to Promise::reject_error (#35646)
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
This commit is contained in:
parent
c844ed232a
commit
38b71087bd
43 changed files with 323 additions and 249 deletions
|
@ -132,7 +132,7 @@ impl GPUMethods<crate::DomTypeHolder> for GPU {
|
|||
))
|
||||
.is_err()
|
||||
{
|
||||
promise.reject_error(Error::Operation);
|
||||
promise.reject_error(Error::Operation, can_gc);
|
||||
}
|
||||
promise
|
||||
}
|
||||
|
|
|
@ -122,10 +122,10 @@ impl GPUAdapterMethods<crate::DomTypeHolder> for GPUAdapter {
|
|||
if let Some(feature) = gpu_to_wgt_feature(ext) {
|
||||
required_features.insert(feature);
|
||||
} else {
|
||||
promise.reject_error(Error::Type(format!(
|
||||
"{} is not supported feature",
|
||||
ext.as_str()
|
||||
)));
|
||||
promise.reject_error(
|
||||
Error::Type(format!("{} is not supported feature", ext.as_str())),
|
||||
can_gc,
|
||||
);
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ impl GPUAdapterMethods<crate::DomTypeHolder> for GPUAdapter {
|
|||
for (limit, value) in (*limits).iter() {
|
||||
if !set_limit(&mut required_limits, limit.as_ref(), *value) {
|
||||
warn!("Unknown GPUDevice limit: {limit}");
|
||||
promise.reject_error(Error::Operation);
|
||||
promise.reject_error(Error::Operation, can_gc);
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ impl GPUAdapterMethods<crate::DomTypeHolder> for GPUAdapter {
|
|||
})
|
||||
.is_err()
|
||||
{
|
||||
promise.reject_error(Error::Operation);
|
||||
promise.reject_error(Error::Operation, can_gc);
|
||||
}
|
||||
// Step 5
|
||||
promise
|
||||
|
@ -225,12 +225,13 @@ impl AsyncWGPUListener for GPUAdapter {
|
|||
promise.resolve_native(&device, can_gc);
|
||||
},
|
||||
WebGPUResponse::Device((_, _, Err(RequestDeviceError::UnsupportedFeature(f)))) => {
|
||||
promise.reject_error(Error::Type(
|
||||
RequestDeviceError::UnsupportedFeature(f).to_string(),
|
||||
))
|
||||
promise.reject_error(
|
||||
Error::Type(RequestDeviceError::UnsupportedFeature(f).to_string()),
|
||||
can_gc,
|
||||
)
|
||||
},
|
||||
WebGPUResponse::Device((_, _, Err(RequestDeviceError::LimitsExceeded(_)))) => {
|
||||
promise.reject_error(Error::Operation)
|
||||
promise.reject_error(Error::Operation, can_gc)
|
||||
},
|
||||
WebGPUResponse::Device((device_id, queue_id, Err(e))) => {
|
||||
let device = GPUDevice::new(
|
||||
|
|
|
@ -193,7 +193,7 @@ impl GPUBufferMethods<crate::DomTypeHolder> for GPUBuffer {
|
|||
fn Unmap(&self) {
|
||||
// Step 1
|
||||
if let Some(promise) = self.pending_map.borrow_mut().take() {
|
||||
promise.reject_error(Error::Abort);
|
||||
promise.reject_error(Error::Abort, CanGc::note());
|
||||
}
|
||||
// Step 2
|
||||
let mut mapping = self.mapping.borrow_mut().take();
|
||||
|
@ -251,7 +251,7 @@ impl GPUBufferMethods<crate::DomTypeHolder> for GPUBuffer {
|
|||
let promise = Promise::new_in_current_realm(comp, can_gc);
|
||||
// Step 2
|
||||
if self.pending_map.borrow().is_some() {
|
||||
promise.reject_error(Error::Operation);
|
||||
promise.reject_error(Error::Operation, can_gc);
|
||||
return promise;
|
||||
}
|
||||
// Step 4
|
||||
|
@ -265,7 +265,7 @@ impl GPUBufferMethods<crate::DomTypeHolder> for GPUBuffer {
|
|||
.dispatch_error(webgpu::Error::Validation(String::from(
|
||||
"Invalid MapModeFlags",
|
||||
)));
|
||||
self.map_failure(&promise);
|
||||
self.map_failure(&promise, can_gc);
|
||||
return promise;
|
||||
},
|
||||
};
|
||||
|
@ -283,7 +283,7 @@ impl GPUBufferMethods<crate::DomTypeHolder> for GPUBuffer {
|
|||
"Failed to send BufferMapAsync ({:?}) ({})",
|
||||
self.buffer.0, e
|
||||
);
|
||||
self.map_failure(&promise);
|
||||
self.map_failure(&promise, can_gc);
|
||||
return promise;
|
||||
}
|
||||
// Step 6
|
||||
|
@ -361,7 +361,7 @@ impl GPUBufferMethods<crate::DomTypeHolder> for GPUBuffer {
|
|||
}
|
||||
|
||||
impl GPUBuffer {
|
||||
fn map_failure(&self, p: &Rc<Promise>) {
|
||||
fn map_failure(&self, p: &Rc<Promise>, can_gc: CanGc) {
|
||||
let mut pending_map = self.pending_map.borrow_mut();
|
||||
// Step 1
|
||||
if pending_map.as_ref() != Some(p) {
|
||||
|
@ -374,9 +374,9 @@ impl GPUBuffer {
|
|||
pending_map.take();
|
||||
// Step 4
|
||||
if self.device.is_lost() {
|
||||
p.reject_error(Error::Abort);
|
||||
p.reject_error(Error::Abort, can_gc);
|
||||
} else {
|
||||
p.reject_error(Error::Operation);
|
||||
p.reject_error(Error::Operation, can_gc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,7 +404,7 @@ impl GPUBuffer {
|
|||
match mapping {
|
||||
Err(error) => {
|
||||
*pending_map = None;
|
||||
p.reject_error(error.clone());
|
||||
p.reject_error(error.clone(), can_gc);
|
||||
},
|
||||
Ok(mut mapping) => {
|
||||
// Step 5
|
||||
|
@ -426,7 +426,7 @@ impl AsyncWGPUListener for GPUBuffer {
|
|||
WebGPUResponse::BufferMapAsync(Ok(mapping)) => {
|
||||
self.map_success(promise, mapping, can_gc)
|
||||
},
|
||||
WebGPUResponse::BufferMapAsync(Err(_)) => self.map_failure(promise),
|
||||
WebGPUResponse::BufferMapAsync(Err(_)) => self.map_failure(promise, can_gc),
|
||||
_ => unreachable!("Wrong response received on AsyncWGPUListener for GPUBuffer"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -588,7 +588,7 @@ impl AsyncWGPUListener for GPUDevice {
|
|||
Ok(None) | Err(PopError::Lost) => {
|
||||
promise.resolve_native(&None::<Option<GPUError>>, can_gc)
|
||||
},
|
||||
Err(PopError::Empty) => promise.reject_error(Error::Operation),
|
||||
Err(PopError::Empty) => promise.reject_error(Error::Operation, can_gc),
|
||||
Ok(Some(error)) => {
|
||||
let error = GPUError::from_error(&self.global(), error, can_gc);
|
||||
promise.resolve_native(&error, can_gc);
|
||||
|
|
|
@ -228,7 +228,7 @@ impl AsyncWGPUListener for GPUQueue {
|
|||
},
|
||||
_ => {
|
||||
warn!("GPUQueue received wrong WebGPUResponse");
|
||||
promise.reject_error(Error::Operation);
|
||||
promise.reject_error(Error::Operation, can_gc);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue