Chromium Code Reviews| 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/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 return GetOrCreate(focused_view); | 117 return GetOrCreate(focused_view); |
| 118 return nullptr; | 118 return nullptr; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void AXAuraObjCache::OnFocusedViewChanged() { | 121 void AXAuraObjCache::OnFocusedViewChanged() { |
| 122 View* view = GetFocusedView(); | 122 View* view = GetFocusedView(); |
| 123 if (view) | 123 if (view) |
| 124 view->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); | 124 view->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void AXAuraObjCache::FireEvent(AXAuraObjWrapper* aura_obj, | |
| 128 ui::AXEvent event_type) { | |
| 129 if (delegate_) | |
| 130 delegate_->OnEvent(aura_obj, event_type); | |
| 131 } | |
| 132 | |
| 127 AXAuraObjCache::AXAuraObjCache() | 133 AXAuraObjCache::AXAuraObjCache() |
| 128 : current_id_(1), | 134 : current_id_(1), |
| 129 focus_client_(nullptr), | 135 focus_client_(nullptr), |
| 130 is_destroying_(false), | 136 is_destroying_(false), |
| 131 delegate_(nullptr) {} | 137 delegate_(nullptr) {} |
| 132 | 138 |
| 133 AXAuraObjCache::~AXAuraObjCache() { | 139 AXAuraObjCache::~AXAuraObjCache() { |
| 134 is_destroying_ = true; | 140 is_destroying_ = true; |
| 135 cache_.clear(); | 141 cache_.clear(); |
| 136 } | 142 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 | 180 |
| 175 void AXAuraObjCache::OnWindowFocused(aura::Window* gained_focus, | 181 void AXAuraObjCache::OnWindowFocused(aura::Window* gained_focus, |
| 176 aura::Window* lost_focus) { | 182 aura::Window* lost_focus) { |
| 177 OnFocusedViewChanged(); | 183 OnFocusedViewChanged(); |
| 178 } | 184 } |
| 179 | 185 |
| 180 void AXAuraObjCache::OnWindowDestroying(aura::Window* window) { | 186 void AXAuraObjCache::OnWindowDestroying(aura::Window* window) { |
| 181 focus_client_ = nullptr; | 187 focus_client_ = nullptr; |
| 182 } | 188 } |
| 183 | 189 |
| 190 void AXAuraObjCache::OnWindowHierarchyChanged( | |
|
David Tseng
2017/04/17 15:39:54
I don't know if this is what you really want. This
dmazzoni
2017/04/19 18:07:34
So on Chrome OS, there's only one root window for
David Tseng
2017/04/19 19:21:31
Please add a comment when we call root_window->Add
dmazzoni
2017/04/19 21:37:02
Done.
| |
| 191 const HierarchyChangeParams& params) { | |
| 192 aura::Window* window = params.target; | |
| 193 if (window->parent()) { | |
| 194 delegate_->OnEvent(GetOrCreate(window->parent()), | |
| 195 ui::AX_EVENT_CHILDREN_CHANGED); | |
| 196 } | |
| 197 } | |
| 198 | |
| 184 template <typename AuraViewWrapper, typename AuraView> | 199 template <typename AuraViewWrapper, typename AuraView> |
| 185 AXAuraObjWrapper* AXAuraObjCache::CreateInternal( | 200 AXAuraObjWrapper* AXAuraObjCache::CreateInternal( |
| 186 AuraView* aura_view, | 201 AuraView* aura_view, |
| 187 std::map<AuraView*, int32_t>& aura_view_to_id_map) { | 202 std::map<AuraView*, int32_t>& aura_view_to_id_map) { |
| 188 if (!aura_view) | 203 if (!aura_view) |
| 189 return nullptr; | 204 return nullptr; |
| 190 | 205 |
| 191 auto it = aura_view_to_id_map.find(aura_view); | 206 auto it = aura_view_to_id_map.find(aura_view); |
| 192 | 207 |
| 193 if (it != aura_view_to_id_map.end()) | 208 if (it != aura_view_to_id_map.end()) |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 219 AuraView* aura_view, | 234 AuraView* aura_view, |
| 220 std::map<AuraView*, int32_t>& aura_view_to_id_map) { | 235 std::map<AuraView*, int32_t>& aura_view_to_id_map) { |
| 221 int32_t id = GetID(aura_view); | 236 int32_t id = GetID(aura_view); |
| 222 if (id == -1) | 237 if (id == -1) |
| 223 return; | 238 return; |
| 224 aura_view_to_id_map.erase(aura_view); | 239 aura_view_to_id_map.erase(aura_view); |
| 225 Remove(id); | 240 Remove(id); |
| 226 } | 241 } |
| 227 | 242 |
| 228 } // namespace views | 243 } // namespace views |
| OLD | NEW |