Title: [154058] trunk
Revision
154058
Author
[email protected]
Date
2013-08-14 10:44:11 -0700 (Wed, 14 Aug 2013)

Log Message

AX: Headings not longer have an AXTitle if they have a link as the only child
https://bugs.webkit.org/show_bug.cgi?id=119699

Reviewed by Anders Carlsson.

Source/WebCore: 

Normally, focusable content is not incuded when looking at the visible text of an element.
One case where we need an exception is with headings, where there is usually link content inside the heading
that we want to be used as the visible text.

Test: accessibility/heading-title-includes-links.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::visibleText):
(WebCore::shouldUseAccessiblityObjectInnerText):
(WebCore::AccessibilityNodeObject::title):
* accessibility/AccessibilityNodeObject.h:
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityTextUnderElementMode::AccessibilityTextUnderElementMode):
(WebCore::AccessibilityObject::textUnderElement):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::textUnderElement):
* accessibility/AccessibilityRenderObject.h:

LayoutTests: 

* accessibility/heading-title-includes-links.html: Added.
* platform/mac/accessibility/heading-title-includes-links-expected.txt: Added.
* platform/mac/accessibility/internal-link-anchors2-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (154057 => 154058)


--- trunk/LayoutTests/ChangeLog	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/LayoutTests/ChangeLog	2013-08-14 17:44:11 UTC (rev 154058)
@@ -1,3 +1,14 @@
+2013-08-13  Chris Fleizach  <[email protected]>
+
+        AX: Headings not longer have an AXTitle if they have a link as the only child
+        https://bugs.webkit.org/show_bug.cgi?id=119699
+
+        Reviewed by Anders Carlsson.
+
+        * accessibility/heading-title-includes-links.html: Added.
+        * platform/mac/accessibility/heading-title-includes-links-expected.txt: Added.
+        * platform/mac/accessibility/internal-link-anchors2-expected.txt:
+
 2013-08-14  Christophe Dumez  <[email protected]>
 
         Move id attribute to parent Element interface

Added: trunk/LayoutTests/accessibility/heading-title-includes-links.html (0 => 154058)


--- trunk/LayoutTests/accessibility/heading-title-includes-links.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/heading-title-includes-links.html	2013-08-14 17:44:11 UTC (rev 154058)
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body" _onload_="setTimeout('runTest()', 0);">
+
+<h1 id="heading">
+    <a href=""
+    Apple
+    </a>
+</h1>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+if (window.testRunner && window.accessibilityController) {
+    window.testRunner.waitUntilDone();
+}
+
+function runTest() {
+    description("This tests that the title of a heading will include links if available.");
+
+    if (window.accessibilityController) {
+
+        debug("Heading title: " + accessibilityController.accessibleElementById("heading").title);
+    }
+    window.testRunner.notifyDone();
+}
+
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac/accessibility/heading-title-includes-links-expected.txt (0 => 154058)


--- trunk/LayoutTests/platform/mac/accessibility/heading-title-includes-links-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/heading-title-includes-links-expected.txt	2013-08-14 17:44:11 UTC (rev 154058)
@@ -0,0 +1,12 @@
+Apple
+
+This tests that the title of a heading will include links if available.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Heading title: AXTitle: Apple
+

Modified: trunk/LayoutTests/platform/mac/accessibility/internal-link-anchors2-expected.txt (154057 => 154058)


--- trunk/LayoutTests/platform/mac/accessibility/internal-link-anchors2-expected.txt	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/LayoutTests/platform/mac/accessibility/internal-link-anchors2-expected.txt	2013-08-14 17:44:11 UTC (rev 154058)
@@ -5,22 +5,22 @@
 AXRoleDescription: heading
 AXChildren: <array of size 4>
 AXHelp: 
-AXParent: <AXHeading: '[ ] Tourette syndrome'>
+AXParent: <AXHeading: '[ edit ] Tourette syndrome'>
 AXSize: NSSize: {769, 22}
-AXTitle: [ ] Tourette syndrome
+AXTitle: [ edit ] Tourette syndrome
 AXDescription: 
 AXValue: 3
 AXFocused: 0
 AXEnabled: 1
