Bug 230594

Summary: Invalid browser selection after splitting a text node
Product: WebKit Reporter: James Toohey <james>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: cdumez, darin, rniwa, thespyder, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Intel)   
OS: macOS 10.15   
Bug Depends on:    
Bug Blocks: 249528    
Attachments:
Description Flags
Replication HTML file none

Description James Toohey 2021-09-21 21:14:28 PDT
Created attachment 438917 [details]
Replication HTML file

Hi team,

As per the spec, when splitting a text node, any live ranges that start or end in the node being split must have their respective nodes and offsets modified. 

https://dom.spec.whatwg.org/#concept-text-split (Important: Section 7)

In Safari 14 (and also in the newly released Safari 15 & Tech Preview), splitting a text node does not correctly adjust the selection to account for this:
- The offsets are not adjusted
- The nodes are not changed when appropriate

Please see the attached HTML file for a replication case. This works correctly in Firefox 92 and Chrome 93.
Comment 1 Sam Sneddon [:gsnedders] 2021-09-28 09:43:05 PDT
I kinda suspect this might be fixed by bug 220514 (live ranges in selection)? Though at least currently it appears regressed by live ranges in selection (even the initial selection is wrong).

Marking this is blocking, then others can debate whether that's fair. ;P
Comment 2 Radar WebKit Bug Importer 2021-09-28 21:15:14 PDT
<rdar://problem/83655114>
Comment 3 Ryosuke Niwa 2022-12-17 02:11:30 PST
Enabling live range selection doesn't fix this bug.