OLD | NEW |
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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "content/browser/accessibility/browser_accessibility_manager.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager.h" |
11 #include "content/common/accessibility_messages.h" | 11 #include "content/common/accessibility_messages.h" |
12 | 12 |
13 typedef WebAccessibility::BoolAttribute BoolAttribute; | 13 typedef AccessibilityNodeData::BoolAttribute BoolAttribute; |
14 typedef WebAccessibility::FloatAttribute FloatAttribute; | 14 typedef AccessibilityNodeData::FloatAttribute FloatAttribute; |
15 typedef WebAccessibility::IntAttribute IntAttribute; | 15 typedef AccessibilityNodeData::IntAttribute IntAttribute; |
16 typedef WebAccessibility::StringAttribute StringAttribute; | 16 typedef AccessibilityNodeData::StringAttribute StringAttribute; |
17 | 17 |
18 #if !defined(OS_MACOSX) && \ | 18 #if !defined(OS_MACOSX) && \ |
19 !(defined(OS_WIN) && !defined(USE_AURA)) && \ | 19 !(defined(OS_WIN) && !defined(USE_AURA)) && \ |
20 !defined(TOOLKIT_GTK) | 20 !defined(TOOLKIT_GTK) |
21 // We have subclassess of BrowserAccessibility on Mac, Linux/GTK, | 21 // We have subclassess of BrowserAccessibility on Mac, Linux/GTK, |
22 // and non-Aura Win. For any other platform, instantiate the base class. | 22 // and non-Aura Win. For any other platform, instantiate the base class. |
23 // static | 23 // static |
24 BrowserAccessibility* BrowserAccessibility::Create() { | 24 BrowserAccessibility* BrowserAccessibility::Create() { |
25 return new BrowserAccessibility(); | 25 return new BrowserAccessibility(); |
26 } | 26 } |
(...skipping 21 matching lines...) Expand all Loading... |
48 children_[i]->DetachTree(nodes); | 48 children_[i]->DetachTree(nodes); |
49 children_.clear(); | 49 children_.clear(); |
50 parent_ = NULL; | 50 parent_ = NULL; |
51 } | 51 } |
52 | 52 |
53 void BrowserAccessibility::PreInitialize( | 53 void BrowserAccessibility::PreInitialize( |
54 BrowserAccessibilityManager* manager, | 54 BrowserAccessibilityManager* manager, |
55 BrowserAccessibility* parent, | 55 BrowserAccessibility* parent, |
56 int32 child_id, | 56 int32 child_id, |
57 int32 index_in_parent, | 57 int32 index_in_parent, |
58 const webkit_glue::WebAccessibility& src) { | 58 const AccessibilityNodeData& src) { |
59 manager_ = manager; | 59 manager_ = manager; |
60 parent_ = parent; | 60 parent_ = parent; |
61 child_id_ = child_id; | 61 child_id_ = child_id; |
62 index_in_parent_ = index_in_parent; | 62 index_in_parent_ = index_in_parent; |
63 | 63 |
64 // Update all of the rest of the attributes. | 64 // Update all of the rest of the attributes. |
65 name_ = src.name; | 65 name_ = src.name; |
66 value_ = src.value; | 66 value_ = src.value; |
67 role_ = src.role; | 67 role_ = src.role; |
68 state_ = src.state; | 68 state_ = src.state; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return NULL; | 128 return NULL; |
129 } | 129 } |
130 | 130 |
131 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() { | 131 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() { |
132 gfx::Rect bounds = location_; | 132 gfx::Rect bounds = location_; |
133 | 133 |
134 // Adjust top left position by the root document's scroll offset. | 134 // Adjust top left position by the root document's scroll offset. |
135 BrowserAccessibility* root = manager_->GetRoot(); | 135 BrowserAccessibility* root = manager_->GetRoot(); |
136 int scroll_x = 0; | 136 int scroll_x = 0; |
137 int scroll_y = 0; | 137 int scroll_y = 0; |
138 if (!root->GetIntAttribute(WebAccessibility::ATTR_SCROLL_X, &scroll_x) || | 138 if (!root->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_X, &scroll_x) || |
139 !root->GetIntAttribute(WebAccessibility::ATTR_SCROLL_Y, &scroll_y)) { | 139 !root->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_Y, &scroll_y)) { |
140 return bounds; | 140 return bounds; |
141 } | 141 } |
142 bounds.Offset(-scroll_x, -scroll_y); | 142 bounds.Offset(-scroll_x, -scroll_y); |
143 | 143 |
144 return bounds; | 144 return bounds; |
145 } | 145 } |
146 | 146 |
147 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() { | 147 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() { |
148 gfx::Rect bounds = GetLocalBoundsRect(); | 148 gfx::Rect bounds = GetLocalBoundsRect(); |
149 | 149 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 if (EqualsASCII(value, "true")) | 285 if (EqualsASCII(value, "true")) |
286 return true; | 286 return true; |
287 | 287 |
288 if (EqualsASCII(value, "mixed")) | 288 if (EqualsASCII(value, "mixed")) |
289 *is_mixed = true; | 289 *is_mixed = true; |
290 | 290 |
291 return false; // Not set | 291 return false; // Not set |
292 } | 292 } |
293 | 293 |
294 bool BrowserAccessibility::HasState(WebAccessibility::State state_enum) const { | 294 bool BrowserAccessibility::HasState( |
| 295 AccessibilityNodeData::State state_enum) const { |
295 return (state_ >> state_enum) & 1; | 296 return (state_ >> state_enum) & 1; |
296 } | 297 } |
297 | 298 |
298 bool BrowserAccessibility::IsEditableText() const { | 299 bool BrowserAccessibility::IsEditableText() const { |
299 // Note: STATE_READONLY being false means it's either a text control, | 300 // Note: STATE_READONLY being false means it's either a text control, |
300 // or contenteditable. We also check for editable text roles to cover | 301 // or contenteditable. We also check for editable text roles to cover |
301 // another element that has role=textbox set on it. | 302 // another element that has role=textbox set on it. |
302 return (!HasState(WebAccessibility::STATE_READONLY) || | 303 return (!HasState(AccessibilityNodeData::STATE_READONLY) || |
303 role_ == WebAccessibility::ROLE_TEXT_FIELD || | 304 role_ == AccessibilityNodeData::ROLE_TEXT_FIELD || |
304 role_ == WebAccessibility::ROLE_TEXTAREA); | 305 role_ == AccessibilityNodeData::ROLE_TEXTAREA); |
305 } | 306 } |
306 | 307 |
307 string16 BrowserAccessibility::GetTextRecursive() const { | 308 string16 BrowserAccessibility::GetTextRecursive() const { |
308 if (!name_.empty()) { | 309 if (!name_.empty()) { |
309 return name_; | 310 return name_; |
310 } | 311 } |
311 | 312 |
312 string16 result; | 313 string16 result; |
313 for (size_t i = 0; i < children_.size(); ++i) | 314 for (size_t i = 0; i < children_.size(); ++i) |
314 result += children_[i]->GetTextRecursive(); | 315 result += children_[i]->GetTextRecursive(); |
315 return result; | 316 return result; |
316 } | 317 } |
317 | 318 |
318 void BrowserAccessibility::PreInitialize() { | 319 void BrowserAccessibility::PreInitialize() { |
319 instance_active_ = true; | 320 instance_active_ = true; |
320 } | 321 } |
OLD | NEW |