Changeset 231778 in webkit


Ignore:
Timestamp:
May 14, 2018, 5:32:06 PM (7 years ago)
Author:
[email protected]
Message:

AX: Listbox and Combobox roles embedded in labels should participate in name calculation
https://bugs.webkit.org/show_bug.cgi?id=185521

Reviewed by Chris Fleizach.

Source/WebCore:

Take selected children into account when computing the name in accessibleNameForNode.
Add ListBox to the roles for which accessibleNameDerivesFromContent returns false so
that native select elements with size > 1 are treated the same way as ARIA listbox.
Also add ListBox to the roles which are treated as controls when used in ARIA. Finally,
prevent labels which contain unrelated controls from being used as an AXTitleUIElement.
This causes us to build a string from the label and its descendants, ensuring the latter
participate in the name calculation.

Test: accessibility/text-alternative-calculation-from-listbox.html

  • accessibility/AccessibilityLabel.cpp:

(WebCore::childrenContainUnrelatedControls):
(WebCore::AccessibilityLabel::containsUnrelatedControls const):

  • accessibility/AccessibilityLabel.h:
  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::accessibleNameForNode):

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::accessibleNameDerivesFromContent const):
(WebCore::AccessibilityObject::isARIAControl):

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::exposesTitleUIElement const):
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const):

