Bug 764355 - Add a new edge swipe simple gesture and add a click count value to existing tap gestures for Win8. r=felipe

This commit is contained in:
Jim Mathies 2012-06-14 12:40:12 -05:00
Родитель e55f82a6de
Коммит 47e4a93863
12 изменённых файлов: 81 добавлений и 14 удалений

Просмотреть файл

@ -45,6 +45,7 @@ let test_expectedType;
let test_expectedDirection; let test_expectedDirection;
let test_expectedDelta; let test_expectedDelta;
let test_expectedModifiers; let test_expectedModifiers;
let test_expectedClickCount;
function test_gestureListener(evt) function test_gestureListener(evt)
{ {
@ -75,6 +76,10 @@ function test_gestureListener(evt)
is(evt.metaKey, (test_expectedModifiers & Components.interfaces.nsIDOMNSEvent.META_MASK) != 0, is(evt.metaKey, (test_expectedModifiers & Components.interfaces.nsIDOMNSEvent.META_MASK) != 0,
"evt.metaKey did not match expected value"); "evt.metaKey did not match expected value");
if (evt.type == "MozTapGesture") {
is(evt.clickCount, test_expectedClickCount, "evt.clickCount does not match");
}
test_eventCount++; test_eventCount++;
} }
@ -95,6 +100,24 @@ function test_helper1(type, direction, delta, modifiers)
is(expectedEventCount, test_eventCount, "Event (" + type + ") was never received by event listener"); is(expectedEventCount, test_eventCount, "Event (" + type + ") was never received by event listener");
} }
function test_clicks(type, clicks)
{
// Setup the expected values
test_expectedType = type;
test_expectedDirection = 0;
test_expectedDelta = 0;
test_expectedModifiers = 0;
test_expectedClickCount = clicks;
let expectedEventCount = test_eventCount + 1;
document.addEventListener(type, test_gestureListener, true);
test_utils.sendSimpleGestureEvent(type, 20, 20, 0, 0, 0, clicks);
document.removeEventListener(type, test_gestureListener, true);
is(expectedEventCount, test_eventCount, "Event (" + type + ") was never received by event listener");
}
function test_TestEventListeners() function test_TestEventListeners()
{ {
let e = test_helper1; // easier to type this name let e = test_helper1; // easier to type this name
@ -126,8 +149,13 @@ function test_TestEventListeners()
e("MozRotateGesture", SimpleGestureEvent.ROTATION_CLOCKWISE, 33.0, 0); e("MozRotateGesture", SimpleGestureEvent.ROTATION_CLOCKWISE, 33.0, 0);
// Tap and presstap gesture events // Tap and presstap gesture events
e("MozTapGesture", 0, 0.0, 0); test_clicks("MozTapGesture", 1);
e("MozPressTapGesture", 0, 0.0, 0); test_clicks("MozTapGesture", 2);
test_clicks("MozTapGesture", 3);
test_clicks("MozPressTapGesture", 1);
// simple delivery test for edgeui gesture
e("MozEdgeUIGesture", 0, 0, 0);
// event.shiftKey // event.shiftKey
let modifier = Components.interfaces.nsIDOMNSEvent.SHIFT_MASK; let modifier = Components.interfaces.nsIDOMNSEvent.SHIFT_MASK;
@ -171,7 +199,7 @@ function test_helper2(type, direction, delta, altKey, ctrlKey, shiftKey, metaKey
10, 10, 10, 10, 10, 10, 10, 10,
ctrlKey, altKey, shiftKey, metaKey, ctrlKey, altKey, shiftKey, metaKey,
1, window, 1, window,
direction, delta); direction, delta, 0);
successful = true; successful = true;
} }
catch (ex) { catch (ex) {

Просмотреть файл

@ -1643,6 +1643,7 @@ GK_ATOM(onMozRotateGestureUpdate, "onMozRotateGestureUpdate")
GK_ATOM(onMozRotateGesture, "onMozRotateGesture") GK_ATOM(onMozRotateGesture, "onMozRotateGesture")
GK_ATOM(onMozTapGesture, "onMozTapGesture") GK_ATOM(onMozTapGesture, "onMozTapGesture")
GK_ATOM(onMozPressTapGesture, "onMozPressTapGesture") GK_ATOM(onMozPressTapGesture, "onMozPressTapGesture")
GK_ATOM(onMozEdgeUIGesture, "onMozEdgeUIGesture")
// Touch events // Touch events
GK_ATOM(onMozTouchDown, "onMozTouchDown") GK_ATOM(onMozTouchDown, "onMozTouchDown")

Просмотреть файл

@ -712,6 +712,10 @@ NON_IDL_EVENT(MozPressTapGesture,
NS_SIMPLE_GESTURE_PRESSTAP, NS_SIMPLE_GESTURE_PRESSTAP,
EventNameType_None, EventNameType_None,
NS_SIMPLE_GESTURE_EVENT) NS_SIMPLE_GESTURE_EVENT)
NON_IDL_EVENT(MozEdgeUIGesture,
NS_SIMPLE_GESTURE_EDGEUI,
EventNameType_None,
NS_SIMPLE_GESTURE_EVENT)
NON_IDL_EVENT(MozTouchDown, NON_IDL_EVENT(MozTouchDown,
NS_MOZTOUCH_DOWN, NS_MOZTOUCH_DOWN,

Просмотреть файл

@ -77,6 +77,7 @@ static const char* const sEventNames[] = {
"MozRotateGesture", "MozRotateGesture",
"MozTapGesture", "MozTapGesture",
"MozPressTapGesture", "MozPressTapGesture",
"MozEdgeUIGesture",
"MozTouchDown", "MozTouchDown",
"MozTouchMove", "MozTouchMove",
"MozTouchUp", "MozTouchUp",
@ -839,6 +840,7 @@ nsDOMEvent::DuplicatePrivateData()
isInputEvent = true; isInputEvent = true;
simpleGestureEvent->direction = oldSimpleGestureEvent->direction; simpleGestureEvent->direction = oldSimpleGestureEvent->direction;
simpleGestureEvent->delta = oldSimpleGestureEvent->delta; simpleGestureEvent->delta = oldSimpleGestureEvent->delta;
simpleGestureEvent->clickCount = oldSimpleGestureEvent->clickCount;
newEvent = simpleGestureEvent; newEvent = simpleGestureEvent;
break; break;
} }
@ -1503,6 +1505,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return sEventNames[eDOMEvents_MozTapGesture]; return sEventNames[eDOMEvents_MozTapGesture];
case NS_SIMPLE_GESTURE_PRESSTAP: case NS_SIMPLE_GESTURE_PRESSTAP:
return sEventNames[eDOMEvents_MozPressTapGesture]; return sEventNames[eDOMEvents_MozPressTapGesture];
case NS_SIMPLE_GESTURE_EDGEUI:
return sEventNames[eDOMEvents_MozEdgeUIGesture];
case NS_MOZTOUCH_DOWN: case NS_MOZTOUCH_DOWN:
return sEventNames[eDOMEvents_MozTouchDown]; return sEventNames[eDOMEvents_MozTouchDown];
case NS_MOZTOUCH_MOVE: case NS_MOZTOUCH_MOVE:

Просмотреть файл

@ -160,6 +160,7 @@ public:
eDOMEvents_MozRotateGesture, eDOMEvents_MozRotateGesture,
eDOMEvents_MozTapGesture, eDOMEvents_MozTapGesture,
eDOMEvents_MozPressTapGesture, eDOMEvents_MozPressTapGesture,
eDOMEvents_MozEdgeUIGesture,
eDOMEvents_MozTouchDown, eDOMEvents_MozTouchDown,
eDOMEvents_MozTouchMove, eDOMEvents_MozTouchMove,
eDOMEvents_MozTouchUp, eDOMEvents_MozTouchUp,

Просмотреть файл

@ -59,6 +59,15 @@ nsDOMSimpleGestureEvent::GetDelta(PRFloat64 *aDelta)
return NS_OK; return NS_OK;
} }
/* readonly attribute unsigned long clickCount; */
NS_IMETHODIMP
nsDOMSimpleGestureEvent::GetClickCount(PRUint32 *aClickCount)
{
NS_ENSURE_ARG_POINTER(aClickCount);
*aClickCount = static_cast<nsSimpleGestureEvent*>(mEvent)->clickCount;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg, nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
bool aCanBubbleArg, bool aCanBubbleArg,
@ -76,7 +85,8 @@ nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
PRUint16 aButton, PRUint16 aButton,
nsIDOMEventTarget* aRelatedTarget, nsIDOMEventTarget* aRelatedTarget,
PRUint32 aDirectionArg, PRUint32 aDirectionArg,
PRFloat64 aDeltaArg) PRFloat64 aDeltaArg,
PRUint32 aClickCountArg)
{ {
nsresult rv = nsDOMMouseEvent::InitMouseEvent(aTypeArg, nsresult rv = nsDOMMouseEvent::InitMouseEvent(aTypeArg,
aCanBubbleArg, aCanBubbleArg,
@ -98,6 +108,7 @@ nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
nsSimpleGestureEvent* simpleGestureEvent = static_cast<nsSimpleGestureEvent*>(mEvent); nsSimpleGestureEvent* simpleGestureEvent = static_cast<nsSimpleGestureEvent*>(mEvent);
simpleGestureEvent->direction = aDirectionArg; simpleGestureEvent->direction = aDirectionArg;
simpleGestureEvent->delta = aDeltaArg; simpleGestureEvent->delta = aDeltaArg;
simpleGestureEvent->clickCount = aClickCountArg;
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -1005,7 +1005,8 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
float aY, float aY,
PRUint32 aDirection, PRUint32 aDirection,
PRFloat64 aDelta, PRFloat64 aDelta,
PRInt32 aModifiers) PRInt32 aModifiers,
PRUint32 aClickCount)
{ {
if (!IsUniversalXPConnectCapable()) { if (!IsUniversalXPConnectCapable()) {
return NS_ERROR_DOM_SECURITY_ERR; return NS_ERROR_DOM_SECURITY_ERR;
@ -1036,11 +1037,14 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
msg = NS_SIMPLE_GESTURE_TAP; msg = NS_SIMPLE_GESTURE_TAP;
else if (aType.EqualsLiteral("MozPressTapGesture")) else if (aType.EqualsLiteral("MozPressTapGesture"))
msg = NS_SIMPLE_GESTURE_PRESSTAP; msg = NS_SIMPLE_GESTURE_PRESSTAP;
else if (aType.EqualsLiteral("MozEdgeUIGesture"))
msg = NS_SIMPLE_GESTURE_EDGEUI;
else else
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsSimpleGestureEvent event(true, msg, widget, aDirection, aDelta); nsSimpleGestureEvent event(true, msg, widget, aDirection, aDelta);
event.modifiers = GetWidgetModifiers(aModifiers); event.modifiers = GetWidgetModifiers(aModifiers);
event.clickCount = aClickCount;
event.time = PR_IntervalNow(); event.time = PR_IntervalNow();
nsPresContext* presContext = GetPresContext(); nsPresContext* presContext = GetPresContext();

Просмотреть файл

@ -490,8 +490,8 @@ interface nsIDOMWindowUtils : nsISupports {
/** Synthesize a simple gesture event for a window. The event types /** Synthesize a simple gesture event for a window. The event types
* supported are: MozSwipeGesture, MozMagnifyGestureStart, * supported are: MozSwipeGesture, MozMagnifyGestureStart,
* MozMagnifyGestureUpdate, MozMagnifyGesture, MozRotateGestureStart, * MozMagnifyGestureUpdate, MozMagnifyGesture, MozRotateGestureStart,
* MozRotateGestureUpdate, MozRotateGesture, MozPressTapGesture, and * MozRotateGestureUpdate, MozRotateGesture, MozPressTapGesture,
* MozTapGesture. * MozTapGesture, and MozEdgeUIGesture.
* *
* Cannot be accessed from unprivileged context (not * Cannot be accessed from unprivileged context (not
* content-accessible) Will throw a DOM security error if called * content-accessible) Will throw a DOM security error if called
@ -503,13 +503,15 @@ interface nsIDOMWindowUtils : nsISupports {
* @param aDirection direction, using constants defined in nsIDOMSimpleGestureEvent * @param aDirection direction, using constants defined in nsIDOMSimpleGestureEvent
* @param aDelta amount of magnification or rotation for magnify and rotation events * @param aDelta amount of magnification or rotation for magnify and rotation events
* @param aModifiers modifiers pressed, using constants defined in nsIDOMNSEvent * @param aModifiers modifiers pressed, using constants defined in nsIDOMNSEvent
* @param aClickCount For tap gestures, the number of taps.
*/ */
void sendSimpleGestureEvent(in AString aType, void sendSimpleGestureEvent(in AString aType,
in float aX, in float aX,
in float aY, in float aY,
in unsigned long aDirection, in unsigned long aDirection,
in double aDelta, in double aDelta,
in long aModifiers); in long aModifiers,
[optional] in unsigned long aClickCount);
/** /**
* Retrieve the element at point aX, aY in the window's document. * Retrieve the element at point aX, aY in the window's document.

Просмотреть файл

@ -57,6 +57,10 @@
* Client coordinates contain the center pivot point of the action. * Client coordinates contain the center pivot point of the action.
* (XXX Not implemented on Mac) * (XXX Not implemented on Mac)
* *
* MozEdgeUIGesture - Generated when the user swipes the display to
* invoke edge ui.
* (XXX Win8 only)
*
* Default behavior: * Default behavior:
* *
* Some operating systems support default behaviors for gesture events * Some operating systems support default behaviors for gesture events
@ -65,7 +69,7 @@
* consuming events. * consuming events.
*/ */
[scriptable, builtinclass, uuid(2827efac-40c1-44af-82b9-3ad92f04d7ac)] [scriptable, builtinclass, uuid(5e2a88ce-5032-4758-8578-37c6d7f87d7b)]
interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
{ {
/* Swipe direction constants */ /* Swipe direction constants */
@ -113,6 +117,9 @@ interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
*/ */
readonly attribute double delta; readonly attribute double delta;
/* Click count value for taps. */
readonly attribute unsigned long clickCount;
void initSimpleGestureEvent(in DOMString typeArg, void initSimpleGestureEvent(in DOMString typeArg,
in boolean canBubbleArg, in boolean canBubbleArg,
in boolean cancelableArg, in boolean cancelableArg,
@ -129,5 +136,6 @@ interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
in unsigned short buttonArg, in unsigned short buttonArg,
in nsIDOMEventTarget relatedTargetArg, in nsIDOMEventTarget relatedTargetArg,
in unsigned long directionArg, in unsigned long directionArg,
in double deltaArg); in double deltaArg,
in unsigned long clickCount);
}; };

Просмотреть файл

@ -55,7 +55,7 @@ function onDebugKeyPress(aEvent) {
let evt = document.createEvent("SimpleGestureEvent"); let evt = document.createEvent("SimpleGestureEvent");
evt.initSimpleGestureEvent("MozSwipeGesture", true, true, window, null, evt.initSimpleGestureEvent("MozSwipeGesture", true, true, window, null,
0, 0, 0, 0, false, false, false, false, 0, null, 0, 0, 0, 0, false, false, false, false, 0, null,
aDirection, 0); aDirection, 0, 0);
Browser.selectedTab.inputHandler.dispatchEvent(evt); Browser.selectedTab.inputHandler.dispatchEvent(evt);
} }
@ -79,7 +79,7 @@ function onDebugKeyPress(aEvent) {
function dispatchMagnifyEvent(aName, aDelta) { function dispatchMagnifyEvent(aName, aDelta) {
let evt = document.createEvent("SimpleGestureEvent"); let evt = document.createEvent("SimpleGestureEvent");
evt.initSimpleGestureEvent("MozMagnifyGesture" + aName, true, true, window, null, evt.initSimpleGestureEvent("MozMagnifyGesture" + aName, true, true, window, null,
0, 0, 0, 0, false, false, false, false, 0, null, 0, aDelta); 0, 0, 0, 0, false, false, false, false, 0, null, 0, aDelta, 0);
Browser.selectedTab.inputHandler.dispatchEvent(evt); Browser.selectedTab.inputHandler.dispatchEvent(evt);
} }
dispatchMagnifyEvent("Start", 0); dispatchMagnifyEvent("Start", 0);

Просмотреть файл

@ -431,6 +431,7 @@ class nsHashKey;
#define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6) #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
#define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+7) #define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+7)
#define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+8) #define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+8)
#define NS_SIMPLE_GESTURE_EDGEUI (NS_SIMPLE_GESTURE_EVENT_START+9)
// These are used to send native events to plugins. // These are used to send native events to plugins.
#define NS_PLUGIN_EVENT_START 3600 #define NS_PLUGIN_EVENT_START 3600
@ -1697,19 +1698,20 @@ public:
nsSimpleGestureEvent(bool isTrusted, PRUint32 msg, nsIWidget* w, nsSimpleGestureEvent(bool isTrusted, PRUint32 msg, nsIWidget* w,
PRUint32 directionArg, PRFloat64 deltaArg) PRUint32 directionArg, PRFloat64 deltaArg)
: nsMouseEvent_base(isTrusted, msg, w, NS_SIMPLE_GESTURE_EVENT), : nsMouseEvent_base(isTrusted, msg, w, NS_SIMPLE_GESTURE_EVENT),
direction(directionArg), delta(deltaArg) direction(directionArg), delta(deltaArg), clickCount(0)
{ {
} }
nsSimpleGestureEvent(const nsSimpleGestureEvent& other) nsSimpleGestureEvent(const nsSimpleGestureEvent& other)
: nsMouseEvent_base((other.flags & NS_EVENT_FLAG_TRUSTED) != 0, : nsMouseEvent_base((other.flags & NS_EVENT_FLAG_TRUSTED) != 0,
other.message, other.widget, NS_SIMPLE_GESTURE_EVENT), other.message, other.widget, NS_SIMPLE_GESTURE_EVENT),
direction(other.direction), delta(other.delta) direction(other.direction), delta(other.delta), clickCount(0)
{ {
} }
PRUint32 direction; // See nsIDOMSimpleGestureEvent for values PRUint32 direction; // See nsIDOMSimpleGestureEvent for values
PRFloat64 delta; // Delta for magnify and rotate events PRFloat64 delta; // Delta for magnify and rotate events
PRUint32 clickCount; // The number of taps for tap events
}; };
class nsTransitionEvent : public nsEvent class nsTransitionEvent : public nsEvent

Просмотреть файл

@ -390,6 +390,7 @@ nsWinGesture::ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, nsS
// Normally maps to "restore" from whatever you may have recently changed. A simple // Normally maps to "restore" from whatever you may have recently changed. A simple
// double click. // double click.
evt.message = NS_SIMPLE_GESTURE_TAP; evt.message = NS_SIMPLE_GESTURE_TAP;
evt.clickCount = 1;
} }
break; break;
@ -397,6 +398,7 @@ nsWinGesture::ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, nsS
{ {
// Two finger right click. Defaults to right click if it falls through. // Two finger right click. Defaults to right click if it falls through.
evt.message = NS_SIMPLE_GESTURE_PRESSTAP; evt.message = NS_SIMPLE_GESTURE_PRESSTAP;
evt.clickCount = 1;
} }
break; break;
} }