Bug 1857288 - Make ownership transfer after creation of AsyncPanZoomController more explicit. r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D190378
This commit is contained in:
Botond Ballo 2023-10-12 07:43:27 +00:00
parent 92e47e34fd
commit 67daab693b
4 changed files with 19 additions and 16 deletions

View File

@ -356,11 +356,12 @@ void APZCTreeManager::NotifyLayerTreeRemoved(LayersId aLayersId) {
}
}
AsyncPanZoomController* APZCTreeManager::NewAPZCInstance(
already_AddRefed<AsyncPanZoomController> APZCTreeManager::NewAPZCInstance(
LayersId aLayersId, GeckoContentController* aController) {
return new AsyncPanZoomController(
aLayersId, this, mInputQueue, aController,
AsyncPanZoomController::USE_GESTURE_DETECTOR);
return MakeRefPtr<AsyncPanZoomController>(
aLayersId, this, mInputQueue, aController,
AsyncPanZoomController::USE_GESTURE_DETECTOR)
.forget();
}
void APZCTreeManager::SetTestSampleTime(const Maybe<TimeStamp>& aTime) {
@ -1155,7 +1156,7 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer(
return node;
}
AsyncPanZoomController* apzc = nullptr;
RefPtr<AsyncPanZoomController> apzc;
// If we get here, aLayer is a scrollable layer and somebody
// has registered a GeckoContentController for it, so we need to ensure
// it has an APZC instance to manage its scrolling.
@ -1173,9 +1174,9 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer(
apzc = insertResult.first->second.apzc;
PrintLayerInfo(aLayer);
}
APZCTM_LOG("Found APZC %p for layer %p with identifiers %" PRIx64 " %" PRId64
"\n",
apzc, aLayer.GetLayer(), uint64_t(guid.mLayersId), guid.mScrollId);
APZCTM_LOG(
"Found APZC %p for layer %p with identifiers %" PRIx64 " %" PRId64 "\n",
apzc.get(), aLayer.GetLayer(), uint64_t(guid.mLayersId), guid.mScrollId);
// If we haven't encountered a layer already with the same metrics, then we
// need to do the full reuse-or-make-an-APZC algorithm, which is contained
@ -1246,9 +1247,10 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer(
aState.mZoomAnimationId = Nothing();
}
APZCTM_LOG(
"Using APZC %p for layer %p with identifiers %" PRIx64 " %" PRId64 "\n",
apzc, aLayer.GetLayer(), uint64_t(aLayersId), aMetrics.GetScrollId());
APZCTM_LOG("Using APZC %p for layer %p with identifiers %" PRIx64
" %" PRId64 "\n",
apzc.get(), aLayer.GetLayer(), uint64_t(aLayersId),
aMetrics.GetScrollId());
apzc->NotifyLayersUpdated(aLayer.Metadata(), aState.mIsFirstPaint,
aLayersId == aState.mOriginatingLayersId);

View File

@ -529,7 +529,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
void UnlockTree() MOZ_CAPABILITY_RELEASE(mTreeLock);
// Protected hooks for gtests subclass
virtual AsyncPanZoomController* NewAPZCInstance(
virtual already_AddRefed<AsyncPanZoomController> NewAPZCInstance(
LayersId aLayersId, GeckoContentController* aController);
public:

View File

@ -6,10 +6,11 @@
#include "APZTestCommon.h"
AsyncPanZoomController* TestAPZCTreeManager::NewAPZCInstance(
already_AddRefed<AsyncPanZoomController> TestAPZCTreeManager::NewAPZCInstance(
LayersId aLayersId, GeckoContentController* aController) {
MockContentControllerDelayed* mcc =
static_cast<MockContentControllerDelayed*>(aController);
return new TestAsyncPanZoomController(
aLayersId, mcc, this, AsyncPanZoomController::USE_GESTURE_DETECTOR);
return MakeRefPtr<TestAsyncPanZoomController>(
aLayersId, mcc, this, AsyncPanZoomController::USE_GESTURE_DETECTOR)
.forget();
}

View File

@ -268,7 +268,7 @@ class TestAPZCTreeManager : public APZCTreeManager {
}
protected:
AsyncPanZoomController* NewAPZCInstance(
already_AddRefed<AsyncPanZoomController> NewAPZCInstance(
LayersId aLayersId, GeckoContentController* aController) override;
SampleTime GetFrameTime() override { return mcc->GetSampleTime(); }