| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 AXVerticalState, | 213 AXVerticalState, |
| 214 AXVisitedState | 214 AXVisitedState |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 class AccessibilityText final : public NoBaseWillBeGarbageCollectedFinalized<Acc
essibilityText> { | 217 class AccessibilityText final : public NoBaseWillBeGarbageCollectedFinalized<Acc
essibilityText> { |
| 218 public: | 218 public: |
| 219 static PassOwnPtrWillBeRawPtr<AccessibilityText> create(const String& text,
const AccessibilityTextSource& source) | 219 static PassOwnPtrWillBeRawPtr<AccessibilityText> create(const String& text,
const AccessibilityTextSource& source) |
| 220 { | 220 { |
| 221 return adoptPtrWillBeNoop(new AccessibilityText(text, source, nullptr)); | 221 return adoptPtrWillBeNoop(new AccessibilityText(text, source, nullptr)); |
| 222 } | 222 } |
| 223 static PassOwnPtrWillBeRawPtr<AccessibilityText> create(const String& text,
const AccessibilityTextSource& source, const RefPtr<AXObject> element) | 223 static PassOwnPtrWillBeRawPtr<AccessibilityText> create(const String& text,
const AccessibilityTextSource& source, const RefPtrWillBeRawPtr<AXObject> elemen
t) |
| 224 { | 224 { |
| 225 return adoptPtrWillBeNoop(new AccessibilityText(text, source, nullptr)); | 225 return adoptPtrWillBeNoop(new AccessibilityText(text, source, nullptr)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 String text() const { return m_text; } | 228 String text() const { return m_text; } |
| 229 AccessibilityTextSource textSource() const { return m_textSource; } | 229 AccessibilityTextSource textSource() const { return m_textSource; } |
| 230 AXObject* textElement() const { return m_textElement.get(); } | 230 AXObject* textElement() const { return m_textElement.get(); } |
| 231 | 231 |
| 232 DEFINE_INLINE_TRACE() { } | 232 DEFINE_INLINE_TRACE() |
| 233 { |
| 234 visitor->trace(m_textElement); |
| 235 } |
| 233 | 236 |
| 234 private: | 237 private: |
| 235 AccessibilityText(const String& text, const AccessibilityTextSource& source,
const PassRefPtr<AXObject> element) | 238 AccessibilityText(const String& text, const AccessibilityTextSource& source,
const RefPtrWillBeRawPtr<AXObject> element) |
| 236 : m_text(text) | 239 : m_text(text) |
| 237 , m_textSource(source) | 240 , m_textSource(source) |
| 238 , m_textElement(element) | 241 , m_textElement(element) |
| 239 { } | 242 { } |
| 240 | 243 |
| 241 String m_text; | 244 String m_text; |
| 242 AccessibilityTextSource m_textSource; | 245 AccessibilityTextSource m_textSource; |
| 243 RefPtr<AXObject> m_textElement; | 246 RefPtrWillBeMember<AXObject> m_textElement; |
| 244 }; | 247 }; |
| 245 | 248 |
| 246 enum AccessibilityOrientation { | 249 enum AccessibilityOrientation { |
| 247 AccessibilityOrientationUndefined = 0, | 250 AccessibilityOrientationUndefined = 0, |
| 248 AccessibilityOrientationVertical, | 251 AccessibilityOrientationVertical, |
| 249 AccessibilityOrientationHorizontal, | 252 AccessibilityOrientationHorizontal, |
| 250 }; | 253 }; |
| 251 | 254 |
| 252 enum AXObjectInclusion { | 255 enum AXObjectInclusion { |
| 253 IncludeObject, | 256 IncludeObject, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 : reason(reason) | 359 : reason(reason) |
| 357 , relatedObject(nullptr) | 360 , relatedObject(nullptr) |
| 358 { } | 361 { } |
| 359 | 362 |
| 360 IgnoredReason(AXIgnoredReason r, const AXObject* obj) | 363 IgnoredReason(AXIgnoredReason r, const AXObject* obj) |
| 361 : reason(r) | 364 : reason(r) |
| 362 , relatedObject(obj) | 365 , relatedObject(obj) |
| 363 { } | 366 { } |
| 364 }; | 367 }; |
| 365 | 368 |
| 366 class MODULES_EXPORT AXObject : public RefCounted<AXObject> { | 369 class MODULES_EXPORT AXObject : public RefCountedWillBeGarbageCollectedFinalized
<AXObject> { |
| 367 public: | 370 public: |
| 368 typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector; | 371 typedef WillBeHeapVector<RefPtrWillBeMember<AXObject>> AccessibilityChildren
Vector; |
| 369 | 372 |
| 370 struct PlainTextRange { | 373 struct PlainTextRange { |
| 371 | 374 |
| 372 unsigned start; | 375 unsigned start; |
| 373 unsigned length; | 376 unsigned length; |
| 374 | 377 |
| 375 PlainTextRange() | 378 PlainTextRange() |
| 376 : start(0) | 379 : start(0) |
| 377 , length(0) | 380 , length(0) |
| 378 { } | 381 { } |
| 379 | 382 |
| 380 PlainTextRange(unsigned s, unsigned l) | 383 PlainTextRange(unsigned s, unsigned l) |
| 381 : start(s) | 384 : start(s) |
| 382 , length(l) | 385 , length(l) |
| 383 { } | 386 { } |
| 384 | 387 |
| 385 bool isNull() const { return !start && !length; } | 388 bool isNull() const { return !start && !length; } |
| 386 }; | 389 }; |
| 387 | 390 |
| 388 protected: | 391 protected: |
| 389 AXObject(AXObjectCacheImpl&); | 392 AXObject(AXObjectCacheImpl&); |
| 390 | 393 |
| 391 public: | 394 public: |
| 392 virtual ~AXObject(); | 395 virtual ~AXObject(); |
| 396 DECLARE_VIRTUAL_TRACE(); |
| 393 | 397 |
| 394 // After constructing an AXObject, it must be given a | 398 // After constructing an AXObject, it must be given a |
| 395 // unique ID, then added to AXObjectCacheImpl, and finally init() must | 399 // unique ID, then added to AXObjectCacheImpl, and finally init() must |
| 396 // be called last. | 400 // be called last. |
| 397 void setAXObjectID(AXID axObjectID) { m_id = axObjectID; } | 401 void setAXObjectID(AXID axObjectID) { m_id = axObjectID; } |
| 398 virtual void init() { } | 402 virtual void init() { } |
| 399 | 403 |
| 400 // When the corresponding WebCore object that this AXObject | 404 // When the corresponding WebCore object that this AXObject |
| 401 // wraps is deleted, it must be detached. | 405 // wraps is deleted, it must be detached. |
| 402 virtual void detach(); | 406 virtual void detach(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 virtual String deprecatedTitle(TextUnderElementMode mode = TextUnderElementA
ll) const { return String(); } | 541 virtual String deprecatedTitle(TextUnderElementMode mode = TextUnderElementA
ll) const { return String(); } |
| 538 virtual String deprecatedHelpText() const { return String(); } | 542 virtual String deprecatedHelpText() const { return String(); } |
| 539 virtual String deprecatedTextUnderElement(TextUnderElementMode mode = TextUn
derElementAll) const { return String(); } | 543 virtual String deprecatedTextUnderElement(TextUnderElementMode mode = TextUn
derElementAll) const { return String(); } |
| 540 | 544 |
| 541 // | 545 // |
| 542 // New text alternative calculation API (under development). | 546 // New text alternative calculation API (under development). |
| 543 // | 547 // |
| 544 | 548 |
| 545 // Retrieves the accessible name of the object, an enum indicating where the
name | 549 // Retrieves the accessible name of the object, an enum indicating where the
name |
| 546 // was derived from, and a list of objects that were used to derive the name
, if any. | 550 // was derived from, and a list of objects that were used to derive the name
, if any. |
| 547 virtual String name(AXNameFrom&, Vector<AXObject*>& nameObjects); | 551 virtual String name(AXNameFrom&, WillBeHeapVector<RawPtrWillBeMember<AXObjec
t>>& nameObjects); |
| 548 | 552 |
| 549 // Takes the result of nameFrom from calling |name|, above, and retrieves th
e | 553 // Takes the result of nameFrom from calling |name|, above, and retrieves th
e |
| 550 // accessible description of the object, which is secondary to |name|, an en
um indicating | 554 // accessible description of the object, which is secondary to |name|, an en
um indicating |
| 551 // where the description was derived from, and a list of objects that were u
sed to | 555 // where the description was derived from, and a list of objects that were u
sed to |
| 552 // derive the description, if any. | 556 // derive the description, if any. |
| 553 virtual String description(AXNameFrom, AXDescriptionFrom&, Vector<AXObject*>
& descriptionObjects) { return String(); } | 557 virtual String description(AXNameFrom, AXDescriptionFrom&, WillBeHeapVector<
RawPtrWillBeMember<AXObject>>& descriptionObjects) { return String(); } |
| 554 | 558 |
| 555 // Takes the result of nameFrom and descriptionFrom from calling |name| and
|description|, | 559 // Takes the result of nameFrom and descriptionFrom from calling |name| and
|description|, |
| 556 // above, and retrieves the placeholder of the object, if present and if it
wasn't already | 560 // above, and retrieves the placeholder of the object, if present and if it
wasn't already |
| 557 // exposed by one of the two functions above. | 561 // exposed by one of the two functions above. |
| 558 virtual String placeholder(AXNameFrom, AXDescriptionFrom) { return String();
} | 562 virtual String placeholder(AXNameFrom, AXDescriptionFrom) { return String();
} |
| 559 | 563 |
| 560 // Internal function used by name and description, above. | 564 // Internal function used by name and description, above. |
| 561 virtual String textAlternative(bool recursive, bool inAriaLabelledByTraversa
l, HashSet<AXObject*>& visited, AXNameFrom*, Vector<AXObject*>* nameObjects) { r
eturn String(); } | 565 virtual String textAlternative(bool recursive, bool inAriaLabelledByTraversa
l, WillBeHeapHashSet<RawPtrWillBeMember<AXObject>>& visited, AXNameFrom*, WillBe
HeapVector<RawPtrWillBeMember<AXObject>>* nameObjects) { return String(); } |
| 562 | 566 |
| 563 // Returns result of Accessible Name Calculation algorithm. | 567 // Returns result of Accessible Name Calculation algorithm. |
| 564 // This is a simpler high-level interface to |name| used by Inspector. | 568 // This is a simpler high-level interface to |name| used by Inspector. |
| 565 virtual String computedName() const { return String(); } | 569 virtual String computedName() const { return String(); } |
| 566 | 570 |
| 567 // | 571 // |
| 568 // Properties of static elements. | 572 // Properties of static elements. |
| 569 // | 573 // |
| 570 | 574 |
| 571 virtual const AtomicString& accessKey() const { return nullAtom; } | 575 virtual const AtomicString& accessKey() const { return nullAtom; } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 LayoutRect m_explicitElementRect; | 781 LayoutRect m_explicitElementRect; |
| 778 | 782 |
| 779 virtual const AXObject* inheritsPresentationalRoleFrom() const { return 0; } | 783 virtual const AXObject* inheritsPresentationalRoleFrom() const { return 0; } |
| 780 | 784 |
| 781 bool nameFromContents() const; | 785 bool nameFromContents() const; |
| 782 | 786 |
| 783 AccessibilityRole buttonRoleType() const; | 787 AccessibilityRole buttonRoleType() const; |
| 784 | 788 |
| 785 unsigned getLengthForTextRange() const { return text().length(); } | 789 unsigned getLengthForTextRange() const { return text().length(); } |
| 786 | 790 |
| 787 mutable AXObject* m_parent; | 791 bool m_detached; |
| 792 |
| 793 mutable RawPtrWillBeMember<AXObject> m_parent; |
| 788 | 794 |
| 789 // The following cached attribute values (the ones starting with m_cached*) | 795 // The following cached attribute values (the ones starting with m_cached*) |
| 790 // are only valid if m_lastModificationCount matches AXObjectCacheImpl::modi
ficationCount(). | 796 // are only valid if m_lastModificationCount matches AXObjectCacheImpl::modi
ficationCount(). |
| 791 mutable int m_lastModificationCount; | 797 mutable int m_lastModificationCount; |
| 792 mutable bool m_cachedIsIgnored : 1; | 798 mutable bool m_cachedIsIgnored : 1; |
| 793 mutable bool m_cachedIsInertOrAriaHidden : 1; | 799 mutable bool m_cachedIsInertOrAriaHidden : 1; |
| 794 mutable bool m_cachedIsDescendantOfLeafNode : 1; | 800 mutable bool m_cachedIsDescendantOfLeafNode : 1; |
| 795 mutable bool m_cachedIsDescendantOfDisabledNode : 1; | 801 mutable bool m_cachedIsDescendantOfDisabledNode : 1; |
| 796 mutable bool m_cachedHasInheritedPresentationalRole : 1; | 802 mutable bool m_cachedHasInheritedPresentationalRole : 1; |
| 797 mutable bool m_cachedIsPresentationalChild : 1; | 803 mutable bool m_cachedIsPresentationalChild : 1; |
| 798 mutable const AXObject* m_cachedLiveRegionRoot; | 804 mutable RawPtrWillBeMember<const AXObject> m_cachedLiveRegionRoot; |
| 799 | 805 |
| 800 AXObjectCacheImpl* m_axObjectCache; | 806 RawPtrWillBeMember<AXObjectCacheImpl> m_axObjectCache; |
| 801 | 807 |
| 802 // Updates the cached attribute values. This may be recursive, so to prevent
deadlocks, | 808 // Updates the cached attribute values. This may be recursive, so to prevent
deadlocks, |
| 803 // functions called here may only search up the tree (ancestors), not down. | 809 // functions called here may only search up the tree (ancestors), not down. |
| 804 void updateCachedAttributeValuesIfNeeded() const; | 810 void updateCachedAttributeValuesIfNeeded() const; |
| 805 | 811 |
| 806 private: | 812 private: |
| 807 static bool includesARIAWidgetRole(const String&); | 813 static bool includesARIAWidgetRole(const String&); |
| 808 static bool hasInteractiveARIAAttribute(const Element&); | 814 static bool hasInteractiveARIAAttribute(const Element&); |
| 809 }; | 815 }; |
| 810 | 816 |
| 811 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | 817 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 812 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred
icate) | 818 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred
icate) |
| 813 | 819 |
| 814 } // namespace blink | 820 } // namespace blink |
| 815 | 821 |
| 816 #endif // AXObject_h | 822 #endif // AXObject_h |
| OLD | NEW |