Bug 207724 - [iOS] ASSERTION FAILED: index == indexComputedByVisiblePosition in HTMLTextFormControlElement::indexForPosition()
Summary: [iOS] ASSERTION FAILED: index == indexComputedByVisiblePosition in HTMLTextFo...
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: iPhone / iPad iOS 13
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on: 205706
Blocks:
  Show dependency treegraph
 
Reported: 2020-02-13 15:01 PST by Daniel Bates
Modified: 2022-02-09 10:14 PST (History)
7 users (show)

See Also:


Attachments
Patch (2.64 KB, patch)
2020-02-13 15:10 PST, Daniel Bates
pvollan: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>