Title: [195405] trunk
Revision
195405
Author
n_w...@apple.com
Date
2016-01-21 00:35:10 -0800 (Thu, 21 Jan 2016)

Log Message

AX: [IOS] Implement next/previous text marker functions using TextIterator
https://bugs.webkit.org/show_bug.cgi?id=153292
<rdar://problem/24268243>

Reviewed by Chris Fleizach.

Source/WebCore:

Added support for the refactored next/previous text marker functions on iOS. And
made text marker tests working on iOS.
Also, fixed an issue in AXObjectCache where creating a range with a replaced node
at the start or end might exclude that node.

Tests: accessibility/text-marker/text-marker-previous-next.html
       accessibility/text-marker/text-marker-with-user-select-none.html

* accessibility/AXObjectCache.cpp:
(WebCore::characterOffsetsInOrder):
(WebCore::resetNodeAndOffsetForReplacedNode):
(WebCore::AXObjectCache::rangeForUnorderedCharacterOffsets):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(+[WebAccessibilityTextMarker textMarkerWithVisiblePosition:cache:]):
(+[WebAccessibilityTextMarker textMarkerWithCharacterOffset:cache:]):
(+[WebAccessibilityTextMarker startOrEndTextMarkerForRange:isStart:cache:]):
(-[WebAccessibilityTextMarker dataRepresentation]):
(-[WebAccessibilityTextMarker visiblePosition]):
(-[WebAccessibilityTextMarker characterOffset]):
(-[WebAccessibilityTextMarker isIgnored]):
(-[WebAccessibilityTextMarker accessibilityObject]):
(-[WebAccessibilityTextMarker description]):
(-[WebAccessibilityObjectWrapper stringForTextMarkers:]):
(blockquoteLevel):
(-[WebAccessibilityObjectWrapper textMarkerRange]):
(-[WebAccessibilityObjectWrapper accessibilityObjectForTextMarker:]):
(-[WebAccessibilityObjectWrapper nextMarkerForMarker:]):
(-[WebAccessibilityObjectWrapper previousMarkerForMarker:]):
(-[WebAccessibilityObjectWrapper textMarkerForPoint:]):
(-[WebAccessibilityObjectWrapper nextMarkerForCharacterOffset:]):
(-[WebAccessibilityObjectWrapper previousMarkerForCharacterOffset:]):
(-[WebAccessibilityObjectWrapper rangeForTextMarkers:]):
(-[WebAccessibilityObjectWrapper lengthForTextMarkers:]):
(-[WebAccessibilityObjectWrapper startOrEndTextMarkerForTextMarkers:isStart:]):
(-[WebAccessibilityObjectWrapper textMarkerRangeForMarkers:]):
(-[WebAccessibilityObjectWrapper accessibilityIdentifier]):

Tools:

Made text marker tests available on iOS.

* DumpRenderTree/AccessibilityTextMarker.h:
* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/ios/AccessibilityTextMarkerIOS.mm: Added.
(AccessibilityTextMarker::AccessibilityTextMarker):
(AccessibilityTextMarker::~AccessibilityTextMarker):
(AccessibilityTextMarker::isEqual):
(AccessibilityTextMarker::platformTextMarker):
(AccessibilityTextMarkerRange::AccessibilityTextMarkerRange):
(AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange):
(AccessibilityTextMarkerRange::isEqual):
(AccessibilityTextMarkerRange::platformTextMarkerRange):
* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::pathDescription):
(AccessibilityUIElement::lineTextMarkerRangeForTextMarker):
(AccessibilityUIElement::textMarkerRangeForElement):
(AccessibilityUIElement::selectedTextMarkerRange):
(AccessibilityUIElement::resetSelectedTextMarkerRange):
(AccessibilityUIElement::textMarkerRangeLength):
(AccessibilityUIElement::textMarkerRangeForMarkers):
(AccessibilityUIElement::startTextMarkerForTextMarkerRange):
(AccessibilityUIElement::endTextMarkerForTextMarkerRange):
(AccessibilityUIElement::accessibilityElementForTextMarker):
(AccessibilityUIElement::endTextMarkerForBounds):
(AccessibilityUIElement::startTextMarkerForBounds):
(AccessibilityUIElement::textMarkerForPoint):
(AccessibilityUIElement::previousTextMarker):
(AccessibilityUIElement::nextTextMarker):
(AccessibilityUIElement::stringForTextMarkerRange):
(AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute):
(AccessibilityUIElement::indexForTextMarker):
(AccessibilityUIElement::isTextMarkerValid):
(AccessibilityUIElement::textMarkerForIndex):
(AccessibilityUIElement::startTextMarker):
(AccessibilityUIElement::endTextMarker):
(AccessibilityUIElement::setSelectedVisibleTextRange):
(AccessibilityUIElement::getLinkedUIElements):
* DumpRenderTree/mac/AccessibilityTextMarkerMac.mm:
(AccessibilityTextMarkerRange::platformTextMarkerRange):
* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::removeSelection):
(AccessibilityUIElement::lineTextMarkerRangeForTextMarker):
(AccessibilityUIElement::setSelectedVisibleTextRange):
(AccessibilityUIElement::supportedActions):
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::textMarkerRangeForElement):
(WTR::AccessibilityUIElement::textMarkerRangeLength):
(WTR::AccessibilityUIElement::previousTextMarker):
(WTR::AccessibilityUIElement::nextTextMarker):
(WTR::AccessibilityUIElement::stringForTextMarkerRange):
(WTR::AccessibilityUIElement::textMarkerRangeForMarkers):
(WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange):
(WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange):
(WTR::AccessibilityUIElement::endTextMarkerForBounds):
(WTR::AccessibilityUIElement::accessibilityElementForTextMarker):
(WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute):

LayoutTests:

* accessibility/mac/previous-next-text-marker-expected.txt: Removed.
* accessibility/mac/previous-next-text-marker.html: Removed.
* accessibility/mac/text-marker-with-user-select-none-expected.txt: Removed.
* accessibility/mac/text-marker-with-user-select-none.html: Removed.
* accessibility/text-marker: Added.
* accessibility/text-marker/text-marker-previous-next-expected.txt: Added.
* accessibility/text-marker/text-marker-previous-next.html: Added.
* accessibility/text-marker/text-marker-with-user-select-none-expected.txt: Added.
* accessibility/text-marker/text-marker-with-user-select-none.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/ios-simulator/TestExpectations:
* platform/win/TestExpectations:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195404 => 195405)


--- trunk/LayoutTests/ChangeLog	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/ChangeLog	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1,3 +1,25 @@
+2016-01-21  Nan Wang  <n_w...@apple.com>
+
+        AX: [IOS] Implement next/previous text marker functions using TextIterator
+        https://bugs.webkit.org/show_bug.cgi?id=153292
+        <rdar://problem/24268243>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/previous-next-text-marker-expected.txt: Removed.
+        * accessibility/mac/previous-next-text-marker.html: Removed.
+        * accessibility/mac/text-marker-with-user-select-none-expected.txt: Removed.
+        * accessibility/mac/text-marker-with-user-select-none.html: Removed.
+        * accessibility/text-marker: Added.
+        * accessibility/text-marker/text-marker-previous-next-expected.txt: Added.
+        * accessibility/text-marker/text-marker-previous-next.html: Added.
+        * accessibility/text-marker/text-marker-with-user-select-none-expected.txt: Added.
+        * accessibility/text-marker/text-marker-with-user-select-none.html: Added.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/ios-simulator/TestExpectations:
+        * platform/win/TestExpectations:
+
 2016-01-20  Zalan Bujtas  <za...@apple.com>
 
         http://victordarras.fr/cssgame/ doesn't work in Safari.

Deleted: trunk/LayoutTests/accessibility/mac/previous-next-text-marker-expected.txt (195404 => 195405)


--- trunk/LayoutTests/accessibility/mac/previous-next-text-marker-expected.txt	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/accessibility/mac/previous-next-text-marker-expected.txt	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1,37 +0,0 @@
-text
-
-text1
-c  d
-
-can't select
-This tests the next/previous text marker functions are implemented correctly.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS text.textMarkerRangeLength(textMarkerRange) is 4
-PASS text.accessibilityElementForTextMarker(startMarker).isEqual(text) is true
-PASS text.accessibilityElementForTextMarker(endMarker).isEqual(text) is true
-PASS element.stringValue is 'AXValue: '
-PASS element.stringValue is 'AXValue: text1'
-PASS element.stringValue is 'AXValue: '
-PASS element.stringValue is 'AXValue: text'
-PASS text2.textMarkerRangeLength(textMarkerRange2) is 5
-Object string for range: c [ATTACHMENT] d
-AXValue: c 
-AXValue: c 
-AXValue: 
-AXValue:  d
-AXValue: 
-AXValue: c 
-AXValue: c 
-AXValue: text1
-PASS text3.stringForTextMarkerRange(markerRange) is 'ect'
-PASS text3.stringForTextMarkerRange(markerRange) is 'sel'
-PASS !psw.accessibilityElementForTextMarker(start) is true
-PASS text2.accessibilityElementForTextMarker(currentMarker).isEqual(text3) is true
-PASS text2.accessibilityElementForTextMarker(currentMarker).isEqual(text2.childAtIndex(2)) is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/accessibility/mac/previous-next-text-marker.html (195404 => 195405)


