1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/interfaces/events/nsIDOMSimpleGestureEvent.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,197 @@ 1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +#include "nsIDOMMouseEvent.idl" 1.11 + 1.12 +/** 1.13 + * The nsIDOMSimpleGestureEvent interface is the datatype for all 1.14 + * Mozilla-specific simple gesture events in the Document Object Model. 1.15 + * 1.16 + * The following events are generated: 1.17 + * 1.18 + * MozSwipeGestureStart - Generated when the user starts a horizontal 1.19 + * swipe across the input device. This event not only acts as a signal, 1.20 + * but also asks two questions: Should a swipe really be started, and 1.21 + * in which directions should the user be able to swipe? The first 1.22 + * question is answered by event listeners by calling or not calling 1.23 + * preventDefault() on the event. Since a swipe swallows all scroll 1.24 + * events, the default action of the swipe start event is *not* to 1.25 + * start a swipe. Call preventDefault() if you want a swipe to be 1.26 + * started. 1.27 + * The second question (swipe-able directions) is answered in the 1.28 + * allowedDirections field. 1.29 + * If this event has preventDefault() called on it (and thus starts 1.30 + * a swipe), it guarantees a future MozSwipeGestureEnd event that 1.31 + * will signal the end of a swipe animation. 1.32 + * 1.33 + * MozSwipeGestureUpdate - Generated periodically while the user is 1.34 + * continuing a horizontal swipe gesture. The "delta" value represents 1.35 + * the current absolute gesture amount. This event may even be sent 1.36 + * after a MozSwipeGesture event fired in order to allow for fluid 1.37 + * completion of a swipe animation. The direction value is meaningless 1.38 + * on swipe update events. 1.39 + * 1.40 + * MozSwipeGestureEnd - Generated when the swipe animation is completed. 1.41 + * 1.42 + * MozSwipeGesture - Generated when the user releases a swipe across 1.43 + * across the input device. This event signals that the actual swipe 1.44 + * operation is complete, even though the animation might not be finished 1.45 + * yet. This event can be sent without accompanying start / update / end 1.46 + * events, and it can also be handled on its own if the consumer doesn't 1.47 + * want to handle swipe animation events. 1.48 + * Only the direction value has any significance, the delta value is 1.49 + * meaningless. 1.50 + * 1.51 + * MozMagnifyGestureStart - Generated when the user begins the magnify 1.52 + * ("pinch") gesture. The "delta" value represents the initial 1.53 + * movement. 1.54 + * 1.55 + * MozMagnifyGestureUpdate - Generated periodically while the user is 1.56 + * continuing the magnify ("pinch") gesture. The "delta" value 1.57 + * represents the movement since the last MozMagnifyGestureStart or 1.58 + * MozMagnifyGestureUpdate event. 1.59 + * 1.60 + * MozMagnifyGesture - Generated when the user has completed the 1.61 + * magnify ("pinch") gesture. If you only want to receive a single 1.62 + * event when the magnify gesture is complete, you only need to hook 1.63 + * this event and can safely ignore the MozMagnifyGestureStart and the 1.64 + * MozMagnifyGestureUpdate events. The "delta" value is the cumulative 1.65 + * amount represented by the user's gesture. 1.66 + * 1.67 + * MozRotateGestureStart - Generated when the user begins the rotation 1.68 + * gesture. The "delta" value represents the initial rotation. 1.69 + * 1.70 + * MozRotateGestureUpdate - Generated periodically while the user is 1.71 + * continuing the rotation gesture. The "delta" value represents the 1.72 + * rotation since the last MozRotateGestureStart or 1.73 + * MozRotateGestureUpdate event. 1.74 + * 1.75 + * MozRotateGesture - Generated when the user has completed the 1.76 + * rotation gesture. If you only want to receive a single event when 1.77 + * the rotation gesture is complete, you only need to hook this event 1.78 + * and can safely ignore the MozRotateGestureStart and the 1.79 + * MozRotateGestureUpdate events. The "delta" value is the cumulative 1.80 + * amount of rotation represented by the user's gesture. 1.81 + * 1.82 + * MozTapGesture - Generated when the user executes a two finger 1.83 + * tap gesture on the input device. Client coordinates contain the 1.84 + * center point of the tap. 1.85 + * (XXX On OS X, only Lion (10.7) and up) 1.86 + * 1.87 + * MozPressTapGesture - Generated when the user executes a press 1.88 + * and tap two finger gesture (first finger down, second finger down, 1.89 + * second finger up, first finger up) on the input device. 1.90 + * Client coordinates contain the center pivot point of the action. 1.91 + * (XXX Not implemented on Mac) 1.92 + * 1.93 + * MozEdgeUIGesture - Generated when the user swipes the display to 1.94 + * invoke edge ui. 1.95 + * (XXX Win8 only) 1.96 + * 1.97 + * Default behavior: 1.98 + * 1.99 + * Some operating systems support default behaviors for gesture events 1.100 + * when they are not handled by the application. Consumers should 1.101 + * use event.preventDefault() to prevent default behavior when 1.102 + * consuming events. 1.103 + */ 1.104 + 1.105 +[scriptable, builtinclass, uuid(d78656ab-9d68-4f03-83f9-7c7bee071aa7)] 1.106 +interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent 1.107 +{ 1.108 + /* Swipe direction constants */ 1.109 + const unsigned long DIRECTION_UP = 1; 1.110 + const unsigned long DIRECTION_DOWN = 2; 1.111 + const unsigned long DIRECTION_LEFT = 4; 1.112 + const unsigned long DIRECTION_RIGHT = 8; 1.113 + 1.114 + /* Rotational direction constants */ 1.115 + const unsigned long ROTATION_COUNTERCLOCKWISE = 1; 1.116 + const unsigned long ROTATION_CLOCKWISE = 2; 1.117 + 1.118 + /* Read-write value for swipe events. 1.119 + * 1.120 + * Reports the directions that can be swiped to; multiple directions 1.121 + * should be OR'ed together. 1.122 + * 1.123 + * The allowedDirections field is designed to be set on SwipeGestureStart 1.124 + * events by event listeners. Its value after event dispatch determines 1.125 + * the behavior of the swipe animation that is about to begin. 1.126 + * Specifically, if the user swipes in a direction that can't be swiped 1.127 + * to, the animation will have a bounce effect. 1.128 + * Future SwipeGestureUpdate, SwipeGesture and SwipeGestureEnd events 1.129 + * will carry the allowDirections value that was set on the SwipeStart 1.130 + * event. Changing this field on non-SwipeGestureStart events doesn't 1.131 + * have any effect. 1.132 + */ 1.133 + attribute unsigned long allowedDirections; 1.134 + 1.135 + /* Direction of a gesture. Diagonals are indicated by OR'ing the 1.136 + * applicable constants together. 1.137 + * 1.138 + * Swipes gestures may occur in any direction. 1.139 + * 1.140 + * Magnify gestures do not have a direction. 1.141 + * 1.142 + * Rotation gestures will be either ROTATION_COUNTERCLOCKWISE or 1.143 + * ROTATION_CLOCKWISE. 1.144 + */ 1.145 + readonly attribute unsigned long direction; 1.146 + 1.147 + /* Delta value for magnify, rotate and swipe gestures. 1.148 + * 1.149 + * For rotation, the value is in degrees and is positive for 1.150 + * clockwise rotation and negative for counterclockwise 1.151 + * rotation. 1.152 + * 1.153 + * For magnification, the value will be positive for a "zoom in" 1.154 + * (i.e, increased magnification) and negative for a "zoom out" 1.155 + * (i.e., decreased magnification). The particular units 1.156 + * represented by the "delta" are currently implementation specific. 1.157 + * 1.158 + * XXX - The units for measuring magnification are currently 1.159 + * unspecified because the units used by Mac OS X are currently 1.160 + * undocumented. The values are typically in the range of 0.0 to 1.161 + * 100.0, but it is only safe currently to rely on the delta being 1.162 + * positive or negative. 1.163 + * 1.164 + * For swipe start, update and end events, the value is a fraction 1.165 + * of one "page". If the resulting swipe will have DIRECTION_LEFT, the 1.166 + * delta value will be positive; for DIRECTION_RIGHT, delta is negative. 1.167 + * If this seems backwards to you, look at it this way: If the current 1.168 + * page is pushed to the right during the animation (positive delta), 1.169 + * the page left to the current page will be visible after the swipe 1.170 + * (DIRECTION_LEFT). 1.171 + * 1.172 + * Units on Windows represent the difference between the initial 1.173 + * and current/final width between the two touch points on the input 1.174 + * device and are measured in pixels. 1.175 + */ 1.176 + readonly attribute double delta; 1.177 + 1.178 + /* Click count value for taps. */ 1.179 + readonly attribute unsigned long clickCount; 1.180 + 1.181 + void initSimpleGestureEvent(in DOMString typeArg, 1.182 + in boolean canBubbleArg, 1.183 + in boolean cancelableArg, 1.184 + in nsIDOMWindow viewArg, 1.185 + in long detailArg, 1.186 + in long screenXArg, 1.187 + in long screenYArg, 1.188 + in long clientXArg, 1.189 + in long clientYArg, 1.190 + in boolean ctrlKeyArg, 1.191 + in boolean altKeyArg, 1.192 + in boolean shiftKeyArg, 1.193 + in boolean metaKeyArg, 1.194 + in unsigned short buttonArg, 1.195 + in nsIDOMEventTarget relatedTargetArg, 1.196 + in unsigned long allowedDirectionsArg, 1.197 + in unsigned long directionArg, 1.198 + in double deltaArg, 1.199 + in unsigned long clickCount); 1.200 +};