More CanGc fixes: Range, Event, gpu error, Header (#33774)

* Propagate CanGc parameter in Range

Signed-off-by: webbeef <me@webbeef.org>

* Propagate CanGc parameter in gpu code and dependencies

Signed-off-by: webbeef <me@webbeef.org>

* Propagate CanGc parameter in Header and dependencies

Signed-off-by: webbeef <me@webbeef.org>

* Propagate CanGc parameter in Event and dependencies

Signed-off-by: webbeef <me@webbeef.org>

* Propagate CanGc parameter in rtcdatachannel

Signed-off-by: webbeef <me@webbeef.org>

* Propagate CanGc parameter in servoparser

Signed-off-by: webbeef <me@webbeef.org>

---------

Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
webbeef 2024-10-10 08:51:22 -07:00 committed by GitHub
parent 8c56cbdab2
commit f9a06d62a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 92 additions and 85 deletions

View file

@ -2286,6 +2286,7 @@ impl Document {
atom!("unload"), atom!("unload"),
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::Cancelable, EventCancelable::Cancelable,
CanGc::note(),
); );
event.set_trusted(true); event.set_trusted(true);
let event_target = self.window.upcast::<EventTarget>(); let event_target = self.window.upcast::<EventTarget>();
@ -2328,7 +2329,7 @@ impl Document {
} }
// https://html.spec.whatwg.org/multipage/#the-end // https://html.spec.whatwg.org/multipage/#the-end
pub fn maybe_queue_document_completion(&self) { pub fn maybe_queue_document_completion(&self, can_gc: CanGc) {
// https://html.spec.whatwg.org/multipage/#delaying-load-events-mode // https://html.spec.whatwg.org/multipage/#delaying-load-events-mode
let is_in_delaying_load_events_mode = match self.window.undiscarded_window_proxy() { let is_in_delaying_load_events_mode = match self.window.undiscarded_window_proxy() {
Some(window_proxy) => window_proxy.is_delaying_load_events_mode(), Some(window_proxy) => window_proxy.is_delaying_load_events_mode(),
@ -2378,6 +2379,7 @@ impl Document {
atom!("load"), atom!("load"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
can_gc,
); );
event.set_trusted(true); event.set_trusted(true);
@ -2658,7 +2660,7 @@ impl Document {
for iframe in self.iter_iframes() { for iframe in self.iter_iframes() {
if let Some(document) = iframe.GetContentDocument() { if let Some(document) = iframe.GetContentDocument() {
// TODO: abort the active documents of every child browsing context. // TODO: abort the active documents of every child browsing context.
document.abort(CanGc::note()); document.abort(can_gc);
// TODO: salvageable flag. // TODO: salvageable flag.
} }
} }
@ -4590,9 +4592,10 @@ impl DocumentMethods for Document {
))), ))),
// FIXME(#25136): devicemotionevent, deviceorientationevent // FIXME(#25136): devicemotionevent, deviceorientationevent
// FIXME(#7529): dragevent // FIXME(#7529): dragevent
"events" | "event" | "htmlevents" | "svgevents" => { "events" | "event" | "htmlevents" | "svgevents" => Ok(Event::new_uninitialized(
Ok(Event::new_uninitialized(self.window.upcast())) self.window.upcast(),
}, CanGc::note(),
)),
"focusevent" => Ok(DomRoot::upcast(FocusEvent::new_uninitialized(&self.window))), "focusevent" => Ok(DomRoot::upcast(FocusEvent::new_uninitialized(&self.window))),
"hashchangeevent" => Ok(DomRoot::upcast(HashChangeEvent::new_uninitialized( "hashchangeevent" => Ok(DomRoot::upcast(HashChangeEvent::new_uninitialized(
&self.window, &self.window,

View file

@ -75,8 +75,8 @@ impl Event {
} }
} }
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<Event> { pub fn new_uninitialized(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Event> {
Self::new_uninitialized_with_proto(global, None, CanGc::note()) Self::new_uninitialized_with_proto(global, None, can_gc)
} }
pub fn new_uninitialized_with_proto( pub fn new_uninitialized_with_proto(
@ -92,8 +92,9 @@ impl Event {
type_: Atom, type_: Atom,
bubbles: EventBubbles, bubbles: EventBubbles,
cancelable: EventCancelable, cancelable: EventCancelable,
can_gc: CanGc,
) -> DomRoot<Event> { ) -> DomRoot<Event> {
Self::new_with_proto(global, None, type_, bubbles, cancelable, CanGc::note()) Self::new_with_proto(global, None, type_, bubbles, cancelable, can_gc)
} }
fn new_with_proto( fn new_with_proto(

View file

@ -682,7 +682,7 @@ impl EventTarget {
bubbles: EventBubbles, bubbles: EventBubbles,
cancelable: EventCancelable, cancelable: EventCancelable,
) -> DomRoot<Event> { ) -> DomRoot<Event> {
let event = Event::new(&self.global(), name, bubbles, cancelable); let event = Event::new(&self.global(), name, bubbles, cancelable, CanGc::note());
event.fire(self); event.fire(self);
event event
} }

View file

@ -3190,14 +3190,19 @@ impl GlobalScope {
} }
} }
pub fn handle_uncaptured_gpu_error(&self, device: WebGPUDevice, error: webgpu::Error) { pub fn handle_uncaptured_gpu_error(
&self,
device: WebGPUDevice,
error: webgpu::Error,
can_gc: CanGc,
) {
if let Some(gpu_device) = self if let Some(gpu_device) = self
.gpu_devices .gpu_devices
.borrow() .borrow()
.get(&device) .get(&device)
.and_then(|device| device.root()) .and_then(|device| device.root())
{ {
gpu_device.fire_uncaptured_error(error); gpu_device.fire_uncaptured_error(error, can_gc);
} else { } else {
warn!("Recived error for lost GPUDevice!") warn!("Recived error for lost GPUDevice!")
} }

View file

@ -63,6 +63,7 @@ use crate::dom::gputexture::GPUTexture;
use crate::dom::gpuuncapturederrorevent::GPUUncapturedErrorEvent; use crate::dom::gpuuncapturederrorevent::GPUUncapturedErrorEvent;
use crate::dom::promise::Promise; use crate::dom::promise::Promise;
use crate::realms::InRealm; use crate::realms::InRealm;
use crate::script_runtime::CanGc;
#[dom_struct] #[dom_struct]
pub struct GPUDevice { pub struct GPUDevice {
@ -170,8 +171,8 @@ impl GPUDevice {
} }
} }
pub fn fire_uncaptured_error(&self, error: webgpu::Error) { pub fn fire_uncaptured_error(&self, error: webgpu::Error, can_gc: CanGc) {
let error = GPUError::from_error(&self.global(), error); let error = GPUError::from_error(&self.global(), error, can_gc);
let ev = GPUUncapturedErrorEvent::new( let ev = GPUUncapturedErrorEvent::new(
&self.global(), &self.global(),
DOMString::from("uncapturederror"), DOMString::from("uncapturederror"),
@ -566,7 +567,7 @@ impl AsyncWGPUListener for GPUDevice {
Ok(None) | Err(PopError::Lost) => promise.resolve_native(&None::<Option<GPUError>>), Ok(None) | Err(PopError::Lost) => promise.resolve_native(&None::<Option<GPUError>>),
Err(PopError::Empty) => promise.reject_error(Error::Operation), Err(PopError::Empty) => promise.reject_error(Error::Operation),
Ok(Some(error)) => { Ok(Some(error)) => {
let error = GPUError::from_error(&self.global(), error); let error = GPUError::from_error(&self.global(), error, CanGc::note());
promise.resolve_native(&error); promise.resolve_native(&error);
}, },
}, },

View file

@ -29,8 +29,8 @@ impl GPUError {
} }
#[allow(dead_code)] #[allow(dead_code)]
pub fn new(global: &GlobalScope, message: DOMString) -> DomRoot<Self> { pub fn new(global: &GlobalScope, message: DOMString, can_gc: CanGc) -> DomRoot<Self> {
Self::new_with_proto(global, None, message) Self::new_with_proto(global, None, message, can_gc)
} }
#[allow(dead_code)] #[allow(dead_code)]
@ -38,34 +38,35 @@ impl GPUError {
global: &GlobalScope, global: &GlobalScope,
proto: Option<HandleObject>, proto: Option<HandleObject>,
message: DOMString, message: DOMString,
can_gc: CanGc,
) -> DomRoot<Self> { ) -> DomRoot<Self> {
reflect_dom_object_with_proto( reflect_dom_object_with_proto(
Box::new(GPUError::new_inherited(message)), Box::new(GPUError::new_inherited(message)),
global, global,
proto, proto,
CanGc::note(), can_gc,
) )
} }
pub fn from_error(global: &GlobalScope, error: Error) -> DomRoot<Self> { pub fn from_error(global: &GlobalScope, error: Error, can_gc: CanGc) -> DomRoot<Self> {
match error { match error {
Error::Validation(msg) => DomRoot::upcast(GPUValidationError::new_with_proto( Error::Validation(msg) => DomRoot::upcast(GPUValidationError::new_with_proto(
global, global,
None, None,
DOMString::from_string(msg), DOMString::from_string(msg),
CanGc::note(), can_gc,
)), )),
Error::OutOfMemory(msg) => DomRoot::upcast(GPUOutOfMemoryError::new_with_proto( Error::OutOfMemory(msg) => DomRoot::upcast(GPUOutOfMemoryError::new_with_proto(
global, global,
None, None,
DOMString::from_string(msg), DOMString::from_string(msg),
CanGc::note(), can_gc,
)), )),
Error::Internal(msg) => DomRoot::upcast(GPUInternalError::new_with_proto( Error::Internal(msg) => DomRoot::upcast(GPUInternalError::new_with_proto(
global, global,
None, None,
DOMString::from_string(msg), DOMString::from_string(msg),
CanGc::note(), can_gc,
)), )),
} }
} }

View file

@ -52,8 +52,8 @@ impl Headers {
} }
} }
pub fn new(global: &GlobalScope) -> DomRoot<Headers> { pub fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> {
Self::new_with_proto(global, None, CanGc::note()) Self::new_with_proto(global, None, can_gc)
} }
fn new_with_proto( fn new_with_proto(
@ -287,14 +287,14 @@ impl Headers {
} }
} }
pub fn for_request(global: &GlobalScope) -> DomRoot<Headers> { pub fn for_request(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> {
let headers_for_request = Headers::new(global); let headers_for_request = Headers::new(global, can_gc);
headers_for_request.guard.set(Guard::Request); headers_for_request.guard.set(Guard::Request);
headers_for_request headers_for_request
} }
pub fn for_response(global: &GlobalScope) -> DomRoot<Headers> { pub fn for_response(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> {
let headers_for_response = Headers::new(global); let headers_for_response = Headers::new(global, can_gc);
headers_for_response.guard.set(Guard::Response); headers_for_response.guard.set(Guard::Response);
headers_for_response headers_for_response
} }

View file

@ -994,7 +994,7 @@ impl HTMLScriptElement {
// Step 2. // Step 2.
Err(e) => { Err(e) => {
warn!("error loading script {:?}", e); warn!("error loading script {:?}", e);
self.dispatch_error_event(); self.dispatch_error_event(CanGc::note());
return; return;
}, },
@ -1043,7 +1043,7 @@ impl HTMLScriptElement {
// Step 6. // Step 6.
if script.external { if script.external {
self.dispatch_load_event(); self.dispatch_load_event(CanGc::note());
} }
} }
@ -1138,19 +1138,21 @@ impl HTMLScriptElement {
.queue_simple_event(self.upcast(), atom!("error"), &window); .queue_simple_event(self.upcast(), atom!("error"), &window);
} }
pub fn dispatch_load_event(&self) { pub fn dispatch_load_event(&self, can_gc: CanGc) {
self.dispatch_event( self.dispatch_event(
atom!("load"), atom!("load"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
can_gc,
); );
} }
pub fn dispatch_error_event(&self) { pub fn dispatch_error_event(&self, can_gc: CanGc) {
self.dispatch_event( self.dispatch_event(
atom!("error"), atom!("error"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
can_gc,
); );
} }
@ -1229,9 +1231,10 @@ impl HTMLScriptElement {
type_: Atom, type_: Atom,
bubbles: EventBubbles, bubbles: EventBubbles,
cancelable: EventCancelable, cancelable: EventCancelable,
can_gc: CanGc,
) -> EventStatus { ) -> EventStatus {
let window = window_from_node(self); let window = window_from_node(self);
let event = Event::new(window.upcast(), type_, bubbles, cancelable); let event = Event::new(window.upcast(), type_, bubbles, cancelable, can_gc);
event.fire(self.upcast()) event.fire(self.upcast())
} }
} }

View file

@ -602,7 +602,7 @@ impl RangeMethods for Range {
fragment.upcast::<Node>().AppendChild(&clone)?; fragment.upcast::<Node>().AppendChild(&clone)?;
} else { } else {
// Step 14.1. // Step 14.1.
let clone = child.CloneNode(/* deep */ false, CanGc::note())?; let clone = child.CloneNode(/* deep */ false, can_gc)?;
// Step 14.2. // Step 14.2.
fragment.upcast::<Node>().AppendChild(&clone)?; fragment.upcast::<Node>().AppendChild(&clone)?;
// Step 14.3. // Step 14.3.
@ -615,7 +615,7 @@ impl RangeMethods for Range {
can_gc, can_gc,
); );
// Step 14.4. // Step 14.4.
let subfragment = subrange.CloneContents(CanGc::note())?; let subfragment = subrange.CloneContents(can_gc)?;
// Step 14.5. // Step 14.5.
clone.AppendChild(subfragment.upcast())?; clone.AppendChild(subfragment.upcast())?;
} }
@ -624,7 +624,7 @@ impl RangeMethods for Range {
// Step 15. // Step 15.
for child in contained_children { for child in contained_children {
// Step 15.1. // Step 15.1.
let clone = child.CloneNode(/* deep */ true, CanGc::note())?; let clone = child.CloneNode(/* deep */ true, can_gc)?;
// Step 15.2. // Step 15.2.
fragment.upcast::<Node>().AppendChild(&clone)?; fragment.upcast::<Node>().AppendChild(&clone)?;
} }
@ -640,20 +640,14 @@ impl RangeMethods for Range {
fragment.upcast::<Node>().AppendChild(&clone)?; fragment.upcast::<Node>().AppendChild(&clone)?;
} else { } else {
// Step 17.1. // Step 17.1.
let clone = child.CloneNode(/* deep */ false, CanGc::note())?; let clone = child.CloneNode(/* deep */ false, can_gc)?;
// Step 17.2. // Step 17.2.
fragment.upcast::<Node>().AppendChild(&clone)?; fragment.upcast::<Node>().AppendChild(&clone)?;
// Step 17.3. // Step 17.3.
let subrange = Range::new( let subrange =
&clone.owner_doc(), Range::new(&clone.owner_doc(), &child, 0, &end_node, end_offset, can_gc);
&child,
0,
&end_node,
end_offset,
CanGc::note(),
);
// Step 17.4. // Step 17.4.
let subfragment = subrange.CloneContents(CanGc::note())?; let subfragment = subrange.CloneContents(can_gc)?;
// Step 17.5. // Step 17.5.
clone.AppendChild(subfragment.upcast())?; clone.AppendChild(subfragment.upcast())?;
} }
@ -683,7 +677,7 @@ impl RangeMethods for Range {
if end_node == start_node { if end_node == start_node {
if let Some(end_data) = end_node.downcast::<CharacterData>() { if let Some(end_data) = end_node.downcast::<CharacterData>() {
// Step 4.1. // Step 4.1.
let clone = end_node.CloneNode(/* deep */ true, CanGc::note())?; let clone = end_node.CloneNode(/* deep */ true, can_gc)?;
// Step 4.2. // Step 4.2.
let text = end_data.SubstringData(start_offset, end_offset - start_offset); let text = end_data.SubstringData(start_offset, end_offset - start_offset);
clone clone
@ -727,7 +721,7 @@ impl RangeMethods for Range {
if let Some(start_data) = child.downcast::<CharacterData>() { if let Some(start_data) = child.downcast::<CharacterData>() {
assert!(child == start_node); assert!(child == start_node);
// Step 15.1. // Step 15.1.
let clone = start_node.CloneNode(/* deep */ true, CanGc::note())?; let clone = start_node.CloneNode(/* deep */ true, can_gc)?;
// Step 15.2. // Step 15.2.
let text = start_data.SubstringData(start_offset, start_node.len() - start_offset); let text = start_data.SubstringData(start_offset, start_node.len() - start_offset);
clone clone
@ -744,7 +738,7 @@ impl RangeMethods for Range {
)?; )?;
} else { } else {
// Step 16.1. // Step 16.1.
let clone = child.CloneNode(/* deep */ false, CanGc::note())?; let clone = child.CloneNode(/* deep */ false, can_gc)?;
// Step 16.2. // Step 16.2.
fragment.upcast::<Node>().AppendChild(&clone)?; fragment.upcast::<Node>().AppendChild(&clone)?;
// Step 16.3. // Step 16.3.
@ -757,7 +751,7 @@ impl RangeMethods for Range {
can_gc, can_gc,
); );
// Step 16.4. // Step 16.4.
let subfragment = subrange.ExtractContents(CanGc::note())?; let subfragment = subrange.ExtractContents(can_gc)?;
// Step 16.5. // Step 16.5.
clone.AppendChild(subfragment.upcast())?; clone.AppendChild(subfragment.upcast())?;
} }
@ -772,7 +766,7 @@ impl RangeMethods for Range {
if let Some(end_data) = child.downcast::<CharacterData>() { if let Some(end_data) = child.downcast::<CharacterData>() {
assert!(child == end_node); assert!(child == end_node);
// Step 18.1. // Step 18.1.
let clone = end_node.CloneNode(/* deep */ true, CanGc::note())?; let clone = end_node.CloneNode(/* deep */ true, can_gc)?;
// Step 18.2. // Step 18.2.
let text = end_data.SubstringData(0, end_offset); let text = end_data.SubstringData(0, end_offset);
clone clone
@ -785,20 +779,14 @@ impl RangeMethods for Range {
end_data.ReplaceData(0, end_offset, DOMString::new())?; end_data.ReplaceData(0, end_offset, DOMString::new())?;
} else { } else {
// Step 19.1. // Step 19.1.
let clone = child.CloneNode(/* deep */ false, CanGc::note())?; let clone = child.CloneNode(/* deep */ false, can_gc)?;
// Step 19.2. // Step 19.2.
fragment.upcast::<Node>().AppendChild(&clone)?; fragment.upcast::<Node>().AppendChild(&clone)?;
// Step 19.3. // Step 19.3.
let subrange = Range::new( let subrange =
&clone.owner_doc(), Range::new(&clone.owner_doc(), &child, 0, &end_node, end_offset, can_gc);
&child,
0,
&end_node,
end_offset,
CanGc::note(),
);
// Step 19.4. // Step 19.4.
let subfragment = subrange.ExtractContents(CanGc::note())?; let subfragment = subrange.ExtractContents(can_gc)?;
// Step 19.5. // Step 19.5.
clone.AppendChild(subfragment.upcast())?; clone.AppendChild(subfragment.upcast())?;
} }

View file

@ -383,7 +383,8 @@ impl RequestMethods for Request {
// Step 31 // Step 31
// "or_init" looks unclear here, but it always enters the block since r // "or_init" looks unclear here, but it always enters the block since r
// hasn't had any other way to initialize its headers // hasn't had any other way to initialize its headers
r.headers.or_init(|| Headers::for_request(&r.global())); r.headers
.or_init(|| Headers::for_request(&r.global(), CanGc::note()));
// Step 33 - but spec says this should only be when non-empty init? // Step 33 - but spec says this should only be when non-empty init?
let headers_copy = init let headers_copy = init
@ -536,7 +537,8 @@ impl RequestMethods for Request {
// https://fetch.spec.whatwg.org/#dom-request-headers // https://fetch.spec.whatwg.org/#dom-request-headers
fn Headers(&self) -> DomRoot<Headers> { fn Headers(&self) -> DomRoot<Headers> {
self.headers.or_init(|| Headers::new(&self.global())) self.headers
.or_init(|| Headers::new(&self.global(), CanGc::note()))
} }
// https://fetch.spec.whatwg.org/#dom-request-destination // https://fetch.spec.whatwg.org/#dom-request-destination

View file

@ -302,7 +302,7 @@ impl ResponseMethods for Response {
// https://fetch.spec.whatwg.org/#dom-response-headers // https://fetch.spec.whatwg.org/#dom-response-headers
fn Headers(&self) -> DomRoot<Headers> { fn Headers(&self) -> DomRoot<Headers> {
self.headers_reflector self.headers_reflector
.or_init(|| Headers::for_response(&self.global())) .or_init(|| Headers::for_response(&self.global(), CanGc::note()))
} }
// https://fetch.spec.whatwg.org/#dom-response-clone // https://fetch.spec.whatwg.org/#dom-response-clone

View file

@ -117,6 +117,7 @@ impl RTCDataChannel {
atom!("open"), atom!("open"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
CanGc::note(),
); );
event.upcast::<Event>().fire(self.upcast()); event.upcast::<Event>().fire(self.upcast());
} }
@ -127,6 +128,7 @@ impl RTCDataChannel {
atom!("close"), atom!("close"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
CanGc::note(),
); );
event.upcast::<Event>().fire(self.upcast()); event.upcast::<Event>().fire(self.upcast());
@ -134,7 +136,7 @@ impl RTCDataChannel {
.unregister_data_channel(&self.servo_media_id); .unregister_data_channel(&self.servo_media_id);
} }
pub fn on_error(&self, error: WebRtcError) { pub fn on_error(&self, error: WebRtcError, can_gc: CanGc) {
let global = self.global(); let global = self.global();
let cx = GlobalScope::get_cx(); let cx = GlobalScope::get_cx();
let _ac = JSAutoRealm::new(*cx, self.reflector().get_jsobject().get()); let _ac = JSAutoRealm::new(*cx, self.reflector().get_jsobject().get());
@ -150,7 +152,7 @@ impl RTCDataChannel {
WebRtcError::Backend(message) => DOMString::from(message), WebRtcError::Backend(message) => DOMString::from(message),
}; };
let error = RTCError::new(&global, &init, message); let error = RTCError::new(&global, &init, message);
let event = RTCErrorEvent::new(&global, atom!("error"), false, false, &error); let event = RTCErrorEvent::new(&global, atom!("error"), false, false, &error, can_gc);
event.upcast::<Event>().fire(self.upcast()); event.upcast::<Event>().fire(self.upcast());
} }
@ -201,13 +203,14 @@ impl RTCDataChannel {
} }
} }
pub fn on_state_change(&self, state: DataChannelState) { pub fn on_state_change(&self, state: DataChannelState, can_gc: CanGc) {
if let DataChannelState::Closing = state { if let DataChannelState::Closing = state {
let event = Event::new( let event = Event::new(
&self.global(), &self.global(),
atom!("closing"), atom!("closing"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
can_gc,
); );
event.upcast::<Event>().fire(self.upcast()); event.upcast::<Event>().fire(self.upcast());
}; };

View file

@ -40,16 +40,9 @@ impl RTCErrorEvent {
bubbles: bool, bubbles: bool,
cancelable: bool, cancelable: bool,
error: &RTCError, error: &RTCError,
can_gc: CanGc,
) -> DomRoot<RTCErrorEvent> { ) -> DomRoot<RTCErrorEvent> {
Self::new_with_proto( Self::new_with_proto(global, None, type_, bubbles, cancelable, error, can_gc)
global,
None,
type_,
bubbles,
cancelable,
error,
CanGc::note(),
)
} }
fn new_with_proto( fn new_with_proto(

View file

@ -279,6 +279,7 @@ impl RTCPeerConnection {
atom!("negotiationneeded"), atom!("negotiationneeded"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
CanGc::note(),
); );
event.upcast::<Event>().fire(self.upcast()); event.upcast::<Event>().fire(self.upcast());
} }
@ -335,9 +336,9 @@ impl RTCPeerConnection {
match event { match event {
DataChannelEvent::Open => channel.on_open(), DataChannelEvent::Open => channel.on_open(),
DataChannelEvent::Close => channel.on_close(), DataChannelEvent::Close => channel.on_close(),
DataChannelEvent::Error(error) => channel.on_error(error), DataChannelEvent::Error(error) => channel.on_error(error, can_gc),
DataChannelEvent::OnMessage(message) => channel.on_message(message, can_gc), DataChannelEvent::OnMessage(message) => channel.on_message(message, can_gc),
DataChannelEvent::StateChange(state) => channel.on_state_change(state), DataChannelEvent::StateChange(state) => channel.on_state_change(state, can_gc),
DataChannelEvent::NewChannel => unreachable!(), DataChannelEvent::NewChannel => unreachable!(),
} }
}, },
@ -383,6 +384,7 @@ impl RTCPeerConnection {
atom!("icegatheringstatechange"), atom!("icegatheringstatechange"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
CanGc::note(),
); );
event.upcast::<Event>().fire(self.upcast()); event.upcast::<Event>().fire(self.upcast());
@ -423,6 +425,7 @@ impl RTCPeerConnection {
atom!("iceconnectionstatechange"), atom!("iceconnectionstatechange"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
CanGc::note(),
); );
event.upcast::<Event>().fire(self.upcast()); event.upcast::<Event>().fire(self.upcast());
} }
@ -445,6 +448,7 @@ impl RTCPeerConnection {
atom!("signalingstatechange"), atom!("signalingstatechange"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
CanGc::note(),
); );
event.upcast::<Event>().fire(self.upcast()); event.upcast::<Event>().fire(self.upcast());
} }
@ -761,7 +765,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
// Step 6 // Step 6
for (_, val) in self.data_channels.borrow().iter() { for (_, val) in self.data_channels.borrow().iter() {
val.on_state_change(DataChannelState::Closed); val.on_state_change(DataChannelState::Closed, CanGc::note());
} }
// Step 7-10 // Step 7-10