--- trunk/LayoutTests/accessibility/mac/previous-next-text-marker.html	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/accessibility/mac/previous-next-text-marker.html	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1,136 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src=""
-</head>
-<style>
-.userselect { user-select: none; -webkit-user-select: none; }
-</style>
-<body id="body">
-
-<div id="text" tabindex="0">text</div>
-<br>
-text1
-
-<div id="text2">
-c <img src="" aria-label="blah" style="background-color: #aaaaaa; width: 100px; height: 100px;"> d
-</div>
-
-<input type="password" id="psw">
-
-<div class="userselect" id="text3">can't select</div>
-
-<p id="description"></p>
-<div id="console"></div>
-
-<script>
-
-    description("This tests the next/previous text marker functions are implemented correctly.");
-    
-    if (window.accessibilityController) {
-        
-        var text = accessibilityController.accessibleElementById("text");
-        // Get the actual text node.
-        text = text.childAtIndex(0);
-        
-        // Check that we can get the start/end marker for this range.
-        var textMarkerRange = text.textMarkerRangeForElement(text);
-        shouldBe("text.textMarkerRangeLength(textMarkerRange)", "4");
-        
-        var startMarker = text.startTextMarkerForTextMarkerRange(textMarkerRange);
-        var endMarker = text.endTextMarkerForTextMarkerRange(textMarkerRange);
-        shouldBeTrue("text.accessibilityElementForTextMarker(startMarker).isEqual(text)");
-        shouldBeTrue("text.accessibilityElementForTextMarker(endMarker).isEqual(text)");
-        
-        // Check next text marker. (Advance 5 characters, it will land at <br>.)
-        var currentMarker = startMarker;
-        for (var i = 0; i < 5; i++) {
-            currentMarker = text.nextTextMarker(currentMarker);
-        }
-        var element = text.accessibilityElementForTextMarker(currentMarker);
-        shouldBe("element.stringValue", "'AXValue: '");
-        
-        // Advance one more character, it will lande at "t" in "text1".
-        currentMarker = text.nextTextMarker(currentMarker);
-        element = text.accessibilityElementForTextMarker(currentMarker);
-        shouldBe("element.stringValue", "'AXValue: text1'");
-        
-        // Check previous text marker. (Traverse backwards one character, it will land at <br>.)
-        currentMarker = text.previousTextMarker(currentMarker);
-        element = text.accessibilityElementForTextMarker(currentMarker);
-        shouldBe("element.stringValue", "'AXValue: '");
-        
-        // Traverse backwards one more character, it will land at the last character of "text".
-        currentMarker = text.previousTextMarker(currentMarker);
-        element = text.accessibilityElementForTextMarker(currentMarker);
-        shouldBe("element.stringValue", "'AXValue: text'");
-        
-        // Check the case with replaced node
-        var text2 = accessibilityController.accessibleElementById("text2");
-        var textMarkerRange2 = text2.textMarkerRangeForElement(text2);
-        shouldBe("text2.textMarkerRangeLength(textMarkerRange2)", "5");
-        var str = text2.stringForTextMarkerRange(textMarkerRange2).replace(String.fromCharCode(65532), "[ATTACHMENT]");
-        debug("Object string for range: " + str);
-        
-        currentMarker = text2.startTextMarkerForTextMarkerRange(textMarkerRange2);
-        // Advance 4 characters, it will land at first character of " d".
-        for (var i = 0; i < 4; i++) {
-            currentMarker = text2.nextTextMarker(currentMarker);
-            element = text2.accessibilityElementForTextMarker(currentMarker);
-            debug(element.stringValue);
-        }
-        
-        // Traverse backwards 4 characters, it will land at the last character of "text1".
-        for (var i = 0; i < 4; i++) {
-            currentMarker = text2.previousTextMarker(currentMarker);
-            element = text2.accessibilityElementForTextMarker(currentMarker);
-            debug(element.stringValue);
-        }
-        
-        // Check the case with user-select:none, nextTextMarker/previousTextMarker should still work.
-        var text3 = accessibilityController.accessibleElementById("text3");
-        text3 = text3.childAtIndex(0);
-        // Advance to land at user-select:none node.
-        var marker1, marker2;
-        for (var i = 0; i < 17; i++) {
-            currentMarker = text3.nextTextMarker(currentMarker);
-            // i == 13, it should land on "e", and i == 16, it should land on "t"
-            if (i == 13) {
-                marker1 = currentMarker;
-            }
-        }
-        marker2 = currentMarker;
-        var markerRange = text3.textMarkerRangeForMarkers(marker1, marker2);
-        shouldBe("text3.stringForTextMarkerRange(markerRange)", "'ect'");
-        // Iterate backwards the second marker for 6 characters, the range should be "sel"
-        for (var i = 0; i < 6; i++) {
-            currentMarker = text3.previousTextMarker(currentMarker);
-        }
-        marker2 = currentMarker;
-        markerRange = text3.textMarkerRangeForMarkers(marker1, marker2);
-        shouldBe("text3.stringForTextMarkerRange(markerRange)", "'sel'");
-
-        // Check the case with password field.
-        var psw = accessibilityController.accessibleElementById("psw");
-        var textMarkerRange3 = psw.textMarkerRangeForElement(psw);
-        var start = psw.startTextMarkerForTextMarkerRange(textMarkerRange3);
-        shouldBeTrue("!psw.accessibilityElementForTextMarker(start)");
-        
-        // Check next/previous text marker call will skip password field
-        // We start from text2 and advance 6 characters, it should skip the password field and land on text3.
-        currentMarker = text2.startTextMarkerForTextMarkerRange(textMarkerRange2);
-        for (var i = 0; i < 6; i++) {
-            currentMarker = text2.nextTextMarker(currentMarker);
-        }
-        shouldBeTrue("text2.accessibilityElementForTextMarker(currentMarker).isEqual(text3)");
-        // Check previous text marker, it should land on " d" node.
-        currentMarker = text2.previousTextMarker(currentMarker);
-        shouldBeTrue("text2.accessibilityElementForTextMarker(currentMarker).isEqual(text2.childAtIndex(2))");
-        
-    }
-
-</script>
-
-<script src=""
-</body>
-</html>
\ No newline at end of file

Deleted: trunk/LayoutTests/accessibility/mac/text-marker-with-user-select-none-expected.txt (195404 => 195405)


--- trunk/LayoutTests/accessibility/mac/text-marker-with-user-select-none-expected.txt	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/accessibility/mac/text-marker-with-user-select-none-expected.txt	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1,16 +0,0 @@
-hello test world test hello
-link to here
-test
-This tests that accessibility text markers still work even when user-select:none is set.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS textElement.textMarkerRangeLength(textMarkerRange) is 45
-PASS text is "hello test world test hello\nlink to here\ntest"
-PASS text is 'h'
-PASS element.isEqual(textElement.childAtIndex(0)) is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/accessibility/mac/text-marker-with-user-select-none.html (195404 => 195405)


--- trunk/LayoutTests/accessibility/mac/text-marker-with-user-select-none.html	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/accessibility/mac/text-marker-with-user-select-none.html	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1,49 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src=""
-</head>
-<body id="body">
-
-<div id="text" style="-webkit-user-select:none">
-
-hello test <b>world</b> test hello<br>
-<a href="" to <a href=""
-test
-
-</div>
-
-
-
-<p id="description"></p>
-<div id="console"></div>
-
-<script>
-
-    description("This tests that accessibility text markers still work even when user-select:none is set.");
-
-    if (window.accessibilityController) {
-
-          var textElement = accessibilityController.accessibleElementById("text");
-          var textMarkerRange = textElement.textMarkerRangeForElement(textElement);
-          shouldBe("textElement.textMarkerRangeLength(textMarkerRange)", "45");
-
-          var startMarker = textElement.startTextMarkerForTextMarkerRange(textMarkerRange);
-          var endMarker = textElement.endTextMarkerForTextMarkerRange(textMarkerRange);
-          textMarkerRange = textElement.textMarkerRangeForMarkers(startMarker, endMarker);
-          var text = textElement.stringForTextMarkerRange(textMarkerRange);
-          shouldBeEqualToString("text", "hello test world test hello\nlink to here\ntest");
-
-          var nextMarker = textElement.nextTextMarker(startMarker);
-          textMarkerRange = textElement.textMarkerRangeForMarkers(startMarker, nextMarker);
-          text = textElement.stringForTextMarkerRange(textMarkerRange);
-          shouldBe("text", "'h'");
-          var element = textElement.accessibilityElementForTextMarker(nextMarker);
-          shouldBeTrue("element.isEqual(textElement.childAtIndex(0))");
-    }
-
-</script>
-
-<script src=""
-</body>
-</html>
\ No newline at end of file

