| 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_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 $(ANNOTATIONS)$(CLASS_MODIFIERS)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._createEvent(eventType); |
| 24 $if DART2JS | 24 $if DART2JS |
| 25 // If polyfilling, then flip these because we'll flip them back to match | 25 // If polyfilling, then flip these because we'll flip them back to match |
| 26 // the W3C standard: | 26 // the W3C standard: |
| 27 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#ev
ents-WheelEvent-deltaY | 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)) { | 28 if (JS('bool', '#.deltaY === undefined', event)) { |
| 29 deltaX = -deltaX; | 29 deltaX = -deltaX; |
| 30 deltaY = -deltaY; | 30 deltaY = -deltaY; |
| 31 } | 31 } |
| 32 if (event._hasInitWheelEvent) { | 32 if (event._hasInitWheelEvent) { |
| 33 var modifiers = []; | 33 var modifiers = []; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 64 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 64 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 65 metaKey, button, relatedTarget, axis); | 65 metaKey, button, relatedTarget, axis); |
| 66 } else { | 66 } else { |
| 67 $else | 67 $else |
| 68 // Dartium always needs these flipped because we're essentially always | 68 // Dartium always needs these flipped because we're essentially always |
| 69 // polyfilling (see similar dart2js code as well) | 69 // polyfilling (see similar dart2js code as well) |
| 70 deltaX = -deltaX; | 70 deltaX = -deltaX; |
| 71 deltaY = -deltaY; | 71 deltaY = -deltaY; |
| 72 $endif | 72 $endif |
| 73 // Fallthrough for Dartium. | 73 // Fallthrough for Dartium. |
| 74 event.$dom_initMouseEvent(type, canBubble, cancelable, view, detail, | 74 event._initMouseEvent(type, canBubble, cancelable, view, detail, |
| 75 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 75 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 76 metaKey, button, relatedTarget); | 76 metaKey, button, relatedTarget); |
| 77 event.$dom_initWebKitWheelEvent(deltaX, | 77 event._initWebKitWheelEvent(deltaX, |
| 78 deltaY ~/ 120, // Chrome does an auto-convert to pixels. | 78 deltaY ~/ 120, // Chrome does an auto-convert to pixels. |
| 79 view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 79 view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 80 metaKey); | 80 metaKey); |
| 81 $if DART2JS | 81 $if DART2JS |
| 82 } | 82 } |
| 83 $endif | 83 $endif |
| 84 | 84 |
| 85 return event; | 85 return event; |
| 86 } | 86 } |
| 87 | 87 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 * [deltaMode]. | 237 * [deltaMode]. |
| 238 * | 238 * |
| 239 * See also: | 239 * See also: |
| 240 * | 240 * |
| 241 * * [WheelEvent.deltaY](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html
/DOM3-Events.html#events-WheelEvent-deltaY) from the W3C. | 241 * * [WheelEvent.deltaY](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html
/DOM3-Events.html#events-WheelEvent-deltaY) from the W3C. |
| 242 */ | 242 */ |
| 243 @DomName('WheelEvent.deltaY') | 243 @DomName('WheelEvent.deltaY') |
| 244 num get deltaY => -_wheelDeltaY; | 244 num get deltaY => -_wheelDeltaY; |
| 245 $endif | 245 $endif |
| 246 } | 246 } |
| OLD | NEW |