Bug 1289432 - Use RefPtr instead of UniquePtr to hold the block state objects, since there will be multiple references to them soon. r?botond
MozReview-Commit-ID: 616dRaTxEwD
--- a/gfx/layers/apz/src/InputBlockState.h
+++ b/gfx/layers/apz/src/InputBlockState.h
@@ -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/. */
#ifndef mozilla_layers_InputBlockState_h
#define mozilla_layers_InputBlockState_h
#include "InputData.h" // for MultiTouchInput
+#include "mozilla/RefCounted.h" // for RefCounted
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/layers/APZUtils.h" // for TouchBehaviorFlags
#include "mozilla/layers/AsyncDragMetrics.h"
#include "mozilla/TimeStamp.h" // for TimeStamp
#include "nsTArray.h" // for nsTArray
#include "TouchCounter.h"
@@ -29,19 +30,21 @@ class PanGestureBlockState;
/**
* A base class that stores state common to various input blocks.
* Currently, it just stores the overscroll handoff chain.
* Note that the InputBlockState constructor acquires the tree lock, so callers
* from inside AsyncPanZoomController should ensure that the APZC lock is not
* held.
*/
-class InputBlockState
+class InputBlockState : public RefCounted<InputBlockState>
{
public:
+ MOZ_DECLARE_REFCOUNTED_TYPENAME(InputBlockState)
+
static const uint64_t NO_BLOCK_ID = 0;
enum class TargetConfirmationState {
eUnconfirmed,
eTimedOut,
eTimedOutAndMainThreadResponded,
eConfirmed
};
--- a/gfx/layers/apz/src/InputQueue.h
+++ b/gfx/layers/apz/src/InputQueue.h
@@ -6,17 +6,16 @@
#ifndef mozilla_layers_InputQueue_h
#define mozilla_layers_InputQueue_h
#include "APZUtils.h"
#include "DragTracker.h"
#include "InputData.h"
#include "mozilla/EventForwards.h"
#include "mozilla/RefPtr.h"
-#include "mozilla/UniquePtr.h"
#include "nsTArray.h"
#include "TouchCounter.h"
namespace mozilla {
class InputData;
class MultiTouchInput;
class ScrollWheelInput;
@@ -179,17 +178,17 @@ private:
CancelableBlockState* aBlock);
void MainThreadTimeout(const uint64_t& aInputBlockId);
void ProcessInputBlocks();
void UpdateActiveApzc(const RefPtr<AsyncPanZoomController>& aNewActive);
private:
// The queue of input blocks that have not yet been fully processed.
// This member must only be accessed on the controller/UI thread.
- nsTArray<UniquePtr<CancelableBlockState>> mInputBlockQueue;
+ nsTArray<RefPtr<CancelableBlockState>> mInputBlockQueue;
// The APZC to which the last event was delivered
RefPtr<AsyncPanZoomController> mLastActiveApzc;
// Track touches so we know when to clear mLastActiveApzc
TouchCounter mTouchCounter;
// Track mouse inputs so we know if we're in a drag or not