Closed Bug 1112276 Opened 6 years ago Closed 5 years ago

"cut" should work for contentEditable selections

Categories

(Firefox for Android :: Text Selection, defect, P5)

x86
macOS
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: miketaylr, Assigned: miketaylr)

References

Details

Attachments

(1 file)

See Bug 783846, which covered paste not working. Cut should also be possible to get working.
Priority: -- → P5
See Also: → 783846
I noticed you can't use element.value to cut here
(contentEditable HTMLElements use nsHTMLEditor vs nsIEditor (iirc) ...)

http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/SelectionHandler.js?rev=7a58fbd76acd&mark=673-673#664

Switching to something along the lines of:
Selectionhandler.getSelection().deleteFromDocument();

Should work for editables (HTMLInputElement, HTMLTextAreaElement) and contentEditables.
Oh sweet. My first attempt was substring'ing textContent but I wasn't sure how that would behave across nodes, etc.
exactly! In one edge case, if the user has (apparently) selected all content by dragging the handle to the right edge of an editable, the focusNode can become the next node with an offset of 0 (-ish - there's more to that story where it can actually wind up as the parent node with an offset of 1).

If the container is an <input>, the #text node is an anonymous node of an anonymous parent div. For <textareas> there can be a terminating anonymous <br> inside the editable, and other weird-ness 

So that rats nest is best avoided :-D
Assignee: nobody → miket
Here's a patch that has cut working, but I ran into some problems with the Robocop tests failing (for reasons I don't understand yet). I probably won't have time to get back into this for a few weeks if some one wants to take over.
To be more clear, the tests that were failing were the tests I'm trying to write for "cut". Everything else passed.
Pruning some old bugs (part 2) either:
   ) obviated by new Core/Layout AccessibleCaret implementation in m-c and stable, targeted for 47.
   ) Or no longer being observable.

If you still see what you consider incorrect behaviour with the new version, please file a new bug targeted there, and attach a test-case or example link to help things :-)


Specific Note here: Works now, using test page: [0], and contenteditable fields on bottom (TAP ME TAP ME) etc.

 [0] https://www.dropbox.com/s/j5jcon30y8vda3u/test_bug988143.html?dl=0
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.