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

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
« no previous file with comments | « Source/modules/accessibility/AXNodeObject.h ('k') | Source/modules/accessibility/AXObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(!m_node);
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)
86 { 86 {
87 if (!node) 87 if (!node)
88 return String(); 88 return String();
89 89
90 if (node->isTextNode()) 90 if (node->isTextNode())
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 { 748 {
749 #if ENABLE(ASSERT) 749 #if ENABLE(ASSERT)
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();
759 AXObject::detach(); 758 AXObject::detach();
760 m_node = 0; 759 m_node = nullptr;
761 } 760 }
762 761
763 bool AXNodeObject::isAnchor() const 762 bool AXNodeObject::isAnchor() const
764 { 763 {
765 return !isNativeImage() && isLink(); 764 return !isNativeImage() && isLink();
766 } 765 }
767 766
768 bool AXNodeObject::isControl() const 767 bool AXNodeObject::isControl() const
769 { 768 {
770 Node* node = this->node(); 769 Node* node = this->node();
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 return placeholder; 1769 return placeholder;
1771 } 1770 }
1772 1771
1773 return String(); 1772 return String();
1774 } 1773 }
1775 1774
1776 // 1775 //
1777 // New AX name calculation. 1776 // New AX name calculation.
1778 // 1777 //
1779 1778
1780 String AXNodeObject::textAlternative(bool recursive, bool inAriaLabelledByTraver sal, HashSet<AXObject*>& visited, AXNameFrom* nameFrom, Vector<AXObject*>* nameO bjects) 1779 String AXNodeObject::textAlternative(bool recursive, bool inAriaLabelledByTraver sal, WillBeHeapHashSet<RawPtrWillBeMember<AXObject>>& visited, AXNameFrom* nameF rom, WillBeHeapVector<RawPtrWillBeMember<AXObject>>* nameObjects)
1781 { 1780 {
1782 bool alreadyVisited = visited.contains(this); 1781 bool alreadyVisited = visited.contains(this);
1783 visited.add(this); 1782 visited.add(this);
1784 1783
1785 if (!node() && !layoutObject()) 1784 if (!node() && !layoutObject())
1786 return String(); 1785 return String();
1787 1786
1788 // Step 2A from: http://www.w3.org/TR/accname-aam-1.1 1787 // Step 2A from: http://www.w3.org/TR/accname-aam-1.1
1789 if (!recursive && layoutObject() 1788 if (!recursive && layoutObject()
1790 && layoutObject()->style()->visibility() != VISIBLE 1789 && layoutObject()->style()->visibility() != VISIBLE
1791 && !equalIgnoringCase(getAttribute(aria_hiddenAttr), "false")) { 1790 && !equalIgnoringCase(getAttribute(aria_hiddenAttr), "false")) {
1792 return String(); 1791 return String();
1793 } 1792 }
1794 1793
1795 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 1794 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1
1796 if (!inAriaLabelledByTraversal && hasAttribute(aria_labelledbyAttr) && !alre adyVisited) { 1795 if (!inAriaLabelledByTraversal && hasAttribute(aria_labelledbyAttr) && !alre adyVisited) {
1797 if (nameFrom) 1796 if (nameFrom)
1798 *nameFrom = AXNameFromRelatedElement; 1797 *nameFrom = AXNameFromRelatedElement;
1799 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; 1798 WillBeHeapVector<RawPtrWillBeMember<Element>> elements;
1800 ariaLabeledByElements(elements); 1799 ariaLabeledByElements(elements);
1801 StringBuilder accumulatedText; 1800 StringBuilder accumulatedText;
1802 for (const auto& element : elements) { 1801 for (const auto& element : elements) {
1803 RefPtr<AXObject> axElement = axObjectCache().getOrCreate(element); 1802 RefPtrWillBeRawPtr<AXObject> axElement = axObjectCache().getOrCreate (element);
1804 if (axElement) { 1803 if (axElement) {
1805 if (nameObjects) 1804 if (nameObjects)
1806 nameObjects->append(axElement.get()); 1805 nameObjects->append(axElement.get());
1807 String result = axElement->textAlternative(true, true, visited, nullptr, nullptr); 1806 String result = axElement->textAlternative(true, true, visited, nullptr, nullptr);
1808 if (!result.isEmpty()) { 1807 if (!result.isEmpty()) {
1809 if (!accumulatedText.isEmpty()) 1808 if (!accumulatedText.isEmpty())
1810 accumulatedText.append(" "); 1809 accumulatedText.append(" ");
1811 accumulatedText.append(result); 1810 accumulatedText.append(result);
1812 } 1811 }
1813 } 1812 }
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 } 2348 }
2350 2349
2351 void AXNodeObject::ariaLabeledByText(WillBeHeapVector<OwnPtrWillBeMember<Accessi bilityText>>& textOrder) const 2350 void AXNodeObject::ariaLabeledByText(WillBeHeapVector<OwnPtrWillBeMember<Accessi bilityText>>& textOrder) const
2352 { 2351 {
2353 String ariaLabeledBy = ariaLabeledByAttribute(); 2352 String ariaLabeledBy = ariaLabeledByAttribute();
2354 if (!ariaLabeledBy.isEmpty()) { 2353 if (!ariaLabeledBy.isEmpty()) {
2355 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; 2354 WillBeHeapVector<RawPtrWillBeMember<Element>> elements;
2356 ariaLabeledByElements(elements); 2355 ariaLabeledByElements(elements);
2357 2356
2358 for (const auto& element : elements) { 2357 for (const auto& element : elements) {
2359 RefPtr<AXObject> axElement = axObjectCache().getOrCreate(element); 2358 RefPtrWillBeRawPtr<AXObject> axElement = axObjectCache().getOrCreate (element);
2360 textOrder.append(AccessibilityText::create(ariaLabeledBy, Alternativ eText, axElement)); 2359 textOrder.append(AccessibilityText::create(ariaLabeledBy, Alternativ eText, axElement));
2361 } 2360 }
2362 } 2361 }
2363 } 2362 }
2364 2363
2364 DEFINE_TRACE(AXNodeObject)
2365 {
2366 visitor->trace(m_node);
2367 AXObject::trace(visitor);
2368 }
2369
2365 } // namespace blink 2370 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXNodeObject.h ('k') | Source/modules/accessibility/AXObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698