diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index a80b8fd70293..5be8635a6cbc 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -865,6 +865,9 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent, tapInput.mPoint = *untransformedPoint; } break; + } case SENTINEL_INPUT: { + MOZ_ASSERT_UNREACHABLE("Invalid InputType."); + break; } } return result; diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index 5cc74f01cba7..c3e70055f910 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -27,6 +27,7 @@ namespace layers { class Layer; class AsyncPanZoomController; +class APZCTreeManagerParent; class CompositorBridgeParent; class OverscrollHandoffChain; struct OverscrollHandoffState; @@ -381,18 +382,20 @@ public: */ void SetLongTapEnabled(bool aTapGestureEnabled) override; -protected: - // Protected destructor, to discourage deletion outside of Release(): - virtual ~APZCTreeManager(); - // Methods to help process WidgetInputEvents (or manage conversion to/from InputData) + void TransformEventRefPoint( LayoutDeviceIntPoint* aRefPoint, ScrollableLayerGuid* aOutTargetGuid) override; + void UpdateWheelTransaction( LayoutDeviceIntPoint aRefPoint, EventMessage aEventMessage) override; +protected: + // Protected destructor, to discourage deletion outside of Release(): + virtual ~APZCTreeManager(); + // Protected hooks for gtests subclass virtual AsyncPanZoomController* NewAPZCInstance(uint64_t aLayersId, GeckoContentController* aController); diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 9872c4a2c0cf..c0e9f2e6fa44 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1003,7 +1003,7 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent, } case SCROLLWHEEL_INPUT: { ScrollWheelInput scrollInput = aEvent.AsScrollWheelInput(); - if (!scrollInput.TransformToLocal(aTransformToApzc)) { + if (!scrollInput.TransformToLocal(aTransformToApzc)) { return rv; } @@ -1012,7 +1012,7 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent, } case PINCHGESTURE_INPUT: { PinchGestureInput pinchInput = aEvent.AsPinchGestureInput(); - if (!pinchInput.TransformToLocal(aTransformToApzc)) { + if (!pinchInput.TransformToLocal(aTransformToApzc)) { return rv; } @@ -1021,7 +1021,7 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent, } case TAPGESTURE_INPUT: { TapGestureInput tapInput = aEvent.AsTapGestureInput(); - if (!tapInput.TransformToLocal(aTransformToApzc)) { + if (!tapInput.TransformToLocal(aTransformToApzc)) { return rv; } @@ -1470,7 +1470,7 @@ AsyncPanZoomController::ConvertToGecko(const ScreenIntPoint& aPoint, CSSPoint* a ScreenToScreenMatrix4x4 transformScreenToGecko = treeManagerLocal->GetScreenToApzcTransform(this) * treeManagerLocal->GetApzcToGeckoTransform(this); - + Maybe layoutPoint = UntransformBy( transformScreenToGecko, aPoint); if (!layoutPoint) { @@ -1776,6 +1776,11 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(const ScrollWheelInput& aEve animation->Update(aEvent.mTimeStamp, deltaInAppUnits, nsSize(velocity.x, velocity.y)); break; } + + case ScrollWheelInput::SCROLLMODE_SENTINEL: { + MOZ_ASSERT_UNREACHABLE("Invalid ScrollMode."); + break; + } } return nsEventStatus_eConsumeNoDefault; diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index b81ddc10efe1..a40451d2896e 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -126,6 +126,9 @@ nsEventStatus GestureEventListener::HandleInputEvent(const MultiTouchInput& aEve mTouches.Clear(); rv = HandleInputTouchCancel(); break; + case MultiTouchInput::MULTITOUCH_SENTINEL: + MOZ_ASSERT_UNREACHABLE("Invalid MultTouchInput."); + break; } return rv; diff --git a/gfx/layers/ipc/APZCTreeManagerChild.cpp b/gfx/layers/ipc/APZCTreeManagerChild.cpp new file mode 100644 index 000000000000..96504fedf004 --- /dev/null +++ b/gfx/layers/ipc/APZCTreeManagerChild.cpp @@ -0,0 +1,215 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/layers/APZCTreeManagerChild.h" + +#include "InputData.h" // for InputData + +namespace mozilla { +namespace layers { + +nsEventStatus +APZCTreeManagerChild::ReceiveInputEvent( + InputData& aEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) +{ + switch (aEvent.mInputType) { + case MULTITOUCH_INPUT: { + MultiTouchInput& event = aEvent.AsMultiTouchInput(); + MultiTouchInput processedEvent; + + nsEventStatus res; + SendReceiveMultiTouchInputEvent(event, + &res, + &processedEvent, + aOutTargetGuid, + aOutInputBlockId); + + event = processedEvent; + return res; + } + case MOUSE_INPUT: { + MouseInput& event = aEvent.AsMouseInput(); + MouseInput processedEvent; + + nsEventStatus res; + SendReceiveMouseInputEvent(event, + &res, + &processedEvent, + aOutTargetGuid, + aOutInputBlockId); + + event = processedEvent; + return res; + } + case PANGESTURE_INPUT: { + PanGestureInput& event = aEvent.AsPanGestureInput(); + PanGestureInput processedEvent; + + nsEventStatus res; + SendReceivePanGestureInputEvent(event, + &res, + &processedEvent, + aOutTargetGuid, + aOutInputBlockId); + + event = processedEvent; + return res; + } + case PINCHGESTURE_INPUT: { + PinchGestureInput& event = aEvent.AsPinchGestureInput(); + PinchGestureInput processedEvent; + + nsEventStatus res; + SendReceivePinchGestureInputEvent(event, + &res, + &processedEvent, + aOutTargetGuid, + aOutInputBlockId); + + event = processedEvent; + return res; + } + case TAPGESTURE_INPUT: { + TapGestureInput& event = aEvent.AsTapGestureInput(); + TapGestureInput processedEvent; + + nsEventStatus res; + SendReceiveTapGestureInputEvent(event, + &res, + &processedEvent, + aOutTargetGuid, + aOutInputBlockId); + + event = processedEvent; + return res; + } + case SCROLLWHEEL_INPUT: { + ScrollWheelInput& event = aEvent.AsScrollWheelInput(); + ScrollWheelInput processedEvent; + + nsEventStatus res; + SendReceiveScrollWheelInputEvent(event, + &res, + &processedEvent, + aOutTargetGuid, + aOutInputBlockId); + + event = processedEvent; + return res; + } + default: { + MOZ_ASSERT_UNREACHABLE("Invalid InputData type."); + return nsEventStatus_eConsumeNoDefault; + } + } +} + +void +APZCTreeManagerChild::ZoomToRect( + const ScrollableLayerGuid& aGuid, + const CSSRect& aRect, + const uint32_t aFlags) +{ + SendZoomToRect(aGuid, aRect, aFlags); +} + +void +APZCTreeManagerChild::ContentReceivedInputBlock( + uint64_t aInputBlockId, + bool aPreventDefault) +{ + SendContentReceivedInputBlock(aInputBlockId, aPreventDefault); +} + +void +APZCTreeManagerChild::SetTargetAPZC( + uint64_t aInputBlockId, + const nsTArray& aTargets) +{ + SendSetTargetAPZC(aInputBlockId, aTargets); +} + +void +APZCTreeManagerChild::UpdateZoomConstraints( + const ScrollableLayerGuid& aGuid, + const Maybe& aConstraints) +{ + SendUpdateZoomConstraints(aGuid, aConstraints); +} + +void +APZCTreeManagerChild::CancelAnimation(const ScrollableLayerGuid &aGuid) +{ + SendCancelAnimation(aGuid); +} + +void +APZCTreeManagerChild::AdjustScrollForSurfaceShift(const ScreenPoint& aShift) +{ + SendAdjustScrollForSurfaceShift(aShift); +} + +void +APZCTreeManagerChild::SetDPI(float aDpiValue) +{ + SendSetDPI(aDpiValue); +} + +void +APZCTreeManagerChild::SetAllowedTouchBehavior( + uint64_t aInputBlockId, + const nsTArray& aValues) +{ + SendSetAllowedTouchBehavior(aInputBlockId, aValues); +} + +void +APZCTreeManagerChild::StartScrollbarDrag( + const ScrollableLayerGuid& aGuid, + const AsyncDragMetrics& aDragMetrics) +{ + SendStartScrollbarDrag(aGuid, aDragMetrics); +} + +void +APZCTreeManagerChild::SetLongTapEnabled(bool aTapGestureEnabled) +{ + SendSetLongTapEnabled(aTapGestureEnabled); +} + +void +APZCTreeManagerChild::ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) +{ + SendProcessTouchVelocity(aTimestampMs, aSpeedY); +} + +void +APZCTreeManagerChild::UpdateWheelTransaction( + LayoutDeviceIntPoint aRefPoint, + EventMessage aEventMessage) +{ + SendUpdateWheelTransaction(aRefPoint, aEventMessage); +} + +void APZCTreeManagerChild::TransformEventRefPoint( + LayoutDeviceIntPoint* aRefPoint, + ScrollableLayerGuid* aOutTargetGuid) +{ + SendTransformEventRefPoint(*aRefPoint, aRefPoint, aOutTargetGuid); +} + +void +APZCTreeManagerChild::OnProcessingError( + Result aCode, + const char* aReason) +{ + MOZ_RELEASE_ASSERT(aCode != MsgDropped); +} + +} // namespace layers +} // namespace mozilla diff --git a/gfx/layers/ipc/APZCTreeManagerChild.h b/gfx/layers/ipc/APZCTreeManagerChild.h new file mode 100644 index 000000000000..cb7080c2cf6c --- /dev/null +++ b/gfx/layers/ipc/APZCTreeManagerChild.h @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_layers_APZCTreeManagerChild_h +#define mozilla_layers_APZCTreeManagerChild_h + +#include "mozilla/layers/IAPZCTreeManager.h" +#include "mozilla/layers/PAPZCTreeManagerChild.h" + +namespace mozilla { +namespace layers { + + +class APZCTreeManagerChild + : public IAPZCTreeManager + , public PAPZCTreeManagerChild +{ +public: + APZCTreeManagerChild() { } + + nsEventStatus + ReceiveInputEvent( + InputData& aEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) override; + + void + ZoomToRect( + const ScrollableLayerGuid& aGuid, + const CSSRect& aRect, + const uint32_t aFlags = DEFAULT_BEHAVIOR) override; + + void + ContentReceivedInputBlock( + uint64_t aInputBlockId, + bool aPreventDefault) override; + + void + SetTargetAPZC( + uint64_t aInputBlockId, + const nsTArray& aTargets) override; + + void + UpdateZoomConstraints( + const ScrollableLayerGuid& aGuid, + const Maybe& aConstraints) override; + + void + CancelAnimation(const ScrollableLayerGuid &aGuid) override; + + void + AdjustScrollForSurfaceShift(const ScreenPoint& aShift) override; + + void + SetDPI(float aDpiValue) override; + + void + SetAllowedTouchBehavior( + uint64_t aInputBlockId, + const nsTArray& aValues) override; + + void + StartScrollbarDrag( + const ScrollableLayerGuid& aGuid, + const AsyncDragMetrics& aDragMetrics) override; + + void + SetLongTapEnabled(bool aTapGestureEnabled) override; + + void + ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) override; + + void + TransformEventRefPoint( + LayoutDeviceIntPoint* aRefPoint, + ScrollableLayerGuid* aOutTargetGuid) override; + + void + UpdateWheelTransaction( + LayoutDeviceIntPoint aRefPoint, + EventMessage aEventMessage) override; + + void + OnProcessingError( + Result aCode, + const char* aReason) override; + +protected: + + virtual + ~APZCTreeManagerChild() { } +}; + +} // namespace layers +} // namespace mozilla + +#endif // mozilla_layers_APZCTreeManagerChild_h diff --git a/gfx/layers/ipc/APZCTreeManagerParent.cpp b/gfx/layers/ipc/APZCTreeManagerParent.cpp new file mode 100644 index 000000000000..c9af1ba0cdec --- /dev/null +++ b/gfx/layers/ipc/APZCTreeManagerParent.cpp @@ -0,0 +1,250 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/layers/APZCTreeManagerParent.h" + +#include "mozilla/layers/APZCTreeManager.h" +#include "mozilla/layers/APZThreadUtils.h" + +namespace mozilla { +namespace layers { + +APZCTreeManagerParent::APZCTreeManagerParent(RefPtr aAPZCTreeManager) + : mTreeManager(aAPZCTreeManager) +{ + MOZ_ASSERT(aAPZCTreeManager != nullptr); +} + +bool +APZCTreeManagerParent::RecvReceiveMultiTouchInputEvent( + const MultiTouchInput& aEvent, + nsEventStatus* aOutStatus, + MultiTouchInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) +{ + MultiTouchInput event = aEvent; + + *aOutStatus = mTreeManager->ReceiveInputEvent( + event, + aOutTargetGuid, + aOutInputBlockId); + *aOutEvent = event; + + return true; +} + +bool +APZCTreeManagerParent::RecvReceiveMouseInputEvent( + const MouseInput& aEvent, + nsEventStatus* aOutStatus, + MouseInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) +{ + MouseInput event = aEvent; + + *aOutStatus = mTreeManager->ReceiveInputEvent( + event, + aOutTargetGuid, + aOutInputBlockId); + *aOutEvent = event; + + return true; +} + +bool +APZCTreeManagerParent::RecvReceivePanGestureInputEvent( + const PanGestureInput& aEvent, + nsEventStatus* aOutStatus, + PanGestureInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) +{ + PanGestureInput event = aEvent; + + *aOutStatus = mTreeManager->ReceiveInputEvent( + event, + aOutTargetGuid, + aOutInputBlockId); + *aOutEvent = event; + + return true; +} + +bool +APZCTreeManagerParent::RecvReceivePinchGestureInputEvent( + const PinchGestureInput& aEvent, + nsEventStatus* aOutStatus, + PinchGestureInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) +{ + PinchGestureInput event = aEvent; + + *aOutStatus = mTreeManager->ReceiveInputEvent( + event, + aOutTargetGuid, + aOutInputBlockId); + *aOutEvent = event; + + return true; +} + +bool +APZCTreeManagerParent::RecvReceiveTapGestureInputEvent( + const TapGestureInput& aEvent, + nsEventStatus* aOutStatus, + TapGestureInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) +{ + TapGestureInput event = aEvent; + + *aOutStatus = mTreeManager->ReceiveInputEvent( + event, + aOutTargetGuid, + aOutInputBlockId); + *aOutEvent = event; + + return true; +} + +bool +APZCTreeManagerParent::RecvReceiveScrollWheelInputEvent( + const ScrollWheelInput& aEvent, + nsEventStatus* aOutStatus, + ScrollWheelInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) +{ + ScrollWheelInput event = aEvent; + + *aOutStatus = mTreeManager->ReceiveInputEvent( + event, + aOutTargetGuid, + aOutInputBlockId); + *aOutEvent = event; + + return true; +} + +bool +APZCTreeManagerParent::RecvZoomToRect( + const ScrollableLayerGuid& aGuid, + const CSSRect& aRect, + const uint32_t& aFlags) +{ + mTreeManager->ZoomToRect(aGuid, aRect, aFlags); + return true; +} + +bool +APZCTreeManagerParent::RecvContentReceivedInputBlock( + const uint64_t& aInputBlockId, + const bool& aPreventDefault) +{ + mTreeManager->ContentReceivedInputBlock(aInputBlockId, aPreventDefault); + return true; +} + +bool +APZCTreeManagerParent::RecvSetTargetAPZC( + const uint64_t& aInputBlockId, + nsTArray&& aTargets) +{ + mTreeManager->SetTargetAPZC(aInputBlockId, aTargets); + return true; +} + +bool +APZCTreeManagerParent::RecvUpdateZoomConstraints( + const ScrollableLayerGuid& aGuid, + const MaybeZoomConstraints& aConstraints) +{ + mTreeManager->UpdateZoomConstraints(aGuid, aConstraints); + return true; +} + +bool +APZCTreeManagerParent::RecvCancelAnimation(const ScrollableLayerGuid& aGuid) +{ + mTreeManager->CancelAnimation(aGuid); + return true; +} + +bool +APZCTreeManagerParent::RecvAdjustScrollForSurfaceShift(const ScreenPoint& aShift) +{ + mTreeManager->AdjustScrollForSurfaceShift(aShift); + return true; +} + +bool +APZCTreeManagerParent::RecvSetDPI(const float& aDpiValue) +{ + mTreeManager->SetDPI(aDpiValue); + return true; +} + +bool +APZCTreeManagerParent::RecvSetAllowedTouchBehavior( + const uint64_t& aInputBlockId, + nsTArray&& aValues) +{ + mTreeManager->SetAllowedTouchBehavior(aInputBlockId, aValues); + return true; +} + +bool +APZCTreeManagerParent::RecvStartScrollbarDrag( + const ScrollableLayerGuid& aGuid, + const AsyncDragMetrics& aDragMetrics) +{ + mTreeManager->StartScrollbarDrag(aGuid, aDragMetrics); + return true; +} + +bool +APZCTreeManagerParent::RecvSetLongTapEnabled(const bool& aTapGestureEnabled) +{ + mTreeManager->SetLongTapEnabled(aTapGestureEnabled); + return true; +} + +bool +APZCTreeManagerParent::RecvProcessTouchVelocity( + const uint32_t& aTimestampMs, + const float& aSpeedY) +{ + mTreeManager->ProcessTouchVelocity(aTimestampMs, aSpeedY); + return true; +} + +bool +APZCTreeManagerParent::RecvUpdateWheelTransaction( + const LayoutDeviceIntPoint& aRefPoint, + const EventMessage& aEventMessage) +{ + mTreeManager->UpdateWheelTransaction(aRefPoint, aEventMessage); + return true; +} + +bool +APZCTreeManagerParent::RecvTransformEventRefPoint( + const LayoutDeviceIntPoint& aRefPoint, + LayoutDeviceIntPoint* aOutRefPoint, + ScrollableLayerGuid* aOutTargetGuid) +{ + LayoutDeviceIntPoint refPoint = aRefPoint; + mTreeManager->TransformEventRefPoint(&refPoint, aOutTargetGuid); + *aOutRefPoint = refPoint; + + return true; +} + +} // namespace layers +} // namespace mozilla diff --git a/gfx/layers/ipc/APZCTreeManagerParent.h b/gfx/layers/ipc/APZCTreeManagerParent.h new file mode 100644 index 000000000000..a9358dc42e14 --- /dev/null +++ b/gfx/layers/ipc/APZCTreeManagerParent.h @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=99: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_layers_APZCTreeManagerParent_h +#define mozilla_layers_APZCTreeManagerParent_h + +#include "mozilla/layers/PAPZCTreeManagerParent.h" + +namespace mozilla { +namespace layers { + +class APZCTreeManager; + +class APZCTreeManagerParent + : public PAPZCTreeManagerParent +{ +public: + + APZCTreeManagerParent(RefPtr aAPZCTreeManager); + virtual ~APZCTreeManagerParent() { } + + bool + RecvReceiveMultiTouchInputEvent( + const MultiTouchInput& aEvent, + nsEventStatus* aOutStatus, + MultiTouchInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) override; + + bool + RecvReceiveMouseInputEvent( + const MouseInput& aEvent, + nsEventStatus* aOutStatus, + MouseInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) override; + + bool + RecvReceivePanGestureInputEvent( + const PanGestureInput& aEvent, + nsEventStatus* aOutStatus, + PanGestureInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) override; + + bool + RecvReceivePinchGestureInputEvent( + const PinchGestureInput& aEvent, + nsEventStatus* aOutStatus, + PinchGestureInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) override; + + bool + RecvReceiveTapGestureInputEvent( + const TapGestureInput& aEvent, + nsEventStatus* aOutStatus, + TapGestureInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) override; + + bool + RecvReceiveScrollWheelInputEvent( + const ScrollWheelInput& aEvent, + nsEventStatus* aOutStatus, + ScrollWheelInput* aOutEvent, + ScrollableLayerGuid* aOutTargetGuid, + uint64_t* aOutInputBlockId) override; + + bool + RecvZoomToRect( + const ScrollableLayerGuid& aGuid, + const CSSRect& aRect, + const uint32_t& aFlags) override; + + bool + RecvContentReceivedInputBlock( + const uint64_t& aInputBlockId, + const bool& aPreventDefault) override; + + bool + RecvSetTargetAPZC( + const uint64_t& aInputBlockId, + nsTArray&& aTargets) override; + + bool + RecvUpdateZoomConstraints( + const ScrollableLayerGuid& aGuid, + const MaybeZoomConstraints& aConstraints) override; + + bool + RecvCancelAnimation(const ScrollableLayerGuid& aGuid) override; + + bool + RecvAdjustScrollForSurfaceShift(const ScreenPoint& aShift) override; + + bool + RecvSetDPI(const float& aDpiValue) override; + + bool + RecvSetAllowedTouchBehavior( + const uint64_t& aInputBlockId, + nsTArray&& aValues) override; + + bool + RecvStartScrollbarDrag( + const ScrollableLayerGuid& aGuid, + const AsyncDragMetrics& aDragMetrics) override; + + bool + RecvSetLongTapEnabled(const bool& aTapGestureEnabled) override; + + bool + RecvProcessTouchVelocity( + const uint32_t& aTimestampMs, + const float& aSpeedY) override; + + bool + RecvUpdateWheelTransaction( + const LayoutDeviceIntPoint& aRefPoint, + const EventMessage& aEventMessage) override; + + bool + RecvTransformEventRefPoint( + const LayoutDeviceIntPoint& aRefPoint, + LayoutDeviceIntPoint* aOutRefPoint, + ScrollableLayerGuid* aOutTargetGuid) override; + + void + ActorDestroy(ActorDestroyReason aWhy) override { } + +private: + RefPtr mTreeManager; +}; + +} // namespace layers +} // namespace mozilla + +#endif // mozilla_layers_APZCTreeManagerParent_h diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index 5db2bda77630..30e8c6d13d75 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -11,6 +11,7 @@ #include "ClientLayerManager.h" // for ClientLayerManager #include "base/message_loop.h" // for MessageLoop #include "base/task.h" // for NewRunnableMethod, etc +#include "gfxPrefs.h" #include "mozilla/layers/LayerTransactionChild.h" #include "mozilla/layers/PLayerTransactionChild.h" #include "mozilla/layers/TextureClient.h"// for TextureClient @@ -39,6 +40,7 @@ using mozilla::layers::LayerTransactionChild; using mozilla::dom::TabChildBase; using mozilla::Unused; +using mozilla::gfx::GPUProcessManager; namespace mozilla { namespace layers { diff --git a/gfx/layers/ipc/PAPZCTreeManager.ipdl b/gfx/layers/ipc/PAPZCTreeManager.ipdl new file mode 100644 index 000000000000..134460317b69 --- /dev/null +++ b/gfx/layers/ipc/PAPZCTreeManager.ipdl @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +include "mozilla/GfxMessageUtils.h"; +include "ipc/nsGUIEventIPC.h"; + +using CSSRect from "Units.h"; +using LayoutDeviceIntPoint from "Units.h"; +using ScreenPoint from "Units.h"; +using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h"; +using mozilla::layers::MaybeZoomConstraints from "FrameMetrics.h"; +using mozilla::layers::TouchBehaviorFlags from "mozilla/layers/APZUtils.h"; +using mozilla::layers::AsyncDragMetrics from "mozilla/layers/AsyncDragMetrics.h"; + +using nsEventStatus from "mozilla/EventForwards.h"; +using EventMessage from "mozilla/EventForwards.h"; +using class mozilla::WidgetInputEvent from "mozilla/BasicEvents.h"; +using class mozilla::WidgetMouseEventBase from "mozilla/MouseEvents.h"; +using mozilla::WidgetMouseEvent::Reason from "mozilla/MouseEvents.h"; +using class mozilla::WidgetTouchEvent from "mozilla/TouchEvents.h"; +using class mozilla::WidgetWheelEvent from "mozilla/MouseEvents.h"; +using class mozilla::InputData from "InputData.h"; +using class mozilla::MultiTouchInput from "InputData.h"; +using class mozilla::MouseInput from "InputData.h"; +using class mozilla::PanGestureInput from "InputData.h"; +using class mozilla::PinchGestureInput from "InputData.h"; +using class mozilla::TapGestureInput from "InputData.h"; +using class mozilla::ScrollWheelInput from "InputData.h"; + +namespace mozilla { +namespace layers { + +sync protocol PAPZCTreeManager +{ +parent: + + sync ReceiveMultiTouchInputEvent(MultiTouchInput aEvent) + returns (nsEventStatus aOutStatus, + MultiTouchInput aOutEvent, + ScrollableLayerGuid aOutTargetGuid, + uint64_t aOutInputBlockId); + + sync ReceiveMouseInputEvent(MouseInput aEvent) + returns (nsEventStatus aOutStatus, + MouseInput aOutEvent, + ScrollableLayerGuid aOutTargetGuid, + uint64_t aOutInputBlockId); + + sync ReceivePanGestureInputEvent(PanGestureInput aEvent) + returns (nsEventStatus aOutStatus, + PanGestureInput aOutEvent, + ScrollableLayerGuid aOutTargetGuid, + uint64_t aOutInputBlockId); + + sync ReceivePinchGestureInputEvent(PinchGestureInput aEvent) + returns (nsEventStatus aOutStatus, + PinchGestureInput aOutEvent, + ScrollableLayerGuid aOutTargetGuid, + uint64_t aOutInputBlockId); + + sync ReceiveTapGestureInputEvent(TapGestureInput aEvent) + returns (nsEventStatus aOutStatus, + TapGestureInput aOutEvent, + ScrollableLayerGuid aOutTargetGuid, + uint64_t aOutInputBlockId); + + sync ReceiveScrollWheelInputEvent(ScrollWheelInput aEvent) + returns (nsEventStatus aOutStatus, + ScrollWheelInput aOutEvent, + ScrollableLayerGuid aOutTargetGuid, + uint64_t aOutInputBlockId); + + async ZoomToRect(ScrollableLayerGuid aGuid, CSSRect aRect, uint32_t Flags); + + async ContentReceivedInputBlock(uint64_t aInputBlockId, bool PreventDefault); + + async SetTargetAPZC(uint64_t aInputBlockId, ScrollableLayerGuid[] Targets); + + async UpdateZoomConstraints(ScrollableLayerGuid aGuid, MaybeZoomConstraints aConstraints); + + async CancelAnimation(ScrollableLayerGuid aGuid); + + async AdjustScrollForSurfaceShift(ScreenPoint aShift); + + async SetDPI(float aDpiValue); + + async SetAllowedTouchBehavior(uint64_t aInputBlockId, TouchBehaviorFlags[] aValues); + + async StartScrollbarDrag(ScrollableLayerGuid aGuid, AsyncDragMetrics aDragMetrics); + + async SetLongTapEnabled(bool aTapGestureEnabled); + + async ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY); + + async UpdateWheelTransaction(LayoutDeviceIntPoint aRefPoint, EventMessage aEventMessage); + + sync TransformEventRefPoint(LayoutDeviceIntPoint aRefPoint) + returns (LayoutDeviceIntPoint aOutRefPoint, + ScrollableLayerGuid aOutTargetGuid); + + async __delete__(); +}; + +} // namespace gfx +} // namespace mozilla diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 4978fbc22007..1fe78bd32e03 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -154,6 +154,8 @@ EXPORTS.mozilla.layers += [ 'Effects.h', 'ImageDataSerializer.h', 'ipc/APZChild.h', + 'ipc/APZCTreeManagerChild.h', + 'ipc/APZCTreeManagerParent.h', 'ipc/AsyncTransactionTracker.h', 'ipc/CompositableForwarder.h', 'ipc/CompositableTransactionParent.h', @@ -342,6 +344,8 @@ UNIFIED_SOURCES += [ 'ImageDataSerializer.cpp', 'ImageLayers.cpp', 'ipc/APZChild.cpp', + 'ipc/APZCTreeManagerChild.cpp', + 'ipc/APZCTreeManagerParent.cpp', 'ipc/AsyncTransactionTracker.cpp', 'ipc/CompositableTransactionParent.cpp', 'ipc/CompositorBench.cpp', @@ -414,6 +418,7 @@ IPDL_SOURCES = [ 'ipc/LayersMessages.ipdlh', 'ipc/LayersSurfaces.ipdlh', 'ipc/PAPZ.ipdl', + 'ipc/PAPZCTreeManager.ipdl', 'ipc/PCompositable.ipdl', 'ipc/PCompositorBridge.ipdl', 'ipc/PImageBridge.ipdl', diff --git a/widget/InputData.h b/widget/InputData.h index 8ed4514cb35b..4a4d2c016cb1 100644 --- a/widget/InputData.h +++ b/widget/InputData.h @@ -21,18 +21,28 @@ class nsIWidget; namespace mozilla { +namespace layers { +class PAPZCTreeManagerParent; +class APZCTreeManagerChild; +} + namespace dom { class Touch; } // namespace dom enum InputType { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h MULTITOUCH_INPUT, MOUSE_INPUT, PANGESTURE_INPUT, PINCHGESTURE_INPUT, TAPGESTURE_INPUT, - SCROLLWHEEL_INPUT + SCROLLWHEEL_INPUT, + + // Used as an upper bound for ContiguousEnumSerializer + SENTINEL_INPUT, }; class MultiTouchInput; @@ -62,6 +72,8 @@ class ScrollWheelInput; class InputData { public: + // Warning, this class is serialized and sent over IPC. Any change to its + // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h InputType mInputType; // Time in milliseconds that this data is relevant to. This only really // matters when this data is used as an event. We use uint32_t instead of @@ -158,6 +170,9 @@ public: already_AddRefed ToNewDOMTouch() const; + // Warning, this class is serialized and sent over IPC. Any change to its + // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h + // A unique number assigned to each SingleTouchData within a MultiTouchInput so // that they can be easily distinguished when handling a touch start/move/end. int32_t mIdentifier; @@ -198,10 +213,15 @@ class MultiTouchInput : public InputData public: enum MultiTouchType { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h MULTITOUCH_START, MULTITOUCH_MOVE, MULTITOUCH_END, - MULTITOUCH_CANCEL + MULTITOUCH_CANCEL, + + // Used as an upper bound for ContiguousEnumSerializer + MULTITOUCH_SENTINEL, }; MultiTouchInput(MultiTouchType aType, uint32_t aTime, TimeStamp aTimeStamp, @@ -245,6 +265,8 @@ public: bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform); + // Warning, this class is serialized and sent over IPC. Any change to its + // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h MultiTouchType mType; nsTArray mTouches; bool mHandledByAPZ; @@ -252,9 +274,24 @@ public: class MouseInput : public InputData { +protected: + friend mozilla::layers::PAPZCTreeManagerParent; + friend mozilla::layers::APZCTreeManagerChild; + + MouseInput() + : InputData(MOUSE_INPUT) + , mType(MOUSE_NONE) + , mButtonType(NONE) + , mInputSource(0) + , mButtons(0) + , mHandledByAPZ(false) + {} + public: enum MouseType { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h MOUSE_NONE, MOUSE_MOVE, MOUSE_DOWN, @@ -263,14 +300,22 @@ public: MOUSE_DRAG_END, MOUSE_WIDGET_ENTER, MOUSE_WIDGET_EXIT, + + // Used as an upper bound for ContiguousEnumSerializer + MOUSE_SENTINEL, }; enum ButtonType { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h LEFT_BUTTON, MIDDLE_BUTTON, RIGHT_BUTTON, - NONE + NONE, + + // Used as an upper bound for ContiguousEnumSerializer + BUTTON_SENTINEL, }; MouseInput(MouseType aType, ButtonType aButtonType, uint16_t aInputSource, int16_t aButtons, const ScreenPoint& aPoint, @@ -284,15 +329,6 @@ public: , mHandledByAPZ(false) {} - MouseInput() - : InputData(MOUSE_INPUT) - , mType(MOUSE_NONE) - , mButtonType(NONE) - , mInputSource(0) - , mButtons(0) - , mHandledByAPZ(false) - {} - explicit MouseInput(const WidgetMouseEventBase& aMouseEvent); bool IsLeftButton() const { return mButtonType == LEFT_BUTTON; } @@ -300,6 +336,8 @@ public: bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform); WidgetMouseEvent ToWidgetMouseEvent(nsIWidget* aWidget) const; + // Warning, this class is serialized and sent over IPC. Any change to its + // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h MouseType mType; ButtonType mButtonType; uint16_t mInputSource; @@ -315,9 +353,28 @@ public: */ class PanGestureInput : public InputData { +protected: + friend mozilla::layers::PAPZCTreeManagerParent; + friend mozilla::layers::APZCTreeManagerChild; + + PanGestureInput() + : InputData(PANGESTURE_INPUT), + mLineOrPageDeltaX(0), + mLineOrPageDeltaY(0), + mUserDeltaMultiplierX(1.0), + mUserDeltaMultiplierY(1.0), + mHandledByAPZ(false), + mFollowedByMomentum(false), + mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false) + { + } + public: enum PanGestureType { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h + // MayStart: Dispatched before any actual panning has occurred but when a // pan gesture is probably about to start, for example when the user // starts touching the touchpad. Should interrupt any ongoing APZ @@ -359,7 +416,10 @@ public: // MomentumEnd: The momentum animation has ended, for example because the // momentum velocity has gone below the stopping threshold, or because the // user has stopped the animation by putting their fingers on a touchpad. - PANGESTURE_MOMENTUMEND + PANGESTURE_MOMENTUMEND, + + // Used as an upper bound for ContiguousEnumSerializer + PANGESTURE_SENTINEL, }; PanGestureInput(PanGestureType aType, @@ -391,6 +451,8 @@ public: ScreenPoint UserMultipliedPanDisplacement() const; ParentLayerPoint UserMultipliedLocalPanDisplacement() const; + // Warning, this class is serialized and sent over IPC. Any change to its + // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h PanGestureType mType; ScreenPoint mPanStartPoint; @@ -432,12 +494,26 @@ public: */ class PinchGestureInput : public InputData { +protected: + friend mozilla::layers::PAPZCTreeManagerParent; + friend mozilla::layers::APZCTreeManagerChild; + + PinchGestureInput() + : InputData(PINCHGESTURE_INPUT) + { + } + public: enum PinchGestureType { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h PINCHGESTURE_START, PINCHGESTURE_SCALE, - PINCHGESTURE_END + PINCHGESTURE_END, + + // Used as an upper bound for ContiguousEnumSerializer + PINCHGESTURE_SENTINEL, }; // Construct a tap gesture from a Screen point. @@ -476,6 +552,8 @@ public: bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform); + // Warning, this class is serialized and sent over IPC. Any change to its + // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h PinchGestureType mType; // Center point of the pinch gesture. That is, if there are two fingers on the @@ -510,15 +588,29 @@ public: */ class TapGestureInput : public InputData { +protected: + friend mozilla::layers::PAPZCTreeManagerParent; + friend mozilla::layers::APZCTreeManagerChild; + + TapGestureInput() + : InputData(TAPGESTURE_INPUT) + { + } + public: enum TapGestureType { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h TAPGESTURE_LONG, TAPGESTURE_LONG_UP, TAPGESTURE_UP, TAPGESTURE_CONFIRMED, TAPGESTURE_DOUBLE, - TAPGESTURE_CANCEL + TAPGESTURE_CANCEL, + + // Used as an upper bound for ContiguousEnumSerializer + TAPGESTURE_SENTINEL, }; // Construct a tap gesture from a Screen point. @@ -549,6 +641,8 @@ public: bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform); + // Warning, this class is serialized and sent over IPC. Any change to its + // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h TapGestureType mType; // The location of the tap in screen pixels. @@ -564,14 +658,36 @@ public: // scroll gestures. class ScrollWheelInput : public InputData { +protected: + friend mozilla::layers::PAPZCTreeManagerParent; + friend mozilla::layers::APZCTreeManagerChild; + + ScrollWheelInput() + : InputData(SCROLLWHEEL_INPUT) + , mHandledByAPZ(false) + , mLineOrPageDeltaX(0) + , mLineOrPageDeltaY(0) + , mScrollSeriesNumber(0) + , mUserDeltaMultiplierX(1.0) + , mUserDeltaMultiplierY(1.0) + , mMayHaveMomentum(false) + , mIsMomentum(false) + {} + public: enum ScrollDeltaType { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h + // There are three kinds of scroll delta modes in Gecko: "page", "line" and // "pixel". SCROLLDELTA_LINE, SCROLLDELTA_PAGE, - SCROLLDELTA_PIXEL + SCROLLDELTA_PIXEL, + + // Used as an upper bound for ContiguousEnumSerializer + SCROLLDELTA_SENTINEL, }; static ScrollDeltaType @@ -608,8 +724,14 @@ public: enum ScrollMode { + // Warning, this enum is serialized and sent over IPC. If you reorder, add, + // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h + SCROLLMODE_INSTANT, - SCROLLMODE_SMOOTH + SCROLLMODE_SMOOTH, + + // Used as an upper bound for ContiguousEnumSerializer + SCROLLMODE_SENTINEL, }; ScrollWheelInput(uint32_t aTime, @@ -645,6 +767,8 @@ public: bool IsCustomizedByUserPrefs() const; + // Warning, this class is serialized and sent over IPC. Any change to its + // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h ScrollDeltaType mDeltaType; ScrollMode mScrollMode; ScreenPoint mOrigin; diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index b39744b583dd..adf5dbb31a3e 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -14,6 +14,7 @@ #include "mozilla/MouseEvents.h" #include "mozilla/TextEvents.h" #include "mozilla/TouchEvents.h" +#include "InputData.h" namespace IPC { @@ -1030,6 +1031,314 @@ struct ParamTraits } }; +// InputData.h + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::InputType, + mozilla::InputType::MULTITOUCH_INPUT, + mozilla::InputType::SENTINEL_INPUT> +{}; + +template<> +struct ParamTraits +{ + typedef mozilla::InputData paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.mInputType); + WriteParam(aMsg, aParam.mTime); + WriteParam(aMsg, aParam.mTimeStamp); + WriteParam(aMsg, aParam.modifiers); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, &aResult->mInputType) && + ReadParam(aMsg, aIter, &aResult->mTime) && + ReadParam(aMsg, aIter, &aResult->mTimeStamp) && + ReadParam(aMsg, aIter, &aResult->modifiers); + } +}; + +template<> +struct ParamTraits +{ + typedef mozilla::SingleTouchData paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.mIdentifier); + WriteParam(aMsg, aParam.mScreenPoint); + WriteParam(aMsg, aParam.mLocalScreenPoint); + WriteParam(aMsg, aParam.mRadius); + WriteParam(aMsg, aParam.mRotationAngle); + WriteParam(aMsg, aParam.mForce); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return (ReadParam(aMsg, aIter, &aResult->mIdentifier) && + ReadParam(aMsg, aIter, &aResult->mScreenPoint) && + ReadParam(aMsg, aIter, &aResult->mLocalScreenPoint) && + ReadParam(aMsg, aIter, &aResult->mRadius) && + ReadParam(aMsg, aIter, &aResult->mRotationAngle) && + ReadParam(aMsg, aIter, &aResult->mForce)); + } +}; + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::MultiTouchInput::MultiTouchType, + mozilla::MultiTouchInput::MultiTouchType::MULTITOUCH_START, + mozilla::MultiTouchInput::MultiTouchType::MULTITOUCH_SENTINEL> +{}; + +template<> +struct ParamTraits +{ + typedef mozilla::MultiTouchInput paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, static_cast(aParam)); + WriteParam(aMsg, aParam.mType); + WriteParam(aMsg, aParam.mTouches); + WriteParam(aMsg, aParam.mHandledByAPZ); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, static_cast(aResult)) && + ReadParam(aMsg, aIter, &aResult->mType) && + ReadParam(aMsg, aIter, &aResult->mTouches) && + ReadParam(aMsg, aIter, &aResult->mHandledByAPZ); + } +}; + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::MouseInput::MouseType, + mozilla::MouseInput::MouseType::MOUSE_NONE, + mozilla::MouseInput::MouseType::MOUSE_SENTINEL> +{}; + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::MouseInput::ButtonType, + mozilla::MouseInput::ButtonType::LEFT_BUTTON, + mozilla::MouseInput::ButtonType::BUTTON_SENTINEL> +{}; + +template<> +struct ParamTraits +{ + typedef mozilla::MouseInput paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, static_cast(aParam)); + WriteParam(aMsg, aParam.mButtonType); + WriteParam(aMsg, aParam.mType); + WriteParam(aMsg, aParam.mInputSource); + WriteParam(aMsg, aParam.mButtons); + WriteParam(aMsg, aParam.mOrigin); + WriteParam(aMsg, aParam.mLocalOrigin); + WriteParam(aMsg, aParam.mHandledByAPZ); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, static_cast(aResult)) && + ReadParam(aMsg, aIter, &aResult->mButtonType) && + ReadParam(aMsg, aIter, &aResult->mType) && + ReadParam(aMsg, aIter, &aResult->mInputSource) && + ReadParam(aMsg, aIter, &aResult->mButtons) && + ReadParam(aMsg, aIter, &aResult->mOrigin) && + ReadParam(aMsg, aIter, &aResult->mLocalOrigin) && + ReadParam(aMsg, aIter, &aResult->mHandledByAPZ); + } +}; + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::PanGestureInput::PanGestureType, + mozilla::PanGestureInput::PanGestureType::PANGESTURE_MAYSTART, + mozilla::PanGestureInput::PanGestureType::PANGESTURE_SENTINEL> +{}; + +template<> +struct ParamTraits +{ + typedef mozilla::PanGestureInput paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, static_cast(aParam)); + WriteParam(aMsg, aParam.mType); + WriteParam(aMsg, aParam.mPanStartPoint); + WriteParam(aMsg, aParam.mPanDisplacement); + WriteParam(aMsg, aParam.mLocalPanStartPoint); + WriteParam(aMsg, aParam.mLocalPanDisplacement); + WriteParam(aMsg, aParam.mLineOrPageDeltaX); + WriteParam(aMsg, aParam.mLineOrPageDeltaY); + WriteParam(aMsg, aParam.mUserDeltaMultiplierX); + WriteParam(aMsg, aParam.mUserDeltaMultiplierY); + WriteParam(aMsg, aParam.mHandledByAPZ); + WriteParam(aMsg, aParam.mFollowedByMomentum); + WriteParam(aMsg, aParam.mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, static_cast(aResult)) && + ReadParam(aMsg, aIter, &aResult->mType) && + ReadParam(aMsg, aIter, &aResult->mPanStartPoint) && + ReadParam(aMsg, aIter, &aResult->mPanDisplacement) && + ReadParam(aMsg, aIter, &aResult->mLocalPanStartPoint) && + ReadParam(aMsg, aIter, &aResult->mLocalPanDisplacement) && + ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) && + ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) && + ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) && + ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) && + ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) && + ReadParam(aMsg, aIter, &aResult->mFollowedByMomentum) && + ReadParam(aMsg, aIter, &aResult->mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection); + } +}; + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::PinchGestureInput::PinchGestureType, + mozilla::PinchGestureInput::PinchGestureType::PINCHGESTURE_START, + mozilla::PinchGestureInput::PinchGestureType::PINCHGESTURE_SENTINEL> +{}; + +template<> +struct ParamTraits +{ + typedef mozilla::PinchGestureInput paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, static_cast(aParam)); + WriteParam(aMsg, aParam.mType); + WriteParam(aMsg, aParam.mFocusPoint); + WriteParam(aMsg, aParam.mLocalFocusPoint); + WriteParam(aMsg, aParam.mCurrentSpan); + WriteParam(aMsg, aParam.mPreviousSpan); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, static_cast(aResult)) && + ReadParam(aMsg, aIter, &aResult->mType) && + ReadParam(aMsg, aIter, &aResult->mFocusPoint) && + ReadParam(aMsg, aIter, &aResult->mLocalFocusPoint) && + ReadParam(aMsg, aIter, &aResult->mCurrentSpan) && + ReadParam(aMsg, aIter, &aResult->mPreviousSpan); + } +}; + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::TapGestureInput::TapGestureType, + mozilla::TapGestureInput::TapGestureType::TAPGESTURE_LONG, + mozilla::TapGestureInput::TapGestureType::TAPGESTURE_SENTINEL> +{}; + +template<> +struct ParamTraits +{ + typedef mozilla::TapGestureInput paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, static_cast(aParam)); + WriteParam(aMsg, aParam.mType); + WriteParam(aMsg, aParam.mPoint); + WriteParam(aMsg, aParam.mLocalPoint); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, static_cast(aResult)) && + ReadParam(aMsg, aIter, &aResult->mType) && + ReadParam(aMsg, aIter, &aResult->mPoint) && + ReadParam(aMsg, aIter, &aResult->mLocalPoint); + } +}; + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::ScrollWheelInput::ScrollDeltaType, + mozilla::ScrollWheelInput::ScrollDeltaType::SCROLLDELTA_LINE, + mozilla::ScrollWheelInput::ScrollDeltaType::SCROLLDELTA_SENTINEL> +{}; + +template<> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::ScrollWheelInput::ScrollMode, + mozilla::ScrollWheelInput::ScrollMode::SCROLLMODE_INSTANT, + mozilla::ScrollWheelInput::ScrollMode::SCROLLMODE_SENTINEL> +{}; + +template<> +struct ParamTraits +{ + typedef mozilla::ScrollWheelInput paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, static_cast(aParam)); + WriteParam(aMsg, aParam.mDeltaType); + WriteParam(aMsg, aParam.mScrollMode); + WriteParam(aMsg, aParam.mOrigin); + WriteParam(aMsg, aParam.mHandledByAPZ); + WriteParam(aMsg, aParam.mDeltaX); + WriteParam(aMsg, aParam.mDeltaY); + WriteParam(aMsg, aParam.mLocalOrigin); + WriteParam(aMsg, aParam.mLineOrPageDeltaX); + WriteParam(aMsg, aParam.mLineOrPageDeltaY); + WriteParam(aMsg, aParam.mScrollSeriesNumber); + WriteParam(aMsg, aParam.mUserDeltaMultiplierX); + WriteParam(aMsg, aParam.mUserDeltaMultiplierY); + WriteParam(aMsg, aParam.mMayHaveMomentum); + WriteParam(aMsg, aParam.mIsMomentum); + WriteParam(aMsg, aParam.mAllowToOverrideSystemScrollSpeed); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, static_cast(aResult)) && + ReadParam(aMsg, aIter, &aResult->mDeltaType) && + ReadParam(aMsg, aIter, &aResult->mScrollMode) && + ReadParam(aMsg, aIter, &aResult->mOrigin) && + ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) && + ReadParam(aMsg, aIter, &aResult->mDeltaX) && + ReadParam(aMsg, aIter, &aResult->mDeltaY) && + ReadParam(aMsg, aIter, &aResult->mLocalOrigin) && + ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) && + ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) && + ReadParam(aMsg, aIter, &aResult->mScrollSeriesNumber) && + ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) && + ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) && + ReadParam(aMsg, aIter, &aResult->mMayHaveMomentum) && + ReadParam(aMsg, aIter, &aResult->mIsMomentum) && + ReadParam(aMsg, aIter, &aResult->mAllowToOverrideSystemScrollSpeed); + } +}; + } // namespace IPC #endif // nsGUIEventIPC_h__