Bug 964421 - Add a mechanism to HandleLongTap(Up) to allow content to preventDefault touches and stop panning while long tapping. r=kats

This commit is contained in:
Doug Sherk
2014-02-07 18:13:50 +01:00
parent dc5ac15933
commit 8837bb44bf
15 changed files with 182 additions and 92 deletions

View File

@@ -356,21 +356,21 @@ child:
* the scroll offset. This message is expected to round-trip back to * the scroll offset. This message is expected to round-trip back to
* ZoomToRect() with a rect indicating where we should zoom to. * ZoomToRect() with a rect indicating where we should zoom to.
*/ */
HandleDoubleTap(CSSIntPoint point); HandleDoubleTap(CSSIntPoint point, ScrollableLayerGuid aGuid);
/** /**
* Requests handling of a single tap. |point| is in CSS pixels, relative to * Requests handling of a single tap. |point| is in CSS pixels, relative to
* the scroll offset. This message is expected to send a "mousedown" and * the scroll offset. This message is expected to send a "mousedown" and
* "mouseup" series of events at this point. * "mouseup" series of events at this point.
*/ */
HandleSingleTap(CSSIntPoint point); HandleSingleTap(CSSIntPoint point, ScrollableLayerGuid aGuid);
/** /**
* Requests handling of a long tap. |point| is in CSS pixels, relative to * Requests handling of a long tap. |point| is in CSS pixels, relative to
* the scroll offset. This message is expected to send a "contextmenu" * the scroll offset. This message is expected to send a "contextmenu"
* events at this point. * events at this point.
*/ */
HandleLongTap(CSSIntPoint point); HandleLongTap(CSSIntPoint point, ScrollableLayerGuid aGuid);
/** /**
* Requests handling of releasing a long tap. |aPoint| is in CSS pixels, * Requests handling of releasing a long tap. |aPoint| is in CSS pixels,
@@ -379,7 +379,7 @@ child:
* this message is expected to generate a "mousedown" and "mouseup" * this message is expected to generate a "mousedown" and "mouseup"
* series of events * series of events
*/ */
HandleLongTapUp(CSSIntPoint point); HandleLongTapUp(CSSIntPoint point, ScrollableLayerGuid aGuid);
/** /**
* Notifies the child that the parent has begun or finished transforming * Notifies the child that the parent has begun or finished transforming

View File

@@ -1592,7 +1592,7 @@ TabChild::ProcessUpdateFrame(const FrameMetrics& aFrameMetrics)
} }
bool bool
TabChild::RecvHandleDoubleTap(const CSSIntPoint& aPoint) TabChild::RecvHandleDoubleTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid)
{ {
if (!mGlobal || !mTabChildGlobal) { if (!mGlobal || !mTabChildGlobal) {
return true; return true;
@@ -1609,7 +1609,7 @@ TabChild::RecvHandleDoubleTap(const CSSIntPoint& aPoint)
} }
bool bool
TabChild::RecvHandleSingleTap(const CSSIntPoint& aPoint) TabChild::RecvHandleSingleTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid)
{ {
if (!mGlobal || !mTabChildGlobal) { if (!mGlobal || !mTabChildGlobal) {
return true; return true;
@@ -1626,7 +1626,7 @@ TabChild::RecvHandleSingleTap(const CSSIntPoint& aPoint)
} }
bool bool
TabChild::RecvHandleLongTap(const CSSIntPoint& aPoint) TabChild::RecvHandleLongTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid)
{ {
if (!mGlobal || !mTabChildGlobal) { if (!mGlobal || !mTabChildGlobal) {
return true; return true;
@@ -1636,18 +1636,20 @@ TabChild::RecvHandleLongTap(const CSSIntPoint& aPoint)
DispatchMouseEvent(NS_LITERAL_STRING("contextmenu"), aPoint, 2, 1, 0, false, DispatchMouseEvent(NS_LITERAL_STRING("contextmenu"), aPoint, 2, 1, 0, false,
nsIDOMMouseEvent::MOZ_SOURCE_TOUCH); nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);
SendContentReceivedTouch(aGuid, mContextMenuHandled);
return true; return true;
} }
bool bool
TabChild::RecvHandleLongTapUp(const CSSIntPoint& aPoint) TabChild::RecvHandleLongTapUp(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid)
{ {
if (mContextMenuHandled) { if (mContextMenuHandled) {
mContextMenuHandled = false; mContextMenuHandled = false;
return true; return true;
} }
RecvHandleSingleTap(aPoint); RecvHandleSingleTap(aPoint, aGuid);
return true; return true;
} }

View File

@@ -222,10 +222,14 @@ public:
virtual bool RecvUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE; virtual bool RecvUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;
virtual bool RecvAcknowledgeScrollUpdate(const ViewID& aScrollId, virtual bool RecvAcknowledgeScrollUpdate(const ViewID& aScrollId,
const uint32_t& aScrollGeneration) MOZ_OVERRIDE; const uint32_t& aScrollGeneration) MOZ_OVERRIDE;
virtual bool RecvHandleDoubleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE; virtual bool RecvHandleDoubleTap(const CSSIntPoint& aPoint,
virtual bool RecvHandleSingleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE; const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
virtual bool RecvHandleLongTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE; virtual bool RecvHandleSingleTap(const CSSIntPoint& aPoint,
virtual bool RecvHandleLongTapUp(const CSSIntPoint& aPoint) MOZ_OVERRIDE; const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
virtual bool RecvHandleLongTap(const CSSIntPoint& aPoint,
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
virtual bool RecvHandleLongTapUp(const CSSIntPoint& aPoint,
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
virtual bool RecvNotifyTransformBegin(const ViewID& aViewId) MOZ_OVERRIDE; virtual bool RecvNotifyTransformBegin(const ViewID& aViewId) MOZ_OVERRIDE;
virtual bool RecvNotifyTransformEnd(const ViewID& aViewId) MOZ_OVERRIDE; virtual bool RecvNotifyTransformEnd(const ViewID& aViewId) MOZ_OVERRIDE;
virtual bool RecvActivate() MOZ_OVERRIDE; virtual bool RecvActivate() MOZ_OVERRIDE;

View File

@@ -514,32 +514,40 @@ TabParent::AcknowledgeScrollUpdate(const ViewID& aScrollId, const uint32_t& aScr
} }
} }
void TabParent::HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers) void TabParent::HandleDoubleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid &aGuid)
{ {
if (!mIsDestroyed) { if (!mIsDestroyed) {
unused << SendHandleDoubleTap(aPoint); unused << SendHandleDoubleTap(aPoint, aGuid);
} }
} }
void TabParent::HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers) void TabParent::HandleSingleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid &aGuid)
{ {
// TODO Send the modifier data to TabChild for use in mouse events. // TODO Send the modifier data to TabChild for use in mouse events.
if (!mIsDestroyed) { if (!mIsDestroyed) {
unused << SendHandleSingleTap(aPoint); unused << SendHandleSingleTap(aPoint, aGuid);
} }
} }
void TabParent::HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers) void TabParent::HandleLongTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid &aGuid)
{ {
if (!mIsDestroyed) { if (!mIsDestroyed) {
unused << SendHandleLongTap(aPoint); unused << SendHandleLongTap(aPoint, aGuid);
} }
} }
void TabParent::HandleLongTapUp(const CSSIntPoint& aPoint, int32_t aModifiers) void TabParent::HandleLongTapUp(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid &aGuid)
{ {
if (!mIsDestroyed) { if (!mIsDestroyed) {
unused << SendHandleLongTapUp(aPoint); unused << SendHandleLongTapUp(aPoint, aGuid);
} }
} }
@@ -717,40 +725,40 @@ CSSIntPoint TabParent::AdjustTapToChildWidget(const CSSIntPoint& aPoint)
aPoint.y + presContext->DevPixelsToIntCSSPixels(mChildProcessOffsetAtTouchStart.y)); aPoint.y + presContext->DevPixelsToIntCSSPixels(mChildProcessOffsetAtTouchStart.y));
} }
bool TabParent::SendHandleSingleTap(const CSSIntPoint& aPoint) bool TabParent::SendHandleSingleTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid)
{ {
if (mIsDestroyed) { if (mIsDestroyed) {
return false; return false;
} }
return PBrowserParent::SendHandleSingleTap(AdjustTapToChildWidget(aPoint)); return PBrowserParent::SendHandleSingleTap(AdjustTapToChildWidget(aPoint), aGuid);
} }
bool TabParent::SendHandleLongTap(const CSSIntPoint& aPoint) bool TabParent::SendHandleLongTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid)
{ {
if (mIsDestroyed) { if (mIsDestroyed) {
return false; return false;
} }
return PBrowserParent::SendHandleLongTap(AdjustTapToChildWidget(aPoint)); return PBrowserParent::SendHandleLongTap(AdjustTapToChildWidget(aPoint), aGuid);
} }
bool TabParent::SendHandleLongTapUp(const CSSIntPoint& aPoint) bool TabParent::SendHandleLongTapUp(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid)
{ {
if (mIsDestroyed) { if (mIsDestroyed) {
return false; return false;
} }
return PBrowserParent::SendHandleLongTapUp(AdjustTapToChildWidget(aPoint)); return PBrowserParent::SendHandleLongTapUp(AdjustTapToChildWidget(aPoint), aGuid);
} }
bool TabParent::SendHandleDoubleTap(const CSSIntPoint& aPoint) bool TabParent::SendHandleDoubleTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid)
{ {
if (mIsDestroyed) { if (mIsDestroyed) {
return false; return false;
} }
return PBrowserParent::SendHandleDoubleTap(AdjustTapToChildWidget(aPoint)); return PBrowserParent::SendHandleDoubleTap(AdjustTapToChildWidget(aPoint), aGuid);
} }
bool TabParent::SendMouseWheelEvent(WidgetWheelEvent& event) bool TabParent::SendMouseWheelEvent(WidgetWheelEvent& event)

View File

@@ -207,10 +207,18 @@ public:
void UpdateDimensions(const nsRect& rect, const nsIntSize& size); void UpdateDimensions(const nsRect& rect, const nsIntSize& size);
void UpdateFrame(const layers::FrameMetrics& aFrameMetrics); void UpdateFrame(const layers::FrameMetrics& aFrameMetrics);
void AcknowledgeScrollUpdate(const ViewID& aScrollId, const uint32_t& aScrollGeneration); void AcknowledgeScrollUpdate(const ViewID& aScrollId, const uint32_t& aScrollGeneration);
void HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers); void HandleDoubleTap(const CSSIntPoint& aPoint,
void HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers); int32_t aModifiers,
void HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers); const ScrollableLayerGuid& aGuid);
void HandleLongTapUp(const CSSIntPoint& aPoint, int32_t aModifiers); void HandleSingleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid);
void HandleLongTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid);
void HandleLongTapUp(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid);
void NotifyTransformBegin(ViewID aViewId); void NotifyTransformBegin(ViewID aViewId);
void NotifyTransformEnd(ViewID aViewId); void NotifyTransformEnd(ViewID aViewId);
void Activate(); void Activate();
@@ -230,10 +238,10 @@ public:
bool SendMouseWheelEvent(mozilla::WidgetWheelEvent& event); bool SendMouseWheelEvent(mozilla::WidgetWheelEvent& event);
bool SendRealKeyEvent(mozilla::WidgetKeyboardEvent& event); bool SendRealKeyEvent(mozilla::WidgetKeyboardEvent& event);
bool SendRealTouchEvent(WidgetTouchEvent& event); bool SendRealTouchEvent(WidgetTouchEvent& event);
bool SendHandleSingleTap(const CSSIntPoint& aPoint); bool SendHandleSingleTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid);
bool SendHandleLongTap(const CSSIntPoint& aPoint); bool SendHandleLongTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid);
bool SendHandleLongTapUp(const CSSIntPoint& aPoint); bool SendHandleLongTapUp(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid);
bool SendHandleDoubleTap(const CSSIntPoint& aPoint); bool SendHandleDoubleTap(const CSSIntPoint& aPoint, const ScrollableLayerGuid& aGuid);
virtual PDocumentRendererParent* virtual PDocumentRendererParent*
AllocPDocumentRendererParent(const nsRect& documentRect, AllocPDocumentRendererParent(const nsRect& documentRect,

View File

@@ -559,12 +559,7 @@ nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent)
const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput(); const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput();
mTouchQueue.AppendElement(multiTouchInput); mTouchQueue.AppendElement(multiTouchInput);
if (!mContentResponseTimeoutTask) { SetContentResponseTimer();
mContentResponseTimeoutTask =
NewRunnableMethod(this, &AsyncPanZoomController::TimeoutContentResponse);
PostDelayedTask(mContentResponseTimeoutTask, gContentResponseTimeout);
}
} }
return nsEventStatus_eIgnore; return nsEventStatus_eIgnore;
} }
@@ -936,7 +931,9 @@ nsEventStatus AsyncPanZoomController::OnLongPress(const TapGestureInput& aEvent)
int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers); int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers);
CSSIntPoint geckoScreenPoint; CSSIntPoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) { if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
controller->HandleLongTap(geckoScreenPoint, modifiers); SetState(WAITING_CONTENT_RESPONSE);
SetContentResponseTimer();
controller->HandleLongTap(geckoScreenPoint, modifiers, GetGuid());
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
} }
} }
@@ -950,7 +947,7 @@ nsEventStatus AsyncPanZoomController::OnLongPressUp(const TapGestureInput& aEven
int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers); int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers);
CSSIntPoint geckoScreenPoint; CSSIntPoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) { if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
controller->HandleLongTapUp(geckoScreenPoint, modifiers); controller->HandleLongTapUp(geckoScreenPoint, modifiers, GetGuid());
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
} }
} }
@@ -966,7 +963,7 @@ nsEventStatus AsyncPanZoomController::OnSingleTapUp(const TapGestureInput& aEven
int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers); int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers);
CSSIntPoint geckoScreenPoint; CSSIntPoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) { if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
controller->HandleSingleTap(geckoScreenPoint, modifiers); controller->HandleSingleTap(geckoScreenPoint, modifiers, GetGuid());
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
} }
} }
@@ -980,7 +977,7 @@ nsEventStatus AsyncPanZoomController::OnSingleTapConfirmed(const TapGestureInput
int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers); int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers);
CSSIntPoint geckoScreenPoint; CSSIntPoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) { if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
controller->HandleSingleTap(geckoScreenPoint, modifiers); controller->HandleSingleTap(geckoScreenPoint, modifiers, GetGuid());
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
} }
} }
@@ -995,7 +992,7 @@ nsEventStatus AsyncPanZoomController::OnDoubleTap(const TapGestureInput& aEvent)
int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers); int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers);
CSSIntPoint geckoScreenPoint; CSSIntPoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) { if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
controller->HandleDoubleTap(geckoScreenPoint, modifiers); controller->HandleDoubleTap(geckoScreenPoint, modifiers, GetGuid());
} }
} }
@@ -1929,6 +1926,15 @@ bool AsyncPanZoomController::AllowZoom() {
&& !(mFrameMetrics.GetDisableScrollingX() || mFrameMetrics.GetDisableScrollingY()); && !(mFrameMetrics.GetDisableScrollingX() || mFrameMetrics.GetDisableScrollingY());
} }
void AsyncPanZoomController::SetContentResponseTimer() {
if (!mContentResponseTimeoutTask) {
mContentResponseTimeoutTask =
NewRunnableMethod(this, &AsyncPanZoomController::TimeoutContentResponse);
PostDelayedTask(mContentResponseTimeoutTask, gContentResponseTimeout);
}
}
void AsyncPanZoomController::TimeoutContentResponse() { void AsyncPanZoomController::TimeoutContentResponse() {
mContentResponseTimeoutTask = nullptr; mContentResponseTimeoutTask = nullptr;
ContentReceivedTouch(false); ContentReceivedTouch(false);

View File

@@ -508,6 +508,15 @@ protected:
*/ */
const FrameMetrics& GetFrameMetrics(); const FrameMetrics& GetFrameMetrics();
/**
* Sets the timer for content response to a series of touch events, if it
* hasn't been already. This is to prevent us from batching up touch events
* indefinitely in the case that content doesn't respond with whether or not
* it wants to preventDefault. When the timer is fired, the touch event queue
* will be flushed.
*/
void SetContentResponseTimer();
/** /**
* Timeout function for content response. This should be called on a timer * Timeout function for content response. This should be called on a timer
* after we get our first touch event in a batch, under the condition that we * after we get our first touch event in a batch, under the condition that we

View File

@@ -42,27 +42,35 @@ public:
* AsyncPanZoomController::ZoomToRect with the dimensions that we want to zoom * AsyncPanZoomController::ZoomToRect with the dimensions that we want to zoom
* to. * to.
*/ */
virtual void HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers) = 0; virtual void HandleDoubleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid) = 0;
/** /**
* Requests handling a single tap. |aPoint| is in CSS pixels, relative to the * Requests handling a single tap. |aPoint| is in CSS pixels, relative to the
* current scroll offset. This should simulate and send to content a mouse * current scroll offset. This should simulate and send to content a mouse
* button down, then mouse button up at |aPoint|. * button down, then mouse button up at |aPoint|.
*/ */
virtual void HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers) = 0; virtual void HandleSingleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid) = 0;
/** /**
* Requests handling a long tap. |aPoint| is in CSS pixels, relative to the * Requests handling a long tap. |aPoint| is in CSS pixels, relative to the
* current scroll offset. * current scroll offset.
*/ */
virtual void HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers) = 0; virtual void HandleLongTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid) = 0;
/** /**
* Requests handling of releasing a long tap. |aPoint| is in CSS pixels, * Requests handling of releasing a long tap. |aPoint| is in CSS pixels,
* relative to the current scroll offset. HandleLongTapUp will always be * relative to the current scroll offset. HandleLongTapUp will always be
* preceeded by HandleLongTap * preceeded by HandleLongTap
*/ */
virtual void HandleLongTapUp(const CSSIntPoint& aPoint, int32_t aModifiers) = 0; virtual void HandleLongTapUp(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid) = 0;
/** /**
* Requests sending a mozbrowserasyncscroll domevent to embedder. * Requests sending a mozbrowserasyncscroll domevent to embedder.

View File

@@ -31,10 +31,10 @@ class MockContentController : public GeckoContentController {
public: public:
MOCK_METHOD1(RequestContentRepaint, void(const FrameMetrics&)); MOCK_METHOD1(RequestContentRepaint, void(const FrameMetrics&));
MOCK_METHOD2(AcknowledgeScrollUpdate, void(const FrameMetrics::ViewID&, const uint32_t& aScrollGeneration)); MOCK_METHOD2(AcknowledgeScrollUpdate, void(const FrameMetrics::ViewID&, const uint32_t& aScrollGeneration));
MOCK_METHOD2(HandleDoubleTap, void(const CSSIntPoint&, int32_t)); MOCK_METHOD3(HandleDoubleTap, void(const CSSIntPoint&, int32_t, const ScrollableLayerGuid&));
MOCK_METHOD2(HandleSingleTap, void(const CSSIntPoint&, int32_t)); MOCK_METHOD3(HandleSingleTap, void(const CSSIntPoint&, int32_t, const ScrollableLayerGuid&));
MOCK_METHOD2(HandleLongTap, void(const CSSIntPoint&, int32_t)); MOCK_METHOD3(HandleLongTap, void(const CSSIntPoint&, int32_t, const ScrollableLayerGuid&));
MOCK_METHOD2(HandleLongTapUp, void(const CSSIntPoint&, int32_t)); MOCK_METHOD3(HandleLongTapUp, void(const CSSIntPoint&, int32_t, const ScrollableLayerGuid&));
MOCK_METHOD3(SendAsyncScrollDOMEvent, void(bool aIsRoot, const CSSRect &aContentRect, const CSSSize &aScrollableSize)); MOCK_METHOD3(SendAsyncScrollDOMEvent, void(bool aIsRoot, const CSSRect &aContentRect, const CSSSize &aScrollableSize));
MOCK_METHOD2(PostDelayedTask, void(Task* aTask, int aDelayMs)); MOCK_METHOD2(PostDelayedTask, void(Task* aTask, int aDelayMs));
}; };
@@ -596,7 +596,7 @@ TEST(AsyncPanZoomController, ShortPress) {
apzc->NotifyLayersUpdated(TestFrameMetrics(), true); apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
apzc->UpdateZoomConstraints(ZoomConstraints(false, CSSToScreenScale(1.0), CSSToScreenScale(1.0))); apzc->UpdateZoomConstraints(ZoomConstraints(false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
EXPECT_CALL(*mcc, HandleSingleTap(CSSIntPoint(10, 10), 0)).Times(1); EXPECT_CALL(*mcc, HandleSingleTap(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
int time = 0; int time = 0;
nsEventStatus status = ApzcTap(apzc, 10, 10, time, 100); nsEventStatus status = ApzcTap(apzc, 10, 10, time, 100);
@@ -615,7 +615,7 @@ TEST(AsyncPanZoomController, MediumPress) {
apzc->NotifyLayersUpdated(TestFrameMetrics(), true); apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
apzc->UpdateZoomConstraints(ZoomConstraints(false, CSSToScreenScale(1.0), CSSToScreenScale(1.0))); apzc->UpdateZoomConstraints(ZoomConstraints(false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
EXPECT_CALL(*mcc, HandleSingleTap(CSSIntPoint(10, 10), 0)).Times(1); EXPECT_CALL(*mcc, HandleSingleTap(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
int time = 0; int time = 0;
nsEventStatus status = ApzcTap(apzc, 10, 10, time, 400); nsEventStatus status = ApzcTap(apzc, 10, 10, time, 400);
@@ -642,8 +642,8 @@ TEST(AsyncPanZoomController, LongPress) {
Task* t = mcc->GetDelayedTask(); Task* t = mcc->GetDelayedTask();
EXPECT_TRUE(nullptr != t); EXPECT_TRUE(nullptr != t);
EXPECT_CALL(*mcc, HandleLongTap(CSSIntPoint(10, 10), 0)).Times(1); EXPECT_CALL(*mcc, HandleLongTap(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
EXPECT_CALL(*mcc, HandleLongTapUp(CSSIntPoint(10, 10), 0)).Times(1); EXPECT_CALL(*mcc, HandleLongTapUp(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(AtLeast(1)); EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(AtLeast(1));
// Manually invoke the longpress while the touch is currently down. // Manually invoke the longpress while the touch is currently down.

View File

@@ -540,7 +540,8 @@ public:
} }
virtual void HandleDoubleTap(const CSSIntPoint& aPoint, virtual void HandleDoubleTap(const CSSIntPoint& aPoint,
int32_t aModifiers) MOZ_OVERRIDE int32_t aModifiers,
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE
{ {
if (MessageLoop::current() != mUILoop) { if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main // We have to send this message from the "UI thread" (main
@@ -548,17 +549,18 @@ public:
mUILoop->PostTask( mUILoop->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &RemoteContentController::HandleDoubleTap, NewRunnableMethod(this, &RemoteContentController::HandleDoubleTap,
aPoint, aModifiers)); aPoint, aModifiers, aGuid));
return; return;
} }
if (mRenderFrame) { if (mRenderFrame) {
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager()); TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
browser->HandleDoubleTap(aPoint, aModifiers); browser->HandleDoubleTap(aPoint, aModifiers, aGuid);
} }
} }
virtual void HandleSingleTap(const CSSIntPoint& aPoint, virtual void HandleSingleTap(const CSSIntPoint& aPoint,
int32_t aModifiers) MOZ_OVERRIDE int32_t aModifiers,
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE
{ {
if (MessageLoop::current() != mUILoop) { if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main // We have to send this message from the "UI thread" (main
@@ -566,17 +568,18 @@ public:
mUILoop->PostTask( mUILoop->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &RemoteContentController::HandleSingleTap, NewRunnableMethod(this, &RemoteContentController::HandleSingleTap,
aPoint, aModifiers)); aPoint, aModifiers, aGuid));
return; return;
} }
if (mRenderFrame) { if (mRenderFrame) {
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager()); TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
browser->HandleSingleTap(aPoint, aModifiers); browser->HandleSingleTap(aPoint, aModifiers, aGuid);
} }
} }
virtual void HandleLongTap(const CSSIntPoint& aPoint, virtual void HandleLongTap(const CSSIntPoint& aPoint,
int32_t aModifiers) MOZ_OVERRIDE int32_t aModifiers,
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE
{ {
if (MessageLoop::current() != mUILoop) { if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main // We have to send this message from the "UI thread" (main
@@ -584,17 +587,18 @@ public:
mUILoop->PostTask( mUILoop->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &RemoteContentController::HandleLongTap, NewRunnableMethod(this, &RemoteContentController::HandleLongTap,
aPoint, aModifiers)); aPoint, aModifiers, aGuid));
return; return;
} }
if (mRenderFrame) { if (mRenderFrame) {
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager()); TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
browser->HandleLongTap(aPoint, aModifiers); browser->HandleLongTap(aPoint, aModifiers, aGuid);
} }
} }
virtual void HandleLongTapUp(const CSSIntPoint& aPoint, virtual void HandleLongTapUp(const CSSIntPoint& aPoint,
int32_t aModifiers) MOZ_OVERRIDE int32_t aModifiers,
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE
{ {
if (MessageLoop::current() != mUILoop) { if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main // We have to send this message from the "UI thread" (main
@@ -602,12 +606,12 @@ public:
mUILoop->PostTask( mUILoop->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &RemoteContentController::HandleLongTapUp, NewRunnableMethod(this, &RemoteContentController::HandleLongTapUp,
aPoint, aModifiers)); aPoint, aModifiers, aGuid));
return; return;
} }
if (mRenderFrame) { if (mRenderFrame) {
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager()); TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
browser->HandleLongTapUp(aPoint, aModifiers); browser->HandleLongTapUp(aPoint, aModifiers, aGuid);
} }
} }

View File

@@ -1938,7 +1938,9 @@ AndroidBridge::AcknowledgeScrollUpdate(const mozilla::layers::FrameMetrics::View
} }
void void
AndroidBridge::HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers) AndroidBridge::HandleDoubleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid)
{ {
nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", aPoint.x, aPoint.y); nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", aPoint.x, aPoint.y);
nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeBroadcastEvent( nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeBroadcastEvent(
@@ -1946,7 +1948,9 @@ AndroidBridge::HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers)
} }
void void
AndroidBridge::HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers) AndroidBridge::HandleSingleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid)
{ {
// TODO Send the modifier data to Gecko for use in mouse events. // TODO Send the modifier data to Gecko for use in mouse events.
nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", aPoint.x, aPoint.y); nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", aPoint.x, aPoint.y);
@@ -1955,7 +1959,9 @@ AndroidBridge::HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers)
} }
void void
AndroidBridge::HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers) AndroidBridge::HandleLongTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid)
{ {
nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", aPoint.x, aPoint.y); nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", aPoint.x, aPoint.y);
nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeBroadcastEvent( nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeBroadcastEvent(
@@ -1963,7 +1969,9 @@ AndroidBridge::HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers)
} }
void void
AndroidBridge::HandleLongTapUp(const CSSIntPoint& aPoint, int32_t aModifiers) AndroidBridge::HandleLongTapUp(const CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid)
{ {
} }

View File

@@ -433,10 +433,18 @@ public:
void RequestContentRepaint(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE; void RequestContentRepaint(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;
void AcknowledgeScrollUpdate(const mozilla::layers::FrameMetrics::ViewID& aScrollId, void AcknowledgeScrollUpdate(const mozilla::layers::FrameMetrics::ViewID& aScrollId,
const uint32_t& aScrollGeneration) MOZ_OVERRIDE; const uint32_t& aScrollGeneration) MOZ_OVERRIDE;
void HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers) MOZ_OVERRIDE; void HandleDoubleTap(const CSSIntPoint& aPoint,
void HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers) MOZ_OVERRIDE; int32_t aModifiers,
void HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers) MOZ_OVERRIDE; const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
void HandleLongTapUp(const CSSIntPoint& aPoint, int32_t aModifiers) MOZ_OVERRIDE; void HandleSingleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
void HandleLongTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
void HandleLongTapUp(const CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
void SendAsyncScrollDOMEvent(bool aIsRoot, void SendAsyncScrollDOMEvent(bool aIsRoot,
const CSSRect& aContentRect, const CSSRect& aContentRect,
const CSSSize& aScrollableSize) MOZ_OVERRIDE; const CSSSize& aScrollableSize) MOZ_OVERRIDE;

View File

@@ -14,6 +14,7 @@ namespace widget {
class ParentProcessController : public mozilla::layers::GeckoContentController class ParentProcessController : public mozilla::layers::GeckoContentController
{ {
typedef mozilla::layers::FrameMetrics FrameMetrics; typedef mozilla::layers::FrameMetrics FrameMetrics;
typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
public: public:
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE; virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;
@@ -22,10 +23,18 @@ public:
virtual void PostDelayedTask(Task* aTask, int aDelayMs) MOZ_OVERRIDE; virtual void PostDelayedTask(Task* aTask, int aDelayMs) MOZ_OVERRIDE;
// No-ops // No-ops
virtual void HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers) MOZ_OVERRIDE {} virtual void HandleDoubleTap(const CSSIntPoint& aPoint,
virtual void HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers) MOZ_OVERRIDE {} int32_t aModifiers,
virtual void HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers) MOZ_OVERRIDE {} const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {}
virtual void HandleLongTapUp(const CSSIntPoint& aPoint, int32_t aModifiers) MOZ_OVERRIDE {} virtual void HandleSingleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {}
virtual void HandleLongTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {}
virtual void HandleLongTapUp(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {}
virtual void SendAsyncScrollDOMEvent(bool aIsRoot, virtual void SendAsyncScrollDOMEvent(bool aIsRoot,
const CSSRect &aContentRect, const CSSRect &aContentRect,

View File

@@ -244,22 +244,30 @@ APZController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
} }
void void
APZController::HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers) APZController::HandleDoubleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid)
{ {
} }
void void
APZController::HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers) APZController::HandleSingleTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid)
{ {
} }
void void
APZController::HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers) APZController::HandleLongTap(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid)
{ {
} }
void void
APZController::HandleLongTapUp(const CSSIntPoint& aPoint, int32_t aModifiers) APZController::HandleLongTapUp(const CSSIntPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid)
{ {
} }

View File

@@ -34,10 +34,18 @@ public:
// GeckoContentController interface // GeckoContentController interface
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics); virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics);
virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, const uint32_t& aScrollGeneration); virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, const uint32_t& aScrollGeneration);
virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint, int32_t aModifiers); virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint,
virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint, int32_t aModifiers); int32_t aModifiers,
virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint, int32_t aModifiers); const mozilla::layers::ScrollableLayerGuid& aGuid);
virtual void HandleLongTapUp(const mozilla::CSSIntPoint& aPoint, int32_t aModifiers); virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid);
virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid);
virtual void HandleLongTapUp(const mozilla::CSSIntPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid);
virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize); virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
virtual void PostDelayedTask(Task* aTask, int aDelayMs); virtual void PostDelayedTask(Task* aTask, int aDelayMs);
virtual bool GetRootZoomConstraints(ZoomConstraints* aOutConstraints); virtual bool GetRootZoomConstraints(ZoomConstraints* aOutConstraints);