Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 } | |
| 25 if (event._hasInitWheelEvent) { | 32 if (event._hasInitWheelEvent) { |
| 26 var modifiers = []; | 33 var modifiers = []; |
| 27 if (ctrlKey) { | 34 if (ctrlKey) { |
| 28 modifiers.push('Control'); | 35 modifiers.push('Control'); |
| 29 } | 36 } |
| 30 if (altKey) { | 37 if (altKey) { |
| 31 modifiers.push('Alt'); | 38 modifiers.push('Alt'); |
| 32 } | 39 } |
| 33 if (shiftKey) { | 40 if (shiftKey) { |
| 34 modifiers.push('Shift'); | 41 modifiers.push('Shift'); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 $if DART2JS | 76 $if DART2JS |
| 70 } | 77 } |
| 71 $endif | 78 $endif |
| 72 | 79 |
| 73 return event; | 80 return event; |
| 74 } | 81 } |
| 75 | 82 |
| 76 $!MEMBERS | 83 $!MEMBERS |
| 77 | 84 |
| 78 $if DART2JS | 85 $if DART2JS |
| 86 /** | |
| 87 * The amount that is expected to scroll vertically, in units determined by | |
| 88 * [deltaMode]. | |
| 89 * | |
| 90 * See also: | |
| 91 * | |
| 92 * * [W3C WheelEvent](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DO M3-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.
| |
| 93 */ | |
| 79 @DomName('WheelEvent.deltaY') | 94 @DomName('WheelEvent.deltaY') |
| 80 num get deltaY { | 95 num get deltaY { |
| 81 if (JS('bool', '#.deltaY !== undefined', this)) { | 96 if (JS('bool', '#.deltaY !== undefined', this)) { |
| 82 // W3C WheelEvent | 97 // W3C WheelEvent |
| 83 return this._deltaY; | 98 return this._deltaY; |
| 84 } else if (JS('bool', '#.wheelDelta !== undefined', this)) { | 99 } else if (JS('bool', '#.wheelDelta !== undefined', this)) { |
| 85 // Chrome and IE | 100 // Chrome and IE |
| 86 return this._wheelDelta; | 101 return -this._wheelDelta; |
| 87 } else if (JS('bool', '#.detail !== undefined', this)) { | 102 } else if (JS('bool', '#.detail !== undefined', this)) { |
| 88 // Firefox | 103 // Firefox |
| 89 | 104 |
| 90 // Handle DOMMouseScroll case where it uses detail and the axis to | 105 // Handle DOMMouseScroll case where it uses detail and the axis to |
| 91 // differentiate. | 106 // differentiate. |
| 92 if (JS('bool', '#.axis == MouseScrollEvent.VERTICAL_AXIS', this)) { | 107 if (JS('bool', '#.axis == MouseScrollEvent.VERTICAL_AXIS', this)) { |
| 93 var detail = this._detail; | 108 var detail = this._detail; |
| 94 // Firefox is normally the number of lines to scale (normally 3) | 109 // Firefox is normally the number of lines to scale (normally 3) |
| 95 // so multiply it by 40 to get pixels to move, matching IE & WebKit. | 110 // so multiply it by 40 to get pixels to move, matching IE & WebKit. |
| 96 if (detail < 100) { | 111 if (detail < 100) { |
| 97 return detail * 40; | 112 return -detail * 40; |
| 98 } | 113 } |
| 99 return detail; | 114 return -detail; |
| 100 } | 115 } |
| 101 return 0; | 116 return 0; |
| 102 } | 117 } |
| 103 throw new UnsupportedError( | 118 throw new UnsupportedError( |
| 104 'deltaY is not supported'); | 119 'deltaY is not supported'); |
| 105 } | 120 } |
| 106 | 121 |
| 122 /** | |
| 123 * The amount that is expected to scroll horizontally, in units determined by | |
| 124 * [deltaMode]. | |
| 125 * | |
| 126 * See also: | |
| 127 * | |
| 128 * * [W3C WheelEvent](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DO M3-Events.html#events-WheelEvent-deltaX) | |
| 129 */ | |
| 107 @DomName('WheelEvent.deltaX') | 130 @DomName('WheelEvent.deltaX') |
| 108 num get deltaX { | 131 num get deltaX { |
| 109 if (JS('bool', '#.deltaX !== undefined', this)) { | 132 if (JS('bool', '#.deltaX !== undefined', this)) { |
| 110 // W3C WheelEvent | 133 // W3C WheelEvent |
| 111 return this._deltaX; | 134 return this._deltaX; |
| 112 } else if (JS('bool', '#.wheelDeltaX !== undefined', this)) { | 135 } else if (JS('bool', '#.wheelDeltaX !== undefined', this)) { |
| 113 // Chrome | 136 // Chrome |
| 114 return this._wheelDeltaX; | 137 return -this._wheelDeltaX; |
| 115 } else if (JS('bool', '#.detail !== undefined', this)) { | 138 } else if (JS('bool', '#.detail !== undefined', this)) { |
| 116 // Firefox and IE. | 139 // Firefox and IE. |
| 117 // IE will have detail set but will not set axis. | 140 // IE will have detail set but will not set axis. |
| 118 | 141 |
| 119 // Handle DOMMouseScroll case where it uses detail and the axis to | 142 // Handle DOMMouseScroll case where it uses detail and the axis to |
| 120 // differentiate. | 143 // differentiate. |
| 121 if (JS('bool', '#.axis !== undefined && ' | 144 if (JS('bool', '#.axis !== undefined && ' |
| 122 '#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) { | 145 '#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) { |
| 123 var detail = this._detail; | 146 var detail = this._detail; |
| 124 // Firefox is normally the number of lines to scale (normally 3) | 147 // Firefox is normally the number of lines to scale (normally 3) |
| 125 // so multiply it by 40 to get pixels to move, matching IE & WebKit. | 148 // so multiply it by 40 to get pixels to move, matching IE & WebKit. |
| 126 if (detail < 100) { | 149 if (detail < 100) { |
| 127 return detail * 40; | 150 return -detail * 40; |
| 128 } | 151 } |
| 129 return detail; | 152 return -detail; |
| 130 } | 153 } |
| 131 return 0; | 154 return 0; |
| 132 } | 155 } |
| 133 throw new UnsupportedError( | 156 throw new UnsupportedError( |
| 134 'deltaX is not supported'); | 157 'deltaX is not supported'); |
| 135 } | 158 } |
| 136 | 159 |
| 137 @DomName('WheelEvent.deltaMode') | 160 @DomName('WheelEvent.deltaMode') |
| 138 int get deltaMode { | 161 int get deltaMode { |
| 139 if (JS('bool', '!!(#.deltaMode)', this)) { | 162 if (JS('bool', '!!(#.deltaMode)', this)) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 int clientY, | 209 int clientY, |
| 187 int button, | 210 int button, |
| 188 EventTarget relatedTarget, | 211 EventTarget relatedTarget, |
| 189 String modifiersList, | 212 String modifiersList, |
| 190 int deltaX, | 213 int deltaX, |
| 191 int deltaY, | 214 int deltaY, |
| 192 int deltaZ, | 215 int deltaZ, |
| 193 int deltaMode) native; | 216 int deltaMode) native; |
| 194 | 217 |
| 195 $else | 218 $else |
| 219 /** | |
| 220 * The amount that is expected to scroll horizontally, in units determined by | |
| 221 * [deltaMode]. | |
| 222 * | |
| 223 * See also: | |
| 224 * | |
| 225 * * [W3C WheelEvent](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DO M3-Events.html#events-WheelEvent-deltaX) | |
| 226 */ | |
| 196 @DomName('WheelEvent.deltaX') | 227 @DomName('WheelEvent.deltaX') |
| 197 num get deltaX => $dom_wheelDeltaX; | 228 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 * * [W3C WheelEvent](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DO M3-Events.html#events-WheelEvent-deltaY) | |
| 237 */ | |
| 198 @DomName('WheelEvent.deltaY') | 238 @DomName('WheelEvent.deltaY') |
| 199 num get deltaY => $dom_wheelDeltaY; | 239 num get deltaY => -$dom_wheelDeltaY; |
| 200 $endif | 240 $endif |
| 201 } | 241 } |
| OLD | NEW |