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, elapsedTime: elapsed_time,
pseudoElement: pseudo_element, pseudoElement: pseudo_element,
}; };
TransitionEvent::new(&window, event_atom, &event_init) TransitionEvent::new(&window, event_atom, &event_init, can_gc)
.upcast::<Event>() .upcast::<Event>()
.fire(node.upcast()); .fire(node.upcast());
} else { } else {

View file

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

View file

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

View file

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

View file

@ -49,8 +49,9 @@ impl GPUPipelineError {
global: &GlobalScope, global: &GlobalScope,
message: DOMString, message: DOMString,
reason: GPUPipelineErrorReason, reason: GPUPipelineErrorReason,
can_gc: CanGc,
) -> DomRoot<Self> { ) -> 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, window: &Window,
type_: Atom, type_: Atom,
init: &TransitionEventInit, init: &TransitionEventInit,
can_gc: CanGc,
) -> DomRoot<TransitionEvent> { ) -> 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( fn new_with_proto(

View file

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

View file

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

View file

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