Multiple CanGc fixes in components/script/dom (#33924)

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
tanishka 2024-10-20 21:37:15 +05:30 committed by GitHub
parent ee9e1fbbd6
commit 65c866285f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 77 additions and 37 deletions

View file

@ -10,6 +10,7 @@ use crate::dom::eventtarget::EventTarget;
use crate::dom::htmlinputelement::InputActivationState; use crate::dom::htmlinputelement::InputActivationState;
use crate::dom::node::window_from_node; use crate::dom::node::window_from_node;
use crate::dom::window::ReflowReason; use crate::dom::window::ReflowReason;
use crate::script_runtime::CanGc;
/// Trait for elements with defined activation behavior /// Trait for elements with defined activation behavior
pub trait Activatable { pub trait Activatable {
@ -29,7 +30,7 @@ pub trait Activatable {
// https://dom.spec.whatwg.org/#eventtarget-activation-behavior // https://dom.spec.whatwg.org/#eventtarget-activation-behavior
// event and target are used only by HTMLAnchorElement, in the case // event and target are used only by HTMLAnchorElement, in the case
// where the target is an <img ismap> so the href gets coordinates appended // where the target is an <img ismap> so the href gets coordinates appended
fn activation_behavior(&self, event: &Event, target: &EventTarget); fn activation_behavior(&self, event: &Event, target: &EventTarget, can_gc: CanGc);
// https://html.spec.whatwg.org/multipage/#concept-selector-active // https://html.spec.whatwg.org/multipage/#concept-selector-active
fn enter_formal_activation_state(&self) { fn enter_formal_activation_state(&self) {

View file

@ -81,6 +81,7 @@ impl AudioBuffer {
length: u32, length: u32,
sample_rate: f32, sample_rate: f32,
initial_data: Option<&[Vec<f32>]>, initial_data: Option<&[Vec<f32>]>,
can_gc: CanGc,
) -> DomRoot<AudioBuffer> { ) -> DomRoot<AudioBuffer> {
Self::new_with_proto( Self::new_with_proto(
global, global,
@ -89,7 +90,7 @@ impl AudioBuffer {
length, length,
sample_rate, sample_rate,
initial_data, initial_data,
CanGc::note(), can_gc,
) )
} }

View file

@ -443,6 +443,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
number_of_channels: u32, number_of_channels: u32,
length: u32, length: u32,
sample_rate: Finite<f32>, sample_rate: Finite<f32>,
can_gc: CanGc,
) -> Fallible<DomRoot<AudioBuffer>> { ) -> Fallible<DomRoot<AudioBuffer>> {
if number_of_channels == 0 || if number_of_channels == 0 ||
number_of_channels > MAX_CHANNEL_COUNT || number_of_channels > MAX_CHANNEL_COUNT ||
@ -457,6 +458,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
length, length,
*sample_rate, *sample_rate,
None, None,
can_gc,
)) ))
} }
@ -547,7 +549,8 @@ impl BaseAudioContextMethods for BaseAudioContext {
decoded_audio.len() as u32 /* number of channels */, decoded_audio.len() as u32 /* number of channels */,
length as u32, length as u32,
this.sample_rate, this.sample_rate,
Some(decoded_audio.as_slice())); Some(decoded_audio.as_slice()),
CanGc::note());
let mut resolvers = this.decode_resolvers.borrow_mut(); let mut resolvers = this.decode_resolvers.borrow_mut();
assert!(resolvers.contains_key(&uuid_)); assert!(resolvers.contains_key(&uuid_));
let resolver = resolvers.remove(&uuid_).unwrap(); let resolver = resolvers.remove(&uuid_).unwrap();

View file

