Changeset 164577 in webkit


Ignore:
Timestamp:
Feb 24, 2014 1:31:12 AM (10 years ago)
Author:
k.czech@samsung.com
Message:

[ATK] Wrong selected element at a given index in a list box.
https://bugs.webkit.org/show_bug.cgi?id=129039

Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/select-element-at-index.html

The selected element at a given index was wrong. One should be considered among the
all children of a list box, not only selected ones.

  • accessibility/atk/WebKitAccessibleInterfaceSelection.cpp:

(core):
(listObjectForSelection):
(optionFromList):
(optionFromSelection):
(webkitAccessibleSelectionRefSelection):

Tools:

Added missing implementation and proposed some new function for testing selection
in a list boxes.

  • DumpRenderTree/AccessibilityUIElement.cpp:

(setSelectedChildAtIndexCallback):
(removeSelectionAtIndexCallback):
(AccessibilityUIElement::getJSClass):

  • DumpRenderTree/AccessibilityUIElement.h:
  • DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:

(AccessibilityUIElement::selectedChildrenCount):
(AccessibilityUIElement::selectedChildAtIndex):
(AccessibilityUIElement::setSelectedChildAtIndex):
(AccessibilityUIElement::removeSelectionAtIndex):

  • DumpRenderTree/win/AccessibilityUIElementWin.cpp:

(AccessibilityUIElement::selectedChildrenCount):
(AccessibilityUIElement::selectedChildAtIndex):

  • WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:

(WTR::AccessibilityUIElement::setSelectedChildAtIndex):
(WTR::AccessibilityUIElement::removeSelectionAtIndex):

  • WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
  • WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
  • WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:

(WTR::AccessibilityUIElement::selectedChildAtIndex):
(WTR::AccessibilityUIElement::selectedChildrenCount):
(WTR::AccessibilityUIElement::setSelectedChildAtIndex):
(WTR::AccessibilityUIElement::removeSelectionAtIndex):

LayoutTests:

Proposed test that checks whether correct element at a given index is retrieved.
Also testing some other scenarios such as removing selection from rows, counting all
selected rows and setting selection.

  • accessibility/select-element-at-index-expected.txt: Added.
  • accessibility/select-element-at-index.html: Added.
  • platform/mac/TestExpectations: Skipping test in Mac, missing implementation.
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r164574 r164577  
     12014-02-24  Krzysztof Czech  <k.czech@samsung.com>
     2
     3        [ATK] Wrong selected element at a given index in a list box.
     4        https://bugs.webkit.org/show_bug.cgi?id=129039
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Proposed test that checks whether correct element at a given index is retrieved.
     9        Also testing some other scenarios such as removing selection from rows, counting all
     10        selected rows and setting selection.
     11
     12        * accessibility/select-element-at-index-expected.txt: Added.
     13        * accessibility/select-element-at-index.html: Added.
     14        * platform/mac/TestExpectations: Skipping test in Mac, missing implementation.
     15
    1162014-02-23  Dean Jackson  <dino@apple.com>
    217
  • trunk/LayoutTests/platform/mac/TestExpectations

    r164574 r164577  
    5050# isIndeterminate is not implemented in mac
    5151webkit.org/b/125855 accessibility/aria-checked-mixed-value.html [ Skip ]
     52# Missing implementation of some functions in mac.
     53webkit.org/b/129039 accessibility/select-element-at-index.html [ Skip ]
    5254
    5355# ariaControlsElementAtIndex is not implemented in mac
  • trunk/Source/WebCore/ChangeLog

    r164574 r164577  
     12014-02-24  Krzysztof Czech  <k.czech@samsung.com>
     2
     3        [ATK] Wrong selected element at a given index in a list box.
     4        https://bugs.webkit.org/show_bug.cgi?id=129039
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Test: accessibility/select-element-at-index.html
     9
     10        The selected element at a given index was wrong. One should be considered among the
     11        all children of a list box, not only selected ones.
     12
     13        * accessibility/atk/WebKitAccessibleInterfaceSelection.cpp:
     14        (core):
     15        (listObjectForSelection):
     16        (optionFromList):
     17        (optionFromSelection):
     18        (webkitAccessibleSelectionRefSelection):
     19
    1202014-02-23  Dean Jackson  <dino@apple.com>
    221
  • trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceSelection.cpp

    r161873 r164577  
    4646{
    4747    if (!WEBKIT_IS_ACCESSIBLE(selection))
    48         return 0;
     48        return nullptr;
    4949
    5050    return webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(selection));
     
    5757    // Only list boxes and menu lists supported so far.
    5858    if (!coreSelection->isListBox() && !coreSelection->isMenuList())
    59         return 0;
     59        return nullptr;
    6060
    6161    // For list boxes the list object is just itself.
     
    6868    const AccessibilityObject::AccessibilityChildrenVector& children = coreSelection->children();
    6969    if (!children.size())
    70         return 0;
     70        return nullptr;
    7171
    7272    AccessibilityObject* listObject = children.at(0).get();
    7373    if (!listObject->isMenuListPopup())
    74         return 0;
     74        return nullptr;
    7575
    7676    return listObject;
     
    8181    AccessibilityObject* coreSelection = core(selection);
    8282    if (!coreSelection || index < 0)
    83         return 0;
     83        return nullptr;
    8484
    8585    // Need to select the proper list object depending on the type.
    8686    AccessibilityObject* listObject = listObjectForSelection(selection);
    8787    if (!listObject)
    88         return 0;
     88        return nullptr;
    8989
    9090    const AccessibilityObject::AccessibilityChildrenVector& options = listObject->children();
     
    9292        return options.at(index).get();
    9393
    94     return 0;
     94    return nullptr;
    9595}
    9696
     
    101101    AccessibilityObject* coreSelection = core(selection);
    102102    if (!coreSelection || !coreSelection->isAccessibilityRenderObject() || index < 0)
    103         return 0;
    104 
    105     AccessibilityObject::AccessibilityChildrenVector selectedItems;
    106     if (coreSelection->isListBox())
    107         coreSelection->selectedChildren(selectedItems);
    108     else if (coreSelection->isMenuList()) {
     103        return nullptr;
     104
     105    int selectedIndex = index;
     106    if (coreSelection->isMenuList()) {
    109107        RenderObject* renderer = coreSelection->renderer();
    110108        if (!renderer)
    111             return 0;
     109            return nullptr;
    112110
    113111        HTMLSelectElement* selectNode = toHTMLSelectElement(renderer->node());
    114         int selectedIndex = selectNode->selectedIndex();
    115         const Vector<HTMLElement*> listItems = selectNode->listItems();
     112        if (!selectNode)
     113            return nullptr;
     114
     115        selectedIndex = selectNode->selectedIndex();
     116        const auto& listItems = selectNode->listItems();
    116117
    117118        if (selectedIndex < 0 || selectedIndex >= static_cast<int>(listItems.size()))
    118             return 0;
    119 
    120         return optionFromList(selection, selectedIndex);
    121     }
    122 
    123     if (index < static_cast<gint>(selectedItems.size()))
    124         return selectedItems.at(index).get();
    125 
    126     return 0;
     119            return nullptr;
     120    }
     121
     122    return optionFromList(selection, selectedIndex);
    127123}
    128124
     
    167163static AtkObject* webkitAccessibleSelectionRefSelection(AtkSelection* selection, gint index)
    168164{
    169     g_return_val_if_fail(ATK_SELECTION(selection), 0);
    170     returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(selection), 0);
     165    g_return_val_if_fail(ATK_SELECTION(selection), nullptr);
     166    returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(selection), nullptr);
    171167
    172168    AccessibilityObject* option = optionFromSelection(selection, index);
     
    177173    }
    178174
    179     return 0;
     175    return nullptr;
    180176}
    181177
  • trunk/Tools/ChangeLog

    r164562 r164577  
     12014-02-24  Krzysztof Czech  <k.czech@samsung.com>
     2
     3        [ATK] Wrong selected element at a given index in a list box.
     4        https://bugs.webkit.org/show_bug.cgi?id=129039
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Added missing implementation and proposed some new function for testing selection
     9        in a list boxes.
     10
     11        * DumpRenderTree/AccessibilityUIElement.cpp:
     12        (setSelectedChildAtIndexCallback):
     13        (removeSelectionAtIndexCallback):
     14        (AccessibilityUIElement::getJSClass):
     15        * DumpRenderTree/AccessibilityUIElement.h:
     16        * DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
     17        (AccessibilityUIElement::selectedChildrenCount):
     18        (AccessibilityUIElement::selectedChildAtIndex):
     19        (AccessibilityUIElement::setSelectedChildAtIndex):
     20        (AccessibilityUIElement::removeSelectionAtIndex):
     21        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
     22        (AccessibilityUIElement::selectedChildrenCount):
     23        (AccessibilityUIElement::selectedChildAtIndex):
     24        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
     25        (WTR::AccessibilityUIElement::setSelectedChildAtIndex):
     26        (WTR::AccessibilityUIElement::removeSelectionAtIndex):
     27        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
     28        * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
     29        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
     30        (WTR::AccessibilityUIElement::selectedChildAtIndex):
     31        (WTR::AccessibilityUIElement::selectedChildrenCount):
     32        (WTR::AccessibilityUIElement::setSelectedChildAtIndex):
     33        (WTR::AccessibilityUIElement::removeSelectionAtIndex):
     34
    1352014-02-23  Diego Pino García  <dpino@igalia.com>
    236
  • trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp

    r164270 r164577  
    12081208}
    12091209
     1210static JSValueRef setSelectedChildAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     1211{
     1212    int indexNumber = -1;
     1213    if (argumentCount == 1);
     1214        indexNumber = JSValueToNumber(context, arguments[0], exception);
     1215
     1216    if (indexNumber >= 0)
     1217        toAXElement(thisObject)->setSelectedChildAtIndex(indexNumber);
     1218    return JSValueMakeUndefined(context);
     1219}
     1220
     1221static JSValueRef removeSelectionAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     1222{
     1223    int indexNumber = -1;
     1224    if (argumentCount == 1)
     1225        indexNumber = JSValueToNumber(context, arguments[0], exception);
     1226
     1227    if (indexNumber >= 0)
     1228        toAXElement(thisObject)->removeSelectionAtIndex(indexNumber);
     1229    return JSValueMakeUndefined(context);
     1230}
     1231
    12101232#elif PLATFORM(IOS)
    12111233
     
    12931315JSStringRef AccessibilityUIElement::rangeForPosition(int, int) { return 0; }
    12941316void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement*) const { }
    1295 unsigned AccessibilityUIElement::selectedChildrenCount() const { return 0; }
    1296 AccessibilityUIElement AccessibilityUIElement::selectedChildAtIndex(unsigned) const { return 0; }
    12971317AccessibilityUIElement AccessibilityUIElement::horizontalScrollbar() const { return 0; }
    12981318AccessibilityUIElement AccessibilityUIElement::verticalScrollbar() const { return 0; }
     
    15961616        { "lineAtOffset", lineAtOffsetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    15971617        { "sentenceAtOffset", sentenceAtOffsetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1618        { "setSelectedChildAtIndex", setSelectedChildAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1619        { "removeSelectionAtIndex", removeSelectionAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    15981620#elif PLATFORM(IOS)
    15991621        { "linkedElement", linkedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/Tools/DumpRenderTree/AccessibilityUIElement.h

    r164270 r164577  
    149149    unsigned selectedChildrenCount() const;
    150150    AccessibilityUIElement selectedChildAtIndex(unsigned) const;
     151    void setSelectedChildAtIndex(unsigned) const;
     152    void removeSelectionAtIndex(unsigned) const;
    151153   
    152154    bool isExpanded() const;
  • trunk/Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp

    r164165 r164577  
    16241624}
    16251625
     1626unsigned AccessibilityUIElement::selectedChildrenCount() const
     1627{
     1628    if (!ATK_IS_SELECTION(m_element))
     1629        return 0;
     1630
     1631    return atk_selection_get_selection_count(ATK_SELECTION(m_element));
     1632}
     1633
     1634AccessibilityUIElement AccessibilityUIElement::selectedChildAtIndex(unsigned index) const
     1635{
     1636    if (!ATK_IS_SELECTION(m_element))
     1637        return nullptr;
     1638
     1639    GRefPtr<AtkObject> child = adoptGRef(atk_selection_ref_selection(ATK_SELECTION(m_element), index));
     1640    return child ? AccessibilityUIElement(child.get()) : nullptr;
     1641}
     1642
     1643void AccessibilityUIElement::setSelectedChildAtIndex(unsigned index) const
     1644{
     1645    if (!ATK_IS_SELECTION(m_element))
     1646        return;
     1647
     1648    atk_selection_add_selection(ATK_SELECTION(m_element), index);
     1649}
     1650
     1651void AccessibilityUIElement::removeSelectionAtIndex(unsigned index) const
     1652{
     1653    if (!ATK_IS_SELECTION(m_element))
     1654        return;
     1655
     1656    atk_selection_remove_selection(ATK_SELECTION(m_element), index);
     1657}
     1658
    16261659#endif
  • trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp

    r164165 r164577  
    874874    return 0;
    875875}
     876
     877unsigned AccessibilityUIElement::selectedChildrenCount() const
     878{
     879    // FIXME: implement
     880    return 0;
     881}
     882
     883AccessibilityUIElement AccessibilityUIElement::selectedChildAtIndex(unsigned) const
     884{
     885    // FIXME: implement
     886    return 0;
     887}
  • trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp

    r164295 r164577  
    6060JSRetainPtr<JSStringRef> AccessibilityUIElement::lineAtOffset(int) { return 0; }
    6161JSRetainPtr<JSStringRef> AccessibilityUIElement::sentenceAtOffset(int) { return 0; }
     62void AccessibilityUIElement::setSelectedChildAtIndex(unsigned) const { }
     63void AccessibilityUIElement::removeSelectionAtIndex(unsigned) const { }
    6264#endif
    6365
  • trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h

    r164295 r164577  
    142142    bool isMultiSelectable() const;
    143143    void setSelectedChild(AccessibilityUIElement*) const;
     144    void setSelectedChildAtIndex(unsigned) const;
     145    void removeSelectionAtIndex(unsigned) const;
    144146    unsigned selectedChildrenCount() const;
    145147    PassRefPtr<AccessibilityUIElement> selectedChildAtIndex(unsigned) const;
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl

    r164165 r164577  
    3838    AccessibilityUIElement selectedChildAtIndex(unsigned long index);
    3939    void setSelectedChild(AccessibilityUIElement element);
     40    void setSelectedChildAtIndex(unsigned long index);
     41    void removeSelectionAtIndex(unsigned long index);
    4042    AccessibilityUIElement titleUIElement();
    4143    AccessibilityUIElement parentElement();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp

    r164165 r164577  
    702702PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::selectedChildAtIndex(unsigned index) const
    703703{
    704     // FIXME: implement
    705     return nullptr;
     704    if (!ATK_SELECTION(m_element.get()))
     705        return nullptr;
     706
     707    GRefPtr<AtkObject> child = adoptGRef(atk_selection_ref_selection(ATK_SELECTION(m_element.get()), index));
     708    return child ? AccessibilityUIElement::create(child.get()) : nullptr;
    706709}
    707710
    708711unsigned AccessibilityUIElement::selectedChildrenCount() const
    709712{
    710     // FIXME: implement
    711     return 0;
     713    if (!ATK_IS_SELECTION(m_element.get()))
     714        return 0;
     715    return atk_selection_get_selection_count(ATK_SELECTION(m_element.get()));
    712716}
    713717
     
    14641468{
    14651469    // FIXME: implement
     1470}
     1471
     1472void AccessibilityUIElement::setSelectedChildAtIndex(unsigned index) const
     1473{
     1474    if (!ATK_IS_SELECTION(m_element.get()))
     1475        return;
     1476
     1477    atk_selection_add_selection(ATK_SELECTION(m_element.get()), index);
     1478}
     1479
     1480void AccessibilityUIElement::removeSelectionAtIndex(unsigned index) const
     1481{
     1482    if (!ATK_IS_SELECTION(m_element.get()))
     1483        return;
     1484
     1485    atk_selection_remove_selection(ATK_SELECTION(m_element.get()), index);
    14661486}
    14671487
Note: See TracChangeset for help on using the changeset viewer.