From 105fbf0346feb1e6956574f0c8500739f1926725 Mon Sep 17 00:00:00 2001 From: Maksim Lebedev Date: Thu, 14 May 2015 08:16:00 -0400 Subject: [PATCH] Bug 1162009 - Add TOUCH_CANCEL sending on e10s. r=kats --- dom/ipc/PBrowser.ipdl | 11 +++++++++-- dom/ipc/TabChild.cpp | 12 +++++++----- dom/ipc/TabChild.h | 6 ++++-- dom/ipc/TabMessageUtils.h | 9 ++++++++- dom/ipc/TabParent.cpp | 15 ++++++++++----- dom/ipc/TabParent.h | 17 ++++++++--------- gfx/layers/apz/util/InputAPZContext.cpp | 13 ++++++++++++- gfx/layers/apz/util/InputAPZContext.h | 15 ++++++++++----- widget/EventForwards.h | 4 +++- widget/nsBaseWidget.cpp | 2 +- 10 files changed, 72 insertions(+), 32 deletions(-) diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 48f010158b9..9121c23f88b 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -60,6 +60,7 @@ using mozilla::layers::TouchBehaviorFlags from "mozilla/layers/APZUtils.h"; using nsIWidget::TouchPointerState from "nsIWidget.h"; using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h"; using struct mozilla::OwningSerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h"; +using nsEventStatus from "mozilla/EventForwards.h"; namespace mozilla { namespace dom { @@ -594,8 +595,14 @@ child: RealMouseButtonEvent(WidgetMouseEvent event); RealKeyEvent(WidgetKeyboardEvent event, MaybeNativeKeyBinding keyBinding); MouseWheelEvent(WidgetWheelEvent event, ScrollableLayerGuid aGuid, uint64_t aInputBlockId); - RealTouchEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid, uint64_t aInputBlockId); - RealTouchMoveEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid, uint64_t aInputBlockId); + RealTouchEvent(WidgetTouchEvent aEvent, + ScrollableLayerGuid aGuid, + uint64_t aInputBlockId, + nsEventStatus aApzResponse); + RealTouchMoveEvent(WidgetTouchEvent aEvent, + ScrollableLayerGuid aGuid, + uint64_t aInputBlockId, + nsEventStatus aApzResponse); RealDragEvent(WidgetDragEvent aEvent, uint32_t aDragAction, uint32_t aDropEffect); /** diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index cc80fa7c2f4..0389bd7d494 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -88,6 +88,7 @@ #include "nsNetUtil.h" #include "nsIPermissionManager.h" #include "nsIScriptError.h" +#include "mozilla/EventForwards.h" #define BROWSER_ELEMENT_CHILD_SCRIPT \ NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") @@ -2379,7 +2380,8 @@ TabChild::GetPresShellResolution() const bool TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId) + const uint64_t& aInputBlockId, + const nsEventStatus& aApzResponse) { TABC_LOG("Receiving touch event of type %d\n", aEvent.message); @@ -2407,17 +2409,17 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent, return true; } - mAPZEventState->ProcessTouchEvent(localEvent, aGuid, aInputBlockId, - nsEventStatus_eIgnore); + mAPZEventState->ProcessTouchEvent(localEvent, aGuid, aInputBlockId, aApzResponse); return true; } bool TabChild::RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId) + const uint64_t& aInputBlockId, + const nsEventStatus& aApzResponse) { - return RecvRealTouchEvent(aEvent, aGuid, aInputBlockId); + return RecvRealTouchEvent(aEvent, aGuid, aInputBlockId, aApzResponse); } bool diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 93901877fd6..ba38d95ddb1 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -363,10 +363,12 @@ public: const uint64_t& aInputBlockId) override; virtual bool RecvRealTouchEvent(const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId) override; + const uint64_t& aInputBlockId, + const nsEventStatus& aApzResponse) override; virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId) override; + const uint64_t& aInputBlockId, + const nsEventStatus& aApzResponse) override; virtual bool RecvKeyEvent(const nsString& aType, const int32_t& aKeyCode, const int32_t& aCharCode, diff --git a/dom/ipc/TabMessageUtils.h b/dom/ipc/TabMessageUtils.h index 4a10f29db8c..adfa04735f7 100644 --- a/dom/ipc/TabMessageUtils.h +++ b/dom/ipc/TabMessageUtils.h @@ -96,7 +96,14 @@ struct ParamTraits mozilla::dom::AUDIO_CHANNEL_STATE_LAST> { }; + +template <> +struct ParamTraits + : public ContiguousEnumSerializer +{ }; + } - #endif diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 50ae35d0d64..a4f5bb8047f 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -1309,7 +1309,7 @@ bool TabParent::SendMouseWheelEvent(WidgetWheelEvent& event) ScrollableLayerGuid guid; uint64_t blockId; - ApzAwareEventRoutingToChild(&guid, &blockId); + ApzAwareEventRoutingToChild(&guid, &blockId, nullptr); event.refPoint += GetChildProcessOffset(); return PBrowserParent::SendMouseWheelEvent(event, guid, blockId); } @@ -1624,7 +1624,8 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event) ScrollableLayerGuid guid; uint64_t blockId; - ApzAwareEventRoutingToChild(&guid, &blockId); + nsEventStatus apzResponse; + ApzAwareEventRoutingToChild(&guid, &blockId, &apzResponse); if (mIsDestroyed) { return false; @@ -1636,8 +1637,8 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event) } return (event.message == NS_TOUCH_MOVE) ? - PBrowserParent::SendRealTouchMoveEvent(event, guid, blockId) : - PBrowserParent::SendRealTouchEvent(event, guid, blockId); + PBrowserParent::SendRealTouchMoveEvent(event, guid, blockId, apzResponse) : + PBrowserParent::SendRealTouchEvent(event, guid, blockId, apzResponse); } bool @@ -2727,7 +2728,8 @@ TabParent::GetWidget() const void TabParent::ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid, - uint64_t* aOutInputBlockId) + uint64_t* aOutInputBlockId, + nsEventStatus* aOutApzResponse) { if (gfxPrefs::AsyncPanZoomEnabled()) { if (aOutTargetGuid) { @@ -2747,6 +2749,9 @@ TabParent::ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid, if (aOutInputBlockId) { *aOutInputBlockId = InputAPZContext::GetInputBlockId(); } + if (aOutApzResponse) { + *aOutApzResponse = InputAPZContext::GetApzResponse(); + } // Let the widget know that the event will be sent to the child process, // which will (hopefully) send a confirmation notice back to APZ. diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 226422f080a..1063e8e8034 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -502,18 +502,17 @@ private: // Update state prior to routing an APZ-aware event to the child process. // |aOutTargetGuid| will contain the identifier - // of the APZC instance that handled the event. aOutTargetGuid may be - // null. + // of the APZC instance that handled the event. aOutTargetGuid may be null. // |aOutInputBlockId| will contain the identifier of the input block - // that this event was added to, if there was one. aOutInputBlockId may - // be null. + // that this event was added to, if there was one. aOutInputBlockId may be null. + // |aOutApzResponse| will contain the response that the APZ gave when processing + // the input block; this is used for generating appropriate pointercancel events. void ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid, - uint64_t* aOutInputBlockId); - // When true, we've initiated normal shutdown and notified our - // managing PContent. + uint64_t* aOutInputBlockId, + nsEventStatus* aOutApzResponse); + // When true, we've initiated normal shutdown and notified our managing PContent. bool mMarkedDestroying; - // When true, the TabParent is invalid and we should not send IPC messages - // anymore. + // When true, the TabParent is invalid and we should not send IPC messages anymore. bool mIsDestroyed; // Whether we have already sent a FileDescriptor for the app package. bool mAppPackageFileDescriptorSent; diff --git a/gfx/layers/apz/util/InputAPZContext.cpp b/gfx/layers/apz/util/InputAPZContext.cpp index 68aa6a46f73..68f35181bb4 100644 --- a/gfx/layers/apz/util/InputAPZContext.cpp +++ b/gfx/layers/apz/util/InputAPZContext.cpp @@ -10,6 +10,7 @@ namespace layers { ScrollableLayerGuid InputAPZContext::sGuid; uint64_t InputAPZContext::sBlockId = 0; +nsEventStatus InputAPZContext::sApzResponse = nsEventStatus_eIgnore; bool InputAPZContext::sRoutedToChildProcess = false; /*static*/ ScrollableLayerGuid @@ -24,6 +25,12 @@ InputAPZContext::GetInputBlockId() return sBlockId; } +/*static*/ nsEventStatus +InputAPZContext::GetApzResponse() +{ + return sApzResponse; +} + /*static*/ void InputAPZContext::SetRoutedToChildProcess() { @@ -31,13 +38,16 @@ InputAPZContext::SetRoutedToChildProcess() } InputAPZContext::InputAPZContext(const ScrollableLayerGuid& aGuid, - const uint64_t& aBlockId) + const uint64_t& aBlockId, + const nsEventStatus& aApzResponse) : mOldGuid(sGuid) , mOldBlockId(sBlockId) + , mOldApzResponse(sApzResponse) , mOldRoutedToChildProcess(sRoutedToChildProcess) { sGuid = aGuid; sBlockId = aBlockId; + sApzResponse = aApzResponse; sRoutedToChildProcess = false; } @@ -45,6 +55,7 @@ InputAPZContext::~InputAPZContext() { sGuid = mOldGuid; sBlockId = mOldBlockId; + sApzResponse = mOldApzResponse; sRoutedToChildProcess = mOldRoutedToChildProcess; } diff --git a/gfx/layers/apz/util/InputAPZContext.h b/gfx/layers/apz/util/InputAPZContext.h index 869066887a7..748907bc000 100644 --- a/gfx/layers/apz/util/InputAPZContext.h +++ b/gfx/layers/apz/util/InputAPZContext.h @@ -7,28 +7,32 @@ #define mozilla_layers_InputAPZContext_h #include "FrameMetrics.h" +#include "mozilla/EventForwards.h" namespace mozilla { namespace layers { -// InputAPZContext is used to communicate the ScrollableLayerGuid and input -// block ID from nsIWidget to RenderFrameParent. It is conceptually attached -// to any WidgetInputEvent that has been processed by APZ directly from a -// widget. +// InputAPZContext is used to communicate the ScrollableLayerGuid, +// input block ID, APZ response from nsIWidget to RenderFrameParent. +// It is conceptually attached to any WidgetInputEvent +// that has been processed by APZ directly from a widget. class MOZ_STACK_CLASS InputAPZContext { private: static ScrollableLayerGuid sGuid; static uint64_t sBlockId; + static nsEventStatus sApzResponse; static bool sRoutedToChildProcess; public: static ScrollableLayerGuid GetTargetLayerGuid(); static uint64_t GetInputBlockId(); + static nsEventStatus GetApzResponse(); static void SetRoutedToChildProcess(); InputAPZContext(const ScrollableLayerGuid& aGuid, - const uint64_t& aBlockId); + const uint64_t& aBlockId, + const nsEventStatus& aApzResponse); ~InputAPZContext(); bool WasRoutedToChildProcess(); @@ -36,6 +40,7 @@ public: private: ScrollableLayerGuid mOldGuid; uint64_t mOldBlockId; + nsEventStatus mOldApzResponse; bool mOldRoutedToChildProcess; }; diff --git a/widget/EventForwards.h b/widget/EventForwards.h index 25567b55b4f..0df64f28b0b 100644 --- a/widget/EventForwards.h +++ b/widget/EventForwards.h @@ -23,7 +23,9 @@ enum nsEventStatus // The event is consumed, don't do default processing nsEventStatus_eConsumeNoDefault, // The event is consumed, but do default processing - nsEventStatus_eConsumeDoDefault + nsEventStatus_eConsumeDoDefault, + // Value is not for use, only for serialization + nsEventStatus_eSentinel }; namespace mozilla { diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index e7c7964207d..b7bb55867f5 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1014,7 +1014,7 @@ nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent, nsEventStatus aApzResponse) { MOZ_ASSERT(NS_IsMainThread()); - InputAPZContext context(aGuid, aInputBlockId); + InputAPZContext context(aGuid, aInputBlockId, aApzResponse); // If this is a touch event and APZ has targeted it to an APZC in the root // process, apply that APZC's callback-transform before dispatching the