Bug 210677

Summary: REGRESSION (r249160): Deleting newline after pasting text ending in a newline results in a discontinuity
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: TextAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: dbates, esprehn+autocc, ews-watchlist, glenn, jonlee, koivisto, kondapallykalyan, mmaxfield, pdr, webkit-bug-importer, wenson_hsieh, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: data:text/html,%3ctextarea%3e%3c/textarea%3e
See Also: https://bugs.webkit.org/show_bug.cgi?id=213336
Bug Depends on: 201181    
Bug Blocks:    
Attachments:
Description Flags
patch
zalan: review+
patch
none
patch none

Description David Kilzer (:ddkilzer) 2020-04-17 15:55:02 PDT
Summary:
Pasting text that ends with a newline, then immediately deleting that newline, results in a discontinuity in a <textarea> element.

Steps to Reproduce
1. Load URL:  <data:text/html,%3ctextarea%3e%3c/textarea%3e>
2. Resize.
3. Type in "lorem\n\n\n\nipsum\n" (hit the Enter key for each newline).
4. Select "lorem" plus its ending newline and copy to pasteboard.
5. Position insertion bar on line 3 (blank line between "lorem and ipsum").
6. Paste text.
7. Immediately hit Delete key.

Expected Results:
Blank line should be deleted after pasting "lorem\n".

Actual Results:
Blank is deleted, but the text is not redrawn with the line removed.  Moving the insertion bar with left/right arrow keys will show it jump over the deleted newline.  (Using up/down arrow keys will actually not move the insertion bar past the deleted newline.)

Regression:
Via bisection, this regressed in r249160 which was the fix for Bug 201181:

Bug 201181: InlineTextBox::end() should return first-past-end offset
​<https://bugs.webkit.org/show_bug.cgi?id=201181>
<rdar://problem/54758922>
<https://trac.webkit.org/changeset/249160/webkit>
Comment 1 Radar WebKit Bug Importer 2020-04-17 15:55:21 PDT
<rdar://problem/61954169>
Comment 2 David Kilzer (:ddkilzer) 2020-04-17 16:06:31 PDT
Forcing a repaint in Safari does not “fix” the discontinuity.

You can fix it by deleting the next blank line after the discontinuity (which makes the deletion jump up two lines), then hit Enter again to make it appear the way it should have originally.
Comment 3 Jon Lee 2020-04-17 16:50:05 PDT
At the end of the second "lorem" line, I can't press the down key to go to the next line.
Comment 4 David Kilzer (:ddkilzer) 2020-04-18 13:35:11 PDT
(In reply to Jon Lee from comment #3)
> At the end of the second "lorem" line, I can't press the down key to go to
> the next line.

As noted in Comment #0:

> (Using up/down arrow keys will actually not move the insertion bar past the deleted newline.)

Part of the behavior of this bug.
Comment 5 Antti Koivisto 2020-04-22 08:11:01 PDT
Created attachment 397191 [details]
patch
Comment 6 Antti Koivisto 2020-04-22 09:34:48 PDT
Created attachment 397208 [details]
patch
Comment 7 Antti Koivisto 2020-04-22 10:01:03 PDT
Created attachment 397213 [details]
patch
Comment 8 EWS 2020-04-22 12:24:59 PDT
Committed r260528: <https://trac.webkit.org/changeset/260528>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397213 [details].