| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 IgnoredReason(AXIgnoredReason r, const AXObject* obj) | 348 IgnoredReason(AXIgnoredReason r, const AXObject* obj) |
| 349 : reason(r) | 349 : reason(r) |
| 350 , relatedObject(obj) | 350 , relatedObject(obj) |
| 351 { } | 351 { } |
| 352 }; | 352 }; |
| 353 | 353 |
| 354 class MODULES_EXPORT AXObject : public RefCounted<AXObject> { | 354 class MODULES_EXPORT AXObject : public RefCounted<AXObject> { |
| 355 public: | 355 public: |
| 356 typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector; | 356 typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector; |
| 357 | 357 |
| 358 struct PlainTextRange { | 358 struct AXRange { |
| 359 // The deepest descendant in which the range starts. |
| 360 // (nullptr means the current object.) |
| 361 RefPtrWillBePersistent<AXObject> anchorObject; |
| 362 // The number of characters and child objects in the anchor object |
| 363 // before the range starts. |
| 364 int anchorOffset; |
| 365 // The deepest descendant in which the range ends. |
| 366 // (nullptr means the current object.) |
| 367 RefPtrWillBePersistent<AXObject> focusObject; |
| 368 // The number of characters and child objects in the focus object |
| 369 // before the range ends. |
| 370 int focusOffset; |
| 359 | 371 |
| 360 unsigned start; | 372 AXRange() |
| 361 unsigned length; | 373 : anchorObject(nullptr) |
| 362 | 374 , anchorOffset(-1) |
| 363 PlainTextRange() | 375 , focusObject(nullptr) |
| 364 : start(0) | 376 , focusOffset(-1) |
| 365 , length(0) | |
| 366 { } | 377 { } |
| 367 | 378 |
| 368 PlainTextRange(unsigned s, unsigned l) | 379 AXRange(int startOffset, int endOffset) |
| 369 : start(s) | 380 : anchorObject(nullptr) |
| 370 , length(l) | 381 , anchorOffset(startOffset) |
| 382 , focusObject(nullptr) |
| 383 , focusOffset(endOffset) |
| 371 { } | 384 { } |
| 372 | 385 |
| 373 bool isNull() const { return !start && !length; } | 386 AXRange(PassRefPtrWillBeRawPtr<AXObject> anchorObject, int anchorOffset, |
| 387 PassRefPtrWillBeRawPtr<AXObject> focusObject, int focusOffset) |
| 388 : anchorObject(anchorObject) |
| 389 , anchorOffset(anchorOffset) |
| 390 , focusObject(focusObject) |
| 391 , focusOffset(focusOffset) |
| 392 { } |
| 393 |
| 394 bool isNull() const { return anchorOffset < 0 || focusOffset < 0; } |
| 395 // Determines if the range only refers to text offsets under the current
object. |
| 396 bool isSimple() const { return !anchorObject || !focusObject; } |
| 374 }; | 397 }; |
| 375 | 398 |
| 376 protected: | 399 protected: |
| 377 AXObject(AXObjectCacheImpl*); | 400 AXObject(AXObjectCacheImpl*); |
| 378 | 401 |
| 379 public: | 402 public: |
| 380 virtual ~AXObject(); | 403 virtual ~AXObject(); |
| 381 | 404 |
| 382 // After constructing an AXObject, it must be given a | 405 // After constructing an AXObject, it must be given a |
| 383 // unique ID, then added to AXObjectCacheImpl, and finally init() must | 406 // unique ID, then added to AXObjectCacheImpl, and finally init() must |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 | 599 |
| 577 // Walk the AXObjects on the same line. This is supported on any | 600 // Walk the AXObjects on the same line. This is supported on any |
| 578 // object type but primarily intended to be used for inline text boxes. | 601 // object type but primarily intended to be used for inline text boxes. |
| 579 virtual AXObject* nextOnLine() const { return nullptr; } | 602 virtual AXObject* nextOnLine() const { return nullptr; } |
| 580 virtual AXObject* previousOnLine() const { return nullptr; } | 603 virtual AXObject* previousOnLine() const { return nullptr; } |
| 581 | 604 |
| 582 // For an inline text box. | 605 // For an inline text box. |
| 583 // The integer horizontal pixel offset of each character in the string; nega
tive values for RTL. | 606 // The integer horizontal pixel offset of each character in the string; nega
tive values for RTL. |
| 584 virtual void textCharacterOffsets(Vector<int>&) const { } | 607 virtual void textCharacterOffsets(Vector<int>&) const { } |
| 585 // The start and end character offset of each word in the inline text box. | 608 // The start and end character offset of each word in the inline text box. |
| 586 virtual void wordBoundaries(Vector<PlainTextRange>& words) const { } | 609 virtual void wordBoundaries(Vector<AXRange>& words) const { } |
| 587 | 610 |
| 588 // Properties of interactive elements. | 611 // Properties of interactive elements. |
| 589 virtual String actionVerb() const; | 612 virtual String actionVerb() const; |
| 590 virtual AccessibilityButtonState checkboxOrRadioValue() const; | 613 virtual AccessibilityButtonState checkboxOrRadioValue() const; |
| 591 virtual InvalidState invalidState() const { return InvalidStateUndefined; } | 614 virtual InvalidState invalidState() const { return InvalidStateUndefined; } |
| 592 // Only used when invalidState() returns InvalidStateOther. | 615 // Only used when invalidState() returns InvalidStateOther. |
| 593 virtual String ariaInvalidValue() const { return String(); } | 616 virtual String ariaInvalidValue() const { return String(); } |
| 594 virtual String valueDescription() const { return String(); } | 617 virtual String valueDescription() const { return String(); } |
| 595 virtual float valueForRange() const { return 0.0f; } | 618 virtual float valueForRange() const { return 0.0f; } |
| 596 virtual float maxValueForRange() const { return 0.0f; } | 619 virtual float maxValueForRange() const { return 0.0f; } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 virtual LayoutObject* layoutObject() const { return 0; } | 713 virtual LayoutObject* layoutObject() const { return 0; } |
| 691 virtual Document* document() const; | 714 virtual Document* document() const; |
| 692 virtual FrameView* documentFrameView() const; | 715 virtual FrameView* documentFrameView() const; |
| 693 virtual Element* anchorElement() const { return 0; } | 716 virtual Element* anchorElement() const { return 0; } |
| 694 virtual Element* actionElement() const { return 0; } | 717 virtual Element* actionElement() const { return 0; } |
| 695 virtual Widget* widgetForAttachmentView() const { return 0; } | 718 virtual Widget* widgetForAttachmentView() const { return 0; } |
| 696 String language() const; | 719 String language() const; |
| 697 bool hasAttribute(const QualifiedName&) const; | 720 bool hasAttribute(const QualifiedName&) const; |
| 698 const AtomicString& getAttribute(const QualifiedName&) const; | 721 const AtomicString& getAttribute(const QualifiedName&) const; |
| 699 | 722 |
| 700 // Selected text. | 723 // |
| 701 virtual PlainTextRange selectedTextRange() const { return PlainTextRange();
} | 724 // Methods that retrieve or manipulate the current selection. |
| 725 // |
| 726 |
| 727 // Get the current selection from anywhere in the accessibility tree. |
| 728 virtual AXRange selection() const { return AXRange(); } |
| 729 // Gets only the start and end offsets of the selection computed using the |
| 730 // current object as the starting point. Returns a null selection if there i
s |
| 731 // no selection in the subtree rooted at this object. |
| 732 virtual AXRange selectionUnderObject() const { return AXRange(); } |
| 733 virtual void setSelection(const AXRange&) { } |
| 702 | 734 |
| 703 // Scrollable containers. | 735 // Scrollable containers. |
| 704 bool isScrollableContainer() const; | 736 bool isScrollableContainer() const; |
| 705 IntPoint scrollOffset() const; | 737 IntPoint scrollOffset() const; |
| 706 IntPoint minimumScrollOffset() const; | 738 IntPoint minimumScrollOffset() const; |
| 707 IntPoint maximumScrollOffset() const; | 739 IntPoint maximumScrollOffset() const; |
| 708 void setScrollOffset(const IntPoint&) const; | 740 void setScrollOffset(const IntPoint&) const; |
| 709 | 741 |
| 710 // If this object itself scrolls, return its ScrollableArea. | 742 // If this object itself scrolls, return its ScrollableArea. |
| 711 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } | 743 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } |
| 712 | 744 |
| 713 // Modify or take an action on an object. | 745 // Modify or take an action on an object. |
| 714 virtual void increment() { } | 746 virtual void increment() { } |
| 715 virtual void decrement() { } | 747 virtual void decrement() { } |
| 716 bool performDefaultAction() const { return press(); } | 748 bool performDefaultAction() const { return press(); } |
| 717 virtual bool press() const; | 749 virtual bool press() const; |
| 718 // Make this object visible by scrolling as many nested scrollable views as
needed. | 750 // Make this object visible by scrolling as many nested scrollable views as
needed. |
| 719 void scrollToMakeVisible() const; | 751 void scrollToMakeVisible() const; |
| 720 // Same, but if the whole object can't be made visible, try for this subrect
, in local coordinates. | 752 // Same, but if the whole object can't be made visible, try for this subrect
, in local coordinates. |
| 721 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; | 753 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; |
| 722 // Scroll this object to a given point in global coordinates of the top-leve
l window. | 754 // Scroll this object to a given point in global coordinates of the top-leve
l window. |
| 723 void scrollToGlobalPoint(const IntPoint&) const; | 755 void scrollToGlobalPoint(const IntPoint&) const; |
| 724 virtual void setFocused(bool) { } | 756 virtual void setFocused(bool) { } |
| 725 virtual void setSelected(bool) { } | 757 virtual void setSelected(bool) { } |
| 726 void setSelectedText(const String&) { } | 758 void setSelectedText(const String&) { } |
| 727 virtual void setSelectedTextRange(const PlainTextRange&) { } | |
| 728 virtual void setValue(const String&) { } | 759 virtual void setValue(const String&) { } |
| 729 virtual void setValue(float) { } | 760 virtual void setValue(float) { } |
| 730 | 761 |
| 731 // Notifications that this object may have changed. | 762 // Notifications that this object may have changed. |
| 732 virtual void childrenChanged() { } | 763 virtual void childrenChanged() { } |
| 733 virtual void handleActiveDescendantChanged() { } | 764 virtual void handleActiveDescendantChanged() { } |
| 734 virtual void handleAriaExpandedChanged() { } | 765 virtual void handleAriaExpandedChanged() { } |
| 735 void notifyIfIgnoredValueChanged(); | 766 void notifyIfIgnoredValueChanged(); |
| 736 virtual void selectionChanged(); | 767 virtual void selectionChanged(); |
| 737 virtual void textChanged() { } | 768 virtual void textChanged() { } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 static bool includesARIAWidgetRole(const String&); | 824 static bool includesARIAWidgetRole(const String&); |
| 794 static bool hasInteractiveARIAAttribute(const Element&); | 825 static bool hasInteractiveARIAAttribute(const Element&); |
| 795 }; | 826 }; |
| 796 | 827 |
| 797 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | 828 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 798 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred
icate) | 829 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred
icate) |
| 799 | 830 |
| 800 } // namespace blink | 831 } // namespace blink |
| 801 | 832 |
| 802 #endif // AXObject_h | 833 #endif // AXObject_h |
| OLD | NEW |