OLD | NEW |
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/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" | 10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 int32 AXAuraObjCache::GetID(aura::Window* window) { | 44 int32 AXAuraObjCache::GetID(aura::Window* window) { |
45 return GetIDInternal(window, window_to_id_map_); | 45 return GetIDInternal(window, window_to_id_map_); |
46 } | 46 } |
47 | 47 |
48 void AXAuraObjCache::Remove(View* view) { | 48 void AXAuraObjCache::Remove(View* view) { |
49 RemoveInternal(view, view_to_id_map_); | 49 RemoveInternal(view, view_to_id_map_); |
50 } | 50 } |
51 | 51 |
| 52 void AXAuraObjCache::RemoveViewSubtree(View* view) { |
| 53 Remove(view); |
| 54 for (int i = 0; i < view->child_count(); ++i) |
| 55 RemoveViewSubtree(view->child_at(i)); |
| 56 } |
| 57 |
52 void AXAuraObjCache::Remove(Widget* widget) { | 58 void AXAuraObjCache::Remove(Widget* widget) { |
53 RemoveInternal(widget, widget_to_id_map_); | 59 RemoveInternal(widget, widget_to_id_map_); |
| 60 |
| 61 // When an entire widget is deleted, it doesn't always send a notification |
| 62 // on each of its views, so we need to explore them recursively. |
| 63 if (widget->GetRootView()) |
| 64 RemoveViewSubtree(widget->GetRootView()); |
54 } | 65 } |
55 | 66 |
56 void AXAuraObjCache::Remove(aura::Window* window) { | 67 void AXAuraObjCache::Remove(aura::Window* window) { |
57 RemoveInternal(window, window_to_id_map_); | 68 RemoveInternal(window, window_to_id_map_); |
58 } | 69 } |
59 | 70 |
60 AXAuraObjWrapper* AXAuraObjCache::Get(int32 id) { | 71 AXAuraObjWrapper* AXAuraObjCache::Get(int32 id) { |
61 std::map<int32, AXAuraObjWrapper*>::iterator it = cache_.find(id); | 72 std::map<int32, AXAuraObjWrapper*>::iterator it = cache_.find(id); |
62 | 73 |
63 if (it == cache_.end()) | 74 if (it == cache_.end()) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 void AXAuraObjCache::RemoveInternal( | 142 void AXAuraObjCache::RemoveInternal( |
132 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map) { | 143 AuraView* aura_view, std::map<AuraView*, int32>& aura_view_to_id_map) { |
133 int32 id = GetID(aura_view); | 144 int32 id = GetID(aura_view); |
134 if (id == -1) | 145 if (id == -1) |
135 return; | 146 return; |
136 aura_view_to_id_map.erase(aura_view); | 147 aura_view_to_id_map.erase(aura_view); |
137 Remove(id); | 148 Remove(id); |
138 } | 149 } |
139 | 150 |
140 } // namespace views | 151 } // namespace views |
OLD | NEW |