Bug 997287 - Access AsyncPanZoomController::mGeckoContentController safely. r=kats

--HG--
extra : source : cf71c9301548157b0b92f1443290273ac8a45f28
This commit is contained in:
Botond Ballo 2014-04-16 17:02:22 -04:00
parent 02e6c083d6
commit 2ca4dde4fe

View File

@ -618,9 +618,10 @@ nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent
mX.StartTouch(point.x);
mY.StartTouch(point.y);
APZCTreeManager* treeManagerLocal = mTreeManager;
if (treeManagerLocal) {
nsRefPtr<GeckoContentController> controller = GetGeckoContentController();
if (treeManagerLocal && controller) {
bool touchCanBePan = treeManagerLocal->CanBePanned(this);
mGeckoContentController->NotifyAPZStateChange(
controller->NotifyAPZStateChange(
GetGuid(), APZStateChange::StartTouch, touchCanBePan);
}
SetState(TOUCHING);
@ -961,8 +962,10 @@ nsEventStatus AsyncPanZoomController::GenerateSingleTap(const ScreenIntPoint& aP
}
void AsyncPanZoomController::OnTouchEndOrCancel() {
mGeckoContentController->NotifyAPZStateChange(
GetGuid(), APZStateChange::EndTouch, mTouchBlockState.mSingleTapOccurred);
if (nsRefPtr<GeckoContentController> controller = GetGeckoContentController()) {
controller->NotifyAPZStateChange(
GetGuid(), APZStateChange::EndTouch, mTouchBlockState.mSingleTapOccurred);
}
}
nsEventStatus AsyncPanZoomController::OnSingleTapUp(const TapGestureInput& aEvent) {
@ -1107,7 +1110,9 @@ nsEventStatus AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent
}
if (IsPanningState(mState)) {
mGeckoContentController->NotifyAPZStateChange(GetGuid(), APZStateChange::StartPanning);
if (nsRefPtr<GeckoContentController> controller = GetGeckoContentController()) {
controller->NotifyAPZStateChange(GetGuid(), APZStateChange::StartPanning);
}
return nsEventStatus_eConsumeNoDefault;
}
// Don't consume an event that didn't trigger a panning.
@ -2006,12 +2011,12 @@ void AsyncPanZoomController::SetState(PanZoomState aNewState) {
mState = aNewState;
}
if (mGeckoContentController) {
if (nsRefPtr<GeckoContentController> controller = GetGeckoContentController()) {
if (!IsTransformingState(oldState) && IsTransformingState(aNewState)) {
mGeckoContentController->NotifyAPZStateChange(
controller->NotifyAPZStateChange(
GetGuid(), APZStateChange::TransformBegin);
} else if (IsTransformingState(oldState) && !IsTransformingState(aNewState)) {
mGeckoContentController->NotifyAPZStateChange(
controller->NotifyAPZStateChange(
GetGuid(), APZStateChange::TransformEnd);
}
}