Title: [234275] trunk
Revision
234275
Author
n_w...@apple.com
Date
2018-07-26 14:34:27 -0700 (Thu, 26 Jul 2018)

Log Message

AX: nothing returned for various previous text marker APIs from one div/p node to another
https://bugs.webkit.org/show_bug.cgi?id=188071

Reviewed by Chris Fleizach.

Source/WebCore:

TextIterator is emitting an extra '\n' at the end of the <p> node and there's no
corresponding text node in the DOM tree, so we are not able to handle that for
text markers. Fixed it by ignoring the extra '\n' and anchor the text marker to
the previous child text node.

Test: accessibility/mac/text-marker-p-tags.html

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::traverseToOffsetInRange):

LayoutTests:

* accessibility/mac/text-marker-p-tags-expected.txt: Added.
* accessibility/mac/text-marker-p-tags.html: Added.
* accessibility/mac/text-marker-string-for-document-range-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234274 => 234275)


--- trunk/LayoutTests/ChangeLog	2018-07-26 21:32:00 UTC (rev 234274)
+++ trunk/LayoutTests/ChangeLog	2018-07-26 21:34:27 UTC (rev 234275)
@@ -1,3 +1,14 @@
+2018-07-26  Nan Wang  <n_w...@apple.com>
+
+        AX: nothing returned for various previous text marker APIs from one div/p node to another
+        https://bugs.webkit.org/show_bug.cgi?id=188071
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/text-marker-p-tags-expected.txt: Added.
+        * accessibility/mac/text-marker-p-tags.html: Added.
+        * accessibility/mac/text-marker-string-for-document-range-expected.txt:
+
 2018-07-26  David Fenton  <david_fen...@apple.com>
 
         Layout Test webgl/2.0.0/conformance2/glsl3/compound-assignment-type-combination.html is timing out on mac Debug

Added: trunk/LayoutTests/accessibility/mac/text-marker-p-tags-expected.txt (0 => 234275)


--- trunk/LayoutTests/accessibility/mac/text-marker-p-tags-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/text-marker-p-tags-expected.txt	2018-07-26 21:34:27 UTC (rev 234275)
@@ -0,0 +1,21 @@
+This tests that previous sentence/word/paragraph text marker calls work with p tag elements
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS selectedString is 'Where'
+Previous sentence: Test sentence two
+
+
+Previous word: two
+
+
+Previous paragraph: Test sentence one. Test sentence two
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Test sentence one. Test sentence two
+
+Where

Added: trunk/LayoutTests/accessibility/mac/text-marker-p-tags.html (0 => 234275)


--- trunk/LayoutTests/accessibility/mac/text-marker-p-tags.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/text-marker-p-tags.html	2018-07-26 21:34:27 UTC (rev 234275)
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div>
+<p id="p1">Test sentence one. Test sentence two</p>
+</div>
+<div>
+<p id="p2">Where</p>
+</div>
+
+<script>
+
+    description("This tests that previous sentence\/word\/paragraph text marker calls work with p tag elements");
+
+    if (window.accessibilityController) {
+
+        // select text
+        selectText('p2');
+        var p2 = accessibilityController.accessibleElementById("p2");
+        var selectedRange = p2.selectedTextMarkerRange();
+        var selectedString = p2.stringForTextMarkerRange(selectedRange);
+        shouldBe("selectedString", "'Where'");
+
+        var startTextMarker = p2.startTextMarkerForTextMarkerRange(selectedRange);
+        var preSentenceStart = p2.previousSentenceStartTextMarkerForTextMarker(startTextMarker);
+        var sentenceRange = p2.textMarkerRangeForMarkers(preSentenceStart, startTextMarker);
+        var sentenceString = p2.stringForTextMarkerRange(sentenceRange);
+        debug("Previous sentence: " + sentenceString);
+
+        var preWordStart = p2.previousWordStartTextMarkerForTextMarker(startTextMarker);
+        var wordRange = p2.textMarkerRangeForMarkers(preWordStart, startTextMarker);
+        var wordString = p2.stringForTextMarkerRange(wordRange);
+        debug("Previous word: " + wordString);
+
+        var preParagraphStart = p2.previousParagraphStartTextMarkerForTextMarker(startTextMarker);
+        var paragraphRange = p2.textMarkerRangeForMarkers(preParagraphStart, startTextMarker);
+        var paragraphString = p2.stringForTextMarkerRange(paragraphRange);
+        debug("Previous paragraph: " + paragraphString);
+    }
+
+    function selectText(node) {
+        node = document.getElementById(node);
+
+        if (document.body.createTextRange) {
+            const range = document.body.createTextRange();
+            range.moveToElementText(node);
+            range.select();
+        } else if (window.getSelection) {
+            const selection = window.getSelection();
+            const range = document.createRange();
+            range.selectNodeContents(node);
+            selection.removeAllRanges();
+            selection.addRange(range);
+        } else {
+            console.warn("Could not select text in node: Unsupported browser.");
+        }
+    }
+    
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/accessibility/mac/text-marker-string-for-document-range-expected.txt (234274 => 234275)


--- trunk/LayoutTests/accessibility/mac/text-marker-string-for-document-range-expected.txt	2018-07-26 21:32:00 UTC (rev 234274)
+++ trunk/LayoutTests/accessibility/mac/text-marker-string-for-document-range-expected.txt	2018-07-26 21:34:27 UTC (rev 234275)
@@ -9,9 +9,6 @@
 This tests that we are getting the correct string for document range if the end visible position has after anchor type.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/WebCore/ChangeLog (234274 => 234275)


--- trunk/Source/WebCore/ChangeLog	2018-07-26 21:32:00 UTC (rev 234274)
+++ trunk/Source/WebCore/ChangeLog	2018-07-26 21:34:27 UTC (rev 234275)
@@ -1,3 +1,20 @@
+2018-07-26  Nan Wang  <n_w...@apple.com>
+
+        AX: nothing returned for various previous text marker APIs from one div/p node to another
+        https://bugs.webkit.org/show_bug.cgi?id=188071
+
+        Reviewed by Chris Fleizach.
+
+        TextIterator is emitting an extra '\n' at the end of the <p> node and there's no
+        corresponding text node in the DOM tree, so we are not able to handle that for 
+        text markers. Fixed it by ignoring the extra '\n' and anchor the text marker to 
+        the previous child text node.
+
+        Test: accessibility/mac/text-marker-p-tags.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::traverseToOffsetInRange):
+
 2018-07-26  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r234181 and r234189.

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (234274 => 234275)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2018-07-26 21:32:00 UTC (rev 234274)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2018-07-26 21:34:27 UTC (rev 234275)
@@ -1694,6 +1694,11 @@
                             currentNode = shadowHost;
                             continue;
                         }
+                    } else if (previousNode && previousNode->isTextNode() && previousNode->isDescendantOf(currentNode) && currentNode->hasTagName(pTag)) {
+                        // TextIterator is emitting an extra newline after the <p> element. We should
+                        // ignore that since the extra text node is not in the DOM tree.
+                        currentNode = previousNode;
+                        continue;
                     } else if (currentNode != previousNode) {
                         // We should set the start offset and length for the current node in case this is the last iteration.
                         lastStartOffset = 1;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to