Bug 1162009 - Add TOUCH_CANCEL sending on e10s. r=kats

This commit is contained in:
Maksim Lebedev 2015-05-14 08:16:00 -04:00
parent 7bed5a5691
commit 513de9dca0
10 changed files with 72 additions and 32 deletions

View File

@ -60,6 +60,7 @@ using mozilla::layers::TouchBehaviorFlags from "mozilla/layers/APZUtils.h";
using nsIWidget::TouchPointerState from "nsIWidget.h"; using nsIWidget::TouchPointerState from "nsIWidget.h";
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h"; using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
using struct mozilla::OwningSerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h"; using struct mozilla::OwningSerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h";
using nsEventStatus from "mozilla/EventForwards.h";
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -594,8 +595,14 @@ child:
RealMouseButtonEvent(WidgetMouseEvent event); RealMouseButtonEvent(WidgetMouseEvent event);
RealKeyEvent(WidgetKeyboardEvent event, MaybeNativeKeyBinding keyBinding); RealKeyEvent(WidgetKeyboardEvent event, MaybeNativeKeyBinding keyBinding);
MouseWheelEvent(WidgetWheelEvent event, ScrollableLayerGuid aGuid, uint64_t aInputBlockId); MouseWheelEvent(WidgetWheelEvent event, ScrollableLayerGuid aGuid, uint64_t aInputBlockId);
RealTouchEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid, uint64_t aInputBlockId); RealTouchEvent(WidgetTouchEvent aEvent,
RealTouchMoveEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid, uint64_t aInputBlockId); 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); RealDragEvent(WidgetDragEvent aEvent, uint32_t aDragAction, uint32_t aDropEffect);
/** /**

View File

@ -88,6 +88,7 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIPermissionManager.h" #include "nsIPermissionManager.h"
#include "nsIScriptError.h" #include "nsIScriptError.h"
#include "mozilla/EventForwards.h"
#define BROWSER_ELEMENT_CHILD_SCRIPT \ #define BROWSER_ELEMENT_CHILD_SCRIPT \
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
@ -2379,7 +2380,8 @@ TabChild::GetPresShellResolution() const
bool bool
TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent, TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
const ScrollableLayerGuid& aGuid, 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); TABC_LOG("Receiving touch event of type %d\n", aEvent.message);
@ -2407,17 +2409,17 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
return true; return true;
} }
mAPZEventState->ProcessTouchEvent(localEvent, aGuid, aInputBlockId, mAPZEventState->ProcessTouchEvent(localEvent, aGuid, aInputBlockId, aApzResponse);
nsEventStatus_eIgnore);
return true; return true;
} }
bool bool
TabChild::RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, TabChild::RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent,
const ScrollableLayerGuid& aGuid, 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 bool

View File

@ -363,10 +363,12 @@ public:
const uint64_t& aInputBlockId) override; const uint64_t& aInputBlockId) override;
virtual bool RecvRealTouchEvent(const WidgetTouchEvent& aEvent, virtual bool RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
const ScrollableLayerGuid& aGuid, const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId) override; const uint64_t& aInputBlockId,
const nsEventStatus& aApzResponse) override;
virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent, virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent,
const ScrollableLayerGuid& aGuid, const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId) override; const uint64_t& aInputBlockId,
const nsEventStatus& aApzResponse) override;
virtual bool RecvKeyEvent(const nsString& aType, virtual bool RecvKeyEvent(const nsString& aType,
const int32_t& aKeyCode, const int32_t& aKeyCode,
const int32_t& aCharCode, const int32_t& aCharCode,

View File

@ -96,7 +96,14 @@ struct ParamTraits<mozilla::dom::AudioChannelState>
mozilla::dom::AUDIO_CHANNEL_STATE_LAST> mozilla::dom::AUDIO_CHANNEL_STATE_LAST>
{ }; { };
template <>
struct ParamTraits<nsEventStatus>
: public ContiguousEnumSerializer<nsEventStatus,
nsEventStatus_eIgnore,
nsEventStatus_eSentinel>
{ };
} }
#endif #endif

View File

@ -1309,7 +1309,7 @@ bool TabParent::SendMouseWheelEvent(WidgetWheelEvent& event)
ScrollableLayerGuid guid; ScrollableLayerGuid guid;
uint64_t blockId; uint64_t blockId;
ApzAwareEventRoutingToChild(&guid, &blockId); ApzAwareEventRoutingToChild(&guid, &blockId, nullptr);
event.refPoint += GetChildProcessOffset(); event.refPoint += GetChildProcessOffset();
return PBrowserParent::SendMouseWheelEvent(event, guid, blockId); return PBrowserParent::SendMouseWheelEvent(event, guid, blockId);
} }
@ -1624,7 +1624,8 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event)
ScrollableLayerGuid guid; ScrollableLayerGuid guid;
uint64_t blockId; uint64_t blockId;
ApzAwareEventRoutingToChild(&guid, &blockId); nsEventStatus apzResponse;
ApzAwareEventRoutingToChild(&guid, &blockId, &apzResponse);
if (mIsDestroyed) { if (mIsDestroyed) {
return false; return false;
@ -1636,8 +1637,8 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event)
} }
return (event.message == NS_TOUCH_MOVE) ? return (event.message == NS_TOUCH_MOVE) ?
PBrowserParent::SendRealTouchMoveEvent(event, guid, blockId) : PBrowserParent::SendRealTouchMoveEvent(event, guid, blockId, apzResponse) :
PBrowserParent::SendRealTouchEvent(event, guid, blockId); PBrowserParent::SendRealTouchEvent(event, guid, blockId, apzResponse);
} }
bool bool
@ -2727,7 +2728,8 @@ TabParent::GetWidget() const
void void
TabParent::ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid, TabParent::ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) uint64_t* aOutInputBlockId,
nsEventStatus* aOutApzResponse)
{ {
if (gfxPrefs::AsyncPanZoomEnabled()) { if (gfxPrefs::AsyncPanZoomEnabled()) {
if (aOutTargetGuid) { if (aOutTargetGuid) {
@ -2747,6 +2749,9 @@ TabParent::ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid,
if (aOutInputBlockId) { if (aOutInputBlockId) {
*aOutInputBlockId = InputAPZContext::GetInputBlockId(); *aOutInputBlockId = InputAPZContext::GetInputBlockId();
} }
if (aOutApzResponse) {
*aOutApzResponse = InputAPZContext::GetApzResponse();
}
// Let the widget know that the event will be sent to the child process, // Let the widget know that the event will be sent to the child process,
// which will (hopefully) send a confirmation notice back to APZ. // which will (hopefully) send a confirmation notice back to APZ.

View File

@ -502,18 +502,17 @@ private:
// Update state prior to routing an APZ-aware event to the child process. // Update state prior to routing an APZ-aware event to the child process.
// |aOutTargetGuid| will contain the identifier // |aOutTargetGuid| will contain the identifier
// of the APZC instance that handled the event. aOutTargetGuid may be // of the APZC instance that handled the event. aOutTargetGuid may be null.
// null.
// |aOutInputBlockId| will contain the identifier of the input block // |aOutInputBlockId| will contain the identifier of the input block
// that this event was added to, if there was one. aOutInputBlockId may // that this event was added to, if there was one. aOutInputBlockId may be null.
// 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, void ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId); uint64_t* aOutInputBlockId,
// When true, we've initiated normal shutdown and notified our nsEventStatus* aOutApzResponse);
// managing PContent. // When true, we've initiated normal shutdown and notified our managing PContent.
bool mMarkedDestroying; bool mMarkedDestroying;
// When true, the TabParent is invalid and we should not send IPC messages // When true, the TabParent is invalid and we should not send IPC messages anymore.
// anymore.
bool mIsDestroyed; bool mIsDestroyed;
// Whether we have already sent a FileDescriptor for the app package. // Whether we have already sent a FileDescriptor for the app package.
bool mAppPackageFileDescriptorSent; bool mAppPackageFileDescriptorSent;

View File

@ -10,6 +10,7 @@ namespace layers {
ScrollableLayerGuid InputAPZContext::sGuid; ScrollableLayerGuid InputAPZContext::sGuid;
uint64_t InputAPZContext::sBlockId = 0; uint64_t InputAPZContext::sBlockId = 0;
nsEventStatus InputAPZContext::sApzResponse = nsEventStatus_eIgnore;
bool InputAPZContext::sRoutedToChildProcess = false; bool InputAPZContext::sRoutedToChildProcess = false;
/*static*/ ScrollableLayerGuid /*static*/ ScrollableLayerGuid
@ -24,6 +25,12 @@ InputAPZContext::GetInputBlockId()
return sBlockId; return sBlockId;
} }
/*static*/ nsEventStatus
InputAPZContext::GetApzResponse()
{
return sApzResponse;
}
/*static*/ void /*static*/ void
InputAPZContext::SetRoutedToChildProcess() InputAPZContext::SetRoutedToChildProcess()
{ {
@ -31,13 +38,16 @@ InputAPZContext::SetRoutedToChildProcess()
} }
InputAPZContext::InputAPZContext(const ScrollableLayerGuid& aGuid, InputAPZContext::InputAPZContext(const ScrollableLayerGuid& aGuid,
const uint64_t& aBlockId) const uint64_t& aBlockId,
const nsEventStatus& aApzResponse)
: mOldGuid(sGuid) : mOldGuid(sGuid)
, mOldBlockId(sBlockId) , mOldBlockId(sBlockId)
, mOldApzResponse(sApzResponse)
, mOldRoutedToChildProcess(sRoutedToChildProcess) , mOldRoutedToChildProcess(sRoutedToChildProcess)
{ {
sGuid = aGuid; sGuid = aGuid;
sBlockId = aBlockId; sBlockId = aBlockId;
sApzResponse = aApzResponse;
sRoutedToChildProcess = false; sRoutedToChildProcess = false;
} }
@ -45,6 +55,7 @@ InputAPZContext::~InputAPZContext()
{ {
sGuid = mOldGuid; sGuid = mOldGuid;
sBlockId = mOldBlockId; sBlockId = mOldBlockId;
sApzResponse = mOldApzResponse;
sRoutedToChildProcess = mOldRoutedToChildProcess; sRoutedToChildProcess = mOldRoutedToChildProcess;
} }

