Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Unified Diff: sky/specs/events.md

Issue 901493005: Specs: dartification of gestures; move GestureManager from ApplicationDocument to Application; actu… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/specs/dom.md ('k') | sky/specs/gestures.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/specs/events.md
diff --git a/sky/specs/events.md b/sky/specs/events.md
index d5571095bb99f4f343397704b0c59d897582709c..b944b792848e323faa41f4c26fa4f32659f276bf 100644
--- a/sky/specs/events.md
+++ b/sky/specs/events.md
@@ -7,9 +7,10 @@ SKY MODULE
<script>
abstract class Event<ReturnType> {
- Event({bool this.bubbles});
+ Event() { init(); }
+ void init() { }
- final bool bubbles;
+ bool get bubbles;
EventTarget _target;
EventTarget get target => _target;
@@ -20,6 +21,8 @@ abstract class Event<ReturnType> {
bool handled; // precise semantics depend on the event type, but in general, set this when you set result
ReturnType result;
+ bool resultIsCompatible(dynamic candidate) => candidate is ReturnType;
+
// TODO(ianh): abstract API for doing things at shadow tree boundaries
// TODO(ianh): do events get blocked at scope boundaries, e.g. focus events when both sides are in the scope?
// TODO(ianh): do events get retargetted, e.g. focus when leaving a custom element?
@@ -36,7 +39,7 @@ class EventTarget {
return [this];
} else {
var result = this.parentNode.getEventDispatchChain();
- result.add(this);
+ result.insert(0, this);
return result;
}
}
@@ -47,9 +50,14 @@ class EventTarget {
// note: this will throw an ExceptionListException<ExceptionListException> if any of the listeners threw
assert(event != null); // event must be non-null
event.handled = false;
+ assert(event.resultIsCompatible(defaultResult));
event.result = defaultResult;
event._target = this;
- var chain = this.getEventDispatchChain();
+ var chain;
+ if (event.bubbles)
+ chain = this.getEventDispatchChain();
+ else
+ chain = [this];
var exceptions = new ExceptionListException<ExceptionListException>();
for (var link in chain) {
try {
« no previous file with comments | « sky/specs/dom.md ('k') | sky/specs/gestures.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698