Bug 1283556 - Convert APZStateChange to an enum class and make the formatting more consistent with the style guide. r?botond
MozReview-Commit-ID: v4xEaL9meF
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1809,17 +1809,17 @@ TabChild::HandleLongTap(const CSSPoint&
}
bool
TabChild::NotifyAPZStateChange(const ViewID& aViewId,
const layers::GeckoContentController::APZStateChange& aChange,
const int& aArg)
{
mAPZEventState->ProcessAPZStateChange(GetDocument(), aViewId, aChange, aArg);
- if (aChange == layers::GeckoContentController::APZStateChange::TransformEnd) {
+ if (aChange == layers::GeckoContentController::APZStateChange::eTransformEnd) {
// This is used by tests to determine when the APZ is done doing whatever
// it's doing. XXX generify this as needed when writing additional tests.
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
}
return true;
}
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -1171,18 +1171,18 @@ struct ParamTraits<mozilla::gfx::FilterD
};
typedef mozilla::layers::GeckoContentController::APZStateChange APZStateChange;
template <>
struct ParamTraits<APZStateChange>
: public ContiguousEnumSerializer<
APZStateChange,
- APZStateChange::TransformBegin,
- APZStateChange::APZStateChangeSentinel>
+ APZStateChange::eTransformBegin,
+ APZStateChange::eSentinel>
{};
template<>
struct ParamTraits<mozilla::layers::EventRegionsOverride>
: public BitFlagsEnumSerializer<
mozilla::layers::EventRegionsOverride,
mozilla::layers::EventRegionsOverride::ALL_BITS>
{};
--- a/gfx/layers/apz/public/GeckoContentController.h
+++ b/gfx/layers/apz/public/GeckoContentController.h
@@ -84,40 +84,43 @@ public:
* APZ can then get the correct touch-sensitive region for each frame
* directly from the layer.
*/
virtual bool GetTouchSensitiveRegion(CSSRect* aOutRegion)
{
return false;
}
- enum APZStateChange {
+ enum class APZStateChange {
/**
* APZ started modifying the view (including panning, zooming, and fling).
*/
- TransformBegin,
+ eTransformBegin,
/**
* APZ finished modifying the view.
*/
- TransformEnd,
+ eTransformEnd,
/**
* APZ started a touch.
* |aArg| is 1 if touch can be a pan, 0 otherwise.
*/
- StartTouch,
+ eStartTouch,
/**
* APZ started a pan.
*/
- StartPanning,
+ eStartPanning,
/**
* APZ finished processing a touch.
* |aArg| is 1 if touch was a click, 0 otherwise.
*/
- EndTouch,
- APZStateChangeSentinel
+ eEndTouch,
+
+ // Sentinel value for IPC, this must be the last item in the enum and
+ // should not be used as an actual message value.
+ eSentinel
};
/**
* General notices of APZ state changes for consumers.
* |aGuid| identifies the APZC originating the state change.
* |aChange| identifies the type of state change
* |aArg| is used by some state changes to pass extra information (see
* the documentation for each state change above)
*/
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1088,17 +1088,17 @@ nsEventStatus AsyncPanZoomController::On
case PAN_MOMENTUM:
CurrentTouchBlock()->GetOverscrollHandoffChain()->CancelAnimations(ExcludeOverscroll);
MOZ_FALLTHROUGH;
case NOTHING: {
mX.StartTouch(point.x, aEvent.mTime);
mY.StartTouch(point.y, aEvent.mTime);
if (RefPtr<GeckoContentController> controller = GetGeckoContentController()) {
controller->NotifyAPZStateChange(
- GetGuid(), APZStateChange::StartTouch,
+ GetGuid(), APZStateChange::eStartTouch,
CurrentTouchBlock()->GetOverscrollHandoffChain()->CanBePanned(this));
}
SetState(TOUCHING);
break;
}
case TOUCHING:
case PANNING:
case PANNING_LOCKED_X:
@@ -2045,17 +2045,17 @@ nsEventStatus AsyncPanZoomController::Ge
}
}
return nsEventStatus_eIgnore;
}
void AsyncPanZoomController::OnTouchEndOrCancel() {
if (RefPtr<GeckoContentController> controller = GetGeckoContentController()) {
controller->NotifyAPZStateChange(
- GetGuid(), APZStateChange::EndTouch, CurrentTouchBlock()->SingleTapOccurred());
+ GetGuid(), APZStateChange::eEndTouch, CurrentTouchBlock()->SingleTapOccurred());
}
}
nsEventStatus AsyncPanZoomController::OnSingleTapUp(const TapGestureInput& aEvent) {
APZC_LOG("%p got a single-tap-up in state %d\n", this, mState);
// If mZoomConstraints.mAllowDoubleTapZoom is true we wait for a call to OnSingleTapConfirmed before
// sending event to content
if (!(mZoomConstraints.mAllowDoubleTapZoom && CurrentTouchBlock()->TouchActionAllowsDoubleTapZoom())) {
@@ -2268,17 +2268,17 @@ nsEventStatus AsyncPanZoomController::St
SetState(PANNING);
} else {
HandlePanning(angle);
}
}
if (IsInPanningState()) {
if (RefPtr<GeckoContentController> controller = GetGeckoContentController()) {
- controller->NotifyAPZStateChange(GetGuid(), APZStateChange::StartPanning);
+ controller->NotifyAPZStateChange(GetGuid(), APZStateChange::eStartPanning);
}
return nsEventStatus_eConsumeNoDefault;
}
// Don't consume an event that didn't trigger a panning.
return nsEventStatus_eIgnore;
}
void AsyncPanZoomController::UpdateWithTouchAtDevicePoint(const MultiTouchInput& aEvent) {
@@ -3644,27 +3644,27 @@ void AsyncPanZoomController::DispatchSta
if (mNotificationBlockers > 0) {
return;
}
}
if (RefPtr<GeckoContentController> controller = GetGeckoContentController()) {
if (!IsTransformingState(aOldState) && IsTransformingState(aNewState)) {
controller->NotifyAPZStateChange(
- GetGuid(), APZStateChange::TransformBegin);
+ GetGuid(), APZStateChange::eTransformBegin);
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
// Let the compositor know about scroll state changes so it can manage
// windowed plugins.
if (mCompositorBridgeParent) {
mCompositorBridgeParent->ScheduleHideAllPluginWindows();
}
#endif
} else if (IsTransformingState(aOldState) && !IsTransformingState(aNewState)) {
controller->NotifyAPZStateChange(
- GetGuid(), APZStateChange::TransformEnd);
+ GetGuid(), APZStateChange::eTransformEnd);
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
if (mCompositorBridgeParent) {
mCompositorBridgeParent->ScheduleShowAllPluginWindows();
}
#endif
}
}
}
--- a/gfx/layers/apz/test/gtest/TestBasic.cpp
+++ b/gfx/layers/apz/test/gtest/TestBasic.cpp
@@ -201,27 +201,27 @@ TEST_F(APZCBasicTester, PanningTransform
// go into overscroll, and finally snap-back to recover from overscroll.
// Again, ensure we only get one set of state change notifications for
// this entire procedure.
MockFunction<void(std::string checkPointName)> check;
{
InSequence s;
EXPECT_CALL(check, Call("Simple pan"));
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::StartTouch,_)).Times(1);
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::TransformBegin,_)).Times(1);
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::StartPanning,_)).Times(1);
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::EndTouch,_)).Times(1);
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::TransformEnd,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eStartTouch,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eTransformBegin,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eStartPanning,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eEndTouch,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eTransformEnd,_)).Times(1);
EXPECT_CALL(check, Call("Complex pan"));
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::StartTouch,_)).Times(1);
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::TransformBegin,_)).Times(1);
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::StartPanning,_)).Times(1);
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::EndTouch,_)).Times(1);
- EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::TransformEnd,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eStartTouch,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eTransformBegin,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eStartPanning,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eEndTouch,_)).Times(1);
+ EXPECT_CALL(*mcc, NotifyAPZStateChange(_,GeckoContentController::APZStateChange::eTransformEnd,_)).Times(1);
EXPECT_CALL(check, Call("Done"));
}
check.Call("Simple pan");
ApzcPanNoFling(apzc, 50, 25);
check.Call("Complex pan");
Pan(apzc, 25, 45);
apzc->AdvanceAnimationsUntilEnd();
--- a/gfx/layers/apz/util/APZEventState.cpp
+++ b/gfx/layers/apz/util/APZEventState.cpp
@@ -371,17 +371,17 @@ APZEventState::ProcessMouseEvent(const W
void
APZEventState::ProcessAPZStateChange(const nsCOMPtr<nsIDocument>& aDocument,
ViewID aViewId,
APZStateChange aChange,
int aArg)
{
switch (aChange)
{
- case APZStateChange::TransformBegin:
+ case APZStateChange::eTransformBegin:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
sf->SetTransformingByAPZ(true);
}
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
if (scrollbarMediator) {
scrollbarMediator->ScrollbarActivityStarted();
@@ -392,17 +392,17 @@ APZEventState::ProcessAPZStateChange(con
if (docshell && sf) {
nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
nsdocshell->NotifyAsyncPanZoomStarted();
}
}
mActiveAPZTransforms++;
break;
}
- case APZStateChange::TransformEnd:
+ case APZStateChange::eTransformEnd:
{
mActiveAPZTransforms--;
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
sf->SetTransformingByAPZ(false);
}
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
if (scrollbarMediator) {
@@ -413,36 +413,37 @@ APZEventState::ProcessAPZStateChange(con
nsCOMPtr<nsIDocShell> docshell(aDocument->GetDocShell());
if (docshell && sf) {
nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
nsdocshell->NotifyAsyncPanZoomStopped();
}
}
break;
}
- case APZStateChange::StartTouch:
+ case APZStateChange::eStartTouch:
{
mActiveElementManager->HandleTouchStart(aArg);
break;
}
- case APZStateChange::StartPanning:
+ case APZStateChange::eStartPanning:
{
// The user started to pan, so we don't want anything to be :active.
mActiveElementManager->ClearActivation();
break;
}
- case APZStateChange::EndTouch:
+ case APZStateChange::eEndTouch:
{
mEndTouchIsClick = aArg;
mActiveElementManager->HandleTouchEnd();
break;
}
- default:
- // APZStateChange has a 'sentinel' value, and the compiler complains
- // if an enumerator is not handled and there is no 'default' case.
+ case APZStateChange::eSentinel:
+ // Should never happen, but we want this case branch to stop the compiler
+ // whining about unhandled values.
+ MOZ_ASSERT(false);
break;
}
}
void
APZEventState::ProcessClusterHit()
{
// If we hit a cluster of links then we shouldn't activate any of them,
--- a/widget/android/AndroidContentController.cpp
+++ b/widget/android/AndroidContentController.cpp
@@ -122,21 +122,21 @@ AndroidContentController::NotifyAPZState
{
// This function may get invoked twice, if the first invocation is not on
// the main thread then the ChromeProcessController version of this function
// will redispatch to the main thread. We want to make sure that our handling
// only happens on the main thread.
ChromeProcessController::NotifyAPZStateChange(aGuid, aChange, aArg);
if (NS_IsMainThread()) {
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
- if (aChange == layers::GeckoContentController::APZStateChange::TransformEnd) {
+ if (aChange == layers::GeckoContentController::APZStateChange::eTransformEnd) {
// This is used by tests to determine when the APZ is done doing whatever
// it's doing. XXX generify this as needed when writing additional tests.
observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
observerService->NotifyObservers(nullptr, "PanZoom:StateChange", MOZ_UTF16("NOTHING"));
- } else if (aChange == layers::GeckoContentController::APZStateChange::TransformBegin) {
+ } else if (aChange == layers::GeckoContentController::APZStateChange::eTransformBegin) {
observerService->NotifyObservers(nullptr, "PanZoom:StateChange", MOZ_UTF16("PANNING"));
}
}
}
} // namespace widget
} // namespace mozilla