Bug 1289650 - Use PAPZCTreeManager in content process instead of PAPZ. draft
authorRyan Hunt <rhunt@mozilla.com>
Sun, 31 Jul 2016 12:39:00 -0700
changeset 400769 ef2530a448a87534ed73aa31bc16ccaad4a21d07
parent 400768 a7198828bfb50db7b51e0f54174476791a1e5584
child 400770 fe3e07a3604c94ebe3ce611d9dbc00697c026603
push id26277
push userbmo:rhunt@mozilla.com
push dateMon, 15 Aug 2016 19:04:21 +0000
bugs1289650
milestone51.0a1
Bug 1289650 - Use PAPZCTreeManager in content process instead of PAPZ. MozReview-Commit-ID: LRhvZlNqli
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
gfx/layers/ipc/APZCTreeManagerParent.cpp
gfx/layers/ipc/APZChild.cpp
gfx/layers/ipc/APZChild.h
gfx/layers/ipc/CompositorBridgeChild.cpp
gfx/layers/ipc/CompositorBridgeChild.h
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/CompositorBridgeParent.h
gfx/layers/ipc/PAPZ.ipdl
gfx/layers/ipc/PAPZCTreeManager.ipdl
gfx/layers/ipc/PCompositorBridge.ipdl
gfx/layers/ipc/RemoteContentController.cpp
gfx/layers/ipc/RemoteContentController.h
layout/base/nsLayoutUtils.cpp
layout/ipc/RenderFrameParent.h
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -664,58 +664,59 @@ TabChild::Observe(nsISupports *aSubject,
   return NS_OK;
 }
 
 void
 TabChild::ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid,
                                     uint64_t aInputBlockId,
                                     bool aPreventDefault) const
 {
-  if (mAPZChild) {
-    mAPZChild->SendContentReceivedInputBlock(aGuid, aInputBlockId,
-                                             aPreventDefault);
+  if (mApzcTreeManager) {
+    mApzcTreeManager->ContentReceivedInputBlock(aInputBlockId, aPreventDefault);
   }
 }
 
 void
 TabChild::SetTargetAPZC(uint64_t aInputBlockId,
                         const nsTArray<ScrollableLayerGuid>& aTargets) const
 {
-  if (mAPZChild) {
-    mAPZChild->SendSetTargetAPZC(aInputBlockId, aTargets);
+  if (mApzcTreeManager) {
+    mApzcTreeManager->SetTargetAPZC(aInputBlockId, aTargets);
   }
 }
 
 void
 TabChild::SetAllowedTouchBehavior(uint64_t aInputBlockId,
                                   const nsTArray<TouchBehaviorFlags>& aTargets) const
 {
-  if (mAPZChild) {
-    mAPZChild->SendSetAllowedTouchBehavior(aInputBlockId, aTargets);
+  if (mApzcTreeManager) {
+    mApzcTreeManager->SetAllowedTouchBehavior(aInputBlockId, aTargets);
   }
 }
 
 bool
 TabChild::DoUpdateZoomConstraints(const uint32_t& aPresShellId,
                                   const ViewID& aViewId,
                                   const Maybe<ZoomConstraints>& aConstraints)
 {
   if (sPreallocatedTab == this) {
     // If we're the preallocated tab, bail out because doing IPC will crash.
     // Once we get used for something we'll get another zoom constraints update
     // and all will be well.
     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
 TabChild::Init()
 {
   nsCOMPtr<nsIWebBrowser> webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
   if (!webBrowser) {
     NS_ERROR("Couldn't create a nsWebBrowser?");
@@ -1700,20 +1701,20 @@ TabChild::HandleDoubleTap(const CSSPoint
   CSSRect zoomToRect = CalculateRectToZoomTo(document, aPoint);
   // The double-tap can be dispatched by any scroll frame (so |aGuid| could be
   // the guid of any scroll frame), but the zoom-to-rect operation must be
   // performed by the root content scroll frame, so query its identifiers
   // for the SendZoomToRect() call rather than using the ones from |aGuid|.
   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);
   }
 }
 
 void
 TabChild::HandleTap(GeckoContentController::TapType aType,
                     const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
                     const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId,
                     bool aCallTakeFocusForClickFromTap)
@@ -1772,29 +1773,34 @@ TabChild::NotifyAPZStateChange(const Vie
     observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
   }
   return true;
 }
 
 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);
   }
 }
 
 void
 TabChild::ZoomToRect(const uint32_t& aPresShellId,
                      const FrameMetrics::ViewID& aViewId,
                      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);
   }
 }
 
 bool
 TabChild::RecvActivate()
 {
   nsCOMPtr<nsIWebBrowserFocus> browser = do_QueryInterface(WebNavigation());
   browser->Activate();
@@ -2747,16 +2753,18 @@ TabChild::InitRenderingState(const Textu
       if (!sTabChildren) {
         sTabChildren = new TabChildMap;
       }
       MOZ_ASSERT(!sTabChildren->Get(aLayersId));
       sTabChildren->Put(aLayersId, this);
       mLayersId = aLayersId;
     }
 
+    mApzcTreeManager = CompositorBridgeChild::Get()->GetAPZCTreeManager(mLayersId);
+
     nsCOMPtr<nsIObserverService> observerService =
         mozilla::services::GetObserverService();
 
     if (observerService) {
         observerService->AddObserver(this,
                                      BEFORE_FIRST_PAINT,
                                      false);
     }
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -46,16 +46,17 @@ namespace mozilla {
 namespace layout {
 class RenderFrameChild;
 } // namespace layout
 
 namespace layers {
 class APZChild;
 class APZEventState;
 class AsyncDragMetrics;
+class IAPZCTreeManager;
 class ImageCompositeNotification;
 } // namespace layers
 
 namespace widget {
 struct AutoCacheNativeKeyCommands;
 } // namespace widget
 
 namespace plugins {
@@ -769,16 +770,17 @@ private:
   bool mParentIsActive;
   bool mAsyncPanZoomEnabled;
   CSSSize mUnscaledInnerSize;
   bool mDidSetRealShowInfo;
   bool mDidLoadURLInit;
 
   AutoTArray<bool, NUMBER_OF_AUDIO_CHANNELS> mAudioChannelsActive;
 
+  RefPtr<layers::IAPZCTreeManager> mApzcTreeManager;
   // APZChild clears this pointer from its destructor, so it shouldn't be a
   // dangling pointer.
   layers::APZChild* mAPZChild;
 
   DISALLOW_EVIL_CONSTRUCTORS(TabChild);
 };
 
 } // namespace dom
--- a/gfx/layers/ipc/APZCTreeManagerParent.cpp
+++ b/gfx/layers/ipc/APZCTreeManagerParent.cpp
@@ -142,26 +142,38 @@ APZCTreeManagerParent::RecvZoomToRect(
   return true;
 }
 
 bool
 APZCTreeManagerParent::RecvContentReceivedInputBlock(
     const uint64_t& aInputBlockId,
     const bool& aPreventDefault)
 {
-  mTreeManager->ContentReceivedInputBlock(aInputBlockId, aPreventDefault);
+  APZThreadUtils::RunOnControllerThread(
+    NewRunnableMethod<uint64_t, bool>(mTreeManager,
+      &IAPZCTreeManager::ContentReceivedInputBlock,
+      aInputBlockId,
+      aPreventDefault));
+
   return true;
 }
 
 bool
 APZCTreeManagerParent::RecvSetTargetAPZC(
     const uint64_t& aInputBlockId,
     nsTArray<ScrollableLayerGuid>&& aTargets)
 {
-  mTreeManager->SetTargetAPZC(aInputBlockId, aTargets);
+  void (IAPZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&)
+      = &IAPZCTreeManager::SetTargetAPZC;
+
+  APZThreadUtils::RunOnControllerThread(NewRunnableMethod
+                                        <uint64_t,
+                                         StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>>
+                                        (mTreeManager, setTargetApzcFunc, aInputBlockId, aTargets));
+
   return true;
 }
 
 bool
 APZCTreeManagerParent::RecvUpdateZoomConstraints(
     const ScrollableLayerGuid& aGuid,
     const MaybeZoomConstraints& aConstraints)
 {
@@ -190,26 +202,37 @@ APZCTreeManagerParent::RecvSetDPI(const 
   return true;
 }
 
 bool
 APZCTreeManagerParent::RecvSetAllowedTouchBehavior(
     const uint64_t& aInputBlockId,
     nsTArray<TouchBehaviorFlags>&& aValues)
 {
-  mTreeManager->SetAllowedTouchBehavior(aInputBlockId, aValues);
+  APZThreadUtils::RunOnControllerThread(NewRunnableMethod
+                                        <uint64_t,
+                                         StoreCopyPassByRRef<nsTArray<TouchBehaviorFlags>>>
+                                        (mTreeManager,
+                                         &IAPZCTreeManager::SetAllowedTouchBehavior,
+                                         aInputBlockId, Move(aValues)));
+
   return true;
 }
 
 bool
 APZCTreeManagerParent::RecvStartScrollbarDrag(
     const ScrollableLayerGuid& aGuid,
     const AsyncDragMetrics& aDragMetrics)
 {
-  mTreeManager->StartScrollbarDrag(aGuid, aDragMetrics);
+    APZThreadUtils::RunOnControllerThread(
+        NewRunnableMethod<ScrollableLayerGuid, AsyncDragMetrics>(
+          mTreeManager,
+          &IAPZCTreeManager::StartScrollbarDrag,
+          aGuid, aDragMetrics));
+
   return true;
 }
 
 bool
 APZCTreeManagerParent::RecvSetLongTapEnabled(const bool& aTapGestureEnabled)
 {
   mTreeManager->SetLongTapEnabled(aTapGestureEnabled);
   return true;
--- a/gfx/layers/ipc/APZChild.cpp
+++ b/gfx/layers/ipc/APZChild.cpp
@@ -89,17 +89,17 @@ APZChild::~APZChild()
     nsCOMPtr<nsIObserverService> os = services::GetObserverService();
     os->RemoveObserver(mObserver, "tab-child-created");
   } else if (mBrowser) {
     mBrowser->SetAPZChild(nullptr);
   }
 }
 
 bool
-APZChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
+APZChild::RecvRequestContentRepaint(const FrameMetrics& aFrameMetrics)
 {
   return mBrowser->UpdateFrame(aFrameMetrics);
 }
 
 bool
 APZChild::RecvHandleTap(const TapType& aType,
                         const LayoutDevicePoint& aPoint,
                         const Modifiers& aModifiers,
@@ -108,21 +108,21 @@ APZChild::RecvHandleTap(const TapType& a
                         const bool& aCallTakeFocusForClickFromTap)
 {
   mBrowser->HandleTap(aType, aPoint, aModifiers, aGuid,
       aInputBlockId, aCallTakeFocusForClickFromTap);
   return true;
 }
 
 bool
-APZChild::RecvNotifyAPZStateChange(const ViewID& aViewId,
+APZChild::RecvNotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
                                    const APZStateChange& aChange,
                                    const int& aArg)
 {
-  return mBrowser->NotifyAPZStateChange(aViewId, aChange, aArg);
+  return mBrowser->NotifyAPZStateChange(aGuid.mScrollId, aChange, aArg);
 }
 
 bool
 APZChild::RecvNotifyFlushComplete()
 {
   nsCOMPtr<nsIPresShell> shell;
   if (nsCOMPtr<nsIDocument> doc = mBrowser->GetDocument()) {
     shell = doc->GetShell();
--- a/gfx/layers/ipc/APZChild.h
+++ b/gfx/layers/ipc/APZChild.h
@@ -21,34 +21,34 @@ namespace layers {
 
 class APZChild final : public PAPZChild
 {
 public:
   static APZChild* Create(const dom::TabId& aTabId);
 
   ~APZChild();
 
-  virtual bool RecvUpdateFrame(const FrameMetrics& frame) override;
+  void SetBrowser(dom::TabChild* aBrowser);
 
-  virtual bool RecvHandleTap(const TapType& aType,
-                             const LayoutDevicePoint& aPoint,
-                             const Modifiers& aModifiers,
-                             const ScrollableLayerGuid& aGuid,
-                             const uint64_t& aInputBlockId,
-                             const bool& aCallTakeFocusForClickFromTap) override;
+  bool RecvRequestContentRepaint(const FrameMetrics& frame) override;
 
-  virtual bool RecvNotifyAPZStateChange(const ViewID& aViewId,
-                                        const APZStateChange& aChange,
-                                        const int& aArg) override;
+  bool RecvHandleTap(const TapType& aType,
+                     const LayoutDevicePoint& aPoint,
+                     const Modifiers& aModifiers,
+                     const ScrollableLayerGuid& aGuid,
+                     const uint64_t& aInputBlockId,
+                     const bool& aCallTakeFocusForClickFromTap) override;
 
-  virtual bool RecvNotifyFlushComplete() override;
+  bool RecvNotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
+                                const APZStateChange& aChange,
+                                const int& aArg) override;
 
-  virtual bool RecvDestroy() override;
+  bool RecvNotifyFlushComplete() override;
 
-  void SetBrowser(dom::TabChild* aBrowser);
+  bool RecvDestroy() override;
 
 private:
   APZChild();
 
   void SetObserver(nsIObserver* aObserver);
 
   RefPtr<dom::TabChild> mBrowser;
   RefPtr<nsIObserver> mObserver;
--- a/gfx/layers/ipc/CompositorBridgeChild.cpp
+++ b/gfx/layers/ipc/CompositorBridgeChild.cpp
@@ -7,16 +7,18 @@
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/CompositorBridgeParent.h"
 #include "mozilla/layers/CompositorThread.h"
 #include <stddef.h>                     // for size_t
 #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/IAPZCTreeManager.h"
+#include "mozilla/layers/APZCTreeManagerChild.h"
 #include "mozilla/layers/LayerTransactionChild.h"
 #include "mozilla/layers/PLayerTransactionChild.h"
 #include "mozilla/layers/TextureClient.h"// for TextureClient
 #include "mozilla/layers/TextureClientPool.h"// for TextureClientPool
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/gfx/GPUProcessManager.h"
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "nsAutoPtr.h"
@@ -150,16 +152,33 @@ CompositorBridgeChild::ShutDown()
   if (sCompositorBridge) {
     sCompositorBridge->Destroy();
     do {
       NS_ProcessNextEvent(nullptr, true);
     } while (sCompositorBridge);
   }
 }
 
+RefPtr<IAPZCTreeManager>
+CompositorBridgeChild::GetAPZCTreeManager(uint64_t aLayerTreeId)
+{
+  bool apzEnabled = false;
+  Unused << SendAsyncPanZoomEnabled(aLayerTreeId, &apzEnabled);
+
+  if (!apzEnabled)
+    return nullptr;
+
+  PAPZCTreeManagerChild* child = SendPAPZCTreeManagerConstructor(aLayerTreeId);
+  if (!child)
+    return nullptr;
+  APZCTreeManagerChild* parentClass = static_cast<APZCTreeManagerChild*>(child);
+
+  return RefPtr<IAPZCTreeManager>(parentClass);
+}
+
 bool
 CompositorBridgeChild::LookupCompositorFrameMetrics(const FrameMetrics::ViewID aId,
                                                     FrameMetrics& aFrame)
 {
   SharedFrameMetricsData* data = mFrameMetricsTable.Get(aId);
   if (data) {
     data->CopyFrameMetrics(&aFrame);
     return true;
@@ -991,16 +1010,31 @@ CompositorBridgeChild::DeallocShmem(ipc:
 widget::PCompositorWidgetChild*
 CompositorBridgeChild::AllocPCompositorWidgetChild(const CompositorWidgetInitData& aInitData)
 {
   // We send the constructor manually.
   MOZ_CRASH("Should not be called");
   return nullptr;
 }
 
+PAPZCTreeManagerChild*
+CompositorBridgeChild::AllocPAPZCTreeManagerChild(const uint64_t& aLayersId)
+{
+  APZCTreeManagerChild* child = new APZCTreeManagerChild();
+  child->AddRef();
+  return child;
+}
+bool
+CompositorBridgeChild::DeallocPAPZCTreeManagerChild(PAPZCTreeManagerChild* aActor)
+{
+  APZCTreeManagerChild* parentclass = static_cast<APZCTreeManagerChild*>(aActor);
+  parentclass->Release();
+  return true;
+}
+
 bool
 CompositorBridgeChild::DeallocPCompositorWidgetChild(PCompositorWidgetChild* aActor)
 {
 #ifdef MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
   delete aActor;
   return true;
 #else
   return false;
--- a/gfx/layers/ipc/CompositorBridgeChild.h
+++ b/gfx/layers/ipc/CompositorBridgeChild.h
@@ -29,16 +29,18 @@ class TabChild;
 namespace widget {
 class CompositorWidget;
 } // namespace widget
 
 namespace layers {
 
 using mozilla::dom::TabChild;
 
+class IAPZCTreeManager;
+class APZCTreeManagerChild;
 class ClientLayerManager;
 class CompositorBridgeParent;
 class TextureClient;
 class TextureClientPool;
 struct FrameMetrics;
 
 class CompositorBridgeChild final : public PCompositorBridgeChild,
                                     public TextureForwarder,
@@ -204,16 +206,21 @@ public:
   virtual bool AllocShmem(size_t aSize,
                           mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
                           mozilla::ipc::Shmem* aShmem) override;
   virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
 
   PCompositorWidgetChild* AllocPCompositorWidgetChild(const CompositorWidgetInitData& aInitData) override;
   bool DeallocPCompositorWidgetChild(PCompositorWidgetChild* aActor) override;
 
+  RefPtr<IAPZCTreeManager> GetAPZCTreeManager(uint64_t aLayerTreeId);
+
+  PAPZCTreeManagerChild* AllocPAPZCTreeManagerChild(const uint64_t& aLayersId) override;
+  bool DeallocPAPZCTreeManagerChild(PAPZCTreeManagerChild* aActor) override;
+
   virtual ShmemAllocator* AsShmemAllocator() override { return this; }
 
   void ProcessingError(Result aCode, const char* aReason) override;
 
 private:
   // Private destructor, to discourage deletion outside of Release():
   virtual ~CompositorBridgeChild();
 
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -27,16 +27,17 @@
 #include "mozilla/DebugOnly.h"          // for DebugOnly
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/gfx/2D.h"          // for DrawTarget
 #include "mozilla/gfx/Point.h"          // for IntSize
 #include "mozilla/gfx/Rect.h"          // for IntSize
 #include "VRManager.h"                  // for VRManager
 #include "mozilla/ipc/Transport.h"      // for Transport
 #include "mozilla/layers/APZCTreeManager.h"  // for APZCTreeManager
+#include "mozilla/layers/APZCTreeManagerParent.h"  // for APZCTreeManagerParent
 #include "mozilla/layers/APZThreadUtils.h"  // for APZCTreeManager
 #include "mozilla/layers/AsyncCompositionManager.h"
 #include "mozilla/layers/BasicCompositor.h"  // for BasicCompositor
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/FrameUniformityData.h"
@@ -1324,16 +1325,43 @@ CompositorBridgeParent::ForceComposeToTa
   PROFILER_LABEL("CompositorBridgeParent", "ForceComposeToTarget",
     js::ProfileEntry::Category::GRAPHICS);
 
   AutoRestore<bool> override(mOverrideComposeReadiness);
   mOverrideComposeReadiness = true;
   mCompositorScheduler->ForceComposeToTarget(aTarget, aRect);
 }
 
+PAPZCTreeManagerParent*
+CompositorBridgeParent::AllocPAPZCTreeManagerParent(const uint64_t& aLayersId)
+{
+  MOZ_ASSERT(aLayersId == mRootLayerTreeID);
+  return new APZCTreeManagerParent(GetAPZCTreeManager());
+}
+
+bool
+CompositorBridgeParent::DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor)
+{
+  delete aActor;
+  return true;
+}
+
+bool
+CompositorBridgeParent::RecvAsyncPanZoomEnabled(const uint64_t& aLayersId, bool* aHasAPZ)
+{
+  *aHasAPZ = AsyncPanZoomEnabled();
+  return true;
+}
+
+RefPtr<APZCTreeManager>
+CompositorBridgeParent::GetAPZCTreeManager()
+{
+  return mApzcTreeManager;
+}
+
 bool
 CompositorBridgeParent::CanComposite()
 {
   return mLayerManager &&
          mLayerManager->GetRoot() &&
          !mPaused;
 }
 
@@ -2123,16 +2151,21 @@ public:
     // Not allowed.
     return nullptr;
   }
   bool DeallocPCompositorWidgetParent(PCompositorWidgetParent* aActor) override {
     // Not allowed.
     return false;
   }
 
+  virtual bool RecvAsyncPanZoomEnabled(const uint64_t& aLayersId, bool* aHasAPZ) override;
+
+  virtual PAPZCTreeManagerParent* AllocPAPZCTreeManagerParent(const uint64_t& aLayersId) override;
+  virtual bool DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor) override;
+
   virtual CompositorBridgeParentIPCAllocator* AsCompositorBridgeParentIPCAllocator() override { return this; }
 
 protected:
   void OnChannelConnected(int32_t pid) override {
     mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
   }
 private:
   // Private destructor, to discourage deletion outside of Release():
@@ -2439,16 +2472,42 @@ CrossProcessCompositorBridgeParent::Deal
 {
   LayerTransactionParent* slp = static_cast<LayerTransactionParent*>(aLayers);
   EraseLayerState(slp->GetId());
   static_cast<LayerTransactionParent*>(aLayers)->ReleaseIPDLReference();
   return true;
 }
 
 bool
+CrossProcessCompositorBridgeParent::RecvAsyncPanZoomEnabled(const uint64_t& aLayersId, bool* aHasAPZ)
+{
+  MonitorAutoLock lock(*sIndirectLayerTreesLock);
+  CompositorBridgeParent::LayerTreeState& state = sIndirectLayerTrees[aLayersId];
+
+  *aHasAPZ = state.mParent ? state.mParent->AsyncPanZoomEnabled() : false;
+  return true;
+}
+
+PAPZCTreeManagerParent*
+CrossProcessCompositorBridgeParent::AllocPAPZCTreeManagerParent(const uint64_t& aLayersId)
+{
+  MonitorAutoLock lock(*sIndirectLayerTreesLock);
+  CompositorBridgeParent::LayerTreeState& state = sIndirectLayerTrees[aLayersId];
+
+  MOZ_ASSERT(state.mParent);
+  return new APZCTreeManagerParent(state.mParent->GetAPZCTreeManager());
+}
+bool
+CrossProcessCompositorBridgeParent::DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor)
+{
+  delete aActor;
+  return true;
+}
+
+bool
 CrossProcessCompositorBridgeParent::RecvNotifyChildCreated(const uint64_t& child)
 {
   MonitorAutoLock lock(*sIndirectLayerTreesLock);
   for (LayerTreeMap::iterator it = sIndirectLayerTrees.begin();
        it != sIndirectLayerTrees.end(); it++) {
     CompositorBridgeParent::LayerTreeState* lts = &it->second;
     if (lts->mParent && lts->mCrossProcessParent == this) {
       lts->mParent->NotifyChildCreated(child);
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -51,16 +51,17 @@ class GPUProcessManager;
 } // namespace gfx
 
 namespace ipc {
 class Shmem;
 } // namespace ipc
 
 namespace layers {
 
+class IAPZCTreeManager;
 class APZCTreeManager;
 class AsyncCompositionManager;
 class Compositor;
 class CompositorBridgeParent;
 class LayerManagerComposite;
 class LayerTransactionParent;
 class PAPZParent;
 class CrossProcessCompositorBridgeParent;
@@ -479,16 +480,23 @@ public:
    * Used by the profiler to denote when a vsync occured
    */
   static void PostInsertVsyncProfilerMarker(mozilla::TimeStamp aVsyncTimestamp);
 
   widget::CompositorWidget* GetWidget() { return mWidget; }
 
   void ForceComposeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect = nullptr);
 
+  PAPZCTreeManagerParent* AllocPAPZCTreeManagerParent(const uint64_t& aLayersId) override;
+  bool DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor) override;
+
+  bool RecvAsyncPanZoomEnabled(const uint64_t& aLayersId, bool* aHasAPZ) override;
+
+  RefPtr<APZCTreeManager> GetAPZCTreeManager();
+
   bool AsyncPanZoomEnabled() const {
     return !!mApzcTreeManager;
   }
 
 private:
 
   void Initialize();
 
--- a/gfx/layers/ipc/PAPZ.ipdl
+++ b/gfx/layers/ipc/PAPZ.ipdl
@@ -37,72 +37,32 @@ namespace layers {
  *
  * Opened through PContent and runs on the main thread in both parent and child.
  */
 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 NotifyAPZStateChange(ScrollableLayerGuid aGuid, APZStateChange aChange, int aArg);
+
   async NotifyFlushComplete();
 
   async Destroy();
 };
 
 } // layers
 } // mozilla
--- a/gfx/layers/ipc/PAPZCTreeManager.ipdl
+++ b/gfx/layers/ipc/PAPZCTreeManager.ipdl
@@ -1,16 +1,18 @@
 /* -*- 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";
 
+include protocol PCompositorBridge;
+
 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";
 
@@ -29,18 +31,48 @@ using class mozilla::PinchGestureInput f
 using class mozilla::TapGestureInput from "InputData.h";
 using class mozilla::ScrollWheelInput from "InputData.h";
 
 namespace mozilla {
 namespace layers {
 
 sync protocol PAPZCTreeManager
 {
+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,
              ScrollableLayerGuid aOutTargetGuid,
              uint64_t            aOutInputBlockId);
 
   sync ReceiveMouseInputEvent(MouseInput aEvent)
     returns (nsEventStatus       aOutStatus,
@@ -67,38 +99,16 @@ parent:
              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__();
 };
--- a/gfx/layers/ipc/PCompositorBridge.ipdl
+++ b/gfx/layers/ipc/PCompositorBridge.ipdl
@@ -3,16 +3,17 @@
  */
 /* 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 LayersSurfaces;
 include LayersMessages;
 include PlatformWidgetTypes;
+include protocol PAPZCTreeManager;
 include protocol PBrowser;
 include protocol PCompositable;
 include protocol PCompositorWidget;
 include protocol PImageContainer;
 include protocol PLayer;
 include protocol PLayerTransaction;
 include protocol PTexture;
 include "mozilla/GfxMessageUtils.h";
@@ -41,16 +42,17 @@ namespace layers {
 
 /**
  * The PCompositorBridge protocol is used to manage communication between
  * the main thread and the compositor thread context. It's primary
  * purpose is to manage the PLayerTransaction sub protocol.
  */
 sync protocol PCompositorBridge
 {
+  manages PAPZCTreeManager;
   // A Compositor manages a single Layer Manager (PLayerTransaction)
   manages PLayerTransaction;
   manages PTexture;
   manages PCompositorWidget;
 
 child:
   // The child should invalidate retained layers. This is used for local
   // compositor device resets, such as in CompositorD3D9, and ensures that
@@ -114,16 +116,22 @@ child:
 
 parent:
   // Must be called before Initialize().
   async PCompositorWidget(CompositorWidgetInitData aInitData);
 
   // When out-of-process, this must be called to finish initialization.
   sync Initialize(uint64_t rootLayerTreeId);
 
+  // Returns whether this Compositor has APZ enabled or not.
+  sync AsyncPanZoomEnabled(uint64_t layersId) returns (bool aHasAPZ);
+
+  // Must be called after Initialize(), and only succeeds if AsyncPanZoomEnabled() is true.
+  async PAPZCTreeManager(uint64_t layersId);
+
   /**
    * Confirmation callback for UpdatePluginConfigurations and HideAllPlugins.
    */
   async RemotePluginsReady();
 
   // Confirmation that the child has invalidated all its layers, and will not
   // request layers against an old compositor.
   async AcknowledgeCompositorUpdate(uint64_t id);
--- a/gfx/layers/ipc/RemoteContentController.cpp
+++ b/gfx/layers/ipc/RemoteContentController.cpp
@@ -7,17 +7,16 @@
 
 #include "mozilla/layers/RemoteContentController.h"
 
 #include "base/message_loop.h"
 #include "base/task.h"
 #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"
 #include "mozilla/unused.h"
 #include "Units.h"
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidBridge.h"
 #endif
@@ -43,17 +42,17 @@ RemoteContentController::~RemoteContentC
 {
 }
 
 void
 RemoteContentController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (CanSend()) {
-    Unused << SendUpdateFrame(aFrameMetrics);
+    Unused << SendRequestContentRepaint(aFrameMetrics);
   }
 }
 
 void
 RemoteContentController::HandleTap(TapType aTapType,
                                    const LayoutDevicePoint& aPoint,
                                    Modifiers aModifiers,
                                    const ScrollableLayerGuid& aGuid,
@@ -119,17 +118,17 @@ RemoteContentController::NotifyAPZStateC
     mUILoop->PostTask(NewRunnableMethod<ScrollableLayerGuid,
                                         APZStateChange,
                                         int>(this,
                                              &RemoteContentController::NotifyAPZStateChange,
                                              aGuid, aChange, aArg));
     return;
   }
   if (CanSend()) {
-    Unused << SendNotifyAPZStateChange(aGuid.mScrollId, aChange, aArg);
+    Unused << SendNotifyAPZStateChange(aGuid, aChange, aArg);
   }
 }
 
 void
 RemoteContentController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId,
                                                    const nsString& aEvent)
 {
   if (MessageLoop::current() != mUILoop) {
@@ -157,123 +156,19 @@ RemoteContentController::NotifyFlushComp
 bool
 RemoteContentController::RecvUpdateHitRegion(const nsRegion& aRegion)
 {
   MutexAutoLock lock(mMutex);
   mTouchSensitiveRegion = aRegion;
   return true;
 }
 
-bool
-RemoteContentController::RecvZoomToRect(const uint32_t& aPresShellId,
-                                        const ViewID& aViewId,
-                                        const CSSRect& aRect,
-                                        const uint32_t& aFlags)
-{
-  if (RefPtr<IAPZCTreeManager> 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<IAPZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
-    APZThreadUtils::RunOnControllerThread(NewRunnableMethod<uint64_t,
-                                                            bool>(apzcTreeManager,
-                                                                  &IAPZCTreeManager::ContentReceivedInputBlock,
-                                                                  aInputBlockId, aPreventDefault));
-
-  }
-  return true;
-}
-
-bool
-RemoteContentController::RecvStartScrollbarDrag(const AsyncDragMetrics& aDragMetrics)
-{
-  if (RefPtr<IAPZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
-    ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId,
-                             aDragMetrics.mViewId);
-
-    APZThreadUtils::RunOnControllerThread(NewRunnableMethod
-                                          <ScrollableLayerGuid,
-                                           AsyncDragMetrics>(apzcTreeManager,
-                                                             &IAPZCTreeManager::StartScrollbarDrag,
-                                                             guid, aDragMetrics));
-  }
-  return true;
-}
-
-bool
-RemoteContentController::RecvSetTargetAPZC(const uint64_t& aInputBlockId,
-                                           nsTArray<ScrollableLayerGuid>&& 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<IAPZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
-    // need a local var to disambiguate between the SetTargetAPZC overloads.
-    void (IAPZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&)
-        = &IAPZCTreeManager::SetTargetAPZC;
-    APZThreadUtils::RunOnControllerThread(NewRunnableMethod
-                                          <uint64_t,
-                                           StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>>
-                                          (apzcTreeManager, setTargetApzcFunc, aInputBlockId, aTargets));
-
-  }
-  return true;
-}
-
-bool
-RemoteContentController::RecvSetAllowedTouchBehavior(const uint64_t& aInputBlockId,
-                                                     nsTArray<TouchBehaviorFlags>&& aFlags)
-{
-  if (RefPtr<IAPZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
-    APZThreadUtils::RunOnControllerThread(NewRunnableMethod
-                                          <uint64_t,
-                                           StoreCopyPassByRRef<nsTArray<TouchBehaviorFlags>>>
-                                          (apzcTreeManager,
-                                           &IAPZCTreeManager::SetAllowedTouchBehavior,
-                                           aInputBlockId, Move(aFlags)));
-  }
-  return true;
-}
-
-bool
-RemoteContentController::RecvUpdateZoomConstraints(const uint32_t& aPresShellId,
-                                                   const ViewID& aViewId,
-                                                   const MaybeZoomConstraints& aConstraints)
-{
-  if (RefPtr<IAPZCTreeManager> 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;
   NS_DispatchToMainThread(NS_NewRunnableFunction([key]() {
     // sDestroyedControllers may or may not contain the key, depending on
     // whether or not SendDestroy() was successfully sent out or not.
     sDestroyedControllers.erase(key);
   }));
@@ -293,33 +188,10 @@ RemoteContentController::Destroy()
       uint64_t key = controller->mLayersId;
       MOZ_ASSERT(sDestroyedControllers.find(key) == sDestroyedControllers.end());
       sDestroyedControllers[key] = controller;
       Unused << controller->SendDestroy();
     }
   }));
 }
 
