Commit 5ca25017 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

[scrollable shelf] Show the hidden icon with the accessibility focus

When the hidden icon of the scrollable shelf receives the a11y focus,
scrollable shelf should show the icon by translating the shelf view.

Bug: 1016028
Change-Id: I90013aa4fc07ed296cffdb6f02809e15f5377fab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891111Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711853}
parent f60a52a4
......@@ -785,12 +785,34 @@ void ScrollableShelfView::ButtonPressed(views::Button* sender,
shelf_view_->ButtonPressed(sender, event, ink_drop);
}
void ScrollableShelfView::HandleAccessibleActionScrollToMakeVisible() {
// Only in tablet mode with hotseat enabled, may scrollable shelf be hidden.
if (!IsInTabletMode() || !chromeos::switches::ShouldShowShelfHotseat())
return;
void ScrollableShelfView::HandleAccessibleActionScrollToMakeVisible(
ShelfButton* button) {
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat()) {
// Only in tablet mode with hotseat enabled, may scrollable shelf be hidden.
GetShelf()->shelf_widget()->ForceToShowHotseat();
}
const int index = shelf_view_->view_model()->GetIndexOfView(button);
DCHECK_NE(-1, index);
GetShelf()->shelf_widget()->ForceToShowHotseat();
const bool is_horizontal_alignment = GetShelf()->IsHorizontalAlignment();
// Translates the shelf view if |button| is hidden under the current layout.
if (index == 0) {
if (is_horizontal_alignment)
ScrollToXOffset(0, /*animating=*/true);
else
ScrollToYOffset(0, /*animating=*/true);
} else if (index == shelf_view_->last_visible_index()) {
if (is_horizontal_alignment)
ScrollToXOffset(CalculateScrollUpperBound(), /*animating=*/true);
else
ScrollToYOffset(CalculateScrollUpperBound(), /*animating=*/true);
} else if (index < first_tappable_app_index_) {
ScrollToNewPage(/*forward=*/false);
} else if (index > last_tappable_app_index_) {
ScrollToNewPage(/*forward=*/true);
}
}
void ScrollableShelfView::ShowContextMenuForViewImpl(
......
......@@ -174,7 +174,7 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
void ButtonPressed(views::Button* sender,
const ui::Event& event,
views::InkDrop* ink_drop) override;
void HandleAccessibleActionScrollToMakeVisible() override;
void HandleAccessibleActionScrollToMakeVisible(ShelfButton* button) override;
// ContextMenuController:
void ShowContextMenuForViewImpl(views::View* source,
......
......@@ -743,7 +743,7 @@ std::unique_ptr<views::InkDropMask> ShelfAppButton::CreateInkDropMask() const {
bool ShelfAppButton::HandleAccessibleAction(
const ui::AXActionData& action_data) {
if (action_data.action == ax::mojom::Action::kScrollToMakeVisible)
shelf_button_delegate()->HandleAccessibleActionScrollToMakeVisible();
shelf_button_delegate()->HandleAccessibleActionScrollToMakeVisible(this);
return views::View::HandleAccessibleAction(action_data);
}
......
......@@ -43,8 +43,9 @@ class ShelfButtonDelegate {
views::InkDrop* ink_drop) = 0;
// Called when the shelf button handles the accessible action with type of
// kScrollToMakeVisible.
virtual void HandleAccessibleActionScrollToMakeVisible() {}
// kScrollToMakeVisible. |button| is the view receiving the accessibility
// focus.
virtual void HandleAccessibleActionScrollToMakeVisible(ShelfButton* button) {}
private:
DISALLOW_COPY_AND_ASSIGN(ShelfButtonDelegate);
......
......@@ -39,6 +39,8 @@ void ShelfContainerView::TranslateShelfView(const gfx::Vector2dF& offset) {
gfx::Transform transform_matrix;
transform_matrix.Translate(-offset);
shelf_view_->SetTransform(transform_matrix);
shelf_view_->NotifyAccessibilityEvent(ax::mojom::Event::kLocationChanged,
true);
}
gfx::Size ShelfContainerView::CalculateIdealSize() const {
......
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