AX: AccessibilityRenderObject is adding duplicated children when CSS first-letter...
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jul 2016 19:15:05 +0000 (19:15 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jul 2016 19:15:05 +0000 (19:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160155

Reviewed by Chris Fleizach.

Source/WebCore:

We were adding the same text node twice if CSS first-letter selector was being used. Added a
check for the inline continuation so that we only add it once.

Test: accessibility/mac/css-first-letter-children.html

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

LayoutTests:

* accessibility/mac/css-first-letter-children-expected.txt: Added.
* accessibility/mac/css-first-letter-children.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/mac/css-first-letter-children-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/css-first-letter-children.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp

index d86c18e..88b2bdb 100644 (file)
@@ -1,3 +1,13 @@
+2016-07-25  Nan Wang  <n_wang@apple.com>
+
+        AX: AccessibilityRenderObject is adding duplicated children when CSS first-letter is being used.
+        https://bugs.webkit.org/show_bug.cgi?id=160155
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/css-first-letter-children-expected.txt: Added.
+        * accessibility/mac/css-first-letter-children.html: Added.
+
 2016-07-24  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         The web process hangs when computing elements-based snap points for a container with large max scroll offset
diff --git a/LayoutTests/accessibility/mac/css-first-letter-children-expected.txt b/LayoutTests/accessibility/mac/css-first-letter-children-expected.txt
new file mode 100644 (file)
index 0000000..64209b9
--- /dev/null
@@ -0,0 +1,14 @@
+Test text
+
+This tests that we are adding children correctly when having CSS first-letter selector.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+AXRole: AXGroup AXValue: 
+  AXRole: AXStaticText AXValue: Test text
+PASS content.childrenCount is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/mac/css-first-letter-children.html b/LayoutTests/accessibility/mac/css-first-letter-children.html
new file mode 100644 (file)
index 0000000..cb90d01
--- /dev/null
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<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>
+
+<style>
+p::first-letter {
+    font-size: 200%;
+}
+</style>
+</head>
+
+<body id="body">
+
+<div>
+<p id="text">Test text</p>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    if (window.accessibilityController) {
+        description("This tests that we are adding children correctly when having CSS first-letter selector.");
+
+        var content = accessibilityController.accessibleElementById("text");
+        dumpAccessibilityChildren(content, 0);
+        
+        shouldBe("content.childrenCount", "1");
+    }
+    successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index a0a0667..2adc881 100644 (file)
@@ -1,3 +1,18 @@
+2016-07-25  Nan Wang  <n_wang@apple.com>
+
+        AX: AccessibilityRenderObject is adding duplicated children when CSS first-letter is being used.
+        https://bugs.webkit.org/show_bug.cgi?id=160155
+
+        Reviewed by Chris Fleizach.
+
+        We were adding the same text node twice if CSS first-letter selector was being used. Added a
+        check for the inline continuation so that we only add it once. 
+
+        Test: accessibility/mac/css-first-letter-children.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::firstChildConsideringContinuation):
+
 2016-07-25  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Media controls on apple.com don't disappear when movie finishes playing
index 1649a81..9892480 100644 (file)
@@ -186,6 +186,12 @@ static inline RenderObject* firstChildConsideringContinuation(RenderObject& rend
 {
     RenderObject* firstChild = renderer.firstChildSlow();
 
+    // We don't want to include the end of a continuation as the firstChild of the
+    // anonymous parent, because everything has already been linked up via continuation.
+    // CSS first-letter selector is an example of this case.
+    if (renderer.isAnonymous() && firstChild && firstChild->isInlineElementContinuation())
+        firstChild = nullptr;
+    
     if (!firstChild && isInlineWithContinuation(renderer))
         firstChild = firstChildInContinuation(downcast<RenderInline>(renderer));