| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 IgnoredReason(AXIgnoredReason r, const AXObject* obj) | 363 IgnoredReason(AXIgnoredReason r, const AXObject* obj) |
| 364 : reason(r) | 364 : reason(r) |
| 365 , relatedObject(obj) | 365 , relatedObject(obj) |
| 366 { } | 366 { } |
| 367 }; | 367 }; |
| 368 | 368 |
| 369 class MODULES_EXPORT AXObject : public RefCountedWillBeGarbageCollectedFinalized
<AXObject> { | 369 class MODULES_EXPORT AXObject : public RefCountedWillBeGarbageCollectedFinalized
<AXObject> { |
| 370 public: | 370 public: |
| 371 typedef WillBeHeapVector<RefPtrWillBeMember<AXObject>> AccessibilityChildren
Vector; | 371 typedef WillBeHeapVector<RefPtrWillBeMember<AXObject>> AccessibilityChildren
Vector; |
| 372 | 372 |
| 373 struct PlainTextRange { | 373 struct AXRange { |
| 374 // The deepest descendant in which the range starts. |
| 375 // (nullptr means the current object.) |
| 376 RefPtrWillBePersistent<AXObject> anchorObject; |
| 377 // The number of characters and child objects in the anchor object |
| 378 // before the range starts. |
| 379 int anchorOffset; |
| 380 // The deepest descendant in which the range ends. |
| 381 // (nullptr means the current object.) |
| 382 RefPtrWillBePersistent<AXObject> focusObject; |
| 383 // The number of characters and child objects in the focus object |
| 384 // before the range ends. |
| 385 int focusOffset; |
| 374 | 386 |
| 375 unsigned start; | 387 AXRange() |
| 376 unsigned length; | 388 : anchorObject(nullptr) |
| 377 | 389 , anchorOffset(-1) |
| 378 PlainTextRange() | 390 , focusObject(nullptr) |
| 379 : start(0) | 391 , focusOffset(-1) |
| 380 , length(0) | |
| 381 { } | 392 { } |
| 382 | 393 |
| 383 PlainTextRange(unsigned s, unsigned l) | 394 AXRange(int startOffset, int endOffset) |
| 384 : start(s) | 395 : anchorObject(nullptr) |
| 385 , length(l) | 396 , anchorOffset(startOffset) |
| 397 , focusObject(nullptr) |
| 398 , focusOffset(endOffset) |
| 386 { } | 399 { } |
| 387 | 400 |
| 388 bool isNull() const { return !start && !length; } | 401 AXRange(PassRefPtrWillBeRawPtr<AXObject> anchorObject, int anchorOffset, |
| 402 PassRefPtrWillBeRawPtr<AXObject> focusObject, int focusOffset) |
| 403 : anchorObject(anchorObject) |
| 404 , anchorOffset(anchorOffset) |
| 405 , focusObject(focusObject) |
| 406 , focusOffset(focusOffset) |
| 407 { } |
| 408 |
| 409 bool isValid() const |
| 410 { |
| 411 return ((anchorObject && focusObject) |
| 412 || (!anchorObject && !focusObject)) |
| 413 && anchorOffset >= 0 && focusOffset >= 0; |
| 414 } |
| 415 |
| 416 // Determines if the range only refers to text offsets under the current
object. |
| 417 bool isSimple() const |
| 418 { |
| 419 return anchorObject == focusObject || !anchorObject || !focusObject; |
| 420 } |
| 389 }; | 421 }; |
| 390 | 422 |
| 391 protected: | 423 protected: |
| 392 AXObject(AXObjectCacheImpl&); | 424 AXObject(AXObjectCacheImpl&); |
| 393 | 425 |
| 394 public: | 426 public: |
| 395 virtual ~AXObject(); | 427 virtual ~AXObject(); |
| 396 DECLARE_VIRTUAL_TRACE(); | 428 DECLARE_VIRTUAL_TRACE(); |
| 397 | 429 |
| 398 static unsigned numberOfLiveAXObjects() { return s_numberOfLiveAXObjects; } | 430 static unsigned numberOfLiveAXObjects() { return s_numberOfLiveAXObjects; } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 630 |
| 599 // Walk the AXObjects on the same line. This is supported on any | 631 // Walk the AXObjects on the same line. This is supported on any |
| 600 // object type but primarily intended to be used for inline text boxes. | 632 // object type but primarily intended to be used for inline text boxes. |
| 601 virtual AXObject* nextOnLine() const { return nullptr; } | 633 virtual AXObject* nextOnLine() const { return nullptr; } |
| 602 virtual AXObject* previousOnLine() const { return nullptr; } | 634 virtual AXObject* previousOnLine() const { return nullptr; } |
| 603 | 635 |
| 604 // For an inline text box. | 636 // For an inline text box. |
| 605 // The integer horizontal pixel offset of each character in the string; nega
tive values for RTL. | 637 // The integer horizontal pixel offset of each character in the string; nega
tive values for RTL. |
| 606 virtual void textCharacterOffsets(Vector<int>&) const { } | 638 virtual void textCharacterOffsets(Vector<int>&) const { } |
| 607 // The start and end character offset of each word in the inline text box. | 639 // The start and end character offset of each word in the inline text box. |
| 608 virtual void wordBoundaries(Vector<PlainTextRange>& words) const { } | 640 virtual void wordBoundaries(Vector<AXRange>& words) const { } |
| 609 | 641 |
| 610 // Properties of interactive elements. | 642 // Properties of interactive elements. |
| 611 virtual String actionVerb() const; | 643 virtual String actionVerb() const; |
| 612 virtual AccessibilityButtonState checkboxOrRadioValue() const; | 644 virtual AccessibilityButtonState checkboxOrRadioValue() const; |
| 613 virtual InvalidState invalidState() const { return InvalidStateUndefined; } | 645 virtual InvalidState invalidState() const { return InvalidStateUndefined; } |
| 614 // Only used when invalidState() returns InvalidStateOther. | 646 // Only used when invalidState() returns InvalidStateOther. |
| 615 virtual String ariaInvalidValue() const { return String(); } | 647 virtual String ariaInvalidValue() const { return String(); } |
| 616 virtual String valueDescription() const { return String(); } | 648 virtual String valueDescription() const { return String(); } |
| 617 virtual float valueForRange() const { return 0.0f; } | 649 virtual float valueForRange() const { return 0.0f; } |
| 618 virtual float maxValueForRange() const { return 0.0f; } | 650 virtual float maxValueForRange() const { return 0.0f; } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 virtual LayoutObject* layoutObject() const { return 0; } | 744 virtual LayoutObject* layoutObject() const { return 0; } |
| 713 virtual Document* document() const; | 745 virtual Document* document() const; |
| 714 virtual FrameView* documentFrameView() const; | 746 virtual FrameView* documentFrameView() const; |
| 715 virtual Element* anchorElement() const { return 0; } | 747 virtual Element* anchorElement() const { return 0; } |
| 716 virtual Element* actionElement() const { return 0; } | 748 virtual Element* actionElement() const { return 0; } |
| 717 virtual Widget* widgetForAttachmentView() const { return 0; } | 749 virtual Widget* widgetForAttachmentView() const { return 0; } |
| 718 String language() const; | 750 String language() const; |
| 719 bool hasAttribute(const QualifiedName&) const; | 751 bool hasAttribute(const QualifiedName&) const; |
| 720 const AtomicString& getAttribute(const QualifiedName&) const; | 752 const AtomicString& getAttribute(const QualifiedName&) const; |
| 721 | 753 |
| 722 // Selected text. | 754 // Methods that retrieve or manipulate the current selection. |
| 723 virtual PlainTextRange selectedTextRange() const { return PlainTextRange();
} | 755 |
| 756 // Get the current selection from anywhere in the accessibility tree. |
| 757 virtual AXRange selection() const { return AXRange(); } |
| 758 // Gets only the start and end offsets of the selection computed using the |
| 759 // current object as the starting point. Returns a null selection if there i
s |
| 760 // no selection in the subtree rooted at this object. |
| 761 virtual AXRange selectionUnderObject() const { return AXRange(); } |
| 762 virtual void setSelection(const AXRange&) { } |
| 724 | 763 |
| 725 // Scrollable containers. | 764 // Scrollable containers. |
| 726 bool isScrollableContainer() const; | 765 bool isScrollableContainer() const; |
| 727 IntPoint scrollOffset() const; | 766 IntPoint scrollOffset() const; |
| 728 IntPoint minimumScrollOffset() const; | 767 IntPoint minimumScrollOffset() const; |
| 729 IntPoint maximumScrollOffset() const; | 768 IntPoint maximumScrollOffset() const; |
| 730 void setScrollOffset(const IntPoint&) const; | 769 void setScrollOffset(const IntPoint&) const; |
| 731 | 770 |
| 732 // If this object itself scrolls, return its ScrollableArea. | 771 // If this object itself scrolls, return its ScrollableArea. |
| 733 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } | 772 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } |
| 734 | 773 |
| 735 // Modify or take an action on an object. | 774 // Modify or take an action on an object. |
| 736 virtual void increment() { } | 775 virtual void increment() { } |
| 737 virtual void decrement() { } | 776 virtual void decrement() { } |
| 738 bool performDefaultAction() const { return press(); } | 777 bool performDefaultAction() const { return press(); } |
| 739 virtual bool press() const; | 778 virtual bool press() const; |
| 740 // Make this object visible by scrolling as many nested scrollable views as
needed. | 779 // Make this object visible by scrolling as many nested scrollable views as
needed. |
| 741 void scrollToMakeVisible() const; | 780 void scrollToMakeVisible() const; |
| 742 // Same, but if the whole object can't be made visible, try for this subrect
, in local coordinates. | 781 // Same, but if the whole object can't be made visible, try for this subrect
, in local coordinates. |
| 743 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; | 782 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; |
| 744 // Scroll this object to a given point in global coordinates of the top-leve
l window. | 783 // Scroll this object to a given point in global coordinates of the top-leve
l window. |
| 745 void scrollToGlobalPoint(const IntPoint&) const; | 784 void scrollToGlobalPoint(const IntPoint&) const; |
| 746 virtual void setFocused(bool) { } | 785 virtual void setFocused(bool) { } |
| 747 virtual void setSelected(bool) { } | 786 virtual void setSelected(bool) { } |
| 748 void setSelectedText(const String&) { } | 787 void setSelectedText(const String&) { } |
| 749 virtual void setSelectedTextRange(const PlainTextRange&) { } | |
| 750 virtual void setValue(const String&) { } | 788 virtual void setValue(const String&) { } |
| 751 virtual void setValue(float) { } | 789 virtual void setValue(float) { } |
| 752 | 790 |
| 753 // Notifications that this object may have changed. | 791 // Notifications that this object may have changed. |
| 754 virtual void childrenChanged() { } | 792 virtual void childrenChanged() { } |
| 755 virtual void handleActiveDescendantChanged() { } | 793 virtual void handleActiveDescendantChanged() { } |
| 756 virtual void handleAriaExpandedChanged() { } | 794 virtual void handleAriaExpandedChanged() { } |
| 757 void notifyIfIgnoredValueChanged(); | 795 void notifyIfIgnoredValueChanged(); |
| 758 virtual void selectionChanged(); | 796 virtual void selectionChanged(); |
| 759 virtual void textChanged() { } | 797 virtual void textChanged() { } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 855 |
| 818 static unsigned s_numberOfLiveAXObjects; | 856 static unsigned s_numberOfLiveAXObjects; |
| 819 }; | 857 }; |
| 820 | 858 |
| 821 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | 859 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 822 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred
icate) | 860 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred
icate) |
| 823 | 861 |
| 824 } // namespace blink | 862 } // namespace blink |
| 825 | 863 |
| 826 #endif // AXObject_h | 864 #endif // AXObject_h |
| OLD | NEW |