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

Side by Side Diff: content/browser/accessibility/browser_accessibility.cc

Issue 2886353003: Remove BrowserAccessibility::platform_node_ (Closed)
Patch Set: Created 3 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility.h" 5 #include "content/browser/accessibility/browser_accessibility.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 22 matching lines...) Expand all
33 #if !defined(PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL) 33 #if !defined(PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL)
34 // static 34 // static
35 BrowserAccessibility* BrowserAccessibility::Create() { 35 BrowserAccessibility* BrowserAccessibility::Create() {
36 return new BrowserAccessibility(); 36 return new BrowserAccessibility();
37 } 37 }
38 #endif 38 #endif
39 39
40 BrowserAccessibility::BrowserAccessibility() 40 BrowserAccessibility::BrowserAccessibility()
41 : manager_(nullptr), 41 : manager_(nullptr),
42 node_(nullptr), 42 node_(nullptr),
43 unique_id_(ui::GetNextAXPlatformNodeUniqueId()), 43 unique_id_(ui::GetNextAXPlatformNodeUniqueId()) {
44 platform_node_(nullptr) {
45 g_unique_id_map.Get()[unique_id_] = this; 44 g_unique_id_map.Get()[unique_id_] = this;
46 } 45 }
47 46
48 BrowserAccessibility::~BrowserAccessibility() { 47 BrowserAccessibility::~BrowserAccessibility() {
49 if (unique_id_) 48 if (unique_id_)
50 g_unique_id_map.Get().erase(unique_id_); 49 g_unique_id_map.Get().erase(unique_id_);
51 if (platform_node_)
52 platform_node_->Destroy();
53 } 50 }
54 51
55 // static 52 // static
56 BrowserAccessibility* BrowserAccessibility::GetFromUniqueID(int32_t unique_id) { 53 BrowserAccessibility* BrowserAccessibility::GetFromUniqueID(int32_t unique_id) {
57 auto iter = g_unique_id_map.Get().find(unique_id); 54 auto iter = g_unique_id_map.Get().find(unique_id);
58 if (iter == g_unique_id_map.Get().end()) 55 if (iter == g_unique_id_map.Get().end())
59 return nullptr; 56 return nullptr;
60 57
61 return iter->second; 58 return iter->second;
62 } 59 }
63 60
64 void BrowserAccessibility::Init(BrowserAccessibilityManager* manager, 61 void BrowserAccessibility::Init(BrowserAccessibilityManager* manager,
65 ui::AXNode* node) { 62 ui::AXNode* node) {
66 manager_ = manager; 63 manager_ = manager;
67 node_ = node; 64 node_ = node;
68
69 // Here we create the AXPlatformNode which contains a platform-specific
70 // implementation of requried accessibility APIS for this node. At this point,
71 // we only are creating this object for Windows. See http://crbug.com/703369
72 #if defined(OS_WIN)
73 platform_node_ = ui::AXPlatformNode::Create(this);
74 #endif
75 } 65 }
76 66
77 bool BrowserAccessibility::PlatformIsLeaf() const { 67 bool BrowserAccessibility::PlatformIsLeaf() const {
78 if (InternalChildCount() == 0) 68 if (InternalChildCount() == 0)
79 return true; 69 return true;
80 70
81 // These types of objects may have children that we use as internal 71 // These types of objects may have children that we use as internal
82 // implementation details, but we want to expose them as leaves to platform 72 // implementation details, but we want to expose them as leaves to platform
83 // accessibility APIs because screen readers might be confused if they find 73 // accessibility APIs because screen readers might be confused if they find
84 // any children. 74 // any children.
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 bounds.Offset(-sx, -sy); 1122 bounds.Offset(-sx, -sy);
1133 } 1123 }
1134 } 1124 }
1135 1125
1136 node = container; 1126 node = container;
1137 } 1127 }
1138 1128
1139 return gfx::ToEnclosingRect(bounds); 1129 return gfx::ToEnclosingRect(bounds);
1140 } 1130 }
1141 1131
1132 gfx::NativeViewAccessible BrowserAccessibility::GetNativeViewAccessible() {
1133 NOTREACHED();
dmazzoni 2017/05/19 19:36:42 Maybe add a comment saying we should implement thi
1134 return nullptr;
1135 }
1136
1142 // 1137 //
1143 // AXPlatformNodeDelegate. 1138 // AXPlatformNodeDelegate.
1144 // 1139 //
1145 const ui::AXNodeData& BrowserAccessibility::GetData() const { 1140 const ui::AXNodeData& BrowserAccessibility::GetData() const {
1146 CR_DEFINE_STATIC_LOCAL(ui::AXNodeData, empty_data, ()); 1141 CR_DEFINE_STATIC_LOCAL(ui::AXNodeData, empty_data, ());
1147 if (node_) 1142 if (node_)
1148 return node_->data(); 1143 return node_->data();
1149 else 1144 else
1150 return empty_data; 1145 return empty_data;
1151 } 1146 }
1152 1147
1153 gfx::NativeWindow BrowserAccessibility::GetTopLevelWidget() { 1148 gfx::NativeWindow BrowserAccessibility::GetTopLevelWidget() {
1154 NOTREACHED(); 1149 NOTREACHED();
1155 return nullptr; 1150 return nullptr;
1156 } 1151 }
1157 1152
1158 gfx::NativeViewAccessible BrowserAccessibility::GetParent() { 1153 gfx::NativeViewAccessible BrowserAccessibility::GetParent() {
1159 auto* parent = PlatformGetParent(); 1154 auto* parent = PlatformGetParent();
1160 if (parent && parent->platform_node_) 1155 if (!parent)
1161 return parent->platform_node_->GetNativeViewAccessible(); 1156 return nullptr;
1162 return nullptr; 1157
1158 return parent->GetNativeViewAccessible();
1163 } 1159 }
1164 1160
1165 int BrowserAccessibility::GetChildCount() { 1161 int BrowserAccessibility::GetChildCount() {
1166 return PlatformChildCount(); 1162 return PlatformChildCount();
1167 } 1163 }
1168 1164
1169 gfx::NativeViewAccessible BrowserAccessibility::ChildAtIndex(int index) { 1165 gfx::NativeViewAccessible BrowserAccessibility::ChildAtIndex(int index) {
1170 auto* child = PlatformGetChild(index); 1166 auto* child = PlatformGetChild(index);
1171 if (child && child->platform_node_) 1167 if (!child)
1172 return child->platform_node_->GetNativeViewAccessible(); 1168 return nullptr;
1173 return nullptr; 1169
1170 return child->GetNativeViewAccessible();
1174 } 1171 }
1175 1172
1176 gfx::Rect BrowserAccessibility::GetScreenBoundsRect() const { 1173 gfx::Rect BrowserAccessibility::GetScreenBoundsRect() const {
1177 gfx::Rect bounds = GetPageBoundsRect(); 1174 gfx::Rect bounds = GetPageBoundsRect();
1178 1175
1179 // Adjust the bounds by the top left corner of the containing view's bounds 1176 // Adjust the bounds by the top left corner of the containing view's bounds
1180 // in screen coordinates. 1177 // in screen coordinates.
1181 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); 1178 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin());
1182 1179
1183 return bounds; 1180 return bounds;
(...skipping 15 matching lines...) Expand all
1199 return gfx::kNullAcceleratedWidget; 1196 return gfx::kNullAcceleratedWidget;
1200 } 1197 }
1201 1198
1202 bool BrowserAccessibility::AccessibilityPerformAction( 1199 bool BrowserAccessibility::AccessibilityPerformAction(
1203 const ui::AXActionData& data) { 1200 const ui::AXActionData& data) {
1204 NOTREACHED(); 1201 NOTREACHED();
1205 return false; 1202 return false;
1206 } 1203 }
1207 1204
1208 } // namespace content 1205 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility.h ('k') | content/browser/accessibility/browser_accessibility_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698