APZChild.cpp (3919B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "mozilla/layers/APZChild.h" 8 #include "mozilla/ipc/ProtocolUtils.h" 9 #include "mozilla/layers/GeckoContentController.h" 10 11 #include "mozilla/dom/BrowserChild.h" 12 #include "mozilla/layers/APZCCallbackHelper.h" 13 14 #include "InputData.h" // for InputData 15 16 namespace mozilla { 17 namespace layers { 18 19 APZChild::APZChild(RefPtr<GeckoContentController> aController) 20 : mController(aController) { 21 MOZ_ASSERT(mController); 22 } 23 24 APZChild::~APZChild() { 25 if (mAPZTaskRunnable) { 26 mAPZTaskRunnable->Revoke(); 27 mAPZTaskRunnable = nullptr; 28 } 29 if (mController) { 30 mController->Destroy(); 31 mController = nullptr; 32 } 33 } 34 35 mozilla::ipc::IPCResult APZChild::RecvLayerTransforms( 36 nsTArray<MatrixMessage>&& aTransforms) { 37 mController->NotifyLayerTransforms(std::move(aTransforms)); 38 return IPC_OK(); 39 } 40 41 mozilla::ipc::IPCResult APZChild::RecvRequestContentRepaint( 42 const RepaintRequest& aRequest) { 43 MOZ_ASSERT(mController->IsRepaintThread()); 44 45 EnsureAPZTaskRunnable(); 46 47 mAPZTaskRunnable->QueueRequest(aRequest); 48 return IPC_OK(); 49 } 50 51 mozilla::ipc::IPCResult APZChild::RecvUpdateOverscrollVelocity( 52 const ScrollableLayerGuid& aGuid, const float& aX, const float& aY, 53 const bool& aIsRootContent) { 54 mController->UpdateOverscrollVelocity(aGuid, aX, aY, aIsRootContent); 55 return IPC_OK(); 56 } 57 58 mozilla::ipc::IPCResult APZChild::RecvUpdateOverscrollOffset( 59 const ScrollableLayerGuid& aGuid, const float& aX, const float& aY, 60 const bool& aIsRootContent) { 61 mController->UpdateOverscrollOffset(aGuid, aX, aY, aIsRootContent); 62 return IPC_OK(); 63 } 64 65 mozilla::ipc::IPCResult APZChild::RecvHideDynamicToolbar() { 66 // Only the RemoteContentController implementation uses the 67 // ScrollableLayerGuid parameter. APZChild::mController is never a 68 // RemoteContentController, so it's fine to invent a value here. 69 mController->HideDynamicToolbar(ScrollableLayerGuid{}); 70 return IPC_OK(); 71 } 72 73 mozilla::ipc::IPCResult APZChild::RecvNotifyMozMouseScrollEvent( 74 const ViewID& aScrollId, const nsString& aEvent) { 75 mController->NotifyMozMouseScrollEvent(aScrollId, aEvent); 76 return IPC_OK(); 77 } 78 79 mozilla::ipc::IPCResult APZChild::RecvNotifyAPZStateChange( 80 const ScrollableLayerGuid& aGuid, const APZStateChange& aChange, 81 const int& aArg, Maybe<uint64_t> aInputBlockId) { 82 MOZ_ASSERT(mController->IsRepaintThread()); 83 EnsureAPZTaskRunnable(); 84 85 mAPZTaskRunnable->QueueAPZStateChange(aGuid, aChange, aArg, aInputBlockId); 86 87 return IPC_OK(); 88 } 89 90 mozilla::ipc::IPCResult APZChild::RecvNotifyFlushComplete() { 91 MOZ_ASSERT(mController->IsRepaintThread()); 92 EnsureAPZTaskRunnable(); 93 94 mAPZTaskRunnable->QueueFlushCompleteNotification(); 95 96 return IPC_OK(); 97 } 98 99 mozilla::ipc::IPCResult APZChild::RecvNotifyAsyncScrollbarDragInitiated( 100 const uint64_t& aDragBlockId, const ViewID& aScrollId, 101 const ScrollDirection& aDirection) { 102 mController->NotifyAsyncScrollbarDragInitiated(aDragBlockId, aScrollId, 103 aDirection); 104 return IPC_OK(); 105 } 106 107 mozilla::ipc::IPCResult APZChild::RecvNotifyAsyncScrollbarDragRejected( 108 const ViewID& aScrollId) { 109 mController->NotifyAsyncScrollbarDragRejected(aScrollId); 110 return IPC_OK(); 111 } 112 113 mozilla::ipc::IPCResult APZChild::RecvNotifyAsyncAutoscrollRejected( 114 const ViewID& aScrollId) { 115 mController->NotifyAsyncAutoscrollRejected(aScrollId); 116 return IPC_OK(); 117 } 118 119 mozilla::ipc::IPCResult APZChild::RecvDestroy() { 120 // mController->Destroy will be called in the destructor 121 PAPZChild::Send__delete__(this); 122 return IPC_OK(); 123 } 124 125 } // namespace layers 126 } // namespace mozilla