Bug 1246477 - Fix carets not updated by scroll events in LongTapState. r=roc

This is a regression by "Bug 1121468 - Go to NoActionState after
receiving release on LongTapState."

When receiving a scroll event in LongTapState, i.e. apz starts, we
should call OnScrollStart() and move to the ScrollState.

--HG--
extra : commitid : GsQNnTtqhzh
extra : rebase_source : 0a6ad44a4bf97ed15b374094929df5409deeba41
This commit is contained in:
Ting-Yu Lin 2016-02-08 16:08:45 +08:00
Родитель ea6f9a1958
Коммит 07b84af1aa
4 изменённых файлов: 54 добавлений и 0 удалений

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

@ -339,6 +339,12 @@ public:
return nsEventStatus_eIgnore;
}
virtual void OnScrollStart(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnScrollStart();
aContext->SetState(aContext->ScrollState());
}
virtual void OnReflow(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnReflow();

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

@ -1,6 +1,10 @@
// Steps to generate AccessibleCaretEventHubStates.png
// 1. Install Graphviz
// 2. dot -T png -o AccessibleCaretEventHubStates.png AccessibleCaretEventHubStates.dot
//
// Note: If the edge has 'constraint=false', it is not used in ranking the
// nodes. http://www.graphviz.org/doc/info/attrs.html#d:constraint
digraph event_hub_states {
node [style=filled];
edge [color="gray30", fontcolor="gray20", fontsize=12]
@ -25,6 +29,7 @@ digraph event_hub_states {
LongTap [color="#E8C516"]
LongTap -> NoAction [label="Release"];
LongTap -> Scroll [label="Scroll start", constraint=false];
Scroll [color="#FF9022"]
Scroll -> PostScroll [label="Scroll end"];

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 94 KiB

После

Ширина:  |  Высота:  |  Размер: 95 KiB

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

@ -447,6 +447,7 @@ AccessibleCaretEventHubTester::TestLongTapWithSelectWordSuccessful(
PressEventCreator aPressEventCreator,
ReleaseEventCreator aReleaseEventCreator)
{
MockFunction<void(::std::string aCheckPointName)> check;
{
InSequence dummy;
@ -455,8 +456,20 @@ AccessibleCaretEventHubTester::TestLongTapWithSelectWordSuccessful(
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), SelectWordOrShortcut(_))
.WillOnce(Return(NS_OK));
EXPECT_CALL(check, Call("longtap with scrolling"));
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), PressCaret(_))
.WillOnce(Return(NS_ERROR_FAILURE));
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), SelectWordOrShortcut(_))
.WillOnce(Return(NS_OK));
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), OnScrollStart());
EXPECT_CALL(*mHub->GetMockAccessibleCaretManager(), OnScrollEnd());
}
// Test long tap without scrolling.
HandleEventAndCheckState(aPressEventCreator(0, 0),
MockAccessibleCaretEventHub::PressNoCaretState(),
nsEventStatus_eIgnore);
@ -468,6 +481,36 @@ AccessibleCaretEventHubTester::TestLongTapWithSelectWordSuccessful(
HandleEventAndCheckState(aReleaseEventCreator(0, 0),
MockAccessibleCaretEventHub::NoActionState(),
nsEventStatus_eIgnore);
// On Fennec, after long tap, the script might scroll and zoom the input field
// to the center of the screen to make typing easier before the user lifts the
// finger.
check.Call("longtap with scrolling");
HandleEventAndCheckState(aPressEventCreator(1, 1),
MockAccessibleCaretEventHub::PressNoCaretState(),
nsEventStatus_eIgnore);
HandleEventAndCheckState(CreateLongTapEvent(1, 1),
MockAccessibleCaretEventHub::LongTapState(),
nsEventStatus_eConsumeNoDefault);
mHub->AsyncPanZoomStarted();
EXPECT_EQ(mHub->GetState(), MockAccessibleCaretEventHub::ScrollState());
mHub->ScrollPositionChanged();
EXPECT_EQ(mHub->GetState(), MockAccessibleCaretEventHub::ScrollState());
mHub->AsyncPanZoomStopped();
EXPECT_EQ(mHub->GetState(), MockAccessibleCaretEventHub::PostScrollState());
// Simulate scroll end fired by timer.
MockAccessibleCaretEventHub::FireScrollEnd(nullptr, mHub);
EXPECT_EQ(mHub->GetState(), MockAccessibleCaretEventHub::NoActionState());
HandleEventAndCheckState(aReleaseEventCreator(1, 1),
MockAccessibleCaretEventHub::NoActionState(),
nsEventStatus_eIgnore);
}
TEST_F(AccessibleCaretEventHubTester, TestMouseLongTapWithSelectWordFailed)