Copied: trunk/LayoutTests/accessibility/text-marker/text-marker-previous-next-expected.txt (from rev 195398, trunk/LayoutTests/accessibility/mac/previous-next-text-marker-expected.txt) (0 => 195405)


--- trunk/LayoutTests/accessibility/text-marker/text-marker-previous-next-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/text-marker/text-marker-previous-next-expected.txt	2016-01-21 08:35:10 UTC (rev 195405)
@@ -0,0 +1,31 @@
+text
+
+text1
+c  d
+
+can't select
+This tests the next/previous text marker functions are implemented correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS text.textMarkerRangeLength(textMarkerRange) is 4
+PASS text.accessibilityElementForTextMarker(startMarker).isEqual(text) is true
+PASS text.accessibilityElementForTextMarker(endMarker).isEqual(text) is true
+PASS text.stringForTextMarkerRange(markerRange) is ''
+PASS text.stringForTextMarkerRange(markerRange) is 't'
+PASS text.stringForTextMarkerRange(markerRange) is ''
+PASS text.stringForTextMarkerRange(markerRange) is 't'
+PASS text2.textMarkerRangeLength(textMarkerRange2) is 5
+Object string for range: c [ATTACHMENT] d
+PASS text2.stringForTextMarkerRange(markerRange) is 'd'
+PASS text2.stringForTextMarkerRange(markerRange) is '1'
+PASS text3.stringForTextMarkerRange(markerRange) is 'ect'
+PASS text3.stringForTextMarkerRange(markerRange) is 'sel'
+PASS !psw.accessibilityElementForTextMarker(start) is true
+PASS text2.accessibilityElementForTextMarker(currentMarker).isEqual(text3) is true
+PASS text2.accessibilityElementForTextMarker(currentMarker).isEqual(text2.childAtIndex(2)) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/accessibility/text-marker/text-marker-previous-next.html (from rev 195398, trunk/LayoutTests/accessibility/mac/previous-next-text-marker.html) (0 => 195405)


