⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249695 in webkit


Ignore:
Timestamp:
Sep 9, 2019, 8:19:48 PM (7 years ago)
Author:
Alan Coon
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 <Andres Gonzalez> 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

Location:
branches/safari-608-branch
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608-branch/LayoutTests/ChangeLog

    r249694 r249695  
     12019-09-09  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r249565. rdar://problem/55113261
     4
     5    AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
     6    https://bugs.webkit.org/show_bug.cgi?id=201518
     7    <rdar://problem/54835122>
     8   
     9    Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-09-06
     10    Reviewed by Ryosuke Niwa.
     11   
     12    Source/WebCore:
     13   
     14    Test: accessibility/set-selected-text-range-after-newline.html
     15   
     16    In the case of an empty line, the CharacterIterator range start and end
     17    were not equal, thus we were not advancing the iterator and returning
     18    the iterator range end, which is not correct. With this change we are
     19    always advancing the iterator if its text is just '\n'. This covers all
     20    the cases we fixed before plus empty lines.
     21   
     22    * editing/Editing.cpp:
     23    (WebCore::visiblePositionForIndexUsingCharacterIterator):
     24   
     25    LayoutTests:
     26   
     27    Extended this test to set the selection range passed an empty line.
     28    * accessibility/set-selected-text-range-after-newline-expected.txt:
     29    * accessibility/set-selected-text-range-after-newline.html:
     30   
     31    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     32
     33    2019-09-06  Andres Gonzalez  <andresg_22@apple.com>
     34
     35            AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
     36            https://bugs.webkit.org/show_bug.cgi?id=201518
     37            <rdar://problem/54835122>
     38
     39            Reviewed by Ryosuke Niwa.
     40
     41            Extended this test to set the selection range passed an empty line.
     42            * accessibility/set-selected-text-range-after-newline-expected.txt:
     43            * accessibility/set-selected-text-range-after-newline.html:
     44
    1452019-09-09  Kocsen Chung  <kocsen_chung@apple.com>
    246
  • branches/safari-608-branch/LayoutTests/accessibility/set-selected-text-range-after-newline-expected.txt

    r245912 r249695  
    11hello
     2
    23world
    34PASS text.selectedTextRange became '{5, 0}'
    45There must be only one [newline] between hello and world: hello[newline]world
    56PASS text.selectedTextRange became '{6, 0}'
     7There must be two [newline] between hello and world: hello[newline][newline]world
     8PASS text.selectedTextRange became '{7, 0}'
    69The text after the newline should be world: world
    710PASS successfullyParsed is true
  • branches/safari-608-branch/LayoutTests/accessibility/set-selected-text-range-after-newline.html

    r245912 r249695  
    1919        text.setSelectedTextRange(5, 0);
    2020        shouldBecomeEqual("text.selectedTextRange", "'{5, 0}'", function() {
     21            // Insert a linebreak between "hello" and "world".
    2122            text.replaceTextInRange("\n", 5, 0);
    2223
     
    2728            text.setSelectedTextRange(6, 0);
    2829            shouldBecomeEqual("text.selectedTextRange", "'{6, 0}'", function() {
    29                 var t = text.stringForRange(6, 5);
     30                // Insert another linebreak before "world".
     31                text.replaceTextInRange("\n", 6, 0);
     32
     33                var t = text.stringForRange(0, 12);
    3034                t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
    31                 debug("The text after the newline should be world: " + t);
     35                debug("There must be two [newline] between hello and world: " + t);
    3236
    33                 finishJSTest();
     37                text.setSelectedTextRange(7, 0);
     38                shouldBecomeEqual("text.selectedTextRange", "'{7, 0}'", function() {
     39                    var t = text.stringForRange(7, 5);
     40                    t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
     41                    debug("The text after the newline should be world: " + t);
     42
     43                    finishJSTest();
     44                });
    3445            });
    3546        });
  • branches/safari-608-branch/Source/WebCore/ChangeLog

    r249694 r249695  
     12019-09-09  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r249565. rdar://problem/55113261
     4
     5    AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
     6    https://bugs.webkit.org/show_bug.cgi?id=201518
     7    <rdar://problem/54835122>
     8   
     9    Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-09-06
     10    Reviewed by Ryosuke Niwa.
     11   
     12    Source/WebCore:
     13   
     14    Test: accessibility/set-selected-text-range-after-newline.html
     15   
     16    In the case of an empty line, the CharacterIterator range start and end
     17    were not equal, thus we were not advancing the iterator and returning
     18    the iterator range end, which is not correct. With this change we are
     19    always advancing the iterator if its text is just '\n'. This covers all
     20    the cases we fixed before plus empty lines.
     21   
     22    * editing/Editing.cpp:
     23    (WebCore::visiblePositionForIndexUsingCharacterIterator):
     24   
     25    LayoutTests:
     26   
     27    Extended this test to set the selection range passed an empty line.
     28    * accessibility/set-selected-text-range-after-newline-expected.txt:
     29    * accessibility/set-selected-text-range-after-newline.html:
     30   
     31    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     32
     33    2019-09-06  Andres Gonzalez  <andresg_22@apple.com>
     34
     35            AccessibilityRenderObject::setSelectedTextRange fails to set the selection passed an empty line.
     36            https://bugs.webkit.org/show_bug.cgi?id=201518
     37            <rdar://problem/54835122>
     38
     39            Reviewed by Ryosuke Niwa.
     40
     41            Test: accessibility/set-selected-text-range-after-newline.html
     42
     43            In the case of an empty line, the CharacterIterator range start and end
     44            were not equal, thus we were not advancing the iterator and returning
     45            the iterator range end, which is not correct. With this change we are
     46            always advancing the iterator if its text is just '\n'. This covers all
     47            the cases we fixed before plus empty lines.
     48
     49            * editing/Editing.cpp:
     50            (WebCore::visiblePositionForIndexUsingCharacterIterator):
     51
    1522019-09-09  Kocsen Chung  <kocsen_chung@apple.com>
    253
  • branches/safari-608-branch/Source/WebCore/editing/Editing.cpp

    r248069 r249695  
    11231123    it.advance(index - 1);
    11241124
    1125     if (!it.atEnd() && it.text()[0] == '\n') {
     1125    if (!it.atEnd() && it.text().length() == 1 && it.text()[0] == '\n') {
    11261126        // FIXME: workaround for collapsed range (where only start position is correct) emitted for some emitted newlines.
    1127         auto iteratorRange = it.range();
    1128         if (iteratorRange->startPosition() == iteratorRange->endPosition()) {
    1129             it.advance(1);
    1130             if (!it.atEnd())
    1131                 return VisiblePosition(it.range()->startPosition());
    1132         }
     1127        it.advance(1);
     1128        if (!it.atEnd())
     1129            return VisiblePosition(it.range()->startPosition());
    11331130    }
    11341131
Note: See TracChangeset for help on using the changeset viewer.