Bug 898478 - Have AsyncPanZoomController keep a pointer to the APZCTreeManager. r=kats

This commit is contained in:
Botond Ballo 2013-08-20 18:10:47 -04:00
Родитель 7e518b8b1e
Коммит 0d500136ea
4 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -118,7 +118,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
bool newApzc = (apzc == nullptr);
if (newApzc) {
apzc = new AsyncPanZoomController(aLayersId, state->mController,
apzc = new AsyncPanZoomController(aLayersId, this, state->mController,
AsyncPanZoomController::USE_GESTURE_DETECTOR);
apzc->SetCompositorParent(aCompositor);
} else {

Просмотреть файл

@ -200,6 +200,7 @@ AsyncPanZoomController::InitializeGlobalState()
}
AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId,
APZCTreeManager* aTreeManager,
GeckoContentController* aGeckoContentController,
GestureBehavior aGestures)
: mLayersId(aLayersId),
@ -221,7 +222,8 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId,
mAsyncScrollTimeoutTask(nullptr),
mDisableNextTouchBatch(false),
mHandlingTouchQueue(false),
mDelayPanning(false)
mDelayPanning(false),
mTreeManager(aTreeManager)
{
MOZ_COUNT_CTOR(AsyncPanZoomController);
@ -262,6 +264,7 @@ AsyncPanZoomController::Destroy()
mPrevSibling = nullptr;
mLastChild = nullptr;
mParent = nullptr;
mTreeManager = nullptr;
}
/* static */float

Просмотреть файл

@ -15,7 +15,6 @@
#include "InputData.h"
#include "Axis.h"
#include "TaskThrottler.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "gfx3DMatrix.h"
#include "base/message_loop.h"
@ -28,6 +27,7 @@ class CompositorParent;
class GestureEventListener;
class ContainerLayer;
class ViewTransform;
class APZCTreeManager;
/**
* Controller for all panning and zooming logic. Any time a user input is
@ -73,6 +73,7 @@ public:
static float GetTouchStartTolerance();
AsyncPanZoomController(uint64_t aLayersId,
APZCTreeManager* aTreeManager,
GeckoContentController* aController,
GestureBehavior aGestures = DEFAULT_GESTURES);
~AsyncPanZoomController();
@ -630,6 +631,13 @@ public:
}
private:
// This is a raw pointer to avoid introducing a reference cycle between
// AsyncPanZoomController and APZCTreeManager. Since these objects don't
// live on the main thread, we can't use the cycle collector with them.
// The APZCTreeManager owns the lifetime of the APZCs, so nulling this
// pointer out in Destroy() will prevent accessing deleted memory.
APZCTreeManager* mTreeManager;
nsRefPtr<AsyncPanZoomController> mLastChild;
nsRefPtr<AsyncPanZoomController> mPrevSibling;
nsRefPtr<AsyncPanZoomController> mParent;

Просмотреть файл

@ -45,8 +45,8 @@ class TestAPZCContainerLayer : public ContainerLayer {
class TestAsyncPanZoomController : public AsyncPanZoomController {
public:
TestAsyncPanZoomController(uint64_t aLayersId, MockContentController* mcc)
: AsyncPanZoomController(aLayersId, mcc)
TestAsyncPanZoomController(uint64_t aLayersId, MockContentController* aMcc)
: AsyncPanZoomController(aLayersId, nullptr, aMcc)
{}
void SetFrameMetrics(const FrameMetrics& metrics) {