| 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 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 if (node && node->isTextNode()) | 1555 if (node && node->isTextNode()) |
| 1556 return toText(node)->wholeText(); | 1556 return toText(node)->wholeText(); |
| 1557 | 1557 |
| 1558 StringBuilder builder; | 1558 StringBuilder builder; |
| 1559 AXObject* previous = nullptr; | 1559 AXObject* previous = nullptr; |
| 1560 for (AXObject* child = firstChild(); child; child = child->nextSibling()) { | 1560 for (AXObject* child = firstChild(); child; child = child->nextSibling()) { |
| 1561 if (!shouldUseAccessibilityObjectInnerText(child)) | 1561 if (!shouldUseAccessibilityObjectInnerText(child)) |
| 1562 continue; | 1562 continue; |
| 1563 | 1563 |
| 1564 if (child->isAXNodeObject()) { | 1564 if (child->isAXNodeObject()) { |
| 1565 Vector<AccessibilityText> textOrder; | 1565 WillBeHeapVector<OwnPtrWillBeMember<AccessibilityText>> textOrder; |
| 1566 toAXNodeObject(child)->alternativeText(textOrder); | 1566 toAXNodeObject(child)->alternativeText(textOrder); |
| 1567 if (textOrder.size() > 0) { | 1567 if (textOrder.size() > 0) { |
| 1568 builder.append(textOrder[0].text); | 1568 builder.append(textOrder[0]->text()); |
| 1569 if (mode == TextUnderElementAny) | 1569 if (mode == TextUnderElementAny) |
| 1570 break; | 1570 break; |
| 1571 continue; | 1571 continue; |
| 1572 } | 1572 } |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 // If we're going between two layoutObjects that are in separate LayoutB
oxes, add | 1575 // If we're going between two layoutObjects that are in separate LayoutB
oxes, add |
| 1576 // whitespace if it wasn't there already. Intuitively if you have | 1576 // whitespace if it wasn't there already. Intuitively if you have |
| 1577 // <span>Hello</span><span>World</span>, those are part of the same Layo
utBox | 1577 // <span>Hello</span><span>World</span>, those are part of the same Layo
utBox |
| 1578 // so we should return "HelloWorld", but given <div>Hello</div><div>Worl
d</div> the | 1578 // so we should return "HelloWorld", but given <div>Hello</div><div>Worl
d</div> the |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2317 String documentTitle = document->title(); | 2317 String documentTitle = document->title(); |
| 2318 if (!documentTitle.isEmpty()) | 2318 if (!documentTitle.isEmpty()) |
| 2319 return documentTitle; | 2319 return documentTitle; |
| 2320 | 2320 |
| 2321 if (HTMLElement* body = document->body()) | 2321 if (HTMLElement* body = document->body()) |
| 2322 return body->getNameAttribute(); | 2322 return body->getNameAttribute(); |
| 2323 | 2323 |
| 2324 return String(); | 2324 return String(); |
| 2325 } | 2325 } |
| 2326 | 2326 |
| 2327 void AXNodeObject::alternativeText(Vector<AccessibilityText>& textOrder) const | 2327 void AXNodeObject::alternativeText(WillBeHeapVector<OwnPtrWillBeMember<Accessibi
lityText>>& textOrder) const |
| 2328 { | 2328 { |
| 2329 if (isWebArea()) { | 2329 if (isWebArea()) { |
| 2330 String webAreaText = alternativeTextForWebArea(); | 2330 String webAreaText = alternativeTextForWebArea(); |
| 2331 if (!webAreaText.isEmpty()) | 2331 if (!webAreaText.isEmpty()) |
| 2332 textOrder.append(AccessibilityText(webAreaText, AlternativeText)); | 2332 textOrder.append(AccessibilityText::create(webAreaText, AlternativeT
ext)); |
| 2333 return; | 2333 return; |
| 2334 } | 2334 } |
| 2335 | 2335 |
| 2336 ariaLabeledByText(textOrder); | 2336 ariaLabeledByText(textOrder); |
| 2337 | 2337 |
| 2338 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 2338 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
| 2339 if (!ariaLabel.isEmpty()) | 2339 if (!ariaLabel.isEmpty()) |
| 2340 textOrder.append(AccessibilityText(ariaLabel, AlternativeText)); | 2340 textOrder.append(AccessibilityText::create(ariaLabel, AlternativeText)); |
| 2341 | 2341 |
| 2342 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) { | 2342 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) { |
| 2343 // Images should use alt as long as the attribute is present, even if em
pty. | 2343 // Images should use alt as long as the attribute is present, even if em
pty. |
| 2344 // Otherwise, it should fallback to other methods, like the title attrib
ute. | 2344 // Otherwise, it should fallback to other methods, like the title attrib
ute. |
| 2345 const AtomicString& alt = getAttribute(altAttr); | 2345 const AtomicString& alt = getAttribute(altAttr); |
| 2346 if (!alt.isNull()) | 2346 if (!alt.isNull()) |
| 2347 textOrder.append(AccessibilityText(alt, AlternativeText)); | 2347 textOrder.append(AccessibilityText::create(alt, AlternativeText)); |
| 2348 } | 2348 } |
| 2349 } | 2349 } |
| 2350 | 2350 |
| 2351 void AXNodeObject::ariaLabeledByText(Vector<AccessibilityText>& 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 RefPtr<AXObject> axElement = axObjectCache().getOrCreate(element); |
| 2360 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a
xElement)); | 2360 textOrder.append(AccessibilityText::create(ariaLabeledBy, Alternativ
eText, axElement)); |
| 2361 } | 2361 } |
| 2362 } | 2362 } |
| 2363 } | 2363 } |
| 2364 | 2364 |
| 2365 } // namespace blink | 2365 } // namespace blink |
| OLD | NEW |