--- trunk/LayoutTests/accessibility/text-marker/text-marker-previous-next.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/text-marker/text-marker-previous-next.html	2016-01-21 08:35:10 UTC (rev 195405)
@@ -0,0 +1,143 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<style>
+.userselect { user-select: none; -webkit-user-select: none; }
+</style>
+<body id="body">
+
+<div id="text" tabindex="0">text</div>
+<br>
+text1
+
+<div id="text2">
+c <img src="" aria-label="blah" style="background-color: #aaaaaa; width: 100px; height: 100px;"> d
+</div>
+
+<input type="password" id="psw">
+
+<div class="userselect" id="text3">can't select</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests the next/previous text marker functions are implemented correctly.");
+    
+    if (window.accessibilityController) {
+        
+        var text = accessibilityController.accessibleElementById("text");
+        // Get the actual text node.
+        text = text.childAtIndex(0);
+        
+        // Check that we can get the start/end marker for this range.
+        var textMarkerRange = text.textMarkerRangeForElement(text);
+        shouldBe("text.textMarkerRangeLength(textMarkerRange)", "4");
+        
+        var startMarker = text.startTextMarkerForTextMarkerRange(textMarkerRange);
+        var endMarker = text.endTextMarkerForTextMarkerRange(textMarkerRange);
+        shouldBeTrue("text.accessibilityElementForTextMarker(startMarker).isEqual(text)");
+        shouldBeTrue("text.accessibilityElementForTextMarker(endMarker).isEqual(text)");
+        
+        // Check next text marker. (Advance 5 characters, it will land at <br>.)
+        var currentMarker = startMarker;
+        var previousMarker, markerRange;
+        for (var i = 0; i < 5; i++) {
+            previousMarker = currentMarker;
+            currentMarker = text.nextTextMarker(currentMarker);
+        }
+        markerRange = text.textMarkerRangeForMarkers(previousMarker, currentMarker);
+        shouldBe("text.stringForTextMarkerRange(markerRange)", "''");
+        
+        // Advance one more character, it will lande at "t" in "text1".
+        previousMarker = currentMarker;
+        currentMarker = text.nextTextMarker(currentMarker);
+        markerRange = text.textMarkerRangeForMarkers(previousMarker, currentMarker);
+        shouldBe("text.stringForTextMarkerRange(markerRange)", "'t'");
+        
+        // Check previous text marker. (Traverse backwards one character, it will land at <br>.)
+        previousMarker = text.previousTextMarker(previousMarker);
+        currentMarker = text.previousTextMarker(currentMarker);
+        markerRange = text.textMarkerRangeForMarkers(previousMarker, currentMarker);
+        shouldBe("text.stringForTextMarkerRange(markerRange)", "''");
+        
+        // Traverse backwards one more character, it will land at the last character of "text".
+        previousMarker = text.previousTextMarker(previousMarker);
+        currentMarker = text.previousTextMarker(currentMarker);
+        markerRange = text.textMarkerRangeForMarkers(previousMarker, currentMarker);
+        shouldBe("text.stringForTextMarkerRange(markerRange)", "'t'");
+        
+        // Check the case with replaced node
+        var text2 = accessibilityController.accessibleElementById("text2");
+        var textMarkerRange2 = text2.textMarkerRangeForElement(text2);
+        shouldBe("text2.textMarkerRangeLength(textMarkerRange2)", "5");
+        var str = text2.stringForTextMarkerRange(textMarkerRange2).replace(String.fromCharCode(65532), "[ATTACHMENT]");
+        debug("Object string for range: " + str);
+        
+        currentMarker = text2.startTextMarkerForTextMarkerRange(textMarkerRange2);
+        // Advance 5 characters, it will land at "d".
+        for (var i = 0; i < 5; i++) {
+            previousMarker = currentMarker;
+            currentMarker = text2.nextTextMarker(currentMarker);
+        }
+        markerRange = text2.textMarkerRangeForMarkers(previousMarker, currentMarker);
+        shouldBe("text2.stringForTextMarkerRange(markerRange)", "'d'");
+        
+        // Traverse backwards 5 characters, it will land at the last character of "text1".
+        for (var i = 0; i < 5; i++) {
+            previousMarker = text2.previousTextMarker(previousMarker);
+            currentMarker = text2.previousTextMarker(currentMarker);
+        }
+        markerRange = text2.textMarkerRangeForMarkers(previousMarker, currentMarker);
+        shouldBe("text2.stringForTextMarkerRange(markerRange)", "'1'");
+        
+        // Check the case with user-select:none, nextTextMarker/previousTextMarker should still work.
+        var text3 = accessibilityController.accessibleElementById("text3");
+        text3 = text3.childAtIndex(0);
+        // Advance to land at user-select:none node.
+        var marker1, marker2;
+        for (var i = 0; i < 17; i++) {
+            currentMarker = text3.nextTextMarker(currentMarker);
+            // i == 13, it should land on "e", and i == 16, it should land on "t"
+            if (i == 13) {
+                marker1 = currentMarker;
+            }
+        }
+        marker2 = currentMarker;
+        markerRange = text3.textMarkerRangeForMarkers(marker1, marker2);
+        shouldBe("text3.stringForTextMarkerRange(markerRange)", "'ect'");
+        // Iterate backwards the second marker for 6 characters, the range should be "sel"
+        for (var i = 0; i < 6; i++) {
+            currentMarker = text3.previousTextMarker(currentMarker);
+        }
+        marker2 = currentMarker;
+        markerRange = text3.textMarkerRangeForMarkers(marker1, marker2);
+        shouldBe("text3.stringForTextMarkerRange(markerRange)", "'sel'");
+
+        // Check the case with password field.
+        var psw = accessibilityController.accessibleElementById("psw");
+        var textMarkerRange3 = psw.textMarkerRangeForElement(psw);
+        var start = psw.startTextMarkerForTextMarkerRange(textMarkerRange3);
+        shouldBeTrue("!psw.accessibilityElementForTextMarker(start)");
+        
+        // Check next/previous text marker call will skip password field
+        // We start from text2 and advance 6 characters, it should skip the password field and land on text3.
+        currentMarker = text2.startTextMarkerForTextMarkerRange(textMarkerRange2);
+        for (var i = 0; i < 6; i++) {
+            currentMarker = text2.nextTextMarker(currentMarker);
+        }
+        shouldBeTrue("text2.accessibilityElementForTextMarker(currentMarker).isEqual(text3)");
+        // Check previous text marker, it should land on " d" node.
+        currentMarker = text2.previousTextMarker(currentMarker);
+        shouldBeTrue("text2.accessibilityElementForTextMarker(currentMarker).isEqual(text2.childAtIndex(2))");
+        
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>
\ No newline at end of file

Copied: trunk/LayoutTests/accessibility/text-marker/text-marker-with-user-select-none-expected.txt (from rev 195398, trunk/LayoutTests/accessibility/mac/text-marker-with-user-select-none-expected.txt) (0 => 195405)


--- trunk/LayoutTests/accessibility/text-marker/text-marker-with-user-select-none-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/text-marker/text-marker-with-user-select-none-expected.txt	2016-01-21 08:35:10 UTC (rev 195405)
@@ -0,0 +1,16 @@
+hello test world test hello
+link to here
+test
+This tests that accessibility text markers still work even when user-select:none is set.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS textElement.textMarkerRangeLength(textMarkerRange) is 45
+PASS text is "hello test world test hello\nlink to here\ntest"
+PASS text is 'h'
+PASS element.isEqual(textElement.childAtIndex(0)) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/accessibility/text-marker/text-marker-with-user-select-none.html (from rev 195398, trunk/LayoutTests/accessibility/mac/text-marker-with-user-select-none.html) (0 => 195405)


--- trunk/LayoutTests/accessibility/text-marker/text-marker-with-user-select-none.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/text-marker/text-marker-with-user-select-none.html	2016-01-21 08:35:10 UTC (rev 195405)
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="text" style="-webkit-user-select:none">
+
+hello test <b>world</b> test hello<br>
+<a href="" to <a href=""
+test
+
+</div>
+
+
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that accessibility text markers still work even when user-select:none is set.");
+
+    if (window.accessibilityController) {
+
+          var textElement = accessibilityController.accessibleElementById("text");
+          var textMarkerRange = textElement.textMarkerRangeForElement(textElement);
+          shouldBe("textElement.textMarkerRangeLength(textMarkerRange)", "45");
+
+          var startMarker = textElement.startTextMarkerForTextMarkerRange(textMarkerRange);
+          var endMarker = textElement.endTextMarkerForTextMarkerRange(textMarkerRange);
+          textMarkerRange = textElement.textMarkerRangeForMarkers(startMarker, endMarker);
+          var text = textElement.stringForTextMarkerRange(textMarkerRange);
+          shouldBeEqualToString("text", "hello test world test hello\nlink to here\ntest");
+
+          var nextMarker = textElement.nextTextMarker(startMarker);
+          textMarkerRange = textElement.textMarkerRangeForMarkers(startMarker, nextMarker);
+          text = textElement.stringForTextMarkerRange(textMarkerRange);
+          shouldBe("text", "'h'");
+          var element = textElement.accessibilityElementForTextMarker(nextMarker);
+          shouldBeTrue("element.isEqual(textElement.childAtIndex(0))");
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/efl/TestExpectations (195404 => 195405)


--- trunk/LayoutTests/platform/efl/TestExpectations	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2016-01-21 08:35:10 UTC (rev 195405)
@@ -2346,6 +2346,9 @@
 webkit.org/b/146887 accessibility/aria-roledescription.html [ Failure ]
 webkit.org/b/146887 accessibility/list-detection.html [ Failure ]
 
+# Text marker tests are not supported
+webkit.org/b/153292 accessibility/text-marker [ Skip ]
+
 # This test hardcodes the result of a platform-dependent font lookup algorithm.
 fast/text/fallback-language-han.html [ Skip ]
 fast/text/fallback-language-han-2.html [ Skip ]

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (195404 => 195405)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2016-01-21 08:35:10 UTC (rev 195405)
@@ -609,6 +609,9 @@
 # ARIA 1.1 table related attributes are not supported
 webkit.org/b/148967 accessibility/aria-table-attributes.html [ Skip ]
 
+# Text marker tests are not supported
+webkit.org/b/153292 accessibility/text-marker [ Skip ]
+
 # WebKitGTK+ needs WOFF2 support.
 webkit.org/b/152616 fast/text/woff2.html [ ImageOnlyFailure ]
 

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (195404 => 195405)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2016-01-21 08:35:10 UTC (rev 195405)
@@ -2764,6 +2764,9 @@
 # Enable "aria-table-attributes" test for iOS
 webkit.org/b/150366 accessibility/aria-table-attributes.html [ Pass ]
 
+# Enable Text marker tests for iOS
+webkit.org/b/153292 accessibility/text-marker [ Pass ]
+
 # More flaky tests (Sept 18, 2015)
 
 fast/forms/select-element-focus-ring.html [ Failure Pass ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (195404 => 195405)


--- trunk/LayoutTests/platform/win/TestExpectations	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/LayoutTests/platform/win/TestExpectations	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1718,6 +1718,9 @@
 webkit.org/b/138566 accessibility/aria-modal.html [ Skip ]
 webkit.org/b/138566 accessibility/aria-modal-multiple-dialogs.html [ Skip ]
 
+# Text marker tests are not supported
+webkit.org/b/153292 accessibility/text-marker [ Skip ]
+
 ################################################################################
 #######################   End Accessibility Issues   ###########################
 ################################################################################

Modified: trunk/Source/WebCore/ChangeLog (195404 => 195405)


--- trunk/Source/WebCore/ChangeLog	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Source/WebCore/ChangeLog	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1,3 +1,48 @@
+2016-01-21  Nan Wang  <n_w...@apple.com>
+
+        AX: [IOS] Implement next/previous text marker functions using TextIterator
+        https://bugs.webkit.org/show_bug.cgi?id=153292
+        <rdar://problem/24268243>
+
+        Reviewed by Chris Fleizach.
+
+        Added support for the refactored next/previous text marker functions on iOS. And 
+        made text marker tests working on iOS.
+        Also, fixed an issue in AXObjectCache where creating a range with a replaced node
+        at the start or end might exclude that node.
+
+        Tests: accessibility/text-marker/text-marker-previous-next.html
+               accessibility/text-marker/text-marker-with-user-select-none.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::characterOffsetsInOrder):
+        (WebCore::resetNodeAndOffsetForReplacedNode):
+        (WebCore::AXObjectCache::rangeForUnorderedCharacterOffsets):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (+[WebAccessibilityTextMarker textMarkerWithVisiblePosition:cache:]):
+        (+[WebAccessibilityTextMarker textMarkerWithCharacterOffset:cache:]):
+        (+[WebAccessibilityTextMarker startOrEndTextMarkerForRange:isStart:cache:]):
+        (-[WebAccessibilityTextMarker dataRepresentation]):
+        (-[WebAccessibilityTextMarker visiblePosition]):
+        (-[WebAccessibilityTextMarker characterOffset]):
+        (-[WebAccessibilityTextMarker isIgnored]):
+        (-[WebAccessibilityTextMarker accessibilityObject]):
+        (-[WebAccessibilityTextMarker description]):
+        (-[WebAccessibilityObjectWrapper stringForTextMarkers:]):
+        (blockquoteLevel):
+        (-[WebAccessibilityObjectWrapper textMarkerRange]):
+        (-[WebAccessibilityObjectWrapper accessibilityObjectForTextMarker:]):
+        (-[WebAccessibilityObjectWrapper nextMarkerForMarker:]):
+        (-[WebAccessibilityObjectWrapper previousMarkerForMarker:]):
+        (-[WebAccessibilityObjectWrapper textMarkerForPoint:]):
+        (-[WebAccessibilityObjectWrapper nextMarkerForCharacterOffset:]):
+        (-[WebAccessibilityObjectWrapper previousMarkerForCharacterOffset:]):
+        (-[WebAccessibilityObjectWrapper rangeForTextMarkers:]):
+        (-[WebAccessibilityObjectWrapper lengthForTextMarkers:]):
+        (-[WebAccessibilityObjectWrapper startOrEndTextMarkerForTextMarkers:isStart:]):
+        (-[WebAccessibilityObjectWrapper textMarkerRangeForMarkers:]):
+        (-[WebAccessibilityObjectWrapper accessibilityIdentifier]):
+
 2016-01-20  Zalan Bujtas  <za...@apple.com>
 
         http://victordarras.fr/cssgame/ doesn't work in Safari.

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (195404 => 195405)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1545,6 +1545,23 @@
     return range1->compareBoundaryPoints(Range::START_TO_START, range2.get(), IGNORE_EXCEPTION) <= 0;
 }
 
+static Node* resetNodeAndOffsetForReplacedNode(Node* replacedNode, int& offset, int characterCount)
+{
+    // Use this function to include the replaced node itself in the range we are creating.
+    if (!replacedNode)
+        return nullptr;
+    
+    RefPtr<Range> nodeRange = AXObjectCache::rangeForNodeContents(replacedNode);
+    int nodeLength = TextIterator::rangeLength(nodeRange.get());
+    offset = characterCount <= nodeLength ? replacedNode->computeNodeIndex() : replacedNode->computeNodeIndex() + 1;
+    return replacedNode->parentNode();
+}
+
+static bool isReplacedNodeOrBR(Node* node)
+{
+    return AccessibilityObject::replacedNodeNeedsCharacter(node) || node->hasTagName(brTag);
+}
+
 RefPtr<Range> AXObjectCache::rangeForUnorderedCharacterOffsets(const CharacterOffset& characterOffset1, const CharacterOffset& characterOffset2)
 {
     if (characterOffset1.isNull() || characterOffset2.isNull())
@@ -1554,30 +1571,33 @@
     CharacterOffset startCharacterOffset = alreadyInOrder ? characterOffset1 : characterOffset2;
     CharacterOffset endCharacterOffset = alreadyInOrder ? characterOffset2 : characterOffset1;
     
-    int endOffset = endCharacterOffset.offset;
-    
-    // endOffset can be out of bounds sometimes if the node is a replaced node or has brTag.
-    if (startCharacterOffset.node == endCharacterOffset.node) {
-        RefPtr<Range> nodeRange = AXObjectCache::rangeForNodeContents(startCharacterOffset.node);
-        int nodeLength = TextIterator::rangeLength(nodeRange.get());
-        if (endOffset > nodeLength)
-            endOffset = nodeLength;
-    }
-    
     int startOffset = startCharacterOffset.startIndex + startCharacterOffset.offset;
-    endOffset = endCharacterOffset.startIndex + endOffset;
+    int endOffset = endCharacterOffset.startIndex + endCharacterOffset.offset;
+    Node* startNode = startCharacterOffset.node;
+    Node* endNode = endCharacterOffset.node;
     
-    // If start node is a replaced node and it has children, we want to include the replaced node itself in the range.
-    Node* startNode = startCharacterOffset.node;
-    if (AccessibilityObject::replacedNodeNeedsCharacter(startNode) && (startNode->hasChildNodes() || startNode != endCharacterOffset.node)) {
-        startOffset = startNode->computeNodeIndex();
-        startNode = startNode->parentNode();
+    // Consider the case when the replaced node is at the start/end of the range.
+    bool startNodeIsReplacedOrBR = isReplacedNodeOrBR(startNode);
+    bool endNodeIsReplacedOrBR = isReplacedNodeOrBR(endNode);
+    if (startNodeIsReplacedOrBR || endNodeIsReplacedOrBR) {
+        // endOffset can be out of bounds sometimes if the node is a replaced node or has brTag and it has no children.
+        if (startNode == endNode && !startNode->hasChildNodes()) {
+            RefPtr<Range> nodeRange = AXObjectCache::rangeForNodeContents(startNode);
+            int nodeLength = TextIterator::rangeLength(nodeRange.get());
+            if (endCharacterOffset.offset > nodeLength)
+                endOffset = endCharacterOffset.startIndex + nodeLength;
+        } else {
+            if (startNodeIsReplacedOrBR)
+                startNode = resetNodeAndOffsetForReplacedNode(startNode, startOffset, startCharacterOffset.offset);
+            if (endNodeIsReplacedOrBR)
+                endNode = resetNodeAndOffsetForReplacedNode(startNode, endOffset, startCharacterOffset.offset);
+        }
     }
     
     RefPtr<Range> result = Range::create(m_document);
     ExceptionCode ecStart = 0, ecEnd = 0;
     result->setStart(startNode, startOffset, ecStart);
-    result->setEnd(endCharacterOffset.node, endOffset, ecEnd);
+    result->setEnd(endNode, endOffset, ecEnd);
     if (ecStart || ecEnd)
         return nullptr;
     

Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (195404 => 195405)


--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2016-01-21 08:35:10 UTC (rev 195405)
@@ -134,6 +134,8 @@
 }
 
 + (WebAccessibilityTextMarker *)textMarkerWithVisiblePosition:(VisiblePosition&)visiblePos cache:(AXObjectCache*)cache;
++ (WebAccessibilityTextMarker *)textMarkerWithCharacterOffset:(CharacterOffset&)characterOffset cache:(AXObjectCache*)cache;
++ (WebAccessibilityTextMarker *)startOrEndTextMarkerForRange:(const RefPtr<Range>)range isStart:(BOOL)isStart cache:(AXObjectCache*)cache;
 
 @end
 
@@ -178,6 +180,33 @@
     return [[[WebAccessibilityTextMarker alloc] initWithTextMarker:&textMarkerData cache:cache] autorelease];
 }
 
++ (WebAccessibilityTextMarker *)textMarkerWithCharacterOffset:(CharacterOffset&)characterOffset cache:(AXObjectCache*)cache
+{
+    if (!cache)
+        return nil;
+    
+    if (characterOffset.isNull())
+        return nil;
+    
+    TextMarkerData textMarkerData;
+    cache->textMarkerDataForCharacterOffset(textMarkerData, *characterOffset.node, characterOffset.offset, false);
+    if (!textMarkerData.axID && !textMarkerData.ignored)
+        return nil;
+    return [[[WebAccessibilityTextMarker alloc] initWithTextMarker:&textMarkerData cache:cache] autorelease];
+}
+
++ (WebAccessibilityTextMarker *)startOrEndTextMarkerForRange:(const RefPtr<Range>)range isStart:(BOOL)isStart cache:(AXObjectCache*)cache
+{
+    if (!cache)
+        return nil;
+    
+    TextMarkerData textMarkerData;
+    cache->startOrEndTextMarkerDataForRange(textMarkerData, range, isStart);
+    if (!textMarkerData.axID)
+        return nil;
+    return [[[WebAccessibilityTextMarker alloc] initWithTextMarker:&textMarkerData cache:cache] autorelease];
+}
+
 - (NSData *)dataRepresentation
 {
     return [NSData dataWithBytes:&_textMarkerData length:sizeof(TextMarkerData)];
@@ -188,6 +217,25 @@
     return _cache->visiblePositionForTextMarkerData(_textMarkerData);
 }
 
+- (CharacterOffset)characterOffset
+{
+    if (_textMarkerData.ignored)
+        return CharacterOffset();
+    return CharacterOffset(_textMarkerData.node, _textMarkerData.characterStartIndex, _textMarkerData.characterOffset);
+}
+
+- (BOOL)isIgnored
+{
+    return _textMarkerData.ignored;
+}
+
+- (AccessibilityObject*)accessibilityObject
+{
+    if (_textMarkerData.ignored)
+        return nullptr;
+    return _cache->accessibilityObjectForTextMarkerData(_textMarkerData);
+}
+
 - (NSString *)description
 {
     return [NSString stringWithFormat:@"[AXTextMarker %p] = node: %p offset: %d", self, _textMarkerData.node, _textMarkerData.offset];
@@ -1831,25 +1879,11 @@
     if (![self _prepareAccessibilityCall])
         return nil;
     
-    if ([markers count] != 2)
+    RefPtr<Range> range = [self rangeForTextMarkers:markers];
+    if (!range)
         return nil;
     
-    WebAccessibilityTextMarker* startMarker = [markers objectAtIndex:0];
-    WebAccessibilityTextMarker* endMarker = [markers objectAtIndex:1];
-    if (![startMarker isKindOfClass:[WebAccessibilityTextMarker class]] || ![endMarker isKindOfClass:[WebAccessibilityTextMarker class]])
-        return nil;
-    
-    // extract the start and end VisiblePosition
-    VisiblePosition startVisiblePosition = [startMarker visiblePosition];
-    if (startVisiblePosition.isNull())
-        return nil;
-    
-    VisiblePosition endVisiblePosition = [endMarker visiblePosition];
-    if (endVisiblePosition.isNull())
-        return nil;
-
-    VisiblePositionRange visiblePosRange = VisiblePositionRange(startVisiblePosition, endVisiblePosition);
-    return m_object->stringForVisiblePositionRange(visiblePosRange);
+    return m_object->stringForRange(range);
 }
 
 static int blockquoteLevel(RenderObject* renderer)
@@ -2124,13 +2158,8 @@
     if (![self _prepareAccessibilityCall])
         return nil;
     
-    VisiblePositionRange range = m_object->visiblePositionRange();
-    VisiblePosition startPosition = range.start;
-    VisiblePosition endPosition = range.end;
-    WebAccessibilityTextMarker* start = [WebAccessibilityTextMarker textMarkerWithVisiblePosition:startPosition cache:m_object->axObjectCache()];
-    WebAccessibilityTextMarker* end = [WebAccessibilityTextMarker textMarkerWithVisiblePosition:endPosition cache:m_object->axObjectCache()];
-    
-    return [NSArray arrayWithObjects:start, end, nil];
+    RefPtr<Range> range = m_object->elementRange();
+    return [self textMarkersForRange:range];
 }
 
 // A method to get the normalized text cursor range of an element. Used in DumpRenderTree.
