| 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 html; | 5 part of html; |
| 6 | 6 |
| 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 8 | 8 |
| 9 factory WheelEvent(String type, Window view, int wheelDeltaX, int wheelDeltaY, | 9 factory WheelEvent(String type, |
| 10 int detail, int screenX, int screenY, int clientX, int clientY, | 10 {Window view, int deltaX: 0, int deltaY: 0, |
| 11 int button, | 11 int detail: 0, int screenX: 0, int screenY: 0, int clientX: 0, |
| 12 [bool canBubble = true, bool cancelable = true, bool ctrlKey = false, | 12 int clientY: 0, int button: 0, bool canBubble: true, |
| 13 bool altKey = false, bool shiftKey = false, bool metaKey = false, | 13 bool cancelable: true, bool ctrlKey: false, bool altKey: false, |
| 14 EventTarget relatedTarget = null]) { | 14 bool shiftKey: false, bool metaKey: false, EventTarget relatedTarget}) { |
| 15 | 15 |
| 16 if (view == null) { |
| 17 view = window; |
| 18 } |
| 16 var eventType = 'WheelEvent'; | 19 var eventType = 'WheelEvent'; |
| 17 if (_Device.isFirefox) { | 20 if (_Device.isFirefox) { |
| 18 eventType = 'MouseScrollEvents'; | 21 eventType = 'MouseScrollEvents'; |
| 19 } | 22 } |
| 20 final event = document.$dom_createEvent(eventType); | 23 final event = document.$dom_createEvent(eventType); |
| 21 $if DART2JS | 24 $if DART2JS |
| 22 if (event._hasInitWheelEvent) { | 25 if (event._hasInitWheelEvent) { |
| 23 var modifiers = []; | 26 var modifiers = []; |
| 24 if (ctrlKey) { | 27 if (ctrlKey) { |
| 25 modifiers.push('Control'); | 28 modifiers.push('Control'); |
| 26 } | 29 } |
| 27 if (altKey) { | 30 if (altKey) { |
| 28 modifiers.push('Alt'); | 31 modifiers.push('Alt'); |
| 29 } | 32 } |
| 30 if (shiftKey) { | 33 if (shiftKey) { |
| 31 modifiers.push('Shift'); | 34 modifiers.push('Shift'); |
| 32 } | 35 } |
| 33 if (metaKey) { | 36 if (metaKey) { |
| 34 modifiers.push('Meta'); | 37 modifiers.push('Meta'); |
| 35 } | 38 } |
| 36 event._initWheelEvent(type, canBubble, cancelable, view, detail, screenX, | 39 event._initWheelEvent(type, canBubble, cancelable, view, detail, screenX, |
| 37 screenY, clientX, clientY, button, relatedTarget, modifiers.join(' '), | 40 screenY, clientX, clientY, button, relatedTarget, modifiers.join(' '), |
| 38 wheelDeltaX, wheelDeltaY, 0, 0); | 41 deltaX, deltaY, 0, 0); |
| 39 } else if (event._hasInitMouseScrollEvent) { | 42 } else if (event._hasInitMouseScrollEvent) { |
| 40 var axis = 0; | 43 var axis = 0; |
| 41 var detail = 0; | 44 var detail = 0; |
| 42 if (wheelDeltaX != 0 && wheelDeltaY != 0) { | 45 if (deltaX != 0 && deltaY != 0) { |
| 43 throw UnsupportedError( | 46 throw UnsupportedError( |
| 44 'Cannot modify wheelDeltaX and wheelDeltaY simultaneously'); | 47 'Cannot modify deltaX and deltaY simultaneously'); |
| 45 } | 48 } |
| 46 if (wheelDeltaY != 0) { | 49 if (deltaY != 0) { |
| 47 detail = wheelDeltaY; | 50 detail = deltaY; |
| 48 axis = JS('int', 'MouseScrollEvent.VERTICAL_AXIS'); | 51 axis = JS('int', 'MouseScrollEvent.VERTICAL_AXIS'); |
| 49 } else if (wheelDeltaX != 0) { | 52 } else if (deltaX != 0) { |
| 50 detail = wheelDeltaX; | 53 detail = deltaX; |
| 51 axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS'); | 54 axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS'); |
| 52 } | 55 } |
| 53 event._initMouseScrollEvent(type, canBubble, cancelable, view, detail, | 56 event._initMouseScrollEvent(type, canBubble, cancelable, view, detail, |
| 54 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 57 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 55 metaKey, button, relatedTarget, axis); | 58 metaKey, button, relatedTarget, axis); |
| 56 } else { | 59 } else { |
| 57 $endif | 60 $endif |
| 58 // Fallthrough for Dartium. | 61 // Fallthrough for Dartium. |
| 59 event.$dom_initMouseEvent(type, canBubble, cancelable, view, detail, | 62 event.$dom_initMouseEvent(type, canBubble, cancelable, view, detail, |
| 60 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 63 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 61 metaKey, button, relatedTarget); | 64 metaKey, button, relatedTarget); |
| 62 event.$dom_initWebKitWheelEvent(wheelDeltaX, | 65 event.$dom_initWebKitWheelEvent(deltaX, |
| 63 wheelDeltaY ~/ 120, // Chrome does an auto-convert to pixels. | 66 deltaY ~/ 120, // Chrome does an auto-convert to pixels. |
| 64 view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, | 67 view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, |
| 65 metaKey); | 68 metaKey); |
| 66 $if DART2JS | 69 $if DART2JS |
| 67 } | 70 } |
| 68 $endif | 71 $endif |
| 69 | 72 |
| 70 return event; | 73 return event; |
| 71 } | 74 } |
| 72 | 75 |
| 73 $!MEMBERS | 76 $!MEMBERS |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 $else | 195 $else |
| 193 @DomName('WheelEvent.deltaX') | 196 @DomName('WheelEvent.deltaX') |
| 194 num get deltaX => $dom_wheelDeltaX; | 197 num get deltaX => $dom_wheelDeltaX; |
| 195 @DomName('WheelEvent.deltaY') | 198 @DomName('WheelEvent.deltaY') |
| 196 num get deltaY => $dom_wheelDeltaY; | 199 num get deltaY => $dom_wheelDeltaY; |
| 197 @DomName('WheelEvent.deltaMode') | 200 @DomName('WheelEvent.deltaMode') |
| 198 int get deltaMode => 0; | 201 int get deltaMode => 0; |
| 199 | 202 |
| 200 $endif | 203 $endif |
| 201 } | 204 } |
| OLD | NEW |