Title: [171997] trunk
Revision
171997
Author
[email protected]
Date
2014-08-04 10:42:44 -0700 (Mon, 04 Aug 2014)

Log Message

AX: SelectText functionality always selects text after current selection even if closer selection is behind it
https://bugs.webkit.org/show_bug.cgi?id=135546

Reviewed by Mario Sanchez Prada.

Source/WebCore:
Logic was incorrect for comparing ranges found before the current selection.
ASSERT was incorrect for allowed ranges. We need to allow ranges that are right at the boundaries of our found ranges.

Extended existing test: platform/mac/accessibility/select-text.html

* accessibility/AccessibilityObject.cpp:
(WebCore::rangeClosestToRange):

LayoutTests:
* platform/mac/accessibility/select-text-expected.txt:
* platform/mac/accessibility/select-text.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (171996 => 171997)


--- trunk/LayoutTests/ChangeLog	2014-08-04 17:32:21 UTC (rev 171996)
+++ trunk/LayoutTests/ChangeLog	2014-08-04 17:42:44 UTC (rev 171997)
@@ -1,5 +1,15 @@
 2014-08-04  Chris Fleizach  <[email protected]>
 
+        AX: SelectText functionality always selects text after current selection even if closer selection is behind it
+        https://bugs.webkit.org/show_bug.cgi?id=135546
+
+        Reviewed by Mario Sanchez Prada.
+
+        * platform/mac/accessibility/select-text-expected.txt:
+        * platform/mac/accessibility/select-text.html:
+
+2014-08-04  Chris Fleizach  <[email protected]>
+
         AX: AXSelectTextWithCriteriaParameterizedAttribute incorrectly selects the beginning letters of a word
         https://bugs.webkit.org/show_bug.cgi?id=135547
 

Modified: trunk/LayoutTests/platform/mac/accessibility/select-text-expected.txt (171996 => 171997)


--- trunk/LayoutTests/platform/mac/accessibility/select-text-expected.txt	2014-08-04 17:32:21 UTC (rev 171996)
+++ trunk/LayoutTests/platform/mac/accessibility/select-text-expected.txt	2014-08-04 17:42:44 UTC (rev 171997)
@@ -1,5 +1,7 @@
 The slow BROWN cat jumps over the lazy dog.
 
+TEXT2: The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+
 This tests the ability to select and replace text with respect to selection.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -27,6 +29,12 @@
 PASS selection is 'brown'
 PASS result is 'brown'
 PASS selection is 'BROWN'
+PASS result is 'quick'
+PASS windowSelection.getRangeAt(0).startOffset is 11
+PASS windowSelection.getRangeAt(0).endOffset is 16
+PASS result is 'quick'
+PASS windowSelection.getRangeAt(0).startOffset is 56
+PASS windowSelection.getRangeAt(0).endOffset is 61
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/accessibility/select-text.html (171996 => 171997)


--- trunk/LayoutTests/platform/mac/accessibility/select-text.html	2014-08-04 17:32:21 UTC (rev 171996)
+++ trunk/LayoutTests/platform/mac/accessibility/select-text.html	2014-08-04 17:42:44 UTC (rev 171997)
@@ -6,8 +6,10 @@
 </head>
 <body>
 
-<p contenteditable="true" id="text">The quick brown fox <span id="target">jumps</span> over the lazy dog.</p>
+<p contenteditable="true" id="text">The quick brown fox <span id="target">jumps</span> over the lazy dog. </p>
 
+<p contenteditable="true" id="text2">TEXT2: The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.</p>
+
 <p id="description"></p>
 <div id="console"></div>
 
@@ -110,6 +112,37 @@
         selection = selectedText();
         shouldBe("selection", "'BROWN'");
 
