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

Side by Side Diff: ui/views/accessibility/ax_aura_obj_cache.cc

Issue 1765583002: AXAuraObjCache - clear focus client reference when window is destroyed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « ui/views/accessibility/ax_aura_obj_cache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/accessibility/ax_aura_obj_cache.h" 5 #include "ui/views/accessibility/ax_aura_obj_cache.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "ui/aura/client/focus_client.h" 9 #include "ui/aura/client/focus_client.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 17 matching lines...) Expand all
28 28
29 AXAuraObjWrapper* AXAuraObjCache::GetOrCreate(Widget* widget) { 29 AXAuraObjWrapper* AXAuraObjCache::GetOrCreate(Widget* widget) {
30 return CreateInternal<AXWidgetObjWrapper>(widget, widget_to_id_map_); 30 return CreateInternal<AXWidgetObjWrapper>(widget, widget_to_id_map_);
31 } 31 }
32 32
33 AXAuraObjWrapper* AXAuraObjCache::GetOrCreate(aura::Window* window) { 33 AXAuraObjWrapper* AXAuraObjCache::GetOrCreate(aura::Window* window) {
34 if (!focus_client_) { 34 if (!focus_client_) {
35 aura::Window* root_window = window->GetRootWindow(); 35 aura::Window* root_window = window->GetRootWindow();
36 if (root_window) { 36 if (root_window) {
37 focus_client_ = aura::client::GetFocusClient(root_window); 37 focus_client_ = aura::client::GetFocusClient(root_window);
38 root_window->AddObserver(this);
38 if (focus_client_) 39 if (focus_client_)
39 focus_client_->AddObserver(this); 40 focus_client_->AddObserver(this);
40 } 41 }
41 } 42 }
42 return CreateInternal<AXWindowObjWrapper>(window, window_to_id_map_); 43 return CreateInternal<AXWindowObjWrapper>(window, window_to_id_map_);
43 } 44 }
44 45
45 int32_t AXAuraObjCache::GetID(View* view) const { 46 int32_t AXAuraObjCache::GetID(View* view) const {
46 return GetIDInternal(view, view_to_id_map_); 47 return GetIDInternal(view, view_to_id_map_);
47 } 48 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return focus_manager->GetFocusedView(); 153 return focus_manager->GetFocusedView();
153 } 154 }
154 155
155 void AXAuraObjCache::OnWindowFocused(aura::Window* gained_focus, 156 void AXAuraObjCache::OnWindowFocused(aura::Window* gained_focus,
156 aura::Window* lost_focus) { 157 aura::Window* lost_focus) {
157 View* view = GetFocusedView(); 158 View* view = GetFocusedView();
158 if (view) 159 if (view)
159 view->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); 160 view->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true);
160 } 161 }
161 162
163 void AXAuraObjCache::OnWindowDestroying(aura::Window* window) {
164 focus_client_ = nullptr;
165 }
166
162 template <typename AuraViewWrapper, typename AuraView> 167 template <typename AuraViewWrapper, typename AuraView>
163 AXAuraObjWrapper* AXAuraObjCache::CreateInternal( 168 AXAuraObjWrapper* AXAuraObjCache::CreateInternal(
164 AuraView* aura_view, 169 AuraView* aura_view,
165 std::map<AuraView*, int32_t>& aura_view_to_id_map) { 170 std::map<AuraView*, int32_t>& aura_view_to_id_map) {
166 if (!aura_view) 171 if (!aura_view)
167 return NULL; 172 return NULL;
168 173
169 typename std::map<AuraView*, int32_t>::iterator it = 174 typename std::map<AuraView*, int32_t>::iterator it =
170 aura_view_to_id_map.find(aura_view); 175 aura_view_to_id_map.find(aura_view);
171 176
(...skipping 26 matching lines...) Expand all
198 AuraView* aura_view, 203 AuraView* aura_view,
199 std::map<AuraView*, int32_t>& aura_view_to_id_map) { 204 std::map<AuraView*, int32_t>& aura_view_to_id_map) {
200 int32_t id = GetID(aura_view); 205 int32_t id = GetID(aura_view);
201 if (id == -1) 206 if (id == -1)
202 return; 207 return;
203 aura_view_to_id_map.erase(aura_view); 208 aura_view_to_id_map.erase(aura_view);
204 Remove(id); 209 Remove(id);
205 } 210 }
206 211
207 } // namespace views 212 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/accessibility/ax_aura_obj_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698