Changeset 184890 in webkit


Ignore:
Timestamp:
May 26, 2015 5:53:00 PM (9 years ago)
Author:
Chris Fleizach
Message:

AX: display:none content exposed to accessibility when aria-hidden is toggled on ancestor element
https://bugs.webkit.org/show_bug.cgi?id=139142

Reviewed by Darin Adler.
Source/WebCore:


Amend the code that determines when an invisible, but aria-hidden=false, element is exposed to accessibility.

The new guideline is that you must have aria-hidden=false on every node that is not rendered (except text which inherits)
otherwise the element will not be visible.

Modified existing test: accessibility/aria-hidden-false-works-in-subtrees.html

  • accessibility/AXObjectCache.cpp:

(WebCore::isNodeAriaVisible):
(WebCore::AXObjectCache::rootWebArea):

LayoutTests:

  • accessibility/aria-hidden-false-works-in-subtrees.html:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r184885 r184890  
     12015-05-26  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: display:none content exposed to accessibility when aria-hidden is toggled on ancestor element
     4        https://bugs.webkit.org/show_bug.cgi?id=139142
     5
     6        Reviewed by Darin Adler.
     7
     8        * accessibility/aria-hidden-false-works-in-subtrees.html:
     9
    1102015-05-26  Zalan Bujtas  <zalan@apple.com>
    211
  • trunk/LayoutTests/accessibility/aria-hidden-false-works-in-subtrees.html

    r160789 r184890  
    66<body id="body">
    77
     8<div id="content">
     9
    810<div hidden aria-hidden="false" aria-label="group0">
    911   <div aria-hidden="true" aria-label="group1">
    1012      ignore me
    1113   </div>
    12    <div role="group" aria-label="group2">
    13      <div role="button" aria-label="button1">button</div>
     14   <div aria-hidden="false" role="group" aria-label="group2">
     15     <div aria-hidden="false" role="button" aria-label="button1">button</div>
    1416     don't ignore me
     17  </div>
     18</div>
     19
     20<!-- The text node should be visible because it inherits from the parent -->
     21<div id="group3" hidden aria-hidden="false">
     22text3
     23</div>
     24
     25<!-- The text node should be visible because it inherits from the parent, and all parents need aria-hidden=false -->
     26<div id="group4" hidden aria-hidden="false">
     27  <div role="group" hidden aria-hidden="false">
     28    text4
     29  </div>
     30</div>
     31
     32<!-- The text node should NOT be visible because it inherits from the parent, and all parents need aria-hidden=false -->
     33<div id="group5" role="group">
     34  <div hidden>
     35    <div role="group" hidden aria-hidden="false">
     36      text5
     37    </div>
     38  </div>
     39</div>
     40
     41<!-- The button inside should NOT be visible because it is not marked as aria-hidden -->
     42<div id="group6" hidden aria-hidden="false">
     43  <div aria-hidden="false">
     44     <button>button</button>
     45  </div>
     46</div>
     47
     48<!-- The button inside should be visible because it is marked as aria-hidden and all its parents are too -->
     49<div id="group7" hidden aria-hidden="false">
     50  <div aria-hidden="false">
     51     <button aria-hidden="false">button</button>
    1552  </div>
    1653</div>
     
    1855<div id="iframe">
    1956<iframe onload="testiFrameContent();" aria-hidden="false" src="resources/cake.png">hidden content</iframe>
     57</div>
     58
    2059</div>
    2160
     
    3473        iframeChild = iframe.childAtIndex(0);
    3574        debug("iFrame child role: " + iframeChild.role);
     75
     76        document.getElementById("content").style.visibility = "hidden";
    3677
    3778        finishJSTest();
     
    5495        window.jsTestIsAsync = true;
    5596
    56         var root = accessibilityController.rootElement.childAtIndex(0).childAtIndex(0);
     97        var root = accessibilityController.rootElement.childAtIndex(0).childAtIndex(0); 
    5798        dumpAccessibilityChildren(root, 0);
    58 }
     99
     100        // Text inside aria-hidden=false inherits from parent.
     101        var object = accessibilityController.accessibleElementById("group3").childAtIndex(0);
     102        shouldBe("object.role", "'AXRole: AXStaticText'");
     103        var stringValue = object.stringValue.replace(/\n/g, '');
     104        shouldBe("stringValue", "'AXValue: text3'");
     105
     106        // Text inside nested aria-hidden=false inherits from parent.
     107        object = accessibilityController.accessibleElementById("group4").childAtIndex(0).childAtIndex(0);
     108        shouldBe("object.role", "'AXRole: AXStaticText'");
     109        stringValue = object.stringValue.replace(/\n/g, '');
     110        shouldBe("stringValue", "'AXValue:     text4  '");
     111
     112        // When not all the parents have aria-hidden=false, element should not be visible.
     113        object = accessibilityController.accessibleElementById("group5").childAtIndex(0);
     114        shouldBeTrue("!object || !object.isValid");
     115
     116        // Objects that don't have aria-hidden=false are not visible when the parents have that attribute.
     117        object = accessibilityController.accessibleElementById("group6").childAtIndex(0);
     118        shouldBe("object.role", "'AXRole: AXGroup'");
     119        shouldBe("object.childrenCount", "0");
     120
     121        // When all objects have aria-hidden=false, then the elements are visible.
     122        object = accessibilityController.accessibleElementById("group7").childAtIndex(0);
     123        shouldBe("object.role", "'AXRole: AXGroup'");
     124        shouldBe("object.childrenCount", "1");
     125        shouldBe("object.childAtIndex(0).role", "'AXRole: AXButton'");
     126    }
    59127
    60128</script>
  • trunk/Source/WebCore/ChangeLog

    r184889 r184890  
     12015-05-26  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: display:none content exposed to accessibility when aria-hidden is toggled on ancestor element
     4        https://bugs.webkit.org/show_bug.cgi?id=139142
     5
     6        Reviewed by Darin Adler.
     7     
     8        Amend the code that determines when an invisible, but aria-hidden=false, element is exposed to accessibility.
     9
     10        The new guideline is that you must have aria-hidden=false on every node that is not rendered (except text which inherits)
     11        otherwise the element will not be visible.
     12
     13        Modified existing test: accessibility/aria-hidden-false-works-in-subtrees.html
     14
     15        * accessibility/AXObjectCache.cpp:
     16        (WebCore::isNodeAriaVisible):
     17        (WebCore::AXObjectCache::rootWebArea):
     18
    1192015-05-26  Roger Fong  <roger_fong@apple.com>
    220
  • trunk/Source/WebCore/accessibility/AXObjectCache.cpp

    r183783 r184890  
    13011301    if (!node)
    13021302        return false;
    1303    
    1304     // To determine if a node is ARIA visible, we need to check the parent hierarchy to see if anyone specifies
    1305     // aria-hidden explicitly.
     1303
     1304    // ARIA Node visibility is controlled by aria-hidden
     1305    //  1) if aria-hidden=true, the whole subtree is hidden
     1306    //  2) if aria-hidden=false, and the object is rendered, there's no effect
     1307    //  3) if aria-hidden=false, and the object is NOT rendered, then it must have
     1308    //     aria-hidden=false on each parent until it gets to a rendered object
     1309    //  3b) a text node inherits a parents aria-hidden value
     1310    bool requiresAriaHiddenFalse = !node->renderer();
     1311    bool ariaHiddenFalsePresent = false;
    13061312    for (Node* testNode = node; testNode; testNode = testNode->parentNode()) {
    13071313        if (is<Element>(*testNode)) {
    13081314            const AtomicString& ariaHiddenValue = downcast<Element>(*testNode).fastGetAttribute(aria_hiddenAttr);
    1309             if (equalIgnoringCase(ariaHiddenValue, "false"))
    1310                 return true;
    13111315            if (equalIgnoringCase(ariaHiddenValue, "true"))
    13121316                return false;
     1317           
     1318            bool ariaHiddenFalse = equalIgnoringCase(ariaHiddenValue, "false");
     1319            if (!testNode->renderer() && !ariaHiddenFalse)
     1320                return false;
     1321            if (!ariaHiddenFalsePresent && ariaHiddenFalse)
     1322                ariaHiddenFalsePresent = true;
    13131323        }
    13141324    }
    13151325   
    1316     return false;
     1326    return !requiresAriaHiddenFalse || ariaHiddenFalsePresent;
    13171327}
    13181328
Note: See TracChangeset for help on using the changeset viewer.