CanGc fixes in components/script/dom (#33843)

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
tanishka 2024-10-15 10:15:16 +05:30 committed by GitHub
parent 1e39787573
commit 46d6c0c883
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 21 additions and 24 deletions

View file

@ -508,7 +508,7 @@ impl Animations {
elapsedTime: elapsed_time,
pseudoElement: pseudo_element,
};
TransitionEvent::new(&window, event_atom, &event_init)
TransitionEvent::new(&window, event_atom, &event_init, can_gc)
.upcast::<Event>()
.fire(node.upcast());
} else {

View file

@ -246,7 +246,7 @@ DOMInterfaces = {
},
'XMLHttpRequest': {
'canGc': ['GetResponseXML', 'Response'],
'canGc': ['Abort', 'GetResponseXML', 'Response'],
},
'XRSession': {

View file

@ -1666,6 +1666,7 @@ impl Document {
delta: WheelDelta,
client_point: Point2D<f32>,
node_address: Option<UntrustedNodeAddress>,
can_gc: CanGc,
) {
let wheel_event_type_string = "wheel".to_owned();
debug!("{}: at {:?}", wheel_event_type_string, client_point);
@ -1697,6 +1698,7 @@ impl Document {
Finite::wrap(delta.y),
Finite::wrap(delta.z),
delta.mode as u32,
can_gc,
);
let event = event.upcast::<Event>();

View file

@ -597,6 +597,7 @@ impl AsyncWGPUListener for GPUDevice {
&self.global(),
msg.into(),
GPUPipelineErrorReason::Validation,
can_gc,
))
},
Err(webgpu::Error::OutOfMemory(msg) | webgpu::Error::Internal(msg)) => promise
@ -604,6 +605,7 @@ impl AsyncWGPUListener for GPUDevice {
&self.global(),
msg.into(),
GPUPipelineErrorReason::Internal,
can_gc,
)),
},
WebGPUResponse::RenderPipeline(result) => match result {
@ -618,6 +620,7 @@ impl AsyncWGPUListener for GPUDevice {
&self.global(),
msg.into(),
GPUPipelineErrorReason::Validation,
can_gc,
))
},
Err(webgpu::Error::OutOfMemory(msg) | webgpu::Error::Internal(msg)) => promise
@ -625,6 +628,7 @@ impl AsyncWGPUListener for GPUDevice {
&self.global(),
msg.into(),
GPUPipelineErrorReason::Internal,
can_gc,
)),
},
_ => unreachable!("Wrong response received on AsyncWGPUListener for GPUDevice"),

View file

@ -49,8 +49,9 @@ impl GPUPipelineError {
global: &GlobalScope,
message: DOMString,
reason: GPUPipelineErrorReason,
can_gc: CanGc,
) -> DomRoot<Self> {
Self::new_with_proto(global, None, message, reason, CanGc::note())
Self::new_with_proto(global, None, message, reason, can_gc)
}
}

View file

@ -43,8 +43,9 @@ impl TransitionEvent {
window: &Window,
type_: Atom,
init: &TransitionEventInit,
can_gc: CanGc,
) -> DomRoot<TransitionEvent> {
Self::new_with_proto(window, None, type_, init, CanGc::note())
Self::new_with_proto(window, None, type_, init, can_gc)
}
fn new_with_proto(

View file

@ -61,20 +61,11 @@ impl WheelEvent {
delta_y: Finite<f64>,
delta_z: Finite<f64>,
delta_mode: u32,
can_gc: CanGc,
) -> DomRoot<WheelEvent> {
Self::new_with_proto(
window,
None,
type_,
can_bubble,
cancelable,
view,
detail,
delta_x,
delta_y,
delta_z,
delta_mode,
CanGc::note(),
window, None, type_, can_bubble, cancelable, view, detail, delta_x, delta_y, delta_z,
delta_mode, can_gc,
)
}

View file

@ -803,7 +803,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
}
/// <https://xhr.spec.whatwg.org/#the-abort()-method>
fn Abort(&self) {
fn Abort(&self, can_gc: CanGc) {
// Step 1
self.terminate_ongoing_fetch();
// Step 2
@ -813,10 +813,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
state == XMLHttpRequestState::Loading
{
let gen_id = self.generation_id.get();
self.process_partial_response(
XHRProgress::Errored(gen_id, Error::Abort),
CanGc::note(),
);
self.process_partial_response(XHRProgress::Errored(gen_id, Error::Abort), can_gc);
// If open was called in one of the handlers invoked by the
// above call then we should terminate the abort sequence
if self.generation_id.get() != gen_id {
@ -825,7 +822,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
}
// Step 3
if self.ready_state.get() == XMLHttpRequestState::Done {
self.change_ready_state(XMLHttpRequestState::Unsent, CanGc::note());
self.change_ready_state(XMLHttpRequestState::Unsent, can_gc);
self.response_status.set(Err(()));
self.response.borrow_mut().clear();
self.response_headers.borrow_mut().clear();

View file

@ -1614,7 +1614,7 @@ impl ScriptThread {
},
CompositorEvent::WheelEvent(delta, point, node_address) => {
self.handle_wheel_event(pipeline_id, delta, point, node_address);
self.handle_wheel_event(pipeline_id, delta, point, node_address, can_gc);
},
CompositorEvent::KeyboardEvent(key_event) => {
@ -3955,12 +3955,13 @@ impl ScriptThread {
wheel_delta: WheelDelta,
point: Point2D<f32>,
node_address: Option<UntrustedNodeAddress>,
can_gc: CanGc,
) {
let Some(document) = self.documents.borrow().find_document(pipeline_id) else {
warn!("Message sent to closed pipeline {pipeline_id}.");
return;
};
unsafe { document.handle_wheel_event(wheel_delta, point, node_address) };
unsafe { document.handle_wheel_event(wheel_delta, point, node_address, can_gc) };
}
/// Handle a "navigate an iframe" message from the constellation.