@@ -2160,8 +2189,7 @@
     if (!marker)
         return nil;
     
-    VisiblePosition visiblePosition = [marker visiblePosition];
-    AccessibilityObject* obj = m_object->accessibilityObjectForPosition(visiblePosition);
+    AccessibilityObject* obj = [marker accessibilityObject];
     if (!obj)
         return nil;
     
@@ -2354,14 +2382,10 @@
     if (!marker)
         return nil;
     
-    VisiblePosition start = [marker visiblePosition];
-    VisiblePosition nextMarker = m_object->nextVisiblePosition(start);
-    
-    return [WebAccessibilityTextMarker textMarkerWithVisiblePosition:nextMarker cache:m_object->axObjectCache()];
+    CharacterOffset start = [marker characterOffset];
+    return [self nextMarkerForCharacterOffset:start];
 }
 
-// This method is intended to return the marker at the start of the line starting at
-// the marker that is passed into the method.
 - (WebAccessibilityTextMarker *)previousMarkerForMarker:(WebAccessibilityTextMarker *)marker
 {
     if (![self _prepareAccessibilityCall])
@@ -2370,10 +2394,8 @@
     if (!marker)
         return nil;
     
-    VisiblePosition start = [marker visiblePosition];
-    VisiblePosition previousMarker = m_object->previousVisiblePosition(start);
-    
-    return [WebAccessibilityTextMarker textMarkerWithVisiblePosition:previousMarker cache:m_object->axObjectCache()];
+    CharacterOffset start = [marker characterOffset];
+    return [self previousMarkerForCharacterOffset:start];
 }
 
 // This method is intended to return the bounds of a text marker range in screen coordinates.
