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

Side by Side Diff: Source/modules/accessibility/AXNodeObject.cpp

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) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 : AXObject(axObjectCache) 63 : AXObject(axObjectCache)
64 , m_ariaRole(UnknownRole) 64 , m_ariaRole(UnknownRole)
65 , m_childrenDirty(false) 65 , m_childrenDirty(false)
66 #if ENABLE(ASSERT) 66 #if ENABLE(ASSERT)
67 , m_initialized(false) 67 , m_initialized(false)
68 #endif 68 #endif
69 , m_node(node) 69 , m_node(node)
70 { 70 {
71 } 71 }
72 72
73 PassRefPtr<AXNodeObject> AXNodeObject::create(Node* node, AXObjectCacheImpl& axO bjectCache) 73 PassRefPtrWillBeRawPtr<AXNodeObject> AXNodeObject::create(Node* node, AXObjectCa cheImpl& axObjectCache)
74 { 74 {
75 return adoptRef(new AXNodeObject(node, axObjectCache)); 75 return adoptRefWillBeNoop(new AXNodeObject(node, axObjectCache));
76 } 76 }
77 77
78 AXNodeObject::~AXNodeObject() 78 AXNodeObject::~AXNodeObject()
79 { 79 {
80 ASSERT(isDetached()); 80 ASSERT(isDetached());
81 } 81 }
82 82
83 // This function implements the ARIA accessible name as described by the Mozilla 83 // This function implements the ARIA accessible name as described by the Mozilla
84 // ARIA Implementer's Guide. 84 // ARIA Implementer's Guide.
85 static String accessibleNameForNode(Node* node) 85 static String accessibleNameForNode(Node* node)
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 ASSERT(!m_initialized); 750 ASSERT(!m_initialized);
751 m_initialized = true; 751 m_initialized = true;
752 #endif 752 #endif
753 m_role = determineAccessibilityRole(); 753 m_role = determineAccessibilityRole();
754 } 754 }
755 755
756 void AXNodeObject::detach() 756 void AXNodeObject::detach()
757 { 757 {
758 clearChildren(); 758 clearChildren();
759 AXObject::detach(); 759 AXObject::detach();
760 m_node = 0; 760 m_node = nullptr;
761 } 761 }
762 762
763 bool AXNodeObject::isAnchor() const 763 bool AXNodeObject::isAnchor() const
764 { 764 {
765 return !isNativeImage() && isLink(); 765 return !isNativeImage() && isLink();
766 } 766 }
767 767
768 bool AXNodeObject::isControl() const 768 bool AXNodeObject::isControl() const
769 { 769 {
770 Node* node = this->node(); 770 Node* node = this->node();
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 return placeholder; 1770 return placeholder;
1771 } 1771 }
1772 1772
1773 return String(); 1773 return String();
1774 } 1774 }
1775 1775
1776 // 1776 //
1777 // New AX name calculation. 1777 // New AX name calculation.
1778 // 1778 //
1779 1779
1780 String AXNodeObject::textAlternative(bool recursive, bool inAriaLabelledByTraver sal, HashSet<AXObject*>& visited, AXNameFrom* nameFrom, Vector<AXObject*>* nameO bjects) 1780 String AXNodeObject::textAlternative(bool recursive, bool inAriaLabelledByTraver sal, WillBeHeapHashSet<RawPtrWillBeMember<AXObject>>& visited, AXNameFrom* nameF rom, WillBeHeapVector<RawPtrWillBeMember<AXObject>>* nameObjects)
1781 { 1781 {
1782 bool alreadyVisited = visited.contains(this); 1782 bool alreadyVisited = visited.contains(this);
1783 visited.add(this); 1783 visited.add(this);
1784 1784
1785 if (!node() && !layoutObject()) 1785 if (!node() && !layoutObject())
1786 return String(); 1786 return String();
1787 1787
1788 // Step 2A from: http://www.w3.org/TR/accname-aam-1.1 1788 // Step 2A from: http://www.w3.org/TR/accname-aam-1.1
1789 if (!recursive && layoutObject() 1789 if (!recursive && layoutObject()
1790 && layoutObject()->style()->visibility() != VISIBLE 1790 && layoutObject()->style()->visibility() != VISIBLE
1791 && !equalIgnoringCase(getAttribute(aria_hiddenAttr), "false")) { 1791 && !equalIgnoringCase(getAttribute(aria_hiddenAttr), "false")) {
1792 return String(); 1792 return String();
1793 } 1793 }
1794 1794
1795 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 1795 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1
1796 if (!inAriaLabelledByTraversal && hasAttribute(aria_labelledbyAttr) && !alre adyVisited) { 1796 if (!inAriaLabelledByTraversal && hasAttribute(aria_labelledbyAttr) && !alre adyVisited) {
1797 if (nameFrom) 1797 if (nameFrom)
1798 *nameFrom = AXNameFromRelatedElement; 1798 *nameFrom = AXNameFromRelatedElement;
1799 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; 1799 WillBeHeapVector<RawPtrWillBeMember<Element>> elements;
1800 ariaLabeledByElements(elements); 1800 ariaLabeledByElements(elements);
1801 StringBuilder accumulatedText; 1801 StringBuilder accumulatedText;
1802 for (const auto& element : elements) { 1802 for (const auto& element : elements) {
1803 RefPtr<AXObject> axElement = axObjectCache().getOrCreate(element); 1803 RefPtrWillBeRawPtr<AXObject> axElement = axObjectCache().getOrCreate (element);
1804 if (axElement) { 1804 if (axElement) {
1805 if (nameObjects) 1805 if (nameObjects)
1806 nameObjects->append(axElement.get()); 1806 nameObjects->append(axElement.get());
1807 String result = axElement->textAlternative(true, true, visited, nullptr, nullptr); 1807 String result = axElement->textAlternative(true, true, visited, nullptr, nullptr);
1808 if (!result.isEmpty()) { 1808 if (!result.isEmpty()) {
1809 if (!accumulatedText.isEmpty()) 1809 if (!accumulatedText.isEmpty())
1810 accumulatedText.append(" "); 1810 accumulatedText.append(" ");
1811 accumulatedText.append(result); 1811 accumulatedText.append(result);
1812 } 1812 }
1813 } 1813 }
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 } 2349 }
2350 2350
2351 void AXNodeObject::ariaLabeledByText(WillBeHeapVector<OwnPtrWillBeMember<Accessi bilityText>>& textOrder) const 2351 void AXNodeObject::ariaLabeledByText(WillBeHeapVector<OwnPtrWillBeMember<Accessi bilityText>>& textOrder) const
2352 { 2352 {
2353 String ariaLabeledBy = ariaLabeledByAttribute(); 2353 String ariaLabeledBy = ariaLabeledByAttribute();
2354 if (!ariaLabeledBy.isEmpty()) { 2354 if (!ariaLabeledBy.isEmpty()) {
2355 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; 2355 WillBeHeapVector<RawPtrWillBeMember<Element>> elements;
2356 ariaLabeledByElements(elements); 2356 ariaLabeledByElements(elements);
2357 2357
2358 for (const auto& element : elements) { 2358 for (const auto& element : elements) {
2359 RefPtr<AXObject> axElement = axObjectCache().getOrCreate(element); 2359 RefPtrWillBeRawPtr<AXObject> axElement = axObjectCache().getOrCreate (element);
2360 textOrder.append(AccessibilityText::create(ariaLabeledBy, Alternativ eText, axElement)); 2360 textOrder.append(AccessibilityText::create(ariaLabeledBy, Alternativ eText, axElement));
2361 } 2361 }
2362 } 2362 }
2363 } 2363 }
2364 2364
2365 DEFINE_TRACE(AXNodeObject)
2366 {
2367 visitor->trace(m_node);
2368 AXObject::trace(visitor);
2369 }
2370
2365 } // namespace blink 2371 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698