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

Unified Diff: tools/dom/templates/html/impl/impl_WheelEvent.darttemplate

Issue 1126463005: Clean up WheelEvent (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review fixes" Created 5 years, 7 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 | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate b/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
index 307d6b35783f93679ec2de1594a616c9d4246394..1fb997c524f2f6b807d1c11ba64205482c32a20e 100644
--- a/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
+++ b/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
@@ -7,80 +7,19 @@ part of $LIBRARYNAME;
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
factory WheelEvent(String type,
- {Window view, int deltaX: 0, int deltaY: 0,
+ {Window view, int deltaX: 0, int deltaY: 0, int deltaZ: 0,
+ int deltaMode: 0,
int detail: 0, int screenX: 0, int screenY: 0, int clientX: 0,
int clientY: 0, int button: 0, bool canBubble: true,
bool cancelable: true, bool ctrlKey: false, bool altKey: false,
bool shiftKey: false, bool metaKey: false, EventTarget relatedTarget}) {
-$if DART2JS
- if (view == null) {
- view = window;
- }
- var eventType = 'WheelEvent';
- if (Device.isFirefox) {
- eventType = 'MouseScrollEvents';
- }
- final event = document._createEvent(eventType);
- // If polyfilling, then flip these because we'll flip them back to match
- // the W3C standard:
- // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaY
- if (JS('bool', '#.deltaY === undefined', event)) {
- deltaX = -deltaX;
- deltaY = -deltaY;
- }
- if (event._hasInitWheelEvent) {
- var modifiers = [];
- if (ctrlKey) {
- modifiers.push('Control');
- }
- if (altKey) {
- modifiers.push('Alt');
- }
- if (shiftKey) {
- modifiers.push('Shift');
- }
- if (metaKey) {
- modifiers.push('Meta');
- }
- event._initWheelEvent(type, canBubble, cancelable, view, detail, screenX,
- screenY, clientX, clientY, button, relatedTarget, modifiers.join(' '),
- deltaX, deltaY, 0, 0);
- } else if (event._hasInitMouseScrollEvent) {
- var axis = 0;
- var detail = 0;
- if (deltaX != 0 && deltaY != 0) {
- throw new UnsupportedError(
- 'Cannot modify deltaX and deltaY simultaneously');
- }
- if (deltaY != 0) {
- detail = deltaY;
- axis = JS('int', 'MouseScrollEvent.VERTICAL_AXIS');
- } else if (deltaX != 0) {
- detail = deltaX;
- axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS');
- }
- event._initMouseScrollEvent(type, canBubble, cancelable, view, detail,
- screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
- metaKey, button, relatedTarget, axis);
- } else {
- // Chrome does an auto-convert to pixels.
- deltaY = deltaY ~/ 120;
-
- event._initMouseEvent(type, canBubble, cancelable, view, detail,
- screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
- metaKey, button, relatedTarget);
- JS('void', '#.initWebKitWheelEvent(#, #, #, #, #, #, #, #, #, #, #)',
- event, deltaX, deltaY,
- view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
- metaKey);
- }
- return event;
-$else
var options = {
'view': view,
+ 'deltaMode': deltaMode,
'deltaX': deltaX,
'deltaY': deltaY,
+ 'deltaZ': deltaZ,
'detail': detail,
'screenX': screenX,
'screenY': screenY,
@@ -95,6 +34,16 @@ $else
'metaKey': metaKey,
'relatedTarget': relatedTarget,
};
+
+$if DART2JS
+ if (view == null) {
+ view = window;
+ }
+
+ return JS('WheelEvent', 'new WheelEvent(#, #)',
+ type, convertDartToNative_Dictionary(options));
+
+$else
return _blink.BlinkWheelEvent.constructorCallback_2(type, options);
$endif
}
@@ -115,24 +64,6 @@ $if DART2JS
if (JS('bool', '#.deltaY !== undefined', this)) {
// W3C WheelEvent
return this._deltaY;
- } else if (JS('bool', '#.wheelDelta !== undefined', this)) {
- // Chrome and IE
- return -this._wheelDelta;
- } else if (JS('bool', '#.detail !== undefined', this)) {
- // Firefox
-
- // Handle DOMMouseScroll case where it uses detail and the axis to
- // differentiate.
- if (JS('bool', '#.axis == MouseScrollEvent.VERTICAL_AXIS', this)) {
- var detail = this._detail;
- // Firefox is normally the number of lines to scale (normally 3)
- // so multiply it by 40 to get pixels to move, matching IE & WebKit.
- if (detail.abs() < 100) {
- return -detail * 40;
- }
- return -detail;
- }
- return 0;
}
throw new UnsupportedError(
'deltaY is not supported');
@@ -151,26 +82,6 @@ $if DART2JS
if (JS('bool', '#.deltaX !== undefined', this)) {
// W3C WheelEvent
return this._deltaX;
- } else if (JS('bool', '#.wheelDeltaX !== undefined', this)) {
- // Chrome
- return -this._wheelDeltaX;
- } else if (JS('bool', '#.detail !== undefined', this)) {
- // Firefox and IE.
- // IE will have detail set but will not set axis.
-
- // Handle DOMMouseScroll case where it uses detail and the axis to
- // differentiate.
- if (JS('bool', '#.axis !== undefined && '
- '#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) {
- var detail = this._detail;
- // Firefox is normally the number of lines to scale (normally 3)
- // so multiply it by 40 to get pixels to move, matching IE & WebKit.
- if (detail < 100) {
- return -detail * 40;
- }
- return -detail;
- }
- return 0;
}
throw new UnsupportedError(
'deltaX is not supported');
« no previous file with comments | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698