Bug 1299209 - Part 2: Support setting pointerId in nsDOMWindowwUtils and nsContentUtils. f=sshih, r=smaug

--HG--
extra : rebase_source : 46affaf510908e28ad47df2e088574d33aa52be3
This commit is contained in:
Ho-Pang 2016-12-20 23:06:00 -05:00
parent 41adef3ae2
commit 7bc745d410
5 changed files with 30 additions and 7 deletions

View File

@ -8240,6 +8240,7 @@ nsContentUtils::SendMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
bool aIgnoreRootScrollFrame,
float aPressure,
unsigned short aInputSourceArg,
uint32_t aIdentifier,
bool aToWindow,
bool *aPreventDefault,
bool aIsDOMEventSynthesized,
@ -8287,6 +8288,7 @@ nsContentUtils::SendMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
WidgetMouseEvent::eReal,
contextMenuKey ? WidgetMouseEvent::eContextMenuKey :
WidgetMouseEvent::eNormal);
event.pointerId = aIdentifier;
event.mModifiers = GetWidgetModifiers(aModifiers);
event.button = aButton;
event.buttons = aButtons != nsIDOMWindowUtils::MOUSE_BUTTONS_NOT_SPECIFIED ?

View File

@ -2586,6 +2586,7 @@ public:
bool aIgnoreRootScrollFrame,
float aPressure,
unsigned short aInputSourceArg,
uint32_t aIdentifier,
bool aToWindow,
bool *aPreventDefault,
bool aIsDOMEventSynthesized,

View File

@ -642,12 +642,16 @@ nsDOMWindowUtils::SendMouseEvent(const nsAString& aType,
bool aIsDOMEventSynthesized,
bool aIsWidgetEventSynthesized,
int32_t aButtons,
uint32_t aIdentifier,
uint8_t aOptionalArgCount,
bool *aPreventDefault)
{
return SendMouseEventCommon(aType, aX, aY, aButton, aClickCount, aModifiers,
aIgnoreRootScrollFrame, aPressure,
aInputSourceArg, false, aPreventDefault,
aInputSourceArg,
aOptionalArgCount >= 7 ?
aIdentifier : DEFAULT_MOUSE_POINTER_ID,
false, aPreventDefault,
aOptionalArgCount >= 4 ?
aIsDOMEventSynthesized : true,
aOptionalArgCount >= 5 ?
@ -669,6 +673,7 @@ nsDOMWindowUtils::SendMouseEventToWindow(const nsAString& aType,
bool aIsDOMEventSynthesized,
bool aIsWidgetEventSynthesized,
int32_t aButtons,
uint32_t aIdentifier,
uint8_t aOptionalArgCount)
{
PROFILER_LABEL("nsDOMWindowUtils", "SendMouseEventToWindow",
@ -676,7 +681,10 @@ nsDOMWindowUtils::SendMouseEventToWindow(const nsAString& aType,
return SendMouseEventCommon(aType, aX, aY, aButton, aClickCount, aModifiers,
aIgnoreRootScrollFrame, aPressure,
aInputSourceArg, true, nullptr,
aInputSourceArg,
aOptionalArgCount >= 7 ?
aIdentifier : DEFAULT_MOUSE_POINTER_ID,
true, nullptr,
aOptionalArgCount >= 4 ?
aIsDOMEventSynthesized : true,
aOptionalArgCount >= 5 ?
@ -695,6 +703,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
bool aIgnoreRootScrollFrame,
float aPressure,
unsigned short aInputSourceArg,
uint32_t aPointerId,
bool aToWindow,
bool *aPreventDefault,
bool aIsDOMEventSynthesized,
@ -704,8 +713,8 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
return nsContentUtils::SendMouseEvent(presShell, aType, aX, aY, aButton,
aButtons, aClickCount, aModifiers, aIgnoreRootScrollFrame, aPressure,
aInputSourceArg, aToWindow, aPreventDefault, aIsDOMEventSynthesized,
aIsWidgetEventSynthesized);
aInputSourceArg, aPointerId, aToWindow, aPreventDefault,
aIsDOMEventSynthesized, aIsWidgetEventSynthesized);
}
NS_IMETHODIMP

View File

@ -91,6 +91,7 @@ protected:
bool aIgnoreRootScrollFrame,
float aPressure,
unsigned short aInputSourceArg,
uint32_t aIdentifier,
bool aToWindow,
bool *aPreventDefault,
bool aIsDOMEventSynthesized,

View File

@ -322,6 +322,8 @@ interface nsIDOMWindowUtils : nsISupports {
* defaults to true
* @param aIsWidgetEventSynthesized controls WidgetMouseEvent.mReason value
* defaults to false (WidgetMouseEvent::eReal)
* @param aIdentifier A unique identifier for the pointer causing the event,
* defaulting to nsIDOMWindowUtils::DEFAULT_MOUSE_POINTER_ID.
*
* returns true if the page called prevent default on this event
*/
@ -337,7 +339,8 @@ interface nsIDOMWindowUtils : nsISupports {
[optional] in unsigned short aInputSourceArg,
[optional] in boolean aIsDOMEventSynthesized,
[optional] in boolean aIsWidgetEventSynthesized,
[optional] in long aButtons);
[optional] in long aButtons,
[optional] in unsigned long aIdentifier);
/** Synthesize a pointer event. The event types supported are:
@ -372,7 +375,8 @@ interface nsIDOMWindowUtils : nsISupports {
* @param aPressure touch input pressure: 0.0 -> 1.0
* @param aInputSourceArg input source, see nsIDOMMouseEvent for values,
* defaults to mouse input.
* @param aPointerId A unique identifier for the pointer causing the event. default is 0
* @param aPointerId A unique identifier for the pointer causing the event,
* defaulting to nsIDOMWindowUtils::DEFAULT_MOUSE_POINTER_ID.
* @param aWidth The width (magnitude on the X axis), default is 0
* @param aHeight The height (magnitude on the Y axis), default is 0
* @param aTilt The plane angle between the Y-Z plane
@ -458,7 +462,8 @@ interface nsIDOMWindowUtils : nsISupports {
[optional] in unsigned short aInputSourceArg,
[optional] in boolean aIsDOMEventSynthesized,
[optional] in boolean aIsWidgetEventSynthesized,
[optional] in long aButtons);
[optional] in long aButtons,
[optional] in unsigned long aIdentifier);
/** The same as sendPointerEvent but ensures that the event
* is dispatched to this DOM window or one of its children.
@ -1979,6 +1984,11 @@ interface nsIDOMWindowUtils : nsISupports {
*/
boolean isTimeoutTracking(in unsigned long timeoutId);
// These consts are only for testing purposes.
const long DEFAULT_MOUSE_POINTER_ID = 0;
const long DEFAULT_PEN_POINTER_ID = 1;
const long DEFAULT_TOUCH_POINTER_ID = 2;
// Match WidgetMouseEventBase::buttonType.
const long MOUSE_BUTTON_LEFT_BUTTON = 0;
const long MOUSE_BUTTON_MIDDLE_BUTTON = 1;