Changeset 200369 in webkit


Ignore:
Timestamp:
May 3, 2016 8:23:23 AM (8 years ago)
Author:
jdiggs@igalia.com
Message:

[ATK] accessibility/content-editable-as-textarea.html fails
https://bugs.webkit.org/show_bug.cgi?id=155353

Reviewed by Darin Adler.

Source/WebCore:

The test was timing out because it expected an AXValueChanged notification.
In ATK, AXValueChanged notifications are made for widgets which implement
the AtkValue interface (sliders, progress bars, etc.). We should be listening
for AXTextChanged instead.

In addition, for contenteditable elements, we should emit the notification on
the element itself. Because we were handling the notification in the same way
as native text controls (where the notification we receive from WebCore is for
StaticTextRole children), we were attempting to emit the notification from
the parent of the contenteditable.

Lastly, ATK's AccessibilityUIElement support had a number of unimplemented
methods that are being used as part of the previously-failing test. Those
methods are now implemented so that the ATK results are much more similar
to those on the Mac.

No new tests needed. The previously-failing test now passes.

  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::AccessibilityNodeObject::childrenChanged):

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::isNonNativeTextControl):

  • accessibility/AccessibilityObject.h:
  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::textChanged):

  • accessibility/atk/AXObjectCacheAtk.cpp:

(WebCore::AXObjectCache::nodeTextChangePlatformNotification):

Tools:

The test was timing out because it expected an AXValueChanged notification.
In ATK, AXValueChanged notifications are made for widgets which implement
the AtkValue interface (sliders, progress bars, etc.). We should be listening
for AXTextChanged instead. AtkText's text-insert and text-remove have been
added to the AccessibilityNotificationHandler.

Also, ATK's AccessibilityUIElement support had a number of unimplemented
methods that are being used as part of the previously-failing test. Those
methods are now implemented so that the ATK results are much more similar
to those on the Mac.

  • WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp:

(WTR::AccessibilityNotificationHandler::connectAccessibilityCallbacks):

  • WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:

(WTR::AccessibilityUIElement::stringAttributeValue):
(WTR::AccessibilityUIElement::rangeForLine):
(WTR::AccessibilityUIElement::boundsForRange):
(WTR::AccessibilityUIElement::attributedStringForRange):

LayoutTests:

Updated the test identified in the bug to listen for the appropriate
notification for ATK and created platform-specific expectations.