@@ -2403,6 +2425,87 @@
     return [WebAccessibilityTextMarker textMarkerWithVisiblePosition:pos cache:m_object->axObjectCache()];
 }
 
+- (WebAccessibilityTextMarker *)nextMarkerForCharacterOffset:(CharacterOffset&)characterOffset
+{
+    characterOffset.offset = characterOffset.offset + 1;
+    WebAccessibilityTextMarker *textMarker = [WebAccessibilityTextMarker textMarkerWithCharacterOffset:characterOffset cache:m_object->axObjectCache()];
+    if (textMarker && textMarker.isIgnored)
+        textMarker = [self nextMarkerForCharacterOffset:characterOffset];
+    return textMarker;
+}
+
+- (WebAccessibilityTextMarker *)previousMarkerForCharacterOffset:(CharacterOffset&)characterOffset
+{
+    characterOffset.offset = characterOffset.offset - 1;
+    WebAccessibilityTextMarker *textMarker = [WebAccessibilityTextMarker textMarkerWithCharacterOffset:characterOffset cache:m_object->axObjectCache()];
+    if (textMarker && textMarker.isIgnored)
+        textMarker = [self previousMarkerForCharacterOffset:characterOffset];
+    return textMarker;
+}
+
+- (RefPtr<Range>)rangeForTextMarkers:(NSArray *)textMarkers
+{
+    if ([textMarkers count] != 2)
+        return nullptr;
+    
+    WebAccessibilityTextMarker *startMarker = [textMarkers objectAtIndex:0];
+    WebAccessibilityTextMarker *endMarker = [textMarkers objectAtIndex:1];
+    
+    if (![startMarker isKindOfClass:[WebAccessibilityTextMarker class]] || ![endMarker isKindOfClass:[WebAccessibilityTextMarker class]])
+        return nullptr;
+    
+    AXObjectCache* cache = m_object->axObjectCache();
+    if (!cache)
+        return nullptr;
+    
+    CharacterOffset startCharacterOffset = [startMarker characterOffset];
+    CharacterOffset endCharacterOffset = [endMarker characterOffset];
+    return cache->rangeForUnorderedCharacterOffsets(startCharacterOffset, endCharacterOffset);
+}
+
+- (NSInteger)lengthForTextMarkers:(NSArray *)textMarkers
+{
+    if (![self _prepareAccessibilityCall])
+        return 0;
+    
+    RefPtr<Range> range = [self rangeForTextMarkers:textMarkers];
+    int length = AXObjectCache::lengthForRange(range.get());
+    return length < 0 ? 0 : length;
+}
+
+- (WebAccessibilityTextMarker *)startOrEndTextMarkerForTextMarkers:(NSArray *)textMarkers isStart:(BOOL)isStart
+{
+    if (![self _prepareAccessibilityCall])
+        return nil;
+    
+    RefPtr<Range> range = [self rangeForTextMarkers:textMarkers];
+    if (!range)
+        return nil;
+    
+    return [WebAccessibilityTextMarker startOrEndTextMarkerForRange:range isStart:isStart cache:m_object->axObjectCache()];
+}
+
+- (NSArray *)textMarkerRangeForMarkers:(NSArray *)textMarkers
+{
+    if (![self _prepareAccessibilityCall])
+        return nil;
+    
+    RefPtr<Range> range = [self rangeForTextMarkers:textMarkers];
+    return [self textMarkersForRange:range];
+}
+
+- (NSArray *)textMarkersForRange:(RefPtr<Range>)range
+{
+    if (!range)
+        return nil;
+    
+    WebAccessibilityTextMarker* start = [WebAccessibilityTextMarker startOrEndTextMarkerForRange:range isStart:YES cache:m_object->axObjectCache()];
+    WebAccessibilityTextMarker* end = [WebAccessibilityTextMarker startOrEndTextMarkerForRange:range isStart:NO cache:m_object->axObjectCache()];
+    if (!start || !end)
+        return nil;
+    return [NSArray arrayWithObjects:start, end, nil];
+}
+
 - (NSString *)accessibilityIdentifier
 {
     if (![self _prepareAccessibilityCall])

Modified: trunk/Tools/ChangeLog (195404 => 195405)


--- trunk/Tools/ChangeLog	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Tools/ChangeLog	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1,3 +1,69 @@
+2016-01-21  Nan Wang  <n_w...@apple.com>
+
+        AX: [IOS] Implement next/previous text marker functions using TextIterator
+        https://bugs.webkit.org/show_bug.cgi?id=153292
+        <rdar://problem/24268243>
+
+        Reviewed by Chris Fleizach.
+
+        Made text marker tests available on iOS.
+
+        * DumpRenderTree/AccessibilityTextMarker.h:
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/ios/AccessibilityTextMarkerIOS.mm: Added.
+        (AccessibilityTextMarker::AccessibilityTextMarker):
+        (AccessibilityTextMarker::~AccessibilityTextMarker):
+        (AccessibilityTextMarker::isEqual):
+        (AccessibilityTextMarker::platformTextMarker):
+        (AccessibilityTextMarkerRange::AccessibilityTextMarkerRange):
+        (AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange):
+        (AccessibilityTextMarkerRange::isEqual):
+        (AccessibilityTextMarkerRange::platformTextMarkerRange):
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::pathDescription):
+        (AccessibilityUIElement::lineTextMarkerRangeForTextMarker):
+        (AccessibilityUIElement::textMarkerRangeForElement):
+        (AccessibilityUIElement::selectedTextMarkerRange):
+        (AccessibilityUIElement::resetSelectedTextMarkerRange):
+        (AccessibilityUIElement::textMarkerRangeLength):
+        (AccessibilityUIElement::textMarkerRangeForMarkers):
+        (AccessibilityUIElement::startTextMarkerForTextMarkerRange):
+        (AccessibilityUIElement::endTextMarkerForTextMarkerRange):
+        (AccessibilityUIElement::accessibilityElementForTextMarker):
+        (AccessibilityUIElement::endTextMarkerForBounds):
+        (AccessibilityUIElement::startTextMarkerForBounds):
+        (AccessibilityUIElement::textMarkerForPoint):
+        (AccessibilityUIElement::previousTextMarker):
+        (AccessibilityUIElement::nextTextMarker):
+        (AccessibilityUIElement::stringForTextMarkerRange):
+        (AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute):
+        (AccessibilityUIElement::indexForTextMarker):
+        (AccessibilityUIElement::isTextMarkerValid):
+        (AccessibilityUIElement::textMarkerForIndex):
+        (AccessibilityUIElement::startTextMarker):
+        (AccessibilityUIElement::endTextMarker):
+        (AccessibilityUIElement::setSelectedVisibleTextRange):
+        (AccessibilityUIElement::getLinkedUIElements):
+        * DumpRenderTree/mac/AccessibilityTextMarkerMac.mm:
+        (AccessibilityTextMarkerRange::platformTextMarkerRange):
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::removeSelection):
+        (AccessibilityUIElement::lineTextMarkerRangeForTextMarker):
+        (AccessibilityUIElement::setSelectedVisibleTextRange):
+        (AccessibilityUIElement::supportedActions):
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::textMarkerRangeForElement):
+        (WTR::AccessibilityUIElement::textMarkerRangeLength):
+        (WTR::AccessibilityUIElement::previousTextMarker):
+        (WTR::AccessibilityUIElement::nextTextMarker):
+        (WTR::AccessibilityUIElement::stringForTextMarkerRange):
+        (WTR::AccessibilityUIElement::textMarkerRangeForMarkers):
+        (WTR::AccessibilityUIElement::startTextMarkerForTextMarkerRange):
+        (WTR::AccessibilityUIElement::endTextMarkerForTextMarkerRange):
+        (WTR::AccessibilityUIElement::endTextMarkerForBounds):
+        (WTR::AccessibilityUIElement::accessibilityElementForTextMarker):
+        (WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute):
+
 2016-01-20  Filip Pizlo  <fpi...@apple.com>
 
         Unreviewed, revert accidental unreviewed commit.

Modified: trunk/Tools/DumpRenderTree/AccessibilityTextMarker.h (195404 => 195405)


--- trunk/Tools/DumpRenderTree/AccessibilityTextMarker.h	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Tools/DumpRenderTree/AccessibilityTextMarker.h	2016-01-21 08:35:10 UTC (rev 195405)
@@ -28,7 +28,7 @@
 
 #include <_javascript_Core/JSObjectRef.h>
 
