| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shell/renderer/test_runner/web_ax_object_proxy.h" | 5 #include "content/shell/renderer/test_runner/web_ax_object_proxy.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "gin/handle.h" | 8 #include "gin/handle.h" |
| 9 #include "third_party/WebKit/public/platform/WebPoint.h" | 9 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 10 #include "third_party/WebKit/public/platform/WebRect.h" | 10 #include "third_party/WebKit/public/platform/WebRect.h" |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 .SetMethod("wordStart", &WebAXObjectProxy::WordStart) | 549 .SetMethod("wordStart", &WebAXObjectProxy::WordStart) |
| 550 .SetMethod("wordEnd", &WebAXObjectProxy::WordEnd) | 550 .SetMethod("wordEnd", &WebAXObjectProxy::WordEnd) |
| 551 // TODO(hajimehoshi): This is for backward compatibility. Remove them. | 551 // TODO(hajimehoshi): This is for backward compatibility. Remove them. |
| 552 .SetMethod("addNotificationListener", | 552 .SetMethod("addNotificationListener", |
| 553 &WebAXObjectProxy::SetNotificationListener) | 553 &WebAXObjectProxy::SetNotificationListener) |
| 554 .SetMethod("removeNotificationListener", | 554 .SetMethod("removeNotificationListener", |
| 555 &WebAXObjectProxy::UnsetNotificationListener); | 555 &WebAXObjectProxy::UnsetNotificationListener); |
| 556 } | 556 } |
| 557 | 557 |
| 558 v8::Handle<v8::Object> WebAXObjectProxy::GetChildAtIndex(unsigned index) { | 558 v8::Handle<v8::Object> WebAXObjectProxy::GetChildAtIndex(unsigned index) { |
| 559 return factory_->GetOrCreate(accessibility_object_.childAt(index)); | 559 return factory_->GetOrCreate(accessibility_object().childAt(index)); |
| 560 } | 560 } |
| 561 | 561 |
| 562 bool WebAXObjectProxy::IsRoot() const { | 562 bool WebAXObjectProxy::IsRoot() const { |
| 563 return false; | 563 return false; |
| 564 } | 564 } |
| 565 | 565 |
| 566 bool WebAXObjectProxy::IsEqualToObject(const blink::WebAXObject& other) { | 566 bool WebAXObjectProxy::IsEqualToObject(const blink::WebAXObject& other) { |
| 567 return accessibility_object_.equals(other); | 567 return accessibility_object().equals(other); |
| 568 } | 568 } |
| 569 | 569 |
| 570 void WebAXObjectProxy::NotificationReceived( | 570 void WebAXObjectProxy::NotificationReceived( |
| 571 blink::WebFrame* frame, | 571 blink::WebFrame* frame, |
| 572 const std::string& notification_name) { | 572 const std::string& notification_name) { |
| 573 if (notification_callback_.IsEmpty()) | 573 if (notification_callback_.IsEmpty()) |
| 574 return; | 574 return; |
| 575 | 575 |
| 576 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 576 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
| 577 if (context.IsEmpty()) | 577 if (context.IsEmpty()) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 589 context->Global(), | 589 context->Global(), |
| 590 arraysize(argv), | 590 arraysize(argv), |
| 591 argv); | 591 argv); |
| 592 } | 592 } |
| 593 | 593 |
| 594 void WebAXObjectProxy::Reset() { | 594 void WebAXObjectProxy::Reset() { |
| 595 notification_callback_.Reset(); | 595 notification_callback_.Reset(); |
| 596 } | 596 } |
| 597 | 597 |
| 598 std::string WebAXObjectProxy::Role() { | 598 std::string WebAXObjectProxy::Role() { |
| 599 accessibility_object_.updateLayoutAndCheckValidity(); | 599 return GetRole(accessibility_object()); |
| 600 return GetRole(accessibility_object_); | |
| 601 } | 600 } |
| 602 | 601 |
| 603 std::string WebAXObjectProxy::Title() { | 602 std::string WebAXObjectProxy::Title() { |
| 604 accessibility_object_.updateLayoutAndCheckValidity(); | 603 return GetTitle(accessibility_object()); |
| 605 return GetTitle(accessibility_object_); | |
| 606 } | 604 } |
| 607 | 605 |
| 608 std::string WebAXObjectProxy::Description() { | 606 std::string WebAXObjectProxy::Description() { |
| 609 accessibility_object_.updateLayoutAndCheckValidity(); | 607 return GetDescription(accessibility_object()); |
| 610 return GetDescription(accessibility_object_); | |
| 611 } | 608 } |
| 612 | 609 |
| 613 std::string WebAXObjectProxy::HelpText() { | 610 std::string WebAXObjectProxy::HelpText() { |
| 614 accessibility_object_.updateLayoutAndCheckValidity(); | 611 return GetHelpText(accessibility_object()); |
| 615 return GetHelpText(accessibility_object_); | |
| 616 } | 612 } |
| 617 | 613 |
| 618 std::string WebAXObjectProxy::StringValue() { | 614 std::string WebAXObjectProxy::StringValue() { |
| 619 accessibility_object_.updateLayoutAndCheckValidity(); | 615 return GetStringValue(accessibility_object()); |
| 620 return GetStringValue(accessibility_object_); | |
| 621 } | 616 } |
| 622 | 617 |
| 623 int WebAXObjectProxy::X() { | 618 int WebAXObjectProxy::X() { |
| 624 accessibility_object_.updateLayoutAndCheckValidity(); | 619 accessibility_object_.updateBackingStoreAndCheckValidity(); |
| 625 return accessibility_object_.boundingBoxRect().x; | 620 return accessibility_object().boundingBoxRect().x; |
| 626 } | 621 } |
| 627 | 622 |
| 628 int WebAXObjectProxy::Y() { | 623 int WebAXObjectProxy::Y() { |
| 629 accessibility_object_.updateLayoutAndCheckValidity(); | 624 accessibility_object_.updateBackingStoreAndCheckValidity(); |
| 630 return accessibility_object_.boundingBoxRect().y; | 625 return accessibility_object().boundingBoxRect().y; |
| 631 } | 626 } |
| 632 | 627 |
| 633 int WebAXObjectProxy::Width() { | 628 int WebAXObjectProxy::Width() { |
| 634 accessibility_object_.updateLayoutAndCheckValidity(); | 629 accessibility_object_.updateBackingStoreAndCheckValidity(); |
| 635 return accessibility_object_.boundingBoxRect().width; | 630 return accessibility_object().boundingBoxRect().width; |
| 636 } | 631 } |
| 637 | 632 |
| 638 int WebAXObjectProxy::Height() { | 633 int WebAXObjectProxy::Height() { |
| 639 accessibility_object_.updateLayoutAndCheckValidity(); | 634 accessibility_object_.updateBackingStoreAndCheckValidity(); |
| 640 return accessibility_object_.boundingBoxRect().height; | 635 return accessibility_object().boundingBoxRect().height; |
| 641 } | 636 } |
| 642 | 637 |
| 643 int WebAXObjectProxy::IntValue() { | 638 int WebAXObjectProxy::IntValue() { |
| 644 accessibility_object_.updateLayoutAndCheckValidity(); | 639 if (accessibility_object().supportsRangeValue()) |
| 645 if (accessibility_object_.supportsRangeValue()) | 640 return accessibility_object().valueForRange(); |
| 646 return accessibility_object_.valueForRange(); | 641 else if (accessibility_object().role() == blink::WebAXRoleHeading) |
| 647 else if (accessibility_object_.role() == blink::WebAXRoleHeading) | 642 return accessibility_object().headingLevel(); |
| 648 return accessibility_object_.headingLevel(); | |
| 649 else | 643 else |
| 650 return atoi(accessibility_object_.stringValue().utf8().data()); | 644 return atoi(accessibility_object().stringValue().utf8().data()); |
| 651 } | 645 } |
| 652 | 646 |
| 653 int WebAXObjectProxy::MinValue() { | 647 int WebAXObjectProxy::MinValue() { |
| 654 accessibility_object_.updateLayoutAndCheckValidity(); | 648 return accessibility_object().minValueForRange(); |
| 655 return accessibility_object_.minValueForRange(); | |
| 656 } | 649 } |
| 657 | 650 |
| 658 int WebAXObjectProxy::MaxValue() { | 651 int WebAXObjectProxy::MaxValue() { |
| 659 accessibility_object_.updateLayoutAndCheckValidity(); | 652 return accessibility_object().maxValueForRange(); |
| 660 return accessibility_object_.maxValueForRange(); | |
| 661 } | 653 } |
| 662 | 654 |
| 663 std::string WebAXObjectProxy::ValueDescription() { | 655 std::string WebAXObjectProxy::ValueDescription() { |
| 664 accessibility_object_.updateLayoutAndCheckValidity(); | 656 return GetValueDescription(accessibility_object()); |
| 665 return GetValueDescription(accessibility_object_); | |
| 666 } | 657 } |
| 667 | 658 |
| 668 int WebAXObjectProxy::ChildrenCount() { | 659 int WebAXObjectProxy::ChildrenCount() { |
| 669 accessibility_object_.updateLayoutAndCheckValidity(); | |
| 670 int count = 1; // Root object always has only one child, the WebView. | 660 int count = 1; // Root object always has only one child, the WebView. |
| 671 if (!IsRoot()) | 661 if (!IsRoot()) |
| 672 count = accessibility_object_.childCount(); | 662 count = accessibility_object().childCount(); |
| 673 return count; | 663 return count; |
| 674 } | 664 } |
| 675 | 665 |
| 676 int WebAXObjectProxy::InsertionPointLineNumber() { | 666 int WebAXObjectProxy::InsertionPointLineNumber() { |
| 677 accessibility_object_.updateLayoutAndCheckValidity(); | 667 if (!accessibility_object().isFocused()) |
| 678 if (!accessibility_object_.isFocused()) | |
| 679 return -1; | 668 return -1; |
| 680 return accessibility_object_.selectionEndLineNumber(); | 669 return accessibility_object().selectionEndLineNumber(); |
| 681 } | 670 } |
| 682 | 671 |
| 683 std::string WebAXObjectProxy::SelectedTextRange() { | 672 std::string WebAXObjectProxy::SelectedTextRange() { |
| 684 accessibility_object_.updateLayoutAndCheckValidity(); | 673 unsigned selection_start = accessibility_object().selectionStart(); |
| 685 unsigned selection_start = accessibility_object_.selectionStart(); | 674 unsigned selection_end = accessibility_object().selectionEnd(); |
| 686 unsigned selection_end = accessibility_object_.selectionEnd(); | |
| 687 return base::StringPrintf("{%d, %d}", | 675 return base::StringPrintf("{%d, %d}", |
| 688 selection_start, selection_end - selection_start); | 676 selection_start, selection_end - selection_start); |
| 689 } | 677 } |
| 690 | 678 |
| 691 bool WebAXObjectProxy::IsEnabled() { | 679 bool WebAXObjectProxy::IsEnabled() { |
| 692 accessibility_object_.updateLayoutAndCheckValidity(); | 680 return accessibility_object().isEnabled(); |
| 693 return accessibility_object_.isEnabled(); | |
| 694 } | 681 } |
| 695 | 682 |
| 696 bool WebAXObjectProxy::IsRequired() { | 683 bool WebAXObjectProxy::IsRequired() { |
| 697 accessibility_object_.updateLayoutAndCheckValidity(); | 684 return accessibility_object().isRequired(); |
| 698 return accessibility_object_.isRequired(); | |
| 699 } | 685 } |
| 700 | 686 |
| 701 bool WebAXObjectProxy::IsFocused() { | 687 bool WebAXObjectProxy::IsFocused() { |
| 702 accessibility_object_.updateLayoutAndCheckValidity(); | 688 return accessibility_object().isFocused(); |
| 703 return accessibility_object_.isFocused(); | |
| 704 } | 689 } |
| 705 | 690 |
| 706 bool WebAXObjectProxy::IsFocusable() { | 691 bool WebAXObjectProxy::IsFocusable() { |
| 707 accessibility_object_.updateLayoutAndCheckValidity(); | 692 return accessibility_object().canSetFocusAttribute(); |
| 708 return accessibility_object_.canSetFocusAttribute(); | |
| 709 } | 693 } |
| 710 | 694 |
| 711 bool WebAXObjectProxy::IsSelected() { | 695 bool WebAXObjectProxy::IsSelected() { |
| 712 accessibility_object_.updateLayoutAndCheckValidity(); | 696 return accessibility_object().isSelected(); |
| 713 return accessibility_object_.isSelected(); | |
| 714 } | 697 } |
| 715 | 698 |
| 716 bool WebAXObjectProxy::IsSelectable() { | 699 bool WebAXObjectProxy::IsSelectable() { |
| 717 accessibility_object_.updateLayoutAndCheckValidity(); | 700 return accessibility_object().canSetSelectedAttribute(); |
| 718 return accessibility_object_.canSetSelectedAttribute(); | |
| 719 } | 701 } |
| 720 | 702 |
| 721 bool WebAXObjectProxy::IsMultiSelectable() { | 703 bool WebAXObjectProxy::IsMultiSelectable() { |
| 722 accessibility_object_.updateLayoutAndCheckValidity(); | 704 return accessibility_object().isMultiSelectable(); |
| 723 return accessibility_object_.isMultiSelectable(); | |
| 724 } | 705 } |
| 725 | 706 |
| 726 bool WebAXObjectProxy::IsSelectedOptionActive() { | 707 bool WebAXObjectProxy::IsSelectedOptionActive() { |
| 727 accessibility_object_.updateLayoutAndCheckValidity(); | 708 return accessibility_object().isSelectedOptionActive(); |
| 728 return accessibility_object_.isSelectedOptionActive(); | |
| 729 } | 709 } |
| 730 | 710 |
| 731 bool WebAXObjectProxy::IsExpanded() { | 711 bool WebAXObjectProxy::IsExpanded() { |
| 732 accessibility_object_.updateLayoutAndCheckValidity(); | 712 return !accessibility_object().isCollapsed(); |
| 733 return !accessibility_object_.isCollapsed(); | |
| 734 } | 713 } |
| 735 | 714 |
| 736 bool WebAXObjectProxy::IsChecked() { | 715 bool WebAXObjectProxy::IsChecked() { |
| 737 accessibility_object_.updateLayoutAndCheckValidity(); | 716 return accessibility_object().isChecked(); |
| 738 return accessibility_object_.isChecked(); | |
| 739 } | 717 } |
| 740 | 718 |
| 741 bool WebAXObjectProxy::IsVisible() { | 719 bool WebAXObjectProxy::IsVisible() { |
| 742 accessibility_object_.updateLayoutAndCheckValidity(); | 720 return accessibility_object().isVisible(); |
| 743 return accessibility_object_.isVisible(); | |
| 744 } | 721 } |
| 745 | 722 |
| 746 bool WebAXObjectProxy::IsOffScreen() { | 723 bool WebAXObjectProxy::IsOffScreen() { |
| 747 accessibility_object_.updateLayoutAndCheckValidity(); | 724 return accessibility_object().isOffScreen(); |
| 748 return accessibility_object_.isOffScreen(); | |
| 749 } | 725 } |
| 750 | 726 |
| 751 bool WebAXObjectProxy::IsCollapsed() { | 727 bool WebAXObjectProxy::IsCollapsed() { |
| 752 accessibility_object_.updateLayoutAndCheckValidity(); | 728 return accessibility_object().isCollapsed(); |
| 753 return accessibility_object_.isCollapsed(); | |
| 754 } | 729 } |
| 755 | 730 |
| 756 bool WebAXObjectProxy::HasPopup() { | 731 bool WebAXObjectProxy::HasPopup() { |
| 757 accessibility_object_.updateLayoutAndCheckValidity(); | 732 return accessibility_object().ariaHasPopup(); |
| 758 return accessibility_object_.ariaHasPopup(); | |
| 759 } | 733 } |
| 760 | 734 |
| 761 bool WebAXObjectProxy::IsValid() { | 735 bool WebAXObjectProxy::IsValid() { |
| 762 accessibility_object_.updateLayoutAndCheckValidity(); | 736 return !accessibility_object().isDetached(); |
| 763 return !accessibility_object_.isDetached(); | |
| 764 } | 737 } |
| 765 | 738 |
| 766 bool WebAXObjectProxy::IsReadOnly() { | 739 bool WebAXObjectProxy::IsReadOnly() { |
| 767 accessibility_object_.updateLayoutAndCheckValidity(); | 740 return accessibility_object().isReadOnly(); |
| 768 return accessibility_object_.isReadOnly(); | |
| 769 } | 741 } |
| 770 | 742 |
| 771 std::string WebAXObjectProxy::Orientation() { | 743 std::string WebAXObjectProxy::Orientation() { |
| 772 accessibility_object_.updateLayoutAndCheckValidity(); | 744 return GetOrientation(accessibility_object()); |
| 773 return GetOrientation(accessibility_object_); | |
| 774 } | 745 } |
| 775 | 746 |
| 776 int WebAXObjectProxy::ClickPointX() { | 747 int WebAXObjectProxy::ClickPointX() { |
| 777 accessibility_object_.updateLayoutAndCheckValidity(); | 748 return accessibility_object().clickPoint().x; |
| 778 return accessibility_object_.clickPoint().x; | |
| 779 } | 749 } |
| 780 | 750 |
| 781 int WebAXObjectProxy::ClickPointY() { | 751 int WebAXObjectProxy::ClickPointY() { |
| 782 accessibility_object_.updateLayoutAndCheckValidity(); | 752 return accessibility_object().clickPoint().y; |
| 783 return accessibility_object_.clickPoint().y; | |
| 784 } | 753 } |
| 785 | 754 |
| 786 int32_t WebAXObjectProxy::RowCount() { | 755 int32_t WebAXObjectProxy::RowCount() { |
| 787 accessibility_object_.updateLayoutAndCheckValidity(); | 756 return static_cast<int32_t>(accessibility_object().rowCount()); |
| 788 return static_cast<int32_t>(accessibility_object_.rowCount()); | |
| 789 } | 757 } |
| 790 | 758 |
| 791 int32_t WebAXObjectProxy::ColumnCount() { | 759 int32_t WebAXObjectProxy::ColumnCount() { |
| 792 accessibility_object_.updateLayoutAndCheckValidity(); | 760 return static_cast<int32_t>(accessibility_object().columnCount()); |
| 793 return static_cast<int32_t>(accessibility_object_.columnCount()); | |
| 794 } | 761 } |
| 795 | 762 |
| 796 bool WebAXObjectProxy::IsClickable() { | 763 bool WebAXObjectProxy::IsClickable() { |
| 797 accessibility_object_.updateLayoutAndCheckValidity(); | 764 return accessibility_object().isClickable(); |
| 798 return accessibility_object_.isClickable(); | |
| 799 } | 765 } |
| 800 | 766 |
| 801 std::string WebAXObjectProxy::AllAttributes() { | 767 std::string WebAXObjectProxy::AllAttributes() { |
| 802 accessibility_object_.updateLayoutAndCheckValidity(); | 768 return GetAttributes(accessibility_object()); |
| 803 return GetAttributes(accessibility_object_); | |
| 804 } | 769 } |
| 805 | 770 |
| 806 std::string WebAXObjectProxy::AttributesOfChildren() { | 771 std::string WebAXObjectProxy::AttributesOfChildren() { |
| 807 accessibility_object_.updateLayoutAndCheckValidity(); | |
| 808 AttributesCollector collector; | 772 AttributesCollector collector; |
| 809 unsigned size = accessibility_object_.childCount(); | 773 unsigned size = accessibility_object().childCount(); |
| 810 for (unsigned i = 0; i < size; ++i) | 774 for (unsigned i = 0; i < size; ++i) |
| 811 collector.CollectAttributes(accessibility_object_.childAt(i)); | 775 collector.CollectAttributes(accessibility_object().childAt(i)); |
| 812 return collector.attributes(); | 776 return collector.attributes(); |
| 813 } | 777 } |
| 814 | 778 |
| 815 int WebAXObjectProxy::LineForIndex(int index) { | 779 int WebAXObjectProxy::LineForIndex(int index) { |
| 816 accessibility_object_.updateLayoutAndCheckValidity(); | |
| 817 blink::WebVector<int> line_breaks; | 780 blink::WebVector<int> line_breaks; |
| 818 accessibility_object_.lineBreaks(line_breaks); | 781 accessibility_object().lineBreaks(line_breaks); |
| 819 int line = 0; | 782 int line = 0; |
| 820 int vector_size = static_cast<int>(line_breaks.size()); | 783 int vector_size = static_cast<int>(line_breaks.size()); |
| 821 while (line < vector_size && line_breaks[line] <= index) | 784 while (line < vector_size && line_breaks[line] <= index) |
| 822 line++; | 785 line++; |
| 823 return line; | 786 return line; |
| 824 } | 787 } |
| 825 | 788 |
| 826 std::string WebAXObjectProxy::BoundsForRange(int start, int end) { | 789 std::string WebAXObjectProxy::BoundsForRange(int start, int end) { |
| 827 accessibility_object_.updateLayoutAndCheckValidity(); | 790 if (accessibility_object().role() != blink::WebAXRoleStaticText) |
| 828 if (accessibility_object_.role() != blink::WebAXRoleStaticText) | |
| 829 return std::string(); | 791 return std::string(); |
| 830 | 792 |
| 831 if (!accessibility_object_.updateLayoutAndCheckValidity()) | 793 if (!accessibility_object_.updateBackingStoreAndCheckValidity()) |
| 832 return std::string(); | 794 return std::string(); |
| 833 | 795 |
| 834 int len = end - start; | 796 int len = end - start; |
| 835 | 797 |
| 836 // Get the bounds for each character and union them into one large rectangle. | 798 // Get the bounds for each character and union them into one large rectangle. |
| 837 // This is just for testing so it doesn't need to be efficient. | 799 // This is just for testing so it doesn't need to be efficient. |
| 838 blink::WebRect bounds = BoundsForCharacter(accessibility_object_, start); | 800 blink::WebRect bounds = BoundsForCharacter(accessibility_object(), start); |
| 839 for (int i = 1; i < len; i++) { | 801 for (int i = 1; i < len; i++) { |
| 840 blink::WebRect next = BoundsForCharacter(accessibility_object_, start + i); | 802 blink::WebRect next = BoundsForCharacter(accessibility_object(), start + i); |
| 841 int right = std::max(bounds.x + bounds.width, next.x + next.width); | 803 int right = std::max(bounds.x + bounds.width, next.x + next.width); |
| 842 int bottom = std::max(bounds.y + bounds.height, next.y + next.height); | 804 int bottom = std::max(bounds.y + bounds.height, next.y + next.height); |
| 843 bounds.x = std::min(bounds.x, next.x); | 805 bounds.x = std::min(bounds.x, next.x); |
| 844 bounds.y = std::min(bounds.y, next.y); | 806 bounds.y = std::min(bounds.y, next.y); |
| 845 bounds.width = right - bounds.x; | 807 bounds.width = right - bounds.x; |
| 846 bounds.height = bottom - bounds.y; | 808 bounds.height = bottom - bounds.y; |
| 847 } | 809 } |
| 848 | 810 |
| 849 return base::StringPrintf("{x: %d, y: %d, width: %d, height: %d}", | 811 return base::StringPrintf("{x: %d, y: %d, width: %d, height: %d}", |
| 850 bounds.x, bounds.y, bounds.width, bounds.height); | 812 bounds.x, bounds.y, bounds.width, bounds.height); |
| 851 } | 813 } |
| 852 | 814 |
| 853 v8::Handle<v8::Object> WebAXObjectProxy::ChildAtIndex(int index) { | 815 v8::Handle<v8::Object> WebAXObjectProxy::ChildAtIndex(int index) { |
| 854 accessibility_object_.updateLayoutAndCheckValidity(); | |
| 855 return GetChildAtIndex(index); | 816 return GetChildAtIndex(index); |
| 856 } | 817 } |
| 857 | 818 |
| 858 v8::Handle<v8::Object> WebAXObjectProxy::ElementAtPoint(int x, int y) { | 819 v8::Handle<v8::Object> WebAXObjectProxy::ElementAtPoint(int x, int y) { |
| 859 accessibility_object_.updateLayoutAndCheckValidity(); | |
| 860 blink::WebPoint point(x, y); | 820 blink::WebPoint point(x, y); |
| 861 blink::WebAXObject obj = accessibility_object_.hitTest(point); | 821 blink::WebAXObject obj = accessibility_object().hitTest(point); |
| 862 if (obj.isNull()) | 822 if (obj.isNull()) |
| 863 return v8::Handle<v8::Object>(); | 823 return v8::Handle<v8::Object>(); |
| 864 | 824 |
| 865 return factory_->GetOrCreate(obj); | 825 return factory_->GetOrCreate(obj); |
| 866 } | 826 } |
| 867 | 827 |
| 868 v8::Handle<v8::Object> WebAXObjectProxy::TableHeader() { | 828 v8::Handle<v8::Object> WebAXObjectProxy::TableHeader() { |
| 869 accessibility_object_.updateLayoutAndCheckValidity(); | 829 blink::WebAXObject obj = accessibility_object().headerContainerObject(); |
| 870 blink::WebAXObject obj = accessibility_object_.headerContainerObject(); | |
| 871 if (obj.isNull()) | 830 if (obj.isNull()) |
| 872 return v8::Handle<v8::Object>(); | 831 return v8::Handle<v8::Object>(); |
| 873 | 832 |
| 874 return factory_->GetOrCreate(obj); | 833 return factory_->GetOrCreate(obj); |
| 875 } | 834 } |
| 876 | 835 |
| 877 std::string WebAXObjectProxy::RowIndexRange() { | 836 std::string WebAXObjectProxy::RowIndexRange() { |
| 878 accessibility_object_.updateLayoutAndCheckValidity(); | 837 unsigned row_index = accessibility_object().cellRowIndex(); |
| 879 unsigned row_index = accessibility_object_.cellRowIndex(); | 838 unsigned row_span = accessibility_object().cellRowSpan(); |
| 880 unsigned row_span = accessibility_object_.cellRowSpan(); | |
| 881 return base::StringPrintf("{%d, %d}", row_index, row_span); | 839 return base::StringPrintf("{%d, %d}", row_index, row_span); |
| 882 } | 840 } |
| 883 | 841 |
| 884 std::string WebAXObjectProxy::ColumnIndexRange() { | 842 std::string WebAXObjectProxy::ColumnIndexRange() { |
| 885 accessibility_object_.updateLayoutAndCheckValidity(); | 843 unsigned column_index = accessibility_object().cellColumnIndex(); |
| 886 unsigned column_index = accessibility_object_.cellColumnIndex(); | 844 unsigned column_span = accessibility_object().cellColumnSpan(); |
| 887 unsigned column_span = accessibility_object_.cellColumnSpan(); | |
| 888 return base::StringPrintf("{%d, %d}", column_index, column_span); | 845 return base::StringPrintf("{%d, %d}", column_index, column_span); |
| 889 } | 846 } |
| 890 | 847 |
| 891 v8::Handle<v8::Object> WebAXObjectProxy::CellForColumnAndRow( | 848 v8::Handle<v8::Object> WebAXObjectProxy::CellForColumnAndRow( |
| 892 int column, int row) { | 849 int column, int row) { |
| 893 accessibility_object_.updateLayoutAndCheckValidity(); | |
| 894 blink::WebAXObject obj = | 850 blink::WebAXObject obj = |
| 895 accessibility_object_.cellForColumnAndRow(column, row); | 851 accessibility_object().cellForColumnAndRow(column, row); |
| 896 if (obj.isNull()) | 852 if (obj.isNull()) |
| 897 return v8::Handle<v8::Object>(); | 853 return v8::Handle<v8::Object>(); |
| 898 | 854 |
| 899 return factory_->GetOrCreate(obj); | 855 return factory_->GetOrCreate(obj); |
| 900 } | 856 } |
| 901 | 857 |
| 902 v8::Handle<v8::Object> WebAXObjectProxy::TitleUIElement() { | 858 v8::Handle<v8::Object> WebAXObjectProxy::TitleUIElement() { |
| 903 accessibility_object_.updateLayoutAndCheckValidity(); | 859 blink::WebAXObject obj = accessibility_object().titleUIElement(); |
| 904 blink::WebAXObject obj = accessibility_object_.titleUIElement(); | |
| 905 if (obj.isNull()) | 860 if (obj.isNull()) |
| 906 return v8::Handle<v8::Object>(); | 861 return v8::Handle<v8::Object>(); |
| 907 | 862 |
| 908 return factory_->GetOrCreate(obj); | 863 return factory_->GetOrCreate(obj); |
| 909 } | 864 } |
| 910 | 865 |
| 911 void WebAXObjectProxy::SetSelectedTextRange(int selection_start, | 866 void WebAXObjectProxy::SetSelectedTextRange(int selection_start, |
| 912 int length) { | 867 int length) { |
| 913 accessibility_object_.updateLayoutAndCheckValidity(); | 868 accessibility_object().setSelectedTextRange(selection_start, |
| 914 accessibility_object_.setSelectedTextRange(selection_start, | |
| 915 selection_start + length); | 869 selection_start + length); |
| 916 } | 870 } |
| 917 | 871 |
| 918 bool WebAXObjectProxy::IsAttributeSettable(const std::string& attribute) { | 872 bool WebAXObjectProxy::IsAttributeSettable(const std::string& attribute) { |
| 919 accessibility_object_.updateLayoutAndCheckValidity(); | |
| 920 bool settable = false; | 873 bool settable = false; |
| 921 if (attribute == "AXValue") | 874 if (attribute == "AXValue") |
| 922 settable = accessibility_object_.canSetValueAttribute(); | 875 settable = accessibility_object().canSetValueAttribute(); |
| 923 return settable; | 876 return settable; |
| 924 } | 877 } |
| 925 | 878 |
| 926 bool WebAXObjectProxy::IsPressActionSupported() { | 879 bool WebAXObjectProxy::IsPressActionSupported() { |
| 927 accessibility_object_.updateLayoutAndCheckValidity(); | 880 return accessibility_object().canPress(); |
| 928 return accessibility_object_.canPress(); | |
| 929 } | 881 } |
| 930 | 882 |
| 931 bool WebAXObjectProxy::IsIncrementActionSupported() { | 883 bool WebAXObjectProxy::IsIncrementActionSupported() { |
| 932 accessibility_object_.updateLayoutAndCheckValidity(); | 884 return accessibility_object().canIncrement(); |
| 933 return accessibility_object_.canIncrement(); | |
| 934 } | 885 } |
| 935 | 886 |
| 936 bool WebAXObjectProxy::IsDecrementActionSupported() { | 887 bool WebAXObjectProxy::IsDecrementActionSupported() { |
| 937 accessibility_object_.updateLayoutAndCheckValidity(); | 888 return accessibility_object().canDecrement(); |
| 938 return accessibility_object_.canDecrement(); | |
| 939 } | 889 } |
| 940 | 890 |
| 941 v8::Handle<v8::Object> WebAXObjectProxy::ParentElement() { | 891 v8::Handle<v8::Object> WebAXObjectProxy::ParentElement() { |
| 942 accessibility_object_.updateLayoutAndCheckValidity(); | 892 blink::WebAXObject parent_object = accessibility_object().parentObject(); |
| 943 blink::WebAXObject parent_object = accessibility_object_.parentObject(); | |
| 944 while (parent_object.accessibilityIsIgnored()) | 893 while (parent_object.accessibilityIsIgnored()) |
| 945 parent_object = parent_object.parentObject(); | 894 parent_object = parent_object.parentObject(); |
| 946 return factory_->GetOrCreate(parent_object); | 895 return factory_->GetOrCreate(parent_object); |
| 947 } | 896 } |
| 948 | 897 |
| 949 void WebAXObjectProxy::Increment() { | 898 void WebAXObjectProxy::Increment() { |
| 950 accessibility_object_.updateLayoutAndCheckValidity(); | 899 accessibility_object().increment(); |
| 951 accessibility_object_.increment(); | |
| 952 } | 900 } |
| 953 | 901 |
| 954 void WebAXObjectProxy::Decrement() { | 902 void WebAXObjectProxy::Decrement() { |
| 955 accessibility_object_.updateLayoutAndCheckValidity(); | 903 accessibility_object().decrement(); |
| 956 accessibility_object_.decrement(); | |
| 957 } | 904 } |
| 958 | 905 |
| 959 void WebAXObjectProxy::ShowMenu() { | 906 void WebAXObjectProxy::ShowMenu() { |
| 960 } | 907 } |
| 961 | 908 |
| 962 void WebAXObjectProxy::Press() { | 909 void WebAXObjectProxy::Press() { |
| 963 accessibility_object_.updateLayoutAndCheckValidity(); | 910 accessibility_object().press(); |
| 964 accessibility_object_.press(); | |
| 965 } | 911 } |
| 966 | 912 |
| 967 bool WebAXObjectProxy::IsEqual(v8::Handle<v8::Object> proxy) { | 913 bool WebAXObjectProxy::IsEqual(v8::Handle<v8::Object> proxy) { |
| 968 WebAXObjectProxy* unwrapped_proxy = NULL; | 914 WebAXObjectProxy* unwrapped_proxy = NULL; |
| 969 if (!gin::ConvertFromV8(blink::mainThreadIsolate(), proxy, &unwrapped_proxy)) | 915 if (!gin::ConvertFromV8(blink::mainThreadIsolate(), proxy, &unwrapped_proxy)) |
| 970 return false; | 916 return false; |
| 971 return unwrapped_proxy->IsEqualToObject(accessibility_object_); | 917 return unwrapped_proxy->IsEqualToObject(accessibility_object_); |
| 972 } | 918 } |
| 973 | 919 |
| 974 void WebAXObjectProxy::SetNotificationListener( | 920 void WebAXObjectProxy::SetNotificationListener( |
| 975 v8::Handle<v8::Function> callback) { | 921 v8::Handle<v8::Function> callback) { |
| 976 v8::Isolate* isolate = blink::mainThreadIsolate(); | 922 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 977 notification_callback_.Reset(isolate, callback); | 923 notification_callback_.Reset(isolate, callback); |
| 978 } | 924 } |
| 979 | 925 |
| 980 void WebAXObjectProxy::UnsetNotificationListener() { | 926 void WebAXObjectProxy::UnsetNotificationListener() { |
| 981 notification_callback_.Reset(); | 927 notification_callback_.Reset(); |
| 982 } | 928 } |
| 983 | 929 |
| 984 void WebAXObjectProxy::TakeFocus() { | 930 void WebAXObjectProxy::TakeFocus() { |
| 985 accessibility_object_.updateLayoutAndCheckValidity(); | 931 accessibility_object().setFocused(true); |
| 986 accessibility_object_.setFocused(true); | |
| 987 } | 932 } |
| 988 | 933 |
| 989 void WebAXObjectProxy::ScrollToMakeVisible() { | 934 void WebAXObjectProxy::ScrollToMakeVisible() { |
| 990 accessibility_object_.updateLayoutAndCheckValidity(); | 935 accessibility_object().scrollToMakeVisible(); |
| 991 accessibility_object_.scrollToMakeVisible(); | |
| 992 } | 936 } |
| 993 | 937 |
| 994 void WebAXObjectProxy::ScrollToMakeVisibleWithSubFocus(int x, int y, | 938 void WebAXObjectProxy::ScrollToMakeVisibleWithSubFocus(int x, int y, |
| 995 int width, int height) { | 939 int width, int height) { |
| 996 accessibility_object_.updateLayoutAndCheckValidity(); | 940 accessibility_object().scrollToMakeVisibleWithSubFocus( |
| 997 accessibility_object_.scrollToMakeVisibleWithSubFocus( | |
| 998 blink::WebRect(x, y, width, height)); | 941 blink::WebRect(x, y, width, height)); |
| 999 } | 942 } |
| 1000 | 943 |
| 1001 void WebAXObjectProxy::ScrollToGlobalPoint(int x, int y) { | 944 void WebAXObjectProxy::ScrollToGlobalPoint(int x, int y) { |
| 1002 accessibility_object_.updateLayoutAndCheckValidity(); | 945 accessibility_object().scrollToGlobalPoint(blink::WebPoint(x, y)); |
| 1003 accessibility_object_.scrollToGlobalPoint(blink::WebPoint(x, y)); | |
| 1004 } | 946 } |
| 1005 | 947 |
| 1006 int WebAXObjectProxy::WordStart(int character_index) { | 948 int WebAXObjectProxy::WordStart(int character_index) { |
| 1007 accessibility_object_.updateLayoutAndCheckValidity(); | 949 if (accessibility_object().role() != blink::WebAXRoleStaticText) |
| 1008 if (accessibility_object_.role() != blink::WebAXRoleStaticText) | |
| 1009 return -1; | 950 return -1; |
| 1010 | 951 |
| 1011 int word_start, word_end; | 952 int word_start, word_end; |
| 1012 GetBoundariesForOneWord(accessibility_object_, character_index, | 953 GetBoundariesForOneWord(accessibility_object(), character_index, |
| 1013 word_start, word_end); | 954 word_start, word_end); |
| 1014 return word_start; | 955 return word_start; |
| 1015 } | 956 } |
| 1016 | 957 |
| 1017 int WebAXObjectProxy::WordEnd(int character_index) { | 958 int WebAXObjectProxy::WordEnd(int character_index) { |
| 1018 accessibility_object_.updateLayoutAndCheckValidity(); | 959 if (accessibility_object().role() != blink::WebAXRoleStaticText) |
| 1019 if (accessibility_object_.role() != blink::WebAXRoleStaticText) | |
| 1020 return -1; | 960 return -1; |
| 1021 | 961 |
| 1022 int word_start, word_end; | 962 int word_start, word_end; |
| 1023 GetBoundariesForOneWord(accessibility_object_, character_index, | 963 GetBoundariesForOneWord(accessibility_object(), character_index, |
| 1024 word_start, word_end); | 964 word_start, word_end); |
| 1025 return word_end; | 965 return word_end; |
| 1026 } | 966 } |
| 1027 | 967 |
| 1028 RootWebAXObjectProxy::RootWebAXObjectProxy( | 968 RootWebAXObjectProxy::RootWebAXObjectProxy( |
| 1029 const blink::WebAXObject &object, Factory *factory) | 969 const blink::WebAXObject &object, Factory *factory) |
| 1030 : WebAXObjectProxy(object, factory) { | 970 : WebAXObjectProxy(object, factory) { |
| 1031 } | 971 } |
| 1032 | 972 |
| 1033 v8::Handle<v8::Object> RootWebAXObjectProxy::GetChildAtIndex(unsigned index) { | 973 v8::Handle<v8::Object> RootWebAXObjectProxy::GetChildAtIndex(unsigned index) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 v8::Handle<v8::Value> value_handle = gin::CreateHandle( | 1037 v8::Handle<v8::Value> value_handle = gin::CreateHandle( |
| 1098 isolate, new RootWebAXObjectProxy(object, this)).ToV8(); | 1038 isolate, new RootWebAXObjectProxy(object, this)).ToV8(); |
| 1099 if (value_handle.IsEmpty()) | 1039 if (value_handle.IsEmpty()) |
| 1100 return v8::Handle<v8::Object>(); | 1040 return v8::Handle<v8::Object>(); |
| 1101 v8::Handle<v8::Object> handle = value_handle->ToObject(); | 1041 v8::Handle<v8::Object> handle = value_handle->ToObject(); |
| 1102 elements_.Append(handle); | 1042 elements_.Append(handle); |
| 1103 return handle; | 1043 return handle; |
| 1104 } | 1044 } |
| 1105 | 1045 |
| 1106 } // namespace content | 1046 } // namespace content |
| OLD | NEW |