| Index: tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
|
| diff --git a/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate b/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
|
| index d660a21e2f5ac083a59791313fe4009a0fd021b6..0a75c439dac4ae1d3e13123388b8d94643400be1 100644
|
| --- a/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
|
| +++ b/tools/dom/templates/html/impl/impl_WheelEvent.darttemplate
|
| @@ -6,6 +6,131 @@ part of html;
|
|
|
| /// @domName $DOMNAME
|
| class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
| +
|
| + factory WheelEvent(
|
| + String type,
|
| + Window view,
|
| + int wheelDeltaX,
|
| + int wheelDeltaY,
|
| + int detail,
|
| + int screenX,
|
| + int screenY,
|
| + int clientX,
|
| + int clientY,
|
| + int button,
|
| + [bool canBubble = true,
|
| + bool cancelable = true,
|
| + bool ctrlKey = false,
|
| + bool altKey = false,
|
| + bool shiftKey = false,
|
| + bool metaKey = false,
|
| + EventTarget relatedTarget = null]) {
|
| +
|
| + var eventType = 'WheelEvent';
|
| + if (_Device.isFirefox) {
|
| + eventType = 'MouseScrollEvents';
|
| + }
|
| + final event = document.$dom_createEvent(eventType);
|
| +
|
| + if (_Device.isWebKit) {
|
| + event.$dom_initMouseEvent(
|
| + type,
|
| + canBubble,
|
| + cancelable,
|
| + view,
|
| + detail,
|
| + screenX,
|
| + screenY,
|
| + clientX,
|
| + clientY,
|
| + ctrlKey,
|
| + altKey,
|
| + shiftKey,
|
| + metaKey,
|
| + button,
|
| + relatedTarget);
|
| + event.$dom_initWebKitWheelEvent(
|
| + wheelDeltaX,
|
| + (wheelDeltaY / 120).toInt(), // Chrome does an auto-convert to pixels.
|
| + view,
|
| + screenX,
|
| + screenY,
|
| + clientX,
|
| + clientY,
|
| + ctrlKey,
|
| + altKey,
|
| + shiftKey,
|
| + metaKey);
|
| + }
|
| +$if DART2JS
|
| + else if (_Device.isIE) {
|
| + var modifiers = [];
|
| + if (ctrlKey) {
|
| + modifiers.push('Control');
|
| + }
|
| + if (altKey) {
|
| + modifiers.push('Alt');
|
| + }
|
| + if (shiftKey) {
|
| + modifiers.push('Shift');
|
| + }
|
| + if (metaKey) {
|
| + modifiers.push('Meta');
|
| + }
|
| + var modifiersList = modifiers.join(' ');
|
| + event._initIEWheelEvent(
|
| + type,
|
| + canBubble,
|
| + cancelable,
|
| + view,
|
| + detail,
|
| + screenX,
|
| + screenY,
|
| + clientX,
|
| + clientY,
|
| + button,
|
| + relatedTarget,
|
| + modifiersList,
|
| + wheelDeltaX,
|
| + wheelDeltaY,
|
| + 0,
|
| + 0);
|
| + } else if (_Device.isFirefox) {
|
| + var axis = 0;
|
| + var detail = 0;
|
| + if (wheelDeltaX != 0 && wheelDeltaY != 0) {
|
| + throw UnsupportedError(
|
| + 'Cannot modify wheelDeltaX and wheelDeltaY simultaneously');
|
| + }
|
| + if (wheelDeltaY != 0) {
|
| + detail = wheelDeltaY;
|
| + axis = JS('int', 'MouseScrollEvent.VERTICAL_AXIS');
|
| + } else if (wheelDeltaX != 0) {
|
| + detail = wheelDeltaX;
|
| + axis = JS('int', 'MouseScrollEvent.HORIZONTAL_AXIS');
|
| + }
|
| + event._initFireFoxMouseScrollEvent(
|
| + type,
|
| + canBubble,
|
| + cancelable,
|
| + view,
|
| + detail,
|
| + screenX,
|
| + screenY,
|
| + clientX,
|
| + clientY,
|
| + ctrlKey,
|
| + altKey,
|
| + shiftKey,
|
| + metaKey,
|
| + button,
|
| + relatedTarget,
|
| + axis);
|
| + }
|
| +$endif
|
| + return event;
|
| + }
|
| +
|
| $!MEMBERS
|
|
|
| $if DART2JS
|
| @@ -51,7 +176,8 @@ $if DART2JS
|
|
|
| // Handle DOMMouseScroll case where it uses detail and the axis to
|
| // differentiate.
|
| - if (JS('bool', '#.axis !== undefined && #.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) {
|
| + if (JS('bool', '#.axis !== undefined && '
|
| + '#.axis == MouseScrollEvent.HORIZONTAL_AXIS', this, this)) {
|
| var detail = this._detail;
|
| // Firefox is normally the number of lines to scale (normally 3)
|
| // so multiply it by 40 to get pixels to move, matching IE & WebKit.
|
| @@ -81,6 +207,44 @@ $if DART2JS
|
| num get _detail => JS('num', '#.detail', this);
|
| int get _deltaMode => JS('int', '#.deltaMode', this);
|
|
|
| + @JSName('initMouseScrollEvent')
|
| + void _initFireFoxMouseScrollEvent(
|
| + String type,
|
| + bool canBubble,
|
| + bool cancelable,
|
| + Window view,
|
| + int detail,
|
| + int screenX,
|
| + int screenY,
|
| + int clientX,
|
| + int clientY,
|
| + bool ctrlKey,
|
| + bool altKey,
|
| + bool shiftKey,
|
| + bool metaKey,
|
| + int button,
|
| + EventTarget relatedTarget,
|
| + int axis) native;
|
| +
|
| + @JSName('initWheelEvent')
|
| + void _initIEWheelEvent(
|
| + String eventType,
|
| + bool canBubble,
|
| + bool cancelable,
|
| + Window view,
|
| + int detail,
|
| + int screenX,
|
| + int screenY,
|
| + int clientX,
|
| + int clientY,
|
| + int button,
|
| + EventTarget relatedTarget,
|
| + String modifiersList,
|
| + int deltaX,
|
| + int deltaY,
|
| + int deltaZ,
|
| + int deltaMode) native;
|
| +
|
| $else
|
| /** @domName WheelEvent.deltaX */
|
| num get deltaX => $dom_wheelDeltaX;
|
|
|