-AXWindow: <AXHeading: '[ ] Tourette syndrome'>
+AXWindow: <AXHeading: '[ edit ] Tourette syndrome'>
 AXSelectedTextMarkerRange: (null)
-AXStartTextMarker: <AXHeading: '[ ] Tourette syndrome'>
-AXEndTextMarker: <AXHeading: '[ ] Tourette syndrome'>
+AXStartTextMarker: <AXHeading: '[ edit ] Tourette syndrome'>
+AXEndTextMarker: <AXHeading: '[ edit ] Tourette syndrome'>
 AXVisited: 0
 AXLinkedUIElements: (null)
 AXSelected: 0
 AXBlockQuoteLevel: 0
-AXTopLevelUIElement: <AXHeading: '[ ] Tourette syndrome'>
+AXTopLevelUIElement: <AXHeading: '[ edit ] Tourette syndrome'>
 AXARIABusy: 0
 
 ------------

Modified: trunk/Source/WebCore/ChangeLog (154057 => 154058)


--- trunk/Source/WebCore/ChangeLog	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/Source/WebCore/ChangeLog	2013-08-14 17:44:11 UTC (rev 154058)
@@ -1,3 +1,28 @@
+2013-08-13  Chris Fleizach  <[email protected]>
+
+        AX: Headings not longer have an AXTitle if they have a link as the only child
+        https://bugs.webkit.org/show_bug.cgi?id=119699
+
+        Reviewed by Anders Carlsson.
+
+        Normally, focusable content is not incuded when looking at the visible text of an element.
+        One case where we need an exception is with headings, where there is usually link content inside the heading
+        that we want to be used as the visible text.
+
+        Test: accessibility/heading-title-includes-links.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::visibleText):
+        (WebCore::shouldUseAccessiblityObjectInnerText):
+        (WebCore::AccessibilityNodeObject::title):
+        * accessibility/AccessibilityNodeObject.h:
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityTextUnderElementMode::AccessibilityTextUnderElementMode):
+        (WebCore::AccessibilityObject::textUnderElement):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::textUnderElement):
+        * accessibility/AccessibilityRenderObject.h:
+
 2013-08-14  Christophe Dumez  <[email protected]>
 
         Move id attribute to parent Element interface

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (154057 => 154058)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-08-14 17:44:11 UTC (rev 154058)
@@ -1280,7 +1280,13 @@
         useTextUnderElement = true;
     
     if (useTextUnderElement) {
-        String text = textUnderElement();
+        AccessibilityTextUnderElementMode mode;
+        
+        // Headings often include links as direct children. Those links need to be included in text under element.
+        if (isHeading())
+            mode.includeFocusableContent = true;
+
+        String text = textUnderElement(mode);
         if (!text.isEmpty())
             textOrder.append(AccessibilityText(text, ChildrenText));
     }
@@ -1507,7 +1513,7 @@
 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)
+    if (mode.childrenInclusion == AccessibilityTextUnderElementMode::TextUnderElementModeIncludeAllChildren)
         return true;
 
     // Consider this hypothetical example:
@@ -1536,7 +1542,7 @@
         return true;
     
     // Skip focusable children, so we don't include the text of links and controls.
-    if (obj->canSetFocusAttribute())
+    if (obj->canSetFocusAttribute() && !mode.includeFocusableContent)
         return false;
 
     // Skip big container elements like lists, tables, etc.
@@ -1624,10 +1630,12 @@
         break;
     }
 
-    if (isHeading() || isLink())
+    if (isLink())
         return textUnderElement();
+    if (isHeading())
+        return textUnderElement(AccessibilityTextUnderElementMode(AccessibilityTextUnderElementMode::TextUnderElementModeSkipIgnoredChildren, true));
 
-    // If it's focusable but it's not content editable or a known control type, then it will appear to                  
+    // If it's focusable but it's not content editable or a known control type, then it will appear to
     // the user as a single atomic object, so we should use its text as the default title.                              
     if (isGenericFocusableElement())
         return textUnderElement();

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h (154057 => 154058)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h	2013-08-14 17:44:11 UTC (rev 154058)
@@ -120,7 +120,7 @@
     virtual AccessibilityButtonState checkboxOrRadioValue() const;
 
     virtual unsigned hierarchicalLevel() const;
