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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 474 } |
475 | 475 |
476 return false; | 476 return false; |
477 } | 477 } |
478 | 478 |
479 base::string16 BrowserAccessibility::GetString16Attribute( | 479 base::string16 BrowserAccessibility::GetString16Attribute( |
480 StringAttribute attribute) const { | 480 StringAttribute attribute) const { |
481 std::string value_utf8; | 481 std::string value_utf8; |
482 if (!GetStringAttribute(attribute, &value_utf8)) | 482 if (!GetStringAttribute(attribute, &value_utf8)) |
483 return base::string16(); | 483 return base::string16(); |
484 return UTF8ToUTF16(value_utf8); | 484 return base::UTF8ToUTF16(value_utf8); |
485 } | 485 } |
486 | 486 |
487 bool BrowserAccessibility::GetString16Attribute( | 487 bool BrowserAccessibility::GetString16Attribute( |
488 StringAttribute attribute, | 488 StringAttribute attribute, |
489 base::string16* value) const { | 489 base::string16* value) const { |
490 std::string value_utf8; | 490 std::string value_utf8; |
491 if (!GetStringAttribute(attribute, &value_utf8)) | 491 if (!GetStringAttribute(attribute, &value_utf8)) |
492 return false; | 492 return false; |
493 *value = UTF8ToUTF16(value_utf8); | 493 *value = base::UTF8ToUTF16(value_utf8); |
494 return true; | 494 return true; |
495 } | 495 } |
496 | 496 |
497 void BrowserAccessibility::SetStringAttribute( | 497 void BrowserAccessibility::SetStringAttribute( |
498 StringAttribute attribute, const std::string& value) { | 498 StringAttribute attribute, const std::string& value) { |
499 for (size_t i = 0; i < string_attributes_.size(); ++i) { | 499 for (size_t i = 0; i < string_attributes_.size(); ++i) { |
500 if (string_attributes_[i].first == attribute) { | 500 if (string_attributes_[i].first == attribute) { |
501 string_attributes_[i].second = value; | 501 string_attributes_[i].second = value; |
502 return; | 502 return; |
503 } | 503 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } | 551 } |
552 | 552 |
553 return false; | 553 return false; |
554 } | 554 } |
555 | 555 |
556 bool BrowserAccessibility::GetHtmlAttribute( | 556 bool BrowserAccessibility::GetHtmlAttribute( |
557 const char* html_attr, base::string16* value) const { | 557 const char* html_attr, base::string16* value) const { |
558 std::string value_utf8; | 558 std::string value_utf8; |
559 if (!GetHtmlAttribute(html_attr, &value_utf8)) | 559 if (!GetHtmlAttribute(html_attr, &value_utf8)) |
560 return false; | 560 return false; |
561 *value = UTF8ToUTF16(value_utf8); | 561 *value = base::UTF8ToUTF16(value_utf8); |
562 return true; | 562 return true; |
563 } | 563 } |
564 | 564 |
565 bool BrowserAccessibility::GetAriaTristate( | 565 bool BrowserAccessibility::GetAriaTristate( |
566 const char* html_attr, | 566 const char* html_attr, |
567 bool* is_defined, | 567 bool* is_defined, |
568 bool* is_mixed) const { | 568 bool* is_mixed) const { |
569 *is_defined = false; | 569 *is_defined = false; |
570 *is_mixed = false; | 570 *is_mixed = false; |
571 | 571 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 GetStringAttribute(AccessibilityNodeData::ATTR_VALUE).size()); | 624 GetStringAttribute(AccessibilityNodeData::ATTR_VALUE).size()); |
625 } | 625 } |
626 | 626 |
627 int len = 0; | 627 int len = 0; |
628 for (size_t i = 0; i < children_.size(); ++i) | 628 for (size_t i = 0; i < children_.size(); ++i) |
629 len += children_[i]->GetStaticTextLenRecursive(); | 629 len += children_[i]->GetStaticTextLenRecursive(); |
630 return len; | 630 return len; |
631 } | 631 } |
632 | 632 |
633 } // namespace content | 633 } // namespace content |
OLD | NEW |