@ -25,7 +25,7 @@ DOMInterfaces = {
'BaseAudioContext': { 'BaseAudioContext': {
'inRealms': ['DecodeAudioData', 'Resume', 'ParseFromString', 'GetBounds', 'GetClientRects'], 'inRealms': ['DecodeAudioData', 'Resume', 'ParseFromString', 'GetBounds', 'GetClientRects'],
'canGc': ['CreateChannelMerger', 'CreateOscillator', 'CreateStereoPanner', 'CreateGain', 'CreateIIRFilter', 'CreateBiquadFilter', 'CreateBufferSource', 'CreateAnalyser', 'CreatePanner', 'CreateChannelSplitter'], 'canGc': ['CreateChannelMerger', 'CreateOscillator', 'CreateStereoPanner', 'CreateGain', 'CreateIIRFilter', 'CreateBiquadFilter', 'CreateBufferSource', 'CreateAnalyser', 'CreatePanner', 'CreateChannelSplitter', 'CreateBuffer'],
}, },
'Blob': { 'Blob': {
@ -109,6 +109,10 @@ DOMInterfaces = {
'weakReferenceable': True, 'weakReferenceable': True,
}, },
'EventTarget': {
'canGc': ['DispatchEvent'],
},
'File': { 'File': {
'weakReferenceable': True, 'weakReferenceable': True,
}, },
@ -144,7 +148,7 @@ DOMInterfaces = {
}, },
'HTMLElement': { 'HTMLElement': {
'canGc': ['Focus', 'Blur'], 'canGc': ['Focus', 'Blur', 'Click'],
}, },
'HTMLFieldSetElement': { 'HTMLFieldSetElement': {

View file

@ -8,6 +8,7 @@
use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::structuredclone::StructuredDataHolder; use crate::dom::bindings::structuredclone::StructuredDataHolder;
use crate::dom::globalscope::GlobalScope; use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::CanGc;
/// The key corresponding to the storage location /// The key corresponding to the storage location
/// of a serialized platform object stored in a StructuredDataHolder. /// of a serialized platform object stored in a StructuredDataHolder.
@ -27,5 +28,6 @@ pub trait Serializable: DomObject {
owner: &GlobalScope, owner: &GlobalScope,
sc_holder: &mut StructuredDataHolder, sc_holder: &mut StructuredDataHolder,
extra_data: StorageKey, extra_data: StorageKey,
can_gc: CanGc,
) -> Result<(), ()>; ) -> Result<(), ()>;
} }

View file

