| 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 "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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 AXAuraObjWrapper* AXAuraObjCache::GetFocus() { | 112 AXAuraObjWrapper* AXAuraObjCache::GetFocus() { |
| 113 View* focused_view = GetFocusedView(); | 113 View* focused_view = GetFocusedView(); |
| 114 if (focused_view) | 114 if (focused_view) |
| 115 return GetOrCreate(focused_view); | 115 return GetOrCreate(focused_view); |
| 116 return nullptr; | 116 return nullptr; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void AXAuraObjCache::OnFocusedViewChanged() { |
| 120 View* view = GetFocusedView(); |
| 121 if (view) |
| 122 view->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); |
| 123 } |
| 124 |
| 119 AXAuraObjCache::AXAuraObjCache() | 125 AXAuraObjCache::AXAuraObjCache() |
| 120 : current_id_(1), | 126 : current_id_(1), |
| 121 focus_client_(nullptr), | 127 focus_client_(nullptr), |
| 122 is_destroying_(false), | 128 is_destroying_(false), |
| 123 delegate_(nullptr) {} | 129 delegate_(nullptr) {} |
| 124 | 130 |
| 125 AXAuraObjCache::~AXAuraObjCache() { | 131 AXAuraObjCache::~AXAuraObjCache() { |
| 126 is_destroying_ = true; | 132 is_destroying_ = true; |
| 127 cache_.clear(); | 133 cache_.clear(); |
| 128 } | 134 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 153 | 159 |
| 154 View* focused_view = focus_manager->GetFocusedView(); | 160 View* focused_view = focus_manager->GetFocusedView(); |
| 155 if (focused_view) | 161 if (focused_view) |
| 156 return focused_view; | 162 return focused_view; |
| 157 else | 163 else |
| 158 return focused_widget->GetRootView(); | 164 return focused_widget->GetRootView(); |
| 159 } | 165 } |
| 160 | 166 |
| 161 void AXAuraObjCache::OnWindowFocused(aura::Window* gained_focus, | 167 void AXAuraObjCache::OnWindowFocused(aura::Window* gained_focus, |
| 162 aura::Window* lost_focus) { | 168 aura::Window* lost_focus) { |
| 163 View* view = GetFocusedView(); | 169 OnFocusedViewChanged(); |
| 164 if (view) | |
| 165 view->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); | |
| 166 } | 170 } |
| 167 | 171 |
| 168 void AXAuraObjCache::OnWindowDestroying(aura::Window* window) { | 172 void AXAuraObjCache::OnWindowDestroying(aura::Window* window) { |
| 169 focus_client_ = nullptr; | 173 focus_client_ = nullptr; |
| 170 } | 174 } |
| 171 | 175 |
| 172 template <typename AuraViewWrapper, typename AuraView> | 176 template <typename AuraViewWrapper, typename AuraView> |
| 173 AXAuraObjWrapper* AXAuraObjCache::CreateInternal( | 177 AXAuraObjWrapper* AXAuraObjCache::CreateInternal( |
| 174 AuraView* aura_view, | 178 AuraView* aura_view, |
| 175 std::map<AuraView*, int32_t>& aura_view_to_id_map) { | 179 std::map<AuraView*, int32_t>& aura_view_to_id_map) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 AuraView* aura_view, | 211 AuraView* aura_view, |
| 208 std::map<AuraView*, int32_t>& aura_view_to_id_map) { | 212 std::map<AuraView*, int32_t>& aura_view_to_id_map) { |
| 209 int32_t id = GetID(aura_view); | 213 int32_t id = GetID(aura_view); |
| 210 if (id == -1) | 214 if (id == -1) |
| 211 return; | 215 return; |
| 212 aura_view_to_id_map.erase(aura_view); | 216 aura_view_to_id_map.erase(aura_view); |
| 213 Remove(id); | 217 Remove(id); |
| 214 } | 218 } |
| 215 | 219 |
| 216 } // namespace views | 220 } // namespace views |
| OLD | NEW |