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

Side by Side Diff: tools/dom/src/WrappedEvent.dart

Issue 166213002: Version 1.2.0-dev.5.7 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/src/EventStreamProvider.dart ('k') | tools/dom/src/dart2js_DOMImplementation.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.html; 5 part of dart.html;
6 6
7 /** 7 /**
8 * Helper class to implement custom events which wrap DOM events. 8 * Helper class to implement custom events which wrap DOM events.
9 */ 9 */
10 class _WrappedEvent implements Event { 10 class _WrappedEvent implements Event {
11 final Event wrapped; 11 final Event wrapped;
12
13 /** The CSS selector involved with event delegation. */
14 String _selector;
15
12 _WrappedEvent(this.wrapped); 16 _WrappedEvent(this.wrapped);
13 17
14 bool get bubbles => wrapped.bubbles; 18 bool get bubbles => wrapped.bubbles;
15 19
16 bool get cancelable => wrapped.cancelable; 20 bool get cancelable => wrapped.cancelable;
17 21
18 DataTransfer get clipboardData => wrapped.clipboardData; 22 DataTransfer get clipboardData => wrapped.clipboardData;
19 23
20 EventTarget get currentTarget => wrapped.currentTarget; 24 EventTarget get currentTarget => wrapped.currentTarget;
21 25
(...skipping 17 matching lines...) Expand all
39 wrapped.preventDefault(); 43 wrapped.preventDefault();
40 } 44 }
41 45
42 void stopImmediatePropagation() { 46 void stopImmediatePropagation() {
43 wrapped.stopImmediatePropagation(); 47 wrapped.stopImmediatePropagation();
44 } 48 }
45 49
46 void stopPropagation() { 50 void stopPropagation() {
47 wrapped.stopPropagation(); 51 wrapped.stopPropagation();
48 } 52 }
53
54 /**
55 * A pointer to the element whose CSS selector matched within which an event
56 * was fired. If this Event was not associated with any Event delegation,
57 * accessing this value will throw an [UnsupportedError].
58 */
59 Element get matchingTarget {
60 if (_selector == null) {
61 throw new UnsupportedError('Cannot call matchingTarget if this Event did'
62 ' not arise as a result of event delegation.');
63 }
64 var currentTarget = this.currentTarget;
65 var target = this.target;
66 var matchedTarget;
67 do {
68 if (target.matches(_selector)) return target;
69 target = target.parent;
70 } while (target != null && target != currentTarget.parent);
71 throw new StateError('No selector matched for populating matchedTarget.');
72 }
73
74 /**
75 * This event's path, taking into account shadow DOM.
76 *
77 * ## Other resources
78 *
79 * * [Shadow DOM extensions to Event]
80 * (http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event) from
81 * W3C.
82 */
83 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#ex tensions-to-event
84 @Experimental()
85 List<Node> get path => wrapped.path;
86
87 dynamic get _get_currentTarget => wrapped._get_currentTarget;
88
89 dynamic get _get_target => wrapped._get_target;
49 } 90 }
OLDNEW
« no previous file with comments | « tools/dom/src/EventStreamProvider.dart ('k') | tools/dom/src/dart2js_DOMImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698