-void
-RemoteContentController::ChildAdopted()
-{
-  // Clear the cached APZCTreeManager.
-  MutexAutoLock lock(mMutex);
-  mApzcTreeManager = nullptr;
-}
-
-already_AddRefed<IAPZCTreeManager>
-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<IAPZCTreeManager> apzcTreeManager(mApzcTreeManager);
-  return apzcTreeManager.forget();
-}
-
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/ipc/RemoteContentController.h
+++ b/gfx/layers/ipc/RemoteContentController.h
@@ -14,18 +14,16 @@
 namespace mozilla {
 
 namespace dom {
 class TabParent;
 }
 
 namespace layers {
 
-class IAPZCTreeManager;
-
 /**
  * RemoteContentController uses the PAPZ protocol to implement a
  * GeckoContentController for a browser living in a remote process.
  * Most of the member functions can be called on any thread, exceptions are
  * annotated in comments. The PAPZ protocol runs on the main thread (so all the
  * Recv* member functions do too).
  */
 class RemoteContentController : public GeckoContentController
@@ -60,59 +58,33 @@ public:
   virtual void NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId,
                                          const nsString& aEvent) override;
 
   // Needs to be called on the main thread.
   virtual void NotifyFlushComplete() override;
 
   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<ScrollableLayerGuid>&& aTargets) override;
