Bug 987718 - Part 4: Send MOZ_LONGTAP event when long tap fired; r=bugs

This commit is contained in:
Morris Tseng 2014-06-04 22:56:00 +02:00
parent 89567c331d
commit 4ef0876bc3
3 changed files with 20 additions and 2 deletions

View File

@ -479,7 +479,7 @@ TabChildBase::DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
nsIWidget* aWidget)
{
MOZ_ASSERT(aMsg == NS_MOUSE_MOVE || aMsg == NS_MOUSE_BUTTON_DOWN ||
aMsg == NS_MOUSE_BUTTON_UP);
aMsg == NS_MOUSE_BUTTON_UP || aMsg == NS_MOUSE_MOZLONGTAP);
WidgetMouseEvent event(true, aMsg, nullptr,
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
@ -691,6 +691,7 @@ TabChild::TabChild(ContentChild* aManager, const TabContext& aContext, uint32_t
, mOrientation(eScreenOrientation_PortraitPrimary)
, mUpdateHitRegion(false)
, mContextMenuHandled(false)
, mLongTapEventHandled(false)
, mWaitingTouchListeners(false)
, mIgnoreKeyPressEvent(false)
, mActiveElementManager(new ActiveElementManager())
@ -1739,7 +1740,17 @@ TabChild::RecvHandleLongTap(const CSSPoint& aPoint, const ScrollableLayerGuid& a
2, 1, 0, false,
nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);
SendContentReceivedTouch(aGuid, mContextMenuHandled);
// If no one handle context menu, fire MOZLONGTAP event
if (!mContextMenuHandled) {
LayoutDevicePoint currentPoint =
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid) * mWidget->GetDefaultScale();
int time = 0;
nsEventStatus status =
DispatchSynthesizedMouseEvent(NS_MOUSE_MOZLONGTAP, time, currentPoint, mWidget);
mLongTapEventHandled = (status == nsEventStatus_eConsumeNoDefault);
}
SendContentReceivedTouch(aGuid, mContextMenuHandled || mLongTapEventHandled);
return true;
}
@ -1752,6 +1763,11 @@ TabChild::RecvHandleLongTapUp(const CSSPoint& aPoint, const ScrollableLayerGuid&
return true;
}
if (mLongTapEventHandled) {
mLongTapEventHandled = false;
return true;
}
RecvHandleSingleTap(aPoint, aGuid);
return true;
}

View File

@ -561,6 +561,7 @@ private:
ScreenOrientation mOrientation;
bool mUpdateHitRegion;
bool mContextMenuHandled;
bool mLongTapEventHandled;
bool mWaitingTouchListeners;
void FireSingleTapEvent(LayoutDevicePoint aPoint);

View File

@ -136,6 +136,7 @@ enum nsEventStructType
#define NS_MOUSE_MOZHITTEST (NS_MOUSE_MESSAGE_START + 33)
#define NS_MOUSEENTER (NS_MOUSE_MESSAGE_START + 34)
#define NS_MOUSELEAVE (NS_MOUSE_MESSAGE_START + 35)
#define NS_MOUSE_MOZLONGTAP (NS_MOUSE_MESSAGE_START + 36)
// Pointer spec events
#define NS_POINTER_EVENT_START 4400