+        // [https://bugs.webkit.org/show_bug.cgi?id=135546] 
+        // A matching range before the selection should be selected when searching for closest match.
+        document.getElementById("text2").focus();
+        var windowSelection = window.getSelection();
+        windowSelection.removeAllRanges();
+
+        // First find the range before the current selection.
+        var range = document.createRange();
+        range.setStart(document.getElementById("text2").firstChild, 20);
+        range.setEnd(document.getElementById("text2").firstChild, 20);
+        windowSelection.addRange(range);
+      
+        var text2 = accessibilityController.accessibleElementById("text2");
+        result = text2.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestToSelection", "quick");
+        shouldBe("result", "'quick'");
+        selection = window.getSelection();
+        shouldBe("windowSelection.getRangeAt(0).startOffset", "11");
+        shouldBe("windowSelection.getRangeAt(0).endOffset", "16");
+
+        // Move the cursor closer to the second instance in front of the selection.
+        range = document.createRange();
+        range.setStart(document.getElementById("text2").firstChild, 48);
+        range.setEnd(document.getElementById("text2").firstChild, 48);
+        windowSelection.removeAllRanges();
+        windowSelection.addRange(range);
+
+        result = text2.selectTextWithCriteria("AXSelectTextAmbiguityResolutionClosestToSelection", "quick");
+        shouldBe("result", "'quick'");
+        shouldBe("windowSelection.getRangeAt(0).startOffset", "56");
+        shouldBe("windowSelection.getRangeAt(0).endOffset", "61");
+
     }
 </script>
 

Modified: trunk/Source/WebCore/ChangeLog (171996 => 171997)


--- trunk/Source/WebCore/ChangeLog	2014-08-04 17:32:21 UTC (rev 171996)
+++ trunk/Source/WebCore/ChangeLog	2014-08-04 17:42:44 UTC (rev 171997)
@@ -1,5 +1,20 @@
 2014-08-04  Chris Fleizach  <[email protected]>
 
+        AX: SelectText functionality always selects text after current selection even if closer selection is behind it
+        https://bugs.webkit.org/show_bug.cgi?id=135546
+
+        Reviewed by Mario Sanchez Prada.
+
+        Logic was incorrect for comparing ranges found before the current selection.
+        ASSERT was incorrect for allowed ranges. We need to allow ranges that are right at the boundaries of our found ranges.
+
+        Extended existing test: platform/mac/accessibility/select-text.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::rangeClosestToRange):
+
+2014-08-04  Chris Fleizach  <[email protected]>
+
         AX: AXSelectTextWithCriteriaParameterizedAttribute incorrectly selects the beginning letters of a word
         https://bugs.webkit.org/show_bug.cgi?id=135547
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (171996 => 171997)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2014-08-04 17:32:21 UTC (rev 171996)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2014-08-04 17:42:44 UTC (rev 171997)
@@ -531,8 +531,8 @@
 static PassRefPtr<Range> rangeClosestToRange(Range* referenceRange, PassRefPtr<Range> afterRange, PassRefPtr<Range> beforeRange)
 {
     ASSERT(referenceRange);
-    ASSERT(!afterRange || afterRange->startPosition() > referenceRange->startPosition());
-    ASSERT(!beforeRange || beforeRange->endPosition() < referenceRange->endPosition());
+    ASSERT(!afterRange || afterRange->startPosition() >= referenceRange->endPosition());
+    ASSERT(!beforeRange || beforeRange->endPosition() <= referenceRange->startPosition());
     
     if (!referenceRange || (!afterRange && !beforeRange))
         return nullptr;
@@ -541,8 +541,8 @@
     if (!afterRange && beforeRange)
         return beforeRange;
     
-    unsigned positionsToAfterRange = Position::positionCountBetweenPositions(afterRange->startPosition(), referenceRange->startPosition());
-    unsigned positionsToBeforeRange = Position::positionCountBetweenPositions(afterRange->endPosition(), referenceRange->endPosition());
+    unsigned positionsToAfterRange = Position::positionCountBetweenPositions(afterRange->startPosition(), referenceRange->endPosition());
+    unsigned positionsToBeforeRange = Position::positionCountBetweenPositions(beforeRange->endPosition(), referenceRange->startPosition());
     
     return positionsToAfterRange < positionsToBeforeRange ? afterRange : beforeRange;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to