| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 AXPressedState, | 204 AXPressedState, |
| 205 AXProtectedState, | 205 AXProtectedState, |
| 206 AXReadonlyState, | 206 AXReadonlyState, |
| 207 AXRequiredState, | 207 AXRequiredState, |
| 208 AXSelectableState, | 208 AXSelectableState, |
| 209 AXSelectedState, | 209 AXSelectedState, |
| 210 AXVerticalState, | 210 AXVerticalState, |
| 211 AXVisitedState | 211 AXVisitedState |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 struct AccessibilityText { | 214 class AccessibilityText : public NoBaseWillBeGarbageCollectedFinalized<Accessibi
lityText> { |
| 215 String text; | 215 public: |
| 216 AccessibilityTextSource textSource; | 216 static PassOwnPtrWillBeRawPtr<AccessibilityText> create(const String& t, con
st AccessibilityTextSource& s) |
| 217 RefPtr<AXObject> textElement; | 217 { |
| 218 return adoptPtrWillBeNoop<AccessibilityText>(new AccessibilityText(t, s,
nullptr)); |
| 219 } |
| 220 static PassOwnPtrWillBeRawPtr<AccessibilityText> create(const String& t, con
st AccessibilityTextSource& s, const RefPtrWillBeRawPtr<AXObject> element) |
| 221 { |
| 222 return adoptPtrWillBeNoop<AccessibilityText>(new AccessibilityText(t, s,
nullptr)); |
| 223 } |
| 218 | 224 |
| 219 AccessibilityText(const String& t, const AccessibilityTextSource& s) | 225 String text() { return m_text; } |
| 220 : text(t) | 226 AccessibilityTextSource textSource() { return m_textSource; } |
| 221 , textSource(s) | 227 AXObject* textElement() { return m_textElement.get(); } |
| 228 |
| 229 DEFINE_INLINE_TRACE() |
| 230 { |
| 231 visitor->trace(m_textElement); |
| 232 } |
| 233 |
| 234 private: |
| 235 AccessibilityText(const String& t, const AccessibilityTextSource& s, const R
efPtrWillBeRawPtr<AXObject> element) |
| 236 : m_text(t) |
| 237 , m_textSource(s) |
| 238 , m_textElement(element) |
| 222 { } | 239 { } |
| 223 | 240 |
| 224 AccessibilityText(const String& t, const AccessibilityTextSource& s, const R
efPtr<AXObject> element) | 241 String m_text; |
| 225 : text(t) | 242 AccessibilityTextSource m_textSource; |
| 226 , textSource(s) | 243 RefPtrWillBeMember<AXObject> m_textElement; |
| 227 , textElement(element) | |
| 228 { } | |
| 229 }; | 244 }; |
| 230 | 245 |
| 231 enum AccessibilityOrientation { | 246 enum AccessibilityOrientation { |
| 232 AccessibilityOrientationUndefined = 0, | 247 AccessibilityOrientationUndefined = 0, |
| 233 AccessibilityOrientationVertical, | 248 AccessibilityOrientationVertical, |
| 234 AccessibilityOrientationHorizontal, | 249 AccessibilityOrientationHorizontal, |
| 235 }; | 250 }; |
| 236 | 251 |
| 237 enum AXObjectInclusion { | 252 enum AXObjectInclusion { |
| 238 IncludeObject, | 253 IncludeObject, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 : reason(reason) | 346 : reason(reason) |
| 332 , relatedObject(nullptr) | 347 , relatedObject(nullptr) |
| 333 { } | 348 { } |
| 334 | 349 |
| 335 IgnoredReason(AXIgnoredReason r, const AXObject* obj) | 350 IgnoredReason(AXIgnoredReason r, const AXObject* obj) |
| 336 : reason(r) | 351 : reason(r) |
| 337 , relatedObject(obj) | 352 , relatedObject(obj) |
| 338 { } | 353 { } |
| 339 }; | 354 }; |
| 340 | 355 |
| 341 class MODULES_EXPORT AXObject : public RefCounted<AXObject> { | 356 class MODULES_EXPORT AXObject : public RefCountedWillBeGarbageCollectedFinalized
<AXObject> { |
| 342 public: | 357 public: |
| 343 typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector; | 358 typedef WillBeHeapVector<RefPtrWillBeMember<AXObject>> AccessibilityChildren
Vector; |
| 344 | 359 |
| 345 struct PlainTextRange { | 360 struct PlainTextRange { |
| 346 | 361 |
| 347 unsigned start; | 362 unsigned start; |
| 348 unsigned length; | 363 unsigned length; |
| 349 | 364 |
| 350 PlainTextRange() | 365 PlainTextRange() |
| 351 : start(0) | 366 : start(0) |
| 352 , length(0) | 367 , length(0) |
| 353 { } | 368 { } |
| 354 | 369 |
| 355 PlainTextRange(unsigned s, unsigned l) | 370 PlainTextRange(unsigned s, unsigned l) |
| 356 : start(s) | 371 : start(s) |
| 357 , length(l) | 372 , length(l) |
| 358 { } | 373 { } |
| 359 | 374 |
| 360 bool isNull() const { return !start && !length; } | 375 bool isNull() const { return !start && !length; } |
| 361 }; | 376 }; |
| 362 | 377 |
| 363 protected: | 378 protected: |
| 364 AXObject(AXObjectCacheImpl*); | 379 AXObject(AXObjectCacheImpl*); |
| 365 | 380 |
| 366 public: | 381 public: |
| 367 virtual ~AXObject(); | 382 virtual ~AXObject(); |
| 383 DECLARE_VIRTUAL_TRACE(); |
| 368 | 384 |
| 369 // After constructing an AXObject, it must be given a | 385 // After constructing an AXObject, it must be given a |
| 370 // unique ID, then added to AXObjectCacheImpl, and finally init() must | 386 // unique ID, then added to AXObjectCacheImpl, and finally init() must |
| 371 // be called last. | 387 // be called last. |
| 372 void setAXObjectID(AXID axObjectID) { m_id = axObjectID; } | 388 void setAXObjectID(AXID axObjectID) { m_id = axObjectID; } |
| 373 virtual void init() { } | 389 virtual void init() { } |
| 374 | 390 |
| 375 // When the corresponding WebCore object that this AXObject | 391 // When the corresponding WebCore object that this AXObject |
| 376 // wraps is deleted, it must be detached. | 392 // wraps is deleted, it must be detached. |
| 377 virtual void detach(); | 393 virtual void detach(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 virtual String deprecatedTitle(TextUnderElementMode mode = TextUnderElementA
ll) const { return String(); } | 524 virtual String deprecatedTitle(TextUnderElementMode mode = TextUnderElementA
ll) const { return String(); } |
| 509 virtual String deprecatedHelpText() const { return String(); } | 525 virtual String deprecatedHelpText() const { return String(); } |
| 510 virtual String deprecatedTextUnderElement(TextUnderElementMode mode = TextUn
derElementAll) const { return String(); } | 526 virtual String deprecatedTextUnderElement(TextUnderElementMode mode = TextUn
derElementAll) const { return String(); } |
| 511 | 527 |
| 512 // | 528 // |
| 513 // New text alternative calculation API (under development). | 529 // New text alternative calculation API (under development). |
| 514 // | 530 // |
| 515 | 531 |
| 516 // Retrieves the accessible name of the object, an enum indicating where the
name | 532 // Retrieves the accessible name of the object, an enum indicating where the
name |
| 517 // was derived from, and a list of objects that were used to derive the name
, if any. | 533 // was derived from, and a list of objects that were used to derive the name
, if any. |
| 518 virtual String name(AXNameFrom&, Vector<AXObject*>& nameObjects) { return St
ring(); } | 534 virtual String name(AXNameFrom&, WillBeHeapVector<RawPtrWillBeMember<AXObjec
t>>& nameObjects) { return String(); } |
| 519 | 535 |
| 520 // Takes the result of nameFrom from calling |name|, above, and retrieves th
e | 536 // Takes the result of nameFrom from calling |name|, above, and retrieves th
e |
| 521 // accessible description of the object, which is secondary to |name|, an en
um indicating | 537 // accessible description of the object, which is secondary to |name|, an en
um indicating |
| 522 // where the description was derived from, and a list of objects that were u
sed to | 538 // where the description was derived from, and a list of objects that were u
sed to |
| 523 // derive the description, if any. | 539 // derive the description, if any. |
| 524 virtual String description(AXNameFrom, AXDescriptionFrom&, Vector<AXObject*>
& descriptionObjects) { return String(); } | 540 virtual String description(AXNameFrom, AXDescriptionFrom&, WillBeHeapVector<
RawPtrWillBeMember<AXObject>>& descriptionObjects) { return String(); } |
| 525 | 541 |
| 526 // Takes the result of nameFrom and descriptionFrom from calling |name| and
|description|, | 542 // Takes the result of nameFrom and descriptionFrom from calling |name| and
|description|, |
| 527 // above, and retrieves the placeholder of the object, if present and if it
wasn't already | 543 // above, and retrieves the placeholder of the object, if present and if it
wasn't already |
| 528 // exposed by one of the two functions above. | 544 // exposed by one of the two functions above. |
| 529 virtual String placeholder(AXNameFrom, AXDescriptionFrom) { return String();
} | 545 virtual String placeholder(AXNameFrom, AXDescriptionFrom) { return String();
} |
| 530 | 546 |
| 531 // Returns result of Accessible Name Calculation algorithm. | 547 // Returns result of Accessible Name Calculation algorithm. |
| 532 // This is a simpler high-level interface to |name| used by Inspector. | 548 // This is a simpler high-level interface to |name| used by Inspector. |
| 533 virtual String computedName() const { return String(); } | 549 virtual String computedName() const { return String(); } |
| 534 | 550 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 // If this object itself scrolls, return its ScrollableArea. | 746 // If this object itself scrolls, return its ScrollableArea. |
| 731 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } | 747 virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; } |
| 732 virtual void scrollTo(const IntPoint&) const { } | 748 virtual void scrollTo(const IntPoint&) const { } |
| 733 | 749 |
| 734 AccessibilityRole buttonRoleType() const; | 750 AccessibilityRole buttonRoleType() const; |
| 735 | 751 |
| 736 unsigned getLengthForTextRange() const { return text().length(); } | 752 unsigned getLengthForTextRange() const { return text().length(); } |
| 737 | 753 |
| 738 bool m_detached; | 754 bool m_detached; |
| 739 | 755 |
| 740 mutable AXObject* m_parent; | 756 mutable RawPtrWillBeMember<AXObject> m_parent; |
| 741 | 757 |
| 742 // The following cached attribute values (the ones starting with m_cached*) | 758 // The following cached attribute values (the ones starting with m_cached*) |
| 743 // are only valid if m_lastModificationCount matches AXObjectCacheImpl::modi
ficationCount(). | 759 // are only valid if m_lastModificationCount matches AXObjectCacheImpl::modi
ficationCount(). |
| 744 mutable int m_lastModificationCount; | 760 mutable int m_lastModificationCount; |
| 745 mutable bool m_cachedIsIgnored : 1; | 761 mutable bool m_cachedIsIgnored : 1; |
| 746 mutable bool m_cachedIsInertOrAriaHidden : 1; | 762 mutable bool m_cachedIsInertOrAriaHidden : 1; |
| 747 mutable bool m_cachedIsDescendantOfLeafNode : 1; | 763 mutable bool m_cachedIsDescendantOfLeafNode : 1; |
| 748 mutable bool m_cachedIsDescendantOfDisabledNode : 1; | 764 mutable bool m_cachedIsDescendantOfDisabledNode : 1; |
| 749 mutable bool m_cachedHasInheritedPresentationalRole : 1; | 765 mutable bool m_cachedHasInheritedPresentationalRole : 1; |
| 750 mutable bool m_cachedIsPresentationalChild : 1; | 766 mutable bool m_cachedIsPresentationalChild : 1; |
| 751 mutable const AXObject* m_cachedLiveRegionRoot; | 767 mutable RawPtrWillBeMember<const AXObject> m_cachedLiveRegionRoot; |
| 752 | 768 |
| 753 AXObjectCacheImpl* m_axObjectCache; | 769 RawPtrWillBeWeakMember<AXObjectCacheImpl> m_axObjectCache; |
| 754 | 770 |
| 755 // Updates the cached attribute values. This may be recursive, so to prevent
deadlocks, | 771 // Updates the cached attribute values. This may be recursive, so to prevent
deadlocks, |
| 756 // functions called here may only search up the tree (ancestors), not down. | 772 // functions called here may only search up the tree (ancestors), not down. |
| 757 void updateCachedAttributeValuesIfNeeded() const; | 773 void updateCachedAttributeValuesIfNeeded() const; |
| 758 | 774 |
| 759 private: | 775 private: |
| 760 static bool includesARIAWidgetRole(const String&); | 776 static bool includesARIAWidgetRole(const String&); |
| 761 static bool hasInteractiveARIAAttribute(const Element&); | 777 static bool hasInteractiveARIAAttribute(const Element&); |
| 762 }; | 778 }; |
| 763 | 779 |
| 764 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | 780 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 765 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred
icate) | 781 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred
icate) |
| 766 | 782 |
| 767 } // namespace blink | 783 } // namespace blink |
| 768 | 784 |
| 769 #endif // AXObject_h | 785 #endif // AXObject_h |
| OLD | NEW |