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

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: 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, bool notify) {
78 int id = GetIDInternal(window, window_to_id_map_);
79 AXAuraObjWrapper* obj = nullptr;
80 if (id != -1) {
dmazzoni 2016/08/31 16:33:50 This check isn't necessary, right? You can still c
David Tseng 2016/08/31 21:06:42 Done.
81 obj = Get(id);
82 if (obj)
83 obj = obj->GetParent();
84 }
85
78 RemoveInternal(window, window_to_id_map_); 86 RemoveInternal(window, window_to_id_map_);
87
88 if (notify && delegate_)
89 delegate_->OnChildWindowRemoved(obj);
79 } 90 }
80 91
81 AXAuraObjWrapper* AXAuraObjCache::Get(int32_t id) { 92 AXAuraObjWrapper* AXAuraObjCache::Get(int32_t id) {
82 std::map<int32_t, AXAuraObjWrapper*>::iterator it = cache_.find(id); 93 std::map<int32_t, AXAuraObjWrapper*>::iterator it = cache_.find(id);
83 94
84 if (it == cache_.end()) 95 if (it == cache_.end())
85 return NULL; 96 return NULL;
86 97
87 return it->second; 98 return it->second;
88 } 99 }
(...skipping 21 matching lines...) Expand all
110 AXAuraObjWrapper* AXAuraObjCache::GetFocus() { 121 AXAuraObjWrapper* AXAuraObjCache::GetFocus() {
111 View* focused_view = GetFocusedView(); 122 View* focused_view = GetFocusedView();
112 if (focused_view) 123 if (focused_view)
113 return GetOrCreate(focused_view); 124 return GetOrCreate(focused_view);
114 return nullptr; 125 return nullptr;
115 } 126 }
116 127
117 AXAuraObjCache::AXAuraObjCache() 128 AXAuraObjCache::AXAuraObjCache()
118 : current_id_(1), 129 : current_id_(1),
119 focus_client_(nullptr), 130 focus_client_(nullptr),
120 is_destroying_(false) { 131 is_destroying_(false),
121 } 132 delegate_(nullptr) {}
122 133
123 AXAuraObjCache::~AXAuraObjCache() { 134 AXAuraObjCache::~AXAuraObjCache() {
124 is_destroying_ = true; 135 is_destroying_ = true;
125 base::STLDeleteContainerPairSecondPointers(cache_.begin(), cache_.end()); 136 base::STLDeleteContainerPairSecondPointers(cache_.begin(), cache_.end());
126 cache_.clear(); 137 cache_.clear();
127 } 138 }
128 139
129 View* AXAuraObjCache::GetFocusedView() { 140 View* AXAuraObjCache::GetFocusedView() {
130 if (!focus_client_) 141 if (!focus_client_)
131 return nullptr; 142 return nullptr;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 AuraView* aura_view, 214 AuraView* aura_view,
204 std::map<AuraView*, int32_t>& aura_view_to_id_map) { 215 std::map<AuraView*, int32_t>& aura_view_to_id_map) {
205 int32_t id = GetID(aura_view); 216 int32_t id = GetID(aura_view);
206 if (id == -1) 217 if (id == -1)
207 return; 218 return;
208 aura_view_to_id_map.erase(aura_view); 219 aura_view_to_id_map.erase(aura_view);
209 Remove(id); 220 Remove(id);
210 } 221 }
211 222
212 } // namespace views 223 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698