Bug 1445662 - Ensure ZoomToRect runs on the controller thread. r=rhunt

Currently the ZoomToRect function is only ever called on Android, on the
UI process main thread, which is neither the controller nor the sampler
thread. Instead of allowing "random" threads to run inside APZ, we
ensure that callers run it on the controller thread.

MozReview-Commit-ID: 64LkHaFLIOl

--HG--
extra : rebase_source : 61f397c0e18f83c68c228879692c9d4767b25675
This commit is contained in:
Kartikaya Gupta 2018-03-14 16:57:52 -04:00
Родитель 139ae9307f
Коммит 186ffd08c7
4 изменённых файлов: 27 добавлений и 4 удалений

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

@ -1891,6 +1891,11 @@ APZCTreeManager::ZoomToRect(const ScrollableLayerGuid& aGuid,
const CSSRect& aRect,
const uint32_t aFlags)
{
// We could probably move this to run on the sampler thread if needed, but
// either way we should restrict it to a single thread. For now let's use the
// controller thread.
APZThreadUtils::AssertOnControllerThread();
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
if (apzc) {
apzc->ZoomToRect(aRect, aFlags);

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

@ -158,8 +158,14 @@ ChromeProcessController::HandleDoubleTap(const mozilla::CSSPoint& aPoint,
FrameMetrics::ViewID viewId;
if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(
document->GetDocumentElement(), &presShellId, &viewId)) {
mAPZCTreeManager->ZoomToRect(
ScrollableLayerGuid(aGuid.mLayersId, presShellId, viewId), zoomToRect);
APZThreadUtils::RunOnControllerThread(
NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>(
"IAPZCTreeManager::ZoomToRect",
mAPZCTreeManager,
&IAPZCTreeManager::ZoomToRect,
ScrollableLayerGuid(aGuid.mLayersId, presShellId, viewId),
zoomToRect,
ZoomToRectBehavior::DEFAULT_BEHAVIOR));
}
}

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

@ -187,7 +187,12 @@ APZCTreeManagerParent::RecvZoomToRect(
return IPC_FAIL_NO_REASON(this);
}
mTreeManager->ZoomToRect(aGuid, aRect, aFlags);
APZThreadUtils::RunOnControllerThread(
NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>(
"layers::IAPZCTreeManager::ZoomToRect",
mTreeManager,
&IAPZCTreeManager::ZoomToRect,
aGuid, aRect, aFlags));
return IPC_OK();
}

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

@ -1933,7 +1933,14 @@ nsBaseWidget::ZoomToRect(const uint32_t& aPresShellId,
return;
}
uint64_t layerId = mCompositorSession->RootLayerTreeId();
mAPZC->ZoomToRect(ScrollableLayerGuid(layerId, aPresShellId, aViewId), aRect, aFlags);
APZThreadUtils::RunOnControllerThread(
NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>(
"layers::IAPZCTreeManager::ZoomToRect",
mAPZC,
&IAPZCTreeManager::ZoomToRect,
ScrollableLayerGuid(layerId, aPresShellId, aViewId),
aRect,
aFlags));
}
#ifdef ACCESSIBILITY