| 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_window_obj_wrapper.h" | 5 #include "ui/views/accessibility/ax_window_obj_wrapper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
| 11 #include "ui/accessibility/platform/aura_window_properties.h" | |
| 12 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 13 #include "ui/views/accessibility/ax_aura_obj_cache.h" | 12 #include "ui/views/accessibility/ax_aura_obj_cache.h" |
| 14 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 15 | 14 |
| 16 namespace views { | 15 namespace views { |
| 17 | 16 |
| 18 AXWindowObjWrapper::AXWindowObjWrapper(aura::Window* window) | 17 AXWindowObjWrapper::AXWindowObjWrapper(aura::Window* window) |
| 19 : window_(window), is_alert_(false) { | 18 : window_(window), is_alert_(false) { |
| 20 window->AddObserver(this); | 19 window->AddObserver(this); |
| 21 } | 20 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 out_children->push_back(AXAuraObjCache::GetInstance()->GetOrCreate(widget)); | 47 out_children->push_back(AXAuraObjCache::GetInstance()->GetOrCreate(widget)); |
| 49 } | 48 } |
| 50 | 49 |
| 51 void AXWindowObjWrapper::Serialize(ui::AXNodeData* out_node_data) { | 50 void AXWindowObjWrapper::Serialize(ui::AXNodeData* out_node_data) { |
| 52 out_node_data->id = GetID(); | 51 out_node_data->id = GetID(); |
| 53 out_node_data->role = is_alert_ ? ui::AX_ROLE_ALERT : ui::AX_ROLE_WINDOW; | 52 out_node_data->role = is_alert_ ? ui::AX_ROLE_ALERT : ui::AX_ROLE_WINDOW; |
| 54 out_node_data->AddStringAttribute(ui::AX_ATTR_NAME, | 53 out_node_data->AddStringAttribute(ui::AX_ATTR_NAME, |
| 55 base::UTF16ToUTF8(window_->GetTitle())); | 54 base::UTF16ToUTF8(window_->GetTitle())); |
| 56 out_node_data->state = 0; | 55 out_node_data->state = 0; |
| 57 out_node_data->location = gfx::RectF(window_->bounds()); | 56 out_node_data->location = gfx::RectF(window_->bounds()); |
| 58 | |
| 59 ui::AXTreeIDRegistry::AXTreeID child_ax_tree_id = | |
| 60 window_->GetProperty(ui::kChildAXTreeID); | |
| 61 if (child_ax_tree_id != ui::AXTreeIDRegistry::kNoAXTreeID) | |
| 62 out_node_data->AddIntAttribute(ui::AX_ATTR_CHILD_TREE_ID, child_ax_tree_id); | |
| 63 } | 57 } |
| 64 | 58 |
| 65 int32_t AXWindowObjWrapper::GetID() { | 59 int32_t AXWindowObjWrapper::GetID() { |
| 66 return AXAuraObjCache::GetInstance()->GetID(window_); | 60 return AXAuraObjCache::GetInstance()->GetID(window_); |
| 67 } | 61 } |
| 68 | 62 |
| 69 void AXWindowObjWrapper::OnWindowDestroyed(aura::Window* window) { | 63 void AXWindowObjWrapper::OnWindowDestroyed(aura::Window* window) { |
| 70 AXAuraObjCache::GetInstance()->Remove(window, nullptr); | 64 AXAuraObjCache::GetInstance()->Remove(window, nullptr); |
| 71 } | 65 } |
| 72 | 66 |
| 73 void AXWindowObjWrapper::OnWindowDestroying(aura::Window* window) { | 67 void AXWindowObjWrapper::OnWindowDestroying(aura::Window* window) { |
| 74 Widget* widget = Widget::GetWidgetForNativeView(window); | 68 Widget* widget = Widget::GetWidgetForNativeView(window); |
| 75 if (widget) | 69 if (widget) |
| 76 AXAuraObjCache::GetInstance()->Remove(widget); | 70 AXAuraObjCache::GetInstance()->Remove(widget); |
| 77 } | 71 } |
| 78 | 72 |
| 79 void AXWindowObjWrapper::OnWindowHierarchyChanged( | 73 void AXWindowObjWrapper::OnWindowHierarchyChanged( |
| 80 const HierarchyChangeParams& params) { | 74 const HierarchyChangeParams& params) { |
| 81 if (params.phase == WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGED) | 75 if (params.phase == WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGED) |
| 82 AXAuraObjCache::GetInstance()->Remove(params.target, params.old_parent); | 76 AXAuraObjCache::GetInstance()->Remove(params.target, params.old_parent); |
| 83 } | 77 } |
| 84 | 78 |
| 85 } // namespace views | 79 } // namespace views |
| OLD | NEW |