AX: [ATK] CSS-generated text content not exposed to assistive technologies
authorjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Oct 2014 18:44:20 +0000 (18:44 +0000)
committerjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Oct 2014 18:44:20 +0000 (18:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137669

Reviewed by Chris Fleizach.

Source/WebCore:

Do not use a text iterator to get the text for elements which include
pseudo elements.

Test: accessibility/css-content-attribute.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::textUnderElement):

LayoutTests:

Moved the Mac platform test and modified it to dump the accessible tree
and string values rather than a platform-specific hierarchy so that it
could be shared across platforms.

* accessibility/css-content-attribute.html: Added.
* platform/gtk/accessibility/css-content-attribute-expected.txt: Added.
* platform/mac/accessibility/css-content-attribute-expected.txt: Modified to reflect new output.
* platform/mac/accessibility/css-content-attribute.html: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174992 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/accessibility/css-content-attribute.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/css-content-attribute-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/css-content-attribute-expected.txt
LayoutTests/platform/mac/accessibility/css-content-attribute.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp

index db5f865..bd5a877 100644 (file)
@@ -1,3 +1,19 @@
+2014-10-21  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] CSS-generated text content not exposed to assistive technologies
+        https://bugs.webkit.org/show_bug.cgi?id=137669
+
+        Reviewed by Chris Fleizach.
+
+        Moved the Mac platform test and modified it to dump the accessible tree
+        and string values rather than a platform-specific hierarchy so that it
+        could be shared across platforms.
+
+        * accessibility/css-content-attribute.html: Added.
+        * platform/gtk/accessibility/css-content-attribute-expected.txt: Added.
+        * platform/mac/accessibility/css-content-attribute-expected.txt: Modified to reflect new output.
+        * platform/mac/accessibility/css-content-attribute.html: Removed.
+
 2014-10-21  Zalan Bujtas  <zalan@apple.com>
 
         REGRESSION: Google Search (mobile) video thumbnails are too large.
diff --git a/LayoutTests/accessibility/css-content-attribute.html b/LayoutTests/accessibility/css-content-attribute.html
new file mode 100644 (file)
index 0000000..6d448f8
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<script>
+    function dumpAccessibilityChildren(element, level) {
+        if (element.stringValue.indexOf('End of test') >= 0)
+            return false;
+
+        var indent = "";
+        for (var k = 0; k < level; k++) { indent += "  "; }
+        debug(indent + element.role + " " + element.stringValue);
+        var childrenCount = element.childrenCount;
+        for (var k = 0; k < childrenCount; k++) {
+            if (!dumpAccessibilityChildren(element.childAtIndex(k), level+1))
+                return false;
+        }
+        return true;
+    }
+</script>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+
+    <style type="text/css">
+
+        h1:before {
+            content: 'This is a';
+        }
+
+        h1:after {
+            content: 'Headline';
+        }
+
+    </style>
+
+</head>
+<body id="body">
+<h1>SAMPLE</h1>
+<div>End of test</div>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that when the content attribute in CSS is used, the correct values are returned.");
+
+    if (window.accessibilityController) {
+          document.getElementById("body").focus();
+          dumpAccessibilityChildren(accessibilityController.focusedElement, 0);
+    }
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/css-content-attribute-expected.txt b/LayoutTests/platform/gtk/accessibility/css-content-attribute-expected.txt
new file mode 100644 (file)
index 0000000..472c9f5
--- /dev/null
@@ -0,0 +1,14 @@
+SAMPLE
+
+End of test
+This tests that when the content attribute in CSS is used, the correct values are returned.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+AXRole: AXWebArea 
+  AXRole: AXHeading AXValue: This is a SAMPLE Headline
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
index 1508415..3695ed7 100644 (file)
@@ -1,16 +1,17 @@
 SAMPLE
 
+End of test
 This tests that when the content attribute in CSS is used, the correct values are returned.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS body.childAtIndex(0).childAtIndex(0).role is 'AXRole: AXStaticText'
