mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Auto merge of #13397 - aochagavia:dispatch-event, r=Ms2ger
Return an enum instead of a boolean from dispatch_event Fixes #13196 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #13196. - [X] These changes do not require tests because the functionality hasn't changed <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13397) <!-- Reviewable:end -->
This commit is contained in:
commit
9b7708063a
7 changed files with 45 additions and 17 deletions
|
@ -20,6 +20,7 @@ use dom::bindings::str::DOMString;
|
|||
use dom::document::Document;
|
||||
use dom::element::{AttributeMutation, Element, ElementCreator};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventdispatcher::EventStatus;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node};
|
||||
use dom::node::{document_from_node, window_from_node};
|
||||
|
@ -488,7 +489,7 @@ impl HTMLScriptElement {
|
|||
}
|
||||
|
||||
// TODO(#12446): beforescriptexecute.
|
||||
if !self.dispatch_before_script_execute_event() {
|
||||
if self.dispatch_before_script_execute_event() == EventStatus::Canceled {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -535,7 +536,7 @@ impl HTMLScriptElement {
|
|||
window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("error"), window.r());
|
||||
}
|
||||
|
||||
pub fn dispatch_before_script_execute_event(&self) -> bool {
|
||||
pub fn dispatch_before_script_execute_event(&self) -> EventStatus {
|
||||
self.dispatch_event(atom!("beforescriptexecute"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::Cancelable)
|
||||
|
@ -606,7 +607,7 @@ impl HTMLScriptElement {
|
|||
fn dispatch_event(&self,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> bool {
|
||||
cancelable: EventCancelable) -> EventStatus {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let event = Event::new(GlobalRef::Window(window), type_, bubbles, cancelable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue