[Webkit-unassigned] [Bug 114063] New: Selection drag tracking code causes selection range to revert to incorrect state

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Apr 5 14:03:29 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=114063

           Summary: Selection drag tracking code causes selection range to
                    revert to incorrect state
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Unspecified
        OS/Version: Unspecified
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: HTML Editing
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: natevw at yahoo.com


Created an attachment (id=196677)
 --> (https://bugs.webkit.org/attachment.cgi?id=196677&action=review)
Example code that implements the splitText+workaround while logging selection state to console

To reproduce:
1. Implement some code that periodically splits a text node at the beginning of the current user-selected text
2. Said code will trigger https://bugs.webkit.org/show_bug.cgi?id=114041 and the selection will get cleared when the text is split. So store a copy of the selection range before splitting, and set it as the current selection after splitting.

Expected results:
3. Profit!

Actual results:
3. If a mouse drag causes the "start" of a selection range to change (i.e. the users is selecting by dragging in a https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#selections "backwards direction") the current range fixed in step #2 gets truncated at step #1's split point anyway.


I've attached a example and annotated console log that sort of shows this, but allow me to explain it here too:
backstory. I have some text "0123" displayed in my DOM, and I want to select the "12" part by dragging from the right of "2" to the left of "1"
1. [user] I select the "2" text by dragging across it right to left.
2. [code] My setInterval callback soon splits the original text node into two pieces  (in my real use caes this is so I can insert another node at the beginning of the selection)
3a. [code] Because this splitText has truncated the selection (i.e. https://bugs.webkit.org/show_bug.cgi?id=114041), I set it back to what it was — so far so good
3b. [user] As a user I don't notice anything, the "2" is still selected as I expect and of course I don't really see that the DOM now actually has the text split between two children  — so far so good
4. [user] As I continue dragging leftwards, however, to extend my selection to also include the "1" — as soon as I do so the "2" gets unselected as if step 3a never happened!

Hopefully this makes a little sense? This doesn't happen when using the keyboard (e.g. Shift+Left arrow) to make a backwards selection — the "reselect after splitText" workaround doesn't get undone. It almost seems as though the mouse tracking code is caching/modifying/applying its own selection state without regard to my JavaScript code's changes in the meantime.


Put another way, why in my attached demo is the behind-the-scenes text node splitting undetectable EXCEPT when I drag right to left?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list