Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReturn an enum instead of a boolean from dispatch_event #13397
Conversation
highfive
commented
Sep 23, 2016
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @emilio (or someone else) soon. |
highfive
commented
Sep 23, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Sep 23, 2016
|
An unresolved question is whether |
|
There is something wrong with the (Windows, GNU) build, but it seems unrelated to this PR |
|
r? @Ms2ger |
| @@ -103,10 +103,15 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve | |||
| } | |||
| } | |||
|
|
|||
| pub enum EventStatus { | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Sep 23, 2016
Member
You can derive PartialEq here so that you don't need if let to match for it.
This comment has been minimized.
This comment has been minimized.
aochagavia
Sep 24, 2016
Author
Contributor
I actually like if let, but if you think it is necessary I could change the code to use ==
This comment has been minimized.
This comment has been minimized.
|
Looking good, just needs a few small changes. |
| @@ -103,10 +103,15 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve | |||
| } | |||
| } | |||
|
|
|||
| pub enum EventStatus { | |||
This comment has been minimized.
This comment has been minimized.
| // Step 13. | ||
| !event.DefaultPrevented() | ||
| // Step 14. | ||
| match event.DefaultPrevented() { |
This comment has been minimized.
This comment has been minimized.
| @@ -560,7 +560,10 @@ impl EventTargetMethods for EventTarget { | |||
| return Err(Error::InvalidState); | |||
| } | |||
| event.set_trusted(false); | |||
| Ok(self.dispatch_event(event)) | |||
| match self.dispatch_event(event) { | |||
This comment has been minimized.
This comment has been minimized.
|
@Ms2ger Thanks for your feedback! I have pushed the changes. |
| @@ -153,6 +154,14 @@ impl Event { | |||
| self.cancelable.set(cancelable); | |||
| } | |||
|
|
|||
| pub fn status(&self) -> EventStatus | |||
| { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| let event_status = event.upcast::<Event>().fire(self.upcast::<EventTarget>()); | ||
|
|
||
| // Step 15 | ||
| if EventStatus::NotCanceled == event_status { |
This comment has been minimized.
This comment has been minimized.
Ms2ger
Sep 26, 2016
Contributor
If you want to swap around the left-hand and right-hand sides of these comparisons, I think that would read better. r+ either way, if you fix the other comment below.
|
@Ms2ger I pushed new changes, including swapping the comparisons. |
|
Thanks a lot! @bors-servo r+ |
|
|
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 -->
|
|
aochagavia commentedSep 23, 2016
•
edited by larsbergstrom
Fixes #13196
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is