Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: Source/modules/accessibility/AXObject.h

Issue 1072273006: Oilpan: Prepare moving AXObject to heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 AXPressedState, 206 AXPressedState,
207 AXProtectedState, 207 AXProtectedState,
208 AXReadonlyState, 208 AXReadonlyState,
209 AXRequiredState, 209 AXRequiredState,
210 AXSelectableState, 210 AXSelectableState,
211 AXSelectedState, 211 AXSelectedState,
212 AXVerticalState, 212 AXVerticalState,
213 AXVisitedState 213 AXVisitedState
214 }; 214 };
215 215
216 struct AccessibilityText { 216 class AccessibilityText : public NoBaseWillBeGarbageCollectedFinalized<Accessibi lityText> {
haraken 2015/05/28 10:48:40 Add final.
keishi 2015/06/08 06:27:20 Done.
217 String text; 217 public:
218 AccessibilityTextSource textSource; 218 static PassOwnPtrWillBeRawPtr<AccessibilityText> create(const String& t, con st AccessibilityTextSource& s)
haraken 2015/05/28 10:48:40 t => text s => source
keishi 2015/06/08 06:27:20 Done.
219 RefPtr<AXObject> textElement; 219 {
220 return adoptPtrWillBeNoop<AccessibilityText>(new AccessibilityText(t, s, nullptr));
haraken 2015/05/28 10:48:41 adoptPtrWillBeNoop<AccessibilityText> => adoptPtrW
keishi 2015/06/08 06:27:21 Done.
221 }
222 static PassOwnPtrWillBeRawPtr<AccessibilityText> create(const String& t, con st AccessibilityTextSource& s, const RefPtrWillBeRawPtr<AXObject> element)
223 {
224 return adoptPtrWillBeNoop<AccessibilityText>(new AccessibilityText(t, s, nullptr));
haraken 2015/05/28 10:48:40 Ditto.
keishi 2015/06/08 06:27:20 Done.
225 }
220 226
221 AccessibilityText(const String& t, const AccessibilityTextSource& s) 227 String text() { return m_text; }
haraken 2015/05/28 10:48:41 Add const.
keishi 2015/06/08 06:27:20 Done.
222 : text(t) 228 AccessibilityTextSource textSource() { return m_textSource; }
haraken 2015/05/28 10:48:41 Ditto.
keishi 2015/06/08 06:27:20 Done.
223 , textSource(s) 229 AXObject* textElement() { return m_textElement.get(); }
haraken 2015/05/28 10:48:41 Ditto.
keishi 2015/06/08 06:27:20 Done.
230
231 DEFINE_INLINE_TRACE()
232 {
233 visitor->trace(m_textElement);
234 }
235
236 private:
237 AccessibilityText(const String& t, const AccessibilityTextSource& s, const R efPtrWillBeRawPtr<AXObject> element)
haraken 2015/05/28 10:48:40 This looks strange... RefPtr => PassRefPtr ?
keishi 2015/06/08 06:27:20 Done.
238 : m_text(t)
239 , m_textSource(s)
240 , m_textElement(element)
224 { } 241 { }
225 242
226 AccessibilityText(const String& t, const AccessibilityTextSource& s, const R efPtr<AXObject> element) 243 String m_text;
227 : text(t) 244 AccessibilityTextSource m_textSource;
228 , textSource(s) 245 RefPtrWillBeMember<AXObject> m_textElement;
229 , textElement(element)
230 { }
231 }; 246 };
232 247
233 enum AccessibilityOrientation { 248 enum AccessibilityOrientation {
234 AccessibilityOrientationUndefined = 0, 249 AccessibilityOrientationUndefined = 0,
235 AccessibilityOrientationVertical, 250 AccessibilityOrientationVertical,
236 AccessibilityOrientationHorizontal, 251 AccessibilityOrientationHorizontal,
237 }; 252 };
238 253
239 enum AXObjectInclusion { 254 enum AXObjectInclusion {
240 IncludeObject, 255 IncludeObject,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 : reason(reason) 358 : reason(reason)
344 , relatedObject(nullptr) 359 , relatedObject(nullptr)
345 { } 360 { }
346 361
347 IgnoredReason(AXIgnoredReason r, const AXObject* obj) 362 IgnoredReason(AXIgnoredReason r, const AXObject* obj)
348 : reason(r) 363 : reason(r)
349 , relatedObject(obj) 364 , relatedObject(obj)
350 { } 365 { }
351 }; 366 };
352 367
353 class MODULES_EXPORT AXObject : public RefCounted<AXObject> { 368 class MODULES_EXPORT AXObject : public RefCountedWillBeGarbageCollectedFinalized <AXObject> {
354 public: 369 public:
355 typedef Vector<RefPtr<AXObject>> AccessibilityChildrenVector; 370 typedef WillBeHeapVector<RefPtrWillBeMember<AXObject>> AccessibilityChildren Vector;
356 371
357 struct PlainTextRange { 372 struct PlainTextRange {
358 373
359 unsigned start; 374 unsigned start;
360 unsigned length; 375 unsigned length;
361 376
362 PlainTextRange() 377 PlainTextRange()
363 : start(0) 378 : start(0)
364 , length(0) 379 , length(0)
365 { } 380 { }
366 381
367 PlainTextRange(unsigned s, unsigned l) 382 PlainTextRange(unsigned s, unsigned l)
368 : start(s) 383 : start(s)
369 , length(l) 384 , length(l)
370 { } 385 { }
371 386
372 bool isNull() const { return !start && !length; } 387 bool isNull() const { return !start && !length; }
373 }; 388 };
374 389
375 protected: 390 protected:
376 AXObject(AXObjectCacheImpl*); 391 AXObject(AXObjectCacheImpl*);
377 392
378 public: 393 public:
379 virtual ~AXObject(); 394 virtual ~AXObject();
395 DECLARE_VIRTUAL_TRACE();
380 396
381 // After constructing an AXObject, it must be given a 397 // After constructing an AXObject, it must be given a
382 // unique ID, then added to AXObjectCacheImpl, and finally init() must 398 // unique ID, then added to AXObjectCacheImpl, and finally init() must
383 // be called last. 399 // be called last.
384 void setAXObjectID(AXID axObjectID) { m_id = axObjectID; } 400 void setAXObjectID(AXID axObjectID) { m_id = axObjectID; }
385 virtual void init() { } 401 virtual void init() { }
386 402
387 // When the corresponding WebCore object that this AXObject 403 // When the corresponding WebCore object that this AXObject
388 // wraps is deleted, it must be detached. 404 // wraps is deleted, it must be detached.
389 virtual void detach(); 405 virtual void detach();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 virtual String deprecatedTitle(TextUnderElementMode mode = TextUnderElementA ll) const { return String(); } 536 virtual String deprecatedTitle(TextUnderElementMode mode = TextUnderElementA ll) const { return String(); }
521 virtual String deprecatedHelpText() const { return String(); } 537 virtual String deprecatedHelpText() const { return String(); }
522 virtual String deprecatedTextUnderElement(TextUnderElementMode mode = TextUn derElementAll) const { return String(); } 538 virtual String deprecatedTextUnderElement(TextUnderElementMode mode = TextUn derElementAll) const { return String(); }
523 539
524 // 540 //
525 // New text alternative calculation API (under development). 541 // New text alternative calculation API (under development).
526 // 542 //
527 543
528 // Retrieves the accessible name of the object, an enum indicating where the name 544 // Retrieves the accessible name of the object, an enum indicating where the name
529 // was derived from, and a list of objects that were used to derive the name , if any. 545 // was derived from, and a list of objects that were used to derive the name , if any.
530 virtual String name(AXNameFrom&, Vector<AXObject*>& nameObjects); 546 virtual String name(AXNameFrom&, WillBeHeapVector<RawPtrWillBeMember<AXObjec t>>& nameObjects);
531 547
532 // Takes the result of nameFrom from calling |name|, above, and retrieves th e 548 // Takes the result of nameFrom from calling |name|, above, and retrieves th e
533 // accessible description of the object, which is secondary to |name|, an en um indicating 549 // accessible description of the object, which is secondary to |name|, an en um indicating
534 // where the description was derived from, and a list of objects that were u sed to 550 // where the description was derived from, and a list of objects that were u sed to
535 // derive the description, if any. 551 // derive the description, if any.
536 virtual String description(AXNameFrom, AXDescriptionFrom&, Vector<AXObject*> & descriptionObjects) { return String(); } 552 virtual String description(AXNameFrom, AXDescriptionFrom&, WillBeHeapVector< RawPtrWillBeMember<AXObject>>& descriptionObjects) { return String(); }
537 553
538 // Takes the result of nameFrom and descriptionFrom from calling |name| and |description|, 554 // Takes the result of nameFrom and descriptionFrom from calling |name| and |description|,
539 // above, and retrieves the placeholder of the object, if present and if it wasn't already 555 // above, and retrieves the placeholder of the object, if present and if it wasn't already
540 // exposed by one of the two functions above. 556 // exposed by one of the two functions above.
541 virtual String placeholder(AXNameFrom, AXDescriptionFrom) { return String(); } 557 virtual String placeholder(AXNameFrom, AXDescriptionFrom) { return String(); }
542 558
543 // Internal function used by name and description, above. 559 // Internal function used by name and description, above.
544 virtual String textAlternative(bool recursive, bool inAriaLabelledByTraversa l, HashSet<AXObject*>& visited, AXNameFrom*, Vector<AXObject*>* nameObjects) { r eturn String(); } 560 virtual String textAlternative(bool recursive, bool inAriaLabelledByTraversa l, WillBeHeapHashSet<RawPtrWillBeMember<AXObject>>& visited, AXNameFrom*, WillBe HeapVector<RawPtrWillBeMember<AXObject>>* nameObjects) { return String(); }
545 561
546 // Returns result of Accessible Name Calculation algorithm. 562 // Returns result of Accessible Name Calculation algorithm.
547 // This is a simpler high-level interface to |name| used by Inspector. 563 // This is a simpler high-level interface to |name| used by Inspector.
548 virtual String computedName() const { return String(); } 564 virtual String computedName() const { return String(); }
549 565
550 // 566 //
551 // Properties of static elements. 567 // Properties of static elements.
552 // 568 //
553 569
554 virtual const AtomicString& accessKey() const { return nullAtom; } 570 virtual const AtomicString& accessKey() const { return nullAtom; }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 virtual const AXObject* inheritsPresentationalRoleFrom() const { return 0; } 780 virtual const AXObject* inheritsPresentationalRoleFrom() const { return 0; }
765 781
766 bool nameFromContents() const; 782 bool nameFromContents() const;
767 783
768 AccessibilityRole buttonRoleType() const; 784 AccessibilityRole buttonRoleType() const;
769 785
770 unsigned getLengthForTextRange() const { return text().length(); } 786 unsigned getLengthForTextRange() const { return text().length(); }
771 787
772 bool m_detached; 788 bool m_detached;
773 789
774 mutable AXObject* m_parent; 790 mutable RawPtrWillBeMember<AXObject> m_parent;
775 791
776 // The following cached attribute values (the ones starting with m_cached*) 792 // The following cached attribute values (the ones starting with m_cached*)
777 // are only valid if m_lastModificationCount matches AXObjectCacheImpl::modi ficationCount(). 793 // are only valid if m_lastModificationCount matches AXObjectCacheImpl::modi ficationCount().
778 mutable int m_lastModificationCount; 794 mutable int m_lastModificationCount;
779 mutable bool m_cachedIsIgnored : 1; 795 mutable bool m_cachedIsIgnored : 1;
780 mutable bool m_cachedIsInertOrAriaHidden : 1; 796 mutable bool m_cachedIsInertOrAriaHidden : 1;
781 mutable bool m_cachedIsDescendantOfLeafNode : 1; 797 mutable bool m_cachedIsDescendantOfLeafNode : 1;
782 mutable bool m_cachedIsDescendantOfDisabledNode : 1; 798 mutable bool m_cachedIsDescendantOfDisabledNode : 1;
783 mutable bool m_cachedHasInheritedPresentationalRole : 1; 799 mutable bool m_cachedHasInheritedPresentationalRole : 1;
784 mutable bool m_cachedIsPresentationalChild : 1; 800 mutable bool m_cachedIsPresentationalChild : 1;
785 mutable const AXObject* m_cachedLiveRegionRoot; 801 mutable RawPtrWillBeMember<const AXObject> m_cachedLiveRegionRoot;
786 802
787 AXObjectCacheImpl* m_axObjectCache; 803 RawPtrWillBeWeakMember<AXObjectCacheImpl> m_axObjectCache;
haraken 2015/05/28 10:48:41 I think this should be a Member. AXObjectCache own
keishi 2015/06/08 06:27:20 Done.
788 804
789 // Updates the cached attribute values. This may be recursive, so to prevent deadlocks, 805 // Updates the cached attribute values. This may be recursive, so to prevent deadlocks,
790 // functions called here may only search up the tree (ancestors), not down. 806 // functions called here may only search up the tree (ancestors), not down.
791 void updateCachedAttributeValuesIfNeeded() const; 807 void updateCachedAttributeValuesIfNeeded() const;
792 808
793 private: 809 private:
794 static bool includesARIAWidgetRole(const String&); 810 static bool includesARIAWidgetRole(const String&);
795 static bool hasInteractiveARIAAttribute(const Element&); 811 static bool hasInteractiveARIAAttribute(const Element&);
796 }; 812 };
797 813
798 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ 814 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \
799 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate) 815 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate)
800 816
801 } // namespace blink 817 } // namespace blink
802 818
803 #endif // AXObject_h 819 #endif // AXObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698