Closed Bug 1708670 Opened 5 years ago Closed 5 years ago

nsIEditor.pasteTransferable won't insert image/png if nsITransaferable uses nsIInputStream

Categories

(Core :: DOM: Editor, defect, P2)

All
Unspecified
defect

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: m_kato, Assigned: m_kato)

References

Details

Attachments

(1 file)

I found this when I tried to use pasteTransferable for image keyboard support (https://developer.android.com/guide/topics/text/image-keyboard).

pasteTransferable initializes DataTransfer when using nsITransferable parameter.

https://searchfox.org/mozilla-central/rev/1ed1bb14eed9b3f27a94513387608436ea74c247/editor/libeditor/HTMLEditorDataTransfer.cpp#2083

But when mime type is image/png, this is recognized as KIND_FILE at here. So if using nsIInputStream, this fetches all data at
here. Then, when InsertObject tries fetching data from nsIInputStream, this stream of image/png is already EOF. So at finally, we cannot insert PNG image.

Summary: nsIEditor.pasteTransferable won't insert image/png if nsITransaferable has nsIInputStream → nsIEditor.pasteTransferable won't insert image/png if nsITransaferable uses nsIInputStream
Severity: -- → S3
Priority: -- → P2

editor.pastedTransferable cannot insert image/png when using nsITransaferable.

Although pastedTransferable stores DataTransfer in stack, when mime type is
image/png, DataTransfer fetches all data in
DataTransferItem::FillInExternalData then stores it as KIND_FILE.
It means that nsIInputStream in nsITransferable is already EOF.

So we should use InsertFromDataTransfer when internal data moves to
DataTransfer.

Pushed by m_kato@ga2.so-net.ne.jp: https://hg.mozilla.org/integration/autoland/rev/4da3a6002a66 nsIEditor.pasteTransferable won't insert image/png if nsITransaferable uses nsIInputStream. r=masayuki
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
Blocks: 1714496
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: