mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 03:24:26 +00:00
Bug 1037019 - Remove the mTouchActionPropertyEnabled flag in APZC and flip the pref directly in the tests. r=botond
This commit is contained in:
parent
1a56b68126
commit
a75ff9e2b1
gfx
layers/apz/src
tests/gtest
@ -714,7 +714,6 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId,
|
||||
mRefPtrMonitor("RefPtrMonitor"),
|
||||
mSharingFrameMetricsAcrossProcesses(false),
|
||||
mMonitor("AsyncPanZoomController"),
|
||||
mTouchActionPropertyEnabled(gfxPrefs::TouchActionEnabled()),
|
||||
mState(NOTHING),
|
||||
mContentResponseTimeoutTask(nullptr),
|
||||
mX(MOZ_THIS_IN_INITIALIZER_LIST()),
|
||||
@ -1011,7 +1010,7 @@ nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent)
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
if (mTouchActionPropertyEnabled &&
|
||||
if (gfxPrefs::TouchActionEnabled() &&
|
||||
(GetTouchBehavior(0) & AllowedTouchBehavior::VERTICAL_PAN) &&
|
||||
(GetTouchBehavior(0) & AllowedTouchBehavior::HORIZONTAL_PAN)) {
|
||||
// User tries to trigger a touch behavior. If allowed touch behavior is vertical pan
|
||||
@ -1579,7 +1578,7 @@ nsEventStatus AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent
|
||||
double angle = atan2(dy, dx); // range [-pi, pi]
|
||||
angle = fabs(angle); // range [0, pi]
|
||||
|
||||
if (mTouchActionPropertyEnabled) {
|
||||
if (gfxPrefs::TouchActionEnabled()) {
|
||||
HandlePanningWithTouchAction(angle, GetTouchBehavior(0));
|
||||
} else {
|
||||
if (GetAxisLockMode() == FREE) {
|
||||
@ -2488,7 +2487,7 @@ void AsyncPanZoomController::CheckContentResponse() {
|
||||
canProceedToTouchState &= mTouchBlockState.mPreventDefaultSet;
|
||||
}
|
||||
|
||||
if (mTouchActionPropertyEnabled) {
|
||||
if (gfxPrefs::TouchActionEnabled()) {
|
||||
canProceedToTouchState &= mTouchBlockState.mAllowedTouchBehaviorSet;
|
||||
}
|
||||
|
||||
@ -2527,7 +2526,7 @@ void AsyncPanZoomController::CheckContentResponse() {
|
||||
}
|
||||
|
||||
bool AsyncPanZoomController::TouchActionAllowPinchZoom() {
|
||||
if (!mTouchActionPropertyEnabled) {
|
||||
if (!gfxPrefs::TouchActionEnabled()) {
|
||||
return true;
|
||||
}
|
||||
// Pointer events specification implies all touch points to allow zoom
|
||||
@ -2541,7 +2540,7 @@ bool AsyncPanZoomController::TouchActionAllowPinchZoom() {
|
||||
}
|
||||
|
||||
bool AsyncPanZoomController::TouchActionAllowDoubleTapZoom() {
|
||||
if (!mTouchActionPropertyEnabled) {
|
||||
if (!gfxPrefs::TouchActionEnabled()) {
|
||||
return true;
|
||||
}
|
||||
for (size_t i = 0; i < mTouchBlockState.mAllowedTouchBehaviors.Length(); i++) {
|
||||
|
@ -712,12 +712,6 @@ protected:
|
||||
// would significantly limit what methods could be 'const'.
|
||||
mutable ReentrantMonitor mMonitor;
|
||||
|
||||
// Specifies whether we should use touch-action css property. Initialized from
|
||||
// the preferences. This property (in comparison with the global one) simplifies
|
||||
// testing apzc with (and without) touch-action property enabled concurrently
|
||||
// (e.g. with the gtest framework).
|
||||
bool mTouchActionPropertyEnabled;
|
||||
|
||||
// Stores the state of panning and zooming this frame. This is protected by
|
||||
// |mMonitor|; that is, it should be held whenever this is updated.
|
||||
PanZoomState mState;
|
||||
|
@ -47,6 +47,19 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
class TouchActionEnabledTester : public AsyncPanZoomControllerTester {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
AsyncPanZoomControllerTester::SetUp();
|
||||
gfxPrefs::SetTouchActionEnabled(true);
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
gfxPrefs::SetTouchActionEnabled(false);
|
||||
AsyncPanZoomControllerTester::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
class MockContentController : public GeckoContentController {
|
||||
public:
|
||||
MOCK_METHOD1(RequestContentRepaint, void(const FrameMetrics&));
|
||||
@ -147,15 +160,6 @@ public:
|
||||
: AsyncPanZoomController(aLayersId, aTreeManager, aMcc, aBehavior)
|
||||
{}
|
||||
|
||||
// Since touch-action-enabled property is global - setting it for each test
|
||||
// separately isn't safe from the concurrency point of view. To make tests
|
||||
// run concurrent and independent from each other we have a member variable
|
||||
// mTouchActionEnabled for each apzc and setter defined here.
|
||||
void SetTouchActionEnabled(const bool touchActionEnabled) {
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
mTouchActionPropertyEnabled = touchActionEnabled;
|
||||
}
|
||||
|
||||
void SetFrameMetrics(const FrameMetrics& metrics) {
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
mFrameMetrics = metrics;
|
||||
@ -280,7 +284,7 @@ void ApzcPan(AsyncPanZoomController* apzc,
|
||||
}
|
||||
|
||||
static
|
||||
void DoPanTest(bool aShouldTriggerScroll, bool aShouldUseTouchAction, uint32_t aBehavior)
|
||||
void DoPanTest(bool aShouldTriggerScroll, uint32_t aBehavior)
|
||||
{
|
||||
TimeStamp testStartTime = TimeStamp::Now();
|
||||
AsyncPanZoomController::SetFrameTime(testStartTime);
|
||||
@ -289,7 +293,6 @@ void DoPanTest(bool aShouldTriggerScroll, bool aShouldUseTouchAction, uint32_t a
|
||||
nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
|
||||
nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc, tm);
|
||||
|
||||
apzc->SetTouchActionEnabled(aShouldUseTouchAction);
|
||||
apzc->SetFrameMetrics(TestFrameMetrics());
|
||||
apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
|
||||
|
||||
@ -451,12 +454,6 @@ void DoPinchTest(bool aUseGestureRecognizer, bool aShouldTriggerPinch,
|
||||
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(0);
|
||||
}
|
||||
|
||||
if (aAllowedTouchBehaviors) {
|
||||
apzc->SetTouchActionEnabled(true);
|
||||
} else {
|
||||
apzc->SetTouchActionEnabled(false);
|
||||
}
|
||||
|
||||
int touchInputId = 0;
|
||||
if (aUseGestureRecognizer) {
|
||||
ApzcPinchWithTouchMoveInput(apzc, 250, 300, 1.25, touchInputId, aShouldTriggerPinch, aAllowedTouchBehaviors);
|
||||
@ -551,21 +548,21 @@ TEST_F(AsyncPanZoomControllerTester, Pinch_DefaultGestures_NoTouchAction) {
|
||||
DoPinchTest(false, true);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, Pinch_DefaultGestures_TouchActionNone) {
|
||||
TEST_F(TouchActionEnabledTester, Pinch_DefaultGestures_TouchActionNone) {
|
||||
nsTArray<uint32_t> behaviors;
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
DoPinchTest(false, false, &behaviors);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, Pinch_DefaultGestures_TouchActionZoom) {
|
||||
TEST_F(TouchActionEnabledTester, Pinch_DefaultGestures_TouchActionZoom) {
|
||||
nsTArray<uint32_t> behaviors;
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
DoPinchTest(false, true, &behaviors);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, Pinch_DefaultGestures_TouchActionNotAllowZoom) {
|
||||
TEST_F(TouchActionEnabledTester, Pinch_DefaultGestures_TouchActionNotAllowZoom) {
|
||||
nsTArray<uint32_t> behaviors;
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
@ -576,21 +573,21 @@ TEST_F(AsyncPanZoomControllerTester, Pinch_UseGestureDetector_NoTouchAction) {
|
||||
DoPinchTest(true, true);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, Pinch_UseGestureDetector_TouchActionNone) {
|
||||
TEST_F(TouchActionEnabledTester, Pinch_UseGestureDetector_TouchActionNone) {
|
||||
nsTArray<uint32_t> behaviors;
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
DoPinchTest(true, false, &behaviors);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, Pinch_UseGestureDetector_TouchActionZoom) {
|
||||
TEST_F(TouchActionEnabledTester, Pinch_UseGestureDetector_TouchActionZoom) {
|
||||
nsTArray<uint32_t> behaviors;
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
DoPinchTest(true, true, &behaviors);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, Pinch_UseGestureDetector_TouchActionNotAllowZoom) {
|
||||
TEST_F(TouchActionEnabledTester, Pinch_UseGestureDetector_TouchActionNotAllowZoom) {
|
||||
nsTArray<uint32_t> behaviors;
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
|
||||
behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
@ -745,7 +742,7 @@ TEST_F(AsyncPanZoomControllerTester, ComplexTransform) {
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, Pan) {
|
||||
DoPanTest(true, false, mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
DoPanTest(true, mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
}
|
||||
|
||||
// In the each of the following 4 pan tests we are performing two pan gestures: vertical pan from top
|
||||
@ -753,24 +750,24 @@ TEST_F(AsyncPanZoomControllerTester, Pan) {
|
||||
// According to the pointer-events/touch-action spec AUTO and PAN_Y touch-action values allow vertical
|
||||
// scrolling while NONE and PAN_X forbid it. The first parameter of DoPanTest method specifies this
|
||||
// behavior.
|
||||
TEST_F(AsyncPanZoomControllerTester, PanWithTouchActionAuto) {
|
||||
DoPanTest(true, true,
|
||||
mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN | mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
|
||||
TEST_F(TouchActionEnabledTester, PanWithTouchActionAuto) {
|
||||
DoPanTest(true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, PanWithTouchActionNone) {
|
||||
DoPanTest(false, true, 0);
|
||||
TEST_F(TouchActionEnabledTester, PanWithTouchActionNone) {
|
||||
DoPanTest(false, 0);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, PanWithTouchActionPanX) {
|
||||
DoPanTest(false, true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN);
|
||||
TEST_F(TouchActionEnabledTester, PanWithTouchActionPanX) {
|
||||
DoPanTest(false, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, PanWithTouchActionPanY) {
|
||||
DoPanTest(true, true, mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
|
||||
TEST_F(TouchActionEnabledTester, PanWithTouchActionPanY) {
|
||||
DoPanTest(true, mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, PanWithPreventDefault) {
|
||||
TEST_F(TouchActionEnabledTester, PanWithPreventDefault) {
|
||||
TimeStamp testStartTime = TimeStamp::Now();
|
||||
AsyncPanZoomController::SetFrameTime(testStartTime);
|
||||
|
||||
@ -793,7 +790,6 @@ TEST_F(AsyncPanZoomControllerTester, PanWithPreventDefault) {
|
||||
// Pan down
|
||||
nsTArray<uint32_t> allowedTouchBehaviors;
|
||||
allowedTouchBehaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
|
||||
apzc->SetTouchActionEnabled(true);
|
||||
ApzcPan(apzc, tm, time, touchStart, touchEnd, true, true, &allowedTouchBehaviors);
|
||||
|
||||
// Send the signal that content has handled and preventDefaulted the touch
|
||||
@ -1042,7 +1038,7 @@ TEST_F(AsyncPanZoomControllerTester, MediumPress) {
|
||||
}
|
||||
|
||||
void
|
||||
DoLongPressTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
|
||||
DoLongPressTest(uint32_t aBehavior) {
|
||||
nsRefPtr<MockContentControllerDelayed> mcc = new MockContentControllerDelayed();
|
||||
nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
|
||||
nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(
|
||||
@ -1052,8 +1048,6 @@ DoLongPressTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
|
||||
apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
|
||||
apzc->UpdateZoomConstraints(ZoomConstraints(false, false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
|
||||
|
||||
apzc->SetTouchActionEnabled(aShouldUseTouchAction);
|
||||
|
||||
int time = 0;
|
||||
|
||||
nsEventStatus status = ApzcDown(apzc, 10, 10, time);
|
||||
@ -1112,7 +1106,7 @@ DoLongPressTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
|
||||
}
|
||||
|
||||
void
|
||||
DoLongPressPreventDefaultTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
|
||||
DoLongPressPreventDefaultTest(uint32_t aBehavior) {
|
||||
// We have to initialize both an integer time and TimeStamp time because
|
||||
// TimeStamp doesn't have any ToXXX() functions for converting back to
|
||||
// primitives.
|
||||
@ -1129,8 +1123,6 @@ DoLongPressPreventDefaultTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
|
||||
apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
|
||||
apzc->UpdateZoomConstraints(ZoomConstraints(false, false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
|
||||
|
||||
apzc->SetTouchActionEnabled(aShouldUseTouchAction);
|
||||
|
||||
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(0);
|
||||
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(0);
|
||||
|
||||
@ -1200,23 +1192,23 @@ DoLongPressPreventDefaultTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, LongPress) {
|
||||
DoLongPressTest(false, mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
DoLongPressTest(mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, LongPressWithTouchAction) {
|
||||
DoLongPressTest(true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
TEST_F(TouchActionEnabledTester, LongPressWithTouchAction) {
|
||||
DoLongPressTest(mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, LongPressPreventDefault) {
|
||||
DoLongPressPreventDefaultTest(false, mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
DoLongPressPreventDefaultTest(mozilla::layers::AllowedTouchBehavior::NONE);
|
||||
}
|
||||
|
||||
TEST_F(AsyncPanZoomControllerTester, LongPressPreventDefaultWithTouchAction) {
|
||||
DoLongPressPreventDefaultTest(true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
TEST_F(TouchActionEnabledTester, LongPressPreventDefaultWithTouchAction) {
|
||||
DoLongPressPreventDefaultTest(mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN
|
||||
| mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
|
||||
}
|
||||
|
||||
// Layer tree for HitTesting1
|
||||
|
Loading…
x
Reference in New Issue
Block a user