Title: [152537] trunk
Revision
152537
Author
[email protected]
Date
2013-07-10 09:20:24 -0700 (Wed, 10 Jul 2013)

Log 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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152536 => 152537)


--- trunk/LayoutTests/ChangeLog	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/LayoutTests/ChangeLog	2013-07-10 16:20:24 UTC (rev 152537)
@@ -1,3 +1,14 @@
+2013-07-10  Mario Sanchez Prada  <[email protected]>
+
+        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.
+
+        Removed tests that are not longer expected to fail.
+
+        * platform/gtk/TestExpectations: Removed tests.
+
 2013-07-10  Simon Pena  <[email protected]>
 
         [GTK] Unreviewed gardening. Update new baselines after r152494 and r152478

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (152536 => 152537)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2013-07-10 16:20:24 UTC (rev 152537)
@@ -837,10 +837,7 @@
 webkit.org/b/98359 accessibility/aria-text-role.html [ Failure ]
 webkit.org/b/98360 accessibility/aria-used-on-image-maps.html [ Failure ]
 webkit.org/b/98361 accessibility/button-press-action.html [ Failure ]
-webkit.org/b/105214 accessibility/button-title-uses-inner-img-alt.html [ Failure ]
 webkit.org/b/98363 accessibility/canvas-fallback-content-2.html [ Failure ]
-webkit.org/b/105214 accessibility/focusable-div.html [ Failure ]
-webkit.org/b/105214 accessibility/listitem-title.html [ Failure ]
 webkit.org/b/98370 accessibility/loading-iframe-sends-notification.html [ Failure ]
 webkit.org/b/98371 accessibility/loading-iframe-updates-axtree.html [ Failure ]
 webkit.org/b/98372 accessibility/onclick-handlers.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (152536 => 152537)


--- trunk/Source/WebCore/ChangeLog	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/Source/WebCore/ChangeLog	2013-07-10 16:20:24 UTC (rev 152537)
@@ -1,3 +1,42 @@
+2013-07-10  Mario Sanchez Prada  <[email protected]>
+
+        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.
+
+        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.
+
 2013-07-10  Sergio Correia  <[email protected]>
 
         Remove the meshType from CoordinatedCustomFilterOperation

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (152536 => 152537)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-07-10 16:20:24 UTC (rev 152537)
@@ -1504,8 +1504,12 @@
 
 // When building the textUnderElement for an object, determine whether or not
 // we should include the inner text of this given descendant object or skip it.
-static bool shouldUseAccessiblityObjectInnerText(AccessibilityObject* obj)
+static bool shouldUseAccessiblityObjectInnerText(AccessibilityObject* obj, AccessibilityTextUnderElementMode mode)
 {
+    // Do not use any heuristic if we are explicitly asking to include all the children.
+    if (mode == TextUnderElementModeIncludeAllChildren)
+        return true;
+
     // Consider this hypothetical example:
     // <div tabindex=0>
     //   <h2>
@@ -1542,7 +1546,7 @@
     return true;
 }
 
-String AccessibilityNodeObject::textUnderElement() const
+String AccessibilityNodeObject::textUnderElement(AccessibilityTextUnderElementMode mode) const
 {
     Node* node = this->node();
     if (node && node->isTextNode())
@@ -1550,7 +1554,7 @@
 
     StringBuilder builder;
     for (AccessibilityObject* child = firstChild(); child; child = child->nextSibling()) {
-        if (!shouldUseAccessiblityObjectInnerText(child))
+        if (!shouldUseAccessiblityObjectInnerText(child, mode))
             continue;
 
         if (child->isAccessibilityNodeObject()) {
@@ -1564,7 +1568,7 @@
             }
         }
 
-        String childText = child->textUnderElement();
+        String childText = child->textUnderElement(mode);
         if (childText.length()) {
             if (builder.length())
                 builder.append(' ');

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h (152536 => 152537)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h	2013-07-10 16:20:24 UTC (rev 152537)
@@ -120,7 +120,7 @@
     virtual AccessibilityButtonState checkboxOrRadioValue() const;
 
     virtual unsigned hierarchicalLevel() const;
-    virtual String textUnderElement() const;
+    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const;
     virtual String accessibilityDescription() const;
     virtual String helpText() const;
     virtual String title() const;

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (152536 => 152537)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2013-07-10 16:20:24 UTC (rev 152537)
@@ -239,6 +239,11 @@
         textElements.append(element);
     }
 };
