Chromium Code Reviews| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 IgnoredReason(AXIgnoredReason r, const AXObject* obj) | 360 IgnoredReason(AXIgnoredReason r, const AXObject* obj) |
| 361 : reason(r) | 361 : reason(r) |
| 362 , relatedObject(obj) | 362 , relatedObject(obj) |
| 363 { } | 363 { } |
| 364 }; | 364 }; |
| 365 | 365 |
| 366 class MODULES_EXPORT AXObject : public RefCounted<AXObject> { | 366 class MODULES_EXPORT AXObject : public RefCounted<AXObject> { |
| 367 public: | 367 public: |
| 368 typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector; | 368 typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector; |
| 369 | 369 |
| 370 struct PlainTextRange { | 370 struct AXRange { |
| 371 // The deepest descendant in which the range starts. | |
| 372 // (nullptr means the current object.) | |
| 373 RefPtrWillBePersistent<AXObject> anchorObject; | |
| 374 // The number of characters and child objects in the anchor object | |
| 375 // before the range starts. | |
| 376 int anchorOffset; | |
| 377 // The deepest descendant in which the range ends. | |
| 378 // (nullptr means the current object.) | |
| 379 RefPtrWillBePersistent<AXObject> focusObject; | |
| 380 // The number of characters and child objects in the focus object | |
| 381 // before the range ends. | |
| 382 int focusOffset; | |
| 371 | 383 |
| 372 unsigned start; | 384 AXRange() |
| 373 unsigned length; | 385 : anchorObject(nullptr) |
| 374 | 386 , anchorOffset(-1) |
| 375 PlainTextRange() | 387 , focusObject(nullptr) |
| 376 : start(0) | 388 , focusOffset(-1) |
| 377 , length(0) | |
| 378 { } | 389 { } |
| 379 | 390 |
| 380 PlainTextRange(unsigned s, unsigned l) | 391 AXRange(int startOffset, int endOffset) |
| 381 : start(s) | 392 : anchorObject(nullptr) |
| 382 , length(l) | 393 , anchorOffset(startOffset) |
| 394 , focusObject(nullptr) | |
| 395 , focusOffset(endOffset) | |
| 383 { } | 396 { } |
| 384 | 397 |
| 385 bool isNull() const { return !start && !length; } | 398 AXRange(PassRefPtrWillBeRawPtr<AXObject> anchorObject, int anchorOffset, |
| 399 PassRefPtrWillBeRawPtr<AXObject> focusObject, int focusOffset) | |
| 400 : anchorObject(anchorObject) | |
| 401 , anchorOffset(anchorOffset) | |
| 402 , focusObject(focusObject) | |
| 403 , focusOffset(focusOffset) | |
| 404 { } | |
| 405 | |
| 406 bool isNull() const { return anchorOffset < 0 || focusOffset < 0; } | |
| 407 // Determines if the range only refers to text offsets under the current object. | |
| 408 bool isSimple() const | |
| 409 { | |
| 410 return anchorObject == focusObject || !anchorObject || !focusObject; | |
|
dmazzoni
2015/06/24 00:11:01
I don't think this should return null if just one
| |
| 411 } | |
| 386 }; | 412 }; |
| 387 | 413 |
| 388 protected: | 414 protected: |
| 389 AXObject(AXObjectCacheImpl&); | 415 AXObject(AXObjectCacheImpl&); |
| 390 | 416 |
| 391 public: | 417 public: |
| 392 virtual ~AXObject(); | 418 virtual ~AXObject(); |
| 393 | 419 |
| 394 // After constructing an AXObject, it must be given a | 420 // After constructing an AXObject, it must be given a |
| 395 // unique ID, then added to AXObjectCacheImpl, and finally init() must | 421 // unique ID, then added to AXObjectCacheImpl, and finally init() must |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 | 618 |
| 593 // Walk the AXObjects on the same line. This is supported on any | 619 // Walk the AXObjects on the same line. This is supported on any |
| 594 // object type but primarily intended to be used for inline text boxes. | 620 // object type but primarily intended to be used for inline text boxes. |
| 595 virtual AXObject* nextOnLine() const { return nullptr; } | 621 virtual AXObject* nextOnLine() const { return nullptr; } |
| 596 virtual AXObject* previousOnLine() const { return nullptr; } | 622 virtual AXObject* previousOnLine() const { return nullptr; } |
| 597 | 623 |
| 598 // For an inline text box. | 624 // For an inline text box. |
| 599 // The integer horizontal pixel offset of each character in the string; nega tive values for RTL. | 625 // The integer horizontal pixel offset of each character in the string; nega tive values for RTL. |
| 600 virtual void textCharacterOffsets(Vector<int>&) const { } | 626 virtual void textCharacterOffsets(Vector<int>&) const { } |
| 601 // The start and end character offset of each word in the inline text box. | 627 // The start and end character offset of each word in the inline text box. |
| 602 virtual void wordBoundaries(Vector<PlainTextRange>& words) const { } | 628 virtual void wordBoundaries(Vector<AXRange>& words) const { } |
| 603 | 629 |
| 604 // Properties of interactive elements. | 630 // Properties of interactive elements. |
| 605 virtual String actionVerb() const; | 631 virtual String actionVerb() const; |
| 606 virtual AccessibilityButtonState checkboxOrRadioValue() const; | 632 virtual AccessibilityButtonState checkboxOrRadioValue() const; |
| 607 virtual InvalidState invalidState() const { return InvalidStateUndefined; } | 633 virtual InvalidState invalidState() const { return InvalidStateUndefined; } |
| 608 // Only used when invalidState() returns InvalidStateOther. | 634 // Only used when invalidState() returns InvalidStateOther. |
| 609 virtual String ariaInvalidValue() const { return String(); } | 635 virtual String ariaInvalidValue() const { return String(); } |
| 610 virtual String valueDescription() const { return String(); } | 636 virtual String valueDescription() const { return String(); } |
| 611 virtual float valueForRange() const { return 0.0f; } | 637 virtual float valueForRange() const { return 0.0f; } |
| 612 virtual float maxValueForRange() const { return 0.0f; } | 638 virtual float maxValueForRange() const { return 0.0f; } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 virtual LayoutObject* layoutObject() const { return 0; } | 732 virtual LayoutObject* layoutObject() const { return 0; } |
| 707 virtual Document* document() const; | 733 virtual Document* document() const; |
| 708 virtual FrameView* documentFrameView() const; | 734 virtual FrameView* documentFrameView() const; |
| 709 virtual Element* anchorElement() const { return 0; } | 735 virtual Element* anchorElement() const { return 0; } |
| 710 virtual Element* actionElement() const { return 0; } | 736 virtual Element* actionElement() const { return 0; } |
| 711 virtual Widget* widgetForAttachmentView() const { return 0; } | 737 virtual Widget* widgetForAttachmentView() const { return 0; } |
| 712 String language() const; | 738 String language() const; |
| 713 bool hasAttribute(const QualifiedName&) const; | 739 bool hasAttribute(const QualifiedName&) const; |
| 714 const AtomicString& getAttribute(const QualifiedName&) const; | 740 const AtomicString& getAttribute(const QualifiedName&) const; |
| 715 | 741 |
| 716 // Selected text. | 742 // Methods that retrieve or manipulate the current selection. |
| 717 virtual PlainTextRange selectedTextRange() const { return PlainTextRange(); } | 743 |
| 744 // Get the current selection from anywhere in the accessibility tree. | |
| 745 virtual AXRange selection() const { return AXRange(); } | |
| 746 // Gets only the start and end offsets of the selection computed using the | |
| 747 // current object as the starting point. Returns a null selection if there i s | |
| 748 // no selection in the subtree rooted at this object. | |
| 749 virtual AXRange selectionUnderObject() const { return AXRange(); } | |
| 750 virtual void setSelection(const AXRange&) { } | |
| 718 | 751 |
| 719 // Scrollable containers. | 752 // Scrollable containers. |
| 720 bool isScrollableContainer() const; | 753 bool isScrollableContainer() const; |
| 721 IntPoint scrollOffset() const; | 754 IntPoint scrollOffset() const; |
| 722 IntPoint minimumScrollOffset() const; | 755 IntPoint minimumScrollOffset() const; |
| 723 IntPoint maximumScrollOffset() const; | 756 IntPoint maximumScrollOffset() const; |
| 724 void setScrollOffset(const IntPoint&) const; | 757 void setScrollOffset(const IntPoint&) const; |
| 725 | 758 |
| 726 // If this object itself scrolls, return its ScrollableArea. | 759 // If this object itself scrolls, return its ScrollableArea. |
| 727 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } | 760 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } |
| 728 | 761 |
| 729 // Modify or take an action on an object. | 762 // Modify or take an action on an object. |
| 730 virtual void increment() { } | 763 virtual void increment() { } |
| 731 virtual void decrement() { } | 764 virtual void decrement() { } |
| 732 bool performDefaultAction() const { return press(); } | 765 bool performDefaultAction() const { return press(); } |
| 733 virtual bool press() const; | 766 virtual bool press() const; |
| 734 // Make this object visible by scrolling as many nested scrollable views as needed. | 767 // Make this object visible by scrolling as many nested scrollable views as needed. |
| 735 void scrollToMakeVisible() const; | 768 void scrollToMakeVisible() const; |
| 736 // Same, but if the whole object can't be made visible, try for this subrect , in local coordinates. | 769 // Same, but if the whole object can't be made visible, try for this subrect , in local coordinates. |
| 737 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; | 770 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; |
| 738 // Scroll this object to a given point in global coordinates of the top-leve l window. | 771 // Scroll this object to a given point in global coordinates of the top-leve l window. |
| 739 void scrollToGlobalPoint(const IntPoint&) const; | 772 void scrollToGlobalPoint(const IntPoint&) const; |
| 740 virtual void setFocused(bool) { } | 773 virtual void setFocused(bool) { } |
| 741 virtual void setSelected(bool) { } | 774 virtual void setSelected(bool) { } |
| 742 void setSelectedText(const String&) { } | 775 void setSelectedText(const String&) { } |
| 743 virtual void setSelectedTextRange(const PlainTextRange&) { } | |
| 744 virtual void setValue(const String&) { } | 776 virtual void setValue(const String&) { } |
| 745 virtual void setValue(float) { } | 777 virtual void setValue(float) { } |
| 746 | 778 |
| 747 // Notifications that this object may have changed. | 779 // Notifications that this object may have changed. |
| 748 virtual void childrenChanged() { } | 780 virtual void childrenChanged() { } |
| 749 virtual void handleActiveDescendantChanged() { } | 781 virtual void handleActiveDescendantChanged() { } |
| 750 virtual void handleAriaExpandedChanged() { } | 782 virtual void handleAriaExpandedChanged() { } |
| 751 void notifyIfIgnoredValueChanged(); | 783 void notifyIfIgnoredValueChanged(); |
| 752 virtual void selectionChanged(); | 784 virtual void selectionChanged(); |
| 753 virtual void textChanged() { } | 785 virtual void textChanged() { } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 static bool includesARIAWidgetRole(const String&); | 839 static bool includesARIAWidgetRole(const String&); |
| 808 static bool hasInteractiveARIAAttribute(const Element&); | 840 static bool hasInteractiveARIAAttribute(const Element&); |
| 809 }; | 841 }; |
| 810 | 842 |
| 811 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | 843 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 812 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate) | 844 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate) |
| 813 | 845 |
| 814 } // namespace blink | 846 } // namespace blink |
| 815 | 847 |
| 816 #endif // AXObject_h | 848 #endif // AXObject_h |
| OLD | NEW |