Bug 207724

Summary: [iOS] ASSERTION FAILED: index == indexComputedByVisiblePosition in HTMLTextFormControlElement::indexForPosition()
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebCore Misc.Assignee: Daniel Bates <dbates>
Status: ASSIGNED ---    
Severity: Normal CC: cdumez, esprehn+autocc, ews-watchlist, gyuyoung.kim, mifenton, pvollan, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: iPhone / iPad   
OS: iOS 13   
See Also: https://bugs.webkit.org/show_bug.cgi?id=128806
https://bugs.webkit.org/show_bug.cgi?id=207725
https://bugs.webkit.org/show_bug.cgi?id=205706
Bug Depends on: 205706    
Bug Blocks:    
Attachments:
Description Flags
Patch pvollan: review+

Description Daniel Bates 2020-02-13 15:01:57 PST
Steps to repro:

1. Visit <data:text/html,<input placeholder="placeholder" oninput="this.selectionStart">>
2. Tap field.
3. Press ‘h’ on the keyboard.
Comment 1 Daniel Bates 2020-02-13 15:05:08 PST
Assert is always incorrect because of FIXME in HTMLTextFormControlElement::indexForPosition(). Well, FIXME is correct:

[[
index = std::min(index, length); // FIXME: We shouldn't have to call innerTextValue() just to ignore the last LF. See finishText.
]]
<https://trac.webkit.org/browser/trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp?rev=256197#L652>


but doesn't explain why. innerTextValue() is wrong because it represents the AFTER insertion value of the field. But the passed position is BEFORE insertion. So, guaranteed mismatch if indexForPosition() is called when the text input event is dispatched.
Comment 2 Daniel Bates 2020-02-13 15:06:03 PST
I am just going to get rid of the assert because I would need to study the code to actually fix it up. The code has had the original FIXME since it was written in 2014!
Comment 3 Daniel Bates 2020-02-13 15:10:48 PST
Created attachment 390692 [details]
Patch
Comment 4 Per Arne Vollan 2020-02-13 15:11:42 PST
Comment on attachment 390692 [details]
Patch

R=me.
Comment 5 Daniel Bates 2020-02-13 15:19:44 PST
<rdar://problem/59435896>