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

Unified Diff: chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc

Issue 380943002: Added battery level and time to the status tray's accessible name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed old view before storing a new one Created 6 years, 5 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
« no previous file with comments | « chrome/browser/ui/views/accessibility/accessibility_event_router_views.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
diff --git a/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc b/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
index bab270e451dbfd7a048f84fac5164b7dbeadcdb0..5317d74a5521099eafdae3decf00e4867cb5347c 100644
--- a/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
+++ b/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc
@@ -24,9 +24,12 @@
#include "ui/views/widget/widget.h"
using views::FocusManager;
+using views::ViewStorage;
AccessibilityEventRouterViews::AccessibilityEventRouterViews()
- : most_recent_profile_(NULL) {
+ : most_recent_profile_(NULL),
+ most_recent_view_id_(
+ ViewStorage::GetInstance()->CreateStorageID()) {
// Register for notification when profile is destroyed to ensure that all
// observers are detatched at that time.
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
@@ -68,7 +71,7 @@ void AccessibilityEventRouterViews::HandleAccessibilityEvent(
// event loop, to handle cases where the view's state changes after
// the call to post the event. It's safe to use base::Unretained(this)
// because AccessibilityEventRouterViews is a singleton.
- views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
+ ViewStorage* view_storage = ViewStorage::GetInstance();
int view_storage_id = view_storage->CreateStorageID();
view_storage->StoreView(view_storage_id, view);
base::MessageLoop::current()->PostTask(
@@ -120,7 +123,7 @@ void AccessibilityEventRouterViews::Observe(
void AccessibilityEventRouterViews::DispatchEventOnViewStorageId(
int view_storage_id,
ui::AXEvent type) {
- views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
+ ViewStorage* view_storage = ViewStorage::GetInstance();
views::View* view = view_storage->RetrieveView(view_storage_id);
view_storage->RemoveView(view_storage_id);
if (!view)
@@ -163,6 +166,20 @@ void AccessibilityEventRouterViews::DispatchAccessibilityEvent(
return;
}
+ view = FindFirstAccessibleAncestor(view);
+
+ // Since multiple items could share a highest focusable view, these items
+ // could all dispatch the same accessibility hover events, which isn't
+ // necessary.
+ if (type == ui::AX_EVENT_HOVER &&
+ ViewStorage::GetInstance()->RetrieveView(most_recent_view_id_) == view) {
+ return;
+ }
+ // If there was already a view stored here from before, it must be removed
+ // before storing a new view.
+ ViewStorage::GetInstance()->RemoveView(most_recent_view_id_);
+ ViewStorage::GetInstance()->StoreView(most_recent_view_id_, view);
+
ui::AXViewState state;
view->GetAccessibleState(&state);
@@ -552,3 +569,12 @@ std::string AccessibilityEventRouterViews::RecursiveGetStaticText(
}
return std::string();
}
+
+// static
+views::View* AccessibilityEventRouterViews::FindFirstAccessibleAncestor(
+ views::View* view) {
+ while (view->parent() && !view->IsAccessibilityFocusable()) {
+ view = view->parent();
+ }
+ return view;
+}
« no previous file with comments | « chrome/browser/ui/views/accessibility/accessibility_event_router_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698