Title: [274826] trunk
Revision
274826
Author
cfleiz...@apple.com
Date
2021-03-22 17:22:00 -0700 (Mon, 22 Mar 2021)

Log Message

AX: textRectsFromMarkers always fails
https://bugs.webkit.org/show_bug.cgi?id=223556
<rdar://74256003>

Reviewed by Zalan Bujtas.

Source/WebCore:

The textRectsFromMarkers:text: method is always failing to return a valid answer because when we try to extend
the search range of text to search, we're creating a range that can't be iterated with a CharacterIterator

Test: accessibility/ios-simulator/text-rects-for-range-matches.html

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

LayoutTests:

* accessibility/ios-simulator/text-rects-for-range-matches.html: Added.
* accessibility/ios-simulator/text-rects-for-range-matches-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (274825 => 274826)


--- trunk/LayoutTests/ChangeLog	2021-03-23 00:20:51 UTC (rev 274825)
+++ trunk/LayoutTests/ChangeLog	2021-03-23 00:22:00 UTC (rev 274826)
@@ -1,3 +1,14 @@
+2021-03-22  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: textRectsFromMarkers always fails
+        https://bugs.webkit.org/show_bug.cgi?id=223556
+        <rdar://74256003>
+
+        Reviewed by Zalan Bujtas.
+
+        * accessibility/ios-simulator/text-rects-for-range-matches.html: Added.
+        * accessibility/ios-simulator/text-rects-for-range-matches-expected.txt: Added.
+
 2021-03-22  Peng Liu  <peng.l...@apple.com>
 
         [ macOS wk2 ] media/media-source/media-source-canplaythrough-event.html is a flakey text failure

Added: trunk/LayoutTests/accessibility/ios-simulator/text-rects-for-range-matches-expected.txt (0 => 274826)


--- trunk/LayoutTests/accessibility/ios-simulator/text-rects-for-range-matches-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/text-rects-for-range-matches-expected.txt	2021-03-23 00:22:00 UTC (rev 274826)
@@ -0,0 +1,11 @@
+This is some testing content.
+This tests that we are able to get the rects for a range correctly with matching text.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Rect for range should not be empty: NSRect: {{75, 26}, {37, 17}}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/ios-simulator/text-rects-for-range-matches.html (0 => 274826)


--- trunk/LayoutTests/accessibility/ios-simulator/text-rects-for-range-matches.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/text-rects-for-range-matches.html	2021-03-23 00:22:00 UTC (rev 274826)
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+    <script src=""
+    <body id="body" tabindex="0">
+        <div tabindex="0" id="text">
+        This is some testing content. 
+        </div>
+
+        <p id="description"></p>
+        <div id="console"></div>
+
+        <script>
+
+            description("This tests that we are able to get the rects for a range correctly with matching text.");
+
+            if (window.accessibilityController) {
+                accessibilityController.enableEnhancedAccessibility(true);
+                var text = accessibilityController.rootElement.childAtIndex(0).childAtIndex(0);
+
+                var rectsForRange = text.rectsForTextMarkerRange(text.textMarkerRangeForElement(text), "testing");
+                debug("Rect for range should not be empty: " + rectsForRange);
+            }
+
+            </script>
+
+        <script src=""
+
+    </body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (274825 => 274826)


--- trunk/Source/WebCore/ChangeLog	2021-03-23 00:20:51 UTC (rev 274825)
+++ trunk/Source/WebCore/ChangeLog	2021-03-23 00:22:00 UTC (rev 274826)
@@ -1,3 +1,19 @@
+2021-03-22  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: textRectsFromMarkers always fails
+        https://bugs.webkit.org/show_bug.cgi?id=223556
+        <rdar://74256003>
+
+        Reviewed by Zalan Bujtas.
+
+        The textRectsFromMarkers:text: method is always failing to return a valid answer because when we try to extend
+        the search range of text to search, we're creating a range that can't be iterated with a CharacterIterator
+
+        Test: accessibility/ios-simulator/text-rects-for-range-matches.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::rangeMatchesTextNearRange):
+
 2021-03-22  Ian Gilbert  <i...@apple.com>
 
         [Web Animations] nullptr crash in updatePlaybackRate() with no timeline

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (274825 => 274826)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2021-03-23 00:20:51 UTC (rev 274825)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2021-03-23 00:22:00 UTC (rev 274826)
@@ -2033,15 +2033,24 @@
     
 Optional<SimpleRange> AXObjectCache::rangeMatchesTextNearRange(const SimpleRange& originalRange, const String& matchText)
 {
-    // Create a large enough range for searching the text within.
+    // Create a large enough range to find the text within it that's being searched for.
     unsigned textLength = matchText.length();
-    auto startPosition = visiblePositionForPositionWithOffset(makeContainerOffsetPosition(originalRange.start), -textLength);
-    auto endPosition = visiblePositionForPositionWithOffset(makeContainerOffsetPosition(originalRange.start), 2 * textLength);
-    if (startPosition.isNull())
-        startPosition = firstPositionInOrBeforeNode(originalRange.start.container.ptr());
-    if (endPosition.isNull())
-        endPosition = lastPositionInOrAfterNode(originalRange.end.container.ptr());
+    auto startPosition = VisiblePosition(makeContainerOffsetPosition(originalRange.start));
+    for (unsigned k = 0; k < textLength; k++) {
+        auto testPosition = startPosition.previous();
+        if (testPosition.isNull())
+            break;
+        startPosition = testPosition;
+    }
 
+    auto endPosition = VisiblePosition(makeContainerOffsetPosition(originalRange.end));
+    for (unsigned k = 0; k < textLength; k++) {
+        auto testPosition = endPosition.next();
+        if (testPosition.isNull())
+            break;
+        endPosition = testPosition;
+    }
+
     auto searchRange = makeSimpleRange(startPosition, endPosition);
     if (!searchRange || searchRange->collapsed())
         return WTF::nullopt;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to