View file

@ -241,7 +241,7 @@ impl ServoParser {
)), )),
ParserKind::Normal, ParserKind::Normal,
); );
parser.parse_complete_string_chunk(String::from(input), CanGc::note()); parser.parse_complete_string_chunk(String::from(input), can_gc);
// Step 14. // Step 14.
let root_element = document.GetDocumentElement().expect("no document element"); let root_element = document.GetDocumentElement().expect("no document element");
@ -637,8 +637,7 @@ impl ServoParser {
// Steps 3-12 are in another castle, namely finish_load. // Steps 3-12 are in another castle, namely finish_load.
let url = self.tokenizer.url().clone(); let url = self.tokenizer.url().clone();
self.document self.document.finish_load(LoadType::PageSource(url), can_gc);
.finish_load(LoadType::PageSource(url), CanGc::note());
} }
} }

View file

@ -1030,6 +1030,7 @@ impl XMLHttpRequest {
atom!("readystatechange"), atom!("readystatechange"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::Cancelable, EventCancelable::Cancelable,
CanGc::note(),
); );
event.fire(self.upcast()); event.fire(self.upcast());
} }
@ -1173,6 +1174,7 @@ impl XMLHttpRequest {
atom!("readystatechange"), atom!("readystatechange"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::Cancelable, EventCancelable::Cancelable,
CanGc::note(),
); );
event.fire(self.upcast()); event.fire(self.upcast());
return_if_fetch_was_terminated!(); return_if_fetch_was_terminated!();

