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