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 AXSelection { |
359 // The ID of the deepest descendant in which the selection starts. | |
360 // (A value of 0 means the current object.) | |
361 AXID anchorId; | |
362 // The number of characters and child objects in the anchor object | |
363 // before the selection starts. | |
364 unsigned anchorOffset; | |
365 // The ID of the deepest descendant in which the selection ends. | |
366 // (A value of 0 means the current object.) | |
367 AXID focusId; | |
368 // The number of characters and child objects in the focus object | |
369 // before the selection ends. | |
370 unsigned focusOffset; | |
359 | 371 |
360 unsigned start; | 372 AXSelection() |
361 unsigned length; | 373 : anchorId(0) |
362 | 374 , anchorOffset(0) |
363 PlainTextRange() | 375 , focusId(0) |
364 : start(0) | 376 , focusOffset(0) |
365 , length(0) | |
366 { } | 377 { } |
367 | 378 |
368 PlainTextRange(unsigned s, unsigned l) | 379 AXSelection(unsigned startOffset, unsigned endOffset) |
369 : start(s) | 380 : anchorId(0) |
370 , length(l) | 381 , anchorOffset(startOffset) |
382 , focusId(0) | |
383 , focusOffset(endOffset) | |
371 { } | 384 { } |
372 | 385 |
373 bool isNull() const { return !start && !length; } | 386 AXSelection(AXID anchorId, unsigned anchorOffset, AXID focusId, unsigned focusOffset) |
387 : anchorId(anchorId) | |
388 , anchorOffset(anchorOffset) | |
389 , focusId(focusId) | |
390 , focusOffset(focusOffset) | |
391 { } | |
392 | |
393 bool isNull() const { return !anchorOffset && !focusOffset; } | |
394 bool hasAnchor() const { return !anchorId; } | |
395 bool hasFocus() const { return !focusId; } | |
374 }; | 396 }; |
375 | 397 |
376 protected: | 398 protected: |
377 AXObject(AXObjectCacheImpl*); | 399 AXObject(AXObjectCacheImpl*); |
378 | 400 |
379 public: | 401 public: |
380 virtual ~AXObject(); | 402 virtual ~AXObject(); |
381 | 403 |
382 // After constructing an AXObject, it must be given a | 404 // After constructing an AXObject, it must be given a |
383 // unique ID, then added to AXObjectCacheImpl, and finally init() must | 405 // unique ID, then added to AXObjectCacheImpl, and finally init() must |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 | 598 |
577 // Walk the AXObjects on the same line. This is supported on any | 599 // 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. | 600 // object type but primarily intended to be used for inline text boxes. |
579 virtual AXObject* nextOnLine() const { return nullptr; } | 601 virtual AXObject* nextOnLine() const { return nullptr; } |
580 virtual AXObject* previousOnLine() const { return nullptr; } | 602 virtual AXObject* previousOnLine() const { return nullptr; } |
581 | 603 |
582 // For an inline text box. | 604 // For an inline text box. |
583 // The integer horizontal pixel offset of each character in the string; nega tive values for RTL. | 605 // The integer horizontal pixel offset of each character in the string; nega tive values for RTL. |
584 virtual void textCharacterOffsets(Vector<int>&) const { } | 606 virtual void textCharacterOffsets(Vector<int>&) const { } |
585 // The start and end character offset of each word in the inline text box. | 607 // The start and end character offset of each word in the inline text box. |
586 virtual void wordBoundaries(Vector<PlainTextRange>& words) const { } | 608 virtual void wordBoundaries(Vector<AXSelection>& words) const { } |
587 | 609 |
588 // Properties of interactive elements. | 610 // Properties of interactive elements. |
589 virtual String actionVerb() const; | 611 virtual String actionVerb() const; |
590 virtual AccessibilityButtonState checkboxOrRadioValue() const; | 612 virtual AccessibilityButtonState checkboxOrRadioValue() const; |
591 virtual InvalidState invalidState() const { return InvalidStateUndefined; } | 613 virtual InvalidState invalidState() const { return InvalidStateUndefined; } |
592 // Only used when invalidState() returns InvalidStateOther. | 614 // Only used when invalidState() returns InvalidStateOther. |
593 virtual String ariaInvalidValue() const { return String(); } | 615 virtual String ariaInvalidValue() const { return String(); } |
594 virtual String valueDescription() const { return String(); } | 616 virtual String valueDescription() const { return String(); } |
595 virtual float valueForRange() const { return 0.0f; } | 617 virtual float valueForRange() const { return 0.0f; } |
596 virtual float maxValueForRange() const { return 0.0f; } | 618 virtual float maxValueForRange() const { return 0.0f; } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
692 virtual Node* node() const { return 0; } | 714 virtual Node* node() const { return 0; } |
693 virtual LayoutObject* layoutObject() const { return 0; } | 715 virtual LayoutObject* layoutObject() const { return 0; } |
694 virtual Document* document() const; | 716 virtual Document* document() const; |
695 virtual FrameView* documentFrameView() const; | 717 virtual FrameView* documentFrameView() const; |
696 virtual Element* anchorElement() const { return 0; } | 718 virtual Element* anchorElement() const { return 0; } |
697 virtual Element* actionElement() const { return 0; } | 719 virtual Element* actionElement() const { return 0; } |
698 virtual Widget* widgetForAttachmentView() const { return 0; } | 720 virtual Widget* widgetForAttachmentView() const { return 0; } |
699 String language() const; | 721 String language() const; |
700 bool hasAttribute(const QualifiedName&) const; | 722 bool hasAttribute(const QualifiedName&) const; |
701 const AtomicString& getAttribute(const QualifiedName&) const; | 723 const AtomicString& getAttribute(const QualifiedName&) const; |
702 | 724 virtual AXSelection selection() const { return AXSelection(); } |
703 // Selected text. | 725 virtual AXSelection selectionUnderObject() const { return AXSelection(); } |
704 virtual PlainTextRange selectedTextRange() const { return PlainTextRange(); } | |
705 | 726 |
706 // Scrollable containers. | 727 // Scrollable containers. |
707 bool isScrollableContainer() const; | 728 bool isScrollableContainer() const; |
708 IntPoint scrollOffset() const; | 729 IntPoint scrollOffset() const; |
709 IntPoint minimumScrollOffset() const; | 730 IntPoint minimumScrollOffset() const; |
710 IntPoint maximumScrollOffset() const; | 731 IntPoint maximumScrollOffset() const; |
711 void setScrollOffset(const IntPoint&) const; | 732 void setScrollOffset(const IntPoint&) const; |
712 | 733 |
713 // If this object itself scrolls, return its ScrollableArea. | 734 // If this object itself scrolls, return its ScrollableArea. |
714 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } | 735 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } |
715 | 736 |
716 // Modify or take an action on an object. | 737 // Modify or take an action on an object. |
717 virtual void increment() { } | 738 virtual void increment() { } |
718 virtual void decrement() { } | 739 virtual void decrement() { } |
719 bool performDefaultAction() const { return press(); } | 740 bool performDefaultAction() const { return press(); } |
720 virtual bool press() const; | 741 virtual bool press() const; |
721 // Make this object visible by scrolling as many nested scrollable views as needed. | 742 // Make this object visible by scrolling as many nested scrollable views as needed. |
722 void scrollToMakeVisible() const; | 743 void scrollToMakeVisible() const; |
723 // Same, but if the whole object can't be made visible, try for this subrect , in local coordinates. | 744 // Same, but if the whole object can't be made visible, try for this subrect , in local coordinates. |
724 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; | 745 void scrollToMakeVisibleWithSubFocus(const IntRect&) const; |
725 // Scroll this object to a given point in global coordinates of the top-leve l window. | 746 // Scroll this object to a given point in global coordinates of the top-leve l window. |
726 void scrollToGlobalPoint(const IntPoint&) const; | 747 void scrollToGlobalPoint(const IntPoint&) const; |
727 virtual void setFocused(bool) { } | 748 virtual void setFocused(bool) { } |
728 virtual void setSelected(bool) { } | 749 virtual void setSelected(bool) { } |
729 void setSelectedText(const String&) { } | 750 void setSelectedText(const String&) { } |
730 virtual void setSelectedTextRange(const PlainTextRange&) { } | 751 virtual void setSelection(const AXSelection&) { } |
dmazzoni
2015/06/16 17:24:04
Why is setSelection implemented here but not expos
| |
731 virtual void setValue(const String&) { } | 752 virtual void setValue(const String&) { } |
732 virtual void setValue(float) { } | 753 virtual void setValue(float) { } |
733 | 754 |
734 // Notifications that this object may have changed. | 755 // Notifications that this object may have changed. |
735 virtual void childrenChanged() { } | 756 virtual void childrenChanged() { } |
736 virtual void handleActiveDescendantChanged() { } | 757 virtual void handleActiveDescendantChanged() { } |
737 virtual void handleAriaExpandedChanged() { } | 758 virtual void handleAriaExpandedChanged() { } |
738 void notifyIfIgnoredValueChanged(); | 759 void notifyIfIgnoredValueChanged(); |
739 virtual void selectionChanged(); | 760 virtual void selectionChanged(); |
740 virtual void textChanged() { } | 761 virtual void textChanged() { } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
796 static bool includesARIAWidgetRole(const String&); | 817 static bool includesARIAWidgetRole(const String&); |
797 static bool hasInteractiveARIAAttribute(const Element&); | 818 static bool hasInteractiveARIAAttribute(const Element&); |
798 }; | 819 }; |
799 | 820 |
800 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | 821 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ |
801 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate) | 822 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate) |
802 | 823 |
803 } // namespace blink | 824 } // namespace blink |
804 | 825 |
805 #endif // AXObject_h | 826 #endif // AXObject_h |
OLD | NEW |