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

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, 8 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 ASSERT(!m_initialized); 682 ASSERT(!m_initialized);
683 m_initialized = true; 683 m_initialized = true;
684 #endif 684 #endif
685 m_role = determineAccessibilityRole(); 685 m_role = determineAccessibilityRole();
686 } 686 }
687 687
688 void AXNodeObject::detach() 688 void AXNodeObject::detach()
689 { 689 {
690 clearChildren(); 690 clearChildren();
691 AXObject::detach(); 691 AXObject::detach();
692 m_node = 0; 692 m_node = nullptr;
693 } 693 }
694 694
695 bool AXNodeObject::isAnchor() const 695 bool AXNodeObject::isAnchor() const
696 { 696 {
697 return !isNativeImage() && isLink(); 697 return !isNativeImage() && isLink();
698 } 698 }
699 699
700 bool AXNodeObject::isControl() const 700 bool AXNodeObject::isControl() const
701 { 701 {
702 Node* node = this->node(); 702 Node* node = this->node();
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 if (node && node->isTextNode()) 1525 if (node && node->isTextNode())
1526 return toText(node)->wholeText(); 1526 return toText(node)->wholeText();
1527 1527
1528 StringBuilder builder; 1528 StringBuilder builder;
1529 AXObject* previous = nullptr; 1529 AXObject* previous = nullptr;
1530 for (AXObject* child = firstChild(); child; child = child->nextSibling()) { 1530 for (AXObject* child = firstChild(); child; child = child->nextSibling()) {
1531 if (!shouldUseAccessibilityObjectInnerText(child)) 1531 if (!shouldUseAccessibilityObjectInnerText(child))
1532 continue; 1532 continue;
1533 1533
1534 if (child->isAXNodeObject()) { 1534 if (child->isAXNodeObject()) {
1535 Vector<AccessibilityText> textOrder; 1535 WillBeHeapVector<OwnPtrWillBeMember<AccessibilityText>> textOrder;
1536 toAXNodeObject(child)->alternativeText(textOrder); 1536 toAXNodeObject(child)->alternativeText(textOrder);
1537 if (textOrder.size() > 0) { 1537 if (textOrder.size() > 0) {
1538 builder.append(textOrder[0].text); 1538 builder.append(textOrder[0]->text());
1539 if (mode == TextUnderElementAny) 1539 if (mode == TextUnderElementAny)
1540 break; 1540 break;
1541 continue; 1541 continue;
1542 } 1542 }
1543 } 1543 }
1544 1544
1545 // If we're going between two layoutObjects that are in separate LayoutB oxes, add 1545 // If we're going between two layoutObjects that are in separate LayoutB oxes, add
1546 // whitespace if it wasn't there already. Intuitively if you have 1546 // whitespace if it wasn't there already. Intuitively if you have
1547 // <span>Hello</span><span>World</span>, those are part of the same Layo utBox 1547 // <span>Hello</span><span>World</span>, those are part of the same Layo utBox
1548 // so we should return "HelloWorld", but given <div>Hello</div><div>Worl d</div> the 1548 // so we should return "HelloWorld", but given <div>Hello</div><div>Worl d</div> the
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 String documentTitle = document->title(); 2173 String documentTitle = document->title();
2174 if (!documentTitle.isEmpty()) 2174 if (!documentTitle.isEmpty())
2175 return documentTitle; 2175 return documentTitle;
2176 2176
2177 if (HTMLElement* body = document->body()) 2177 if (HTMLElement* body = document->body())
2178 return body->getNameAttribute(); 2178 return body->getNameAttribute();
2179 2179
2180 return String(); 2180 return String();
2181 } 2181 }
2182 2182
2183 void AXNodeObject::alternativeText(Vector<AccessibilityText>& textOrder) const 2183 void AXNodeObject::alternativeText(WillBeHeapVector<OwnPtrWillBeMember<Accessibi lityText>>& textOrder) const
2184 { 2184 {
2185 if (isWebArea()) { 2185 if (isWebArea()) {
2186 String webAreaText = alternativeTextForWebArea(); 2186 String webAreaText = alternativeTextForWebArea();
2187 if (!webAreaText.isEmpty()) 2187 if (!webAreaText.isEmpty())
2188 textOrder.append(AccessibilityText(webAreaText, AlternativeText)); 2188 textOrder.append(AccessibilityText::create(webAreaText, AlternativeT ext));
2189 return; 2189 return;
2190 } 2190 }
2191 2191
2192 ariaLabeledByText(textOrder); 2192 ariaLabeledByText(textOrder);
2193 2193
2194 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); 2194 const AtomicString& ariaLabel = getAttribute(aria_labelAttr);
2195 if (!ariaLabel.isEmpty()) 2195 if (!ariaLabel.isEmpty())
2196 textOrder.append(AccessibilityText(ariaLabel, AlternativeText)); 2196 textOrder.append(AccessibilityText::create(ariaLabel, AlternativeText));
2197 2197
2198 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) { 2198 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) {
2199 // Images should use alt as long as the attribute is present, even if em pty. 2199 // Images should use alt as long as the attribute is present, even if em pty.
2200 // Otherwise, it should fallback to other methods, like the title attrib ute. 2200 // Otherwise, it should fallback to other methods, like the title attrib ute.
2201 const AtomicString& alt = getAttribute(altAttr); 2201 const AtomicString& alt = getAttribute(altAttr);
2202 if (!alt.isNull()) 2202 if (!alt.isNull())
2203 textOrder.append(AccessibilityText(alt, AlternativeText)); 2203 textOrder.append(AccessibilityText::create(alt, AlternativeText));
2204 } 2204 }
2205 } 2205 }
2206 2206
2207 void AXNodeObject::ariaLabeledByText(Vector<AccessibilityText>& textOrder) const 2207 void AXNodeObject::ariaLabeledByText(WillBeHeapVector<OwnPtrWillBeMember<Accessi bilityText>>& textOrder) const
2208 { 2208 {
2209 String ariaLabeledBy = ariaLabeledByAttribute(); 2209 String ariaLabeledBy = ariaLabeledByAttribute();
2210 if (!ariaLabeledBy.isEmpty()) { 2210 if (!ariaLabeledBy.isEmpty()) {
2211 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; 2211 WillBeHeapVector<RawPtrWillBeMember<Element>> elements;
2212 ariaLabeledByElements(elements); 2212 ariaLabeledByElements(elements);
2213 2213
2214 for (const auto& element : elements) { 2214 for (const auto& element : elements) {
2215 RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); 2215 RefPtrWillBeRawPtr<AXObject> axElement = axObjectCache()->getOrCreat e(element);
2216 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a xElement)); 2216 textOrder.append(AccessibilityText::create(ariaLabeledBy, Alternativ eText, axElement));
2217 } 2217 }
2218 } 2218 }
2219 } 2219 }
2220 2220
2221 DEFINE_TRACE(AXNodeObject)
2222 {
2223 AXObject::trace(visitor);
2224 visitor->trace(m_node);
2225 }
2226
2221 } // namespace blink 2227 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698