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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 11931009: Adding support for the MouseWheel event in Streams. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding more dynamic checking for which init function to use. Created 7 years, 11 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:
Download patch
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index bbc0d61bfd73d438bb971fdc7a9919c756c32e14..dfbd20e2a4ee12e8197db1d8867128312360aab5 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -26413,6 +26413,64 @@ class WebSocketEvents extends Events {
/// @domName WheelEvent
class WheelEvent extends MouseEvent {
+
+ factory WheelEvent(
+ String type,
+ Window view,
+ int wheelDeltaX,
+ int wheelDeltaY,
+ int detail,
+ int screenX,
+ int screenY,
+ int clientX,
+ int clientY,
+ int button,
+ [bool canBubble = true,
+ bool cancelable = true,
+ bool ctrlKey = false,
+ bool altKey = false,
+ bool shiftKey = false,
+ bool metaKey = false,
+ EventTarget relatedTarget = null]) {
+
+ var eventType = 'WheelEvent';
+ if (_Device.isFirefox) {
+ eventType = 'MouseScrollEvents';
+ }
+ final event = document.$dom_createEvent(eventType);
+ // Fallthrough for Dartium.
+ event.$dom_initMouseEvent(
+ type,
+ canBubble,
+ cancelable,
+ view,
+ detail,
+ screenX,
+ screenY,
+ clientX,
+ clientY,
+ ctrlKey,
+ altKey,
+ shiftKey,
+ metaKey,
+ button,
+ relatedTarget);
+ event.$dom_initWebKitWheelEvent(
+ wheelDeltaX,
+ (wheelDeltaY / 120).toInt(), // Chrome does an auto-convert to pixels.
+ view,
+ screenX,
+ screenY,
+ clientX,
+ clientY,
+ ctrlKey,
+ altKey,
+ shiftKey,
+ metaKey);
+
+ return event;
+ }
+
WheelEvent.internal() : super.internal();
@@ -26429,7 +26487,7 @@ class WheelEvent extends MouseEvent {
/** @domName WheelEvent.initWebKitWheelEvent */
- void initWebKitWheelEvent(int wheelDeltaX, int wheelDeltaY, Window view, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) native "WheelEvent_initWebKitWheelEvent_Callback";
+ void $dom_initWebKitWheelEvent(int wheelDeltaX, int wheelDeltaY, Window view, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) native "WheelEvent_initWebKitWheelEvent_Callback";
/** @domName WheelEvent.deltaX */
@@ -30338,6 +30396,23 @@ class EventStreamProvider<T extends Event> {
return new _EventStream(e, _eventType, useCapture);
}
}
+
+typedef String _EventTypeGetter(EventTarget target);
+
+/**
+ * A factory to expose DOM events as streams, where the DOM event name has to
+ * be determined on the fly (for example, mouse wheel events).
+ */
+class _CustomEventStreamProvider<T extends Event>
+ implements EventStreamProvider<T> {
+
+ final _eventTypeGetter;
+ const _CustomEventStreamProvider(this._eventTypeGetter);
+
+ Stream<T> forTarget(EventTarget e, {bool useCapture: false}) {
+ return new _EventStream(e, _eventTypeGetter(e), useCapture);
+ }
+}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Powered by Google App Engine
This is Rietveld 408576698