-PASS body.childAtIndex(0).childAtIndex(1).role is 'AXRole: AXStaticText'
-PASS body.childAtIndex(0).childAtIndex(2).role is 'AXRole: AXStaticText'
-PASS body.childAtIndex(0).childAtIndex(0).stringValue is 'AXValue: This is a'
-PASS body.childAtIndex(0).childAtIndex(1).stringValue is 'AXValue: SAMPLE'
-PASS body.childAtIndex(0).childAtIndex(2).stringValue is 'AXValue: Headline'
+AXRole: AXWebArea AXValue: 
+  AXRole: AXHeading AXValue: 1
+    AXRole: AXStaticText AXValue: This is a
+    AXRole: AXStaticText AXValue: SAMPLE
+    AXRole: AXStaticText AXValue: Headline
+  AXRole: AXGroup AXValue: 
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/platform/mac/accessibility/css-content-attribute.html b/LayoutTests/platform/mac/accessibility/css-content-attribute.html
deleted file mode 100644 (file)
index 2ee4c00..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../../resources/js-test-pre.js"></script>
-
-    <style type="text/css">
-    
-        h1:before {
-            content: 'This is a';
-        }
-    
-        h1:after {
-            content: 'Headline';
-        }
-         
-    </style>
-
-</head>
-<body id="body">
-<h1>SAMPLE</h1>
-
-<p id="description"></p>
-<div id="console"></div>
-
-<script>
-
-    description("This tests that when the content attribute in CSS is used, the correct values are returned.");
-
-    if (window.accessibilityController) {
-
-          document.getElementById("body").focus();
-          var body = accessibilityController.focusedElement;
-
-          // Test that all three children in the header appear with the correct values.
-          shouldBe("body.childAtIndex(0).childAtIndex(0).role", "'AXRole: AXStaticText'");
-          shouldBe("body.childAtIndex(0).childAtIndex(1).role", "'AXRole: AXStaticText'");
-          shouldBe("body.childAtIndex(0).childAtIndex(2).role", "'AXRole: AXStaticText'");
-
-          shouldBe("body.childAtIndex(0).childAtIndex(0).stringValue", "'AXValue: This is a'");
-          shouldBe("body.childAtIndex(0).childAtIndex(1).stringValue", "'AXValue: SAMPLE'");
-          shouldBe("body.childAtIndex(0).childAtIndex(2).stringValue", "'AXValue: Headline'");
-    }
-
-</script>
-
-<script src="../../../resources/js-test-post.js"></script>
-</body>
-</html>
index c387a3a..f20ba5a 100644 (file)
@@ -1,3 +1,18 @@
+2014-10-21  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] CSS-generated text content not exposed to assistive technologies
+        https://bugs.webkit.org/show_bug.cgi?id=137669
+
+        Reviewed by Chris Fleizach.
+
+        Do not use a text iterator to get the text for elements which include
+        pseudo elements.
+
+        Test: accessibility/css-content-attribute.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::textUnderElement):
+
 2014-10-21  Chris Dumez  <cdumez@apple.com>
 
         REGRESSION(r174676): It broke the !ENABLE(VIDEO) build
index 927fb58..aac1d2d 100644 (file)
@@ -637,6 +637,10 @@ String AccessibilityRenderObject::textUnderElement(AccessibilityTextUnderElement
         return downcast<RenderText>(*m_renderer).text();
 #endif
 
+    // rangeOfContents does not include CSS-generated content.
+    if (m_renderer->isBeforeOrAfterContent())
+        return AccessibilityNodeObject::textUnderElement(mode);
+
     // 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 (is<RenderText>(*m_renderer) || mode.childrenInclusion == AccessibilityTextUnderElementMode::TextUnderElementModeIncludeAllChildren) {
@@ -645,6 +649,12 @@ String AccessibilityRenderObject::textUnderElement(AccessibilityTextUnderElement
         Document* nodeDocument = nullptr;
         RefPtr<Range> textRange;
         if (Node* node = m_renderer->node()) {
+            // rangeOfContents does not include CSS-generated content.
+            Node* firstChild = node->pseudoAwareFirstChild();
+            Node* lastChild = node->pseudoAwareLastChild();
+            if ((firstChild && firstChild->isPseudoElement()) || (lastChild && lastChild->isPseudoElement()))
+                return AccessibilityNodeObject::textUnderElement(mode);
+
             nodeDocument = &node->document();
             textRange = rangeOfContents(*node);
         } else {