Commit d0785493 authored by Katie D's avatar Katie D Committed by Commit Bot

Autoclick scroll bubble is initially positioned near menu bubble.

The scroll bubble sticks near the menu bubble until the user
explicitly changes the scroll bubble position. Per UX.

Bug: 978163
Change-Id: Id3064be03c2b9fde84ca0a96a4fd4f50391a6503
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1691781
Commit-Queue: Katie Dektar <katie@chromium.org>
Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#676106}
parent c27d41b4
...@@ -265,9 +265,10 @@ void AutoclickController::OnExitedScrollButton() { ...@@ -265,9 +265,10 @@ void AutoclickController::OnExitedScrollButton() {
void AutoclickController::OnAutoclickScrollableBoundsFound( void AutoclickController::OnAutoclickScrollableBoundsFound(
gfx::Rect& bounds_in_screen) { gfx::Rect& bounds_in_screen) {
// TODO(katie): Don't call this on the very first time scrollable bounds // The very first time scrollable bounds are found, the default first
// are found for each time the type is changed to scroll. We want the // position of the scrollbar to be next to the menu bubble.
// default first position of the scrollbar to be next to the menu bubble. if (is_initial_scroll_location_)
return;
menu_bubble_controller_->SetScrollPosition(bounds_in_screen, menu_bubble_controller_->SetScrollPosition(bounds_in_screen,
scroll_location_); scroll_location_);
} }
...@@ -341,6 +342,7 @@ void AutoclickController::DoAutoclickAction() { ...@@ -341,6 +342,7 @@ void AutoclickController::DoAutoclickAction() {
mouse_event_flags_); mouse_event_flags_);
} else { } else {
scroll_location_ = gesture_anchor_location_; scroll_location_ = gesture_anchor_location_;
is_initial_scroll_location_ = false;
UpdateScrollPosition(scroll_location_); UpdateScrollPosition(scroll_location_);
Shell::Get() Shell::Get()
->accessibility_controller() ->accessibility_controller()
...@@ -498,13 +500,12 @@ void AutoclickController::UpdateRingSize() { ...@@ -498,13 +500,12 @@ void AutoclickController::UpdateRingSize() {
} }
void AutoclickController::InitializeScrollLocation() { void AutoclickController::InitializeScrollLocation() {
// TODO(katie): Set the first scroll location to the center of the active // Sets the scroll location to the center of the root window.
// window or view, which will be found using the automation API. Currently
// just setting it to the center of the root window.
scroll_location_ = ash::Shell::Get() scroll_location_ = ash::Shell::Get()
->GetPrimaryRootWindow() ->GetPrimaryRootWindow()
->GetBoundsInScreen() ->GetBoundsInScreen()
.CenterPoint(); .CenterPoint();
is_initial_scroll_location_ = true;
Shell::Get() Shell::Get()
->accessibility_controller() ->accessibility_controller()
->RequestAutoclickScrollableBoundsForPoint(scroll_location_); ->RequestAutoclickScrollableBoundsForPoint(scroll_location_);
......
...@@ -189,6 +189,10 @@ class ASH_EXPORT AutoclickController ...@@ -189,6 +189,10 @@ class ASH_EXPORT AutoclickController
// The point at which the next scroll event will occur. // The point at which the next scroll event will occur.
gfx::Point scroll_location_{-kDefaultAutoclickMovementThreshold, gfx::Point scroll_location_{-kDefaultAutoclickMovementThreshold,
-kDefaultAutoclickMovementThreshold}; -kDefaultAutoclickMovementThreshold};
// Whether the current scroll_location_ is the initial one set automatically,
// or if false, it was chosen explicitly by the user. The scroll bubble
// positions are different in these two cases.
bool is_initial_scroll_location_ = true;
// Whether the cursor is currently over a scroll button. If true, new gestures // Whether the cursor is currently over a scroll button. If true, new gestures
// will not be started. This ensures the autoclick ring is not drawn over // will not be started. This ensures the autoclick ring is not drawn over
// the scroll position buttons, and extra clicks will not be generated there. // the scroll position buttons, and extra clicks will not be generated there.
......
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
namespace ash { namespace ash {
namespace {
const int kScrollToMenuBoundsBuffer = 18;
}
class MouseEventCapturer : public ui::EventHandler { class MouseEventCapturer : public ui::EventHandler {
public: public:
MouseEventCapturer() { Reset(); } MouseEventCapturer() { Reset(); }
...@@ -1309,4 +1313,67 @@ TEST_F(AutoclickTest, ScrollOccursWhenHoveredOverScrollButtons) { ...@@ -1309,4 +1313,67 @@ TEST_F(AutoclickTest, ScrollOccursWhenHoveredOverScrollButtons) {
EnableExperimentalAutoclickFlag(false); EnableExperimentalAutoclickFlag(false);
} }
TEST_F(AutoclickTest, ScrollMenuBubblePostioning) {
UpdateDisplay("800x600");
EnableExperimentalAutoclickFlag(true);
GetAutoclickController()->SetEnabled(true, false /* do not show dialog */);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomRight);
GetAutoclickController()->SetAutoclickEventType(AutoclickEventType::kScroll);
ASSERT_TRUE(GetAutoclickScrollView());
// Set the bounds to be the entire window.
gfx::Rect display_bounds = gfx::Rect(0, 0, 800, 600);
GetAutoclickController()->OnAutoclickScrollableBoundsFound(display_bounds);
// The scroll bubble should start near the autoclick menu.
gfx::Rect scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
gfx::Rect menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
kScrollToMenuBoundsBuffer);
// Moving the autoclick menu around the screen moves the scroll bubble too.
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomLeft);
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
kScrollToMenuBoundsBuffer);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kTopLeft);
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
kScrollToMenuBoundsBuffer);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kTopRight);
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
kScrollToMenuBoundsBuffer);
// However, if we dwell somewhere else, the autoclick scroll menu will now
// move out of the corner and near that point when the display bounds are
// found.
gfx::Point scroll_point = gfx::Point(0, 0);
GetEventGenerator()->MoveMouseTo(scroll_point);
base::RunLoop().RunUntilIdle();
GetAutoclickController()->OnAutoclickScrollableBoundsFound(display_bounds);
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
EXPECT_GT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
kScrollToMenuBoundsBuffer);
// Moving the bubble menu now does not change the scroll bubble's position,
// it remains near its point.
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomRight);
EXPECT_EQ(GetAutoclickScrollView()->GetBoundsInScreen(), scroll_bounds);
EnableExperimentalAutoclickFlag(false);
}
} // namespace ash } // namespace ash
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment