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