-#if PLATFORM(MAC) && !PLATFORM(IOS)
+#if PLATFORM(MAC) || PLATFORM(IOS)
 #define SUPPORTS_AX_TEXTMARKERS 1
 #else
 #define SUPPORTS_AX_TEXTMARKERS 0
@@ -58,7 +58,7 @@
     
 private:
     static JSClassRef getJSClass();
-#if SUPPORTS_AX_TEXTMARKERS
+#if SUPPORTS_AX_TEXTMARKERS && PLATFORM(MAC)
     RetainPtr<PlatformTextMarker> m_textMarker;
 #else
     PlatformTextMarker m_textMarker;
@@ -78,7 +78,7 @@
     
 private:
     static JSClassRef getJSClass();
-#if SUPPORTS_AX_TEXTMARKERS
+#if SUPPORTS_AX_TEXTMARKERS && PLATFORM(MAC)
     RetainPtr<PlatformTextMarkerRange> m_textMarkerRange;
 #else
     PlatformTextMarkerRange m_textMarkerRange;

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (195404 => 195405)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2016-01-21 08:35:10 UTC (rev 195405)
@@ -95,6 +95,7 @@
 		A8B91ADC0CF3B32F008F91FF /* DumpRenderTreeWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8B91AD90CF3B32F008F91FF /* DumpRenderTreeWindow.mm */; };
 		A8B91BFD0CF522B4008F91FF /* CheckedMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */; };
 		A8D79CEB0FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m in Sources */ = {isa = PBXBuildFile; fileRef = A8D79CE90FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m */; };
+		A9BB7C5C1C505278002C525B /* AccessibilityTextMarkerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9BB7C5B1C505278002C525B /* AccessibilityTextMarkerIOS.mm */; };
 		AA5A15EF16E15CD000F7C561 /* AccessibilityControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA5A15ED16E15CD000F7C561 /* AccessibilityControllerIOS.mm */; };
 		AA5A15F016E15CD000F7C561 /* AccessibilityUIElementIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA5A15EE16E15CD000F7C561 /* AccessibilityUIElementIOS.mm */; };
 		BC0131DA0C9772010087317D /* TestRunner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC0131D80C9772010087317D /* TestRunner.cpp */; };
@@ -309,6 +310,7 @@
 		A8B91BF90CF522B4008F91FF /* CheckedMalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CheckedMalloc.h; path = mac/CheckedMalloc.h; sourceTree = "<group>"; };
 		A8D79CE80FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreeFileDraggingSource.h; sourceTree = "<group>"; };
 		A8D79CE90FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DumpRenderTreeFileDraggingSource.m; sourceTree = "<group>"; };
+		A9BB7C5B1C505278002C525B /* AccessibilityTextMarkerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityTextMarkerIOS.mm; path = ios/AccessibilityTextMarkerIOS.mm; sourceTree = "<group>"; };
 		AA5A15ED16E15CD000F7C561 /* AccessibilityControllerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityControllerIOS.mm; path = ios/AccessibilityControllerIOS.mm; sourceTree = "<group>"; };
 		AA5A15EE16E15CD000F7C561 /* AccessibilityUIElementIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityUIElementIOS.mm; path = ios/AccessibilityUIElementIOS.mm; sourceTree = "<group>"; };
 		AA7F10C20CB3C1030003BDC9 /* AHEM____.TTF */ = {isa = PBXFileReference; lastKnownFileType = file; name = "AHEM____.TTF"; path = "fonts/AHEM____.TTF"; sourceTree = "<group>"; };
@@ -499,6 +501,7 @@
 				80045AEC147718E7008290A8 /* AccessibilityNotificationHandler.mm */,
 				29CFBA0F122736E600BC30C0 /* AccessibilityTextMarker.cpp */,
 				29CFBA0E122736E600BC30C0 /* AccessibilityTextMarker.h */,
+				A9BB7C5B1C505278002C525B /* AccessibilityTextMarkerIOS.mm */,
 				29CFBA2D12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm */,
 				BC0E24DF0E2D9451001B6BC2 /* AccessibilityUIElement.cpp */,
 				BC0E24DE0E2D9451001B6BC2 /* AccessibilityUIElement.h */,
@@ -974,6 +977,7 @@
 				BCA18C470C9B5B9400114369 /* DumpRenderTree.mm in Sources */,
 				9830F31F15C81181005AB206 /* DumpRenderTreeCommon.cpp in Sources */,
 				BCA18B7B0C9B08F100114369 /* DumpRenderTreeDraggingInfo.mm in Sources */,
+				A9BB7C5C1C505278002C525B /* AccessibilityTextMarkerIOS.mm in Sources */,
 				A8D79CEB0FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m in Sources */,
 				A8B91ADA0CF3B32F008F91FF /* DumpRenderTreePasteboard.m in Sources */,
 				A8B91ADC0CF3B32F008F91FF /* DumpRenderTreeWindow.mm in Sources */,

Copied: trunk/Tools/DumpRenderTree/ios/AccessibilityTextMarkerIOS.mm (from rev 195398, trunk/Tools/DumpRenderTree/mac/AccessibilityTextMarkerMac.mm) (0 => 195405)


--- trunk/Tools/DumpRenderTree/ios/AccessibilityTextMarkerIOS.mm	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/ios/AccessibilityTextMarkerIOS.mm	2016-01-21 08:35:10 UTC (rev 195405)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "AccessibilityTextMarker.h"
+
+#import "DumpRenderTree.h"
+
+#if SUPPORTS_AX_TEXTMARKERS && PLATFORM(IOS)
+
+// MARK: AccessibilityTextMarker
+
+AccessibilityTextMarker::AccessibilityTextMarker(PlatformTextMarker marker)
+    : m_textMarker(marker)
+{
+}
+
+AccessibilityTextMarker::AccessibilityTextMarker(const AccessibilityTextMarker& marker)
+    : m_textMarker(marker.platformTextMarker())
+{
+}
+
+AccessibilityTextMarker::~AccessibilityTextMarker()
+{
+}
+
+bool AccessibilityTextMarker::isEqual(AccessibilityTextMarker* other)
+{
+    return [(id)platformTextMarker() isEqual:(id)other->platformTextMarker()];
+}
+
+PlatformTextMarker AccessibilityTextMarker::platformTextMarker() const 
+{ 
+    return m_textMarker;
+}
+
+// MARK: AccessibilityTextMarkerRange
+
+AccessibilityTextMarkerRange::AccessibilityTextMarkerRange(PlatformTextMarkerRange markerRange)
+    : m_textMarkerRange(markerRange)
+{
+}
+
+AccessibilityTextMarkerRange::AccessibilityTextMarkerRange(const AccessibilityTextMarkerRange& markerRange)
+    : m_textMarkerRange(markerRange.platformTextMarkerRange())
+{
+}
+
+AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange()
+{
+}
+
+bool AccessibilityTextMarkerRange::isEqual(AccessibilityTextMarkerRange* other)
+{
+    return [(id)platformTextMarkerRange() isEqual:(id)other->platformTextMarkerRange()];
+}
+
+PlatformTextMarkerRange AccessibilityTextMarkerRange::platformTextMarkerRange() const
+{
+    return m_textMarkerRange;
+}
+
+#endif // SUPPORTS_AX_TEXTMARKERS && PLATFORM(IOS)

Modified: trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm (195404 => 195405)


--- trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm	2016-01-21 08:35:10 UTC (rev 195405)
@@ -94,6 +94,16 @@
 - (NSUInteger)accessibilityARIAColumnIndex;
 - (UIAccessibilityTraits)_axContainedByFieldsetTrait;
 - (id)_accessibilityFieldsetAncestor;
+
+// TextMarker related
+- (NSArray *)textMarkerRange;
+- (NSInteger)lengthForTextMarkers:(NSArray *)textMarkers;
+- (NSString *)stringForTextMarkers:(NSArray *)markers;
+- (id)startOrEndTextMarkerForTextMarkers:(NSArray*)textMarkers isStart:(BOOL)isStart;
+- (NSArray *)textMarkerRangeForMarkers:(NSArray *)textMarkers;
+- (id)nextMarkerForMarker:(id)marker;
+- (id)previousMarkerForMarker:(id)marker;
+- (id)accessibilityObjectForTextMarker:(id)marker;
 @end
 
 @interface NSObject (WebAccessibilityObjectWrapperPrivate)
@@ -411,6 +421,137 @@
     return [result createJSStringRef];
 }
 
