From c0b437cb14e69e47dcabb1ea005fba12213790ca Mon Sep 17 00:00:00 2001 From: Ryan Hunt Date: Sun, 31 Jul 2016 12:39:00 -0700 Subject: [PATCH] Bug 1289650 - Use PAPZCTreeManager in content process instead of PAPZ. r=kats MozReview-Commit-ID: LRhvZlNqli --- dom/ipc/TabChild.cpp | 44 +++--- dom/ipc/TabChild.h | 2 + .../apz/public/GeckoContentController.h | 2 +- gfx/layers/ipc/APZCTreeManagerParent.cpp | 38 ++++- gfx/layers/ipc/APZCTreeManagerParent.h | 8 ++ gfx/layers/ipc/APZChild.cpp | 2 +- gfx/layers/ipc/APZChild.h | 34 ++--- gfx/layers/ipc/CompositorBridgeParent.cpp | 33 +++-- gfx/layers/ipc/CompositorBridgeParent.h | 2 + gfx/layers/ipc/PAPZ.ipdl | 48 +------ gfx/layers/ipc/PAPZCTreeManager.ipdl | 50 ++++--- gfx/layers/ipc/RemoteContentController.cpp | 130 +----------------- gfx/layers/ipc/RemoteContentController.h | 28 ---- layout/base/nsLayoutUtils.cpp | 2 +- layout/ipc/RenderFrameParent.h | 1 - 15 files changed, 147 insertions(+), 277 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 05b291d1a7d2..9f83ea70b1f5 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -670,9 +670,8 @@ TabChild::ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId, bool aPreventDefault) const { - if (mAPZChild) { - mAPZChild->SendContentReceivedInputBlock(aGuid, aInputBlockId, - aPreventDefault); + if (mApzcTreeManager) { + mApzcTreeManager->ContentReceivedInputBlock(aInputBlockId, aPreventDefault); } } @@ -680,8 +679,8 @@ void TabChild::SetTargetAPZC(uint64_t aInputBlockId, const nsTArray& aTargets) const { - if (mAPZChild) { - mAPZChild->SendSetTargetAPZC(aInputBlockId, aTargets); + if (mApzcTreeManager) { + mApzcTreeManager->SetTargetAPZC(aInputBlockId, aTargets); } } @@ -689,8 +688,8 @@ void TabChild::SetAllowedTouchBehavior(uint64_t aInputBlockId, const nsTArray& aTargets) const { - if (mAPZChild) { - mAPZChild->SendSetAllowedTouchBehavior(aInputBlockId, aTargets); + if (mApzcTreeManager) { + mApzcTreeManager->SetAllowedTouchBehavior(aInputBlockId, aTargets); } } @@ -706,12 +705,14 @@ TabChild::DoUpdateZoomConstraints(const uint32_t& aPresShellId, return true; } - if (!mAPZChild) { + if (!mApzcTreeManager) { return false; } - return mAPZChild->SendUpdateZoomConstraints(aPresShellId, aViewId, - aConstraints); + ScrollableLayerGuid guid = ScrollableLayerGuid(mLayersId, aPresShellId, aViewId); + + mApzcTreeManager->UpdateZoomConstraints(guid, aConstraints); + return true; } nsresult @@ -1704,10 +1705,10 @@ TabChild::HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers, uint32_t presShellId; ViewID viewId; if (APZCCallbackHelper::GetOrCreateScrollIdentifiers( - document->GetDocumentElement(), &presShellId, &viewId) && - mAPZChild) { - mAPZChild->SendZoomToRect(presShellId, viewId, zoomToRect, - DEFAULT_BEHAVIOR); + document->GetDocumentElement(), &presShellId, &viewId) && mApzcTreeManager) { + ScrollableLayerGuid guid(mLayersId, presShellId, viewId); + + mApzcTreeManager->ZoomToRect(guid, zoomToRect, DEFAULT_BEHAVIOR); } } @@ -1776,8 +1777,11 @@ TabChild::NotifyAPZStateChange(const ViewID& aViewId, void TabChild::StartScrollbarDrag(const layers::AsyncDragMetrics& aDragMetrics) { - if (mAPZChild) { - mAPZChild->SendStartScrollbarDrag(aDragMetrics); + ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId, + aDragMetrics.mViewId); + + if (mApzcTreeManager) { + mApzcTreeManager->StartScrollbarDrag(guid, aDragMetrics); } } @@ -1787,8 +1791,10 @@ TabChild::ZoomToRect(const uint32_t& aPresShellId, const CSSRect& aRect, const uint32_t& aFlags) { - if (mAPZChild) { - mAPZChild->SendZoomToRect(aPresShellId, aViewId, aRect, aFlags); + ScrollableLayerGuid guid(mLayersId, aPresShellId, aViewId); + + if (mApzcTreeManager) { + mApzcTreeManager->ZoomToRect(guid, aRect, aFlags); } } @@ -2752,6 +2758,8 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden mLayersId = aLayersId; } + mApzcTreeManager = CompositorBridgeChild::Get()->GetAPZCTreeManager(mLayersId); + nsCOMPtr observerService = mozilla::services::GetObserverService(); diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index a06f753bb84e..29a720c88d01 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -51,6 +51,7 @@ namespace layers { class APZChild; class APZEventState; class AsyncDragMetrics; +class IAPZCTreeManager; class ImageCompositeNotification; } // namespace layers @@ -774,6 +775,7 @@ private: AutoTArray mAudioChannelsActive; + RefPtr mApzcTreeManager; // APZChild clears this pointer from its destructor, so it shouldn't be a // dangling pointer. layers::APZChild* mAPZChild; diff --git a/gfx/layers/apz/public/GeckoContentController.h b/gfx/layers/apz/public/GeckoContentController.h index e9b13bfad89f..216b99e3627e 100644 --- a/gfx/layers/apz/public/GeckoContentController.h +++ b/gfx/layers/apz/public/GeckoContentController.h @@ -143,7 +143,7 @@ public: virtual void SetScrollingRootContent(bool isRootContent) {} GeckoContentController() {} - virtual void ChildAdopted() {} + /** * Needs to be called on the main thread. */ diff --git a/gfx/layers/ipc/APZCTreeManagerParent.cpp b/gfx/layers/ipc/APZCTreeManagerParent.cpp index 9c7b9a8fd1e5..acacdc5f74eb 100644 --- a/gfx/layers/ipc/APZCTreeManagerParent.cpp +++ b/gfx/layers/ipc/APZCTreeManagerParent.cpp @@ -19,6 +19,13 @@ APZCTreeManagerParent::APZCTreeManagerParent(uint64_t aLayersId, RefPtr aAPZCTreeManager) +{ + MOZ_ASSERT(aAPZCTreeManager != nullptr); + mTreeManager = aAPZCTreeManager; +} + bool APZCTreeManagerParent::RecvReceiveMultiTouchInputEvent( const MultiTouchInput& aEvent, @@ -154,7 +161,12 @@ APZCTreeManagerParent::RecvContentReceivedInputBlock( const uint64_t& aInputBlockId, const bool& aPreventDefault) { - mTreeManager->ContentReceivedInputBlock(aInputBlockId, aPreventDefault); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod(mTreeManager, + &IAPZCTreeManager::ContentReceivedInputBlock, + aInputBlockId, + aPreventDefault)); + return true; } @@ -171,7 +183,14 @@ APZCTreeManagerParent::RecvSetTargetAPZC( } } - mTreeManager->SetTargetAPZC(aInputBlockId, aTargets); + void (IAPZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray&) + = &IAPZCTreeManager::SetTargetAPZC; + + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + >> + (mTreeManager, setTargetApzcFunc, aInputBlockId, aTargets)); + return true; } @@ -222,7 +241,13 @@ APZCTreeManagerParent::RecvSetAllowedTouchBehavior( const uint64_t& aInputBlockId, nsTArray&& aValues) { - mTreeManager->SetAllowedTouchBehavior(aInputBlockId, aValues); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + >> + (mTreeManager, + &IAPZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, Move(aValues))); + return true; } @@ -237,7 +262,12 @@ APZCTreeManagerParent::RecvStartScrollbarDrag( return false; } - mTreeManager->StartScrollbarDrag(aGuid, aDragMetrics); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod( + mTreeManager, + &IAPZCTreeManager::StartScrollbarDrag, + aGuid, aDragMetrics)); + return true; } diff --git a/gfx/layers/ipc/APZCTreeManagerParent.h b/gfx/layers/ipc/APZCTreeManagerParent.h index 855d462ea40f..b22f6ade201d 100644 --- a/gfx/layers/ipc/APZCTreeManagerParent.h +++ b/gfx/layers/ipc/APZCTreeManagerParent.h @@ -22,6 +22,14 @@ public: explicit APZCTreeManagerParent(uint64_t aLayersId, RefPtr aAPZCTreeManager); virtual ~APZCTreeManagerParent() { } + uint64_t LayersId() const { return mLayersId; } + + /** + * Called when the layer tree that this protocol is connected to + * is adopted by another compositor, and we need to switch APZCTreeManagers. + */ + void ChildAdopted(RefPtr aAPZCTreeManager); + bool RecvReceiveMultiTouchInputEvent( const MultiTouchInput& aEvent, diff --git a/gfx/layers/ipc/APZChild.cpp b/gfx/layers/ipc/APZChild.cpp index cf5ee6ec11b2..e426e78e331d 100644 --- a/gfx/layers/ipc/APZChild.cpp +++ b/gfx/layers/ipc/APZChild.cpp @@ -94,7 +94,7 @@ APZChild::~APZChild() } bool -APZChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics) +APZChild::RecvRequestContentRepaint(const FrameMetrics& aFrameMetrics) { return mBrowser->UpdateFrame(aFrameMetrics); } diff --git a/gfx/layers/ipc/APZChild.h b/gfx/layers/ipc/APZChild.h index d71dd82e2b51..76be97aec036 100644 --- a/gfx/layers/ipc/APZChild.h +++ b/gfx/layers/ipc/APZChild.h @@ -26,25 +26,25 @@ public: ~APZChild(); - virtual bool RecvUpdateFrame(const FrameMetrics& frame) override; - - virtual bool RecvHandleTap(const TapType& aType, - const LayoutDevicePoint& aPoint, - const Modifiers& aModifiers, - const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId, - const bool& aCallTakeFocusForClickFromTap) override; - - virtual bool RecvNotifyAPZStateChange(const ViewID& aViewId, - const APZStateChange& aChange, - const int& aArg) override; - - virtual bool RecvNotifyFlushComplete() override; - - virtual bool RecvDestroy() override; - void SetBrowser(dom::TabChild* aBrowser); + bool RecvRequestContentRepaint(const FrameMetrics& frame) override; + + bool RecvHandleTap(const TapType& aType, + const LayoutDevicePoint& aPoint, + const Modifiers& aModifiers, + const ScrollableLayerGuid& aGuid, + const uint64_t& aInputBlockId, + const bool& aCallTakeFocusForClickFromTap) override; + + bool RecvNotifyAPZStateChange(const ViewID& aViewId, + const APZStateChange& aChange, + const int& aArg) override; + + bool RecvNotifyFlushComplete() override; + + bool RecvDestroy() override; + private: APZChild(); diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index b274800e11d4..0511757dd1ef 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -104,7 +104,8 @@ using base::ProcessId; using base::Thread; CompositorBridgeParent::LayerTreeState::LayerTreeState() - : mParent(nullptr) + : mApzcTreeManagerParent(nullptr) + , mParent(nullptr) , mLayerManager(nullptr) , mCrossProcessParent(nullptr) , mLayerTree(nullptr) @@ -1801,7 +1802,7 @@ CompositorBridgeParent::UpdateRemoteContentController(uint64_t aLayersId, bool CompositorBridgeParent::RecvAdoptChild(const uint64_t& child) { - RefPtr controller; + APZCTreeManagerParent* parent; { MonitorAutoLock lock(*sIndirectLayerTreesLock); NotifyChildCreated(child); @@ -1811,14 +1812,11 @@ CompositorBridgeParent::RecvAdoptChild(const uint64_t& child) if (sIndirectLayerTrees[child].mRoot) { sIndirectLayerTrees[child].mRoot->AsLayerComposite()->SetLayerManager(mLayerManager); } - controller = sIndirectLayerTrees[child].mController; + parent = sIndirectLayerTrees[child].mApzcTreeManagerParent; } - // Calling ChildAdopted on controller will acquire a lock, to avoid a - // potential deadlock between that lock and sIndirectLayerTreesLock we - // release sIndirectLayerTreesLock first before calling ChildAdopted. - if (mApzcTreeManager && controller) { - controller->ChildAdopted(); + if (mApzcTreeManager && parent) { + parent->ChildAdopted(mApzcTreeManager); } return true; } @@ -2561,14 +2559,27 @@ CrossProcessCompositorBridgeParent::AllocPAPZCTreeManagerParent(const uint64_t& MonitorAutoLock lock(*sIndirectLayerTreesLock); CompositorBridgeParent::LayerTreeState& state = sIndirectLayerTrees[aLayersId]; - MOZ_ASSERT(state.mParent); - return new APZCTreeManagerParent(aLayersId, state.mParent->GetAPZCTreeManager()); + MOZ_ASSERT(!state.mApzcTreeManagerParent); + state.mApzcTreeManagerParent = new APZCTreeManagerParent(aLayersId, state.mParent->GetAPZCTreeManager()); + + return state.mApzcTreeManagerParent; } bool CrossProcessCompositorBridgeParent::DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor) { - delete aActor; + APZCTreeManagerParent* parent = static_cast(aActor); + + MonitorAutoLock lock(*sIndirectLayerTreesLock); + auto iter = sIndirectLayerTrees.find(parent->LayersId()); + if (iter != sIndirectLayerTrees.end()) { + CompositorBridgeParent::LayerTreeState& state = iter->second; + MOZ_ASSERT(state.mApzcTreeManagerParent == parent); + state.mApzcTreeManagerParent = nullptr; + } + + delete parent; + return true; } diff --git a/gfx/layers/ipc/CompositorBridgeParent.h b/gfx/layers/ipc/CompositorBridgeParent.h index d1a941ef5ef3..7b1315d3bc8c 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.h +++ b/gfx/layers/ipc/CompositorBridgeParent.h @@ -58,6 +58,7 @@ class Shmem; namespace layers { class APZCTreeManager; +class APZCTreeManagerParent; class AsyncCompositionManager; class Compositor; class CompositorBridgeParent; @@ -429,6 +430,7 @@ public: ~LayerTreeState(); RefPtr mRoot; RefPtr mController; + APZCTreeManagerParent* mApzcTreeManagerParent; CompositorBridgeParent* mParent; LayerManagerComposite* mLayerManager; // Pointer to the CrossProcessCompositorBridgeParent. Used by APZCs to share diff --git a/gfx/layers/ipc/PAPZ.ipdl b/gfx/layers/ipc/PAPZ.ipdl index ad08ac8b69bd..4e57a6698fc4 100644 --- a/gfx/layers/ipc/PAPZ.ipdl +++ b/gfx/layers/ipc/PAPZ.ipdl @@ -42,63 +42,23 @@ sync protocol PAPZ manager PContent; parent: + async UpdateHitRegion(nsRegion aRegion); - /** - * Instructs the TabParent to forward a request to zoom to a rect given in - * CSS pixels. This rect is relative to the document. - */ - async ZoomToRect(uint32_t aPresShellId, ViewID aViewId, CSSRect aRect, uint32_t aFlags); - - /** - * We know for sure that content has either preventDefaulted or not - * preventDefaulted. This applies to an entire batch of touch events. It is - * expected that, if there are any DOM touch listeners, touch events will be - * batched and only processed for panning and zooming if content does not - * preventDefault. - */ - async ContentReceivedInputBlock(ScrollableLayerGuid aGuid, uint64_t aInputBlockId, bool aPreventDefault); - - /** - * Notifies the APZ code of the results of the gecko hit-test for a - * particular input block. Each target corresponds to one touch point in the - * touch event. - */ - async SetTargetAPZC(uint64_t aInputBlockId, ScrollableLayerGuid[] aTargets); - - // Start an APZ drag on a scrollbar - async StartScrollbarDrag(AsyncDragMetrics aDragMetrics); - - /** - * Notifies the APZ code of the allowed touch-behaviours for a particular - * input block. Each item in the aFlags array corresponds to one touch point - * in the touch event. - */ - async SetAllowedTouchBehavior(uint64_t aInputBlockId, TouchBehaviorFlags[] aFlags); - - /** - * Updates the zoom constraints for a scrollable frame in this tab. - * The zoom controller code lives on the parent side and so this allows it to - * have up-to-date zoom constraints. - */ - async UpdateZoomConstraints(uint32_t aPresShellId, ViewID aViewId, - MaybeZoomConstraints aConstraints); - async __delete__(); child: - async UpdateFrame(FrameMetrics frame); + async RequestContentRepaint(FrameMetrics frame); - // The following methods correspond to functions on the GeckoContentController - // interface in gfx/layers/apz/public/GeckoContentController.h. Refer to documentation - // in that file for these functions. // The aCallTakeFocusForClickFromTap argument is used for eSingleTap types, // to request that the child take focus before dispatching the mouse events // for the tap (otherwise the resulting focus behaviour is incorrect). async HandleTap(TapType aType, LayoutDevicePoint point, Modifiers aModifiers, ScrollableLayerGuid aGuid, uint64_t aInputBlockId, bool aCallTakeFocusForClickFromTap); + async NotifyAPZStateChange(ViewID aViewId, APZStateChange aChange, int aArg); + async NotifyFlushComplete(); async Destroy(); diff --git a/gfx/layers/ipc/PAPZCTreeManager.ipdl b/gfx/layers/ipc/PAPZCTreeManager.ipdl index ee3b8cae57f1..ea86424b39d3 100644 --- a/gfx/layers/ipc/PAPZCTreeManager.ipdl +++ b/gfx/layers/ipc/PAPZCTreeManager.ipdl @@ -40,6 +40,34 @@ manager PCompositorBridge; parent: + // These messages correspond to the methods + // on the IAPZCTreeManager interface + + 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); + + // The following messages are used to + // implement the ReceiveInputEvent methods + sync ReceiveMultiTouchInputEvent(MultiTouchInput aEvent) returns (nsEventStatus aOutStatus, MultiTouchInput aOutEvent, @@ -76,28 +104,6 @@ parent: 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) diff --git a/gfx/layers/ipc/RemoteContentController.cpp b/gfx/layers/ipc/RemoteContentController.cpp index 651ebe060d74..d5455bac6854 100644 --- a/gfx/layers/ipc/RemoteContentController.cpp +++ b/gfx/layers/ipc/RemoteContentController.cpp @@ -12,7 +12,6 @@ #include "MainThreadUtils.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/TabParent.h" -#include "mozilla/layers/IAPZCTreeManager.h" #include "mozilla/layers/APZThreadUtils.h" #include "mozilla/layout/RenderFrameParent.h" #include "mozilla/gfx/GPUProcessManager.h" @@ -48,7 +47,7 @@ RemoteContentController::RequestContentRepaint(const FrameMetrics& aFrameMetrics { MOZ_ASSERT(NS_IsMainThread()); if (CanSend()) { - Unused << SendUpdateFrame(aFrameMetrics); + Unused << SendRequestContentRepaint(aFrameMetrics); } } @@ -162,113 +161,9 @@ RemoteContentController::RecvUpdateHitRegion(const nsRegion& aRegion) return true; } -bool -RemoteContentController::RecvZoomToRect(const uint32_t& aPresShellId, - const ViewID& aViewId, - const CSSRect& aRect, - const uint32_t& aFlags) -{ - if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - apzcTreeManager->ZoomToRect(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId), - aRect, aFlags); - } - return true; -} - -bool -RemoteContentController::RecvContentReceivedInputBlock(const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId, - const bool& aPreventDefault) -{ - if (aGuid.mLayersId != mLayersId) { - // Guard against bad data from hijacked child processes - NS_ERROR("Unexpected layers id in RecvContentReceivedInputBlock; dropping message..."); - return false; - } - if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod(apzcTreeManager, - &IAPZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, aPreventDefault)); - - } - return true; -} - -bool -RemoteContentController::RecvStartScrollbarDrag(const AsyncDragMetrics& aDragMetrics) -{ - if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId, - aDragMetrics.mViewId); - - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - (apzcTreeManager, - &IAPZCTreeManager::StartScrollbarDrag, - guid, aDragMetrics)); - } - return true; -} - -bool -RemoteContentController::RecvSetTargetAPZC(const uint64_t& aInputBlockId, - nsTArray&& aTargets) -{ - for (size_t i = 0; i < aTargets.Length(); i++) { - if (aTargets[i].mLayersId != mLayersId) { - // Guard against bad data from hijacked child processes - NS_ERROR("Unexpected layers id in SetTargetAPZC; dropping message..."); - return false; - } - } - if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - // need a local var to disambiguate between the SetTargetAPZC overloads. - void (IAPZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray&) - = &IAPZCTreeManager::SetTargetAPZC; - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - >> - (apzcTreeManager, setTargetApzcFunc, aInputBlockId, aTargets)); - - } - return true; -} - -bool -RemoteContentController::RecvSetAllowedTouchBehavior(const uint64_t& aInputBlockId, - nsTArray&& aFlags) -{ - if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - APZThreadUtils::RunOnControllerThread(NewRunnableMethod - >> - (apzcTreeManager, - &IAPZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, Move(aFlags))); - } - return true; -} - -bool -RemoteContentController::RecvUpdateZoomConstraints(const uint32_t& aPresShellId, - const ViewID& aViewId, - const MaybeZoomConstraints& aConstraints) -{ - if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - apzcTreeManager->UpdateZoomConstraints(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId), - aConstraints); - } - return true; -} - void RemoteContentController::ActorDestroy(ActorDestroyReason aWhy) { - { - MutexAutoLock lock(mMutex); - mApzcTreeManager = nullptr; - } mBrowserParent = nullptr; uint64_t key = mLayersId; @@ -298,28 +193,5 @@ RemoteContentController::Destroy() })); } -void -RemoteContentController::ChildAdopted() -{ - // Clear the cached APZCTreeManager. - MutexAutoLock lock(mMutex); - mApzcTreeManager = nullptr; -} - -already_AddRefed -RemoteContentController::GetApzcTreeManager() -{ - // We can't get a ref to the APZCTreeManager until after the child is - // created and the static getter knows which CompositorBridgeParent is - // instantiated with this layers ID. That's why try to fetch it when - // we first need it and cache the result. - MutexAutoLock lock(mMutex); - if (!mApzcTreeManager) { - mApzcTreeManager = GPUProcessManager::Get()->GetAPZCTreeManagerForLayers(mLayersId); - } - RefPtr apzcTreeManager(mApzcTreeManager); - return apzcTreeManager.forget(); -} - } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/RemoteContentController.h b/gfx/layers/ipc/RemoteContentController.h index 81c7f919653e..37b5f93aeebe 100644 --- a/gfx/layers/ipc/RemoteContentController.h +++ b/gfx/layers/ipc/RemoteContentController.h @@ -19,8 +19,6 @@ class TabParent; namespace layers { -class IAPZCTreeManager; - /** * RemoteContentController uses the PAPZ protocol to implement a * GeckoContentController for a browser living in a remote process. @@ -65,40 +63,16 @@ public: virtual bool RecvUpdateHitRegion(const nsRegion& aRegion) override; - virtual bool RecvZoomToRect(const uint32_t& aPresShellId, - const ViewID& aViewId, - const CSSRect& aRect, - const uint32_t& aFlags) override; - - virtual bool RecvContentReceivedInputBlock(const ScrollableLayerGuid& aGuid, - const uint64_t& aInputBlockId, - const bool& aPreventDefault) override; - - virtual bool RecvStartScrollbarDrag(const AsyncDragMetrics& aDragMetrics) override; - - virtual bool RecvSetTargetAPZC(const uint64_t& aInputBlockId, - nsTArray&& aTargets) override; - - virtual bool RecvSetAllowedTouchBehavior(const uint64_t& aInputBlockId, - nsTArray&& aFlags) override; - - virtual bool RecvUpdateZoomConstraints(const uint32_t& aPresShellId, - const ViewID& aViewId, - const MaybeZoomConstraints& aConstraints) override; - virtual void ActorDestroy(ActorDestroyReason aWhy) override; virtual void Destroy() override; - virtual void ChildAdopted() override; - private: bool CanSend() { MOZ_ASSERT(NS_IsMainThread()); return !!mBrowserParent; } - already_AddRefed GetApzcTreeManager(); MessageLoop* mUILoop; uint64_t mLayersId; @@ -106,8 +80,6 @@ private: // Mutex protecting members below accessed from multiple threads. mozilla::Mutex mMutex; - - RefPtr mApzcTreeManager; nsRegion mTouchSensitiveRegion; }; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 8619c3278884..aae2b44cf499 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -9285,7 +9285,7 @@ nsLayoutUtils::UpdateDisplayPortMarginsFromPendingMessages() { mozilla::dom::ContentChild::GetSingleton()->GetIPCChannel()) { mozilla::dom::ContentChild::GetSingleton()->GetIPCChannel()->PeekMessages( [](const IPC::Message& aMsg) -> bool { - if (aMsg.type() == mozilla::layers::PAPZ::Msg_UpdateFrame__ID) { + if (aMsg.type() == mozilla::layers::PAPZ::Msg_RequestContentRepaint__ID) { PickleIterator iter(aMsg); FrameMetrics frame; if (!IPC::ReadParam(&aMsg, &iter, &frame)) { diff --git a/layout/ipc/RenderFrameParent.h b/layout/ipc/RenderFrameParent.h index c10d1055b124..d05017fe7fc3 100644 --- a/layout/ipc/RenderFrameParent.h +++ b/layout/ipc/RenderFrameParent.h @@ -24,7 +24,6 @@ namespace mozilla { class InputEvent; namespace layers { -class APZCTreeManager; class AsyncDragMetrics; class TargetConfig; struct TextureFactoryIdentifier;