| OLD | NEW |
| 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 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 if (node && node->isTextNode()) | 1581 if (node && node->isTextNode()) |
| 1582 return toText(node)->wholeText(); | 1582 return toText(node)->wholeText(); |
| 1583 | 1583 |
| 1584 StringBuilder builder; | 1584 StringBuilder builder; |
| 1585 AXObject* previous = nullptr; | 1585 AXObject* previous = nullptr; |
| 1586 for (AXObject* child = firstChild(); child; child = child->nextSibling()) { | 1586 for (AXObject* child = firstChild(); child; child = child->nextSibling()) { |
| 1587 if (!shouldUseAccessibilityObjectInnerText(child)) | 1587 if (!shouldUseAccessibilityObjectInnerText(child)) |
| 1588 continue; | 1588 continue; |
| 1589 | 1589 |
| 1590 if (child->isAXNodeObject()) { | 1590 if (child->isAXNodeObject()) { |
| 1591 Vector<AccessibilityText> textOrder; | 1591 WillBeHeapVector<OwnPtrWillBeMember<AccessibilityText>> textOrder; |
| 1592 toAXNodeObject(child)->alternativeText(textOrder); | 1592 toAXNodeObject(child)->alternativeText(textOrder); |
| 1593 if (textOrder.size() > 0) { | 1593 if (textOrder.size() > 0) { |
| 1594 builder.append(textOrder[0].text); | 1594 builder.append(textOrder[0]->text()); |
| 1595 if (mode == TextUnderElementAny) | 1595 if (mode == TextUnderElementAny) |
| 1596 break; | 1596 break; |
| 1597 continue; | 1597 continue; |
| 1598 } | 1598 } |
| 1599 } | 1599 } |
| 1600 | 1600 |
| 1601 // If we're going between two layoutObjects that are in separate LayoutB
oxes, add | 1601 // If we're going between two layoutObjects that are in separate LayoutB
oxes, add |
| 1602 // whitespace if it wasn't there already. Intuitively if you have | 1602 // whitespace if it wasn't there already. Intuitively if you have |
| 1603 // <span>Hello</span><span>World</span>, those are part of the same Layo
utBox | 1603 // <span>Hello</span><span>World</span>, those are part of the same Layo
utBox |
| 1604 // so we should return "HelloWorld", but given <div>Hello</div><div>Worl
d</div> the | 1604 // so we should return "HelloWorld", but given <div>Hello</div><div>Worl
d</div> the |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2333 String documentTitle = document->title(); | 2333 String documentTitle = document->title(); |
| 2334 if (!documentTitle.isEmpty()) | 2334 if (!documentTitle.isEmpty()) |
| 2335 return documentTitle; | 2335 return documentTitle; |
| 2336 | 2336 |
| 2337 if (HTMLElement* body = document->body()) | 2337 if (HTMLElement* body = document->body()) |
| 2338 return body->getNameAttribute(); | 2338 return body->getNameAttribute(); |
| 2339 | 2339 |
| 2340 return String(); | 2340 return String(); |
| 2341 } | 2341 } |
| 2342 | 2342 |
| 2343 void AXNodeObject::alternativeText(Vector<AccessibilityText>& textOrder) const | 2343 void AXNodeObject::alternativeText(WillBeHeapVector<OwnPtrWillBeMember<Accessibi
lityText>>& textOrder) const |
| 2344 { | 2344 { |
| 2345 if (isWebArea()) { | 2345 if (isWebArea()) { |
| 2346 String webAreaText = alternativeTextForWebArea(); | 2346 String webAreaText = alternativeTextForWebArea(); |
| 2347 if (!webAreaText.isEmpty()) | 2347 if (!webAreaText.isEmpty()) |
| 2348 textOrder.append(AccessibilityText(webAreaText, AlternativeText)); | 2348 textOrder.append(AccessibilityText::create(webAreaText, AlternativeT
ext)); |
| 2349 return; | 2349 return; |
| 2350 } | 2350 } |
| 2351 | 2351 |
| 2352 ariaLabeledByText(textOrder); | 2352 ariaLabeledByText(textOrder); |
| 2353 | 2353 |
| 2354 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 2354 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
| 2355 if (!ariaLabel.isEmpty()) | 2355 if (!ariaLabel.isEmpty()) |
| 2356 textOrder.append(AccessibilityText(ariaLabel, AlternativeText)); | 2356 textOrder.append(AccessibilityText::create(ariaLabel, AlternativeText)); |
| 2357 | 2357 |
| 2358 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) { | 2358 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) { |
| 2359 // Images should use alt as long as the attribute is present, even if em
pty. | 2359 // Images should use alt as long as the attribute is present, even if em
pty. |
| 2360 // Otherwise, it should fallback to other methods, like the title attrib
ute. | 2360 // Otherwise, it should fallback to other methods, like the title attrib
ute. |
| 2361 const AtomicString& alt = getAttribute(altAttr); | 2361 const AtomicString& alt = getAttribute(altAttr); |
| 2362 if (!alt.isNull()) | 2362 if (!alt.isNull()) |
| 2363 textOrder.append(AccessibilityText(alt, AlternativeText)); | 2363 textOrder.append(AccessibilityText::create(alt, AlternativeText)); |
| 2364 } | 2364 } |
| 2365 } | 2365 } |
| 2366 | 2366 |
| 2367 void AXNodeObject::ariaLabeledByText(Vector<AccessibilityText>& textOrder) const | 2367 void AXNodeObject::ariaLabeledByText(WillBeHeapVector<OwnPtrWillBeMember<Accessi
bilityText>>& textOrder) const |
| 2368 { | 2368 { |
| 2369 String ariaLabeledBy = ariaLabeledByAttribute(); | 2369 String ariaLabeledBy = ariaLabeledByAttribute(); |
| 2370 if (!ariaLabeledBy.isEmpty()) { | 2370 if (!ariaLabeledBy.isEmpty()) { |
| 2371 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 2371 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; |
| 2372 ariaLabeledByElements(elements); | 2372 ariaLabeledByElements(elements); |
| 2373 | 2373 |
| 2374 for (const auto& element : elements) { | 2374 for (const auto& element : elements) { |
| 2375 RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); | 2375 RefPtrWillBeRawPtr<AXObject> axElement = axObjectCache()->getOrCreat
e(element); |
| 2376 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a
xElement)); | 2376 textOrder.append(AccessibilityText::create(ariaLabeledBy, Alternativ
eText, axElement)); |
| 2377 } | 2377 } |
| 2378 } | 2378 } |
| 2379 } | 2379 } |
| 2380 | 2380 |
| 2381 } // namespace blink | 2381 } // namespace blink |
| OLD | NEW |