View file

@ -2005,7 +2005,9 @@ impl ScriptThread {
FromScript(inner_msg) => self.handle_msg_from_script(inner_msg), FromScript(inner_msg) => self.handle_msg_from_script(inner_msg),
FromDevtools(inner_msg) => self.handle_msg_from_devtools(inner_msg), FromDevtools(inner_msg) => self.handle_msg_from_devtools(inner_msg),
FromImageCache(inner_msg) => self.handle_msg_from_image_cache(inner_msg), FromImageCache(inner_msg) => self.handle_msg_from_image_cache(inner_msg),
FromWebGPUServer(inner_msg) => self.handle_msg_from_webgpu_server(inner_msg), FromWebGPUServer(inner_msg) => {
self.handle_msg_from_webgpu_server(inner_msg, can_gc)
},
} }
None None
@ -2025,7 +2027,7 @@ impl ScriptThread {
let mut docs = self.docs_with_no_blocking_loads.borrow_mut(); let mut docs = self.docs_with_no_blocking_loads.borrow_mut();
for document in docs.iter() { for document in docs.iter() {
let _realm = enter_realm(&**document); let _realm = enter_realm(&**document);
document.maybe_queue_document_completion(); document.maybe_queue_document_completion(can_gc);
// Document load is a rendering opportunity. // Document load is a rendering opportunity.
ScriptThread::note_rendering_opportunity(document.window().pipeline_id()); ScriptThread::note_rendering_opportunity(document.window().pipeline_id());
@ -2473,7 +2475,7 @@ impl ScriptThread {
window.layout_mut().set_epoch_paint_time(epoch, time); window.layout_mut().set_epoch_paint_time(epoch, time);
} }
fn handle_msg_from_webgpu_server(&self, msg: WebGPUMsg) { fn handle_msg_from_webgpu_server(&self, msg: WebGPUMsg, can_gc: CanGc) {
match msg { match msg {
WebGPUMsg::FreeAdapter(id) => self.gpu_id_hub.free_adapter_id(id), WebGPUMsg::FreeAdapter(id) => self.gpu_id_hub.free_adapter_id(id),
WebGPUMsg::FreeDevice { WebGPUMsg::FreeDevice {
@ -2518,7 +2520,7 @@ impl ScriptThread {
} => { } => {
let global = self.documents.borrow().find_global(pipeline_id).unwrap(); let global = self.documents.borrow().find_global(pipeline_id).unwrap();
let _ac = enter_realm(&*global); let _ac = enter_realm(&*global);
global.handle_uncaptured_gpu_error(device, error); global.handle_uncaptured_gpu_error(device, error, can_gc);
}, },
_ => {}, _ => {},
} }