Title: [249695] branches/safari-608-branch
Revision
249695
Author
alanc...@apple.com
Date
2019-09-09 20:19:48 -0700 (Mon, 09 Sep 2019)

Log Message

Cherry-pick r249565. rdar://problem/55113261

    AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
    https://bugs.webkit.org/show_bug.cgi?id=201518
    <rdar://problem/54835122>

    Patch by Andres Gonzalez <andresg...@apple.com> on 2019-09-06
    Reviewed by Ryosuke Niwa.

    Source/WebCore:

    Test: accessibility/set-selected-text-range-after-newline.html

    In the case of an empty line, the CharacterIterator range start and end
    were not equal, thus we were not advancing the iterator and returning
    the iterator range end, which is not correct. With this change we are
    always advancing the iterator if its text is just '\n'. This covers all
    the cases we fixed before plus empty lines.

    * editing/Editing.cpp:
    (WebCore::visiblePositionForIndexUsingCharacterIterator):

    LayoutTests:

    Extended this test to set the selection range passed an empty line.
    * accessibility/set-selected-text-range-after-newline-expected.txt:
    * accessibility/set-selected-text-range-after-newline.html:

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

Modified Paths

Diff

Modified: branches/safari-608-branch/LayoutTests/ChangeLog (249694 => 249695)


--- branches/safari-608-branch/LayoutTests/ChangeLog	2019-09-10 03:19:45 UTC (rev 249694)
+++ branches/safari-608-branch/LayoutTests/ChangeLog	2019-09-10 03:19:48 UTC (rev 249695)
@@ -1,5 +1,49 @@
 2019-09-09  Kocsen Chung  <kocsen_ch...@apple.com>
 
+        Cherry-pick r249565. rdar://problem/55113261
+
+    AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
+    https://bugs.webkit.org/show_bug.cgi?id=201518
+    <rdar://problem/54835122>
+    
+    Patch by Andres Gonzalez <andresg...@apple.com> on 2019-09-06
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebCore:
+    
+    Test: accessibility/set-selected-text-range-after-newline.html
+    
+    In the case of an empty line, the CharacterIterator range start and end
+    were not equal, thus we were not advancing the iterator and returning
+    the iterator range end, which is not correct. With this change we are
+    always advancing the iterator if its text is just '\n'. This covers all
+    the cases we fixed before plus empty lines.
+    
+    * editing/Editing.cpp:
+    (WebCore::visiblePositionForIndexUsingCharacterIterator):
+    
+    LayoutTests:
+    
+    Extended this test to set the selection range passed an empty line.
+    * accessibility/set-selected-text-range-after-newline-expected.txt:
+    * accessibility/set-selected-text-range-after-newline.html:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-09-06  Andres Gonzalez  <andresg...@apple.com>
+
+            AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
+            https://bugs.webkit.org/show_bug.cgi?id=201518
+            <rdar://problem/54835122>
+
+            Reviewed by Ryosuke Niwa.
+
+            Extended this test to set the selection range passed an empty line.
+            * accessibility/set-selected-text-range-after-newline-expected.txt:
+            * accessibility/set-selected-text-range-after-newline.html:
+
+2019-09-09  Kocsen Chung  <kocsen_ch...@apple.com>
+
         Cherry-pick r249534. rdar://problem/55183098
 
     AX: children cache are not re-computed if tab index is removed

Modified: branches/safari-608-branch/LayoutTests/accessibility/set-selected-text-range-after-newline-expected.txt (249694 => 249695)


--- branches/safari-608-branch/LayoutTests/accessibility/set-selected-text-range-after-newline-expected.txt	2019-09-10 03:19:45 UTC (rev 249694)
+++ branches/safari-608-branch/LayoutTests/accessibility/set-selected-text-range-after-newline-expected.txt	2019-09-10 03:19:48 UTC (rev 249695)
@@ -1,8 +1,11 @@
 hello
+
 world
 PASS text.selectedTextRange became '{5, 0}'
 There must be only one [newline] between hello and world: hello[newline]world
 PASS text.selectedTextRange became '{6, 0}'
+There must be two [newline] between hello and world: hello[newline][newline]world
+PASS text.selectedTextRange became '{7, 0}'
 The text after the newline should be world: world
 PASS successfullyParsed is true
 

Modified: branches/safari-608-branch/LayoutTests/accessibility/set-selected-text-range-after-newline.html (249694 => 249695)


