Changeset 152537 in webkit


Ignore:
Timestamp:
Jul 10, 2013 9:20:24 AM (11 years ago)
Author:
mario@webkit.org
Message:

AX: Allow requesting the full plain text for an object with textUnderElement()
https://bugs.webkit.org/show_bug.cgi?id=105214

Reviewed by Chris Fleizach.

Source/WebCore:

Allow specifying different function modes for textUnderElement(),
so we can effectively ask for the "normal" result (e.g to retrieve
test to be exposed as the 'title') or for the full text under the
element (without omitting any child in the subtree). This is
needed for the implementation of atk_text_get_text() in GTK/EFL.

  • accessibility/AccessibilityObject.h: Add new enumeration to

specify the different modes for textUnderElement().
(WebCore::AccessibilityObject::textUnderElement): Added parameter.

  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::shouldUseAccessiblityObjectInnerText): Always return
'true' when using the "include all children" mode.
(WebCore::AccessibilityNodeObject::textUnderElement): Updated call
to shouldUseAccessiblityObjectInnerText().

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

(WebCore::AccessibilityRenderObject::textUnderElement): Removed
GTK specific code and expand the usage of text iterators beyond
text render objects, using it also when in the "include all
children" mode.

  • accessibility/AccessibilityRenderObject.h:
  • accessibility/atk/AccessibilityObjectAtk.cpp:

(WebCore::AccessibilityObject::getLengthForTextRange): Updated
call to textUnderElement(), preserving the previous behavior.

  • accessibility/atk/WebKitAccessibleInterfaceText.cpp:

(webkitAccessibleTextGetText): Updated call to textUnderElement(),
using the "include all children" mode.

LayoutTests:

Removed tests that are not longer expected to fail.

  • platform/gtk/TestExpectations: Removed tests.
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r152533 r152537  
     12013-07-10  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        AX: Allow requesting the full plain text for an object with textUnderElement()
     4        https://bugs.webkit.org/show_bug.cgi?id=105214
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Removed tests that are not longer expected to fail.
     9
     10        * platform/gtk/TestExpectations: Removed tests.
     11
    1122013-07-10  Simon Pena  <simon.pena@samsung.com>
    213
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r152447 r152537  
    838838webkit.org/b/98360 accessibility/aria-used-on-image-maps.html [ Failure ]
    839839webkit.org/b/98361 accessibility/button-press-action.html [ Failure ]
    840 webkit.org/b/105214 accessibility/button-title-uses-inner-img-alt.html [ Failure ]
    841840webkit.org/b/98363 accessibility/canvas-fallback-content-2.html [ Failure ]
    842 webkit.org/b/105214 accessibility/focusable-div.html [ Failure ]
    843 webkit.org/b/105214 accessibility/listitem-title.html [ Failure ]
    844841webkit.org/b/98370 accessibility/loading-iframe-sends-notification.html [ Failure ]
    845842webkit.org/b/98371 accessibility/loading-iframe-updates-axtree.html [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r152534 r152537  
     12013-07-10  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        AX: Allow requesting the full plain text for an object with textUnderElement()
     4        https://bugs.webkit.org/show_bug.cgi?id=105214
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Allow specifying different function modes for textUnderElement(),
     9        so we can effectively ask for the "normal" result (e.g to retrieve
     10        test to be exposed as the 'title') or for the full text under the
     11        element (without omitting any child in the subtree). This is
     12        needed for the implementation of atk_text_get_text() in GTK/EFL.
     13
     14        * accessibility/AccessibilityObject.h: Add new enumeration to
     15        specify the different modes for textUnderElement().
     16        (WebCore::AccessibilityObject::textUnderElement): Added parameter.
     17
     18        * accessibility/AccessibilityNodeObject.cpp:
     19        (WebCore::shouldUseAccessiblityObjectInnerText): Always return
     20        'true' when using the "include all children" mode.
     21        (WebCore::AccessibilityNodeObject::textUnderElement): Updated call
     22        to shouldUseAccessiblityObjectInnerText().
     23        * accessibility/AccessibilityNodeObject.h:
     24
     25        * accessibility/AccessibilityRenderObject.cpp:
     26        (WebCore::AccessibilityRenderObject::textUnderElement): Removed
     27        GTK specific code and expand the usage of text iterators beyond
     28        text render objects, using it also when in the "include all
     29        children" mode.
     30        * accessibility/AccessibilityRenderObject.h:
     31
     32        * accessibility/atk/AccessibilityObjectAtk.cpp:
     33        (WebCore::AccessibilityObject::getLengthForTextRange): Updated
     34        call to textUnderElement(), preserving the previous behavior.
     35
     36        * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
     37        (webkitAccessibleTextGetText): Updated call to textUnderElement(),
     38        using the "include all children" mode.
     39
    1402013-07-10  Sergio Correia  <sergio.correia@openbossa.org>
    241
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r152532 r152537  
    15051505// When building the textUnderElement for an object, determine whether or not
    15061506// we should include the inner text of this given descendant object or skip it.
    1507 static bool shouldUseAccessiblityObjectInnerText(AccessibilityObject* obj)
    1508 {
     1507static bool shouldUseAccessiblityObjectInnerText(AccessibilityObject* obj, AccessibilityTextUnderElementMode mode)
     1508{
     1509    // Do not use any heuristic if we are explicitly asking to include all the children.
     1510    if (mode == TextUnderElementModeIncludeAllChildren)
     1511        return true;
     1512
    15091513    // Consider this hypothetical example:
    15101514    // <div tabindex=0>
     
    15431547}
    15441548
    1545 String AccessibilityNodeObject::textUnderElement() const
     1549String AccessibilityNodeObject::textUnderElement(AccessibilityTextUnderElementMode mode) const
    15461550{
    15471551    Node* node = this->node();
     
    15511555    StringBuilder builder;
    15521556    for (AccessibilityObject* child = firstChild(); child; child = child->nextSibling()) {
    1553         if (!shouldUseAccessiblityObjectInnerText(child))
     1557        if (!shouldUseAccessiblityObjectInnerText(child, mode))
    15541558            continue;
    15551559
     
    15651569        }
    15661570
    1567         String childText = child->textUnderElement();
     1571        String childText = child->textUnderElement(mode);
    15681572        if (childText.length()) {
    15691573            if (builder.length())
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h

    r151841 r152537  
    121121
    122122    virtual unsigned hierarchicalLevel() const;
    123     virtual String textUnderElement() const;
     123    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const;
    124124    virtual String accessibilityDescription() const;
    125125    virtual String helpText() const;
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r151776 r152537  
    240240    }
    241241};
     242
     243enum AccessibilityTextUnderElementMode {
     244    TextUnderElementModeSkipIgnoredChildren,
     245    TextUnderElementModeIncludeAllChildren
     246};
    242247   
    243248enum AccessibilityOrientation {
     
    586591    // Methods for determining accessibility text.
    587592    virtual String stringValue() const { return String(); }
    588     virtual String textUnderElement() const { return String(); }
     593    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const { return String(); }
    589594    virtual String text() const { return String(); }
    590595    virtual int textLength() const { return 0; }
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r152522 r152537  
    627627}
    628628
    629 String AccessibilityRenderObject::textUnderElement() const
     629String AccessibilityRenderObject::textUnderElement(AccessibilityTextUnderElementMode mode) const
    630630{
    631631    if (!m_renderer)
     
    646646#endif
    647647
    648 #if PLATFORM(GTK)
    649     // On GTK, always use a text iterator in order to get embedded object characters.
    650     // TODO: Add support for embedded object characters to the other codepaths that try
    651     // to build the accessible text recursively, so this special case isn't needed.
    652     // https://bugs.webkit.org/show_bug.cgi?id=105214
    653     if (Node* node = this->node()) {
    654         if (Frame* frame = node->document()->frame()) {
    655             // catch stale WebCoreAXObject (see <rdar://problem/3960196>)
    656             if (frame->document() != node->document())
    657                 return String();
    658 
    659             return plainText(rangeOfContents(node).get(), textIteratorBehaviorForTextRange());
    660         }
    661     }
    662 #endif
    663 
    664     if (m_renderer->isText()) {
     648    // We use a text iterator for text objects AND for those cases where we are
     649    // explicitly asking for the full text under a given element.
     650    if (m_renderer->isText() || mode == TextUnderElementModeIncludeAllChildren) {
    665651        // If possible, use a text iterator to get the text, so that whitespace
    666652        // is handled consistently.
     
    684670    }
    685671   
    686     return AccessibilityNodeObject::textUnderElement();
     672    return AccessibilityNodeObject::textUnderElement(mode);
    687673}
    688674
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h

    r151123 r152537  
    145145    virtual String stringValue() const;
    146146    virtual String helpText() const;
    147     virtual String textUnderElement() const;
     147    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const;
    148148    virtual String text() const;
    149149    virtual int textLength() const;
  • trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp

    r140166 r152537  
    165165    // accessibility object if the value is still zero.
    166166    if (!textLength && allowsTextRanges())
    167         textLength = textUnderElement().length();
     167        textLength = textUnderElement(TextUnderElementModeIncludeAllChildren).length();
    168168
    169169    return textLength;
  • trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp

    r152396 r152537  
    536536        end = coreObject->stringValue().length();
    537537        if (!end)
    538             end = coreObject->textUnderElement().length();
     538            end = coreObject->textUnderElement(TextUnderElementModeIncludeAllChildren).length();
    539539    }
    540540
     
    545545        ret = coreObject->stringValue();
    546546        if (!ret)
    547             ret = coreObject->textUnderElement();
     547            ret = coreObject->textUnderElement(TextUnderElementModeIncludeAllChildren);
    548548    }
    549549
Note: See TracChangeset for help on using the changeset viewer.