@ -37,7 +37,7 @@ use crate::dom::blob::Blob;
use crate::dom::globalscope::GlobalScope; use crate::dom::globalscope::GlobalScope;
use crate::dom::messageport::MessagePort; use crate::dom::messageport::MessagePort;
use crate::realms::{enter_realm, AlreadyInRealm, InRealm}; use crate::realms::{enter_realm, AlreadyInRealm, InRealm};
use crate::script_runtime::JSContext as SafeJSContext; use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
// TODO: Should we add Min and Max const to https://github.com/servo/rust-mozjs/blob/master/src/consts.rs? // TODO: Should we add Min and Max const to https://github.com/servo/rust-mozjs/blob/master/src/consts.rs?
// TODO: Determine for sure which value Min and Max should have. // TODO: Determine for sure which value Min and Max should have.
@ -57,6 +57,7 @@ unsafe fn read_blob(
owner: &GlobalScope, owner: &GlobalScope,
r: *mut JSStructuredCloneReader, r: *mut JSStructuredCloneReader,
sc_holder: &mut StructuredDataHolder, sc_holder: &mut StructuredDataHolder,
can_gc: CanGc,
) -> *mut JSObject { ) -> *mut JSObject {
let mut name_space: u32 = 0; let mut name_space: u32 = 0;
let mut index: u32 = 0; let mut index: u32 = 0;
@ -66,7 +67,7 @@ unsafe fn read_blob(
&mut index as *mut u32 &mut index as *mut u32
)); ));
let storage_key = StorageKey { index, name_space }; let storage_key = StorageKey { index, name_space };
if <Blob as Serializable>::deserialize(owner, sc_holder, storage_key).is_ok() { if <Blob as Serializable>::deserialize(owner, sc_holder, storage_key, can_gc).is_ok() {
let blobs = match sc_holder { let blobs = match sc_holder {
StructuredDataHolder::Read { blobs, .. } => blobs, StructuredDataHolder::Read { blobs, .. } => blobs,
_ => panic!("Unexpected variant of StructuredDataHolder"), _ => panic!("Unexpected variant of StructuredDataHolder"),
@ -133,6 +134,7 @@ unsafe extern "C" fn read_callback(
&GlobalScope::from_context(cx, InRealm::Already(&in_realm_proof)), &GlobalScope::from_context(cx, InRealm::Already(&in_realm_proof)),
r, r,
&mut *(closure as *mut StructuredDataHolder), &mut *(closure as *mut StructuredDataHolder),
CanGc::note(),
); );
} }
ptr::null_mut() ptr::null_mut()

View file

@ -132,6 +132,7 @@ impl Serializable for Blob {
owner: &GlobalScope, owner: &GlobalScope,
sc_holder: &mut StructuredDataHolder, sc_holder: &mut StructuredDataHolder,
storage_key: StorageKey, storage_key: StorageKey,
can_gc: CanGc,
) -> Result<(), ()> { ) -> Result<(), ()> {
// 1. Re-build the key for the storage location // 1. Re-build the key for the storage location
// of the serialized object. // of the serialized object.
@ -162,7 +163,7 @@ impl Serializable for Blob {
*blob_impls = None; *blob_impls = None;
} }
let deserialized_blob = Blob::new(owner, blob_impl, CanGc::note()); let deserialized_blob = Blob::new(owner, blob_impl, can_gc);
let blobs = blobs.get_or_insert_with(HashMap::new); let blobs = blobs.get_or_insert_with(HashMap::new);
blobs.insert(storage_key, deserialized_blob); blobs.insert(storage_key, deserialized_blob);

View file

@ -1365,6 +1365,7 @@ impl Document {
pressed_mouse_buttons, pressed_mouse_buttons,
None, None,
point_in_node, point_in_node,
can_gc,
); );
let event = event.upcast::<Event>(); let event = event.upcast::<Event>();
@ -1398,7 +1399,7 @@ impl Document {
if let MouseEventType::Click = mouse_event_type { if let MouseEventType::Click = mouse_event_type {
self.commit_focus_transaction(FocusType::Element, can_gc); self.commit_focus_transaction(FocusType::Element, can_gc);
self.maybe_fire_dblclick(client_point, node, pressed_mouse_buttons); self.maybe_fire_dblclick(client_point, node, pressed_mouse_buttons, can_gc);
} }
} }
@ -1407,6 +1408,7 @@ impl Document {
click_pos: Point2D<f32>, click_pos: Point2D<f32>,
target: &Node, target: &Node,
pressed_mouse_buttons: u16, pressed_mouse_buttons: u16,
can_gc: CanGc,
) { ) {
// https://w3c.github.io/uievents/#event-type-dblclick // https://w3c.github.io/uievents/#event-type-dblclick
let now = Instant::now(); let now = Instant::now();
@ -1449,6 +1451,7 @@ impl Document {
pressed_mouse_buttons, pressed_mouse_buttons,
None, None,
None, None,
can_gc,
); );
event.upcast::<Event>().fire(target.upcast()); event.upcast::<Event>().fire(target.upcast());
@ -1470,6 +1473,7 @@ impl Document {
can_bubble: EventBubbles, can_bubble: EventBubbles,
cancelable: EventCancelable, cancelable: EventCancelable,
pressed_mouse_buttons: u16, pressed_mouse_buttons: u16,
can_gc: CanGc,
) { ) {
let client_x = client_point.x.to_i32().unwrap_or(0); let client_x = client_point.x.to_i32().unwrap_or(0);
let client_y = client_point.y.to_i32().unwrap_or(0); let client_y = client_point.y.to_i32().unwrap_or(0);
@ -1493,6 +1497,7 @@ impl Document {
pressed_mouse_buttons, pressed_mouse_buttons,
None, None,
None, None,
can_gc,
); );
let event = mouse_event.upcast::<Event>(); let event = mouse_event.upcast::<Event>();
event.fire(target); event.fire(target);
@ -1505,6 +1510,7 @@ impl Document {
prev_mouse_over_target: &MutNullableDom<Element>, prev_mouse_over_target: &MutNullableDom<Element>,
node_address: Option<UntrustedNodeAddress>, node_address: Option<UntrustedNodeAddress>,
pressed_mouse_buttons: u16, pressed_mouse_buttons: u16,
can_gc: CanGc,
) { ) {
let maybe_new_target = node_address.and_then(|address| { let maybe_new_target = node_address.and_then(|address| {
let node = node::from_untrusted_node_address(address); let node = node::from_untrusted_node_address(address);
@ -1552,6 +1558,7 @@ impl Document {
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::Cancelable, EventCancelable::Cancelable,
pressed_mouse_buttons, pressed_mouse_buttons,
can_gc,
); );
if !old_target_is_ancestor_of_new_target { if !old_target_is_ancestor_of_new_target {
@ -1563,6 +1570,7 @@ impl Document {
moving_into, moving_into,
event_target, event_target,
pressed_mouse_buttons, pressed_mouse_buttons,
can_gc,
); );
} }
} }
@ -1586,6 +1594,7 @@ impl Document {
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::Cancelable, EventCancelable::Cancelable,
pressed_mouse_buttons, pressed_mouse_buttons,
can_gc,
); );
let moving_from = prev_mouse_over_target let moving_from = prev_mouse_over_target
@ -1598,6 +1607,7 @@ impl Document {
moving_from, moving_from,
event_target, event_target,
pressed_mouse_buttons, pressed_mouse_buttons,
can_gc,
); );
} }
@ -1610,6 +1620,7 @@ impl Document {
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::Cancelable, EventCancelable::Cancelable,
pressed_mouse_buttons, pressed_mouse_buttons,
can_gc,
); );
// If the target has changed then store the current mouse over target for next frame. // If the target has changed then store the current mouse over target for next frame.
@ -1625,6 +1636,7 @@ impl Document {
related_target: Option<DomRoot<Node>>, related_target: Option<DomRoot<Node>>,
event_target: DomRoot<Node>, event_target: DomRoot<Node>,
pressed_mouse_buttons: u16, pressed_mouse_buttons: u16,
can_gc: CanGc,
) { ) {
assert!(matches!( assert!(matches!(
event_type, event_type,
@ -1664,6 +1676,7 @@ impl Document {
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
pressed_mouse_buttons, pressed_mouse_buttons,
can_gc,
); );
} }
} }
@ -1902,7 +1915,7 @@ impl Document {
{ {
if let Some(elem) = target.downcast::<Element>() { if let Some(elem) = target.downcast::<Element>() {
elem.upcast::<Node>() elem.upcast::<Node>()
.fire_synthetic_mouse_event_not_trusted(DOMString::from("click")); .fire_synthetic_mouse_event_not_trusted(DOMString::from("click"), can_gc);
} }
} }
} }

