mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 01:08:21 +00:00
Bug 1210315 - Use preference to control whether to use long tap injector. r=roc
In AccessibleCaretEventHub, it is not accurate to use APZ enabled to determine whether to use long tap injector. On desktop browser, there's no long tap events even if APZ is enabled. We should use a preference to control that. Since it's a fact the APZ on b2g has long tap events, we should use preference to disable long tap injector so that when long tap events stop dispatching to AccessibleCaretEventHub, we'll know immediately. Delete SetUseAsyncPanZoom() usage in gtest since APZ is not related to scrolling in AccessibleCaretEventHub. --HG-- extra : commitid : KgAxEFNYaeb extra : rebase_source : 1f0eb87354be8d97f946ea2b1f2a5425521bcf12
This commit is contained in:
parent
c3436b9a3b
commit
d7357db411
@ -1069,6 +1069,11 @@ pref("dom.apps.customization.enabled", true);
|
||||
// New implementation to unify touch-caret and selection-carets.
|
||||
pref("layout.accessiblecaret.enabled", true);
|
||||
|
||||
// APZ on real devices supports long tap events.
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
pref("layout.accessiblecaret.use_long_tap_injector", false);
|
||||
#endif
|
||||
|
||||
// Enable sync and mozId with Firefox Accounts.
|
||||
pref("services.sync.fxaccounts.enabled", true);
|
||||
pref("identity.fxaccounts.enabled", true);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsFrameSelection.h"
|
||||
@ -371,8 +372,16 @@ MOZ_IMPL_STATE_CLASS_GETTER(ScrollState)
|
||||
MOZ_IMPL_STATE_CLASS_GETTER(PostScrollState)
|
||||
MOZ_IMPL_STATE_CLASS_GETTER(LongTapState)
|
||||
|
||||
bool AccessibleCaretEventHub::sUseLongTapInjector = true;
|
||||
|
||||
AccessibleCaretEventHub::AccessibleCaretEventHub()
|
||||
{
|
||||
static bool prefsAdded = false;
|
||||
if (!prefsAdded) {
|
||||
Preferences::AddBoolVarCache(&sUseLongTapInjector,
|
||||
"layout.accessiblecaret.use_long_tap_injector");
|
||||
prefsAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
AccessibleCaretEventHub::~AccessibleCaretEventHub()
|
||||
@ -406,16 +415,15 @@ AccessibleCaretEventHub::Init(nsIPresShell* aPresShell)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
mUseAsyncPanZoom = mPresShell->AsyncPanZoomEnabled();
|
||||
#endif
|
||||
|
||||
docShell->AddWeakReflowObserver(this);
|
||||
docShell->AddWeakScrollObserver(this);
|
||||
|
||||
mDocShell = static_cast<nsDocShell*>(docShell);
|
||||
|
||||
mLongTapInjectorTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
if (sUseLongTapInjector) {
|
||||
mLongTapInjectorTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
}
|
||||
|
||||
mScrollEndInjectorTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
|
||||
mManager = MakeUnique<AccessibleCaretManager>(mPresShell);
|
||||
@ -638,10 +646,6 @@ AccessibleCaretEventHub::MoveDistanceIsLarge(const nsPoint& aPoint) const
|
||||
void
|
||||
AccessibleCaretEventHub::LaunchLongTapInjector()
|
||||
{
|
||||
if (mUseAsyncPanZoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mLongTapInjectorTimer) {
|
||||
return;
|
||||
}
|
||||
@ -654,10 +658,6 @@ AccessibleCaretEventHub::LaunchLongTapInjector()
|
||||
void
|
||||
AccessibleCaretEventHub::CancelLongTapInjector()
|
||||
{
|
||||
if (mUseAsyncPanZoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mLongTapInjectorTimer) {
|
||||
return;
|
||||
}
|
||||
|
@ -130,9 +130,6 @@ protected:
|
||||
// Member variables
|
||||
bool mInitialized = false;
|
||||
|
||||
// True if async-pan-zoom should be used.
|
||||
bool mUseAsyncPanZoom = false;
|
||||
|
||||
State* mState = NoActionState();
|
||||
|
||||
// Will be set to nullptr in Terminate().
|
||||
@ -155,6 +152,9 @@ protected:
|
||||
// For filter multitouch event
|
||||
int32_t mActiveTouchId = kInvalidTouchId;
|
||||
|
||||
// Simulate long tap if the platform does not support eMouseLongTap events.
|
||||
static bool sUseLongTapInjector;
|
||||
|
||||
static const int32_t kScrollEndTimerDelay = 300;
|
||||
static const int32_t kMoveStartToleranceInPixel = 5;
|
||||
static const int32_t kInvalidTouchId = -1;
|
||||
|
@ -87,11 +87,6 @@ public:
|
||||
{
|
||||
return static_cast<MockAccessibleCaretManager*>(mManager.get());
|
||||
}
|
||||
|
||||
void SetUseAsyncPanZoom(bool aUseAsyncPanZoom)
|
||||
{
|
||||
mUseAsyncPanZoom = aUseAsyncPanZoom;
|
||||
}
|
||||
};
|
||||
|
||||
// Print the name of the state for debugging.
|
||||
@ -558,8 +553,6 @@ AccessibleCaretEventHubTester::TestEventDrivenAsyncPanZoomScroll(
|
||||
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), OnScrollEnd());
|
||||
}
|
||||
|
||||
mHub->SetUseAsyncPanZoom(true);
|
||||
|
||||
// Receive press event.
|
||||
HandleEventAndCheckState(aPressEventCreator(0, 0),
|
||||
MockAccessibleCaretEventHub::PressNoCaretState(),
|
||||
@ -641,8 +634,6 @@ TEST_F(AccessibleCaretEventHubTester, TestNoEventAsyncPanZoomScroll)
|
||||
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), OnScrollEnd());
|
||||
}
|
||||
|
||||
mHub->SetUseAsyncPanZoom(true);
|
||||
|
||||
check.Call("1");
|
||||
|
||||
mHub->AsyncPanZoomStarted();
|
||||
@ -680,8 +671,6 @@ TEST_F(AccessibleCaretEventHubTester, TestAsyncPanZoomScrollStartedThenBlur)
|
||||
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), OnBlur());
|
||||
}
|
||||
|
||||
mHub->SetUseAsyncPanZoom(true);
|
||||
|
||||
mHub->AsyncPanZoomStarted();
|
||||
EXPECT_EQ(mHub->GetState(), MockAccessibleCaretEventHub::ScrollState());
|
||||
|
||||
@ -702,8 +691,6 @@ TEST_F(AccessibleCaretEventHubTester, TestAsyncPanZoomScrollEndedThenBlur)
|
||||
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), OnBlur());
|
||||
}
|
||||
|
||||
mHub->SetUseAsyncPanZoom(true);
|
||||
|
||||
mHub->AsyncPanZoomStarted();
|
||||
EXPECT_EQ(mHub->GetState(), MockAccessibleCaretEventHub::ScrollState());
|
||||
|
||||
|
@ -4855,6 +4855,10 @@ pref("layout.accessiblecaret.bar.width", "2.0");
|
||||
// no one touches it. Set the value to 0 to disable this feature.
|
||||
pref("layout.accessiblecaret.timeout_ms", 3000);
|
||||
|
||||
// Simulate long tap to select words on the platforms where APZ is not enabled
|
||||
// or long tap events does not fired by APZ.
|
||||
pref("layout.accessiblecaret.use_long_tap_injector", true);
|
||||
|
||||
// Wakelock is disabled by default.
|
||||
pref("dom.wakelock.enabled", false);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user