In addition, set-selected-text-range-contenteditable.html was timing out
due to the use of shouldBecomeEqual() with an assertion that is wrong for
ATK. Modifying the test so that it verifies the result appropriate for
each platform eliminates the timeout.

  • accessibility/content-editable-as-textarea.html: Updated.
  • accessibility/set-selected-text-range-contenteditable.html: Updated.
  • platform/gtk/TestExpectations: Unskipped the failing tests.
  • platform/gtk/accessibility/content-editable-as-textarea-expected.txt: Added.
  • platform/gtk/accessibility/set-selected-text-range-contenteditable-expected.txt: Added.
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r200367 r200369  
     12016-05-03  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        [ATK] accessibility/content-editable-as-textarea.html fails
     4        https://bugs.webkit.org/show_bug.cgi?id=155353
     5
     6        Reviewed by Darin Adler.
     7
     8        Updated the test identified in the bug to listen for the appropriate
     9        notification for ATK and created platform-specific expectations.
     10
     11        In addition, set-selected-text-range-contenteditable.html was timing out
     12        due to the use of shouldBecomeEqual() with an assertion that is wrong for
     13        ATK. Modifying the test so that it verifies the result appropriate for
     14        each platform eliminates the timeout.
     15
     16        * accessibility/content-editable-as-textarea.html: Updated.
     17        * accessibility/set-selected-text-range-contenteditable.html: Updated.
     18        * platform/gtk/TestExpectations: Unskipped the failing tests.
     19        * platform/gtk/accessibility/content-editable-as-textarea-expected.txt: Added.
     20        * platform/gtk/accessibility/set-selected-text-range-contenteditable-expected.txt: Added.
     21
    1222016-05-03  Joseph Pecoraro  <pecoraro@apple.com>
    223
  • trunk/LayoutTests/accessibility/content-editable-as-textarea.html

    r168042 r200369  
    2020    var notification = 0;
    2121    var textArea = 0;
     22    var notificationType = "AXValueChanged";
    2223    function callback(notification) {
    23         if (notification == "AXValueChanged") {
     24        if (notification == notificationType) {
    2425            textArea.removeNotificationListener();
    2526            debug("Updated value: " + textArea.stringValue);
     
    3132    if (window.accessibilityController) {
    3233        window.jsTestIsAsync = true;
     34
     35        // In ATK, value-changed notifications are made for widgets which implement
     36        // the AtkValue interface (sliders, progress bars, etc.).
     37        if (accessibilityController.platformName == "atk")
     38            notificationType = "AXTextChanged";
    3339
    3440        textArea = accessibilityController.accessibleElementById("content");
  • trunk/LayoutTests/accessibility/set-selected-text-range-contenteditable.html

    r198768 r200369  
    4545                        debug("\nSet range: {-1, 0}");
    4646                        content.setSelectedTextRange(-1, 0);
    47                         shouldBecomeEqual("content.selectedTextRange", "'{0, 0}'", function() {
     47
     48                        // In ATK, -1 is used as an alias for the final offset.
     49                        expectations = accessibilityController.platformName == "atk" ? "'{16, 0}'" : "'{0, 0}'";
     50
     51                        shouldBecomeEqual("content.selectedTextRange", expectations, function() {
    4852                            debug("\nSet range: {7, 3}");
    4953                            content.setSelectedTextRange(7, 3);
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r200366 r200369  
    8888webkit.org/b/98348 accessibility/radio-button-group-members.html [ Skip ]
    8989webkit.org/b/141074 accessibility/auto-filled-value.html [ Skip ]
    90 webkit.org/b/133148 accessibility/content-editable-as-textarea.html [ Skip ]
    91 webkit.org/b/133148 accessibility/set-selected-text-range-contenteditable.html [ Skip ]
    9290webkit.org/b/156045 accessibility/attachment-element.html [ Skip ]
    9391
  • trunk/Source/WebCore/ChangeLog

    r200368 r200369  
     12016-05-03  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        [ATK] accessibility/content-editable-as-textarea.html fails
     4        https://bugs.webkit.org/show_bug.cgi?id=155353
     5
     6        Reviewed by Darin Adler.
     7
     8        The test was timing out because it expected an AXValueChanged notification.
     9        In ATK, AXValueChanged notifications are made for widgets which implement
     10        the AtkValue interface (sliders, progress bars, etc.). We should be listening
     11        for AXTextChanged instead.
     12
     13        In addition, for contenteditable elements, we should emit the notification on
     14        the element itself. Because we were handling the notification in the same way
     15        as native text controls (where the notification we receive from WebCore is for
     16        StaticTextRole children), we were attempting to emit the notification from
     17        the parent of the contenteditable.
     18
     19        Lastly, ATK's AccessibilityUIElement support had a number of unimplemented
     20        methods that are being used as part of the previously-failing test. Those
     21        methods are now implemented so that the ATK results are much more similar
     22        to those on the Mac.
     23
     24        No new tests needed. The previously-failing test now passes.
     25
     26        * accessibility/AccessibilityNodeObject.cpp:
     27        (WebCore::AccessibilityNodeObject::childrenChanged):
     28        * accessibility/AccessibilityObject.cpp:
     29        (WebCore::AccessibilityObject::isNonNativeTextControl):
     30        * accessibility/AccessibilityObject.h:
     31        * accessibility/AccessibilityRenderObject.cpp:
     32        (WebCore::AccessibilityRenderObject::textChanged):
     33        * accessibility/atk/AXObjectCacheAtk.cpp:
     34        (WebCore::AXObjectCache::nodeTextChangePlatformNotification):
     35
    1362016-05-02  Sergio Villar Senin  <svillar@igalia.com>
    237
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r200318 r200369  
    160160       
    161161        // If this element is an ARIA text control, notify the AT of changes.
    162         if ((parent->isARIATextControl() || parent->hasContentEditableAttributeSet()) && !parent->isNativeTextControl())
     162        if (parent->isNonNativeTextControl())
    163163            cache->postNotification(parent, parent->document(), AXObjectCache::AXValueChanged);
    164164    }
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r200222 r200369  
    391391{
    392392    return ariaRoleAttribute() == TextAreaRole || ariaRoleAttribute() == TextFieldRole || ariaRoleAttribute() == SearchFieldRole;
     393}
     394
     395bool AccessibilityObject::isNonNativeTextControl() const
     396{
     397    return (isARIATextControl() || hasContentEditableAttributeSet()) && !isNativeTextControl();
    393398}
    394399
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r200222 r200369  
    535535    bool isTextControl() const;
    536536    bool isARIATextControl() const;
     537    bool isNonNativeTextControl() const;
    537538    bool isTabList() const { return roleValue() == TabListRole; }
    538539    bool isTabItem() const { return roleValue() == TabRole; }
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r200290 r200369  
    29222922            cache->postNotification(renderParent, AXObjectCache::AXLiveRegionChanged);
    29232923
    2924         if ((parent->isARIATextControl() || parent->hasContentEditableAttributeSet()) && !parent->isNativeTextControl())
     2924        if (parent->isNonNativeTextControl())
    29252925            cache->postNotification(renderParent, AXObjectCache::AXValueChanged);
    29262926    }
  • trunk/Source/WebCore/accessibility/atk/AXObjectCacheAtk.cpp

    r186279 r200369  
    250250        return;
    251251
    252     AccessibilityObject* parentObject = object->parentObjectUnignored();
     252    AccessibilityObject* parentObject = object->isNonNativeTextControl() ? object : object->parentObjectUnignored();
    253253    if (!parentObject)
    254254        return;
  • trunk/Tools/ChangeLog

    r200346 r200369  
     12016-05-03  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        [ATK] accessibility/content-editable-as-textarea.html fails
     4        https://bugs.webkit.org/show_bug.cgi?id=155353
     5
     6        Reviewed by Darin Adler.
     7
     8        The test was timing out because it expected an AXValueChanged notification.
     9        In ATK, AXValueChanged notifications are made for widgets which implement
     10        the AtkValue interface (sliders, progress bars, etc.). We should be listening
     11        for AXTextChanged instead. AtkText's text-insert and text-remove have been
     12        added to the AccessibilityNotificationHandler.
     13
     14        Also, ATK's AccessibilityUIElement support had a number of unimplemented
     15        methods that are being used as part of the previously-failing test. Those
     16        methods are now implemented so that the ATK results are much more similar
     17        to those on the Mac.
     18
     19        * WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp:
     20        (WTR::AccessibilityNotificationHandler::connectAccessibilityCallbacks):
     21        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
     22        (WTR::AccessibilityUIElement::stringAttributeValue):
     23        (WTR::AccessibilityUIElement::rangeForLine):
     24        (WTR::AccessibilityUIElement::boundsForRange):
     25        (WTR::AccessibilityUIElement::attributedStringForRange):
     26
    1272016-05-02  Brady Eidson  <beidson@apple.com>
    228
  • trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp

    r185502 r200369  
    9292        JSRetainPtr<JSStringRef> jsSignalValue(Adopt, JSStringCreateWithUTF8CString(signalValue.get()));
    9393        extraArgs.append(JSValueMakeString(jsContext, jsSignalValue.get()));
    94     }
     94    } else if (!g_strcmp0(signalQuery.signal_name, "text-insert") || !g_strcmp0(signalQuery.signal_name, "text-remove"))
     95        notificationName = "AXTextChanged";
    9596
    9697    if (!jsContext)
     
    219220        "ATK:AtkSelection:selection-changed",
    220221        "ATK:AtkText:text-caret-moved",
     222        "ATK:AtkText:text-insert",
     223        "ATK:AtkText:text-remove",
    221224        0
    222225    };
  • trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp

    r200245 r200369  
    187187}
    188188
    189 String getAtkAttributeSetAsString(AtkObject* accessible, AtkAttributeType type)
    190 {
    191     AtkAttributeSet* attributeSet = getAttributeSet(accessible, type);
     189String attributeSetToString(AtkAttributeSet* attributeSet, String separator=", ")
     190{
    192191    if (!attributeSet)
    193192        return String();
     
    199198        builder.append(attributeData.get());
    200199        if (attributes->next)
    201             builder.append(", ");
     200            builder.append(separator);
    202201    }
    203202    atk_attribute_set_free(attributeSet);
    204203
    205204    return builder.toString();
     205}
     206
     207String getAtkAttributeSetAsString(AtkObject* accessible, AtkAttributeType type,  String separator=", ")
     208{
     209    return attributeSetToString(getAttributeSet(accessible, type), separator);
    206210}
    207211
     
    503507}
    504508
     509String selectedText(AtkObject* accessible)
     510{
     511    if (!ATK_IS_TEXT(accessible))
     512        return String();
     513
     514    AtkText* text = ATK_TEXT(accessible);
     515
     516    gint start, end;
     517    g_free(atk_text_get_selection(text, 0, &start, &end));
     518
     519    return atk_text_get_text(text, start, end);
     520}
     521
    505522String attributesOfElement(AccessibilityUIElement* element)
    506523{
     
    915932    String atkAttributeName = coreAttributeToAtkAttribute(attribute);
    916933
    917     // Try object attributes first.
     934    // The value of AXSelectedText is not exposed through any AtkAttribute.
     935    if (atkAttributeName == "AXSelectedText") {
     936        String string = selectedText(m_element.get());
     937        return JSStringCreateWithUTF8CString(string.utf8().data());
     938    }
     939
     940    // Try object attributes before text attributes.
    918941    String attributeValue = getAttributeSetValueForId(ATK_OBJECT(m_element.get()), ObjectAttributeType, atkAttributeName);
    919942
     
    14531476JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForLine(int line)
    14541477{
     1478    if (!ATK_IS_TEXT(m_element.get()))
     1479        return JSStringCreateWithCharacters(0, 0);
     1480
     1481    AtkText* text = ATK_TEXT(m_element.get());
     1482    gint startOffset = 0, endOffset = 0;
     1483    for (int i = 0; i <= line; ++i)
     1484        atk_text_get_string_at_offset(text, endOffset, ATK_TEXT_GRANULARITY_LINE, &startOffset, &endOffset);
     1485
     1486    GUniquePtr<gchar> range(g_strdup_printf("{%d, %d}", startOffset, endOffset - startOffset));
     1487    return JSStringCreateWithUTF8CString(range.get());
     1488}
     1489
     1490JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForPosition(int x, int y)
     1491{
    14551492    // FIXME: implement
    14561493    return JSStringCreateWithCharacters(0, 0);
    14571494}
    14581495
    1459 JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForPosition(int x, int y)
    1460 {
    1461     // FIXME: implement
    1462     return JSStringCreateWithCharacters(0, 0);
    1463 }
    1464 
    14651496JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
    14661497{
    1467     // FIXME: implement
    1468     return JSStringCreateWithCharacters(0, 0);
     1498    if (!ATK_IS_TEXT(m_element.get()))
     1499        return JSStringCreateWithCharacters(0, 0);
     1500
     1501    AtkTextRectangle rect;
     1502    atk_text_get_range_extents(ATK_TEXT(m_element.get()), location, location + length, ATK_XY_WINDOW, &rect);
     1503
     1504    GUniquePtr<gchar> bounds(g_strdup_printf("{%d, %d, %d, %d}", rect.x, rect.y, rect.width, rect.height));
     1505    return JSStringCreateWithUTF8CString(bounds.get());
    14691506}
    14701507
     
    14801517JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
    14811518{
    1482     // FIXME: implement
    1483     return JSStringCreateWithCharacters(0, 0);
     1519    if (!ATK_IS_TEXT(m_element.get()))
     1520        return JSStringCreateWithCharacters(0, 0);
     1521
     1522    StringBuilder builder;
     1523
     1524    // The default text attributes apply to the entire element.
     1525    builder.append("\n\tDefault text attributes:\n\t\t");
     1526    builder.append(attributeSetToString(getAttributeSet(m_element.get(), TextAttributeType), "\n\t\t"));
     1527
     1528    // The attribute run provides attributes specific to the range of text at the specified offset.
     1529    AtkAttributeSet* attributeSet;
     1530    AtkText* text = ATK_TEXT(m_element.get());
     1531    gint start = 0, end = 0;
     1532    for (int i = location; i < location + length; i = end) {
     1533        AtkAttributeSet* attributeSet = atk_text_get_run_attributes(text, i, &start, &end);
     1534        GUniquePtr<gchar> substring(replaceCharactersForResults(atk_text_get_text(text, start, end)));
     1535        builder.append(String::format("\n\tRange attributes for '%s':\n\t\t", substring.get()));
     1536        builder.append(attributeSetToString(attributeSet, "\n\t\t"));
     1537    }
     1538
     1539    atk_attribute_set_free(attributeSet);
     1540
     1541    return JSStringCreateWithUTF8CString(builder.toString().utf8().data());
    14841542}
    14851543
Note: See TracChangeset for help on using the changeset viewer.