| 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)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 7 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
| 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 $if DART2JS |
| 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._createEvent(eventType); | 23 final event = document._createEvent(eventType); |
| 24 $if DART2JS | |
| 25 // If polyfilling, then flip these because we'll flip them back to match | 24 // If polyfilling, then flip these because we'll flip them back to match |
| 26 // the W3C standard: | 25 // the W3C standard: |
| 27 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#ev
ents-WheelEvent-deltaY | 26 // 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)) { | 27 if (JS('bool', '#.deltaY === undefined', event)) { |
| 29 deltaX = -deltaX; | 28 deltaX = -deltaX; |
| 30 deltaY = -deltaY; | 29 deltaY = -deltaY; |
| 31 } | 30 } |
| 32 if (event._hasInitWheelEvent) { | 31 if (event._hasInitWheelEvent) { |
| 33 var modifiers = []; | 32 var modifiers = []; |
| 34 if (ctrlKey) { | 33 if (ctrlKey) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 59 } else if (deltaX != 0) { | 58 } else if (deltaX != 0) { |
| 60 detail = deltaX; | 59 detail = deltaX; |
| 61 axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS'); | 60 axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS'); |
| 62 } | 61 } |
| 63 event._initMouseScrollEvent(type, canBubble, cancelable, view, detail, | 62 event._initMouseScrollEvent(type, canBubble, cancelable, view, detail, |
| 64 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 63 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 65 metaKey, button, relatedTarget, axis); | 64 metaKey, button, relatedTarget, axis); |
| 66 } else { | 65 } else { |
| 67 // Chrome does an auto-convert to pixels. | 66 // Chrome does an auto-convert to pixels. |
| 68 deltaY = deltaY ~/ 120; | 67 deltaY = deltaY ~/ 120; |
| 69 $else | 68 |
| 70 // Dartium always needs these flipped because we're using the legacy | |
| 71 // _initWebKitWheelEvent instead of the more modern WheelEvent constructor | |
| 72 // which isn't yet properly exposed by the Dartium bindings. | |
| 73 deltaX = -deltaX; | |
| 74 deltaY = -deltaY; | |
| 75 $endif | |
| 76 // Fallthrough for Dartium. | |
| 77 event._initMouseEvent(type, canBubble, cancelable, view, detail, | 69 event._initMouseEvent(type, canBubble, cancelable, view, detail, |
| 78 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 70 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 79 metaKey, button, relatedTarget); | 71 metaKey, button, relatedTarget); |
| 80 event._initWebKitWheelEvent(deltaX, deltaY, | 72 JS('void', '#.initWebKitWheelEvent(#, #, #, #, #, #, #, #, #, #, #)', |
| 73 event, deltaX, deltaY, |
| 81 view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 74 view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 82 metaKey); | 75 metaKey); |
| 83 $if DART2JS | |
| 84 } | 76 } |
| 85 $endif | |
| 86 | 77 |
| 87 return event; | 78 return event; |
| 79 $else |
| 80 var options = { |
| 81 'view': view, |
| 82 'deltaX': deltaX, |
| 83 'deltaY': deltaY, |
| 84 'detail': detail, |
| 85 'screenX': screenX, |
| 86 'screenY': screenY, |
| 87 'clientX': clientX, |
| 88 'clientY': clientY, |
| 89 'button': button, |
| 90 'bubbles': canBubble, |
| 91 'cancelable': cancelable, |
| 92 'ctrlKey': ctrlKey, |
| 93 'altKey': altKey, |
| 94 'shiftKey': shiftKey, |
| 95 'metaKey': metaKey, |
| 96 'relatedTarget': relatedTarget, |
| 97 }; |
| 98 return _blink.BlinkWheelEvent.constructorCallback(type, options); |
| 99 $endif |
| 88 } | 100 } |
| 89 | 101 |
| 90 $!MEMBERS | 102 $!MEMBERS |
| 91 | 103 |
| 92 $if DART2JS | 104 $if DART2JS |
| 93 /** | 105 /** |
| 94 * The amount that is expected to scroll vertically, in units determined by | 106 * The amount that is expected to scroll vertically, in units determined by |
| 95 * [deltaMode]. | 107 * [deltaMode]. |
| 96 * | 108 * |
| 97 * See also: | 109 * See also: |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 * [deltaMode]. | 249 * [deltaMode]. |
| 238 * | 250 * |
| 239 * See also: | 251 * See also: |
| 240 * | 252 * |
| 241 * * [WheelEvent.deltaY](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html
/DOM3-Events.html#events-WheelEvent-deltaY) from the W3C. | 253 * * [WheelEvent.deltaY](http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html
/DOM3-Events.html#events-WheelEvent-deltaY) from the W3C. |
| 242 */ | 254 */ |
| 243 @DomName('WheelEvent.deltaY') | 255 @DomName('WheelEvent.deltaY') |
| 244 num get deltaY => _deltaY; | 256 num get deltaY => _deltaY; |
| 245 $endif | 257 $endif |
| 246 } | 258 } |
| OLD | NEW |