View File

@ -7,28 +7,32 @@
#define mozilla_layers_InputAPZContext_h #define mozilla_layers_InputAPZContext_h
#include "FrameMetrics.h" #include "FrameMetrics.h"
#include "mozilla/EventForwards.h"
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
// InputAPZContext is used to communicate the ScrollableLayerGuid and input // InputAPZContext is used to communicate the ScrollableLayerGuid,
// block ID from nsIWidget to RenderFrameParent. It is conceptually attached // input block ID, APZ response from nsIWidget to RenderFrameParent.
// to any WidgetInputEvent that has been processed by APZ directly from a // It is conceptually attached to any WidgetInputEvent
// widget. // that has been processed by APZ directly from a widget.
class MOZ_STACK_CLASS InputAPZContext class MOZ_STACK_CLASS InputAPZContext
{ {
private: private:
static ScrollableLayerGuid sGuid; static ScrollableLayerGuid sGuid;
static uint64_t sBlockId; static uint64_t sBlockId;
static nsEventStatus sApzResponse;
static bool sRoutedToChildProcess; static bool sRoutedToChildProcess;
public: public:
static ScrollableLayerGuid GetTargetLayerGuid(); static ScrollableLayerGuid GetTargetLayerGuid();
static uint64_t GetInputBlockId(); static uint64_t GetInputBlockId();
static nsEventStatus GetApzResponse();
static void SetRoutedToChildProcess(); static void SetRoutedToChildProcess();
InputAPZContext(const ScrollableLayerGuid& aGuid, InputAPZContext(const ScrollableLayerGuid& aGuid,
const uint64_t& aBlockId); const uint64_t& aBlockId,
const nsEventStatus& aApzResponse);
~InputAPZContext(); ~InputAPZContext();
bool WasRoutedToChildProcess(); bool WasRoutedToChildProcess();
@ -36,6 +40,7 @@ public:
private: private:
ScrollableLayerGuid mOldGuid; ScrollableLayerGuid mOldGuid;
uint64_t mOldBlockId; uint64_t mOldBlockId;
nsEventStatus mOldApzResponse;
bool mOldRoutedToChildProcess; bool mOldRoutedToChildProcess;
}; };

View File

@ -23,7 +23,9 @@ enum nsEventStatus
// The event is consumed, don't do default processing // The event is consumed, don't do default processing
nsEventStatus_eConsumeNoDefault, nsEventStatus_eConsumeNoDefault,
// The event is consumed, but do default processing // The event is consumed, but do default processing
nsEventStatus_eConsumeDoDefault nsEventStatus_eConsumeDoDefault,
// Value is not for use, only for serialization
nsEventStatus_eSentinel
}; };
namespace mozilla { namespace mozilla {

View File

@ -1014,7 +1014,7 @@ nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent,
nsEventStatus aApzResponse) nsEventStatus aApzResponse)
{ {
MOZ_ASSERT(NS_IsMainThread()); 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 // 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 // process, apply that APZC's callback-transform before dispatching the