Chromium Code Reviews| 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" |
| 11 #include "content/browser/accessibility/browser_accessibility_manager.h" | 11 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 12 #include "content/common/accessibility_messages.h" | 12 #include "content/common/accessibility_messages.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 typedef AccessibilityNodeData::BoolAttribute BoolAttribute; | 16 typedef ui::AXBoolAttribute BoolAttribute; |
| 17 typedef AccessibilityNodeData::FloatAttribute FloatAttribute; | 17 typedef ui::AXFloatAttribute FloatAttribute; |
|
David Tseng
2014/01/06 18:13:55
Optional: I wonder if it wouldn't be easier to hav
dmazzoni
2014/01/06 19:19:58
I got rid of the typedefs. It's only saving 6 char
| |
| 18 typedef AccessibilityNodeData::IntAttribute IntAttribute; | 18 typedef ui::AXIntAttribute IntAttribute; |
| 19 typedef AccessibilityNodeData::StringAttribute StringAttribute; | 19 typedef ui::AXStringAttribute StringAttribute; |
| 20 | 20 |
| 21 #if !defined(OS_MACOSX) && \ | 21 #if !defined(OS_MACOSX) && \ |
| 22 !defined(OS_WIN) && \ | 22 !defined(OS_WIN) && \ |
| 23 !defined(TOOLKIT_GTK) && \ | 23 !defined(TOOLKIT_GTK) && \ |
| 24 !defined(OS_ANDROID) | 24 !defined(OS_ANDROID) |
| 25 // We have subclassess of BrowserAccessibility on Mac, Linux/GTK, | 25 // We have subclassess of BrowserAccessibility on Mac, Linux/GTK, |
| 26 // and Win. For any other platform, instantiate the base class. | 26 // and Win. For any other platform, instantiate the base class. |
| 27 // static | 27 // static |
| 28 BrowserAccessibility* BrowserAccessibility::Create() { | 28 BrowserAccessibility* BrowserAccessibility::Create() { |
| 29 return new BrowserAccessibility(); | 29 return new BrowserAccessibility(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool BrowserAccessibility::PlatformIsLeaf() const { | 46 bool BrowserAccessibility::PlatformIsLeaf() const { |
| 47 if (child_count() == 0) | 47 if (child_count() == 0) |
| 48 return true; | 48 return true; |
| 49 | 49 |
| 50 // All of these roles may have children that we use as internal | 50 // All of these roles may have children that we use as internal |
| 51 // implementation details, but we want to expose them as leaves | 51 // implementation details, but we want to expose them as leaves |
| 52 // to platform accessibility APIs. | 52 // to platform accessibility APIs. |
| 53 switch (role_) { | 53 switch (role_) { |
| 54 case blink::WebAXRoleEditableText: | 54 case ui::AX_ROLE_EDITABLE_TEXT: |
| 55 case blink::WebAXRoleSlider: | 55 case ui::AX_ROLE_SLIDER: |
| 56 case blink::WebAXRoleStaticText: | 56 case ui::AX_ROLE_STATIC_TEXT: |
| 57 case blink::WebAXRoleTextArea: | 57 case ui::AX_ROLE_TEXT_AREA: |
| 58 case blink::WebAXRoleTextField: | 58 case ui::AX_ROLE_TEXT_FIELD: |
| 59 return true; | 59 return true; |
| 60 default: | 60 default: |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 uint32 BrowserAccessibility::PlatformChildCount() const { | 65 uint32 BrowserAccessibility::PlatformChildCount() const { |
| 66 return PlatformIsLeaf() ? 0 : children_.size(); | 66 return PlatformIsLeaf() ? 0 : children_.size(); |
| 67 } | 67 } |
| 68 | 68 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 79 BrowserAccessibilityManager* manager, | 79 BrowserAccessibilityManager* manager, |
| 80 BrowserAccessibility* parent, | 80 BrowserAccessibility* parent, |
| 81 int32 renderer_id, | 81 int32 renderer_id, |
| 82 int32 index_in_parent) { | 82 int32 index_in_parent) { |
| 83 manager_ = manager; | 83 manager_ = manager; |
| 84 parent_ = parent; | 84 parent_ = parent; |
| 85 renderer_id_ = renderer_id; | 85 renderer_id_ = renderer_id; |
| 86 index_in_parent_ = index_in_parent; | 86 index_in_parent_ = index_in_parent; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void BrowserAccessibility::InitializeData(const AccessibilityNodeData& src) { | 89 void BrowserAccessibility::InitializeData(const ui::AXNodeData& src) { |
| 90 DCHECK_EQ(renderer_id_, src.id); | 90 DCHECK_EQ(renderer_id_, src.id); |
| 91 role_ = src.role; | 91 role_ = src.role; |
| 92 state_ = src.state; | 92 state_ = src.state; |
| 93 string_attributes_ = src.string_attributes; | 93 string_attributes_ = src.string_attributes; |
| 94 int_attributes_ = src.int_attributes; | 94 int_attributes_ = src.int_attributes; |
| 95 float_attributes_ = src.float_attributes; | 95 float_attributes_ = src.float_attributes; |
| 96 bool_attributes_ = src.bool_attributes; | 96 bool_attributes_ = src.bool_attributes; |
| 97 intlist_attributes_ = src.intlist_attributes; | 97 intlist_attributes_ = src.intlist_attributes; |
| 98 html_attributes_ = src.html_attributes; | 98 html_attributes_ = src.html_attributes; |
| 99 location_ = src.location; | 99 location_ = src.location; |
| 100 instance_active_ = true; | 100 instance_active_ = true; |
| 101 | 101 |
| 102 GetStringAttribute(AccessibilityNodeData::ATTR_NAME, &name_); | 102 GetStringAttribute(ui::AX_ATTR_NAME, &name_); |
| 103 GetStringAttribute(AccessibilityNodeData::ATTR_VALUE, &value_); | 103 GetStringAttribute(ui::AX_ATTR_VALUE, &value_); |
| 104 | 104 |
| 105 PreInitialize(); | 105 PreInitialize(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool BrowserAccessibility::IsNative() const { | 108 bool BrowserAccessibility::IsNative() const { |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void BrowserAccessibility::SwapChildren( | 112 void BrowserAccessibility::SwapChildren( |
| 113 std::vector<BrowserAccessibility*>& children) { | 113 std::vector<BrowserAccessibility*>& children) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 } | 159 } |
| 160 | 160 |
| 161 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { | 161 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { |
| 162 gfx::Rect bounds = location_; | 162 gfx::Rect bounds = location_; |
| 163 | 163 |
| 164 // Walk up the parent chain. Every time we encounter a Web Area, offset | 164 // Walk up the parent chain. Every time we encounter a Web Area, offset |
| 165 // based on the scroll bars and then offset based on the origin of that | 165 // based on the scroll bars and then offset based on the origin of that |
| 166 // nested web area. | 166 // nested web area. |
| 167 BrowserAccessibility* parent = parent_; | 167 BrowserAccessibility* parent = parent_; |
| 168 bool need_to_offset_web_area = | 168 bool need_to_offset_web_area = |
| 169 (role_ == blink::WebAXRoleWebArea || | 169 (role_ == ui::AX_ROLE_WEB_AREA || |
| 170 role_ == blink::WebAXRoleRootWebArea); | 170 role_ == ui::AX_ROLE_ROOT_WEB_AREA); |
| 171 while (parent) { | 171 while (parent) { |
| 172 if (need_to_offset_web_area && | 172 if (need_to_offset_web_area && |
| 173 parent->location().width() > 0 && | 173 parent->location().width() > 0 && |
| 174 parent->location().height() > 0) { | 174 parent->location().height() > 0) { |
| 175 bounds.Offset(parent->location().x(), parent->location().y()); | 175 bounds.Offset(parent->location().x(), parent->location().y()); |
| 176 need_to_offset_web_area = false; | 176 need_to_offset_web_area = false; |
| 177 } | 177 } |
| 178 | 178 |
| 179 // On some platforms, we don't want to take the root scroll offsets | 179 // On some platforms, we don't want to take the root scroll offsets |
| 180 // into account. | 180 // into account. |
| 181 if (parent->role() == blink::WebAXRoleRootWebArea && | 181 if (parent->role() == ui::AX_ROLE_ROOT_WEB_AREA && |
| 182 !manager()->UseRootScrollOffsetsWhenComputingBounds()) { | 182 !manager()->UseRootScrollOffsetsWhenComputingBounds()) { |
| 183 break; | 183 break; |
| 184 } | 184 } |
| 185 | 185 |
| 186 if (parent->role() == blink::WebAXRoleWebArea || | 186 if (parent->role() == ui::AX_ROLE_WEB_AREA || |
| 187 parent->role() == blink::WebAXRoleRootWebArea) { | 187 parent->role() == ui::AX_ROLE_ROOT_WEB_AREA) { |
| 188 int sx = 0; | 188 int sx = 0; |
| 189 int sy = 0; | 189 int sy = 0; |
| 190 if (parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_X, &sx) && | 190 if (parent->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && |
| 191 parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_Y, &sy)) { | 191 parent->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { |
| 192 bounds.Offset(-sx, -sy); | 192 bounds.Offset(-sx, -sy); |
| 193 } | 193 } |
| 194 need_to_offset_web_area = true; | 194 need_to_offset_web_area = true; |
| 195 } | 195 } |
| 196 parent = parent->parent(); | 196 parent = parent->parent(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 return bounds; | 199 return bounds; |
| 200 } | 200 } |
| 201 | 201 |
| 202 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const { | 202 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const { |
| 203 gfx::Rect bounds = GetLocalBoundsRect(); | 203 gfx::Rect bounds = GetLocalBoundsRect(); |
| 204 | 204 |
| 205 // Adjust the bounds by the top left corner of the containing view's bounds | 205 // Adjust the bounds by the top left corner of the containing view's bounds |
| 206 // in screen coordinates. | 206 // in screen coordinates. |
| 207 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); | 207 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); |
| 208 | 208 |
| 209 return bounds; | 209 return bounds; |
| 210 } | 210 } |
| 211 | 211 |
| 212 gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) | 212 gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) |
| 213 const { | 213 const { |
| 214 if (role_ != blink::WebAXRoleStaticText) { | 214 if (role() != ui::AX_ROLE_STATIC_TEXT) { |
| 215 // Apply recursively to all static text descendants. For example, if | 215 // Apply recursively to all static text descendants. For example, if |
| 216 // you call it on a div with two text node children, it just calls | 216 // you call it on a div with two text node children, it just calls |
| 217 // GetLocalBoundsForRange on each of the two children (adjusting | 217 // GetLocalBoundsForRange on each of the two children (adjusting |
| 218 // |start| for each one) and unions the resulting rects. | 218 // |start| for each one) and unions the resulting rects. |
| 219 gfx::Rect bounds; | 219 gfx::Rect bounds; |
| 220 for (size_t i = 0; i < children_.size(); ++i) { | 220 for (size_t i = 0; i < children_.size(); ++i) { |
| 221 BrowserAccessibility* child = children_[i]; | 221 BrowserAccessibility* child = children_[i]; |
| 222 int child_len = child->GetStaticTextLenRecursive(); | 222 int child_len = child->GetStaticTextLenRecursive(); |
| 223 if (start < child_len && start + len > 0) { | 223 if (start < child_len && start + len > 0) { |
| 224 gfx::Rect child_rect = child->GetLocalBoundsForRange(start, len); | 224 gfx::Rect child_rect = child->GetLocalBoundsForRange(start, len); |
| 225 bounds.Union(child_rect); | 225 bounds.Union(child_rect); |
| 226 } | 226 } |
| 227 start -= child_len; | 227 start -= child_len; |
| 228 } | 228 } |
| 229 return bounds; | 229 return bounds; |
| 230 } | 230 } |
| 231 | 231 |
| 232 int end = start + len; | 232 int end = start + len; |
| 233 int child_start = 0; | 233 int child_start = 0; |
| 234 int child_end = 0; | 234 int child_end = 0; |
| 235 | 235 |
| 236 gfx::Rect bounds; | 236 gfx::Rect bounds; |
| 237 for (size_t i = 0; i < children_.size() && child_end < start + len; ++i) { | 237 for (size_t i = 0; i < children_.size() && child_end < start + len; ++i) { |
| 238 BrowserAccessibility* child = children_[i]; | 238 BrowserAccessibility* child = children_[i]; |
| 239 DCHECK_EQ(child->role(), blink::WebAXRoleInlineTextBox); | 239 DCHECK_EQ(child->role(), ui::AX_ROLE_INLINE_TEXT_BOX); |
| 240 std::string child_text; | 240 std::string child_text; |
| 241 child->GetStringAttribute(AccessibilityNodeData::ATTR_VALUE, &child_text); | 241 child->GetStringAttribute(ui::AX_ATTR_VALUE, &child_text); |
| 242 int child_len = static_cast<int>(child_text.size()); | 242 int child_len = static_cast<int>(child_text.size()); |
| 243 child_start = child_end; | 243 child_start = child_end; |
| 244 child_end += child_len; | 244 child_end += child_len; |
| 245 | 245 |
| 246 if (child_end < start) | 246 if (child_end < start) |
| 247 continue; | 247 continue; |
| 248 | 248 |
| 249 int overlap_start = std::max(start, child_start); | 249 int overlap_start = std::max(start, child_start); |
| 250 int overlap_end = std::min(end, child_end); | 250 int overlap_end = std::min(end, child_end); |
| 251 | 251 |
| 252 int local_start = overlap_start - child_start; | 252 int local_start = overlap_start - child_start; |
| 253 int local_end = overlap_end - child_start; | 253 int local_end = overlap_end - child_start; |
| 254 | 254 |
| 255 gfx::Rect child_rect = child->location(); | 255 gfx::Rect child_rect = child->location(); |
| 256 int text_direction = child->GetIntAttribute( | 256 int text_direction = child->GetIntAttribute( |
| 257 AccessibilityNodeData::ATTR_TEXT_DIRECTION); | 257 ui::AX_ATTR_TEXT_DIRECTION); |
| 258 const std::vector<int32>& character_offsets = child->GetIntListAttribute( | 258 const std::vector<int32>& character_offsets = child->GetIntListAttribute( |
| 259 AccessibilityNodeData::ATTR_CHARACTER_OFFSETS); | 259 ui::AX_ATTR_CHARACTER_OFFSETS); |
| 260 int start_pixel_offset = | 260 int start_pixel_offset = |
| 261 local_start > 0 ? character_offsets[local_start - 1] : 0; | 261 local_start > 0 ? character_offsets[local_start - 1] : 0; |
| 262 int end_pixel_offset = | 262 int end_pixel_offset = |
| 263 local_end > 0 ? character_offsets[local_end - 1] : 0; | 263 local_end > 0 ? character_offsets[local_end - 1] : 0; |
| 264 | 264 |
| 265 gfx::Rect child_overlap_rect; | 265 gfx::Rect child_overlap_rect; |
| 266 switch (text_direction) { | 266 switch (text_direction) { |
| 267 case blink::WebAXTextDirectionLR: { | 267 case ui::AX_TEXT_DIRECTION_LR: { |
| 268 int left = child_rect.x() + start_pixel_offset; | 268 int left = child_rect.x() + start_pixel_offset; |
| 269 int right = child_rect.x() + end_pixel_offset; | 269 int right = child_rect.x() + end_pixel_offset; |
| 270 child_overlap_rect = gfx::Rect(left, child_rect.y(), | 270 child_overlap_rect = gfx::Rect(left, child_rect.y(), |
| 271 right - left, child_rect.height()); | 271 right - left, child_rect.height()); |
| 272 break; | 272 break; |
| 273 } | 273 } |
| 274 case blink::WebAXTextDirectionRL: { | 274 case ui::AX_TEXT_DIRECTION_RL: { |
| 275 int right = child_rect.right() - start_pixel_offset; | 275 int right = child_rect.right() - start_pixel_offset; |
| 276 int left = child_rect.right() - end_pixel_offset; | 276 int left = child_rect.right() - end_pixel_offset; |
| 277 child_overlap_rect = gfx::Rect(left, child_rect.y(), | 277 child_overlap_rect = gfx::Rect(left, child_rect.y(), |
| 278 right - left, child_rect.height()); | 278 right - left, child_rect.height()); |
| 279 break; | 279 break; |
| 280 } | 280 } |
| 281 case blink::WebAXTextDirectionTB: { | 281 case ui::AX_TEXT_DIRECTION_TB: { |
| 282 int top = child_rect.y() + start_pixel_offset; | 282 int top = child_rect.y() + start_pixel_offset; |
| 283 int bottom = child_rect.y() + end_pixel_offset; | 283 int bottom = child_rect.y() + end_pixel_offset; |
| 284 child_overlap_rect = gfx::Rect(child_rect.x(), top, | 284 child_overlap_rect = gfx::Rect(child_rect.x(), top, |
| 285 child_rect.width(), bottom - top); | 285 child_rect.width(), bottom - top); |
| 286 break; | 286 break; |
| 287 } | 287 } |
| 288 case blink::WebAXTextDirectionBT: { | 288 case ui::AX_TEXT_DIRECTION_BT: { |
| 289 int bottom = child_rect.bottom() - start_pixel_offset; | 289 int bottom = child_rect.bottom() - start_pixel_offset; |
| 290 int top = child_rect.bottom() - end_pixel_offset; | 290 int top = child_rect.bottom() - end_pixel_offset; |
| 291 child_overlap_rect = gfx::Rect(child_rect.x(), top, | 291 child_overlap_rect = gfx::Rect(child_rect.x(), top, |
| 292 child_rect.width(), bottom - top); | 292 child_rect.width(), bottom - top); |
| 293 break; | 293 break; |
| 294 } | 294 } |
| 295 default: | 295 default: |
| 296 NOTREACHED(); | 296 NOTREACHED(); |
| 297 } | 297 } |
| 298 | 298 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 ++iter) { | 334 ++iter) { |
| 335 (*iter)->Destroy(); | 335 (*iter)->Destroy(); |
| 336 } | 336 } |
| 337 children_.clear(); | 337 children_.clear(); |
| 338 | 338 |
| 339 // Allow the object to fire a TextRemoved notification. | 339 // Allow the object to fire a TextRemoved notification. |
| 340 name_.clear(); | 340 name_.clear(); |
| 341 value_.clear(); | 341 value_.clear(); |
| 342 PostInitialize(); | 342 PostInitialize(); |
| 343 | 343 |
| 344 manager_->NotifyAccessibilityEvent( | 344 manager_->NotifyAccessibilityEvent(ui::AX_EVENT_HIDE, this); |
| 345 blink::WebAXEventHide, this); | |
| 346 | 345 |
| 347 instance_active_ = false; | 346 instance_active_ = false; |
| 348 manager_->RemoveNode(this); | 347 manager_->RemoveNode(this); |
| 349 NativeReleaseReference(); | 348 NativeReleaseReference(); |
| 350 } | 349 } |
| 351 | 350 |
| 352 void BrowserAccessibility::NativeReleaseReference() { | 351 void BrowserAccessibility::NativeReleaseReference() { |
| 353 delete this; | 352 delete this; |
| 354 } | 353 } |
| 355 | 354 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 if (string_attributes_[i].first == attribute) { | 499 if (string_attributes_[i].first == attribute) { |
| 501 string_attributes_[i].second = value; | 500 string_attributes_[i].second = value; |
| 502 return; | 501 return; |
| 503 } | 502 } |
| 504 } | 503 } |
| 505 if (!value.empty()) | 504 if (!value.empty()) |
| 506 string_attributes_.push_back(std::make_pair(attribute, value)); | 505 string_attributes_.push_back(std::make_pair(attribute, value)); |
| 507 } | 506 } |
| 508 | 507 |
| 509 bool BrowserAccessibility::HasIntListAttribute( | 508 bool BrowserAccessibility::HasIntListAttribute( |
| 510 AccessibilityNodeData::IntListAttribute attribute) const { | 509 ui::AXIntListAttribute attribute) const { |
| 511 for (size_t i = 0; i < intlist_attributes_.size(); ++i) { | 510 for (size_t i = 0; i < intlist_attributes_.size(); ++i) { |
| 512 if (intlist_attributes_[i].first == attribute) | 511 if (intlist_attributes_[i].first == attribute) |
| 513 return true; | 512 return true; |
| 514 } | 513 } |
| 515 | 514 |
| 516 return false; | 515 return false; |
| 517 } | 516 } |
| 518 | 517 |
| 519 const std::vector<int32>& BrowserAccessibility::GetIntListAttribute( | 518 const std::vector<int32>& BrowserAccessibility::GetIntListAttribute( |
| 520 AccessibilityNodeData::IntListAttribute attribute) const { | 519 ui::AXIntListAttribute attribute) const { |
| 521 CR_DEFINE_STATIC_LOCAL(std::vector<int32>, empty_vector, ()); | 520 CR_DEFINE_STATIC_LOCAL(std::vector<int32>, empty_vector, ()); |
| 522 for (size_t i = 0; i < intlist_attributes_.size(); ++i) { | 521 for (size_t i = 0; i < intlist_attributes_.size(); ++i) { |
| 523 if (intlist_attributes_[i].first == attribute) | 522 if (intlist_attributes_[i].first == attribute) |
| 524 return intlist_attributes_[i].second; | 523 return intlist_attributes_[i].second; |
| 525 } | 524 } |
| 526 | 525 |
| 527 return empty_vector; | 526 return empty_vector; |
| 528 } | 527 } |
| 529 | 528 |
| 530 bool BrowserAccessibility::GetIntListAttribute( | 529 bool BrowserAccessibility::GetIntListAttribute( |
| 531 AccessibilityNodeData::IntListAttribute attribute, | 530 ui::AXIntListAttribute attribute, |
| 532 std::vector<int32>* value) const { | 531 std::vector<int32>* value) const { |
| 533 for (size_t i = 0; i < intlist_attributes_.size(); ++i) { | 532 for (size_t i = 0; i < intlist_attributes_.size(); ++i) { |
| 534 if (intlist_attributes_[i].first == attribute) { | 533 if (intlist_attributes_[i].first == attribute) { |
| 535 *value = intlist_attributes_[i].second; | 534 *value = intlist_attributes_[i].second; |
| 536 return true; | 535 return true; |
| 537 } | 536 } |
| 538 } | 537 } |
| 539 | 538 |
| 540 return false; | 539 return false; |
| 541 } | 540 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 | 579 |
| 581 if (EqualsASCII(value, "true")) | 580 if (EqualsASCII(value, "true")) |
| 582 return true; | 581 return true; |
| 583 | 582 |
| 584 if (EqualsASCII(value, "mixed")) | 583 if (EqualsASCII(value, "mixed")) |
| 585 *is_mixed = true; | 584 *is_mixed = true; |
| 586 | 585 |
| 587 return false; // Not set | 586 return false; // Not set |
| 588 } | 587 } |
| 589 | 588 |
| 590 bool BrowserAccessibility::HasState(blink::WebAXState state_enum) const { | 589 bool BrowserAccessibility::HasState(ui::AXState state_enum) const { |
| 591 return (state_ >> state_enum) & 1; | 590 return (state_ >> state_enum) & 1; |
| 592 } | 591 } |
| 593 | 592 |
| 594 bool BrowserAccessibility::IsEditableText() const { | 593 bool BrowserAccessibility::IsEditableText() const { |
| 595 // These roles don't have readonly set, but they're not editable text. | 594 // These roles don't have readonly set, but they're not editable text. |
| 596 if (role_ == blink::WebAXRoleScrollArea || | 595 if (role_ == ui::AX_ROLE_SCROLL_AREA || |
| 597 role_ == blink::WebAXRoleColumn || | 596 role_ == ui::AX_ROLE_COLUMN || |
| 598 role_ == blink::WebAXRoleTableHeaderContainer) { | 597 role_ == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { |
| 599 return false; | 598 return false; |
| 600 } | 599 } |
| 601 | 600 |
| 602 // Note: WebAXStateReadonly being false means it's either a text control, | 601 // Note: WebAXStateReadonly being false means it's either a text control, |
| 603 // or contenteditable. We also check for editable text roles to cover | 602 // or contenteditable. We also check for editable text roles to cover |
| 604 // another element that has role=textbox set on it. | 603 // another element that has role=textbox set on it. |
| 605 return (!HasState(blink::WebAXStateReadonly) || | 604 return (!HasState(ui::AX_STATE_READONLY) || |
| 606 role_ == blink::WebAXRoleTextField || | 605 role_ == ui::AX_ROLE_TEXT_FIELD || |
| 607 role_ == blink::WebAXRoleTextArea); | 606 role_ == ui::AX_ROLE_TEXT_AREA); |
| 608 } | 607 } |
| 609 | 608 |
| 610 std::string BrowserAccessibility::GetTextRecursive() const { | 609 std::string BrowserAccessibility::GetTextRecursive() const { |
| 611 if (!name_.empty()) { | 610 if (!name_.empty()) { |
| 612 return name_; | 611 return name_; |
| 613 } | 612 } |
| 614 | 613 |
| 615 std::string result; | 614 std::string result; |
| 616 for (uint32 i = 0; i < PlatformChildCount(); ++i) | 615 for (uint32 i = 0; i < PlatformChildCount(); ++i) |
| 617 result += PlatformGetChild(i)->GetTextRecursive(); | 616 result += PlatformGetChild(i)->GetTextRecursive(); |
| 618 return result; | 617 return result; |
| 619 } | 618 } |
| 620 | 619 |
| 621 int BrowserAccessibility::GetStaticTextLenRecursive() const { | 620 int BrowserAccessibility::GetStaticTextLenRecursive() const { |
| 622 if (role_ == blink::WebAXRoleStaticText) { | 621 if (role_ == blink::WebAXRoleStaticText) |
| 623 return static_cast<int>( | 622 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); |
| 624 GetStringAttribute(AccessibilityNodeData::ATTR_VALUE).size()); | |
| 625 } | |
| 626 | 623 |
| 627 int len = 0; | 624 int len = 0; |
| 628 for (size_t i = 0; i < children_.size(); ++i) | 625 for (size_t i = 0; i < children_.size(); ++i) |
| 629 len += children_[i]->GetStaticTextLenRecursive(); | 626 len += children_[i]->GetStaticTextLenRecursive(); |
| 630 return len; | 627 return len; |
| 631 } | 628 } |
| 632 | 629 |
| 633 } // namespace content | 630 } // namespace content |
| OLD | NEW |