+#if SUPPORTS_AX_TEXTMARKERS && PLATFORM(IOS)
+
+// Text markers
+
+AccessibilityTextMarkerRange AccessibilityUIElement::lineTextMarkerRangeForTextMarker(AccessibilityTextMarker*)
+{
+    return nullptr;
+}
+
+AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForElement(AccessibilityUIElement* element)
+{
+    id textMarkerRange = [element->platformUIElement() textMarkerRange];
+    return AccessibilityTextMarkerRange(textMarkerRange);
+}
+
+AccessibilityTextMarkerRange AccessibilityUIElement::selectedTextMarkerRange()
+{
+    return nullptr;
+}
+
+void AccessibilityUIElement::resetSelectedTextMarkerRange()
+{
+}
+
+int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange* range)
+{
+    id textMarkers = (id)range->platformTextMarkerRange();
+    return [m_element lengthForTextMarkers:textMarkers];
+}
+
+AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker)
+{
+    NSArray *textMarkers = [NSArray arrayWithObjects:(id)startMarker->platformTextMarker(), (id)endMarker->platformTextMarker(), nil];
+    id textMarkerRange = [m_element textMarkerRangeForMarkers:textMarkers];
+    return AccessibilityTextMarkerRange(textMarkerRange);
+}
+
+AccessibilityTextMarker AccessibilityUIElement::startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
+{
+    id textMarkers = (id)range->platformTextMarkerRange();
+    id textMarker = [m_element startOrEndTextMarkerForTextMarkers:textMarkers isStart:YES];
+    return AccessibilityTextMarker(textMarker);
+}
+
+AccessibilityTextMarker AccessibilityUIElement::endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
+{
+    id textMarkers = (id)range->platformTextMarkerRange();
+    id textMarker = [m_element startOrEndTextMarkerForTextMarkers:textMarkers isStart:NO];
+    return AccessibilityTextMarker(textMarker);
+}
+
+AccessibilityUIElement AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker* marker)
+{
+    id obj = [m_element accessibilityObjectForTextMarker:(id)marker->platformTextMarker()];
+    if (obj)
+        return AccessibilityUIElement(obj);
+    return nullptr;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::endTextMarkerForBounds(int x, int y, int width, int height)
+{
+    return nullptr;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::startTextMarkerForBounds(int x, int y, int width, int height)
+{
+    return nullptr;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::textMarkerForPoint(int x, int y)
+{
+    return nullptr;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker* textMarker)
+{
+    id previousMarker = [m_element previousMarkerForMarker:(id)textMarker->platformTextMarker()];
+    return AccessibilityTextMarker(previousMarker);
+}
+
+AccessibilityTextMarker AccessibilityUIElement::nextTextMarker(AccessibilityTextMarker* textMarker)
+{
+    id nextMarker = [m_element nextMarkerForMarker:(id)textMarker->platformTextMarker()];
+    return AccessibilityTextMarker(nextMarker);
+}
+
+JSStringRef AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
+{
+    id textMarkers = (id)markerRange->platformTextMarkerRange();
+    if (!textMarkers || ![textMarkers isKindOfClass:[NSArray class]])
+        return JSStringCreateWithCharacters(0, 0);
+    return [[m_element stringForTextMarkers:textMarkers] createJSStringRef];
+}
+
+bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*)
+{
+    return false;
+}
+
+int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*)
+{
+    return -1;
+}
+
+bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*)
+{
+    return false;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::textMarkerForIndex(int)
+{
+    return nullptr;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::startTextMarker()
+{
+    return nullptr;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::endTextMarker()
+{
+    return nullptr;
+}
+
+bool AccessibilityUIElement::setSelectedVisibleTextRange(AccessibilityTextMarkerRange*)
+{
+    return false;
+}
+
+#endif // SUPPORTS_AX_TEXTMARKERS && PLATFORM(IOS)
+
 #pragma mark Unused
 
 void AccessibilityUIElement::getLinkedUIElements(Vector<AccessibilityUIElement>& elementVector)

Modified: trunk/Tools/DumpRenderTree/mac/AccessibilityTextMarkerMac.mm (195404 => 195405)


--- trunk/Tools/DumpRenderTree/mac/AccessibilityTextMarkerMac.mm	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Tools/DumpRenderTree/mac/AccessibilityTextMarkerMac.mm	2016-01-21 08:35:10 UTC (rev 195405)
@@ -28,7 +28,7 @@
 #import "AccessibilityTextMarker.h"
 #import "DumpRenderTree.h"
 
-#if SUPPORTS_AX_TEXTMARKERS
+#if SUPPORTS_AX_TEXTMARKERS && PLATFORM(MAC)
 
 // MARK: AccessibilityTextMarker
 
@@ -82,4 +82,4 @@
     return m_textMarkerRange.get();
 }
 
-#endif // SUPPORTS_AX_TEXTMARKERS
+#endif // SUPPORTS_AX_TEXTMARKERS && PLATFORM(MAC)

Modified: trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm (195404 => 195405)


--- trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm	2016-01-21 08:35:10 UTC (rev 195405)
@@ -1612,7 +1612,7 @@
     // FIXME: implement
 }
 
-#if SUPPORTS_AX_TEXTMARKERS
+#if SUPPORTS_AX_TEXTMARKERS && PLATFORM(MAC)
 
 // Text markers
 AccessibilityTextMarkerRange AccessibilityUIElement::lineTextMarkerRangeForTextMarker(AccessibilityTextMarker* textMarker)
@@ -1846,7 +1846,7 @@
     return true;
 }
 
-#endif // SUPPORTS_AX_TEXTMARKERS
+#endif // SUPPORTS_AX_TEXTMARKERS && PLATFORM(MAC)
 
 JSStringRef AccessibilityUIElement::supportedActions()
 {

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm (195404 => 195405)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm	2016-01-21 07:59:26 UTC (rev 195404)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm	2016-01-21 08:35:10 UTC (rev 195405)
@@ -71,6 +71,16 @@
 - (NSUInteger)accessibilityARIAColumnIndex;
 - (UIAccessibilityTraits)_axContainedByFieldsetTrait;
 - (id)_accessibilityFieldsetAncestor;
+
+// TextMarker related
+- (NSArray *)textMarkerRange;
+- (NSInteger)lengthForTextMarkers:(NSArray *)textMarkers;
+- (NSString *)stringForTextMarkers:(NSArray *)markers;
+- (id)startOrEndTextMarkerForTextMarkers:(NSArray*)textMarkers isStart:(BOOL)isStart;
+- (NSArray *)textMarkerRangeForMarkers:(NSArray *)textMarkers;
+- (id)nextMarkerForMarker:(id)marker;
+- (id)previousMarkerForMarker:(id)marker;
+- (id)accessibilityObjectForTextMarker:(id)marker;
 @end
 
 @interface NSObject (WebAccessibilityObjectWrapperPrivate)
@@ -982,42 +992,55 @@
 
 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForElement(AccessibilityUIElement* element)
 {
-    return 0;
+    id textMarkerRange = [element->platformUIElement() textMarkerRange];
+    return AccessibilityTextMarkerRange::create(textMarkerRange);
 }
 
 int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange* range)
 {
-    return 0;
+    id textMarkers = (id)range->platformTextMarkerRange();    
+    return [m_element lengthForTextMarkers:textMarkers];
 }
 
 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker* textMarker)
 {
-    return 0;
+    id previousMarker = [m_element previousMarkerForMarker:(id)textMarker->platformTextMarker()];
+    return AccessibilityTextMarker::create(previousMarker);
 }
 
 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::nextTextMarker(AccessibilityTextMarker* textMarker)
 {
-    return 0;
+    id nextMarker = [m_element nextMarkerForMarker:(id)textMarker->platformTextMarker()];
+    return AccessibilityTextMarker::create(nextMarker);
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
 {
-    return 0;
+    id textMarkers = (id)markerRange->platformTextMarkerRange();
+    if (!textMarkers || ![textMarkers isKindOfClass:[NSArray class]])
+        return JSStringCreateWithCharacters(0, 0);
+    return [[m_element stringForTextMarkers:textMarkers] createJSStringRef];
 }
 
 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker)
 {
-    return 0;
+    NSArray *textMarkers = [NSArray arrayWithObjects:(id)startMarker->platformTextMarker(), (id)endMarker->platformTextMarker(), nil];
+    id textMarkerRange = [m_element textMarkerRangeForMarkers:textMarkers];
+    return AccessibilityTextMarkerRange::create(textMarkerRange);
 }
 
 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
 {
-    return 0;
+    id textMarkers = (id)range->platformTextMarkerRange();
+    id textMarker = [m_element startOrEndTextMarkerForTextMarkers:textMarkers isStart:YES];
+    return AccessibilityTextMarker::create(textMarker);
 }
 
 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
 {
-    return 0;
+    id textMarkers = (id)range->platformTextMarkerRange();
+    id textMarker = [m_element startOrEndTextMarkerForTextMarkers:textMarkers isStart:NO];
+    return AccessibilityTextMarker::create(textMarker);
 }
 
 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::endTextMarkerForBounds(int x, int y, int width, int height)
@@ -1037,7 +1060,10 @@
 
 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker* marker)
 {
-    return 0;
+    id obj = [m_element accessibilityObjectForTextMarker:(id)marker->platformTextMarker()];
+    if (obj)
+        return AccessibilityUIElement::create(obj);
+    return nullptr;
 }
 
 bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef attribute, AccessibilityTextMarkerRange* range)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to