Bug 1242690 - Ensure that mouse events have the callback transform applied. r=botond

--HG--
extra : commitid : IXh9rbTOf5R
This commit is contained in:
Kartikaya Gupta 2016-01-29 16:31:15 -05:00
parent e7ee60296d
commit eec655d1f0
5 changed files with 38 additions and 39 deletions

View File

@ -1795,35 +1795,37 @@ TabChild::RecvMouseEvent(const nsString& aType,
}
bool
TabChild::RecvRealMouseMoveEvent(const WidgetMouseEvent& event,
TabChild::RecvRealMouseMoveEvent(const WidgetMouseEvent& aEvent,
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId)
{
return RecvRealMouseButtonEvent(event, aGuid, aInputBlockId);
return RecvRealMouseButtonEvent(aEvent, aGuid, aInputBlockId);
}
bool
TabChild::RecvSynthMouseMoveEvent(const WidgetMouseEvent& event,
TabChild::RecvSynthMouseMoveEvent(const WidgetMouseEvent& aEvent,
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId)
{
return RecvRealMouseButtonEvent(event, aGuid, aInputBlockId);
return RecvRealMouseButtonEvent(aEvent, aGuid, aInputBlockId);
}
bool
TabChild::RecvRealMouseButtonEvent(const WidgetMouseEvent& event,
TabChild::RecvRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId)
{
nsEventStatus unused;
InputAPZContext context(aGuid, aInputBlockId, unused);
WidgetMouseEvent localEvent(event);
WidgetMouseEvent localEvent(aEvent);
localEvent.widget = mPuppetWidget;
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
mPuppetWidget->GetDefaultScale());
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
if (event.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessMouseEvent(event, aGuid, aInputBlockId);
if (aEvent.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessMouseEvent(aEvent, aGuid, aInputBlockId);
}
return true;
}
@ -1839,16 +1841,18 @@ TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& aEvent,
mPuppetWidget, document, aEvent, aGuid, aInputBlockId);
}
WidgetWheelEvent event(aEvent);
event.widget = mPuppetWidget;
APZCCallbackHelper::DispatchWidgetEvent(event);
WidgetWheelEvent localEvent(aEvent);
localEvent.widget = mPuppetWidget;
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
mPuppetWidget->GetDefaultScale());
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
if (event.mCanTriggerSwipe) {
SendRespondStartSwipeEvent(aInputBlockId, event.TriggersSwipe());
if (localEvent.mCanTriggerSwipe) {
SendRespondStartSwipeEvent(aInputBlockId, localEvent.TriggersSwipe());
}
if (aEvent.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessWheelEvent(event, aGuid, aInputBlockId);
mAPZEventState->ProcessWheelEvent(localEvent, aGuid, aInputBlockId);
}
return true;
}

View File

@ -1087,10 +1087,9 @@ APZCTreeManager::ReceiveInputEvent(WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId)
{
// This function will be removed once metro code is modified to use the
// InputData version of ReceiveInputEvent.
// In general it is preferable to use the version of ReceiveInputEvent
// that takes an InputData, as that is usable from off-main-thread.
// that takes an InputData, as that is usable from off-main-thread. On some
// platforms OMT input isn't possible, and there we can use this version.
MOZ_ASSERT(NS_IsMainThread());
APZThreadUtils::AssertOnControllerThread();

View File

@ -532,13 +532,19 @@ APZCCallbackHelper::ApplyCallbackTransform(const LayoutDeviceIntPoint& aPoint,
}
void
APZCCallbackHelper::ApplyCallbackTransform(WidgetTouchEvent& aEvent,
APZCCallbackHelper::ApplyCallbackTransform(WidgetEvent& aEvent,
const ScrollableLayerGuid& aGuid,
const CSSToLayoutDeviceScale& aScale)
{
for (size_t i = 0; i < aEvent.touches.Length(); i++) {
aEvent.touches[i]->mRefPoint = ApplyCallbackTransform(
aEvent.touches[i]->mRefPoint, aGuid, aScale);
if (aEvent.AsTouchEvent()) {
WidgetTouchEvent& event = *(aEvent.AsTouchEvent());
for (size_t i = 0; i < event.touches.Length(); i++) {
event.touches[i]->mRefPoint = ApplyCallbackTransform(
event.touches[i]->mRefPoint, aGuid, aScale);
}
} else {
aEvent.refPoint = ApplyCallbackTransform(
aEvent.refPoint, aGuid, aScale);
}
}

View File

@ -99,9 +99,9 @@ public:
const ScrollableLayerGuid& aGuid,
const CSSToLayoutDeviceScale& aScale);
/* Convenience function for applying a callback transform to all touch
* points of a touch event. */
static void ApplyCallbackTransform(WidgetTouchEvent& aEvent,
/* Convenience function for applying a callback transform to all refpoints
* in the input event. */
static void ApplyCallbackTransform(WidgetEvent& aEvent,
const ScrollableLayerGuid& aGuid,
const CSSToLayoutDeviceScale& aScale);

View File

@ -1012,14 +1012,13 @@ nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent,
MOZ_ASSERT(NS_IsMainThread());
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 an event that the APZ has targeted to an APZC in the root
// process, apply that APZC's callback-transform before dispatching the
// event. If the event is instead targeted to an APZC in the child process,
// the transform will be applied in the child process before dispatching
// the event there (see e.g. TabChild::RecvRealTouchEvent()).
// TODO: Do other types of events (than touch) need this?
if (aEvent->AsTouchEvent() && aGuid.mLayersId == mCompositorParent->RootLayerTreeId()) {
APZCCallbackHelper::ApplyCallbackTransform(*aEvent->AsTouchEvent(), aGuid,
if (aGuid.mLayersId == mCompositorParent->RootLayerTreeId()) {
APZCCallbackHelper::ApplyCallbackTransform(*aEvent, aGuid,
GetDefaultScale());
}
@ -1030,7 +1029,7 @@ nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent,
UniquePtr<WidgetEvent> original(aEvent->Duplicate());
DispatchEvent(aEvent, status);
if (mAPZC && !context.WasRoutedToChildProcess()) {
if (mAPZC && !context.WasRoutedToChildProcess() && aInputBlockId) {
// EventStateManager did not route the event into the child process.
// It's safe to communicate to APZ that the event has been processed.
// TODO: Eventually we'll be able to move the SendSetTargetAPZCNotification
@ -1067,16 +1066,7 @@ nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent,
nsEventStatus
nsBaseWidget::DispatchInputEvent(WidgetInputEvent* aEvent)
{
if (mAPZC) {
nsEventStatus result = mAPZC->ReceiveInputEvent(*aEvent, nullptr, nullptr);
if (result == nsEventStatus_eConsumeNoDefault) {
return result;
}
}
nsEventStatus status;
DispatchEvent(aEvent, status);
return status;
return DispatchAPZAwareEvent(aEvent);
}
class DispatchWheelEventOnMainThread : public Task