+
+enum AccessibilityTextUnderElementMode {
+    TextUnderElementModeSkipIgnoredChildren,
+    TextUnderElementModeIncludeAllChildren
+};
     
 enum AccessibilityOrientation {
     AccessibilityOrientationVertical,
@@ -585,7 +590,7 @@
 
     // Methods for determining accessibility text.
     virtual String stringValue() const { return String(); }
-    virtual String textUnderElement() const { return String(); }
+    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const { return String(); }
     virtual String text() const { return String(); }
     virtual int textLength() const { return 0; }
     virtual String ariaLabeledByAttribute() const { return String(); }

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (152536 => 152537)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-07-10 16:20:24 UTC (rev 152537)
@@ -626,7 +626,7 @@
     return String();
 }
 
-String AccessibilityRenderObject::textUnderElement() const
+String AccessibilityRenderObject::textUnderElement(AccessibilityTextUnderElementMode mode) const
 {
     if (!m_renderer)
         return String();
@@ -645,23 +645,9 @@
     }
 #endif
 
-#if PLATFORM(GTK)
-    // On GTK, always use a text iterator in order to get embedded object characters.
-    // TODO: Add support for embedded object characters to the other codepaths that try
-    // to build the accessible text recursively, so this special case isn't needed.
-    // https://bugs.webkit.org/show_bug.cgi?id=105214
-    if (Node* node = this->node()) {
-        if (Frame* frame = node->document()->frame()) {
-            // catch stale WebCoreAXObject (see <rdar://problem/3960196>)
-            if (frame->document() != node->document())
-                return String();
-
-            return plainText(rangeOfContents(node).get(), textIteratorBehaviorForTextRange());
-        }
-    }
-#endif
-
-    if (m_renderer->isText()) {
+    // We use a text iterator for text objects AND for those cases where we are
+    // explicitly asking for the full text under a given element.
+    if (m_renderer->isText() || mode == TextUnderElementModeIncludeAllChildren) {
         // If possible, use a text iterator to get the text, so that whitespace
         // is handled consistently.
         if (Node* node = this->node()) {
@@ -683,7 +669,7 @@
             return String(renderTextObject->text());
     }
     
-    return AccessibilityNodeObject::textUnderElement();
+    return AccessibilityNodeObject::textUnderElement(mode);
 }
 
 Node* AccessibilityRenderObject::node() const

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (152536 => 152537)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2013-07-10 16:20:24 UTC (rev 152537)
@@ -144,7 +144,7 @@
     virtual VisibleSelection selection() const;
     virtual String stringValue() const;
     virtual String helpText() const;
-    virtual String textUnderElement() const;
+    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const;
     virtual String text() const;
     virtual int textLength() const;
     virtual String selectedText() const;

Modified: trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp (152536 => 152537)


--- trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp	2013-07-10 16:20:24 UTC (rev 152537)
@@ -164,7 +164,7 @@
     // Get the text length from the elements under the
     // accessibility object if the value is still zero.
     if (!textLength && allowsTextRanges())
-        textLength = textUnderElement().length();
+        textLength = textUnderElement(TextUnderElementModeIncludeAllChildren).length();
 
     return textLength;
 }

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp (152536 => 152537)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2013-07-10 15:52:47 UTC (rev 152536)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2013-07-10 16:20:24 UTC (rev 152537)
@@ -535,7 +535,7 @@
     if (endOffset == -1) {
         end = coreObject->stringValue().length();
         if (!end)
-            end = coreObject->textUnderElement().length();
+            end = coreObject->textUnderElement(TextUnderElementModeIncludeAllChildren).length();
     }
 
     String ret;
@@ -544,7 +544,7 @@
     else {
         ret = coreObject->stringValue();
         if (!ret)
-            ret = coreObject->textUnderElement();
+            ret = coreObject->textUnderElement(TextUnderElementModeIncludeAllChildren);
     }
 
     if (!ret.length()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to