View file

@ -168,6 +168,7 @@ impl Event {
&self, &self,
target: &EventTarget, target: &EventTarget,
legacy_target_override: bool, legacy_target_override: bool,
can_gc: CanGc,
// TODO legacy_did_output_listeners_throw_flag for indexeddb // TODO legacy_did_output_listeners_throw_flag for indexeddb
) -> EventStatus { ) -> EventStatus {
// Step 1. // Step 1.
@ -333,7 +334,7 @@ impl Event {
if self.DefaultPrevented() { if self.DefaultPrevented() {
activation_target.legacy_canceled_activation_behavior(pre_activation_result); activation_target.legacy_canceled_activation_behavior(pre_activation_result);
} else { } else {
activation_target.activation_behavior(self, target); activation_target.activation_behavior(self, target, can_gc);
} }
} }
@ -380,7 +381,7 @@ impl Event {
/// <https://html.spec.whatwg.org/multipage/#fire-a-simple-event> /// <https://html.spec.whatwg.org/multipage/#fire-a-simple-event>
pub fn fire(&self, target: &EventTarget) -> EventStatus { pub fn fire(&self, target: &EventTarget) -> EventStatus {
self.set_trusted(true); self.set_trusted(true);
target.dispatch_event(self) target.dispatch_event(self, CanGc::note())
} }
} }

View file

@ -397,8 +397,8 @@ impl EventTarget {
}) })
} }
pub fn dispatch_event(&self, event: &Event) -> EventStatus { pub fn dispatch_event(&self, event: &Event, can_gc: CanGc) -> EventStatus {
event.dispatch(self, false) event.dispatch(self, false, can_gc)
} }
pub fn remove_all_listeners(&self) { pub fn remove_all_listeners(&self) {
@ -779,12 +779,12 @@ impl EventTargetMethods for EventTarget {
} }
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent // https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
fn DispatchEvent(&self, event: &Event) -> Fallible<bool> { fn DispatchEvent(&self, event: &Event, can_gc: CanGc) -> Fallible<bool> {
if event.dispatching() || !event.initialized() { if event.dispatching() || !event.initialized() {
return Err(Error::InvalidState); return Err(Error::InvalidState);
} }
event.set_trusted(false); event.set_trusted(false);
Ok(match self.dispatch_event(event) { Ok(match self.dispatch_event(event, can_gc) {
EventStatus::Canceled => false, EventStatus::Canceled => false,
EventStatus::NotCanceled => true, EventStatus::NotCanceled => true,
}) })

View file

@ -206,7 +206,7 @@ impl GPUDevice {
}, },
can_gc, can_gc,
); );
let _ = self.eventtarget.DispatchEvent(ev.event()); let _ = self.eventtarget.DispatchEvent(ev.event(), can_gc);
} }
/// <https://gpuweb.github.io/gpuweb/#abstract-opdef-validate-texture-format-required-features> /// <https://gpuweb.github.io/gpuweb/#abstract-opdef-validate-texture-format-required-features>

