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 | |
dmazzoni
2015/06/26 06:14:38
Maybe this should be isValid?
isNull is usually t
| |
407 { | |
408 return (anchorObject && !focusObject) | |
409 || (!anchorObject && focusObject) | |
410 || (anchorOffset < 0 || focusOffset < 0); | |
411 } | |
412 | |
413 // Determines if the range only refers to text offsets under the current object. | |
414 bool isSimple() const | |
415 { | |
416 return anchorObject == focusObject || !anchorObject || !focusObject; | |
417 } | |
386 }; | 418 }; |
387 | 419 |
388 protected: | 420 protected: |
389 AXObject(AXObjectCacheImpl&); | 421 AXObject(AXObjectCacheImpl&); |
390 | 422 |
391 public: | 423 public: |
392 virtual ~AXObject(); | 424 virtual ~AXObject(); |
393 | 425 |
394 // After constructing an AXObject, it must be given a | 426 // After constructing an AXObject, it must be given a |
395 // unique ID, then added to AXObjectCacheImpl, and finally init() must | 427 // unique ID, then added to AXObjectCacheImpl, and finally init() must |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 | 624 |
593 // Walk the AXObjects on the same line. This is supported on any | 625 // 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. | 626 // object type but primarily intended to be used for inline text boxes. |
595 virtual AXObject* nextOnLine() const { return nullptr; } | 627 virtual AXObject* nextOnLine() const { return nullptr; } |
596 virtual AXObject* previousOnLine() const { return nullptr; } | 628 virtual AXObject* previousOnLine() const { return nullptr; } |
597 | 629 |
598 // For an inline text box. | 630 // For an inline text box. |
599 // The integer horizontal pixel offset of each character in the string; nega tive values for RTL. | 631 // The integer horizontal pixel offset of each character in the string; nega tive values for RTL. |
600 virtual void textCharacterOffsets(Vector<int>&) const { } | 632 virtual void textCharacterOffsets(Vector<int>&) const { } |
601 // The start and end character offset of each word in the inline text box. | 633 // The start and end character offset of each word in the inline text box. |
602 virtual void wordBoundaries(Vector<PlainTextRange>& words) const { } | 634 virtual void wordBoundaries(Vector<AXRange>& words) const { } |
603 | 635 |
604 // Properties of interactive elements. | 636 // Properties of interactive elements. |
605 virtual String actionVerb() const; | 637 virtual String actionVerb() const; |
606 virtual AccessibilityButtonState checkboxOrRadioValue() const; | 638 virtual AccessibilityButtonState checkboxOrRadioValue() const; |
607 virtual InvalidState invalidState() const { return InvalidStateUndefined; } | 639 virtual InvalidState invalidState() const { return InvalidStateUndefined; } |
608 // Only used when invalidState() returns InvalidStateOther. | 640 // Only used when invalidState() returns InvalidStateOther. |
609 virtual String ariaInvalidValue() const { return String(); } | 641 virtual String ariaInvalidValue() const { return String(); } |
610 virtual String valueDescription() const { return String(); } | 642 virtual String valueDescription() const { return String(); } |
611 virtual float valueForRange() const { return 0.0f; } | 643 virtual float valueForRange() const { return 0.0f; } |
612 virtual float maxValueForRange() const { return 0.0f; } | 644 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; } | 738 virtual LayoutObject* layoutObject() const { return 0; } |
707 virtual Document* document() const; | 739 virtual Document* document() const; |
708 virtual FrameView* documentFrameView() const; | 740 virtual FrameView* documentFrameView() const; |
709 virtual Element* anchorElement() const { return 0; } | 741 virtual Element* anchorElement() const { return 0; } |
710 virtual Element* actionElement() const { return 0; } | 742 virtual Element* actionElement() const { return 0; } |
711 virtual Widget* widgetForAttachmentView() const { return 0; } | 743 virtual Widget* widgetForAttachmentView() const { return 0; } |
712 String language() const; | 744 String language() const; |
713 bool hasAttribute(const QualifiedName&) const; | 745 bool hasAttribute(const QualifiedName&) const; |
714 const AtomicString& getAttribute(const QualifiedName&) const; | 746 const AtomicString& getAttribute(const QualifiedName&) const; |
715 | 747 |
716 // Selected text. | 748 // Methods that retrieve or manipulate the current selection. |
717 virtual PlainTextRange selectedTextRange() const { return PlainTextRange(); } | 749 |
750 // Get the current selection from anywhere in the accessibility tree. | |
751 virtual AXRange selection() const { return AXRange(); } | |
752 // Gets only the start and end offsets of the selection computed using the | |
753 // current object as the starting point. Returns a null selection if there i s | |
754 // no selection in the subtree rooted at this object. | |
755 virtual AXRange selectionUnderObject() const { return AXRange(); } | |
756 virtual void setSelection(const AXRange&) { } | |
718 | 757 |
719 // Scrollable containers. | 758 // Scrollable containers. |
720 bool isScrollableContainer() const; | 759 bool isScrollableContainer() const; |
721 IntPoint scrollOffset() const; | 760 IntPoint scrollOffset() const; |
722 IntPoint minimumScrollOffset() const; | 761 IntPoint minimumScrollOffset() const; |
723 IntPoint maximumScrollOffset() const; | 762 IntPoint maximumScrollOffset() const; |
724 void setScrollOffset(const IntPoint&) const; | 763 void setScrollOffset(const IntPoint&) const; |
725 | 764 |
726 // If this object itself scrolls, return its ScrollableArea. | 765 // If this object itself scrolls, return its ScrollableArea. |
727 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } | 766 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } |
728 | 767 |
729 // Modify or take an action on an object. | 768 // Modify or take an action on an object. |
730 virtual void increment() { } | 769 virtual void increment() { } |
731 virtual void decrement() { } | 770 virtual void decrement() { } |
732 bool performDefaultAction() const { return press(); } | 771 bool performDefaultAction() const { return press(); } |
733 virtual bool press() const; | 772 virtual bool press() const; |
734 // Make this object visible by scrolling as many nested scrollable views as needed. | 773 // Make this object visible by scrolling as many nested scrollable views as needed. |
735 void scrollToMakeVisible() const; | 774 void scrollToMakeVisible() const; |
736 // Same, but if the whole object can't be made visible, try for this subrect , in local coordinates. | 775 // Same, but if the whole object can't be made visible, try for this subrect , in local coordinates. |
737 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; | 776 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; |
738 // Scroll this object to a given point in global coordinates of the top-leve l window. | 777 // Scroll this object to a given point in global coordinates of the top-leve l window. |
739 void scrollToGlobalPoint(const IntPoint&) const; | 778 void scrollToGlobalPoint(const IntPoint&) const; |
740 virtual void setFocused(bool) { } | 779 virtual void setFocused(bool) { } |
741 virtual void setSelected(bool) { } | 780 virtual void setSelected(bool) { } |
742 void setSelectedText(const String&) { } | 781 void setSelectedText(const String&) { } |
743 virtual void setSelectedTextRange(const PlainTextRange&) { } | |
744 virtual void setValue(const String&) { } | 782 virtual void setValue(const String&) { } |
745 virtual void setValue(float) { } | 783 virtual void setValue(float) { } |
746 | 784 |
747 // Notifications that this object may have changed. | 785 // Notifications that this object may have changed. |
748 virtual void childrenChanged() { } | 786 virtual void childrenChanged() { } |
749 virtual void handleActiveDescendantChanged() { } | 787 virtual void handleActiveDescendantChanged() { } |
750 virtual void handleAriaExpandedChanged() { } | 788 virtual void handleAriaExpandedChanged() { } |
751 void notifyIfIgnoredValueChanged(); | 789 void notifyIfIgnoredValueChanged(); |
752 virtual void selectionChanged(); | 790 virtual void selectionChanged(); |
753 virtual void textChanged() { } | 791 virtual void textChanged() { } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 static bool includesARIAWidgetRole(const String&); | 845 static bool includesARIAWidgetRole(const String&); |
808 static bool hasInteractiveARIAAttribute(const Element&); | 846 static bool hasInteractiveARIAAttribute(const Element&); |
809 }; | 847 }; |
810 | 848 |
811 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | 849 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ |
812 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate) | 850 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate) |
813 | 851 |
814 } // namespace blink | 852 } // namespace blink |
815 | 853 |
816 #endif // AXObject_h | 854 #endif // AXObject_h |
OLD | NEW |