Commit 83f5f044 authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Fire live region change events in UI on a slight delay

When a live region event is fired at the same time as other events, JAWS
is preferring to to skip the live region announcement. Firing the
live region event on a slight delay fixes this problem.

Bug: 1024847
Change-Id: If1eacb95d3cbbf7bbc58c54dfb1a3f64eda76ae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1917339Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715819}
parent d1a2460d
...@@ -99,6 +99,14 @@ void FlushQueue() { ...@@ -99,6 +99,14 @@ void FlushQueue() {
g_event_queue.Get().clear(); g_event_queue.Get().clear();
} }
void PostFlushEventQueueTaskIfNecessary() {
if (!g_is_queueing_events) {
g_is_queueing_events = true;
base::OnceCallback<void()> cb = base::BindOnce(&FlushQueue);
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(cb));
}
}
} // namespace } // namespace
struct ViewAXPlatformNodeDelegate::ChildWidgetsResult { struct ViewAXPlatformNodeDelegate::ChildWidgetsResult {
...@@ -164,11 +172,16 @@ void ViewAXPlatformNodeDelegate::NotifyAccessibilityEvent( ...@@ -164,11 +172,16 @@ void ViewAXPlatformNodeDelegate::NotifyAccessibilityEvent(
// before the next focus event. It makes sense to delay the entire next // before the next focus event. It makes sense to delay the entire next
// synchronous batch of next events so that ordering remains the same. // synchronous batch of next events so that ordering remains the same.
// Begin queueing subsequent events and flush queue asynchronously. // Begin queueing subsequent events and flush queue asynchronously.
g_is_queueing_events = true; PostFlushEventQueueTaskIfNecessary();
base::OnceCallback<void()> cb = base::BindOnce(&FlushQueue);
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(cb));
break; break;
} }
case ax::mojom::Event::kLiveRegionChanged: {
// Fire after a delay so that screen readers don't wipe it out when
// another user-generated event fires simultaneously.
PostFlushEventQueueTaskIfNecessary();
g_event_queue.Get().emplace_back(event_type, GetUniqueId());
return;
}
default: default:
break; break;
} }
......
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