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

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

Issue 2295183003: Update desktop tree when Aura windows are removed. (Closed)
Patch Set: Fix test. Created 4 years, 3 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
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 void AXAuraObjCache::Remove(Widget* widget) { 68 void AXAuraObjCache::Remove(Widget* widget) {
69 RemoveInternal(widget, widget_to_id_map_); 69 RemoveInternal(widget, widget_to_id_map_);
70 70
71 // When an entire widget is deleted, it doesn't always send a notification 71 // When an entire widget is deleted, it doesn't always send a notification
72 // on each of its views, so we need to explore them recursively. 72 // on each of its views, so we need to explore them recursively.
73 if (widget->GetRootView()) 73 if (widget->GetRootView())
74 RemoveViewSubtree(widget->GetRootView()); 74 RemoveViewSubtree(widget->GetRootView());
75 } 75 }
76 76
77 void AXAuraObjCache::Remove(aura::Window* window) { 77 void AXAuraObjCache::Remove(aura::Window* window, aura::Window* parent) {
78 int id = GetIDInternal(parent, window_to_id_map_);
79 AXAuraObjWrapper* parent_window_obj = Get(id);
78 RemoveInternal(window, window_to_id_map_); 80 RemoveInternal(window, window_to_id_map_);
81 if (parent && delegate_)
82 delegate_->OnChildWindowRemoved(parent_window_obj);
79 } 83 }
80 84
81 AXAuraObjWrapper* AXAuraObjCache::Get(int32_t id) { 85 AXAuraObjWrapper* AXAuraObjCache::Get(int32_t id) {
82 std::map<int32_t, AXAuraObjWrapper*>::iterator it = cache_.find(id); 86 std::map<int32_t, AXAuraObjWrapper*>::iterator it = cache_.find(id);
83 87
84 if (it == cache_.end()) 88 if (it == cache_.end())
85 return NULL; 89 return NULL;
86 90
87 return it->second; 91 return it->second;
88 } 92 }
(...skipping 21 matching lines...) Expand all
110 AXAuraObjWrapper* AXAuraObjCache::GetFocus() { 114 AXAuraObjWrapper* AXAuraObjCache::GetFocus() {
111 View* focused_view = GetFocusedView(); 115 View* focused_view = GetFocusedView();
112 if (focused_view) 116 if (focused_view)
113 return GetOrCreate(focused_view); 117 return GetOrCreate(focused_view);
114 return nullptr; 118 return nullptr;
115 } 119 }
116 120
117 AXAuraObjCache::AXAuraObjCache() 121 AXAuraObjCache::AXAuraObjCache()
118 : current_id_(1), 122 : current_id_(1),
119 focus_client_(nullptr), 123 focus_client_(nullptr),
120 is_destroying_(false) { 124 is_destroying_(false),
121 } 125 delegate_(nullptr) {}
122 126
123 AXAuraObjCache::~AXAuraObjCache() { 127 AXAuraObjCache::~AXAuraObjCache() {
124 is_destroying_ = true; 128 is_destroying_ = true;
125 base::STLDeleteContainerPairSecondPointers(cache_.begin(), cache_.end()); 129 base::STLDeleteContainerPairSecondPointers(cache_.begin(), cache_.end());
126 cache_.clear(); 130 cache_.clear();
127 } 131 }
128 132
129 View* AXAuraObjCache::GetFocusedView() { 133 View* AXAuraObjCache::GetFocusedView() {
130 if (!focus_client_) 134 if (!focus_client_)
131 return nullptr; 135 return nullptr;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 AuraView* aura_view, 207 AuraView* aura_view,
204 std::map<AuraView*, int32_t>& aura_view_to_id_map) { 208 std::map<AuraView*, int32_t>& aura_view_to_id_map) {
205 int32_t id = GetID(aura_view); 209 int32_t id = GetID(aura_view);
206 if (id == -1) 210 if (id == -1)
207 return; 211 return;
208 aura_view_to_id_map.erase(aura_view); 212 aura_view_to_id_map.erase(aura_view);
209 Remove(id); 213 Remove(id);
210 } 214 }
211 215
212 } // namespace views 216 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/accessibility/ax_aura_obj_cache.h ('k') | ui/views/accessibility/ax_widget_obj_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698