Bug 41358 - Selection offset does not update when DOMCharacterDataModified fires
Summary: Selection offset does not update when DOMCharacterDataModified fires
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2010-06-29 09:57 PDT by Nikita Vasilyev
Modified: 2022-08-18 13:19 PDT (History)
6 users (show)

See Also:


Attachments
Reduction (952 bytes, text/html)
2010-06-29 09:57 PDT, Nikita Vasilyev
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2010-06-29 09:57:40 PDT
Created attachment 60031 [details]
Reduction

See reduction.

The problem is, both range.startOffset and range.endOffset have previously selected offset, while range.startContainer and range.endContainer are pointing to the actual (ie new) nodes. It makes impossible (?) to get actual selection within DOMCharacterDataModified event.

I've looked to the specs [1], [2] and didn't find any clarification what UA should actually do. But what they do now is not useful at all.

I compared Firefox 3.6.6 with WebKit. Firefox behaves slightly less wrong:
1) When pressing delete or backspace key, range.startOffset and range.endOffset actually match to the current selection
2) getSelection().isCollapsed is always false, no matter what was selected before


[1]: http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMCharacterDataModified
[2]: http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html
Comment 1 Ahmad Saleem 2022-06-02 21:47:42 PDT
I am still able to reproduce this bug using attached "reduction" in Safari 15.5 on macOS 12.4. It matches with Firefox Nightly 103 incorrect behavior where "caret" does not follow "Selection" and "typing". Chrome Canary 104 seems to have fixed this issue. Thanks!

It might have got fixed in Chrome's LayoutNg project since I was not able to find any relevant "FIXED" bug by using "range.startOffset" as search on Chrome's monorail. Thanks!