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/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { | 137 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { |
138 gfx::Rect bounds = location_; | 138 gfx::Rect bounds = location_; |
139 | 139 |
140 // Walk up the parent chain. Every time we encounter a Web Area, offset | 140 // Walk up the parent chain. Every time we encounter a Web Area, offset |
141 // based on the scroll bars and then offset based on the origin of that | 141 // based on the scroll bars and then offset based on the origin of that |
142 // nested web area. | 142 // nested web area. |
143 BrowserAccessibility* parent = parent_; | 143 BrowserAccessibility* parent = parent_; |
144 bool need_to_offset_web_area = | 144 bool need_to_offset_web_area = |
145 (role_ == AccessibilityNodeData::ROLE_WEB_AREA || | 145 (role_ == WebKit::WebAXRoleWebArea || |
146 role_ == AccessibilityNodeData::ROLE_ROOT_WEB_AREA); | 146 role_ == WebKit::WebAXRoleRootWebArea); |
147 while (parent) { | 147 while (parent) { |
148 if (need_to_offset_web_area && | 148 if (need_to_offset_web_area && |
149 parent->location().width() > 0 && | 149 parent->location().width() > 0 && |
150 parent->location().height() > 0) { | 150 parent->location().height() > 0) { |
151 bounds.Offset(parent->location().x(), parent->location().y()); | 151 bounds.Offset(parent->location().x(), parent->location().y()); |
152 need_to_offset_web_area = false; | 152 need_to_offset_web_area = false; |
153 } | 153 } |
154 | 154 |
155 // On some platforms, we don't want to take the root scroll offsets | 155 // On some platforms, we don't want to take the root scroll offsets |
156 // into account. | 156 // into account. |
157 if (parent->role() == AccessibilityNodeData::ROLE_ROOT_WEB_AREA && | 157 if (parent->role() == WebKit::WebAXRoleRootWebArea && |
158 !manager()->UseRootScrollOffsetsWhenComputingBounds()) { | 158 !manager()->UseRootScrollOffsetsWhenComputingBounds()) { |
159 break; | 159 break; |
160 } | 160 } |
161 | 161 |
162 if (parent->role() == AccessibilityNodeData::ROLE_WEB_AREA || | 162 if (parent->role() == WebKit::WebAXRoleWebArea || |
163 parent->role() == AccessibilityNodeData::ROLE_ROOT_WEB_AREA) { | 163 parent->role() == WebKit::WebAXRoleRootWebArea) { |
164 int sx = 0; | 164 int sx = 0; |
165 int sy = 0; | 165 int sy = 0; |
166 if (parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_X, &sx) && | 166 if (parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_X, &sx) && |
167 parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_Y, &sy)) { | 167 parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_Y, &sy)) { |
168 bounds.Offset(-sx, -sy); | 168 bounds.Offset(-sx, -sy); |
169 } | 169 } |
170 need_to_offset_web_area = true; | 170 need_to_offset_web_area = true; |
171 } | 171 } |
172 parent = parent->parent(); | 172 parent = parent->parent(); |
173 } | 173 } |
(...skipping 30 matching lines...) Expand all Loading... |
204 (*iter)->Destroy(); | 204 (*iter)->Destroy(); |
205 } | 205 } |
206 children_.clear(); | 206 children_.clear(); |
207 | 207 |
208 // Allow the object to fire a TextRemoved notification. | 208 // Allow the object to fire a TextRemoved notification. |
209 name_.clear(); | 209 name_.clear(); |
210 value_.clear(); | 210 value_.clear(); |
211 PostInitialize(); | 211 PostInitialize(); |
212 | 212 |
213 manager_->NotifyAccessibilityEvent( | 213 manager_->NotifyAccessibilityEvent( |
214 AccessibilityNotificationObjectHide, this); | 214 WebKit::WebAXEventHide, this); |
215 | 215 |
216 instance_active_ = false; | 216 instance_active_ = false; |
217 manager_->RemoveNode(this); | 217 manager_->RemoveNode(this); |
218 NativeReleaseReference(); | 218 NativeReleaseReference(); |
219 } | 219 } |
220 | 220 |
221 void BrowserAccessibility::NativeReleaseReference() { | 221 void BrowserAccessibility::NativeReleaseReference() { |
222 delete this; | 222 delete this; |
223 } | 223 } |
224 | 224 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 if (EqualsASCII(value, "true")) | 450 if (EqualsASCII(value, "true")) |
451 return true; | 451 return true; |
452 | 452 |
453 if (EqualsASCII(value, "mixed")) | 453 if (EqualsASCII(value, "mixed")) |
454 *is_mixed = true; | 454 *is_mixed = true; |
455 | 455 |
456 return false; // Not set | 456 return false; // Not set |
457 } | 457 } |
458 | 458 |
459 bool BrowserAccessibility::HasState( | 459 bool BrowserAccessibility::HasState(WebKit::WebAXState state_enum) const { |
460 AccessibilityNodeData::State state_enum) const { | |
461 return (state_ >> state_enum) & 1; | 460 return (state_ >> state_enum) & 1; |
462 } | 461 } |
463 | 462 |
464 bool BrowserAccessibility::IsEditableText() const { | 463 bool BrowserAccessibility::IsEditableText() const { |
465 // These roles don't have readonly set, but they're not editable text. | 464 // These roles don't have readonly set, but they're not editable text. |
466 if (role_ == AccessibilityNodeData::ROLE_SCROLLAREA || | 465 if (role_ == WebKit::WebAXRoleScrollArea || |
467 role_ == AccessibilityNodeData::ROLE_COLUMN || | 466 role_ == WebKit::WebAXRoleColumn || |
468 role_ == AccessibilityNodeData::ROLE_TABLE_HEADER_CONTAINER) { | 467 role_ == WebKit::WebAXRoleTableHeaderContainer) { |
469 return false; | 468 return false; |
470 } | 469 } |
471 | 470 |
472 // Note: STATE_READONLY being false means it's either a text control, | 471 // Note: WebAXStateReadonly being false means it's either a text control, |
473 // or contenteditable. We also check for editable text roles to cover | 472 // or contenteditable. We also check for editable text roles to cover |
474 // another element that has role=textbox set on it. | 473 // another element that has role=textbox set on it. |
475 return (!HasState(AccessibilityNodeData::STATE_READONLY) || | 474 return (!HasState(WebKit::WebAXStateReadonly) || |
476 role_ == AccessibilityNodeData::ROLE_TEXT_FIELD || | 475 role_ == WebKit::WebAXRoleTextField || |
477 role_ == AccessibilityNodeData::ROLE_TEXTAREA); | 476 role_ == WebKit::WebAXRoleTextArea); |
478 } | 477 } |
479 | 478 |
480 std::string BrowserAccessibility::GetTextRecursive() const { | 479 std::string BrowserAccessibility::GetTextRecursive() const { |
481 if (!name_.empty()) { | 480 if (!name_.empty()) { |
482 return name_; | 481 return name_; |
483 } | 482 } |
484 | 483 |
485 std::string result; | 484 std::string result; |
486 for (size_t i = 0; i < children_.size(); ++i) | 485 for (size_t i = 0; i < children_.size(); ++i) |
487 result += children_[i]->GetTextRecursive(); | 486 result += children_[i]->GetTextRecursive(); |
488 return result; | 487 return result; |
489 } | 488 } |
490 | 489 |
491 } // namespace content | 490 } // namespace content |
OLD | NEW |