cangc fixes in several files + event.rs + rtcpeerconnection.rs (#34002)

Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
chickenleaf 2024-10-25 18:14:15 +05:30 committed by GitHub
parent 3b5dc069ae
commit 7ad8822d94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 166 additions and 132 deletions

View file

@ -510,7 +510,7 @@ impl Animations {
};
TransitionEvent::new(&window, event_atom, &event_init, can_gc)
.upcast::<Event>()
.fire(node.upcast());
.fire(node.upcast(), can_gc);
} else {
let event_init = AnimationEventInit {
parent,
@ -520,7 +520,7 @@ impl Animations {
};
AnimationEvent::new(&window, event_atom, &event_init, can_gc)
.upcast::<Event>()
.fire(node.upcast());
.fire(node.upcast(), can_gc);
}
}

View file

@ -190,6 +190,7 @@ pub fn handle_get_attribute_style(
pipeline: PipelineId,
node_id: String,
reply: IpcSender<Option<Vec<NodeStyle>>>,
can_gc: CanGc,
) {
let node = match find_node_by_unique_id(documents, pipeline, &node_id) {
None => return reply.send(None).unwrap(),
@ -206,7 +207,7 @@ pub fn handle_get_attribute_style(
let name = style.Item(i);
NodeStyle {
name: name.to_string(),
value: style.GetPropertyValue(name.clone()).to_string(),
value: style.GetPropertyValue(name.clone(), can_gc).to_string(),
priority: style.GetPropertyPriority(name).to_string(),
}
})
@ -223,6 +224,7 @@ pub fn handle_get_stylesheet_style(
selector: String,
stylesheet: usize,
reply: IpcSender<Option<Vec<NodeStyle>>>,
can_gc: CanGc,
) {
let msg = (|| {
let node = find_node_by_unique_id(documents, pipeline, &node_id)?;
@ -248,7 +250,7 @@ pub fn handle_get_stylesheet_style(
let name = style.Item(i);
NodeStyle {
name: name.to_string(),
value: style.GetPropertyValue(name.clone()).to_string(),
value: style.GetPropertyValue(name.clone(), can_gc).to_string(),
priority: style.GetPropertyPriority(name).to_string(),
}
})
@ -303,6 +305,7 @@ pub fn handle_get_computed_style(
pipeline: PipelineId,
node_id: String,
reply: IpcSender<Option<Vec<NodeStyle>>>,
can_gc: CanGc,
) {
let node = match find_node_by_unique_id(documents, pipeline, &node_id) {
None => return reply.send(None).unwrap(),
@ -320,7 +323,9 @@ pub fn handle_get_computed_style(
let name = computed_style.Item(i);
NodeStyle {
name: name.to_string(),
value: computed_style.GetPropertyValue(name.clone()).to_string(),
value: computed_style
.GetPropertyValue(name.clone(), can_gc)
.to_string(),
priority: computed_style.GetPropertyPriority(name).to_string(),
}
})
@ -435,6 +440,7 @@ pub fn handle_modify_rule(
pipeline: PipelineId,
node_id: String,
modifications: Vec<RuleModification>,
can_gc: CanGc,
) {
let Some(document) = documents.find_document(pipeline) else {
return warn!("Document for pipeline id {} is not found", &pipeline);
@ -458,6 +464,7 @@ pub fn handle_modify_rule(
modification.name.into(),
modification.value.into(),
modification.priority.into(),
can_gc,
);
}
}

View file

@ -71,7 +71,7 @@ DOMInterfaces = {
},
'CSSStyleDeclaration': {
'canGc': ['RemoveProperty', 'SetCssText']
'canGc': ['RemoveProperty', 'SetCssText', 'GetPropertyValue', 'SetProperty', 'CssFloat', 'SetCssFloat']
},
'CanvasGradient': {
@ -136,7 +136,7 @@ DOMInterfaces = {
},
'Element': {
'canGc': ['SetInnerHTML', 'SetOuterHTML', 'InsertAdjacentHTML', 'GetClientRects', 'GetBoundingClientRect', 'InsertAdjacentText', 'ToggleAttribute', 'SetAttribute', 'SetAttributeNS', "SetId","SetClassName","Prepend","Append","ReplaceChildren","Before","After","ReplaceWith", 'SetRole', 'SetAriaAtomic', 'SetAriaAutoComplete', 'SetAriaBrailleLabel', 'SetAriaBrailleRoleDescription', 'SetAriaBusy', 'SetAriaChecked', 'SetAriaColCount', 'SetAriaColIndex', 'SetAriaColIndexText', 'SetAriaColSpan', 'SetAriaCurrent', 'SetAriaDescription', 'SetAriaDisabled', 'SetAriaExpanded', 'SetAriaHasPopup', 'SetAriaHidden', 'SetAriaInvalid', 'SetAriaKeyShortcuts', 'SetAriaLabel', 'SetAriaLevel', 'SetAriaLive', 'SetAriaModal', 'SetAriaMultiLine', 'SetAriaMultiSelectable', 'SetAriaOrientation', 'SetAriaPlaceholder', 'SetAriaPosInSet', 'SetAriaPressed','SetAriaReadOnly', 'SetAriaRelevant', 'SetAriaRequired', 'SetAriaRoleDescription', 'SetAriaRowCount', 'SetAriaRowIndex', 'SetAriaRowIndexText', 'SetAriaRowSpan', 'SetAriaSelected', 'SetAriaSetSize','SetAriaSort', 'SetAriaValueMax', 'SetAriaValueMin', 'SetAriaValueNow', 'SetAriaValueText', 'SetScrollTop', 'SetScrollLeft', 'Scroll', 'Scroll_', 'ScrollBy', 'ScrollBy_', 'ScrollWidth', 'ScrollHeight', 'ScrollTop', 'ScrollLeft', 'ClientTop', 'ClientLeft', 'ClientWidth', 'ClientHeight', 'RequestFullscreen'],
'canGc': ['SetInnerHTML', 'SetOuterHTML', 'InsertAdjacentHTML', 'GetClientRects', 'GetBoundingClientRect', 'InsertAdjacentText', 'ToggleAttribute', 'SetAttribute', 'SetAttributeNS', 'SetId','SetClassName','Prepend','Append','ReplaceChildren','Before','After','ReplaceWith', 'SetRole', 'SetAriaAtomic', 'SetAriaAutoComplete', 'SetAriaBrailleLabel', 'SetAriaBrailleRoleDescription', 'SetAriaBusy', 'SetAriaChecked', 'SetAriaColCount', 'SetAriaColIndex', 'SetAriaColIndexText', 'SetAriaColSpan', 'SetAriaCurrent', 'SetAriaDescription', 'SetAriaDisabled', 'SetAriaExpanded', 'SetAriaHasPopup', 'SetAriaHidden', 'SetAriaInvalid', 'SetAriaKeyShortcuts', 'SetAriaLabel', 'SetAriaLevel', 'SetAriaLive', 'SetAriaModal', 'SetAriaMultiLine', 'SetAriaMultiSelectable', 'SetAriaOrientation', 'SetAriaPlaceholder', 'SetAriaPosInSet', 'SetAriaPressed','SetAriaReadOnly', 'SetAriaRelevant', 'SetAriaRequired', 'SetAriaRoleDescription', 'SetAriaRowCount', 'SetAriaRowIndex', 'SetAriaRowIndexText', 'SetAriaRowSpan', 'SetAriaSelected', 'SetAriaSetSize','SetAriaSort', 'SetAriaValueMax', 'SetAriaValueMin', 'SetAriaValueNow', 'SetAriaValueText', 'SetScrollTop', 'SetScrollLeft', 'Scroll', 'Scroll_', 'ScrollBy', 'ScrollBy_', 'ScrollWidth', 'ScrollHeight', 'ScrollTop', 'ScrollLeft', 'ClientTop', 'ClientLeft', 'ClientWidth', 'ClientHeight', 'RequestFullscreen'],
},
'ElementInternals': {
@ -212,7 +212,7 @@ DOMInterfaces = {
},
'HTMLElement': {
'canGc': ['Focus', 'Blur', 'Click', 'SetInnerText', 'SetOuterText', "SetTranslate", 'SetAutofocus', 'GetOffsetParent', 'OffsetTop', 'OffsetLeft', 'OffsetWidth', 'OffsetHeight', 'InnerText', 'GetOuterText'],
'canGc': ['Focus', 'Blur', 'Click', 'SetInnerText', 'SetOuterText', "SetTranslate", 'SetAutofocus', 'GetOffsetParent', 'OffsetTop', 'OffsetLeft', 'OffsetWidth', 'OffsetHeight', 'InnerText', 'GetOuterText', 'GetOnerror', 'GetOnload', 'GetOnblur', 'GetOnfocus', 'GetOnresize', 'GetOnscroll'],
},
'HTMLFieldSetElement': {

View file

@ -192,14 +192,14 @@ macro_rules! css_properties(
$id.enabled_for_all_content(),
"Someone forgot a #[Pref] annotation"
);
self.get_property_value($id)
self.get_property_value($id, CanGc::note())
}
fn $setter(&self, value: DOMString) -> ErrorResult {
debug_assert!(
$id.enabled_for_all_content(),
"Someone forgot a #[Pref] annotation"
);
self.set_property($id, value, DOMString::new())
self.set_property($id, value, DOMString::new(), CanGc::note())
}
)*
);
@ -263,10 +263,10 @@ impl CSSStyleDeclaration {
}
}
fn get_property_value(&self, id: PropertyId) -> DOMString {
fn get_property_value(&self, id: PropertyId, can_gc: CanGc) -> DOMString {
if self.readonly {
// Readonly style declarations are used for getComputedStyle.
return self.get_computed_style(id, CanGc::note());
return self.get_computed_style(id, can_gc);
}
let mut string = String::new();
@ -278,7 +278,13 @@ impl CSSStyleDeclaration {
DOMString::from(string)
}
fn set_property(&self, id: PropertyId, value: DOMString, priority: DOMString) -> ErrorResult {
fn set_property(
&self,
id: PropertyId,
value: DOMString,
priority: DOMString,
can_gc: CanGc,
) -> ErrorResult {
// Step 1
if self.readonly {
return Err(Error::NoModificationAllowed);
@ -344,7 +350,7 @@ impl CSSStyleDeclaration {
Ok(())
},
CanGc::note(),
can_gc,
)
}
}
@ -394,12 +400,12 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
fn GetPropertyValue(&self, property: DOMString) -> DOMString {
fn GetPropertyValue(&self, property: DOMString, can_gc: CanGc) -> DOMString {
let id = match PropertyId::parse_enabled_for_all_content(&property) {
Ok(id) => id,
Err(..) => return DOMString::new(),
};
self.get_property_value(id)
self.get_property_value(id, can_gc)
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
@ -429,13 +435,14 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
property: DOMString,
value: DOMString,
priority: DOMString,
can_gc: CanGc,
) -> ErrorResult {
// Step 3
let id = match PropertyId::parse_enabled_for_all_content(&property) {
Ok(id) => id,
Err(..) => return Ok(()),
};
self.set_property(id, value, priority)
self.set_property(id, value, priority, can_gc)
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
@ -464,16 +471,17 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
fn CssFloat(&self) -> DOMString {
self.get_property_value(PropertyId::NonCustom(LonghandId::Float.into()))
fn CssFloat(&self, can_gc: CanGc) -> DOMString {
self.get_property_value(PropertyId::NonCustom(LonghandId::Float.into()), can_gc)
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
fn SetCssFloat(&self, value: DOMString) -> ErrorResult {
fn SetCssFloat(&self, value: DOMString, can_gc: CanGc) -> ErrorResult {
self.set_property(
PropertyId::NonCustom(LonghandId::Float.into()),
value,
DOMString::new(),
can_gc,
)
}

View file

@ -587,7 +587,7 @@ impl DedicatedWorkerGlobalScope {
CanGc::note(),
);
let event_status =
event.upcast::<Event>().fire(worker.upcast::<EventTarget>());
event.upcast::<Event>().fire(worker.upcast::<EventTarget>(), CanGc::note());
// Step 2.
if event_status == EventStatus::NotCanceled {

View file

@ -1382,7 +1382,7 @@ impl Document {
match mouse_event_type {
MouseEventType::Click => {
el.set_click_in_progress(true);
event.fire(node.upcast());
event.fire(node.upcast(), can_gc);
el.set_click_in_progress(false);
},
MouseEventType::MouseDown => {
@ -1391,7 +1391,7 @@ impl Document {
}
let target = node.upcast();
event.fire(target);
event.fire(target, can_gc);
},
MouseEventType::MouseUp => {
if let Some(a) = activatable {
@ -1399,7 +1399,7 @@ impl Document {
}
let target = node.upcast();
event.fire(target);
event.fire(target, can_gc);
},
}
@ -1459,7 +1459,7 @@ impl Document {
None,
can_gc,
);
event.upcast::<Event>().fire(target.upcast());
event.upcast::<Event>().fire(target.upcast(), can_gc);
// When a double click occurs, self.last_click_info is left as None so that a
// third sequential click will not cause another double click.
@ -1507,7 +1507,7 @@ impl Document {
can_gc,
);
let event = mouse_event.upcast::<Event>();
event.fire(target);
event.fire(target, can_gc);
}
#[allow(unsafe_code)]
@ -1733,7 +1733,7 @@ impl Document {
event.set_trusted(true);
let target = node.upcast();
event.fire(target);
event.fire(target, can_gc);
}
#[allow(unsafe_code)]
@ -1743,6 +1743,7 @@ impl Document {
touch_id: TouchId,
point: Point2D<f32>,
node_address: Option<UntrustedNodeAddress>,
can_gc: CanGc,
) -> TouchEventResult {
let TouchId(identifier) = touch_id;
@ -1835,7 +1836,7 @@ impl Document {
false,
);
let event = event.upcast::<Event>();
let result = event.fire(&target);
let result = event.fire(&target, can_gc);
match result {
EventStatus::Canceled => TouchEventResult::Processed(false),
@ -1876,7 +1877,7 @@ impl Document {
can_gc,
);
let event = keyevent.upcast::<Event>();
event.fire(target);
event.fire(target, can_gc);
let mut cancel_state = event.get_cancel_state();
// https://w3c.github.io/uievents/#keys-cancelable-keys
@ -1904,7 +1905,7 @@ impl Document {
can_gc,
);
let ev = event.upcast::<Event>();
ev.fire(target);
ev.fire(target, can_gc);
cancel_state = ev.get_cancel_state();
}
@ -1966,7 +1967,7 @@ impl Document {
can_gc,
);
let event = compositionevent.upcast::<Event>();
event.fire(target);
event.fire(target, can_gc);
}
// https://dom.spec.whatwg.org/#converting-nodes-into-a-node
@ -2907,7 +2908,7 @@ impl Document {
let event = event.upcast::<Event>();
event.set_trusted(true);
let target = node.upcast();
event.fire(target);
event.fire(target, can_gc);
}
/// <https://html.spec.whatwg.org/multipage/#cookie-averse-document-object>

View file

@ -381,9 +381,9 @@ impl Event {
}
/// <https://html.spec.whatwg.org/multipage/#fire-a-simple-event>
pub fn fire(&self, target: &EventTarget) -> EventStatus {
pub fn fire(&self, target: &EventTarget, can_gc: CanGc) -> EventStatus {
self.set_trusted(true);
target.dispatch_event(self, CanGc::note())
target.dispatch_event(self, can_gc)
}
}

View file

@ -263,7 +263,7 @@ impl EventSourceContext {
task!(dispatch_the_event_source_event: move || {
let event_source = event_source.root();
if event_source.ready_state.get() != ReadyState::Closed {
event.root().upcast::<Event>().fire(event_source.upcast());
event.root().upcast::<Event>().fire(event_source.upcast(), CanGc::note());
}
}),
&global,

View file

@ -708,7 +708,7 @@ impl EventTarget {
can_gc: CanGc,
) -> DomRoot<Event> {
let event = Event::new(&self.global(), name, bubbles, cancelable, can_gc);
event.fire(self);
event.fire(self, can_gc);
event
}
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener

View file

@ -140,7 +140,9 @@ impl ExtendableMessageEvent {
ports,
can_gc,
);
Extendablemessageevent.upcast::<Event>().fire(target);
Extendablemessageevent
.upcast::<Event>()
.fire(target, can_gc);
}
pub fn dispatch_error(target: &EventTarget, scope: &GlobalScope, can_gc: CanGc) {
@ -156,7 +158,7 @@ impl ExtendableMessageEvent {
init.ports.clone(),
can_gc,
);
ExtendableMsgEvent.upcast::<Event>().fire(target);
ExtendableMsgEvent.upcast::<Event>().fire(target, can_gc);
}
}

View file

@ -425,7 +425,7 @@ impl FileReader {
total.unwrap_or(0),
can_gc,
);
progressevent.upcast::<Event>().fire(self.upcast());
progressevent.upcast::<Event>().fire(self.upcast(), can_gc);
}
fn terminate_ongoing_reading(&self) {

View file

@ -24,16 +24,16 @@ pub struct FontFaceSet {
}
impl FontFaceSet {
pub fn new_inherited(global: &GlobalScope) -> Self {
pub fn new_inherited(global: &GlobalScope, can_gc: CanGc) -> Self {
FontFaceSet {
target: EventTarget::new_inherited(),
promise: Promise::new(global, CanGc::note()),
promise: Promise::new(global, can_gc),
}
}
pub fn new(global: &GlobalScope, proto: Option<HandleObject>, can_gc: CanGc) -> DomRoot<Self> {
reflect_dom_object_with_proto(
Box::new(FontFaceSet::new_inherited(global)),
Box::new(FontFaceSet::new_inherited(global, can_gc)),
global,
proto,
can_gc,

View file

@ -249,7 +249,7 @@ impl Gamepad {
let event = GamepadEvent::new_with_type(&self.global(), event_type, self, can_gc);
event
.upcast::<Event>()
.fire(self.global().as_window().upcast::<EventTarget>());
.fire(self.global().as_window().upcast::<EventTarget>(), can_gc);
}
/// Initialize the number of axes in the "standard" gamepad mapping.

View file

@ -2478,7 +2478,9 @@ impl GlobalScope {
);
// Step 7.
let event_status = event.upcast::<Event>().fire(self.upcast::<EventTarget>());
let event_status = event
.upcast::<Event>()
.fire(self.upcast::<EventTarget>(), can_gc);
// Step 8.
self.in_error_reporting_mode.set(false);

View file

@ -156,7 +156,7 @@ impl History {
);
event
.upcast::<Event>()
.fire(self.window.upcast::<EventTarget>());
.fire(self.window.upcast::<EventTarget>(), can_gc);
}
}

View file

@ -181,7 +181,7 @@ impl HTMLElementMethods for HTMLElement {
}
// https://html.spec.whatwg.org/multipage/#handler-onerror
fn GetOnerror(&self) -> Option<Rc<OnErrorEventHandlerNonNull>> {
fn GetOnerror(&self, can_gc: CanGc) -> Option<Rc<OnErrorEventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
@ -191,7 +191,7 @@ impl HTMLElementMethods for HTMLElement {
}
} else {
self.upcast::<EventTarget>()
.get_event_handler_common("error", CanGc::note())
.get_event_handler_common("error", can_gc)
}
}
@ -210,7 +210,7 @@ impl HTMLElementMethods for HTMLElement {
}
// https://html.spec.whatwg.org/multipage/#handler-onload
fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
fn GetOnload(&self, can_gc: CanGc) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
@ -220,7 +220,7 @@ impl HTMLElementMethods for HTMLElement {
}
} else {
self.upcast::<EventTarget>()
.get_event_handler_common("load", CanGc::note())
.get_event_handler_common("load", can_gc)
}
}
@ -238,7 +238,7 @@ impl HTMLElementMethods for HTMLElement {
}
// https://html.spec.whatwg.org/multipage/#handler-onblur
fn GetOnblur(&self) -> Option<Rc<EventHandlerNonNull>> {
fn GetOnblur(&self, can_gc: CanGc) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
@ -248,7 +248,7 @@ impl HTMLElementMethods for HTMLElement {
}
} else {
self.upcast::<EventTarget>()
.get_event_handler_common("blur", CanGc::note())
.get_event_handler_common("blur", can_gc)
}
}
@ -266,7 +266,7 @@ impl HTMLElementMethods for HTMLElement {
}
// https://html.spec.whatwg.org/multipage/#handler-onfocus
fn GetOnfocus(&self) -> Option<Rc<EventHandlerNonNull>> {
fn GetOnfocus(&self, can_gc: CanGc) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
@ -276,7 +276,7 @@ impl HTMLElementMethods for HTMLElement {
}
} else {
self.upcast::<EventTarget>()
.get_event_handler_common("focus", CanGc::note())
.get_event_handler_common("focus", can_gc)
}
}
@ -294,7 +294,7 @@ impl HTMLElementMethods for HTMLElement {
}
// https://html.spec.whatwg.org/multipage/#handler-onresize
fn GetOnresize(&self) -> Option<Rc<EventHandlerNonNull>> {
fn GetOnresize(&self, can_gc: CanGc) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
@ -304,7 +304,7 @@ impl HTMLElementMethods for HTMLElement {
}
} else {
self.upcast::<EventTarget>()
.get_event_handler_common("resize", CanGc::note())
.get_event_handler_common("resize", can_gc)
}
}
@ -322,7 +322,7 @@ impl HTMLElementMethods for HTMLElement {
}
// https://html.spec.whatwg.org/multipage/#handler-onscroll
fn GetOnscroll(&self) -> Option<Rc<EventHandlerNonNull>> {
fn GetOnscroll(&self, can_gc: CanGc) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
@ -332,7 +332,7 @@ impl HTMLElementMethods for HTMLElement {
}
} else {
self.upcast::<EventTarget>()
.get_event_handler_common("scroll", CanGc::note())
.get_event_handler_common("scroll", can_gc)
}
}

View file

@ -764,7 +764,7 @@ impl HTMLFormElement {
can_gc,
);
let event = event.upcast::<Event>();
event.fire(self.upcast::<EventTarget>());
event.fire(self.upcast::<EventTarget>(), can_gc);
// Step 6.6
self.firing_submission_events.set(false);
@ -1223,7 +1223,9 @@ impl HTMLFormElement {
can_gc,
);
event.upcast::<Event>().fire(self.upcast::<EventTarget>());
event
.upcast::<Event>()
.fire(self.upcast::<EventTarget>(), can_gc);
// Step 8
self.constructing_entry_list.set(false);

View file

@ -1640,7 +1640,9 @@ impl HTMLMediaElement {
can_gc,
);
event.upcast::<Event>().fire(self.upcast::<EventTarget>());
event
.upcast::<Event>()
.fire(self.upcast::<EventTarget>(), can_gc);
}
}
@ -1695,7 +1697,9 @@ impl HTMLMediaElement {
can_gc,
);
event.upcast::<Event>().fire(self.upcast::<EventTarget>());
event
.upcast::<Event>()
.fire(self.upcast::<EventTarget>(), can_gc);
}
}

View file

@ -1227,7 +1227,7 @@ impl HTMLScriptElement {
) -> EventStatus {
let window = window_from_node(self);
let event = Event::new(window.upcast(), type_, bubbles, cancelable, can_gc);
event.fire(self.upcast())
event.fire(self.upcast(), can_gc)
}
}

View file

@ -219,7 +219,7 @@ impl MessageEvent {
ports,
can_gc,
);
messageevent.upcast::<Event>().fire(target);
messageevent.upcast::<Event>().fire(target, can_gc);
}
pub fn dispatch_error(target: &EventTarget, scope: &GlobalScope, can_gc: CanGc) {
@ -236,7 +236,7 @@ impl MessageEvent {
init.ports.clone(),
can_gc,
);
messageevent.upcast::<Event>().fire(target);
messageevent.upcast::<Event>().fire(target, can_gc);
}
}

