diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index f9c78354c071..1d6f2c88647b 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -23,6 +23,7 @@ using struct gfxMatrix from "gfxMatrix.h"; using struct gfxSize from "gfxPoint.h"; using CSSRect from "Units.h"; using struct mozilla::layers::FrameMetrics from "FrameMetrics.h"; +using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h"; using FrameMetrics::ViewID from "FrameMetrics.h"; using mozilla::layout::ScrollingBehavior from "mozilla/layout/RenderFrameUtils.h"; using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; @@ -285,7 +286,7 @@ parent: * batched and only processed for panning and zooming if content does not * preventDefault. */ - ContentReceivedTouch(bool aPreventDefault); + ContentReceivedTouch(ScrollableLayerGuid aGuid, bool aPreventDefault); /** * Updates the parent's zoom constraints for this tab. The zoom controller @@ -373,10 +374,10 @@ child: RealMouseEvent(WidgetMouseEvent event); RealKeyEvent(WidgetKeyboardEvent event); MouseWheelEvent(WidgetWheelEvent event); - RealTouchEvent(WidgetTouchEvent event); + RealTouchEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid); // We use a separate message for touchmove events only to apply // compression to them. - RealTouchMoveEvent(WidgetTouchEvent event) compress; + RealTouchMoveEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid) compress; /** * @see nsIDOMWindowUtils sendKeyEvent. diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index f1e98edaef48..0e35d08f565b 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -1867,7 +1867,8 @@ TabChild::CancelTapTracking() } bool -TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent) +TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent, + const ScrollableLayerGuid& aGuid) { WidgetTouchEvent localEvent(aEvent); nsEventStatus status = DispatchWidgetEvent(localEvent); @@ -1877,7 +1878,7 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent) nsCOMPtr innerWindow = outerWindow->GetCurrentInnerWindow(); if (innerWindow && innerWindow->HasTouchEventListeners()) { - SendContentReceivedTouch(nsIPresShell::gPreventMouseEvents); + SendContentReceivedTouch(aGuid, nsIPresShell::gPreventMouseEvents); } } else { UpdateTapState(aEvent, status); @@ -1887,9 +1888,10 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent) } bool -TabChild::RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent) +TabChild::RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, + const ScrollableLayerGuid& aGuid) { - return RecvRealTouchEvent(aEvent); + return RecvRealTouchEvent(aEvent, aGuid); } bool diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 5943b4487c41..0202ac5581b4 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -229,8 +229,10 @@ public: virtual bool RecvRealMouseEvent(const mozilla::WidgetMouseEvent& event); virtual bool RecvRealKeyEvent(const mozilla::WidgetKeyboardEvent& event); virtual bool RecvMouseWheelEvent(const mozilla::WidgetWheelEvent& event); - virtual bool RecvRealTouchEvent(const WidgetTouchEvent& event); - virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& event); + virtual bool RecvRealTouchEvent(const WidgetTouchEvent& aEvent, + const ScrollableLayerGuid& aGuid); + virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, + const ScrollableLayerGuid& aGuid); virtual bool RecvKeyEvent(const nsString& aType, const int32_t& aKeyCode, const int32_t& aCharCode, diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index e4b7d9fdf3d3..4bbb8771eeac 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -649,7 +649,7 @@ bool TabParent::SendRealMouseEvent(WidgetMouseEvent& event) return false; } WidgetMouseEvent e(event); - MaybeForwardEventToRenderFrame(event, &e); + MaybeForwardEventToRenderFrame(event, nullptr, &e); if (!MapEventCoordinatesForChildProcess(&e)) { return false; } @@ -662,7 +662,7 @@ bool TabParent::SendMouseWheelEvent(WidgetWheelEvent& event) return false; } WidgetWheelEvent e(event); - MaybeForwardEventToRenderFrame(event, &e); + MaybeForwardEventToRenderFrame(event, nullptr, &e); if (!MapEventCoordinatesForChildProcess(&e)) { return false; } @@ -675,7 +675,7 @@ bool TabParent::SendRealKeyEvent(WidgetKeyboardEvent& event) return false; } WidgetKeyboardEvent e(event); - MaybeForwardEventToRenderFrame(event, &e); + MaybeForwardEventToRenderFrame(event, nullptr, &e); if (!MapEventCoordinatesForChildProcess(&e)) { return false; } @@ -720,13 +720,14 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event) } } - MaybeForwardEventToRenderFrame(event, &e); + ScrollableLayerGuid guid; + MaybeForwardEventToRenderFrame(event, &guid, &e); MapEventCoordinatesForChildProcess(mChildProcessOffsetAtTouchStart, &e); return (e.message == NS_TOUCH_MOVE) ? - PBrowserParent::SendRealTouchMoveEvent(e) : - PBrowserParent::SendRealTouchEvent(e); + PBrowserParent::SendRealTouchMoveEvent(e, guid) : + PBrowserParent::SendRealTouchEvent(e, guid); } /*static*/ TabParent* @@ -1576,10 +1577,11 @@ TabParent::UseAsyncPanZoom() void TabParent::MaybeForwardEventToRenderFrame(const WidgetInputEvent& aEvent, + ScrollableLayerGuid* aOutTargetGuid, WidgetInputEvent* aOutEvent) { if (RenderFrameParent* rfp = GetRenderFrame()) { - rfp->NotifyInputEvent(aEvent, aOutEvent); + rfp->NotifyInputEvent(aEvent, aOutTargetGuid, aOutEvent); } } @@ -1646,10 +1648,11 @@ TabParent::RecvUpdateScrollOffset(const uint32_t& aPresShellId, } bool -TabParent::RecvContentReceivedTouch(const bool& aPreventDefault) +TabParent::RecvContentReceivedTouch(const ScrollableLayerGuid& aGuid, + const bool& aPreventDefault) { if (RenderFrameParent* rfp = GetRenderFrame()) { - rfp->ContentReceivedTouch(aPreventDefault); + rfp->ContentReceivedTouch(aGuid, aPreventDefault); } return true; } diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index abbc59d83686..eb681696d98c 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -169,7 +169,8 @@ public: const CSSToScreenScale& aMinZoom, const CSSToScreenScale& aMaxZoom); virtual bool RecvUpdateScrollOffset(const uint32_t& aPresShellId, const ViewID& aViewId, const CSSIntPoint& aScrollOffset); - virtual bool RecvContentReceivedTouch(const bool& aPreventDefault); + virtual bool RecvContentReceivedTouch(const ScrollableLayerGuid& aGuid, + const bool& aPreventDefault); virtual bool RecvRecordingDeviceEvents(const nsString& aRecordingStatus, const bool& aIsAudio, const bool& aIsVideo); @@ -345,8 +346,11 @@ private: // If we have a render frame currently, notify it that we're about // to dispatch |aEvent| to our child. If there's a relevant // transform in place, |aOutEvent| is the transformed |aEvent| to - // dispatch to content. + // dispatch to content. |aOutTargetGuid| will contain the identifier + // of the APZC instance that handled the event. aOutTargetGuid may be + // null but aOutEvent must not be. void MaybeForwardEventToRenderFrame(const WidgetInputEvent& aEvent, + ScrollableLayerGuid* aOutTargetGuid, WidgetInputEvent* aOutEvent); // The offset for the child process which is sampled at touch start. This // means that the touch events are relative to where the frame was at the diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index ee6d391cdaed..2baf7a82f4c3 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -660,6 +660,26 @@ struct ParamTraits mozilla::gfx::FORMAT_UNKNOWN> {}; +template <> +struct ParamTraits +{ + typedef mozilla::layers::ScrollableLayerGuid paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.mLayersId); + WriteParam(aMsg, aParam.mPresShellId); + WriteParam(aMsg, aParam.mScrollId); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + return (ReadParam(aMsg, aIter, &aResult->mLayersId) && + ReadParam(aMsg, aIter, &aResult->mPresShellId) && + ReadParam(aMsg, aIter, &aResult->mScrollId)); + } +}; + } /* namespace IPC */ #endif /* __GFXMESSAGEUTILS_H__ */ diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index b3cfc76a3501..109d18e17adc 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -827,10 +827,11 @@ RenderFrameParent::OwnerContentChanged(nsIContent* aContent) void RenderFrameParent::NotifyInputEvent(const WidgetInputEvent& aEvent, + ScrollableLayerGuid* aOutTargetGuid, WidgetInputEvent* aOutEvent) { if (GetApzcTreeManager()) { - GetApzcTreeManager()->ReceiveInputEvent(aEvent, nullptr, aOutEvent); + GetApzcTreeManager()->ReceiveInputEvent(aEvent, aOutTargetGuid, aOutEvent); } } @@ -1011,11 +1012,11 @@ RenderFrameParent::ZoomToRect(uint32_t aPresShellId, ViewID aViewId, } void -RenderFrameParent::ContentReceivedTouch(bool aPreventDefault) +RenderFrameParent::ContentReceivedTouch(const ScrollableLayerGuid& aGuid, + bool aPreventDefault) { if (GetApzcTreeManager()) { - GetApzcTreeManager()->ContentReceivedTouch(ScrollableLayerGuid(mLayersId), - aPreventDefault); + GetApzcTreeManager()->ContentReceivedTouch(aGuid, aPreventDefault); } } diff --git a/layout/ipc/RenderFrameParent.h b/layout/ipc/RenderFrameParent.h index 8979c959015e..f2d18fb5dd1d 100644 --- a/layout/ipc/RenderFrameParent.h +++ b/layout/ipc/RenderFrameParent.h @@ -30,6 +30,7 @@ class GestureEventListener; class TargetConfig; class LayerTransactionParent; struct TextureFactoryIdentifier; +struct ScrollableLayerGuid; } namespace layout { @@ -47,6 +48,7 @@ class RenderFrameParent : public PRenderFrameParent, typedef mozilla::layers::LayerTransactionParent LayerTransactionParent; typedef mozilla::FrameLayerBuilder::ContainerParameters ContainerParameters; typedef mozilla::layers::TextureFactoryIdentifier TextureFactoryIdentifier; + typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; typedef FrameMetrics::ViewID ViewID; public: @@ -93,14 +95,25 @@ public: void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); }; + /** + * Notify the APZ code of an input event, and get back the untransformed event. + * @param aOutTargetGuid An out-parameter that will contain the identifier + * of the APZC instance that handled the event, if one was found. This + * argument may be null. + * @param aOutEvent An out-parameter that contains aEvent with the async transforms + * unapplied. This can be passed to Gecko for hit testing and normal event + * dispatch. This argument may not be null. + */ void NotifyInputEvent(const WidgetInputEvent& aEvent, + ScrollableLayerGuid* aOutTargetGuid, WidgetInputEvent* aOutEvent); void NotifyDimensionsChanged(ScreenIntSize size); void ZoomToRect(uint32_t aPresShellId, ViewID aViewId, const CSSRect& aRect); - void ContentReceivedTouch(bool aPreventDefault); + void ContentReceivedTouch(const ScrollableLayerGuid& aGuid, + bool aPreventDefault); void UpdateZoomConstraints(bool aAllowZoom, const CSSToScreenScale& aMinZoom,