LayoutTests:

  • accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior.
  • accessibility/text-alternative-calculation-from-listbox-expected.txt: Added.
  • accessibility/text-alternative-calculation-from-listbox.html: Added.
  • platform/mac/accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior.
  • platform/win/accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r231766 r231778  
     12018-05-14  Joanmarie Diggs  <[email protected]>
     2
     3        AX: Listbox and Combobox roles embedded in labels should participate in name calculation
     4        https://bugs.webkit.org/show_bug.cgi?id=185521
     5
     6        Reviewed by Chris Fleizach.
     7
     8        * accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior.
     9        * accessibility/text-alternative-calculation-from-listbox-expected.txt: Added.
     10        * accessibility/text-alternative-calculation-from-listbox.html: Added.
     11        * platform/mac/accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior.
     12        * platform/win/accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior.
     13
    1142018-05-14  Antoine Quint  <[email protected]>
    215
  • trunk/LayoutTests/accessibility/label-with-pseudo-elements-expected.txt

    r229682 r231778  
    2525        AXTitleUIElement: null
    2626
    27         AXTitle:
     27        AXTitle: test 5 input value
    2828        AXDescription:
    29         AXTitleUIElement: non-null
     29        AXTitleUIElement: null
    3030
    31         AXTitle:
     31        AXTitle: before test 6 input value after
    3232        AXDescription:
    33         AXTitleUIElement: non-null
     33        AXTitleUIElement: null
    3434
    3535PASS successfullyParsed is true
  • trunk/LayoutTests/platform/mac/accessibility/label-with-pseudo-elements-expected.txt

    r229682 r231778  
    2929        AXTitleUIElement: null
    3030
    31         AXTitle:
     31        AXTitle: test 5 input value
    3232        AXDescription:
    3333        AXHelp:
    34         AXTitleUIElement: non-null
     34        AXTitleUIElement: null
    3535
    36         AXTitle:
     36        AXTitle: before test 6 input value after
    3737        AXDescription:
    3838        AXHelp:
    39         AXTitleUIElement: non-null
     39        AXTitleUIElement: null
    4040
    4141PASS successfullyParsed is true
  • trunk/LayoutTests/platform/win/accessibility/label-with-pseudo-elements-expected.txt

    r229682 r231778  
    2525        AXTitleUIElement: null
    2626
    27         AXTitle:
     27        AXTitle: test 5 input value
    2828        AXDescription:
    29         AXTitleUIElement: non-null
     29        AXTitleUIElement: null
    3030
    31         AXTitle:
     31        AXTitle: before test 6 input value after
    3232        AXDescription:
    33         AXTitleUIElement: non-null
     33        AXTitleUIElement: null
    3434
    3535PASS successfullyParsed is true
  • trunk/Source/WebCore/ChangeLog

    r231766 r231778  
     12018-05-14  Joanmarie Diggs  <[email protected]>
     2
     3        AX: Listbox and Combobox roles embedded in labels should participate in name calculation
     4        https://bugs.webkit.org/show_bug.cgi?id=185521
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Take selected children into account when computing the name in accessibleNameForNode.
     9        Add ListBox to the roles for which accessibleNameDerivesFromContent returns false so
     10        that native select elements with size > 1 are treated the same way as ARIA listbox.
     11        Also add ListBox to the roles which are treated as controls when used in ARIA. Finally,
     12        prevent labels which contain unrelated controls from being used as an AXTitleUIElement.
     13        This causes us to build a string from the label and its descendants, ensuring the latter
     14        participate in the name calculation.
     15
     16        Test: accessibility/text-alternative-calculation-from-listbox.html
     17
     18        * accessibility/AccessibilityLabel.cpp:
     19        (WebCore::childrenContainUnrelatedControls):
     20        (WebCore::AccessibilityLabel::containsUnrelatedControls const):
     21        * accessibility/AccessibilityLabel.h:
     22        * accessibility/AccessibilityNodeObject.cpp:
     23        (WebCore::accessibleNameForNode):
     24        * accessibility/AccessibilityObject.cpp:
     25        (WebCore::AccessibilityObject::accessibleNameDerivesFromContent const):
     26        (WebCore::AccessibilityObject::isARIAControl):
     27        * accessibility/AccessibilityRenderObject.cpp:
     28        (WebCore::AccessibilityRenderObject::exposesTitleUIElement const):
     29        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const):
     30
    1312018-05-14  Antoine Quint  <[email protected]>
    232
  • trunk/Source/WebCore/accessibility/AccessibilityLabel.cpp

    r224074 r231778  
    8484}
    8585
     86static bool childrenContainUnrelatedControls(const AccessibilityObject::AccessibilityChildrenVector& children, AccessibilityObject* controlForLabel)
     87{
     88    if (!children.size())
     89        return false;
     90
     91    for (const auto& child : children) {
     92        if (child->isControl()) {
     93            if (child == controlForLabel)
     94                continue;
     95            return true;
     96        }
     97
     98        if (childrenContainUnrelatedControls(child->children(), controlForLabel))
     99            return true;
     100    }
     101
     102    return false;
     103}
     104
     105bool AccessibilityLabel::containsUnrelatedControls() const
     106{
     107    if (containsOnlyStaticText())
     108        return false;
     109
     110    return childrenContainUnrelatedControls(m_children, correspondingControlForLabelElement());
     111}
     112
    86113void AccessibilityLabel::updateChildrenIfNecessary()
    87114{
  • trunk/Source/WebCore/accessibility/AccessibilityLabel.h

    r224074 r231778  
    3939   
    4040    bool containsOnlyStaticText() const;
     41    bool containsUnrelatedControls() const;
    4142
    4243private:
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r231627 r231778  
    19531953        if (!valueDescription.isEmpty())
    19541954            return valueDescription;
     1955
     1956        // The Accname specification states that if the name is being calculated for a combobox
     1957        // or listbox inside a labeling element, return the text alternative of the chosen option.
     1958        AccessibilityObject::AccessibilityChildrenVector children;
     1959        if (axObject->isListBox())
     1960            axObject->selectedChildren(children);
     1961        else if (axObject->isComboBox()) {
     1962            for (const auto& child : axObject->children()) {
     1963                if (child->isListBox()) {
     1964                    child->selectedChildren(children);
     1965                    break;
     1966                }
     1967            }
     1968        }
     1969
     1970        StringBuilder builder;
     1971        String childText;
     1972        for (const auto& child : children)
     1973            appendNameToStringBuilder(builder, accessibleNameForNode(child->node()));
     1974
     1975        childText = builder.toString();
     1976        if (!childText.isEmpty())
     1977            return childText;
    19551978    }
    19561979   
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r231720 r231778  
    355355    switch (roleValue()) {
    356356    case AccessibilityRole::Slider:
     357    case AccessibilityRole::ListBox:
    357358        return false;
    358359    default:
     
    906907bool AccessibilityObject::isARIAControl(AccessibilityRole ariaRole)
    907908{
    908     return isARIAInput(ariaRole) || ariaRole == AccessibilityRole::TextArea || ariaRole == AccessibilityRole::Button || ariaRole == AccessibilityRole::ComboBox || ariaRole == AccessibilityRole::Slider;
     909    return isARIAInput(ariaRole) || ariaRole == AccessibilityRole::TextArea || ariaRole == AccessibilityRole::Button || ariaRole == AccessibilityRole::ComboBox || ariaRole == AccessibilityRole::Slider || ariaRole == AccessibilityRole::ListBox;
    909910}
    910911   
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r229310 r231778  
    3232#include "AXObjectCache.h"
    3333#include "AccessibilityImageMapLink.h"
     34#include "AccessibilityLabel.h"
    3435#include "AccessibilityListBox.h"
    3536#include "AccessibilitySVGRoot.h"
     
    10651066                if (!labelObject->ariaLabeledByAttribute().isEmpty())
    10661067                    return false;
     1068                // To simplify instances where the labeling element includes widget descendants
     1069                // which it does not label.
     1070                if (is<AccessibilityLabel>(*labelObject)
     1071                    && downcast<AccessibilityLabel>(*labelObject).containsUnrelatedControls())
     1072                    return false;
    10671073            }
    10681074        }
     
    12051211        return true;
    12061212
    1207     // find out if this element is inside of a label element.
    1208     // if so, it may be ignored because it's the label for a checkbox or radio button
    1209     AccessibilityObject* controlObject = correspondingControlForLabelElement();
    1210     if (controlObject && !controlObject->exposesTitleUIElement() && controlObject->isCheckboxOrRadio())
    1211         return true;
    1212    
    12131213    // https://webkit.org/b/161276 Getting the controlObject might cause the m_renderer to be nullptr.
    12141214    if (!m_renderer)
     
    14161416    if (m_renderer->isRubyRun() || m_renderer->isRubyBlock() || m_renderer->isRubyInline())
    14171417        return false;
     1418
     1419    // Find out if this element is inside of a label element.
     1420    // If so, it may be ignored because it's the label for a checkbox or radio button.
     1421    AccessibilityObject* controlObject = correspondingControlForLabelElement();
     1422    if (controlObject && !controlObject->exposesTitleUIElement() && controlObject->isCheckboxOrRadio())
     1423        return true;
    14181424
    14191425    // By default, objects should be ignored so that the AX hierarchy is not
Note: See TracChangeset for help on using the changeset viewer.