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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 ui::AX_ATTR_TEXT_DIRECTION); | 252 ui::AX_ATTR_TEXT_DIRECTION); |
253 const std::vector<int32>& character_offsets = child->GetIntListAttribute( | 253 const std::vector<int32>& character_offsets = child->GetIntListAttribute( |
254 ui::AX_ATTR_CHARACTER_OFFSETS); | 254 ui::AX_ATTR_CHARACTER_OFFSETS); |
255 int start_pixel_offset = | 255 int start_pixel_offset = |
256 local_start > 0 ? character_offsets[local_start - 1] : 0; | 256 local_start > 0 ? character_offsets[local_start - 1] : 0; |
257 int end_pixel_offset = | 257 int end_pixel_offset = |
258 local_end > 0 ? character_offsets[local_end - 1] : 0; | 258 local_end > 0 ? character_offsets[local_end - 1] : 0; |
259 | 259 |
260 gfx::Rect child_overlap_rect; | 260 gfx::Rect child_overlap_rect; |
261 switch (text_direction) { | 261 switch (text_direction) { |
| 262 case ui::AX_TEXT_DIRECTION_NONE: |
262 case ui::AX_TEXT_DIRECTION_LR: { | 263 case ui::AX_TEXT_DIRECTION_LR: { |
263 int left = child_rect.x() + start_pixel_offset; | 264 int left = child_rect.x() + start_pixel_offset; |
264 int right = child_rect.x() + end_pixel_offset; | 265 int right = child_rect.x() + end_pixel_offset; |
265 child_overlap_rect = gfx::Rect(left, child_rect.y(), | 266 child_overlap_rect = gfx::Rect(left, child_rect.y(), |
266 right - left, child_rect.height()); | 267 right - left, child_rect.height()); |
267 break; | 268 break; |
268 } | 269 } |
269 case ui::AX_TEXT_DIRECTION_RL: { | 270 case ui::AX_TEXT_DIRECTION_RL: { |
270 int right = child_rect.right() - start_pixel_offset; | 271 int right = child_rect.right() - start_pixel_offset; |
271 int left = child_rect.right() - end_pixel_offset; | 272 int left = child_rect.right() - end_pixel_offset; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // These roles don't have readonly set, but they're not editable text. | 596 // These roles don't have readonly set, but they're not editable text. |
596 if (role_ == ui::AX_ROLE_SCROLL_AREA || | 597 if (role_ == ui::AX_ROLE_SCROLL_AREA || |
597 role_ == ui::AX_ROLE_COLUMN || | 598 role_ == ui::AX_ROLE_COLUMN || |
598 role_ == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { | 599 role_ == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { |
599 return false; | 600 return false; |
600 } | 601 } |
601 | 602 |
602 // Note: WebAXStateReadonly being false means it's either a text control, | 603 // Note: WebAXStateReadonly being false means it's either a text control, |
603 // or contenteditable. We also check for editable text roles to cover | 604 // or contenteditable. We also check for editable text roles to cover |
604 // another element that has role=textbox set on it. | 605 // another element that has role=textbox set on it. |
605 return (!HasState(ui::AX_STATE_READONLY) || | 606 return (!HasState(ui::AX_STATE_READ_ONLY) || |
606 role_ == ui::AX_ROLE_TEXT_FIELD || | 607 role_ == ui::AX_ROLE_TEXT_FIELD || |
607 role_ == ui::AX_ROLE_TEXT_AREA); | 608 role_ == ui::AX_ROLE_TEXT_AREA); |
608 } | 609 } |
609 | 610 |
610 std::string BrowserAccessibility::GetTextRecursive() const { | 611 std::string BrowserAccessibility::GetTextRecursive() const { |
611 if (!name_.empty()) { | 612 if (!name_.empty()) { |
612 return name_; | 613 return name_; |
613 } | 614 } |
614 | 615 |
615 std::string result; | 616 std::string result; |
616 for (uint32 i = 0; i < PlatformChildCount(); ++i) | 617 for (uint32 i = 0; i < PlatformChildCount(); ++i) |
617 result += PlatformGetChild(i)->GetTextRecursive(); | 618 result += PlatformGetChild(i)->GetTextRecursive(); |
618 return result; | 619 return result; |
619 } | 620 } |
620 | 621 |
621 int BrowserAccessibility::GetStaticTextLenRecursive() const { | 622 int BrowserAccessibility::GetStaticTextLenRecursive() const { |
622 if (role_ == blink::WebAXRoleStaticText) | 623 if (role_ == blink::WebAXRoleStaticText) |
623 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); | 624 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); |
624 | 625 |
625 int len = 0; | 626 int len = 0; |
626 for (size_t i = 0; i < children_.size(); ++i) | 627 for (size_t i = 0; i < children_.size(); ++i) |
627 len += children_[i]->GetStaticTextLenRecursive(); | 628 len += children_[i]->GetStaticTextLenRecursive(); |
628 return len; | 629 return len; |
629 } | 630 } |
630 | 631 |
631 } // namespace content | 632 } // namespace content |
OLD | NEW |