-    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const;
+    virtual String textUnderElement(AccessibilityTextUnderElementMode = AccessibilityTextUnderElementMode()) const;
     virtual String accessibilityDescription() const;
     virtual String helpText() const;
     virtual String title() const;

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (154057 => 154058)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2013-08-14 17:44:11 UTC (rev 154058)
@@ -240,9 +240,19 @@
     }
 };
 
-enum AccessibilityTextUnderElementMode {
-    TextUnderElementModeSkipIgnoredChildren,
-    TextUnderElementModeIncludeAllChildren
+struct AccessibilityTextUnderElementMode {
+    enum ChildrenInclusion {
+        TextUnderElementModeSkipIgnoredChildren,
+        TextUnderElementModeIncludeAllChildren,
+    };
+    
+    ChildrenInclusion childrenInclusion;
+    bool includeFocusableContent;
+    
+    AccessibilityTextUnderElementMode(ChildrenInclusion c = TextUnderElementModeSkipIgnoredChildren, bool i = false)
+    : childrenInclusion(c)
+    , includeFocusableContent(i)
+    { }
 };
     
 enum AccessibilityOrientation {
@@ -590,7 +600,7 @@
 
     // Methods for determining accessibility text.
     virtual String stringValue() const { return String(); }
-    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const { return String(); }
+    virtual String textUnderElement(AccessibilityTextUnderElementMode = AccessibilityTextUnderElementMode()) 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 (154057 => 154058)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-08-14 17:44:11 UTC (rev 154058)
@@ -647,7 +647,7 @@
 
     // 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 (m_renderer->isText() || mode.childrenInclusion == AccessibilityTextUnderElementMode::TextUnderElementModeIncludeAllChildren) {
         // If possible, use a text iterator to get the text, so that whitespace
         // is handled consistently.
         if (Node* node = this->node()) {

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (154057 => 154058)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2013-08-14 17:44:11 UTC (rev 154058)
@@ -144,7 +144,7 @@
     virtual VisibleSelection selection() const;
     virtual String stringValue() const;
     virtual String helpText() const;
-    virtual String textUnderElement(AccessibilityTextUnderElementMode = TextUnderElementModeSkipIgnoredChildren) const;
+    virtual String textUnderElement(AccessibilityTextUnderElementMode = AccessibilityTextUnderElementMode()) const;
     virtual String text() const;
     virtual int textLength() const;
     virtual String selectedText() const;

Modified: trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp (154057 => 154058)


--- trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp	2013-08-14 17:44:11 UTC (rev 154058)
@@ -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(TextUnderElementModeIncludeAllChildren).length();
+        textLength = textUnderElement(AccessibilityTextUnderElementMode(AccessibilityTextUnderElementMode::TextUnderElementModeIncludeAllChildren)).length();
 
     return textLength;
 }

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp (154057 => 154058)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2013-08-14 17:41:57 UTC (rev 154057)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2013-08-14 17:44:11 UTC (rev 154058)
@@ -592,7 +592,7 @@
     if (endOffset == -1) {
         end = coreObject->stringValue().length();
         if (!end)
-            end = coreObject->textUnderElement(TextUnderElementModeIncludeAllChildren).length();
+            end = coreObject->textUnderElement(AccessibilityTextUnderElementMode(AccessibilityTextUnderElementMode::TextUnderElementModeIncludeAllChildren)).length();
     }
 
     String ret;
@@ -601,7 +601,7 @@
     else {
         ret = coreObject->stringValue();
         if (!ret)
-            ret = coreObject->textUnderElement(TextUnderElementModeIncludeAllChildren);
+            ret = coreObject->textUnderElement(AccessibilityTextUnderElementMode(AccessibilityTextUnderElementMode::TextUnderElementModeIncludeAllChildren));
     }
 
     if (!ret.length()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to