Commit ae8526c6 authored by Anatoliy Potapchuk's avatar Anatoliy Potapchuk Committed by Commit Bot

[Ash] Rename AutoclickMenuPosition into FloatingMenuPosition

Since AutoclickMenuPosition contains quite generic values, which can be
reused by other floating menus, we should rename it to better indicate
its properties.

Bug: 1061068
Change-Id: Ifb58be11de2fa4163fc2e9a4f37a4b9c9bdc43b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2141928
Commit-Queue: Anatoliy Potapchuk <apotapchuk@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarKatie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757811}
parent 6c1f253e
...@@ -1516,7 +1516,7 @@ void AccessibilityControllerImpl::UpdateAutoclickMenuPositionFromPref() { ...@@ -1516,7 +1516,7 @@ void AccessibilityControllerImpl::UpdateAutoclickMenuPositionFromPref() {
} }
void AccessibilityControllerImpl::SetAutoclickMenuPosition( void AccessibilityControllerImpl::SetAutoclickMenuPosition(
AutoclickMenuPosition position) { FloatingMenuPosition position) {
if (!active_user_prefs_) if (!active_user_prefs_)
return; return;
active_user_prefs_->SetInteger(prefs::kAccessibilityAutoclickMenuPosition, active_user_prefs_->SetInteger(prefs::kAccessibilityAutoclickMenuPosition,
...@@ -1525,9 +1525,9 @@ void AccessibilityControllerImpl::SetAutoclickMenuPosition( ...@@ -1525,9 +1525,9 @@ void AccessibilityControllerImpl::SetAutoclickMenuPosition(
Shell::Get()->autoclick_controller()->SetMenuPosition(position); Shell::Get()->autoclick_controller()->SetMenuPosition(position);
} }
AutoclickMenuPosition AccessibilityControllerImpl::GetAutoclickMenuPosition() { FloatingMenuPosition AccessibilityControllerImpl::GetAutoclickMenuPosition() {
DCHECK(active_user_prefs_); DCHECK(active_user_prefs_);
return static_cast<AutoclickMenuPosition>(active_user_prefs_->GetInteger( return static_cast<FloatingMenuPosition>(active_user_prefs_->GetInteger(
prefs::kAccessibilityAutoclickMenuPosition)); prefs::kAccessibilityAutoclickMenuPosition));
} }
......
...@@ -201,8 +201,8 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController, ...@@ -201,8 +201,8 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
void SetAutoclickEventType(AutoclickEventType event_type); void SetAutoclickEventType(AutoclickEventType event_type);
AutoclickEventType GetAutoclickEventType(); AutoclickEventType GetAutoclickEventType();
void SetAutoclickMenuPosition(AutoclickMenuPosition position); void SetAutoclickMenuPosition(FloatingMenuPosition position);
AutoclickMenuPosition GetAutoclickMenuPosition(); FloatingMenuPosition GetAutoclickMenuPosition();
void RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen); void RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen);
// Update the autoclick menu bounds if necessary. This may need to happen when // Update the autoclick menu bounds if necessary. This may need to happen when
......
...@@ -207,7 +207,7 @@ void AutoclickController::SetMovementThreshold(int movement_threshold) { ...@@ -207,7 +207,7 @@ void AutoclickController::SetMovementThreshold(int movement_threshold) {
UpdateRingSize(); UpdateRingSize();
} }
void AutoclickController::SetMenuPosition(AutoclickMenuPosition menu_position) { void AutoclickController::SetMenuPosition(FloatingMenuPosition menu_position) {
menu_position_ = menu_position; menu_position_ = menu_position;
UpdateAutoclickMenuBoundsIfNeeded(); UpdateAutoclickMenuBoundsIfNeeded();
} }
......
...@@ -74,7 +74,7 @@ class ASH_EXPORT AutoclickController ...@@ -74,7 +74,7 @@ class ASH_EXPORT AutoclickController
void SetMovementThreshold(int movement_threshold); void SetMovementThreshold(int movement_threshold);
// Sets the menu position and updates the UI. // Sets the menu position and updates the UI.
void SetMenuPosition(AutoclickMenuPosition menu_position); void SetMenuPosition(FloatingMenuPosition menu_position);
// Performs the given ScrollPadAction at the current scrolling point. // Performs the given ScrollPadAction at the current scrolling point.
void DoScrollAction(ScrollPadAction action); void DoScrollAction(ScrollPadAction action);
...@@ -166,7 +166,7 @@ class ASH_EXPORT AutoclickController ...@@ -166,7 +166,7 @@ class ASH_EXPORT AutoclickController
// manually, the position will be fixed regardless of language direction and // manually, the position will be fixed regardless of language direction and
// shelf position. This probably means adding a new AutoclickMenuPostion // shelf position. This probably means adding a new AutoclickMenuPostion
// enum for "system default". // enum for "system default".
AutoclickMenuPosition menu_position_ = kDefaultAutoclickMenuPosition; FloatingMenuPosition menu_position_ = kDefaultAutoclickMenuPosition;
int mouse_event_flags_ = ui::EF_NONE; int mouse_event_flags_ = ui::EF_NONE;
// The target window is observed by AutoclickController for the duration // The target window is observed by AutoclickController for the duration
// of a autoclick gesture. // of a autoclick gesture.
......
...@@ -829,12 +829,12 @@ TEST_F(AutoclickTest, DoesActionOnBubbleWhenInDifferentModes) { ...@@ -829,12 +829,12 @@ TEST_F(AutoclickTest, DoesActionOnBubbleWhenInDifferentModes) {
const struct { const struct {
const std::string display_spec; const std::string display_spec;
float scale; float scale;
AutoclickMenuPosition position; FloatingMenuPosition position;
} kTestCases[] = { } kTestCases[] = {
{"800x600", 1.0f, AutoclickMenuPosition::kBottomRight}, {"800x600", 1.0f, FloatingMenuPosition::kBottomRight},
{"1024x800*2.0", 2.0f, AutoclickMenuPosition::kBottomRight}, {"1024x800*2.0", 2.0f, FloatingMenuPosition::kBottomRight},
{"800x600", 1.0f, AutoclickMenuPosition::kTopLeft}, {"800x600", 1.0f, FloatingMenuPosition::kTopLeft},
{"1024x800*2.0", 2.0f, AutoclickMenuPosition::kTopLeft}, {"1024x800*2.0", 2.0f, FloatingMenuPosition::kTopLeft},
}; };
for (const auto& test : kTestCases) { for (const auto& test : kTestCases) {
UpdateDisplay(test.display_spec); UpdateDisplay(test.display_spec);
...@@ -916,7 +916,7 @@ TEST_F(AutoclickTest, ...@@ -916,7 +916,7 @@ TEST_F(AutoclickTest,
GetAutoclickController()->SetAutoclickEventType( GetAutoclickController()->SetAutoclickEventType(
AutoclickEventType::kNoAction); AutoclickEventType::kNoAction);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomRight); FloatingMenuPosition::kBottomRight);
int animation_delay = 5; int animation_delay = 5;
int full_delay = UpdateAnimationDelayAndGetFullDelay(animation_delay); int full_delay = UpdateAnimationDelayAndGetFullDelay(animation_delay);
...@@ -987,7 +987,7 @@ TEST_F(AutoclickTest, BubbleMovesWithShelfPositionChange) { ...@@ -987,7 +987,7 @@ TEST_F(AutoclickTest, BubbleMovesWithShelfPositionChange) {
// Set up autoclick and the shelf. // Set up autoclick and the shelf.
Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true); Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomRight); FloatingMenuPosition::kBottomRight);
Shelf* shelf = GetPrimaryShelf(); Shelf* shelf = GetPrimaryShelf();
shelf->SetAutoHideBehavior(ShelfAutoHideBehavior::kNever); shelf->SetAutoHideBehavior(ShelfAutoHideBehavior::kNever);
EXPECT_EQ(shelf->GetVisibilityState(), SHELF_VISIBLE); EXPECT_EQ(shelf->GetVisibilityState(), SHELF_VISIBLE);
...@@ -1039,7 +1039,7 @@ TEST_F(AutoclickTest, AvoidsShelfBubble) { ...@@ -1039,7 +1039,7 @@ TEST_F(AutoclickTest, AvoidsShelfBubble) {
// Set up autoclick and the shelf. // Set up autoclick and the shelf.
Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true); Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomRight); FloatingMenuPosition::kBottomRight);
auto* unified_system_tray = GetPrimaryUnifiedSystemTray(); auto* unified_system_tray = GetPrimaryUnifiedSystemTray();
EXPECT_FALSE(unified_system_tray->IsBubbleShown()); EXPECT_FALSE(unified_system_tray->IsBubbleShown());
AutoclickMenuView* menu = GetAutoclickMenuView(); AutoclickMenuView* menu = GetAutoclickMenuView();
...@@ -1304,7 +1304,7 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) { ...@@ -1304,7 +1304,7 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) {
GetAutoclickController()->SetEnabled(true, false /* do not show dialog */); GetAutoclickController()->SetEnabled(true, false /* do not show dialog */);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomRight); FloatingMenuPosition::kBottomRight);
GetAutoclickController()->SetAutoclickEventType(AutoclickEventType::kScroll); GetAutoclickController()->SetAutoclickEventType(AutoclickEventType::kScroll);
ASSERT_TRUE(GetAutoclickScrollView()); ASSERT_TRUE(GetAutoclickScrollView());
...@@ -1321,21 +1321,21 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) { ...@@ -1321,21 +1321,21 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) {
// Moving the autoclick menu around the screen moves the scroll bubble too. // Moving the autoclick menu around the screen moves the scroll bubble too.
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomLeft); FloatingMenuPosition::kBottomLeft);
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen(); scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen(); menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds), EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
kScrollToMenuBoundsBuffer); kScrollToMenuBoundsBuffer);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kTopLeft); FloatingMenuPosition::kTopLeft);
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen(); scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen(); menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds), EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
kScrollToMenuBoundsBuffer); kScrollToMenuBoundsBuffer);
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kTopRight); FloatingMenuPosition::kTopRight);
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen(); scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen(); menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds), EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
...@@ -1355,7 +1355,7 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) { ...@@ -1355,7 +1355,7 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) {
// Moving the bubble menu now does not change the scroll bubble's position, // Moving the bubble menu now does not change the scroll bubble's position,
// it remains near its point. // it remains near its point.
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
AutoclickMenuPosition::kBottomRight); FloatingMenuPosition::kBottomRight);
EXPECT_EQ(GetAutoclickScrollView()->GetBoundsInScreen(), scroll_bounds); EXPECT_EQ(GetAutoclickScrollView()->GetBoundsInScreen(), scroll_bounds);
} }
......
...@@ -122,10 +122,10 @@ enum class AutoclickEventType { ...@@ -122,10 +122,10 @@ enum class AutoclickEventType {
kMaxValue = kScroll kMaxValue = kScroll
}; };
// The Automatic Clicks feature's on-screen menu display location. These values // Display location of the on-screen floating menus used by accessibility features(e.g. the
// are written to prefs so they should not be changed. New values should be // Automatic Clicks) . These values are written to prefs so they should not be changed. New values
// added at the end. // should be added at the end.
enum class AutoclickMenuPosition { enum class FloatingMenuPosition {
// The bottom right of the screen. // The bottom right of the screen.
kBottomRight, kBottomRight,
......
...@@ -57,8 +57,8 @@ constexpr AutoclickEventType kDefaultAutoclickEventType = ...@@ -57,8 +57,8 @@ constexpr AutoclickEventType kDefaultAutoclickEventType =
constexpr int kDefaultAutoclickMovementThreshold = 20; constexpr int kDefaultAutoclickMovementThreshold = 20;
// The default automatic click menu position. // The default automatic click menu position.
constexpr AutoclickMenuPosition kDefaultAutoclickMenuPosition = constexpr FloatingMenuPosition kDefaultAutoclickMenuPosition =
AutoclickMenuPosition::kSystemDefault; FloatingMenuPosition::kSystemDefault;
// The default frame color. // The default frame color.
constexpr SkColor kDefaultFrameColor = SkColorSetRGB(0xFD, 0xFE, 0xFF); constexpr SkColor kDefaultFrameColor = SkColorSetRGB(0xFD, 0xFE, 0xFF);
......
...@@ -29,34 +29,34 @@ namespace { ...@@ -29,34 +29,34 @@ namespace {
const int kAutoclickMenuWidth = 369; const int kAutoclickMenuWidth = 369;
const int kAutoclickMenuHeight = 64; const int kAutoclickMenuHeight = 64;
AutoclickMenuPosition DefaultSystemPosition() { FloatingMenuPosition DefaultSystemPosition() {
return base::i18n::IsRTL() ? AutoclickMenuPosition::kBottomLeft return base::i18n::IsRTL() ? FloatingMenuPosition::kBottomLeft
: AutoclickMenuPosition::kBottomRight; : FloatingMenuPosition::kBottomRight;
} }
views::BubbleBorder::Arrow GetScrollAnchorAlignmentForPosition( views::BubbleBorder::Arrow GetScrollAnchorAlignmentForPosition(
AutoclickMenuPosition position) { FloatingMenuPosition position) {
// If this is the default system position, pick the position based on the // If this is the default system position, pick the position based on the
// language direction. // language direction.
if (position == AutoclickMenuPosition::kSystemDefault) { if (position == FloatingMenuPosition::kSystemDefault) {
position = DefaultSystemPosition(); position = DefaultSystemPosition();
} }
// Mirror arrow in RTL languages so that it always stays near the screen // Mirror arrow in RTL languages so that it always stays near the screen
// edge. // edge.
switch (position) { switch (position) {
case AutoclickMenuPosition::kBottomLeft: case FloatingMenuPosition::kBottomLeft:
return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::TOP_RIGHT return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::TOP_RIGHT
: views::BubbleBorder::Arrow::TOP_LEFT; : views::BubbleBorder::Arrow::TOP_LEFT;
case AutoclickMenuPosition::kTopLeft: case FloatingMenuPosition::kTopLeft:
return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::BOTTOM_RIGHT return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::BOTTOM_RIGHT
: views::BubbleBorder::Arrow::BOTTOM_LEFT; : views::BubbleBorder::Arrow::BOTTOM_LEFT;
case AutoclickMenuPosition::kBottomRight: case FloatingMenuPosition::kBottomRight:
return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::TOP_LEFT return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::TOP_LEFT
: views::BubbleBorder::Arrow::TOP_RIGHT; : views::BubbleBorder::Arrow::TOP_RIGHT;
case AutoclickMenuPosition::kTopRight: case FloatingMenuPosition::kTopRight:
return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::BOTTOM_LEFT return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::BOTTOM_LEFT
: views::BubbleBorder::Arrow::BOTTOM_RIGHT; : views::BubbleBorder::Arrow::BOTTOM_RIGHT;
case AutoclickMenuPosition::kSystemDefault: case FloatingMenuPosition::kSystemDefault:
// It's not possible for position to be kSystemDefault here because we've // It's not possible for position to be kSystemDefault here because we've
// set it via DefaultSystemPosition() above if it was kSystemDefault. // set it via DefaultSystemPosition() above if it was kSystemDefault.
NOTREACHED(); NOTREACHED();
...@@ -102,21 +102,21 @@ void AutoclickMenuBubbleController::SetEventType(AutoclickEventType type) { ...@@ -102,21 +102,21 @@ void AutoclickMenuBubbleController::SetEventType(AutoclickEventType type) {
} }
void AutoclickMenuBubbleController::SetPosition( void AutoclickMenuBubbleController::SetPosition(
AutoclickMenuPosition new_position) { FloatingMenuPosition new_position) {
if (!menu_view_ || !bubble_view_ || !bubble_widget_) if (!menu_view_ || !bubble_view_ || !bubble_widget_)
return; return;
// Update the menu view's UX if the position has changed, or if it's not the // Update the menu view's UX if the position has changed, or if it's not the
// default position (because that can change with language direction). // default position (because that can change with language direction).
if (position_ != new_position || if (position_ != new_position ||
new_position == AutoclickMenuPosition::kSystemDefault) { new_position == FloatingMenuPosition::kSystemDefault) {
menu_view_->UpdatePosition(new_position); menu_view_->UpdatePosition(new_position);
} }
position_ = new_position; position_ = new_position;
// If this is the default system position, pick the position based on the // If this is the default system position, pick the position based on the
// language direction. // language direction.
if (new_position == AutoclickMenuPosition::kSystemDefault) if (new_position == FloatingMenuPosition::kSystemDefault)
new_position = DefaultSystemPosition(); new_position = DefaultSystemPosition();
// Calculates the ideal bounds. // Calculates the ideal bounds.
...@@ -127,17 +127,17 @@ void AutoclickMenuBubbleController::SetPosition( ...@@ -127,17 +127,17 @@ void AutoclickMenuBubbleController::SetPosition(
WorkAreaInsets::ForWindow(window)->user_work_area_bounds(); WorkAreaInsets::ForWindow(window)->user_work_area_bounds();
gfx::Rect new_bounds; gfx::Rect new_bounds;
switch (new_position) { switch (new_position) {
case AutoclickMenuPosition::kBottomRight: case FloatingMenuPosition::kBottomRight:
new_bounds = gfx::Rect(work_area.right() - kAutoclickMenuWidth, new_bounds = gfx::Rect(work_area.right() - kAutoclickMenuWidth,
work_area.bottom() - kAutoclickMenuHeight, work_area.bottom() - kAutoclickMenuHeight,
kAutoclickMenuWidth, kAutoclickMenuHeight); kAutoclickMenuWidth, kAutoclickMenuHeight);
break; break;
case AutoclickMenuPosition::kBottomLeft: case FloatingMenuPosition::kBottomLeft:
new_bounds = new_bounds =
gfx::Rect(work_area.x(), work_area.bottom() - kAutoclickMenuHeight, gfx::Rect(work_area.x(), work_area.bottom() - kAutoclickMenuHeight,
kAutoclickMenuWidth, kAutoclickMenuHeight); kAutoclickMenuWidth, kAutoclickMenuHeight);
break; break;
case AutoclickMenuPosition::kTopLeft: case FloatingMenuPosition::kTopLeft:
// Because there is no inset at the top of the widget, add // Because there is no inset at the top of the widget, add
// 2 * kCollisionWindowWorkAreaInsetsDp to the top of the work area. // 2 * kCollisionWindowWorkAreaInsetsDp to the top of the work area.
// to ensure correct padding. // to ensure correct padding.
...@@ -145,7 +145,7 @@ void AutoclickMenuBubbleController::SetPosition( ...@@ -145,7 +145,7 @@ void AutoclickMenuBubbleController::SetPosition(
work_area.x(), work_area.y() + 2 * kCollisionWindowWorkAreaInsetsDp, work_area.x(), work_area.y() + 2 * kCollisionWindowWorkAreaInsetsDp,
kAutoclickMenuWidth, kAutoclickMenuHeight); kAutoclickMenuWidth, kAutoclickMenuHeight);
break; break;
case AutoclickMenuPosition::kTopRight: case FloatingMenuPosition::kTopRight:
// Because there is no inset at the top of the widget, add // Because there is no inset at the top of the widget, add
// 2 * kCollisionWindowWorkAreaInsetsDp to the top of the work area. // 2 * kCollisionWindowWorkAreaInsetsDp to the top of the work area.
// to ensure correct padding. // to ensure correct padding.
...@@ -154,7 +154,7 @@ void AutoclickMenuBubbleController::SetPosition( ...@@ -154,7 +154,7 @@ void AutoclickMenuBubbleController::SetPosition(
work_area.y() + 2 * kCollisionWindowWorkAreaInsetsDp, work_area.y() + 2 * kCollisionWindowWorkAreaInsetsDp,
kAutoclickMenuWidth, kAutoclickMenuHeight); kAutoclickMenuWidth, kAutoclickMenuHeight);
break; break;
case AutoclickMenuPosition::kSystemDefault: case FloatingMenuPosition::kSystemDefault:
return; return;
} }
...@@ -200,7 +200,7 @@ void AutoclickMenuBubbleController::SetScrollPosition( ...@@ -200,7 +200,7 @@ void AutoclickMenuBubbleController::SetScrollPosition(
} }
void AutoclickMenuBubbleController::ShowBubble(AutoclickEventType type, void AutoclickMenuBubbleController::ShowBubble(AutoclickEventType type,
AutoclickMenuPosition position) { FloatingMenuPosition position) {
// Ignore if bubble widget already exists. // Ignore if bubble widget already exists.
if (bubble_widget_) if (bubble_widget_)
return; return;
...@@ -319,7 +319,7 @@ void AutoclickMenuBubbleController::BubbleViewDestroyed() { ...@@ -319,7 +319,7 @@ void AutoclickMenuBubbleController::BubbleViewDestroyed() {
void AutoclickMenuBubbleController::OnLocaleChanged() { void AutoclickMenuBubbleController::OnLocaleChanged() {
// Layout update is needed when language changes between LTR and RTL, if the // Layout update is needed when language changes between LTR and RTL, if the
// position is the system default. // position is the system default.
if (position_ == AutoclickMenuPosition::kSystemDefault) if (position_ == FloatingMenuPosition::kSystemDefault)
SetPosition(position_); SetPosition(position_);
} }
......
...@@ -32,15 +32,14 @@ class ASH_EXPORT AutoclickMenuBubbleController ...@@ -32,15 +32,14 @@ class ASH_EXPORT AutoclickMenuBubbleController
void SetEventType(AutoclickEventType type); void SetEventType(AutoclickEventType type);
// Sets the menu's position on the screen. // Sets the menu's position on the screen.
void SetPosition(AutoclickMenuPosition position); void SetPosition(FloatingMenuPosition position);
// Set the scroll menu's position on the screen. The rect is the bounds of // Set the scroll menu's position on the screen. The rect is the bounds of
// the scrollable area, and the point is the user-selected scroll point. // the scrollable area, and the point is the user-selected scroll point.
void SetScrollPosition(gfx::Rect scroll_bounds_in_dips, void SetScrollPosition(gfx::Rect scroll_bounds_in_dips,
const gfx::Point& scroll_point_in_dips); const gfx::Point& scroll_point_in_dips);
void ShowBubble(AutoclickEventType event_type, void ShowBubble(AutoclickEventType event_type, FloatingMenuPosition position);
AutoclickMenuPosition position);
void CloseBubble(); void CloseBubble();
...@@ -73,7 +72,7 @@ class ASH_EXPORT AutoclickMenuBubbleController ...@@ -73,7 +72,7 @@ class ASH_EXPORT AutoclickMenuBubbleController
// Owned by views hierarchy. // Owned by views hierarchy.
TrayBubbleView* bubble_view_ = nullptr; TrayBubbleView* bubble_view_ = nullptr;
AutoclickMenuView* menu_view_ = nullptr; AutoclickMenuView* menu_view_ = nullptr;
AutoclickMenuPosition position_ = kDefaultAutoclickMenuPosition; FloatingMenuPosition position_ = kDefaultAutoclickMenuPosition;
views::Widget* bubble_widget_ = nullptr; views::Widget* bubble_widget_ = nullptr;
......
...@@ -180,7 +180,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) { ...@@ -180,7 +180,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) {
Shell::Get()->accessibility_controller(); Shell::Get()->accessibility_controller();
// Set to a known position for than the first event in kTestCases. // Set to a known position for than the first event in kTestCases.
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopRight); controller->SetAutoclickMenuPosition(FloatingMenuPosition::kTopRight);
// Get the full root window bounds to test the position. // Get the full root window bounds to test the position.
gfx::Rect window_bounds = Shell::GetPrimaryRootWindow()->bounds(); gfx::Rect window_bounds = Shell::GetPrimaryRootWindow()->bounds();
...@@ -188,14 +188,14 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) { ...@@ -188,14 +188,14 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) {
// Test cases rotate clockwise. // Test cases rotate clockwise.
const struct { const struct {
gfx::Point expected_location; gfx::Point expected_location;
AutoclickMenuPosition expected_position; FloatingMenuPosition expected_position;
} kTestCases[] = { } kTestCases[] = {
{gfx::Point(window_bounds.width(), window_bounds.height()), {gfx::Point(window_bounds.width(), window_bounds.height()),
AutoclickMenuPosition::kBottomRight}, FloatingMenuPosition::kBottomRight},
{gfx::Point(0, window_bounds.height()), {gfx::Point(0, window_bounds.height()),
AutoclickMenuPosition::kBottomLeft}, FloatingMenuPosition::kBottomLeft},
{gfx::Point(0, 0), AutoclickMenuPosition::kTopLeft}, {gfx::Point(0, 0), FloatingMenuPosition::kTopLeft},
{gfx::Point(window_bounds.width(), 0), AutoclickMenuPosition::kTopRight}, {gfx::Point(window_bounds.width(), 0), FloatingMenuPosition::kTopRight},
}; };
// Find the autoclick menu position button. // Find the autoclick menu position button.
...@@ -277,7 +277,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { ...@@ -277,7 +277,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) {
// When the menu is in the top right, the scroll view should be directly // When the menu is in the top right, the scroll view should be directly
// under it and along the right side of the screen. // under it and along the right side of the screen.
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopRight); controller->SetAutoclickMenuPosition(FloatingMenuPosition::kTopRight);
EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint( EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint(
GetMenuViewBounds().bottom_center()), GetMenuViewBounds().bottom_center()),
kMenuViewBoundsBuffer); kMenuViewBoundsBuffer);
...@@ -285,7 +285,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { ...@@ -285,7 +285,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) {
// When the menu is in the bottom right, the scroll view is directly above // When the menu is in the bottom right, the scroll view is directly above
// it and along the right side of the screen. // it and along the right side of the screen.
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomRight); controller->SetAutoclickMenuPosition(FloatingMenuPosition::kBottomRight);
EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint( EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint(
GetMenuViewBounds().top_center()), GetMenuViewBounds().top_center()),
kMenuViewBoundsBuffer); kMenuViewBoundsBuffer);
...@@ -293,7 +293,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { ...@@ -293,7 +293,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) {
// When the menu is on the bottom left, the scroll view is directly above it // When the menu is on the bottom left, the scroll view is directly above it
// and along the left side of the screen. // and along the left side of the screen.
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomLeft); controller->SetAutoclickMenuPosition(FloatingMenuPosition::kBottomLeft);
EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint( EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint(
GetMenuViewBounds().top_center()), GetMenuViewBounds().top_center()),
kMenuViewBoundsBuffer); kMenuViewBoundsBuffer);
...@@ -301,7 +301,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) { ...@@ -301,7 +301,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) {
// When the menu is on the top left, the scroll view is directly below it // When the menu is on the top left, the scroll view is directly below it
// and along the left side of the screen. // and along the left side of the screen.
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopLeft); controller->SetAutoclickMenuPosition(FloatingMenuPosition::kTopLeft);
EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint( EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint(
GetMenuViewBounds().bottom_center()), GetMenuViewBounds().bottom_center()),
kMenuViewBoundsBuffer); kMenuViewBoundsBuffer);
...@@ -333,7 +333,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ...@@ -333,7 +333,7 @@ TEST_F(AutoclickMenuBubbleControllerTest,
UpdateDisplay(test.display_spec); UpdateDisplay(test.display_spec);
base::i18n::SetRTLForTesting(test.is_RTL); base::i18n::SetRTLForTesting(test.is_RTL);
gfx::Rect scroll_bounds = test.scroll_bounds; gfx::Rect scroll_bounds = test.scroll_bounds;
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopRight); controller->SetAutoclickMenuPosition(FloatingMenuPosition::kTopRight);
// Start with a point no where near the autoclick menu. // Start with a point no where near the autoclick menu.
gfx::Point point = gfx::Point(400, 400); gfx::Point point = gfx::Point(400, 400);
...@@ -355,7 +355,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ...@@ -355,7 +355,7 @@ TEST_F(AutoclickMenuBubbleControllerTest,
// Moving the autoclick bubble doesn't impact the scroll bubble once it // Moving the autoclick bubble doesn't impact the scroll bubble once it
// has been manually set. // has been manually set.
gfx::Rect bubble_bounds = GetScrollViewBounds(); gfx::Rect bubble_bounds = GetScrollViewBounds();
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomRight); controller->SetAutoclickMenuPosition(FloatingMenuPosition::kBottomRight);
EXPECT_EQ(bubble_bounds, GetScrollViewBounds()); EXPECT_EQ(bubble_bounds, GetScrollViewBounds());
// If we position it by the edge of the screen, it should stay on-screen, // If we position it by the edge of the screen, it should stay on-screen,
......
...@@ -36,7 +36,7 @@ const int kSeparatorHeight = 16; ...@@ -36,7 +36,7 @@ const int kSeparatorHeight = 16;
} // namespace } // namespace
AutoclickMenuView::AutoclickMenuView(AutoclickEventType type, AutoclickMenuView::AutoclickMenuView(AutoclickEventType type,
AutoclickMenuPosition position) FloatingMenuPosition position)
: left_click_button_( : left_click_button_(
new FloatingMenuButton(this, new FloatingMenuButton(this,
kAutoclickLeftClickIcon, kAutoclickLeftClickIcon,
...@@ -138,21 +138,21 @@ void AutoclickMenuView::UpdateEventType(AutoclickEventType type) { ...@@ -138,21 +138,21 @@ void AutoclickMenuView::UpdateEventType(AutoclickEventType type) {
event_type_ = type; event_type_ = type;
} }
void AutoclickMenuView::UpdatePosition(AutoclickMenuPosition position) { void AutoclickMenuView::UpdatePosition(FloatingMenuPosition position) {
switch (position) { switch (position) {
case AutoclickMenuPosition::kBottomRight: case FloatingMenuPosition::kBottomRight:
position_button_->SetVectorIcon(kAutoclickPositionBottomRightIcon); position_button_->SetVectorIcon(kAutoclickPositionBottomRightIcon);
return; return;
case AutoclickMenuPosition::kBottomLeft: case FloatingMenuPosition::kBottomLeft:
position_button_->SetVectorIcon(kAutoclickPositionBottomLeftIcon); position_button_->SetVectorIcon(kAutoclickPositionBottomLeftIcon);
return; return;
case AutoclickMenuPosition::kTopLeft: case FloatingMenuPosition::kTopLeft:
position_button_->SetVectorIcon(kAutoclickPositionTopLeftIcon); position_button_->SetVectorIcon(kAutoclickPositionTopLeftIcon);
return; return;
case AutoclickMenuPosition::kTopRight: case FloatingMenuPosition::kTopRight:
position_button_->SetVectorIcon(kAutoclickPositionTopRightIcon); position_button_->SetVectorIcon(kAutoclickPositionTopRightIcon);
return; return;
case AutoclickMenuPosition::kSystemDefault: case FloatingMenuPosition::kSystemDefault:
position_button_->SetVectorIcon(base::i18n::IsRTL() position_button_->SetVectorIcon(base::i18n::IsRTL()
? kAutoclickPositionBottomLeftIcon ? kAutoclickPositionBottomLeftIcon
: kAutoclickPositionBottomRightIcon); : kAutoclickPositionBottomRightIcon);
...@@ -163,25 +163,25 @@ void AutoclickMenuView::UpdatePosition(AutoclickMenuPosition position) { ...@@ -163,25 +163,25 @@ void AutoclickMenuView::UpdatePosition(AutoclickMenuPosition position) {
void AutoclickMenuView::ButtonPressed(views::Button* sender, void AutoclickMenuView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
if (sender == position_button_) { if (sender == position_button_) {
AutoclickMenuPosition new_position; FloatingMenuPosition new_position;
// Rotate clockwise throughout the screen positions. // Rotate clockwise throughout the screen positions.
switch ( switch (
Shell::Get()->accessibility_controller()->GetAutoclickMenuPosition()) { Shell::Get()->accessibility_controller()->GetAutoclickMenuPosition()) {
case AutoclickMenuPosition::kBottomRight: case FloatingMenuPosition::kBottomRight:
new_position = AutoclickMenuPosition::kBottomLeft; new_position = FloatingMenuPosition::kBottomLeft;
break; break;
case AutoclickMenuPosition::kBottomLeft: case FloatingMenuPosition::kBottomLeft:
new_position = AutoclickMenuPosition::kTopLeft; new_position = FloatingMenuPosition::kTopLeft;
break; break;
case AutoclickMenuPosition::kTopLeft: case FloatingMenuPosition::kTopLeft:
new_position = AutoclickMenuPosition::kTopRight; new_position = FloatingMenuPosition::kTopRight;
break; break;
case AutoclickMenuPosition::kTopRight: case FloatingMenuPosition::kTopRight:
new_position = AutoclickMenuPosition::kBottomRight; new_position = FloatingMenuPosition::kBottomRight;
break; break;
case AutoclickMenuPosition::kSystemDefault: case FloatingMenuPosition::kSystemDefault:
new_position = base::i18n::IsRTL() ? AutoclickMenuPosition::kTopLeft new_position = base::i18n::IsRTL() ? FloatingMenuPosition::kTopLeft
: AutoclickMenuPosition::kBottomLeft; : FloatingMenuPosition::kBottomLeft;
break; break;
} }
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition( Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
......
...@@ -28,11 +28,11 @@ class AutoclickMenuView : public views::View, public views::ButtonListener { ...@@ -28,11 +28,11 @@ class AutoclickMenuView : public views::View, public views::ButtonListener {
kPause = 7, kPause = 7,
}; };
AutoclickMenuView(AutoclickEventType type, AutoclickMenuPosition position); AutoclickMenuView(AutoclickEventType type, FloatingMenuPosition position);
~AutoclickMenuView() override = default; ~AutoclickMenuView() override = default;
void UpdateEventType(AutoclickEventType type); void UpdateEventType(AutoclickEventType type);
void UpdatePosition(AutoclickMenuPosition position); void UpdatePosition(FloatingMenuPosition position);
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......
...@@ -30,7 +30,7 @@ the label “autoclick” (or, use ...@@ -30,7 +30,7 @@ the label “autoclick” (or, use
[this template](https://bugs.chromium.org/p/chromium/issues/entry?summary=Autoclick%20-%20&status=Available&cc=katie%40chromium.org%2C%20qqwangxin%40google.com&labels=Pri-3%2C%20autoclick%2C&components=UI>Accessibility)). [this template](https://bugs.chromium.org/p/chromium/issues/entry?summary=Autoclick%20-%20&status=Available&cc=katie%40chromium.org%2C%20qqwangxin%40google.com&labels=Pri-3%2C%20autoclick%2C&components=UI>Accessibility)).
Open bugs have the label Open bugs have the label
[autoclick](https://bugs.chromium.org/p/chromium/issues/list?can=2&q=label%3Aautoclick)”. [autoclick](https://bugs.chromium.org/p/chromium/issues/list?can=2&q=label%3Aautoclick)”.
## Developing ## Developing
...@@ -138,7 +138,7 @@ to accessibility tree information, and using a HitTest is able to find the view ...@@ -138,7 +138,7 @@ to accessibility tree information, and using a HitTest is able to find the view
at the scroll location, then walks up the tree to find the first view which can at the scroll location, then walks up the tree to find the first view which can
scroll, or stops at the nearest window or dialog bounds. This logic takes place scroll, or stops at the nearest window or dialog bounds. This logic takes place
in autoclick.js, onAutomationHitTestResult_. When the scrolling location is in autoclick.js, onAutomationHitTestResult_. When the scrolling location is
found, the bounds of the scrollable area are highlighted with a focus ring. found, the bounds of the scrollable area are highlighted with a focus ring.
In addition, the bounds are sent back through the AccessibilityPrivate API, In addition, the bounds are sent back through the AccessibilityPrivate API,
routed to the AutoclickController, which passes it via the routed to the AutoclickController, which passes it via the
AutoclickMenuBubbleController to the AutoclickScrollBubbleController, which AutoclickMenuBubbleController to the AutoclickScrollBubbleController, which
...@@ -165,9 +165,9 @@ draw the custom shape buttons for left/right/up/down scrolling. ...@@ -165,9 +165,9 @@ draw the custom shape buttons for left/right/up/down scrolling.
The autoclick bubble menu can be positioned in the four corners of the screen The autoclick bubble menu can be positioned in the four corners of the screen
and defaults to the same location as the volume widget (which depends on and defaults to the same location as the volume widget (which depends on
LTR/RTL language). AutoclickMenuBubbleController takes a preferred LTR/RTL language). AutoclickMenuBubbleController takes a preferred
AutoclickMenuPosition enum and uses that to determine the best position for FloatingMenuPosition enum and uses that to determine the best position for
the menu in AutoclickMenuBubbleController::SetPosition. This function finds the menu in AutoclickMenuBubbleController::SetPosition. This function finds
the ideal corner of the screen, then uses CollisionDetectionUtils (also used the ideal corner of the screen, then uses CollisionDetectionUtils (also used
by Picture-in-Picture) to refine the position to avoid collisions with system by Picture-in-Picture) to refine the position to avoid collisions with system
UI. UI.
...@@ -178,7 +178,7 @@ if the user selects a new scroll point it will move. When a scroll point is ...@@ -178,7 +178,7 @@ if the user selects a new scroll point it will move. When a scroll point is
selected, if the scrollable region found by the Autoclick component extension selected, if the scrollable region found by the Autoclick component extension
is large enough, the scroll bubble will be anchored near the scroll point is large enough, the scroll bubble will be anchored near the scroll point
itself, similarly to the way the context menu is anchored near the cursor on itself, similarly to the way the context menu is anchored near the cursor on
a right click. When the scrollable region is small, the scroll bubble will be a right click. When the scrollable region is small, the scroll bubble will be
anchored to the closest side of the scrollable region to the scroll point, as anchored to the closest side of the scrollable region to the scroll point, as
long as there is space for it on that side. long as there is space for it on that side.
...@@ -188,10 +188,10 @@ The AutomaticController cannot generate synthetic click events over the ...@@ -188,10 +188,10 @@ The AutomaticController cannot generate synthetic click events over the
bubbles, because that would cause context and focus changes. For example, if bubbles, because that would cause context and focus changes. For example, if
the user has a drop-down menu open, clicking the autoclick menu bubble will the user has a drop-down menu open, clicking the autoclick menu bubble will
cause the drop-down to close. Instead, the AutoclickController must check to cause the drop-down to close. Instead, the AutoclickController must check to
see if an event will take place over a bubble menu, and if so, request that see if an event will take place over a bubble menu, and if so, request that
AutoclickMenuBubbleController forward the event to the bubble via AutoclickMenuBubbleController forward the event to the bubble via
AutoclickMenuBubbleController::ClickOnBubble. This generates a synthetic mouse AutoclickMenuBubbleController::ClickOnBubble. This generates a synthetic mouse
event which does not propagate through the system, so there is no focus or event which does not propagate through the system, so there is no focus or
context change, allowing users to continue to interact with whatever was on context change, allowing users to continue to interact with whatever was on
screen. screen.
......
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