Commit 4a8b28bf authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Fixed Task Manager accessibility with NVDA

TableView would fire a focus event every time the active row or column changed,
e.g. every time an NVDA user would use the arrow keys to navigate around the view.

However, Task Manager updates its displayed information very frequently and so
by the time NVDA would process the focus changed event, the AXVirtualView object corresponding to the focused item
would no longer be available. Task Manager marks every item as changed every time it refreshes its display,
thereby causing the corresponding AXVirtualView object to be destroyed and re-created.

To work around this issue, we delay firing the focus changed event after OnPaint.

R=dmazzoni@chromium.org, sky@chromium.org

Bug: 811277
Change-Id: I941cda49fefdc5becdbd7baf8f2cca26104d1aa9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930061Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719175}
parent 4df4ec48
...@@ -828,13 +828,13 @@ void TableView::OnPaint(gfx::Canvas* canvas) { ...@@ -828,13 +828,13 @@ void TableView::OnPaint(gfx::Canvas* canvas) {
void TableView::OnFocus() { void TableView::OnFocus() {
SchedulePaintForSelection(); SchedulePaintForSelection();
focus_ring_->SchedulePaint(); focus_ring_->SchedulePaint();
UpdateAccessibilityFocus(); needs_update_accessibility_focus_ = true;
} }
void TableView::OnBlur() { void TableView::OnBlur() {
SchedulePaintForSelection(); SchedulePaintForSelection();
focus_ring_->SchedulePaint(); focus_ring_->SchedulePaint();
UpdateAccessibilityFocus(); needs_update_accessibility_focus_ = true;
} }
int TableView::GetCellMargin() const { int TableView::GetCellMargin() const {
...@@ -876,6 +876,7 @@ void TableView::SortItemsAndUpdateMapping(bool schedule_paint) { ...@@ -876,6 +876,7 @@ void TableView::SortItemsAndUpdateMapping(bool schedule_paint) {
model_to_view_[view_to_model_[i]] = i; model_to_view_[view_to_model_[i]] = i;
model_->ClearCollator(); model_->ClearCollator();
} }
UpdateVirtualAccessibilityChildren(); UpdateVirtualAccessibilityChildren();
if (schedule_paint) if (schedule_paint)
SchedulePaint(); SchedulePaint();
...@@ -1060,7 +1061,7 @@ void TableView::SetActiveVisibleColumnIndex(int index) { ...@@ -1060,7 +1061,7 @@ void TableView::SetActiveVisibleColumnIndex(int index) {
} }
focus_ring_->SchedulePaint(); focus_ring_->SchedulePaint();
UpdateAccessibilityFocus(); needs_update_accessibility_focus_ = true;
OnPropertyChanged(&active_visible_column_index_, kPropertyEffectsNone); OnPropertyChanged(&active_visible_column_index_, kPropertyEffectsNone);
} }
...@@ -1101,7 +1102,7 @@ void TableView::SetSelectionModel(ui::ListSelectionModel new_selection) { ...@@ -1101,7 +1102,7 @@ void TableView::SetSelectionModel(ui::ListSelectionModel new_selection) {
} }
focus_ring_->SchedulePaint(); focus_ring_->SchedulePaint();
UpdateAccessibilityFocus(); needs_update_accessibility_focus_ = true;
NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true);
if (observer_) if (observer_)
observer_->OnSelectionChanged(); observer_->OnSelectionChanged();
...@@ -1188,6 +1189,9 @@ void TableView::UpdateVirtualAccessibilityChildren() { ...@@ -1188,6 +1189,9 @@ void TableView::UpdateVirtualAccessibilityChildren() {
GetViewAccessibility().RemoveAllVirtualChildViews(); GetViewAccessibility().RemoveAllVirtualChildViews();
if (!GetRowCount() || visible_columns_.empty()) { if (!GetRowCount() || visible_columns_.empty()) {
NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, true); NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, true);
if (needs_update_accessibility_focus_)
UpdateAccessibilityFocus();
return; return;
} }
...@@ -1345,9 +1349,13 @@ void TableView::UpdateVirtualAccessibilityChildren() { ...@@ -1345,9 +1349,13 @@ void TableView::UpdateVirtualAccessibilityChildren() {
} }
NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, true); NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, true);
if (needs_update_accessibility_focus_)
UpdateAccessibilityFocus();
} }
void TableView::UpdateAccessibilityFocus() { void TableView::UpdateAccessibilityFocus() {
needs_update_accessibility_focus_ = false;
if (!HasFocus()) if (!HasFocus())
return; return;
......
...@@ -421,6 +421,14 @@ class VIEWS_EXPORT TableView ...@@ -421,6 +421,14 @@ class VIEWS_EXPORT TableView
// True if in SetVisibleColumnWidth(). // True if in SetVisibleColumnWidth().
bool in_set_visible_column_width_ = false; bool in_set_visible_column_width_ = false;
// Keeps track whether a focus change has occurred so that the accessibility
// focus would be updated after all the virtual accessibility children. Some
// screen readers don't process the accessibility focus event right away and
// by the time they do the focused virtual accessibility child is no longer
// there. We need to fire the accessibility focus event after the virtual
// accessibility children have been updated.
bool needs_update_accessibility_focus_ = false;
DISALLOW_COPY_AND_ASSIGN(TableView); DISALLOW_COPY_AND_ASSIGN(TableView);
}; };
......
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