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

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

Issue 13465021: Flipping the direction of WheelEvent.deltaX/Y to follow standards (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « sdk/lib/html/dartium/html_dartium.dart ('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 93da12737b89fb857bb4f42dff7ce764a8122475..a89b6896e909b52ec277cfa6bacbdf8aa7010d78 100644
--- a/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
+++ b/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
@@ -22,6 +22,13 @@ $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
}
final event = document.$dom_createEvent(eventType);
$if DART2JS
+ // 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) {
@@ -76,6 +83,14 @@ $endif
$!MEMBERS
$if DART2JS
+ /**
+ * The amount that is expected to scroll vertically, in units determined by
+ * [deltaMode].
+ *
+ * See also:
+ *
+ * * [W3C WheelEvent](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaY)
Andrei Mouravski 2013/04/03 15:22:00 Nit: we have been annotating these as [Foo](link.c
blois 2013/04/03 18:00:49 Done.
+ */
@DomName('WheelEvent.deltaY')
num get deltaY {
if (JS('bool', '#.deltaY !== undefined', this)) {
@@ -83,7 +98,7 @@ $if DART2JS
return this._deltaY;
} else if (JS('bool', '#.wheelDelta !== undefined', this)) {
// Chrome and IE
- return this._wheelDelta;
+ return -this._wheelDelta;
} else if (JS('bool', '#.detail !== undefined', this)) {
// Firefox
@@ -94,9 +109,9 @@ $if DART2JS
// 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 * 40;
}
- return detail;
+ return -detail;
}
return 0;
}
@@ -104,6 +119,14 @@ $if DART2JS
'deltaY is not supported');
}
+ /**
+ * The amount that is expected to scroll horizontally, in units determined by
+ * [deltaMode].
+ *
+ * See also:
+ *
+ * * [W3C WheelEvent](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaX)
+ */
@DomName('WheelEvent.deltaX')
num get deltaX {
if (JS('bool', '#.deltaX !== undefined', this)) {
@@ -111,7 +134,7 @@ $if DART2JS
return this._deltaX;
} else if (JS('bool', '#.wheelDeltaX !== undefined', this)) {
// Chrome
- return this._wheelDeltaX;
+ return -this._wheelDeltaX;
} else if (JS('bool', '#.detail !== undefined', this)) {
// Firefox and IE.
// IE will have detail set but will not set axis.
@@ -124,9 +147,9 @@ $if DART2JS
// 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 * 40;
}
- return detail;
+ return -detail;
}
return 0;
}
@@ -193,9 +216,26 @@ $if DART2JS
int deltaMode) native;
$else
+ /**
+ * The amount that is expected to scroll horizontally, in units determined by
+ * [deltaMode].
+ *
+ * See also:
+ *
+ * * [W3C WheelEvent](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaX)
+ */
@DomName('WheelEvent.deltaX')
- num get deltaX => $dom_wheelDeltaX;
+ num get deltaX => -$dom_wheelDeltaX;
+
+ /**
+ * The amount that is expected to scroll vertically, in units determined by
+ * [deltaMode].
+ *
+ * See also:
+ *
+ * * [W3C WheelEvent](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-WheelEvent-deltaY)
+ */
@DomName('WheelEvent.deltaY')
- num get deltaY => $dom_wheelDeltaY;
+ num get deltaY => -$dom_wheelDeltaY;
$endif
}
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698