Changeset 137946 in webkit
- Timestamp:
- Dec 17, 2012 2:24:03 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r137945 r137946 1 2012-12-17 Dominic Mazzoni <dmazzoni@google.com> 2 3 AX: textUnderElement should consider alt text, but skip links and controls 4 https://bugs.webkit.org/show_bug.cgi?id=101650 5 6 Reviewed by Chris Fleizach. 7 8 Adds new tests to show that getting inner text from an element 9 now ignores focusable descendants and containers, but uses alternative 10 text. 11 12 Updates and rebaselines several tests to reflect the new logic. 13 Skips these tests on GTK until support for the object replacement 14 character can be added. 15 16 * accessibility/button-title-uses-inner-img-alt-expected.txt: Added. 17 * accessibility/button-title-uses-inner-img-alt.html: Added. 18 * accessibility/focusable-div-expected.txt: Extended with more test cases. 19 * accessibility/focusable-div.html: Extended with more test cases. 20 * platform/chromium/TestExpectations: Un-skip test that now passes. 21 * platform/chromium/accessibility/image-link-expected.txt: Rebaseline 22 * platform/mac/accessibility/image-link-expected.txt: Rebaseline 23 * platform/mac/accessibility/internal-link-anchors2-expected.txt: Rebaseline 24 * platform/mac/accessibility/static-text-role-uses-text-under-element-expected.txt: Rebaseline 25 * platform/mac/accessibility/static-text-role-uses-text-under-element.html: Fix 26 * platform/mac/accessibility/table-with-aria-role-expected.txt: Rebaseline 27 * platform/gtk/TestExpectations: Skip these tests until this feature is implemented for GTK. 28 1 29 2012-12-17 Levi Weintraub <leviw@chromium.org> 2 30 -
trunk/LayoutTests/accessibility/focusable-div-expected.txt
r137592 r137946 2 2 B 3 3 C 4 This test makes sure that a generic focusable div can get accessibility focus. 4 Link 5 Initial text before linkLink 6 List item 7 Initial text before list 8 List item 9 This test makes sure that a generic focusable div can get accessibility focus and gets its accessible text from contents.. 5 10 6 11 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 15 20 PASS document.activeElement == div3 is true 16 21 PASS lastChar(axDiv3.description) is "D" 22 PASS document.activeElement == div4 is true 23 PASS axDiv4.title.indexOf('Link') is -1 24 PASS document.activeElement == div5 is true 25 PASS axDiv5.title.indexOf('Link') is -1 26 PASS axDiv5.title.indexOf('Initial text before link') >= 0 is true 27 PASS document.activeElement == div6 is true 28 PASS axDiv6.title.indexOf('List item') is -1 29 PASS document.activeElement == div7 is true 30 PASS axDiv7.title.indexOf('List item') is -1 31 PASS axDiv7.title.indexOf('Initial text before list') >= 0 is true 17 32 PASS successfullyParsed is true 18 33 -
trunk/LayoutTests/accessibility/focusable-div.html
r137592 r137946 4 4 <script src="../fast/js/resources/js-test-pre.js"></script> 5 5 6 <!-- A link always gets its accessible text from contents. --> 6 7 <a id="link" href="#">A</a> 8 9 <!-- A generic focusable div should also get its accessible text from contents. --> 7 10 <div id="div" tabindex="0">B</div> 8 11 <div id="div2" tabindex="0"><div></div>C</div> 9 12 <div id="div3" tabindex="0" aria-label="D"></div> 10 13 14 <!-- A generic focusable div should not get accessible text from children that are focusable or containers. --> 15 <div id="div4" tabindex="0"><a href="#">Link</a></div> 16 <div id="div5" tabindex="0">Initial text before link<a href="#">Link</a></div> 17 <div id="div6" tabindex="0"><ul><li>List item</li></ul></div> 18 <div id="div7" tabindex="0">Initial text before list<ul><li>List item</li></ul></div> 19 11 20 <div id="console"></div> 12 21 <script> 13 description("This test makes sure that a generic focusable div can get accessibility focus .");22 description("This test makes sure that a generic focusable div can get accessibility focus and gets its accessible text from contents.."); 14 23 15 24 if (window.testRunner && window.accessibilityController) { … … 43 52 window.axDiv3 = accessibilityController.focusedElement; 44 53 shouldBe("lastChar(axDiv3.description)", "\"D\""); 54 55 var div4 = document.getElementById('div4'); 56 div4.focus(); 57 shouldBe("document.activeElement == div4", "true"); 58 window.axDiv4 = accessibilityController.focusedElement; 59 shouldBe("axDiv4.title.indexOf('Link')", "-1"); 60 61 var div5 = document.getElementById('div5'); 62 div5.focus(); 63 shouldBe("document.activeElement == div5", "true"); 64 window.axDiv5 = accessibilityController.focusedElement; 65 shouldBe("axDiv5.title.indexOf('Link')", "-1"); 66 shouldBe("axDiv5.title.indexOf('Initial text before link') >= 0", "true"); 67 68 var div6 = document.getElementById('div6'); 69 div6.focus(); 70 shouldBe("document.activeElement == div6", "true"); 71 window.axDiv6 = accessibilityController.focusedElement; 72 shouldBe("axDiv6.title.indexOf('List item')", "-1"); 73 74 var div7 = document.getElementById('div7'); 75 div7.focus(); 76 shouldBe("document.activeElement == div7", "true"); 77 window.axDiv7 = accessibilityController.focusedElement; 78 shouldBe("axDiv7.title.indexOf('List item')", "-1"); 79 shouldBe("axDiv7.title.indexOf('Initial text before list') >= 0", "true"); 45 80 } 46 81 -
trunk/LayoutTests/platform/chromium/TestExpectations
r137945 r137946 1399 1399 crbug.com/10322 accessibility/document-attributes.html [ Skip ] 1400 1400 crbug.com/10322 accessibility/iframe-bastardization.html [ Skip ] 1401 crbug.com/10322 accessibility/image-link.html [ Skip ]1402 1401 crbug.com/10322 accessibility/image-map-update-parent-crash.html [ Skip ] 1403 1402 crbug.com/10322 accessibility/image-map2.html [ Skip ] -
trunk/LayoutTests/platform/chromium/accessibility/image-link-expected.txt
r137592 r137946 4 4 5 5 6 AXTitle: Delicious cake 6 7 AXRole: AXLink 7 AXSubrole: (null) 8 AXRoleDescription: link 9 AXChildren: <array of size 1> 10 AXHelp: 11 AXParent: <AXLink> 12 AXSize: NSSize: {280, 213} 8 AXDescription: 9 10 Child 0: 13 11 AXTitle: 14 AXDescription: 15 AXValue: 16 AXFocused: 1 17 AXEnabled: 1 18 AXWindow: <AXLink> 19 AXSelectedTextMarkerRange: (null) 20 AXStartTextMarker: <AXLink> 21 AXEndTextMarker: <AXLink> 22 AXVisited: 0 23 AXLinkedUIElements: (null) 24 AXSelected: 0 25 AXBlockQuoteLevel: 0 26 AXTopLevelUIElement: <AXLink> 27 AXURL: http://www.wowhead.com/?item=33924 28 AXAccessKey: (null) 12 AXRole: AXImage 13 AXDescription: Delicious cake 29 14 30 15 31 Child 0:32 AXRole: AXImage33 AXSubrole: (null)34 AXRoleDescription: image35 AXChildren: <array of size 0>36 AXHelp:37 AXParent: <AXImage>38 AXSize: NSSize: {280, 209}39 AXTitle:40 AXDescription: Delicious cake41 AXValue:42 AXFocused: 043 AXEnabled: 144 AXWindow: <AXImage>45 AXSelectedTextMarkerRange: (null)46 AXStartTextMarker: <AXImage>47 AXEndTextMarker: <AXImage>48 AXVisited: 049 AXLinkedUIElements: (null)50 AXSelected: 051 AXBlockQuoteLevel: 052 AXTopLevelUIElement: <AXImage>53 AXURL: LayoutTests/accessibility/resources/cake.png54 AXAccessKey: (null)55 56 57 -
trunk/LayoutTests/platform/gtk/TestExpectations
r137758 r137946 773 773 webkit.org/b/98360 accessibility/aria-used-on-image-maps.html [ Failure ] 774 774 webkit.org/b/98361 accessibility/button-press-action.html [ Failure ] 775 webkit.org/b/105214 accessibility/button-title-uses-inner-img-alt.html [ Failure ] 775 776 webkit.org/b/98363 accessibility/canvas-fallback-content-2.html [ Failure ] 777 webkit.org/b/105214 accessibility/focusable-div.html [ Failure ] 776 778 webkit.org/b/98370 accessibility/loading-iframe-sends-notification.html [ Failure ] 777 779 webkit.org/b/98371 accessibility/loading-iframe-updates-axtree.html [ Failure ] -
trunk/LayoutTests/platform/mac/accessibility/image-link-expected.txt
r137592 r137946 9 9 AXChildren: <array of size 1> 10 10 AXHelp: 11 AXParent: <AXLink >11 AXParent: <AXLink: 'Delicious cake'> 12 12 AXSize: NSSize: {280, 213} 13 AXTitle: 13 AXTitle: Delicious cake 14 14 AXDescription: 15 15 AXValue: 16 16 AXFocused: 1 17 17 AXEnabled: 1 18 AXWindow: <AXLink >18 AXWindow: <AXLink: 'Delicious cake'> 19 19 AXSelectedTextMarkerRange: (null) 20 AXStartTextMarker: <AXLink >21 AXEndTextMarker: <AXLink >20 AXStartTextMarker: <AXLink: 'Delicious cake'> 21 AXEndTextMarker: <AXLink: 'Delicious cake'> 22 22 AXVisited: 0 23 23 AXLinkedUIElements: (null) 24 24 AXSelected: 0 25 25 AXBlockQuoteLevel: 0 26 AXTopLevelUIElement: <AXLink >26 AXTopLevelUIElement: <AXLink: 'Delicious cake'> 27 27 AXURL: http://www.wowhead.com/?item=33924 28 28 AXAccessKey: (null) -
trunk/LayoutTests/platform/mac/accessibility/internal-link-anchors2-expected.txt
r137638 r137946 6 6 AXChildren: <array of size 4> 7 7 AXHelp: 8 AXParent: <AXHeading: '[ edit] Tourette syndrome'>8 AXParent: <AXHeading: '[] Tourette syndrome'> 9 9 AXSize: NSSize: {769, 22} 10 AXTitle: [ edit] Tourette syndrome10 AXTitle: [] Tourette syndrome 11 11 AXDescription: 12 12 AXValue: 3 13 13 AXFocused: 0 14 14 AXEnabled: 1 15 AXWindow: <AXHeading: '[ edit] Tourette syndrome'>15 AXWindow: <AXHeading: '[] Tourette syndrome'> 16 16 AXSelectedTextMarkerRange: (null) 17 AXStartTextMarker: <AXHeading: '[ edit] Tourette syndrome'>18 AXEndTextMarker: <AXHeading: '[ edit] Tourette syndrome'>17 AXStartTextMarker: <AXHeading: '[] Tourette syndrome'> 18 AXEndTextMarker: <AXHeading: '[] Tourette syndrome'> 19 19 AXVisited: 0 20 20 AXLinkedUIElements: (null) 21 21 AXSelected: 0 22 22 AXBlockQuoteLevel: 0 23 AXTopLevelUIElement: <AXHeading: '[ edit] Tourette syndrome'>23 AXTopLevelUIElement: <AXHeading: '[] Tourette syndrome'> 24 24 AXARIABusy: 0 25 25 -
trunk/LayoutTests/platform/mac/accessibility/static-text-role-uses-text-under-element-expected.txt
r137592 r137946 5 5 6 6 7 PASS text.stringValue is 'AXValue: Text 1 Text 2Text 3'7 PASS text.stringValue is 'AXValue: Text 3' 8 8 PASS successfullyParsed is true 9 9 -
trunk/LayoutTests/platform/mac/accessibility/static-text-role-uses-text-under-element.html
r137592 r137946 27 27 document.getElementById("text1").focus(); 28 28 var text = accessibilityController.focusedElement; 29 shouldBe("text.stringValue", "'AXValue: Text 1 Text 2Text 3'");29 shouldBe("text.stringValue", "'AXValue: Text 3'"); 30 30 } 31 31 -
trunk/LayoutTests/platform/mac/accessibility/table-with-aria-role-expected.txt
r137592 r137946 8 8 AXChildren: <array of size 0> 9 9 AXHelp: 10 AXParent: <AXButton: 'test test test 11 test test test 12 '> 10 AXParent: <AXButton: 'testtesttesttesttesttest'> 13 11 AXSize: NSSize: {85, 52} 14 AXTitle: test test test 15 test test test 16 12 AXTitle: testtesttesttesttesttest 17 13 AXDescription: 18 14 AXFocused: 0 19 15 AXEnabled: 1 20 AXWindow: <AXButton: 'test test test 21 test test test 22 '> 16 AXWindow: <AXButton: 'testtesttesttesttesttest'> 23 17 AXSelectedTextMarkerRange: (null) 24 AXStartTextMarker: <AXButton: 'test test test 25 test test test 26 '> 27 AXEndTextMarker: <AXButton: 'test test test 28 test test test 29 '> 18 AXStartTextMarker: <AXButton: 'testtesttesttesttesttest'> 19 AXEndTextMarker: <AXButton: 'testtesttesttesttesttest'> 30 20 AXVisited: 0 31 21 AXLinkedUIElements: (null) 32 22 AXSelected: 0 33 23 AXBlockQuoteLevel: 0 34 AXTopLevelUIElement: <AXButton: 'test test test 35 test test test 36 '> 24 AXTopLevelUIElement: <AXButton: 'testtesttesttesttesttest'> 37 25 AXTitleUIElement: (null) 38 26 AXAccessKey: (null) -
trunk/Source/WebCore/ChangeLog
r137940 r137946 1 2012-12-17 Dominic Mazzoni <dmazzoni@google.com> 2 3 AX: textUnderElement should consider alt text, but skip links and controls 4 https://bugs.webkit.org/show_bug.cgi?id=101650 5 6 Reviewed by Chris Fleizach. 7 8 Getting inner text from an element now ignores focusable descendants 9 and containers, but uses alternative text. The computation of 10 textUnderElement is now recursive and doesn't depend on text 11 iterators, which might not do the right thing for accessibility 12 anyways. 13 14 For GTK, the old behavior is retained so that support for 15 the object replacement character is still there. Filed a new 16 bug (105214) for GTK folks to look at this. 17 18 Test: accessibility/button-title-uses-inner-img-alt.html 19 Test: accessibility/focusable-div.html 20 21 * accessibility/AccessibilityNodeObject.cpp: 22 (WebCore): 23 (WebCore::shouldUseAccessiblityObjectInnerText): 24 (WebCore::AccessibilityNodeObject::textUnderElement): 25 * accessibility/AccessibilityRenderObject.cpp: 26 (WebCore::AccessibilityRenderObject::textUnderElement): 27 1 28 2012-12-17 Otto Derek Cheung <otcheung@rim.com> 2 29 -
trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
r137592 r137946 1435 1435 } 1436 1436 1437 // When building the textUnderElement for an object, determine whether or not 1438 // we should include the inner text of this given descendant object or skip it. 1439 static bool shouldUseAccessiblityObjectInnerText(AccessibilityObject* obj) 1440 { 1441 // Consider this hypothetical example: 1442 // <div tabindex=0> 1443 // <h2> 1444 // Table of contents 1445 // </h2> 1446 // <a href="#start">Jump to start of book</a> 1447 // <ul> 1448 // <li><a href="#1">Chapter 1</a></li> 1449 // <li><a href="#1">Chapter 2</a></li> 1450 // </ul> 1451 // </div> 1452 // 1453 // The goal is to return a reasonable title for the outer container div, because 1454 // it's focusable - but without making its title be the full inner text, which is 1455 // quite long. As a heuristic, skip links, controls, and elements that are usually 1456 // containers with lots of children. 1457 1458 // Skip focusable children, so we don't include the text of links and controls. 1459 if (obj->canSetFocusAttribute()) 1460 return false; 1461 1462 // Skip big container elements like lists, tables, etc. 1463 if (obj->isList() || obj->isAccessibilityTable() || obj->isTree() || obj->isCanvas()) 1464 return false; 1465 1466 return true; 1467 } 1468 1437 1469 String AccessibilityNodeObject::textUnderElement() const 1438 1470 { 1439 1471 Node* node = this->node(); 1440 if (!node) 1441 return String(); 1442 1443 // Note: TextIterator doesn't return any text for nodes that don't have renderers. 1444 // If this could be fixed, it'd be more accurate use TextIterator here. 1445 if (node->isElementNode()) 1446 return toElement(node)->innerText(); 1447 else if (node->isTextNode()) 1472 if (node && node->isTextNode()) 1448 1473 return toText(node)->wholeText(); 1449 1450 return String(); 1474 1475 String result; 1476 for (AccessibilityObject* child = firstChild(); child; child = child->nextSibling()) { 1477 if (!shouldUseAccessiblityObjectInnerText(child)) 1478 continue; 1479 1480 if (child->isAccessibilityNodeObject()) { 1481 Vector<AccessibilityText> textOrder; 1482 toAccessibilityNodeObject(child)->alternativeText(textOrder); 1483 if (textOrder.size() > 0) { 1484 result.append(textOrder[0].text); 1485 continue; 1486 } 1487 } 1488 1489 result.append(child->textUnderElement()); 1490 } 1491 1492 return result; 1451 1493 } 1452 1494 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r137592 r137946 625 625 if (!m_renderer) 626 626 return String(); 627 627 628 628 if (m_renderer->isFileUploadControl()) 629 629 return toRenderFileUploadControl(m_renderer)->buttonValue(); 630 630 631 Node* node = m_renderer->node();632 633 631 #if ENABLE(MATHML) 634 632 // Math operators create RenderText nodes on the fly that are not tied into the DOM in a reasonable way, … … 641 639 } 642 640 #endif 643 644 if (node) { 641 642 #if PLATFORM(GTK) 643 // On GTK, always use a text iterator in order to get embedded object characters. 644 // TODO: Add support for embedded object characters to the other codepaths that try 645 // to build the accessible text recursively, so this special case isn't needed. 646 // https://bugs.webkit.org/show_bug.cgi?id=105214 647 if (Node* node = this->node()) { 645 648 if (Frame* frame = node->document()->frame()) { 646 649 // catch stale WebCoreAXObject (see <rdar://problem/3960196>) … … 651 654 } 652 655 } 653 654 // Sometimes text fragments don't have Node's associated with them (like when 655 // CSS content is used to insert text). 656 #endif 657 656 658 if (m_renderer->isText()) { 659 // If possible, use a text iterator to get the text, so that whitespace 660 // is handled consistently. 661 if (Node* node = this->node()) { 662 if (Frame* frame = node->document()->frame()) { 663 // catch stale WebCoreAXObject (see <rdar://problem/3960196>) 664 if (frame->document() != node->document()) 665 return String(); 666 667 return plainText(rangeOfContents(node).get(), textIteratorBehaviorForTextRange()); 668 } 669 } 670 671 // Sometimes text fragments don't have Nodes associated with them (like when 672 // CSS content is used to insert text). 657 673 RenderText* renderTextObject = toRenderText(m_renderer); 658 674 if (renderTextObject->isTextFragment()) … … 660 676 } 661 677 662 // return the null string for anonymous text because it is non-trivial to get 663 // the actual text and, so far, that is not needed 664 return String(); 678 return AccessibilityNodeObject::textUnderElement(); 665 679 } 666 680
Note: See TracChangeset
for help on using the changeset viewer.