Bug 114041

Summary: Selection truncated after .splitText call
Product: WebKit Reporter: Nathan Vander Wilt <natevw>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ahmad.saleem792, ap, bfulgham, karlcow, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Simple demo showing the issue
none
Tweak the demo to show weird multiple selection effects
none
Video Recording - Chrome Canary 110 & Safari 16.1 on "Tweaked" testcase none

Nathan Vander Wilt
Reported 2013-04-05 10:44:06 PDT
Created attachment 196649 [details] Simple demo showing the issue When a text node within a selection is divided into two nodes by a call to .splitText, the window's selection is changed. This does not happen in Firefox or IE9 and seemingly should not happen according to the relevant specs (e.g. http://dom.spec.whatwg.org/#concept-text-split). To reproduce (see attached demo source as well): 1. Select some text within a text node (programmatically or via HID) 2. Programmatically split one of the text nodes Expected results: Original selection is still displayed in user interface. Actual results: Selection gets truncated! Workaround: Any range object referenced before the splitText call is correctly updated; if a this stored range is set the display does update. However in practice I am seeing as-yet undiagnosed issues with this workaround if the user is dragging from right to left to select the text.
Attachments
Simple demo showing the issue (1.31 KB, text/html)
2013-04-05 10:44 PDT, Nathan Vander Wilt
no flags
Tweak the demo to show weird multiple selection effects (2.68 KB, text/html)
2013-04-05 10:57 PDT, Nathan Vander Wilt
no flags
Video Recording - Chrome Canary 110 & Safari 16.1 on "Tweaked" testcase (21.54 MB, video/quicktime)
2022-11-17 11:58 PST, Ahmad Saleem
no flags
Nathan Vander Wilt
Comment 1 2013-04-05 10:57:00 PDT
Created attachment 196652 [details] Tweak the demo to show weird multiple selection effects Things get even stranger: it appears that the bug doesn't so much "truncate" the selection as it is *not* selecting the new text node. I.e. the result can be a multiple-selection looking thing that can't be represented by the single-selection-only W3C standard. What's even weirder is that this broken multiple selection effect persists even after calling `.selectAllChildren(parent)` on the selection after the text is split. See new attachment — click on the button repeatedly to randomly split text and the selection soon starts getting "holes" in it between a previous split and the most recent one.
Ahmad Saleem
Comment 2 2022-11-17 06:10:28 PST
I am able to reproduce this bug using "tweak" demo where clicking "button" multiple time show that the selection does get dropped and there are patches of text not selected while it is not the case in Chrome Canary 110 and Firefox Nightly 109. While in simple "Demo", Chrome Canary 110 and Safari 16.1 behave same and update selection to just "Here" after clicking button while Firefox Nightly 109 does not do anything. Changing status to "New". Thanks!
Ryosuke Niwa
Comment 3 2022-11-17 11:46:28 PST
Chrome behaves this way as well.
Ahmad Saleem
Comment 4 2022-11-17 11:58:13 PST
Created attachment 463591 [details] Video Recording - Chrome Canary 110 & Safari 16.1 on "Tweaked" testcase Just a video of what I am experiencing with "tweaked" testcase.
Note You need to log in before you can comment on or make changes to this bug.