Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Unified Diff: content/browser/accessibility/browser_accessibility_manager.cc

Issue 1925473002: Add verbose logging for native accessibility events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@load_complete
Patch Set: address all feedback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/browser_accessibility_manager.cc
diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc
index e734b6cf7354e9b1e6e6b9ebd00ac1392da105ff..9ced783549907b6510cf4cf6ba5da4507af04edc 100644
--- a/content/browser/accessibility/browser_accessibility_manager.cc
+++ b/content/browser/accessibility/browser_accessibility_manager.cc
@@ -183,7 +183,15 @@ BrowserAccessibilityManager::GetEmptyDocument() {
return update;
}
-void BrowserAccessibilityManager::FireFocusEventsIfNeeded() {
+void BrowserAccessibilityManager::NotifyAccessibilityEvent(
+ BrowserAccessibilityEvent::Source source,
+ ui::AXEvent event_type,
+ BrowserAccessibility* node) {
+ BrowserAccessibilityEvent::Create(source, event_type, node)->Fire();
+}
+
+void BrowserAccessibilityManager::FireFocusEventsIfNeeded(
+ BrowserAccessibilityEvent::Source source) {
BrowserAccessibility* focus = GetFocus();
// Don't fire focus events if the window itself doesn't have focus.
@@ -209,7 +217,7 @@ void BrowserAccessibilityManager::FireFocusEventsIfNeeded() {
}
if (focus && focus != last_focused_node_)
- FireFocusEvent(focus);
+ FireFocusEvent(source, focus);
last_focused_node_ = focus;
last_focused_manager_ = focus ? focus->manager() : nullptr;
@@ -219,8 +227,10 @@ bool BrowserAccessibilityManager::CanFireEvents() {
return true;
}
-void BrowserAccessibilityManager::FireFocusEvent(BrowserAccessibility* node) {
- NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, node);
+void BrowserAccessibilityManager::FireFocusEvent(
+ BrowserAccessibilityEvent::Source source,
+ BrowserAccessibility* node) {
+ NotifyAccessibilityEvent(source, ui::AX_EVENT_FOCUS, node);
if (!g_focus_change_callback_for_testing.Get().is_null())
g_focus_change_callback_for_testing.Get().Run();
@@ -292,7 +302,7 @@ const ui::AXTreeData& BrowserAccessibilityManager::GetTreeData() {
void BrowserAccessibilityManager::OnWindowFocused() {
if (this == GetRootManager())
- FireFocusEventsIfNeeded();
+ FireFocusEventsIfNeeded(BrowserAccessibilityEvent::FromWindowFocusChange);
}
void BrowserAccessibilityManager::OnWindowBlurred() {
@@ -318,15 +328,6 @@ void BrowserAccessibilityManager::NavigationFailed() {
user_is_navigating_away_ = false;
}
-void BrowserAccessibilityManager::GotMouseDown() {
- BrowserAccessibility* focus = GetFocus();
- if (!focus)
- return;
-
- osk_state_ = OSK_ALLOWED_WITHIN_FOCUSED_OBJECT;
- NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, focus);
-}
-
bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() {
return true;
}
@@ -354,8 +355,10 @@ void BrowserAccessibilityManager::OnAccessibilityEvents(
if (!connected_to_parent_tree_node_) {
parent->OnDataChanged();
parent->UpdatePlatformAttributes();
- parent->manager()->NotifyAccessibilityEvent(
- ui::AX_EVENT_CHILDREN_CHANGED, parent);
+ NotifyAccessibilityEvent(
+ BrowserAccessibilityEvent::FromChildFrameLoading,
+ ui::AX_EVENT_CHILDREN_CHANGED,
+ parent);
connected_to_parent_tree_node_ = true;
}
} else {
@@ -366,7 +369,8 @@ void BrowserAccessibilityManager::OnAccessibilityEvents(
// Screen readers might not do the right thing if they're not aware of what
// has focus, so always try that first. Nothing will be fired if the window
// itself isn't focused or if focus hasn't changed.
- GetRootManager()->FireFocusEventsIfNeeded();
+ GetRootManager()->FireFocusEventsIfNeeded(
+ BrowserAccessibilityEvent::FromBlink);
// Now iterate over the events again and fire the events other than focus
// events.
@@ -398,7 +402,13 @@ void BrowserAccessibilityManager::OnAccessibilityEvents(
}
// Fire the native event.
- NotifyAccessibilityEvent(event_type, GetFromAXNode(node));
+ BrowserAccessibility* event_target = GetFromAXNode(node);
+ if (event_target) {
+ NotifyAccessibilityEvent(
+ BrowserAccessibilityEvent::FromBlink,
+ event_type,
+ event_target);
+ }
}
}
@@ -473,7 +483,10 @@ void BrowserAccessibilityManager::ActivateFindInPageResult(
// The "scrolled to anchor" notification is a great way to get a
// screen reader to jump directly to a specific location in a document.
- NotifyAccessibilityEvent(ui::AX_EVENT_SCROLLED_TO_ANCHOR, node);
+ NotifyAccessibilityEvent(
+ BrowserAccessibilityEvent::FromFindInPageResult,
+ ui::AX_EVENT_SCROLLED_TO_ANCHOR,
+ node);
}
BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendantFocus(

Powered by Google App Engine
This is Rietveld 408576698