View file

@ -34,6 +34,7 @@ use crate::dom::node::{document_from_node, BindContext, Node};
use crate::dom::urlhelper::UrlHelper; use crate::dom::urlhelper::UrlHelper;
use crate::dom::virtualmethods::VirtualMethods; use crate::dom::virtualmethods::VirtualMethods;
use crate::links::{follow_hyperlink, LinkRelations}; use crate::links::{follow_hyperlink, LinkRelations};
use crate::script_runtime::CanGc;
#[dom_struct] #[dom_struct]
pub struct HTMLAnchorElement { pub struct HTMLAnchorElement {
@ -593,7 +594,7 @@ impl Activatable for HTMLAnchorElement {
} }
//https://html.spec.whatwg.org/multipage/#the-a-element:activation-behaviour //https://html.spec.whatwg.org/multipage/#the-a-element:activation-behaviour
fn activation_behavior(&self, event: &Event, target: &EventTarget) { fn activation_behavior(&self, event: &Event, target: &EventTarget, _can_gc: CanGc) {
let element = self.as_element(); let element = self.as_element();
let mouse_event = event.downcast::<MouseEvent>().unwrap(); let mouse_event = event.downcast::<MouseEvent>().unwrap();
let mut ismap_suffix = None; let mut ismap_suffix = None;

View file

@ -29,6 +29,7 @@ use crate::dom::htmlelement::HTMLElement;
use crate::dom::node::{BindContext, Node}; use crate::dom::node::{BindContext, Node};
use crate::dom::virtualmethods::VirtualMethods; use crate::dom::virtualmethods::VirtualMethods;
use crate::links::{follow_hyperlink, LinkRelations}; use crate::links::{follow_hyperlink, LinkRelations};
use crate::script_runtime::CanGc;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum Area { pub enum Area {
@ -371,7 +372,7 @@ impl Activatable for HTMLAreaElement {
self.as_element().has_attribute(&local_name!("href")) self.as_element().has_attribute(&local_name!("href"))
} }
fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { fn activation_behavior(&self, _event: &Event, _target: &EventTarget, _can_gc: CanGc) {
follow_hyperlink(self.as_element(), self.relations.get(), None); follow_hyperlink(self.as_element(), self.relations.get(), None);
} }
} }

View file

@ -343,7 +343,7 @@ impl Activatable for HTMLButtonElement {
} }
// https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps // https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps
fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { fn activation_behavior(&self, _event: &Event, _target: &EventTarget, _can_gc: CanGc) {
let ty = self.button_type.get(); let ty = self.button_type.get();
match ty { match ty {
//https://html.spec.whatwg.org/multipage/#attr-button-type-submit-state //https://html.spec.whatwg.org/multipage/#attr-button-type-submit-state

View file

@ -384,7 +384,7 @@ impl HTMLElementMethods for HTMLElement {
} }
// https://html.spec.whatwg.org/multipage/#dom-click // https://html.spec.whatwg.org/multipage/#dom-click
fn Click(&self) { fn Click(&self, can_gc: CanGc) {
let element = self.as_element(); let element = self.as_element();
if element.disabled_state() { if element.disabled_state() {
return; return;
@ -395,7 +395,7 @@ impl HTMLElementMethods for HTMLElement {
element.set_click_in_progress(true); element.set_click_in_progress(true);
self.upcast::<Node>() self.upcast::<Node>()
.fire_synthetic_mouse_event_not_trusted(DOMString::from("click")); .fire_synthetic_mouse_event_not_trusted(DOMString::from("click"), can_gc);
element.set_click_in_progress(false); element.set_click_in_progress(false);
} }
@ -1139,7 +1139,7 @@ impl Activatable for HTMLElement {
} }
// Basically used to make the HTMLSummaryElement activatable (which has no IDL definition) // Basically used to make the HTMLSummaryElement activatable (which has no IDL definition)
fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { fn activation_behavior(&self, _event: &Event, _target: &EventTarget, _can_gc: CanGc) {
self.summary_activation_behavior(); self.summary_activation_behavior();
} }
} }

View file

@ -1825,7 +1825,7 @@ impl VirtualMethods for HTMLImageElement {
None => return, None => return,
}; };
if shp.hit_test(&point) { if shp.hit_test(&point) {
element.activation_behavior(event, self.upcast()); element.activation_behavior(event, self.upcast(), CanGc::note());
return; return;
} }
} }

View file

@ -2072,7 +2072,7 @@ impl HTMLInputElement {
// but we can get here from synthetic keydown events // but we can get here from synthetic keydown events
button button
.upcast::<Node>() .upcast::<Node>()
.fire_synthetic_mouse_event_not_trusted(DOMString::from("click")); .fire_synthetic_mouse_event_not_trusted(DOMString::from("click"), can_gc);
} }
}, },
None => { None => {
@ -2801,7 +2801,7 @@ impl Activatable for HTMLInputElement {
} }
// https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps // https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps
fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { fn activation_behavior(&self, _event: &Event, _target: &EventTarget, _can_gc: CanGc) {
let ty = self.input_type(); let ty = self.input_type();
match ty { match ty {
InputType::Submit => { InputType::Submit => {

View file

@ -25,6 +25,7 @@ use crate::dom::htmlelement::HTMLElement;
use crate::dom::htmlformelement::{FormControl, FormControlElementHelpers, HTMLFormElement}; use crate::dom::htmlformelement::{FormControl, FormControlElementHelpers, HTMLFormElement};
use crate::dom::node::{Node, ShadowIncluding}; use crate::dom::node::{Node, ShadowIncluding};
use crate::dom::virtualmethods::VirtualMethods; use crate::dom::virtualmethods::VirtualMethods;
use crate::script_runtime::CanGc;
#[dom_struct] #[dom_struct]
pub struct HTMLLabelElement { pub struct HTMLLabelElement {
@ -73,9 +74,9 @@ impl Activatable for HTMLLabelElement {
// at all, we are free to do an implementation-dependent thing; // at all, we are free to do an implementation-dependent thing;
// firing a click event is an example, and the precise details of that // firing a click event is an example, and the precise details of that
// click event (e.g. isTrusted) are not specified. // click event (e.g. isTrusted) are not specified.
fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { fn activation_behavior(&self, _event: &Event, _target: &EventTarget, can_gc: CanGc) {
if let Some(e) = self.GetControl() { if let Some(e) = self.GetControl() {
e.Click(); e.Click(can_gc);
} }
} }
} }

View file

@ -107,6 +107,7 @@ impl MouseEvent {
buttons: u16, buttons: u16,
related_target: Option<&EventTarget>, related_target: Option<&EventTarget>,
point_in_target: Option<Point2D<f32>>, point_in_target: Option<Point2D<f32>>,
can_gc: CanGc,
) -> DomRoot<MouseEvent> { ) -> DomRoot<MouseEvent> {
Self::new_with_proto( Self::new_with_proto(
window, window,
@ -128,7 +129,7 @@ impl MouseEvent {
buttons, buttons,
related_target, related_target,
point_in_target, point_in_target,
CanGc::note(), can_gc,
) )
} }

View file

@ -390,7 +390,7 @@ impl Node {
} }
/// <https://html.spec.whatg.org/#fire_a_synthetic_mouse_event> /// <https://html.spec.whatg.org/#fire_a_synthetic_mouse_event>
pub fn fire_synthetic_mouse_event_not_trusted(&self, name: DOMString) { pub fn fire_synthetic_mouse_event_not_trusted(&self, name: DOMString, can_gc: CanGc) {
// Spec says the choice of which global to create // Spec says the choice of which global to create
// the mouse event on is not well-defined, // the mouse event on is not well-defined,
// and refers to heycam/webidl#135 // and refers to heycam/webidl#135
@ -415,6 +415,7 @@ impl Node {
0, // buttons uninitialized (and therefore none) 0, // buttons uninitialized (and therefore none)
None, // related_target uninitialized, None, // related_target uninitialized,
None, // point_in_target uninitialized, None, // point_in_target uninitialized,
can_gc,
); );
// Step 4: TODO composed flag for shadow root // Step 4: TODO composed flag for shadow root
@ -426,7 +427,7 @@ impl Node {
mouse_event mouse_event
.upcast::<Event>() .upcast::<Event>()
.dispatch(self.upcast::<EventTarget>(), false); .dispatch(self.upcast::<EventTarget>(), false, can_gc);
} }
pub fn parent_directionality(&self) -> String { pub fn parent_directionality(&self) -> String {

View file

@ -197,7 +197,8 @@ impl OfflineAudioContextMethods for OfflineAudioContext {
this.channel_count, this.channel_count,
this.length, this.length,
*this.context.SampleRate(), *this.context.SampleRate(),
Some(processed_audio.as_slice())); Some(processed_audio.as_slice()),
CanGc::note());
(*this.pending_rendering_promise.borrow_mut()).take().unwrap().resolve_native(&buffer); (*this.pending_rendering_promise.borrow_mut()).take().unwrap().resolve_native(&buffer);
let global = &this.global(); let global = &this.global();
let window = global.as_window(); let window = global.as_window();

View file

@ -51,6 +51,7 @@ impl PromiseRejectionEvent {
cancelable: EventCancelable, cancelable: EventCancelable,
promise: Rc<Promise>, promise: Rc<Promise>,
reason: HandleValue, reason: HandleValue,
can_gc: CanGc,
) -> DomRoot<Self> { ) -> DomRoot<Self> {
Self::new_with_proto( Self::new_with_proto(
global, global,
@ -60,7 +61,7 @@ impl PromiseRejectionEvent {
cancelable, cancelable,
promise.promise_obj(), promise.promise_obj(),
reason, reason,
CanGc::note(), can_gc,
) )
} }

View file

@ -481,7 +481,7 @@ impl ServiceWorkerGlobalScope {
fn dispatch_activate(&self, can_gc: CanGc) { fn dispatch_activate(&self, can_gc: CanGc) {
let event = ExtendableEvent::new(self, atom!("activate"), false, false, can_gc); let event = ExtendableEvent::new(self, atom!("activate"), false, false, can_gc);
let event = (*event).upcast::<Event>(); let event = (*event).upcast::<Event>();
self.upcast::<EventTarget>().dispatch_event(event); self.upcast::<EventTarget>().dispatch_event(event, can_gc);
} }
} }

View file

@ -548,7 +548,7 @@ impl Window {
// see note at https://dom.spec.whatwg.org/#concept-event-dispatch step 2 // see note at https://dom.spec.whatwg.org/#concept-event-dispatch step 2
pub fn dispatch_event_with_target_override(&self, event: &Event) -> EventStatus { pub fn dispatch_event_with_target_override(&self, event: &Event) -> EventStatus {
event.dispatch(self.upcast(), true) event.dispatch(self.upcast(), true, CanGc::note())
} }
} }

View file

@ -302,7 +302,8 @@ unsafe extern "C" fn promise_rejection_tracker(
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::Cancelable, EventCancelable::Cancelable,
root_promise, root_promise,
reason.handle() reason.handle(),
CanGc::note()
); );
event.upcast::<Event>().fire(&target); event.upcast::<Event>().fire(&target);
@ -419,7 +420,8 @@ pub fn notify_about_rejected_promises(global: &GlobalScope) {
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::Cancelable, EventCancelable::Cancelable,
promise.clone(), promise.clone(),
reason.handle() reason.handle(),
CanGc::note()
); );
let event_status = event.upcast::<Event>().fire(&target); let event_status = event.upcast::<Event>().fire(&target);

View file

@ -1484,6 +1484,7 @@ impl ScriptThread {
point: Point2D<f32>, point: Point2D<f32>,
node_address: Option<UntrustedNodeAddress>, node_address: Option<UntrustedNodeAddress>,
pressed_mouse_buttons: u16, pressed_mouse_buttons: u16,
can_gc: CanGc,
) { ) {
// Get the previous target temporarily // Get the previous target temporarily
let prev_mouse_over_target = self.topmost_mouse_over_target.get(); let prev_mouse_over_target = self.topmost_mouse_over_target.get();
@ -1494,6 +1495,7 @@ impl ScriptThread {
&self.topmost_mouse_over_target, &self.topmost_mouse_over_target,
node_address, node_address,
pressed_mouse_buttons, pressed_mouse_buttons,
can_gc,
) )
} }
@ -1592,6 +1594,7 @@ impl ScriptThread {
point, point,
node_address, node_address,
pressed_mouse_buttons, pressed_mouse_buttons,
can_gc,
); );
}, },