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

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

Issue 22305005: Make includeAncestors match a separate method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
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 html; 5 part of html;
6 6
7 /** 7 /**
8 * Adapter for exposing DOM events as Dart streams. 8 * Adapter for exposing DOM events as Dart streams.
9 */ 9 */
10 class _EventStream<T extends Event> extends Stream<T> { 10 class _EventStream<T extends Event> extends Stream<T> {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 /** 45 /**
46 * Adapter for exposing DOM Element events as streams, while also allowing 46 * Adapter for exposing DOM Element events as streams, while also allowing
47 * event delegation. 47 * event delegation.
48 */ 48 */
49 class _ElementEventStreamImpl<T extends Event> extends _EventStream<T> 49 class _ElementEventStreamImpl<T extends Event> extends _EventStream<T>
50 implements ElementStream<T> { 50 implements ElementStream<T> {
51 _ElementEventStreamImpl(target, eventType, useCapture) : 51 _ElementEventStreamImpl(target, eventType, useCapture) :
52 super(target, eventType, useCapture); 52 super(target, eventType, useCapture);
53 53
54 Stream<T> matches(String selector) => 54 Stream<T> matches(String selector) =>
55 this.where((event) => event.target.matches(selector, true)); 55 this.where((event) => event.target.matchesWithAncestors(selector));
56 } 56 }
57 57
58 /** 58 /**
59 * Adapter for exposing events on a collection of DOM Elements as streams, 59 * Adapter for exposing events on a collection of DOM Elements as streams,
60 * while also allowing event delegation. 60 * while also allowing event delegation.
61 */ 61 */
62 class _ElementListEventStreamImpl<T extends Event> extends Stream<T> 62 class _ElementListEventStreamImpl<T extends Event> extends Stream<T>
63 implements ElementStream<T> { 63 implements ElementStream<T> {
64 final _StreamPool _pool; 64 final _StreamPool _pool;
65 Stream<T> _stream; 65 Stream<T> _stream;
66 66
67 _ElementListEventStreamImpl(targetList, eventType, useCapture) : 67 _ElementListEventStreamImpl(targetList, eventType, useCapture) :
68 _pool = new _StreamPool.broadcast() { 68 _pool = new _StreamPool.broadcast() {
69 for (Element target in targetList) { 69 for (Element target in targetList) {
70 var stream = new _EventStream(target, eventType, useCapture); 70 var stream = new _EventStream(target, eventType, useCapture);
71 _pool.add(stream); 71 _pool.add(stream);
72 } 72 }
73 _stream = _pool.stream; 73 _stream = _pool.stream;
74 } 74 }
75 75
76 Stream<T> matches(String selector) => 76 Stream<T> matches(String selector) =>
77 this.where((event) => event.target.matches(selector, true)); 77 this.where((event) => event.target.matchesWIthAncestors(selector));
78 78
79 // Delegate all regular Stream behavor to our wrapped Stream. 79 // Delegate all regular Stream behavor to our wrapped Stream.
80 StreamSubscription<T> listen(void onData(T event), 80 StreamSubscription<T> listen(void onData(T event),
81 { void onError(error), 81 { void onError(error),
82 void onDone(), 82 void onDone(),
83 bool cancelOnError}) => 83 bool cancelOnError}) =>
84 _stream.listen(onData, onError: onError, onDone: onDone, 84 _stream.listen(onData, onError: onError, onDone: onDone,
85 cancelOnError: cancelOnError); 85 cancelOnError: cancelOnError);
86 Stream<T> asBroadcastStream({void onListen(StreamSubscription subscription), 86 Stream<T> asBroadcastStream({void onListen(StreamSubscription subscription),
87 void onCancel(StreamSubscription subscription)}) 87 void onCancel(StreamSubscription subscription)})
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 ElementStream<T> _forElementList(ElementList e, 322 ElementStream<T> _forElementList(ElementList e,
323 {bool useCapture: false}) { 323 {bool useCapture: false}) {
324 return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture); 324 return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture);
325 } 325 }
326 326
327 String getEventType(EventTarget target) { 327 String getEventType(EventTarget target) {
328 return _eventTypeGetter(target); 328 return _eventTypeGetter(target);
329 } 329 }
330 } 330 }
OLDNEW
« no previous file with comments | « tools/dom/scripts/htmlrenamer.py ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698