Commit d7dec2d4 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Fires a focus event when navigation completes or is cancelled

In BrowserAccessibilityManager, we were relying on the presence of other accessibility events, such as kChildrenChanged,
in order to tricker the firing of a focus event.
However, when page navigation is cancelled, or is simply completed after the page contents have been loaded
in the accessibility tree, there are no other events that would tricker the focus event. This creates a situation where
the screen reader does not move its virtual cursor to the web contents. As a result, focus appears to be nowhere, and the user
develops the mistaken belief that the virtual buffer in screen readers such as NVDA is also blank.

R=dmazzoni@chromium.org, kbabbitt@microsoft.com

Bug: 1058959
Change-Id: I29150977d032152d5337889b1ae0c2e196fda065
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095758Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarIan Prest <iapres@microsoft.com>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749022}
parent 3f0a36cd
...@@ -279,6 +279,11 @@ void BrowserAccessibilityManager::FireFocusEventsIfNeeded() { ...@@ -279,6 +279,11 @@ void BrowserAccessibilityManager::FireFocusEventsIfNeeded() {
return; return;
} }
// Wait until navigation is complete or stopped, before attempting to move the
// accessibility focus.
if (user_is_navigating_away_)
return;
BrowserAccessibility* last_focused_node = GetLastFocusedNode(); BrowserAccessibility* last_focused_node = GetLastFocusedNode();
if (focus != last_focused_node) if (focus != last_focused_node)
FireFocusEvent(focus); FireFocusEvent(focus);
...@@ -356,14 +361,17 @@ void BrowserAccessibilityManager::UserIsReloading() { ...@@ -356,14 +361,17 @@ void BrowserAccessibilityManager::UserIsReloading() {
void BrowserAccessibilityManager::NavigationSucceeded() { void BrowserAccessibilityManager::NavigationSucceeded() {
user_is_navigating_away_ = false; user_is_navigating_away_ = false;
FireFocusEventsIfNeeded();
} }
void BrowserAccessibilityManager::NavigationFailed() { void BrowserAccessibilityManager::NavigationFailed() {
user_is_navigating_away_ = false; user_is_navigating_away_ = false;
FireFocusEventsIfNeeded();
} }
void BrowserAccessibilityManager::DidStopLoading() { void BrowserAccessibilityManager::DidStopLoading() {
user_is_navigating_away_ = false; user_is_navigating_away_ = false;
FireFocusEventsIfNeeded();
} }
bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() { bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() {
......
...@@ -577,13 +577,9 @@ void BrowserAccessibilityManagerWin::FireUiaTextContainerEvent( ...@@ -577,13 +577,9 @@ void BrowserAccessibilityManagerWin::FireUiaTextContainerEvent(
} }
bool BrowserAccessibilityManagerWin::CanFireEvents() const { bool BrowserAccessibilityManagerWin::CanFireEvents() const {
if (!BrowserAccessibilityManager::CanFireEvents()) return BrowserAccessibilityManager::CanFireEvents() &&
return false; GetDelegateFromRootManager() &&
BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); GetDelegateFromRootManager()->AccessibilityGetAcceleratedWidget();
if (!root_delegate)
return false;
HWND hwnd = root_delegate->AccessibilityGetAcceleratedWidget();
return hwnd != nullptr;
} }
gfx::Rect BrowserAccessibilityManagerWin::GetViewBounds() { gfx::Rect BrowserAccessibilityManagerWin::GetViewBounds() {
......
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