Closed
Bug 783846
Opened 12 years ago
Closed 10 years ago
firefox android won't allow user to paste clipboard content into a contenteditable=true element (e.g. <div>)
Categories
(Firefox for Android Graveyard :: Text Selection, defect, P5)
Tracking
(firefox15 affected, firefox16 affected, firefox17 affected, firefox39 fixed, relnote-firefox 39+, fennec+)
RESOLVED
FIXED
Firefox 39
People
(Reporter: nirvn.asia, Assigned: miketaylr)
References
()
Details
Attachments
(4 files, 9 obsolete files)
386 bytes,
text/html
|
Details | |
2.96 KB,
patch
|
wesj
:
review+
|
Details | Diff | Splinter Review |
5.59 KB,
patch
|
wesj
:
review+
capella
:
feedback+
|
Details | Diff | Splinter Review |
1.44 KB,
patch
|
miketaylr
:
review+
|
Details | Diff | Splinter Review |
The summary is pretty self explanatory. Firefox for Android doesn't offer any way to paste clipboard content into a contenteditable=true element. That's a pretty substantial implementation issue.
Reporter | ||
Comment 1•12 years ago
|
||
To reproduce issue:
1. load attached test case
2. hold touch within the <div> element
3. witness the absence of the "paste" feature
(you can verify that the <div> element has the contenteditable=true tag by clicking on the <div> and write stuff in it through keyboard)
Updated•12 years ago
|
Attachment #653132 -
Attachment mime type: text/plain → text/html
Updated•12 years ago
|
Status: UNCONFIRMED → NEW
tracking-fennec: --- → ?
status-firefox15:
--- → affected
status-firefox16:
--- → affected
status-firefox17:
--- → affected
Ever confirmed: true
OS: Linux → Android
Hardware: x86 → ARM
Comment 2•12 years ago
|
||
Additional note here, text-selection on any value wont also allow for the copying operation through tap or context-menu.
Updated•12 years ago
|
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
Comment 4•12 years ago
|
||
I dont think this is dupe; <textarea>'s work fine.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Reporter | ||
Comment 5•12 years ago
|
||
This is not a duplicate. I tried using a nightly build with bug 780906 applied and the problem is still present.
As Aaron mentioned, copying text to clipboard within contenteditable=true div also fails.
Reporter | ||
Comment 6•12 years ago
|
||
(I meant problem is still present with contenteditable=true div while <textarea> works fine)
Reporter | ||
Comment 7•12 years ago
|
||
Pasting into contenteditable enabled div working fine on iOS, should this bug be flagged with a parity keyword?
Comment 8•12 years ago
|
||
I take it, stock Android works? In that case we can whiteboard add [parity-stock]. What about Chrome ([parity-chrome])?
Updated•12 years ago
|
Status: REOPENED → NEW
Comment 9•12 years ago
|
||
Sriram - Can you look into why we don't get a context menu?
Assignee: nobody → sriram
tracking-fennec: ? → 17+
Updated•12 years ago
|
tracking-fennec: 17+ → +
Updated•10 years ago
|
Assignee: sriram.mozilla → nobody
Mentor: markcapella
Assignee | ||
Comment 12•10 years ago
|
||
I spent some time looking at this last night,
In http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/SelectionHandler.js#629, the paste actionbar action is never added because isElementEditableText[1] doesn't consider contenteditable elements as editable (or designMode documents).
Fixing that and we get paste UI, but you have to add some execCommand code for non-nsIDOMNSEditableElement elements in the action (handler? method?), i.e., contenteditable stuff to get it to actually paste.
I noticed cut doesn't support contenteditable either, it assumes a value property on aElement[2], so it would need some execCommand support as well.
Mark, would you suggest I open another bug for cut or is it OK to lump both fixes in this bug?
[1] http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/SelectionHandler.js#796
[2] http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/SelectionHandler.js#578
Assignee: nobody → miket
Comment 13•10 years ago
|
||
I wouldn't think a second bug is required. We could ask that the solution be provided here in separate small patches though.
Flags: needinfo?(markcapella)
Updated•10 years ago
|
Component: General → Text Selection
Assignee | ||
Comment 14•10 years ago
|
||
Thanks. Will split the patches.
Assignee | ||
Comment 15•10 years ago
|
||
Assignee | ||
Comment 16•10 years ago
|
||
Assignee | ||
Comment 17•10 years ago
|
||
Assignee | ||
Comment 18•10 years ago
|
||
Here's the simple test page I was using, https://miketaylr.com/bzla/951716.html.
Range selection needs some work in contenteditable, but these patches fix CUT and PASTE (and the 3rd one fixes a billion null pointer errors when moving a range inside of contentEditable.
Comment 19•10 years ago
|
||
Comment on attachment 8519065 [details] [diff] [review]
783846-1.patch
Looks good in theory :-) I didn't dig in and will be mostly away for the next month or so ... kicking over to wesj for r? as he's a proper module peer
Attachment #8519065 -
Flags: review?(wjohnston)
Attachment #8519065 -
Flags: review?(markcapella)
Attachment #8519065 -
Flags: feedback+
Comment 20•10 years ago
|
||
Comment on attachment 8519066 [details] [diff] [review]
783846-2.patch
also to wesj
Attachment #8519066 -
Flags: review?(wjohnston)
Attachment #8519066 -
Flags: review?(markcapella)
Attachment #8519066 -
Flags: feedback+
Comment 21•10 years ago
|
||
Comment on attachment 8519067 [details] [diff] [review]
783846-3.patch
Also
Attachment #8519067 -
Flags: review?(wjohnston)
Attachment #8519067 -
Flags: review?(markcapella)
Attachment #8519067 -
Flags: feedback+
Assignee | ||
Comment 22•10 years ago
|
||
Cool, no worries.
Comment 23•10 years ago
|
||
Comment on attachment 8519065 [details] [diff] [review]
783846-1.patch
Review of attachment 8519065 [details] [diff] [review]:
-----------------------------------------------------------------
These are nice fixes! It shouldn't be hard to write some simple tests for them. Would you mind? We already do some basic tests for textSelection code here:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/tests/roboextender/testSelectionHandler.html?force=1#29
The framework is a little ad-hoc there, but you'd basically add a function to that list of promises. Even a simple function would be nice. i.e.:
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
clipboard.copyString("Test text", document);
let elements = document.querySelectorAll("thingsToTest");
var promises = [];
for (var i = 0; i < elements.length; i++) {
SelectionHandler.PASTE.action(elements[i]);
if (elements[i].hasAttribute("passing")) {
promises.push(is(elements[i].value, "Test text", "Pasted correctly"));
promises.push(ok(SelectionHandler.isElementEditableText(elements[i]), "Element is editable");
} else {
promises.push(isnot(elements[i].value, "Test text", "Paste failed correctly"));
promises.push(ok(!SelectionHandler.isElementEditableText(elements[i]), "Element is not editable");
}
}
return Promise.all(promises);
designMode might be a bit more work...
::: mobile/android/chrome/content/SelectionHandler.js
@@ +795,5 @@
>
> isElementEditableText: function (aElement) {
> return (((aElement instanceof HTMLInputElement && aElement.mozIsTextField(false)) ||
> + (aElement instanceof HTMLTextAreaElement)) && !aElement.readOnly) ||
> + aElement.contentEditable == "true" || aElement.ownerDocument.designMode == "on";
:( Ouch
Attachment #8519065 -
Flags: review?(wjohnston) → review+
Assignee | ||
Comment 24•10 years ago
|
||
(In reply to Wesley Johnston (:wesj) from comment #23)
> It shouldn't be hard to write some simple tests for them. Would you mind?
Oh yeah, cool. Will put something together.
> > isElementEditableText: function (aElement) {
> > return (((aElement instanceof HTMLInputElement && aElement.mozIsTextField(false)) ||
> > + (aElement instanceof HTMLTextAreaElement)) && !aElement.readOnly) ||
> > + aElement.contentEditable == "true" || aElement.ownerDocument.designMode == "on";
>
> :( Ouch
Heh, yeah.
Comment 25•10 years ago
|
||
Comment on attachment 8519066 [details] [diff] [review]
783846-2.patch
Review of attachment 8519066 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/chrome/content/SelectionHandler.js
@@ +580,5 @@
> + if (aElement instanceof Ci.nsIDOMNSEditableElement) {
> + aElement.value = aElement.value.substring(0, start) + aElement.value.substring(end);
> + } else {
> + // Handle contentEditable and designMode cutting.
> + aElement.textContent = aElement.textContent.substring(0, start) + aElement.textContent.substring(end);
I have a feeling this breaks if the selection covers multiple nodes. I have a feeling our old code doesn't handle that very well either (although since it was limited to textboxes, maybe that wasn't an issue).
I think we should probably try to get the editor and call cut() on it here anyway. Actually, I see editor has a canCut(). Maybe we should use that below... I feel a bit bad we didn't use it more originally here.
Attachment #8519066 -
Flags: review?(wjohnston) → review-
Updated•10 years ago
|
Attachment #8519067 -
Flags: review?(wjohnston) → review+
Assignee | ||
Comment 26•10 years ago
|
||
(In reply to Wesley Johnston (:wesj) from comment #25)
> I think we should probably try to get the editor and call cut() on it here
> anyway. Actually, I see editor has a canCut(). Maybe we should use that
> below... I feel a bit bad we didn't use it more originally here.
Now that I read through http://mxr.mozilla.org/mozilla-central/source/editor/nsIEditor.idl, we can simplify isElementEditableText with editor.isDocumentEditable and editor.isSelectionEditable as well.
Assignee | ||
Comment 27•10 years ago
|
||
Small status update (and wow, a month goes by really quickly): I spent some time on tests yesterday but am struggling with contentEditable failing (though working manually) the paste tests based on Comment 23.
Will keep poking at it this weekend.
Assignee | ||
Comment 28•10 years ago
|
||
Attachment #8519065 -
Attachment is obsolete: true
Attachment #8519066 -
Attachment is obsolete: true
Attachment #8519067 -
Attachment is obsolete: true
Assignee | ||
Comment 29•10 years ago
|
||
So I'm punting on getting "cut" to work without using textContent string slicing--nsIEditor just doesn't want to cooperate with me. I'll open another bug to come back to that one.
So here's the two patches related to paste, including tests. Also punting on designMode because I couldn't get any of my tests to pass (and we probably don't need this for mobile compat--at least I don't know of any open bugs).
Assignee | ||
Comment 30•10 years ago
|
||
Crap. Forgot to convert to hg patches. >_<
Attachment #8537395 -
Attachment is obsolete: true
Assignee | ||
Comment 31•10 years ago
|
||
Updated•10 years ago
|
Attachment #8537401 -
Flags: review?(wjohnston) → review+
Updated•10 years ago
|
Attachment #8537402 -
Flags: review?(wjohnston) → review+
Assignee | ||
Comment 34•10 years ago
|
||
I don't have rights to push to try servers. Wes could you help please?
Comment 35•10 years ago
|
||
(In reply to Mike Taylor [:miketaylr] from comment #34)
> I don't have rights to push to try servers. Wes could you help please?
You should request L1 commit access! I'll vouch for you.
https://www.mozilla.org/en-US/about/governance/policies/commit/
Assignee | ||
Comment 36•10 years ago
|
||
Oh, cool. Thanks! :)
Comment 37•10 years ago
|
||
Flags: needinfo?(wjohnston)
Comment 38•10 years ago
|
||
Checking in w/Mike ... or you still pursuing this?
We've had some changes in that test recently, you may find this patch bit-rotted.
Assignee | ||
Comment 39•10 years ago
|
||
Holy smokes time goes by fast. Yeah, I'll investigate what is up with the try run that Margaret pasted (rebasing first) in the next few days. Thanks for the ping.
Comment 40•10 years ago
|
||
Oh sure, I realized I'm still listed as "mentor" :)
I can't believe you don't have l1 access, seems like you've done your share of bugs !!! If you need try push again or anything, I'm happy to help.
Heh - if you'd rather, I can drop off as mentor and quit nagging you :-D
Assignee | ||
Comment 41•10 years ago
|
||
Ah thanks. I actually got level 1 taken care of just around the new year. ^_^ Still learning the ropes of try syntax and figuring out all that related stuff.
Assignee | ||
Comment 42•10 years ago
|
||
OK, rebased patches (and fixed conflict) and pushed again to try to see what (if anything) changed: https://treeherder.mozilla.org/#/jobs?repo=try&revision=d7efe22a18fc
Assignee | ||
Comment 43•10 years ago
|
||
Try servers are green, uploading rebased patches for checkin.
Attachment #8537389 -
Attachment is obsolete: true
Attachment #8537402 -
Attachment is obsolete: true
Assignee | ||
Comment 44•10 years ago
|
||
Attachment #8537401 -
Attachment is obsolete: true
Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Comment 45•10 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/1a29df76bdc8
https://hg.mozilla.org/integration/fx-team/rev/c909641ec171
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
Comment 46•10 years ago
|
||
Backed out for testSelectionHandler robocop failures. Not sure why you specified only a subset of them in your Try push instead of running all of them?
https://hg.mozilla.org/integration/fx-team/rev/a22f43770da8
https://treeherder.mozilla.org/logviewer.html#?job_id=1885897&repo=fx-team
Assignee | ||
Comment 47•10 years ago
|
||
Sorry about that--still learning the ropes of try syntax. Didn't realize I had excluded some robocop tests. Will investigate.
Assignee | ||
Comment 48•10 years ago
|
||
Update: unsure why the tests are failing now when they weren't before. Will investigate a bit more next week. Also, relieving Mark of mentor duty. :)
Mentor: markcapella
Assignee | ||
Comment 49•10 years ago
|
||
> Error in selection test TypeError: this._contentWindow is null
This was likely due to passing in <input type=button> to the PASTE action. SelectionHandler._contentWindow is never set for type=button inputs due to the early return in SelectionHandler.startSelection.
So I've updated my tests to account for this and cleaned up some bit-rot. Also prevent the CUT action from handling contentEditable elements until someone tackles Bug 1112276.
Let's try again: https://treeherder.mozilla.org/#/jobs?repo=try&revision=f647f4ce4a59
Assignee | ||
Comment 50•10 years ago
|
||
Not much has changed since the first r+'d patch, except for disallowing CUT for contentEditable and using the isContentEditable property (which I just learned about, hey).
Attachment #8558923 -
Attachment is obsolete: true
Assignee | ||
Comment 51•10 years ago
|
||
Assignee | ||
Comment 52•10 years ago
|
||
Carrying forward r+ on this one.
Assignee | ||
Updated•10 years ago
|
Attachment #8558924 -
Attachment is obsolete: true
Assignee | ||
Updated•10 years ago
|
Whiteboard: [fixed-in-fx-team]
Updated•10 years ago
|
Attachment #8576469 -
Flags: review?(wjohnston) → review+
Comment 53•10 years ago
|
||
Comment on attachment 8576473 [details] [diff] [review]
783846-Part-2.patch
Review of attachment 8576473 [details] [diff] [review]:
-----------------------------------------------------------------
These look good. Mark's been doing a lot of work here, so mostly want to make sure he's aware of these changes (but feel free to review them if you have time quickly :))
Attachment #8576473 -
Flags: review?(wjohnston)
Attachment #8576473 -
Flags: review+
Attachment #8576473 -
Flags: feedback?(markcapella)
Assignee | ||
Comment 54•10 years ago
|
||
Thanks Wes!
Comment 55•10 years ago
|
||
Comment on attachment 8576473 [details] [diff] [review]
783846-Part-2.patch
Review of attachment 8576473 [details] [diff] [review]:
-----------------------------------------------------------------
Yep :) I'm good with wes approval ... was watching and no impact to my plans so \o/
Attachment #8576473 -
Flags: feedback?(markcapella) → feedback+
Assignee | ||
Comment 56•10 years ago
|
||
Sweet, thanks! Let's try checkin-needed again.
Keywords: checkin-needed
Comment 57•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/7a58fbd76acd
https://hg.mozilla.org/mozilla-central/rev/1d9b1d65a77c
https://hg.mozilla.org/mozilla-central/rev/c37984bc95db
Status: NEW → RESOLVED
Closed: 12 years ago → 10 years ago
status-firefox39:
--- → fixed
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 39
Comment 59•10 years ago
|
||
Release Note Request (optional, but appreciated)
[Why is this notable]: It's nice that this will work now.
[Suggested wording]: New: Paste Android clipboard content into web content
[Links (documentation, blog post, etc)]: Mike, want to write a post about this? Or is there one already?
relnote-firefox:
--- → 39+
Flags: needinfo?(miket)
Assignee | ||
Comment 60•10 years ago
|
||
I was planning on writing something up about this on my own blog this afternoon--will paste the link in here when it's ready.
Assignee | ||
Comment 61•10 years ago
|
||
So um, paste in contenteditable isn't very exciting so I spiced it up a little bit here: https://miketaylr.com/posts/2015/03/contenteditable-paste.html
Maybe using "Paste Android clipboard content into editable web content" would be better? That way it doesn't sound like we just added paste for input elements, etc.
Comment 62•10 years ago
|
||
Your blog posts bring all the android pasteable content to the... ummm.... editable yard!
Relnoted for 39 with your suggested wording and link from comment 39.
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•