View file

@ -207,7 +207,7 @@ impl OfflineAudioContextMethods for OfflineAudioContext {
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable,
&buffer, CanGc::note());
event.upcast::<Event>().fire(this.upcast());
event.upcast::<Event>().fire(this.upcast(), CanGc::note());
}),
&canceller,
);

View file

@ -77,7 +77,7 @@ impl PopStateEvent {
) {
let event =
PopStateEvent::new(window, None, atom!("popstate"), false, false, state, can_gc);
event.upcast::<Event>().fire(target);
event.upcast::<Event>().fire(target, can_gc);
}
}

View file

@ -119,7 +119,7 @@ impl RTCDataChannel {
EventCancelable::NotCancelable,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
pub fn on_close(&self, can_gc: CanGc) {
@ -130,7 +130,7 @@ impl RTCDataChannel {
EventCancelable::NotCancelable,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
self.peer_connection
.unregister_data_channel(&self.servo_media_id);
@ -153,7 +153,7 @@ impl RTCDataChannel {
};
let error = RTCError::new(&global, &init, message, can_gc);
let event = RTCErrorEvent::new(&global, atom!("error"), false, false, &error, can_gc);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
#[allow(unsafe_code)]
@ -213,7 +213,7 @@ impl RTCDataChannel {
EventCancelable::NotCancelable,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
};
self.ready_state.set(state.into());
}

View file

@ -101,7 +101,7 @@ impl WebRtcSignaller for RTCSignaller {
let _ = self.task_source.queue_with_canceller(
task!(on_negotiation_needed: move || {
let this = this.root();
this.on_negotiation_needed();
this.on_negotiation_needed(CanGc::note());
}),
&self.canceller,
);
@ -123,7 +123,7 @@ impl WebRtcSignaller for RTCSignaller {
let _ = self.task_source.queue_with_canceller(
task!(update_ice_connection_state: move || {
let this = this.root();
this.update_ice_connection_state(state);
this.update_ice_connection_state(state, CanGc::note());
}),
&self.canceller,
);
@ -134,7 +134,7 @@ impl WebRtcSignaller for RTCSignaller {
let _ = self.task_source.queue_with_canceller(
task!(update_signaling_state: move || {
let this = this.root();
this.update_signaling_state(state);
this.update_signaling_state(state, CanGc::note());
}),
&self.canceller,
);
@ -146,7 +146,7 @@ impl WebRtcSignaller for RTCSignaller {
let _ = self.task_source.queue_with_canceller(
task!(on_add_stream: move || {
let this = this.root();
this.on_add_stream(id, ty);
this.on_add_stream(id, ty, CanGc::note());
}),
&self.canceller,
);
@ -269,10 +269,10 @@ impl RTCPeerConnection {
true,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
fn on_negotiation_needed(&self) {
fn on_negotiation_needed(&self, can_gc: CanGc) {
if self.closed.get() {
return;
}
@ -281,25 +281,19 @@ impl RTCPeerConnection {
atom!("negotiationneeded"),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable,
CanGc::note(),
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
fn on_add_stream(&self, id: MediaStreamId, ty: MediaStreamType) {
fn on_add_stream(&self, id: MediaStreamId, ty: MediaStreamType, can_gc: CanGc) {
if self.closed.get() {
return;
}
let track = MediaStreamTrack::new(&self.global(), id, ty);
let event = RTCTrackEvent::new(
&self.global(),
atom!("track"),
false,
false,
&track,
CanGc::note(),
);
event.upcast::<Event>().fire(self.upcast());
let event =
RTCTrackEvent::new(&self.global(), atom!("track"), false, false, &track, can_gc);
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
fn on_data_channel_event(
@ -330,7 +324,7 @@ impl RTCPeerConnection {
&channel,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
},
_ => {
let channel = if let Some(channel) = self.data_channels.borrow().get(&channel_id) {
@ -394,9 +388,9 @@ impl RTCPeerConnection {
atom!("icegatheringstatechange"),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable,
CanGc::note(),
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
// step 6
if state == RTCIceGatheringState::Complete {
@ -408,12 +402,12 @@ impl RTCPeerConnection {
true,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
}
/// <https://www.w3.org/TR/webrtc/#update-ice-connection-state>
fn update_ice_connection_state(&self, state: IceConnectionState) {
fn update_ice_connection_state(&self, state: IceConnectionState, can_gc: CanGc) {
// step 1
if self.closed.get() {
return;
@ -436,12 +430,12 @@ impl RTCPeerConnection {
atom!("iceconnectionstatechange"),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable,
CanGc::note(),
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
fn update_signaling_state(&self, state: SignalingState) {
fn update_signaling_state(&self, state: SignalingState, can_gc: CanGc) {
if self.closed.get() {
return;
}
@ -459,9 +453,9 @@ impl RTCPeerConnection {
atom!("signalingstatechange"),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable,
CanGc::note(),
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
fn create_offer(&self) {

View file

@ -225,7 +225,7 @@ impl Storage {
Some(&this),
CanGc::note()
);
event.upcast::<Event>().fire(global.upcast());
event.upcast::<Event>().fire(global.upcast(), CanGc::note());
}),
global.upcast(),
)

View file

@ -87,7 +87,7 @@ impl TextTrackList {
CanGc::note()
);
event.upcast::<Event>().fire(this.upcast::<EventTarget>());
event.upcast::<Event>().fire(this.upcast::<EventTarget>(), CanGc::note());
}
}),
canceller,

View file

@ -304,10 +304,10 @@ impl WebGLRenderingContext {
);
match canvas {
HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(canvas) => {
event.upcast::<Event>().fire(canvas.upcast());
event.upcast::<Event>().fire(canvas.upcast(), can_gc);
},
HTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(canvas) => {
event.upcast::<Event>().fire(canvas.upcast());
event.upcast::<Event>().fire(canvas.upcast(), can_gc);
},
}
None

View file

@ -541,7 +541,9 @@ impl TaskOnce for CloseTask {
reason,
CanGc::note(),
);
close_event.upcast::<Event>().fire(ws.upcast());
close_event
.upcast::<Event>()
.fire(ws.upcast(), CanGc::note());
}
}

View file

@ -2294,7 +2294,7 @@ impl Window {
old_url,
new_url,
CanGc::note());
event.upcast::<Event>().fire(this.upcast::<EventTarget>());
event.upcast::<Event>().fire(this.upcast::<EventTarget>(), CanGc::note());
});
// FIXME(nox): Why are errors silenced here?
let _ = self.script_chan.send(CommonScriptMsg::Task(
@ -2497,7 +2497,9 @@ impl Window {
mql.Matches(),
can_gc,
);
event.upcast::<Event>().fire(mql.upcast::<EventTarget>());
event
.upcast::<Event>()
.fire(mql.upcast::<EventTarget>(), can_gc);
}
}

View file

@ -1023,7 +1023,7 @@ impl XMLHttpRequest {
EventCancelable::Cancelable,
can_gc,
);
event.fire(self.upcast());
event.fire(self.upcast(), can_gc);
}
}
@ -1172,7 +1172,7 @@ impl XMLHttpRequest {
EventCancelable::Cancelable,
can_gc,
);
event.fire(self.upcast());
event.fire(self.upcast(), can_gc);
return_if_fetch_was_terminated!();
self.dispatch_response_progress_event(atom!("progress"), can_gc);
}
@ -1272,7 +1272,7 @@ impl XMLHttpRequest {
} else {
self.upcast()
};
progressevent.upcast::<Event>().fire(target);
progressevent.upcast::<Event>().fire(target, can_gc);
}
fn dispatch_upload_progress_event(

View file

@ -65,7 +65,7 @@ impl XRInputSourceArray {
&[],
can_gc,
);
event.upcast::<Event>().fire(session.upcast());
event.upcast::<Event>().fire(session.upcast(), can_gc);
}
pub fn remove_input_source(&self, session: &XRSession, id: InputId, can_gc: CanGc) {
@ -88,7 +88,7 @@ impl XRInputSourceArray {
can_gc,
);
self.input_sources.borrow_mut().retain(|i| i.id() != id);
event.upcast::<Event>().fire(session.upcast());
event.upcast::<Event>().fire(session.upcast(), can_gc);
}
pub fn add_remove_input_source(
@ -124,7 +124,7 @@ impl XRInputSourceArray {
removed,
can_gc,
);
event.upcast::<Event>().fire(session.upcast());
event.upcast::<Event>().fire(session.upcast(), can_gc);
}
pub fn find(&self, id: InputId) -> Option<DomRoot<XRInputSource>> {

View file

@ -299,7 +299,7 @@ impl XRSession {
// Step 7
let event =
XRSessionEvent::new(&self.global(), atom!("end"), false, false, self, can_gc);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
},
XREvent::Select(input, kind, ty, frame) => {
use servo_atoms::Atom;
@ -323,7 +323,7 @@ impl XRSession {
&source,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
} else {
if ty == SelectEvent::Select {
let event = XRInputSourceEvent::new(
@ -335,7 +335,7 @@ impl XRSession {
&source,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
let event = XRInputSourceEvent::new(
&self.global(),
@ -346,7 +346,7 @@ impl XRSession {
&source,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
frame.set_active(false);
}
@ -366,7 +366,7 @@ impl XRSession {
self,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
// The page may be visible again, dirty the layers
// This also wakes up the event loop if necessary
self.dirty_layers();
@ -411,7 +411,7 @@ impl XRSession {
Some(&*offset),
can_gc,
);
event.upcast::<Event>().fire(space.upcast());
event.upcast::<Event>().fire(space.upcast(), can_gc);
});
},
}
@ -615,7 +615,7 @@ impl XRSession {
self,
can_gc,
);
event.upcast::<Event>().fire(self.upcast());
event.upcast::<Event>().fire(self.upcast(), can_gc);
}
}

View file

@ -306,7 +306,7 @@ unsafe extern "C" fn promise_rejection_tracker(
CanGc::note()
);
event.upcast::<Event>().fire(&target);
event.upcast::<Event>().fire(&target, CanGc::note());
}),
global.upcast(),
).unwrap();
@ -424,7 +424,7 @@ pub fn notify_about_rejected_promises(global: &GlobalScope) {
CanGc::note()
);
let event_status = event.upcast::<Event>().fire(&target);
let event_status = event.upcast::<Event>().fire(&target, CanGc::note());
// Step 4-3.
if event_status == EventStatus::Canceled {

View file

@ -1605,6 +1605,7 @@ impl ScriptThread {
identifier,
point,
node_address,
can_gc,
);
match (event_type, touch_result) {
(TouchEventType::Down, TouchEventResult::Processed(handled)) => {
@ -2592,7 +2593,7 @@ impl ScriptThread {
devtools::handle_get_children(&documents, id, node_id, reply)
},
DevtoolScriptControlMsg::GetAttributeStyle(id, node_id, reply) => {
devtools::handle_get_attribute_style(&documents, id, node_id, reply)
devtools::handle_get_attribute_style(&documents, id, node_id, reply, can_gc)
},
DevtoolScriptControlMsg::GetStylesheetStyle(
id,
@ -2601,13 +2602,13 @@ impl ScriptThread {
stylesheet,
reply,
) => devtools::handle_get_stylesheet_style(
&documents, id, node_id, selector, stylesheet, reply,
&documents, id, node_id, selector, stylesheet, reply, can_gc,
),
DevtoolScriptControlMsg::GetSelectors(id, node_id, reply) => {
devtools::handle_get_selectors(&documents, id, node_id, reply)
},
DevtoolScriptControlMsg::GetComputedStyle(id, node_id, reply) => {
devtools::handle_get_computed_style(&documents, id, node_id, reply)
devtools::handle_get_computed_style(&documents, id, node_id, reply, can_gc)
},
DevtoolScriptControlMsg::GetLayout(id, node_id, reply) => {
devtools::handle_get_layout(&documents, id, node_id, reply, can_gc)
@ -2616,7 +2617,7 @@ impl ScriptThread {
devtools::handle_modify_attribute(&documents, id, node_id, modifications, can_gc)
},
DevtoolScriptControlMsg::ModifyRule(id, node_id, modifications) => {
devtools::handle_modify_rule(&documents, id, node_id, modifications)
devtools::handle_modify_rule(&documents, id, node_id, modifications, can_gc)
},
DevtoolScriptControlMsg::WantsLiveNotifications(id, to_send) => match documents
.find_window(id)
@ -2843,7 +2844,14 @@ impl ScriptThread {
)
},
WebDriverScriptCommand::GetElementCSS(node_id, name, reply) => {
webdriver_handlers::handle_get_css(&documents, pipeline_id, node_id, name, reply)
webdriver_handlers::handle_get_css(
&documents,
pipeline_id,
node_id,
name,
reply,
can_gc,
)
},
WebDriverScriptCommand::GetElementRect(node_id, reply) => {
webdriver_handlers::handle_get_rect(&documents, pipeline_id, node_id, reply, can_gc)
@ -3963,6 +3971,7 @@ impl ScriptThread {
identifier: TouchId,
point: Point2D<f32>,
node_address: Option<UntrustedNodeAddress>,
can_gc: CanGc,
) -> TouchEventResult {
let document = match self.documents.borrow().find_document(pipeline_id) {
Some(document) => document,
@ -3971,7 +3980,7 @@ impl ScriptThread {
return TouchEventResult::Processed(true);
},
};
unsafe { document.handle_touch_event(event_type, identifier, point, node_address) }
unsafe { document.handle_touch_event(event_type, identifier, point, node_address, can_gc) }
}
fn handle_wheel_event(
@ -4087,7 +4096,7 @@ impl ScriptThread {
0i32,
can_gc,
);
uievent.upcast::<Event>().fire(window.upcast());
uievent.upcast::<Event>().fire(window.upcast(), can_gc);
}
}

View file

@ -115,7 +115,7 @@ impl CSPViolationReporter {
can_gc,
);
event.upcast::<Event>().fire(&target);
event.upcast::<Event>().fire(&target, can_gc);
}
/// <https://w3c.github.io/webappsec-csp/#strip-url-for-use-in-reports>

View file

@ -93,7 +93,7 @@ impl OneshotTimerCallback {
match self {
OneshotTimerCallback::XhrTimeout(callback) => callback.invoke(can_gc),
OneshotTimerCallback::EventSourceTimeout(callback) => callback.invoke(),
OneshotTimerCallback::JsTimer(task) => task.invoke(this, js_timers),
OneshotTimerCallback::JsTimer(task) => task.invoke(this, js_timers, can_gc),
OneshotTimerCallback::TestBindingCallback(callback) => callback.invoke(),
OneshotTimerCallback::FakeRequestAnimationFrame(callback) => callback.invoke(can_gc),
OneshotTimerCallback::RefreshRedirectDue(callback) => callback.invoke(can_gc),
@ -537,7 +537,7 @@ fn clamp_duration(nesting_level: u32, unclamped: Duration) -> Duration {
impl JsTimerTask {
// see https://html.spec.whatwg.org/multipage/#timer-initialisation-steps
pub fn invoke<T: DomObject>(self, this: &T, timers: &JsTimers) {
pub fn invoke<T: DomObject>(self, this: &T, timers: &JsTimers, can_gc: CanGc) {
// step 4.1 can be ignored, because we proactively prevent execution
// of this task when its scheduled execution is canceled.
@ -558,7 +558,7 @@ impl JsTimerTask {
rval.handle_mut(),
ScriptFetchOptions::default_classic_script(&global),
global.api_base_url(),
CanGc::note(),
can_gc,
);
},
InternalTimerCallback::FunctionTimerCallback(ref function, ref arguments) => {

View file

@ -1044,6 +1044,7 @@ pub fn handle_get_css(
node_id: String,
name: String,
reply: IpcSender<Result<String, ErrorStatus>>,
can_gc: CanGc,
) {
reply
.send(
@ -1053,7 +1054,7 @@ pub fn handle_get_css(
String::from(
window
.GetComputedStyle(element, None)
.GetPropertyValue(DOMString::from(name)),
.GetPropertyValue(DOMString::from(name), can_gc),
)
}),
)