Commit 1b3084cf authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Fix vox for opening and closing folder

Changes:
Avoid announcing search box focus when opening or closing a folder.

Bug: 921189
Change-Id: Id9b3096534b1b1196d41ce290bbc4617d9ddc2a9
Reviewed-on: https://chromium-review.googlesource.com/c/1457413
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630053}
parent e86d698f
......@@ -35,6 +35,7 @@
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
......@@ -471,6 +472,9 @@ AppListFolderView::AppListFolderView(AppsContainerView* container_view,
view_model_->Add(page_switcher_, kIndexPageSwitcher);
model_->AddObserver(this);
announcement_view_ = new views::View();
AddChildView(announcement_view_);
}
AppListFolderView::~AppListFolderView() {
......@@ -486,10 +490,7 @@ AppListFolderView::~AppListFolderView() {
}
void AppListFolderView::SetAppListFolderItem(AppListFolderItem* folder) {
accessible_name_ = ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
IDS_APP_LIST_FOLDER_OPEN_FOLDER_ACCESSIBILE_NAME);
NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
CreateOpenOrCloseFolderAccessibilityEvent(true);
folder_item_ = folder;
items_grid_view_->SetItemList(folder_item_->item_list());
folder_header_view_->SetFolderItem(folder_item_);
......@@ -803,11 +804,8 @@ void AppListFolderView::HideViewImmediately() {
}
void AppListFolderView::CloseFolderPage() {
accessible_name_ = ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME);
NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
GiveBackFocusToSearchBox();
CreateOpenOrCloseFolderAccessibilityEvent(false);
if (items_grid_view()->dragging())
items_grid_view()->EndDrag(true);
items_grid_view()->ClearAnySelectedView();
......@@ -824,7 +822,6 @@ void AppListFolderView::SetRootLevelDragViewVisible(bool visible) {
void AppListFolderView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kGenericContainer;
node_data->SetName(accessible_name_);
}
void AppListFolderView::NavigateBack(AppListFolderItem* item,
......@@ -833,7 +830,11 @@ void AppListFolderView::NavigateBack(AppListFolderItem* item,
}
void AppListFolderView::GiveBackFocusToSearchBox() {
contents_view_->GetSearchBoxView()->search_box()->RequestFocus();
// Avoid announcing search box focus since it is overlapped with closing
// folder alert.
auto* search_box = contents_view_->GetSearchBoxView()->search_box();
search_box->GetViewAccessibility().OverrideIsIgnored(true);
search_box->RequestFocus();
}
void AppListFolderView::SetItemName(AppListFolderItem* item,
......@@ -845,4 +846,12 @@ ui::Compositor* AppListFolderView::GetCompositor() {
return GetWidget()->GetCompositor();
}
void AppListFolderView::CreateOpenOrCloseFolderAccessibilityEvent(bool open) {
announcement_view_->GetViewAccessibility().OverrideName(
ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
open ? IDS_APP_LIST_FOLDER_OPEN_FOLDER_ACCESSIBILE_NAME
: IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME));
announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
}
} // namespace app_list
......@@ -155,6 +155,10 @@ class APP_LIST_EXPORT AppListFolderView : public views::View,
// Returns nullptr if there isn't one associated with this widget.
ui::Compositor* GetCompositor();
// Creates accessibility event for opening folder if |open| is true.
// Otherwise, creates the event for closing folder.
void CreateOpenOrCloseFolderAccessibilityEvent(bool open);
// Views below are not owned by views hierarchy.
AppsContainerView* container_view_;
ContentsView* contents_view_;
......@@ -182,8 +186,6 @@ class APP_LIST_EXPORT AppListFolderView : public views::View,
bool hide_for_reparent_;
base::string16 accessible_name_;
std::unique_ptr<gfx::SlideAnimation> background_animation_;
std::unique_ptr<gfx::SlideAnimation> folder_item_title_animation_;
std::unique_ptr<Animation> top_icon_animation_;
......@@ -195,6 +197,9 @@ class APP_LIST_EXPORT AppListFolderView : public views::View,
// The compositor frame number when animation starts.
int animation_start_frame_number_;
// View used to announce opening and closing a folder.
views::View* announcement_view_ = nullptr; // Owned by AppListFolderView.
DISALLOW_COPY_AND_ASSIGN(AppListFolderView);
};
......
......@@ -104,9 +104,14 @@ void AppsContainerView::ShowActiveFolder(AppListFolderItem* folder_item) {
SetShowState(SHOW_ACTIVE_FOLDER, false);
// Avoid announcing search box focus since it is overlapped with opening
// folder alert.
auto* search_box = contents_view_->GetSearchBoxView()->search_box();
search_box->GetViewAccessibility().OverrideIsIgnored(true);
// Disable all the items behind the folder so that they will not be reached
// during focus traversal.
contents_view_->GetSearchBoxView()->search_box()->RequestFocus();
search_box->RequestFocus();
DisableFocusForShowingActiveFolder(true);
}
......
......@@ -18,6 +18,7 @@
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_impl.h"
......@@ -204,6 +205,15 @@ class SearchBoxTextfield : public views::Textfield {
// Clear selection and set the caret to the end of the text.
ClearSelection();
Textfield::OnBlur();
// Search box focus announcement overlaps with opening or closing folder
// alert, so we ignored the search box in those cases. Now reset the flag
// here.
auto& accessibility = GetViewAccessibility();
if (accessibility.IsIgnored()) {
accessibility.OverrideIsIgnored(false);
accessibility.NotifyAccessibilityEvent(ax::mojom::Event::kTreeChanged);
}
}
void OnGestureEvent(ui::GestureEvent* event) override {
......
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