[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: Xiyuan Xia <xiyuan@chromium.org> Reviewed-by: Katie Dektar <katie@chromium.org> Cr-Commit-Position: refs/heads/master@{#757811}
This commit is contained in:

committed by
Commit Bot

parent
6c1f253e0e
commit
ae8526c690
ash
accessibility
autoclick
public
system
docs/accessibility
@ -1516,7 +1516,7 @@ void AccessibilityControllerImpl::UpdateAutoclickMenuPositionFromPref() {
|
||||
}
|
||||
|
||||
void AccessibilityControllerImpl::SetAutoclickMenuPosition(
|
||||
AutoclickMenuPosition position) {
|
||||
FloatingMenuPosition position) {
|
||||
if (!active_user_prefs_)
|
||||
return;
|
||||
active_user_prefs_->SetInteger(prefs::kAccessibilityAutoclickMenuPosition,
|
||||
@ -1525,9 +1525,9 @@ void AccessibilityControllerImpl::SetAutoclickMenuPosition(
|
||||
Shell::Get()->autoclick_controller()->SetMenuPosition(position);
|
||||
}
|
||||
|
||||
AutoclickMenuPosition AccessibilityControllerImpl::GetAutoclickMenuPosition() {
|
||||
FloatingMenuPosition AccessibilityControllerImpl::GetAutoclickMenuPosition() {
|
||||
DCHECK(active_user_prefs_);
|
||||
return static_cast<AutoclickMenuPosition>(active_user_prefs_->GetInteger(
|
||||
return static_cast<FloatingMenuPosition>(active_user_prefs_->GetInteger(
|
||||
prefs::kAccessibilityAutoclickMenuPosition));
|
||||
}
|
||||
|
||||
|
@ -201,8 +201,8 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
|
||||
|
||||
void SetAutoclickEventType(AutoclickEventType event_type);
|
||||
AutoclickEventType GetAutoclickEventType();
|
||||
void SetAutoclickMenuPosition(AutoclickMenuPosition position);
|
||||
AutoclickMenuPosition GetAutoclickMenuPosition();
|
||||
void SetAutoclickMenuPosition(FloatingMenuPosition position);
|
||||
FloatingMenuPosition GetAutoclickMenuPosition();
|
||||
void RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen);
|
||||
|
||||
// Update the autoclick menu bounds if necessary. This may need to happen when
|
||||
|
@ -207,7 +207,7 @@ void AutoclickController::SetMovementThreshold(int movement_threshold) {
|
||||
UpdateRingSize();
|
||||
}
|
||||
|
||||
void AutoclickController::SetMenuPosition(AutoclickMenuPosition menu_position) {
|
||||
void AutoclickController::SetMenuPosition(FloatingMenuPosition menu_position) {
|
||||
menu_position_ = menu_position;
|
||||
UpdateAutoclickMenuBoundsIfNeeded();
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class ASH_EXPORT AutoclickController
|
||||
void SetMovementThreshold(int movement_threshold);
|
||||
|
||||
// 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.
|
||||
void DoScrollAction(ScrollPadAction action);
|
||||
@ -166,7 +166,7 @@ class ASH_EXPORT AutoclickController
|
||||
// manually, the position will be fixed regardless of language direction and
|
||||
// shelf position. This probably means adding a new AutoclickMenuPostion
|
||||
// enum for "system default".
|
||||
AutoclickMenuPosition menu_position_ = kDefaultAutoclickMenuPosition;
|
||||
FloatingMenuPosition menu_position_ = kDefaultAutoclickMenuPosition;
|
||||
int mouse_event_flags_ = ui::EF_NONE;
|
||||
// The target window is observed by AutoclickController for the duration
|
||||
// of a autoclick gesture.
|
||||
|
@ -829,12 +829,12 @@ TEST_F(AutoclickTest, DoesActionOnBubbleWhenInDifferentModes) {
|
||||
const struct {
|
||||
const std::string display_spec;
|
||||
float scale;
|
||||
AutoclickMenuPosition position;
|
||||
FloatingMenuPosition position;
|
||||
} kTestCases[] = {
|
||||
{"800x600", 1.0f, AutoclickMenuPosition::kBottomRight},
|
||||
{"1024x800*2.0", 2.0f, AutoclickMenuPosition::kBottomRight},
|
||||
{"800x600", 1.0f, AutoclickMenuPosition::kTopLeft},
|
||||
{"1024x800*2.0", 2.0f, AutoclickMenuPosition::kTopLeft},
|
||||
{"800x600", 1.0f, FloatingMenuPosition::kBottomRight},
|
||||
{"1024x800*2.0", 2.0f, FloatingMenuPosition::kBottomRight},
|
||||
{"800x600", 1.0f, FloatingMenuPosition::kTopLeft},
|
||||
{"1024x800*2.0", 2.0f, FloatingMenuPosition::kTopLeft},
|
||||
};
|
||||
for (const auto& test : kTestCases) {
|
||||
UpdateDisplay(test.display_spec);
|
||||
@ -916,7 +916,7 @@ TEST_F(AutoclickTest,
|
||||
GetAutoclickController()->SetAutoclickEventType(
|
||||
AutoclickEventType::kNoAction);
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
|
||||
AutoclickMenuPosition::kBottomRight);
|
||||
FloatingMenuPosition::kBottomRight);
|
||||
|
||||
int animation_delay = 5;
|
||||
int full_delay = UpdateAnimationDelayAndGetFullDelay(animation_delay);
|
||||
@ -987,7 +987,7 @@ TEST_F(AutoclickTest, BubbleMovesWithShelfPositionChange) {
|
||||
// Set up autoclick and the shelf.
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true);
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
|
||||
AutoclickMenuPosition::kBottomRight);
|
||||
FloatingMenuPosition::kBottomRight);
|
||||
Shelf* shelf = GetPrimaryShelf();
|
||||
shelf->SetAutoHideBehavior(ShelfAutoHideBehavior::kNever);
|
||||
EXPECT_EQ(shelf->GetVisibilityState(), SHELF_VISIBLE);
|
||||
@ -1039,7 +1039,7 @@ TEST_F(AutoclickTest, AvoidsShelfBubble) {
|
||||
// Set up autoclick and the shelf.
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickEnabled(true);
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
|
||||
AutoclickMenuPosition::kBottomRight);
|
||||
FloatingMenuPosition::kBottomRight);
|
||||
auto* unified_system_tray = GetPrimaryUnifiedSystemTray();
|
||||
EXPECT_FALSE(unified_system_tray->IsBubbleShown());
|
||||
AutoclickMenuView* menu = GetAutoclickMenuView();
|
||||
@ -1304,7 +1304,7 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) {
|
||||
GetAutoclickController()->SetEnabled(true, false /* do not show dialog */);
|
||||
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
|
||||
AutoclickMenuPosition::kBottomRight);
|
||||
FloatingMenuPosition::kBottomRight);
|
||||
GetAutoclickController()->SetAutoclickEventType(AutoclickEventType::kScroll);
|
||||
|
||||
ASSERT_TRUE(GetAutoclickScrollView());
|
||||
@ -1321,21 +1321,21 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) {
|
||||
|
||||
// Moving the autoclick menu around the screen moves the scroll bubble too.
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
|
||||
AutoclickMenuPosition::kBottomLeft);
|
||||
FloatingMenuPosition::kBottomLeft);
|
||||
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
|
||||
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
|
||||
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
|
||||
kScrollToMenuBoundsBuffer);
|
||||
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
|
||||
AutoclickMenuPosition::kTopLeft);
|
||||
FloatingMenuPosition::kTopLeft);
|
||||
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
|
||||
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
|
||||
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
|
||||
kScrollToMenuBoundsBuffer);
|
||||
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
|
||||
AutoclickMenuPosition::kTopRight);
|
||||
FloatingMenuPosition::kTopRight);
|
||||
scroll_bounds = GetAutoclickScrollView()->GetBoundsInScreen();
|
||||
menu_bounds = GetAutoclickMenuView()->GetBoundsInScreen();
|
||||
EXPECT_LT(menu_bounds.ManhattanInternalDistance(scroll_bounds),
|
||||
@ -1355,7 +1355,7 @@ TEST_F(AutoclickTest, ScrollMenuBubblePostioning) {
|
||||
// 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);
|
||||
FloatingMenuPosition::kBottomRight);
|
||||
EXPECT_EQ(GetAutoclickScrollView()->GetBoundsInScreen(), scroll_bounds);
|
||||
}
|
||||
|
||||
|
@ -122,10 +122,10 @@ enum class AutoclickEventType {
|
||||
kMaxValue = kScroll
|
||||
};
|
||||
|
||||
// The Automatic Clicks feature's on-screen menu display location. These values
|
||||
// are written to prefs so they should not be changed. New values should be
|
||||
// added at the end.
|
||||
enum class AutoclickMenuPosition {
|
||||
// Display location of the on-screen floating menus used by accessibility features(e.g. the
|
||||
// Automatic Clicks) . These values are written to prefs so they should not be changed. New values
|
||||
// should be added at the end.
|
||||
enum class FloatingMenuPosition {
|
||||
// The bottom right of the screen.
|
||||
kBottomRight,
|
||||
|
||||
|
@ -57,8 +57,8 @@ constexpr AutoclickEventType kDefaultAutoclickEventType =
|
||||
constexpr int kDefaultAutoclickMovementThreshold = 20;
|
||||
|
||||
// The default automatic click menu position.
|
||||
constexpr AutoclickMenuPosition kDefaultAutoclickMenuPosition =
|
||||
AutoclickMenuPosition::kSystemDefault;
|
||||
constexpr FloatingMenuPosition kDefaultAutoclickMenuPosition =
|
||||
FloatingMenuPosition::kSystemDefault;
|
||||
|
||||
// The default frame color.
|
||||
constexpr SkColor kDefaultFrameColor = SkColorSetRGB(0xFD, 0xFE, 0xFF);
|
||||
|
@ -29,34 +29,34 @@ namespace {
|
||||
const int kAutoclickMenuWidth = 369;
|
||||
const int kAutoclickMenuHeight = 64;
|
||||
|
||||
AutoclickMenuPosition DefaultSystemPosition() {
|
||||
return base::i18n::IsRTL() ? AutoclickMenuPosition::kBottomLeft
|
||||
: AutoclickMenuPosition::kBottomRight;
|
||||
FloatingMenuPosition DefaultSystemPosition() {
|
||||
return base::i18n::IsRTL() ? FloatingMenuPosition::kBottomLeft
|
||||
: FloatingMenuPosition::kBottomRight;
|
||||
}
|
||||
|
||||
views::BubbleBorder::Arrow GetScrollAnchorAlignmentForPosition(
|
||||
AutoclickMenuPosition position) {
|
||||
FloatingMenuPosition position) {
|
||||
// If this is the default system position, pick the position based on the
|
||||
// language direction.
|
||||
if (position == AutoclickMenuPosition::kSystemDefault) {
|
||||
if (position == FloatingMenuPosition::kSystemDefault) {
|
||||
position = DefaultSystemPosition();
|
||||
}
|
||||
// Mirror arrow in RTL languages so that it always stays near the screen
|
||||
// edge.
|
||||
switch (position) {
|
||||
case AutoclickMenuPosition::kBottomLeft:
|
||||
case FloatingMenuPosition::kBottomLeft:
|
||||
return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::TOP_RIGHT
|
||||
: views::BubbleBorder::Arrow::TOP_LEFT;
|
||||
case AutoclickMenuPosition::kTopLeft:
|
||||
case FloatingMenuPosition::kTopLeft:
|
||||
return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::BOTTOM_RIGHT
|
||||
: views::BubbleBorder::Arrow::BOTTOM_LEFT;
|
||||
case AutoclickMenuPosition::kBottomRight:
|
||||
case FloatingMenuPosition::kBottomRight:
|
||||
return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::TOP_LEFT
|
||||
: views::BubbleBorder::Arrow::TOP_RIGHT;
|
||||
case AutoclickMenuPosition::kTopRight:
|
||||
case FloatingMenuPosition::kTopRight:
|
||||
return base::i18n::IsRTL() ? views::BubbleBorder::Arrow::BOTTOM_LEFT
|
||||
: views::BubbleBorder::Arrow::BOTTOM_RIGHT;
|
||||
case AutoclickMenuPosition::kSystemDefault:
|
||||
case FloatingMenuPosition::kSystemDefault:
|
||||
// It's not possible for position to be kSystemDefault here because we've
|
||||
// set it via DefaultSystemPosition() above if it was kSystemDefault.
|
||||
NOTREACHED();
|
||||
@ -102,21 +102,21 @@ void AutoclickMenuBubbleController::SetEventType(AutoclickEventType type) {
|
||||
}
|
||||
|
||||
void AutoclickMenuBubbleController::SetPosition(
|
||||
AutoclickMenuPosition new_position) {
|
||||
FloatingMenuPosition new_position) {
|
||||
if (!menu_view_ || !bubble_view_ || !bubble_widget_)
|
||||
return;
|
||||
|
||||
// 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).
|
||||
if (position_ != new_position ||
|
||||
new_position == AutoclickMenuPosition::kSystemDefault) {
|
||||
new_position == FloatingMenuPosition::kSystemDefault) {
|
||||
menu_view_->UpdatePosition(new_position);
|
||||
}
|
||||
position_ = new_position;
|
||||
|
||||
// If this is the default system position, pick the position based on the
|
||||
// language direction.
|
||||
if (new_position == AutoclickMenuPosition::kSystemDefault)
|
||||
if (new_position == FloatingMenuPosition::kSystemDefault)
|
||||
new_position = DefaultSystemPosition();
|
||||
|
||||
// Calculates the ideal bounds.
|
||||
@ -127,17 +127,17 @@ void AutoclickMenuBubbleController::SetPosition(
|
||||
WorkAreaInsets::ForWindow(window)->user_work_area_bounds();
|
||||
gfx::Rect new_bounds;
|
||||
switch (new_position) {
|
||||
case AutoclickMenuPosition::kBottomRight:
|
||||
case FloatingMenuPosition::kBottomRight:
|
||||
new_bounds = gfx::Rect(work_area.right() - kAutoclickMenuWidth,
|
||||
work_area.bottom() - kAutoclickMenuHeight,
|
||||
kAutoclickMenuWidth, kAutoclickMenuHeight);
|
||||
break;
|
||||
case AutoclickMenuPosition::kBottomLeft:
|
||||
case FloatingMenuPosition::kBottomLeft:
|
||||
new_bounds =
|
||||
gfx::Rect(work_area.x(), work_area.bottom() - kAutoclickMenuHeight,
|
||||
kAutoclickMenuWidth, kAutoclickMenuHeight);
|
||||
break;
|
||||
case AutoclickMenuPosition::kTopLeft:
|
||||
case FloatingMenuPosition::kTopLeft:
|
||||
// Because there is no inset at the top of the widget, add
|
||||
// 2 * kCollisionWindowWorkAreaInsetsDp to the top of the work area.
|
||||
// to ensure correct padding.
|
||||
@ -145,7 +145,7 @@ void AutoclickMenuBubbleController::SetPosition(
|
||||
work_area.x(), work_area.y() + 2 * kCollisionWindowWorkAreaInsetsDp,
|
||||
kAutoclickMenuWidth, kAutoclickMenuHeight);
|
||||
break;
|
||||
case AutoclickMenuPosition::kTopRight:
|
||||
case FloatingMenuPosition::kTopRight:
|
||||
// Because there is no inset at the top of the widget, add
|
||||
// 2 * kCollisionWindowWorkAreaInsetsDp to the top of the work area.
|
||||
// to ensure correct padding.
|
||||
@ -154,7 +154,7 @@ void AutoclickMenuBubbleController::SetPosition(
|
||||
work_area.y() + 2 * kCollisionWindowWorkAreaInsetsDp,
|
||||
kAutoclickMenuWidth, kAutoclickMenuHeight);
|
||||
break;
|
||||
case AutoclickMenuPosition::kSystemDefault:
|
||||
case FloatingMenuPosition::kSystemDefault:
|
||||
return;
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ void AutoclickMenuBubbleController::SetScrollPosition(
|
||||
}
|
||||
|
||||
void AutoclickMenuBubbleController::ShowBubble(AutoclickEventType type,
|
||||
AutoclickMenuPosition position) {
|
||||
FloatingMenuPosition position) {
|
||||
// Ignore if bubble widget already exists.
|
||||
if (bubble_widget_)
|
||||
return;
|
||||
@ -319,7 +319,7 @@ void AutoclickMenuBubbleController::BubbleViewDestroyed() {
|
||||
void AutoclickMenuBubbleController::OnLocaleChanged() {
|
||||
// Layout update is needed when language changes between LTR and RTL, if the
|
||||
// position is the system default.
|
||||
if (position_ == AutoclickMenuPosition::kSystemDefault)
|
||||
if (position_ == FloatingMenuPosition::kSystemDefault)
|
||||
SetPosition(position_);
|
||||
}
|
||||
|
||||
|
@ -32,15 +32,14 @@ class ASH_EXPORT AutoclickMenuBubbleController
|
||||
void SetEventType(AutoclickEventType type);
|
||||
|
||||
// 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
|
||||
// the scrollable area, and the point is the user-selected scroll point.
|
||||
void SetScrollPosition(gfx::Rect scroll_bounds_in_dips,
|
||||
const gfx::Point& scroll_point_in_dips);
|
||||
|
||||
void ShowBubble(AutoclickEventType event_type,
|
||||
AutoclickMenuPosition position);
|
||||
void ShowBubble(AutoclickEventType event_type, FloatingMenuPosition position);
|
||||
|
||||
void CloseBubble();
|
||||
|
||||
@ -73,7 +72,7 @@ class ASH_EXPORT AutoclickMenuBubbleController
|
||||
// Owned by views hierarchy.
|
||||
TrayBubbleView* bubble_view_ = nullptr;
|
||||
AutoclickMenuView* menu_view_ = nullptr;
|
||||
AutoclickMenuPosition position_ = kDefaultAutoclickMenuPosition;
|
||||
FloatingMenuPosition position_ = kDefaultAutoclickMenuPosition;
|
||||
|
||||
views::Widget* bubble_widget_ = nullptr;
|
||||
|
||||
|
@ -180,7 +180,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) {
|
||||
Shell::Get()->accessibility_controller();
|
||||
|
||||
// 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.
|
||||
gfx::Rect window_bounds = Shell::GetPrimaryRootWindow()->bounds();
|
||||
@ -188,14 +188,14 @@ TEST_F(AutoclickMenuBubbleControllerTest, CanChangePosition) {
|
||||
// Test cases rotate clockwise.
|
||||
const struct {
|
||||
gfx::Point expected_location;
|
||||
AutoclickMenuPosition expected_position;
|
||||
FloatingMenuPosition expected_position;
|
||||
} kTestCases[] = {
|
||||
{gfx::Point(window_bounds.width(), window_bounds.height()),
|
||||
AutoclickMenuPosition::kBottomRight},
|
||||
FloatingMenuPosition::kBottomRight},
|
||||
{gfx::Point(0, window_bounds.height()),
|
||||
AutoclickMenuPosition::kBottomLeft},
|
||||
{gfx::Point(0, 0), AutoclickMenuPosition::kTopLeft},
|
||||
{gfx::Point(window_bounds.width(), 0), AutoclickMenuPosition::kTopRight},
|
||||
FloatingMenuPosition::kBottomLeft},
|
||||
{gfx::Point(0, 0), FloatingMenuPosition::kTopLeft},
|
||||
{gfx::Point(window_bounds.width(), 0), FloatingMenuPosition::kTopRight},
|
||||
};
|
||||
|
||||
// Find the autoclick menu position button.
|
||||
@ -277,7 +277,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) {
|
||||
|
||||
// When the menu is in the top right, the scroll view should be directly
|
||||
// under it and along the right side of the screen.
|
||||
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopRight);
|
||||
controller->SetAutoclickMenuPosition(FloatingMenuPosition::kTopRight);
|
||||
EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint(
|
||||
GetMenuViewBounds().bottom_center()),
|
||||
kMenuViewBoundsBuffer);
|
||||
@ -285,7 +285,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) {
|
||||
|
||||
// When the menu is in the bottom right, the scroll view is directly above
|
||||
// it and along the right side of the screen.
|
||||
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomRight);
|
||||
controller->SetAutoclickMenuPosition(FloatingMenuPosition::kBottomRight);
|
||||
EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint(
|
||||
GetMenuViewBounds().top_center()),
|
||||
kMenuViewBoundsBuffer);
|
||||
@ -293,7 +293,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) {
|
||||
|
||||
// When the menu is on the bottom left, the scroll view is directly above it
|
||||
// and along the left side of the screen.
|
||||
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomLeft);
|
||||
controller->SetAutoclickMenuPosition(FloatingMenuPosition::kBottomLeft);
|
||||
EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint(
|
||||
GetMenuViewBounds().top_center()),
|
||||
kMenuViewBoundsBuffer);
|
||||
@ -301,7 +301,7 @@ TEST_F(AutoclickMenuBubbleControllerTest, ScrollBubbleDefaultPositioning) {
|
||||
|
||||
// When the menu is on the top left, the scroll view is directly below it
|
||||
// and along the left side of the screen.
|
||||
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kTopLeft);
|
||||
controller->SetAutoclickMenuPosition(FloatingMenuPosition::kTopLeft);
|
||||
EXPECT_LT(GetScrollViewBounds().ManhattanDistanceToPoint(
|
||||
GetMenuViewBounds().bottom_center()),
|
||||
kMenuViewBoundsBuffer);
|
||||
@ -333,7 +333,7 @@ TEST_F(AutoclickMenuBubbleControllerTest,
|
||||
UpdateDisplay(test.display_spec);
|
||||
base::i18n::SetRTLForTesting(test.is_RTL);
|
||||
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.
|
||||
gfx::Point point = gfx::Point(400, 400);
|
||||
@ -355,7 +355,7 @@ TEST_F(AutoclickMenuBubbleControllerTest,
|
||||
// Moving the autoclick bubble doesn't impact the scroll bubble once it
|
||||
// has been manually set.
|
||||
gfx::Rect bubble_bounds = GetScrollViewBounds();
|
||||
controller->SetAutoclickMenuPosition(AutoclickMenuPosition::kBottomRight);
|
||||
controller->SetAutoclickMenuPosition(FloatingMenuPosition::kBottomRight);
|
||||
EXPECT_EQ(bubble_bounds, GetScrollViewBounds());
|
||||
|
||||
// If we position it by the edge of the screen, it should stay on-screen,
|
||||
|
@ -36,7 +36,7 @@ const int kSeparatorHeight = 16;
|
||||
} // namespace
|
||||
|
||||
AutoclickMenuView::AutoclickMenuView(AutoclickEventType type,
|
||||
AutoclickMenuPosition position)
|
||||
FloatingMenuPosition position)
|
||||
: left_click_button_(
|
||||
new FloatingMenuButton(this,
|
||||
kAutoclickLeftClickIcon,
|
||||
@ -138,21 +138,21 @@ void AutoclickMenuView::UpdateEventType(AutoclickEventType type) {
|
||||
event_type_ = type;
|
||||
}
|
||||
|
||||
void AutoclickMenuView::UpdatePosition(AutoclickMenuPosition position) {
|
||||
void AutoclickMenuView::UpdatePosition(FloatingMenuPosition position) {
|
||||
switch (position) {
|
||||
case AutoclickMenuPosition::kBottomRight:
|
||||
case FloatingMenuPosition::kBottomRight:
|
||||
position_button_->SetVectorIcon(kAutoclickPositionBottomRightIcon);
|
||||
return;
|
||||
case AutoclickMenuPosition::kBottomLeft:
|
||||
case FloatingMenuPosition::kBottomLeft:
|
||||
position_button_->SetVectorIcon(kAutoclickPositionBottomLeftIcon);
|
||||
return;
|
||||
case AutoclickMenuPosition::kTopLeft:
|
||||
case FloatingMenuPosition::kTopLeft:
|
||||
position_button_->SetVectorIcon(kAutoclickPositionTopLeftIcon);
|
||||
return;
|
||||
case AutoclickMenuPosition::kTopRight:
|
||||
case FloatingMenuPosition::kTopRight:
|
||||
position_button_->SetVectorIcon(kAutoclickPositionTopRightIcon);
|
||||
return;
|
||||
case AutoclickMenuPosition::kSystemDefault:
|
||||
case FloatingMenuPosition::kSystemDefault:
|
||||
position_button_->SetVectorIcon(base::i18n::IsRTL()
|
||||
? kAutoclickPositionBottomLeftIcon
|
||||
: kAutoclickPositionBottomRightIcon);
|
||||
@ -163,25 +163,25 @@ void AutoclickMenuView::UpdatePosition(AutoclickMenuPosition position) {
|
||||
void AutoclickMenuView::ButtonPressed(views::Button* sender,
|
||||
const ui::Event& event) {
|
||||
if (sender == position_button_) {
|
||||
AutoclickMenuPosition new_position;
|
||||
FloatingMenuPosition new_position;
|
||||
// Rotate clockwise throughout the screen positions.
|
||||
switch (
|
||||
Shell::Get()->accessibility_controller()->GetAutoclickMenuPosition()) {
|
||||
case AutoclickMenuPosition::kBottomRight:
|
||||
new_position = AutoclickMenuPosition::kBottomLeft;
|
||||
case FloatingMenuPosition::kBottomRight:
|
||||
new_position = FloatingMenuPosition::kBottomLeft;
|
||||
break;
|
||||
case AutoclickMenuPosition::kBottomLeft:
|
||||
new_position = AutoclickMenuPosition::kTopLeft;
|
||||
case FloatingMenuPosition::kBottomLeft:
|
||||
new_position = FloatingMenuPosition::kTopLeft;
|
||||
break;
|
||||
case AutoclickMenuPosition::kTopLeft:
|
||||
new_position = AutoclickMenuPosition::kTopRight;
|
||||
case FloatingMenuPosition::kTopLeft:
|
||||
new_position = FloatingMenuPosition::kTopRight;
|
||||
break;
|
||||
case AutoclickMenuPosition::kTopRight:
|
||||
new_position = AutoclickMenuPosition::kBottomRight;
|
||||
case FloatingMenuPosition::kTopRight:
|
||||
new_position = FloatingMenuPosition::kBottomRight;
|
||||
break;
|
||||
case AutoclickMenuPosition::kSystemDefault:
|
||||
new_position = base::i18n::IsRTL() ? AutoclickMenuPosition::kTopLeft
|
||||
: AutoclickMenuPosition::kBottomLeft;
|
||||
case FloatingMenuPosition::kSystemDefault:
|
||||
new_position = base::i18n::IsRTL() ? FloatingMenuPosition::kTopLeft
|
||||
: FloatingMenuPosition::kBottomLeft;
|
||||
break;
|
||||
}
|
||||
Shell::Get()->accessibility_controller()->SetAutoclickMenuPosition(
|
||||
|
@ -28,11 +28,11 @@ class AutoclickMenuView : public views::View, public views::ButtonListener {
|
||||
kPause = 7,
|
||||
};
|
||||
|
||||
AutoclickMenuView(AutoclickEventType type, AutoclickMenuPosition position);
|
||||
AutoclickMenuView(AutoclickEventType type, FloatingMenuPosition position);
|
||||
~AutoclickMenuView() override = default;
|
||||
|
||||
void UpdateEventType(AutoclickEventType type);
|
||||
void UpdatePosition(AutoclickMenuPosition position);
|
||||
void UpdatePosition(FloatingMenuPosition position);
|
||||
|
||||
// views::ButtonListener:
|
||||
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
||||
|
@ -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)).
|
||||
|
||||
|
||||
Open bugs have the label
|
||||
Open bugs have the label
|
||||
“[autoclick](https://bugs.chromium.org/p/chromium/issues/list?can=2&q=label%3Aautoclick)”.
|
||||
|
||||
## Developing
|
||||
@ -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
|
||||
scroll, or stops at the nearest window or dialog bounds. This logic takes place
|
||||
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,
|
||||
routed to the AutoclickController, which passes it via the
|
||||
AutoclickMenuBubbleController to the AutoclickScrollBubbleController, which
|
||||
@ -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
|
||||
and defaults to the same location as the volume widget (which depends on
|
||||
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 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
|
||||
UI.
|
||||
|
||||
@ -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
|
||||
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
|
||||
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
|
||||
long as there is space for it on that side.
|
||||
|
||||
@ -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
|
||||
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
|
||||
see if an event will take place over a bubble menu, and if so, request that
|
||||
AutoclickMenuBubbleController forward the event to the bubble via
|
||||
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::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
|
||||
screen.
|
||||
|
||||
|
Reference in New Issue
Block a user