Bug 1242690 - Ensure that mouse events have the callback transform applied. r=
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1815,16 +1815,18 @@ TabChild::RecvRealMouseButtonEvent(const
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId)
{
nsEventStatus unused;
InputAPZContext context(aGuid, aInputBlockId, unused);
WidgetMouseEvent localEvent(event);
localEvent.widget = mPuppetWidget;
+ APZCCallbackHelper::ApplyCallbackTransform(&localEvent, aGuid,
+ mPuppetWidget->GetDefaultScale());
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
if (event.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessMouseEvent(event, aGuid, aInputBlockId);
}
return true;
}
@@ -1836,16 +1838,18 @@ TabChild::RecvMouseWheelEvent(const Widg
if (aEvent.mFlags.mHandledByAPZ) {
nsCOMPtr<nsIDocument> document(GetDocument());
APZCCallbackHelper::SendSetTargetAPZCNotification(
mPuppetWidget, document, aEvent, aGuid, aInputBlockId);
}
WidgetWheelEvent event(aEvent);
event.widget = mPuppetWidget;
+ APZCCallbackHelper::ApplyCallbackTransform(&event, aGuid,
+ mPuppetWidget->GetDefaultScale());
APZCCallbackHelper::DispatchWidgetEvent(event);
if (event.mCanTriggerSwipe) {
SendRespondStartSwipeEvent(aInputBlockId, event.TriggersSwipe());
}
if (aEvent.mFlags.mHandledByAPZ) {
mAPZEventState->ProcessWheelEvent(event, aGuid, aInputBlockId);
@@ -1866,17 +1870,17 @@ TabChild::RecvRealTouchEvent(const Widge
const uint64_t& aInputBlockId,
const nsEventStatus& aApzResponse)
{
TABC_LOG("Receiving touch event of type %d\n", aEvent.mMessage);
WidgetTouchEvent localEvent(aEvent);
localEvent.widget = mPuppetWidget;
- APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
+ APZCCallbackHelper::ApplyCallbackTransform(&localEvent, aGuid,
mPuppetWidget->GetDefaultScale());
if (localEvent.mMessage == eTouchStart && AsyncPanZoomEnabled()) {
if (gfxPrefs::TouchActionEnabled()) {
APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(mPuppetWidget,
localEvent, aInputBlockId, mSetAllowedTouchBehaviorCallback);
}
nsCOMPtr<nsIDocument> document = GetDocument();
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -527,23 +527,29 @@ APZCCallbackHelper::ApplyCallbackTransfo
const CSSToLayoutDeviceScale& aScale)
{
LayoutDevicePoint point = LayoutDevicePoint(aPoint.x, aPoint.y);
point = ApplyCallbackTransform(point / aScale, aGuid) * aScale;
return gfx::RoundedToInt(point);
}
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);
}
}
nsEventStatus
APZCCallbackHelper::DispatchWidgetEvent(WidgetGUIEvent& aEvent)
{
nsEventStatus status = nsEventStatus_eConsumeNoDefault;
if (aEvent.widget) {
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -94,19 +94,19 @@ public:
/* Same as above, but operates on LayoutDeviceIntPoint.
Requires an additonal |aScale| parameter to convert between CSS and
LayoutDevice space. */
static mozilla::LayoutDeviceIntPoint
ApplyCallbackTransform(const LayoutDeviceIntPoint& aPoint,
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);
/* Dispatch a widget event via the widget stored in the event, if any.
* In a child process, allows the TabParent event-capture mechanism to
* intercept the event. */
static nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& aEvent);
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1008,24 +1008,23 @@ nsEventStatus
nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent,
const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId,
nsEventStatus aApzResponse)
{
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());
}
// Make a copy of the original event for the APZCCallbackHelper helpers that
// we call later, because the event passed to DispatchEvent can get mutated in
// ways that we don't want (i.e. touch points can get stripped out).
nsEventStatus status;
UniquePtr<WidgetEvent> original(aEvent->Duplicate());
@@ -1063,26 +1062,17 @@ nsBaseWidget::ProcessUntransformedAPZEve
}
return status;
}
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
{
public:
DispatchWheelEventOnMainThread(const ScrollWheelInput& aWheelInput,
nsBaseWidget* aWidget,
nsEventStatus aAPZResult,