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

Side by Side Diff: tools/dom/templates/html/impl/impl_WheelEvent.darttemplate

Issue 13567002: Revert "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, 8 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
8 8
9 factory WheelEvent(String type, 9 factory WheelEvent(String type,
10 {Window view, int deltaX: 0, int deltaY: 0, 10 {Window view, int deltaX: 0, int deltaY: 0,
11 int detail: 0, int screenX: 0, int screenY: 0, int clientX: 0, 11 int detail: 0, int screenX: 0, int screenY: 0, int clientX: 0,
12 int clientY: 0, int button: 0, bool canBubble: true, 12 int clientY: 0, int button: 0, bool canBubble: true,
13 bool cancelable: true, bool ctrlKey: false, bool altKey: false, 13 bool cancelable: true, bool ctrlKey: false, bool altKey: false,
14 bool shiftKey: false, bool metaKey: false, EventTarget relatedTarget}) { 14 bool shiftKey: false, bool metaKey: false, EventTarget relatedTarget}) {
15 15
16 if (view == null) { 16 if (view == null) {
17 view = window; 17 view = window;
18 } 18 }
19 var eventType = 'WheelEvent'; 19 var eventType = 'WheelEvent';
20 if (Device.isFirefox) { 20 if (Device.isFirefox) {
21 eventType = 'MouseScrollEvents'; 21 eventType = 'MouseScrollEvents';
22 } 22 }
23 final event = document.$dom_createEvent(eventType); 23 final event = document.$dom_createEvent(eventType);
24 $if DART2JS 24 $if DART2JS
25 // If polyfilling, then flip these because we'll flip them back to match
26 // the W3C standard:
27 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#ev ents-WheelEvent-deltaY
28 if (JS('bool', '#.deltaY === undefined', event)) {
29 deltaX = -deltaX;
30 deltaY = -deltaY;
31 }
32 if (event._hasInitWheelEvent) { 25 if (event._hasInitWheelEvent) {
33 var modifiers = []; 26 var modifiers = [];
34 if (ctrlKey) { 27 if (ctrlKey) {
35 modifiers.push('Control'); 28 modifiers.push('Control');
36 } 29 }
37 if (altKey) { 30 if (altKey) {
38 modifiers.push('Alt'); 31 modifiers.push('Alt');
39 } 32 }
40 if (shiftKey) { 33 if (shiftKey) {
41 modifiers.push('Shift'); 34 modifiers.push('Shift');
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 $if DART2JS 69 $if DART2JS
77 } 70 }
78 $endif 71 $endif
79 72
80 return event; 73 return event;
81 } 74 }
82 75
83 $!MEMBERS 76 $!MEMBERS
84 77
85 $if DART2JS 78 $if DART2JS
86 /**
87 * The amount that is expected to scroll vertically, in units determined by
88 * [deltaMode].
89 *
90 * See also:
91 *
92 * * [WheelEvent.deltaY](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html /DOM3-Events.html#events-WheelEvent-deltaY) from the W3C.
93 */
94 @DomName('WheelEvent.deltaY') 79 @DomName('WheelEvent.deltaY')
95 num get deltaY { 80 num get deltaY {
96 if (JS('bool', '#.deltaY !== undefined', this)) { 81 if (JS('bool', '#.deltaY !== undefined', this)) {
97 // W3C WheelEvent 82 // W3C WheelEvent
98 return this._deltaY; 83 return this._deltaY;
99 } else if (JS('bool', '#.wheelDelta !== undefined', this)) { 84 } else if (JS('bool', '#.wheelDelta !== undefined', this)) {
100 // Chrome and IE 85 // Chrome and IE
101 return -this._wheelDelta; 86 return this._wheelDelta;
102 } else if (JS('bool', '#.detail !== undefined', this)) { 87 } else if (JS('bool', '#.detail !== undefined', this)) {
103 // Firefox 88 // Firefox
104 89
105 // Handle DOMMouseScroll case where it uses detail and the axis to 90 // Handle DOMMouseScroll case where it uses detail and the axis to
106 // differentiate. 91 // differentiate.
107 if (JS('bool', '#.axis == MouseScrollEvent.VERTICAL_AXIS', this)) { 92 if (JS('bool', '#.axis == MouseScrollEvent.VERTICAL_AXIS', this)) {
108 var detail = this._detail; 93 var detail = this._detail;
109 // Firefox is normally the number of lines to scale (normally 3) 94 // Firefox is normally the number of lines to scale (normally 3)
110 // so multiply it by 40 to get pixels to move, matching IE & WebKit. 95 // so multiply it by 40 to get pixels to move, matching IE & WebKit.
111 if (detail < 100) { 96 if (detail < 100) {
112 return -detail * 40; 97 return detail * 40;
113 } 98 }
114 return -detail; 99 return detail;
115 } 100 }
116 return 0; 101 return 0;
117 } 102 }
118 throw new UnsupportedError( 103 throw new UnsupportedError(
119 'deltaY is not supported'); 104 'deltaY is not supported');
120 } 105 }
121 106
122 /**
123 * The amount that is expected to scroll horizontally, in units determined by
124 * [deltaMode].
125 *
126 * See also:
127 *
128 * * [WheelEvent.deltaX](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html /DOM3-Events.html#events-WheelEvent-deltaX) from the W3C.
129 */
130 @DomName('WheelEvent.deltaX') 107 @DomName('WheelEvent.deltaX')
131 num get deltaX { 108 num get deltaX {
132 if (JS('bool', '#.deltaX !== undefined', this)) { 109 if (JS('bool', '#.deltaX !== undefined', this)) {
133 // W3C WheelEvent 110 // W3C WheelEvent
134 return this._deltaX; 111 return this._deltaX;
135 } else if (JS('bool', '#.wheelDeltaX !== undefined', this)) { 112 } else if (JS('bool', '#.wheelDeltaX !== undefined', this)) {
136 // Chrome 113 // Chrome
137 return -this._wheelDeltaX; 114 return this._wheelDeltaX;
138 } else if (JS('bool', '#.detail !== undefined', this)) { 115 } else if (JS('bool', '#.detail !== undefined', this)) {
139 // Firefox and IE. 116 // Firefox and IE.
140 // IE will have detail set but will not set axis. 117 // IE will have detail set but will not set axis.
141 118
142 // Handle DOMMouseScroll case where it uses detail and the axis to 119 // Handle DOMMouseScroll case where it uses detail and the axis to
143 // differentiate. 120 // differentiate.
144 if (JS('bool', '#.axis !== undefined && ' 121 if (JS('bool', '#.axis !== undefined && '
145 '#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) { 122 '#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) {
146 var detail = this._detail; 123 var detail = this._detail;
147 // Firefox is normally the number of lines to scale (normally 3) 124 // Firefox is normally the number of lines to scale (normally 3)
148 // so multiply it by 40 to get pixels to move, matching IE & WebKit. 125 // so multiply it by 40 to get pixels to move, matching IE & WebKit.
149 if (detail < 100) { 126 if (detail < 100) {
150 return -detail * 40; 127 return detail * 40;
151 } 128 }
152 return -detail; 129 return detail;
153 } 130 }
154 return 0; 131 return 0;
155 } 132 }
156 throw new UnsupportedError( 133 throw new UnsupportedError(
157 'deltaX is not supported'); 134 'deltaX is not supported');
158 } 135 }
159 136
160 @DomName('WheelEvent.deltaMode') 137 @DomName('WheelEvent.deltaMode')
161 int get deltaMode { 138 int get deltaMode {
162 if (JS('bool', '!!(#.deltaMode)', this)) { 139 if (JS('bool', '!!(#.deltaMode)', this)) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 int clientY, 186 int clientY,
210 int button, 187 int button,
211 EventTarget relatedTarget, 188 EventTarget relatedTarget,
212 String modifiersList, 189 String modifiersList,
213 int deltaX, 190 int deltaX,
214 int deltaY, 191 int deltaY,
215 int deltaZ, 192 int deltaZ,
216 int deltaMode) native; 193 int deltaMode) native;
217 194
218 $else 195 $else
219 /**
220 * The amount that is expected to scroll horizontally, in units determined by
221 * [deltaMode].
222 *
223 * See also:
224 *
225 * * [WheelEvent.deltaX](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html /DOM3-Events.html#events-WheelEvent-deltaX) from the W3C.
226 */
227 @DomName('WheelEvent.deltaX') 196 @DomName('WheelEvent.deltaX')
228 num get deltaX => -$dom_wheelDeltaX; 197 num get deltaX => $dom_wheelDeltaX;
229
230 /**
231 * The amount that is expected to scroll vertically, in units determined by
232 * [deltaMode].
233 *
234 * See also:
235 *
236 * * [WheelEvent.deltaY](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html /DOM3-Events.html#events-WheelEvent-deltaY) from the W3C.
237 */
238 @DomName('WheelEvent.deltaY') 198 @DomName('WheelEvent.deltaY')
239 num get deltaY => -$dom_wheelDeltaY; 199 num get deltaY => $dom_wheelDeltaY;
240 $endif 200 $endif
241 } 201 }
OLDNEW
« 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