--- branches/safari-608-branch/LayoutTests/accessibility/set-selected-text-range-after-newline.html	2019-09-10 03:19:45 UTC (rev 249694)
+++ branches/safari-608-branch/LayoutTests/accessibility/set-selected-text-range-after-newline.html	2019-09-10 03:19:48 UTC (rev 249695)
@@ -18,6 +18,7 @@
         var text = accessibilityController.focusedElement;
         text.setSelectedTextRange(5, 0);
         shouldBecomeEqual("text.selectedTextRange", "'{5, 0}'", function() {
+            // Insert a linebreak between "hello" and "world".
             text.replaceTextInRange("\n", 5, 0);
 
             var t = text.stringForRange(0, 11);
@@ -26,11 +27,21 @@
 
             text.setSelectedTextRange(6, 0);
             shouldBecomeEqual("text.selectedTextRange", "'{6, 0}'", function() {
-                var t = text.stringForRange(6, 5);
+                // Insert another linebreak before "world".
+                text.replaceTextInRange("\n", 6, 0);
+
+                var t = text.stringForRange(0, 12);
                 t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
-                debug("The text after the newline should be world: " + t);
+                debug("There must be two [newline] between hello and world: " + t);
 
-                finishJSTest();
+                text.setSelectedTextRange(7, 0);
+                shouldBecomeEqual("text.selectedTextRange", "'{7, 0}'", function() {
+                    var t = text.stringForRange(7, 5);
+                    t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
+                    debug("The text after the newline should be world: " + t);
+
+                    finishJSTest();
+                });
             });
         });
     }

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (249694 => 249695)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-09-10 03:19:45 UTC (rev 249694)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-09-10 03:19:48 UTC (rev 249695)
@@ -1,5 +1,56 @@
 2019-09-09  Kocsen Chung  <kocsen_ch...@apple.com>
 
+        Cherry-pick r249565. rdar://problem/55113261
+
+    AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
+    https://bugs.webkit.org/show_bug.cgi?id=201518
+    <rdar://problem/54835122>
+    
+    Patch by Andres Gonzalez <andresg...@apple.com> on 2019-09-06
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebCore:
+    
+    Test: accessibility/set-selected-text-range-after-newline.html
+    
+    In the case of an empty line, the CharacterIterator range start and end
+    were not equal, thus we were not advancing the iterator and returning
+    the iterator range end, which is not correct. With this change we are
+    always advancing the iterator if its text is just '\n'. This covers all
+    the cases we fixed before plus empty lines.
+    
+    * editing/Editing.cpp:
+    (WebCore::visiblePositionForIndexUsingCharacterIterator):
+    
+    LayoutTests:
+    
+    Extended this test to set the selection range passed an empty line.
+    * accessibility/set-selected-text-range-after-newline-expected.txt:
+    * accessibility/set-selected-text-range-after-newline.html:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-09-06  Andres Gonzalez  <andresg...@apple.com>
+
+            AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
+            https://bugs.webkit.org/show_bug.cgi?id=201518
+            <rdar://problem/54835122>
+
+            Reviewed by Ryosuke Niwa.
+
+            Test: accessibility/set-selected-text-range-after-newline.html
+
+            In the case of an empty line, the CharacterIterator range start and end
+            were not equal, thus we were not advancing the iterator and returning
+            the iterator range end, which is not correct. With this change we are
+            always advancing the iterator if its text is just '\n'. This covers all
+            the cases we fixed before plus empty lines.
+
+            * editing/Editing.cpp:
+            (WebCore::visiblePositionForIndexUsingCharacterIterator):
+
+2019-09-09  Kocsen Chung  <kocsen_ch...@apple.com>
+
         Cherry-pick r249534. rdar://problem/55183098
 
     AX: children cache are not re-computed if tab index is removed

Modified: branches/safari-608-branch/Source/WebCore/editing/Editing.cpp (249694 => 249695)


--- branches/safari-608-branch/Source/WebCore/editing/Editing.cpp	2019-09-10 03:19:45 UTC (rev 249694)
+++ branches/safari-608-branch/Source/WebCore/editing/Editing.cpp	2019-09-10 03:19:48 UTC (rev 249695)
@@ -1122,14 +1122,11 @@
     CharacterIterator it(range.get());
     it.advance(index - 1);
 
-    if (!it.atEnd() && it.text()[0] == '\n') {
+    if (!it.atEnd() && it.text().length() == 1 && it.text()[0] == '\n') {
         // FIXME: workaround for collapsed range (where only start position is correct) emitted for some emitted newlines.
-        auto iteratorRange = it.range();
-        if (iteratorRange->startPosition() == iteratorRange->endPosition()) {
-            it.advance(1);
-            if (!it.atEnd())
-                return VisiblePosition(it.range()->startPosition());
-        }
+        it.advance(1);
+        if (!it.atEnd())
+            return VisiblePosition(it.range()->startPosition());
     }
 
     return { it.atEnd() ? range->endPosition() : it.range()->endPosition(), UPSTREAM };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to