-
-  virtual bool RecvSetAllowedTouchBehavior(const uint64_t& aInputBlockId,
-                                           nsTArray<TouchBehaviorFlags>&& 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<IAPZCTreeManager> GetApzcTreeManager();
 
   MessageLoop* mUILoop;
   uint64_t mLayersId;
   RefPtr<dom::TabParent> mBrowserParent;
 
   // Mutex protecting members below accessed from multiple threads.
   mozilla::Mutex mMutex;
-
-  RefPtr<IAPZCTreeManager> mApzcTreeManager;
   nsRegion mTouchSensitiveRegion;
 };
 
 } // namespace layers
 
 } // namespace mozilla
 
 #endif // mozilla_layers_RemoteContentController_h
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -9286,17 +9286,17 @@ static void UpdateDisplayPortMarginsForP
 }
 
 /* static */ void
 nsLayoutUtils::UpdateDisplayPortMarginsFromPendingMessages() {
   if (mozilla::dom::ContentChild::GetSingleton() &&
       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)) {
             MOZ_ASSERT(false);
             return true;
           }
 
           UpdateDisplayPortMarginsForPendingMetrics(frame);
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.h
@@ -19,17 +19,16 @@
 class nsFrameLoader;
 class nsSubDocumentFrame;
 
 namespace mozilla {
 
 class InputEvent;
 
 namespace layers {
-class APZCTreeManager;
 class AsyncDragMetrics;
 class TargetConfig;
 struct TextureFactoryIdentifier;
 struct ScrollableLayerGuid;
 } // namespace layers
 
 namespace layout {