Add the possibility to check that the clipboard contains some pdfjs stuff
Categories
(Core :: DOM: Copy & Paste and Drag & Drop, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox106 | --- | fixed |
People
(Reporter: calixte, Assigned: calixte)
Details
Attachments
(1 file, 1 obsolete file)
We landed a patch in pdf.js:
https://github.com/mozilla/pdf.js/pull/15373
in order to allow to copy/cut/paste some annotations from a pdf to another.
We use a mime type for pdfjs:
https://github.com/mozilla/pdf.js/pull/15373/files#diff-e5ec9751980dd8449e7b036e02292ca16e34c3b6db368b014f2ea17ffb2da27bR501
In order to be able to update the context menu if there's something to paste, we need to know if the clipboard contains a transferable for application/pdfjs
(in using for example Services.clipboard.hasDataMatchingFlavors
).
But this mimetype isn't in the list because of bug 860857: the user defined mime types are put behind application/x-moz-custom-clipdata
(see https://searchfox.org/mozilla-central/rev/fa81b64fc1a339e2b2b1f6a8637a689916e13c4e/dom/events/DataTransfer.cpp#1076).
An idea could be to add a special mime application/x-moz-pdfjs
and associate it to a nullptr
in the transferable when application/pdfjs
is present and then check for this mime type when we need to update the context menu.
:enndeakin, what do you think ?
Comment 1•3 years ago
|
||
It would probably be easiest to just add application/pdfjs to the list of known formats so it doesn't end up in the custom formats list: https://searchfox.org/mozilla-central/rev/fa81b64fc1a339e2b2b1f6a8637a689916e13c4e/dom/events/DataTransfer.cpp#892
Assignee | ||
Comment 2•3 years ago
|
||
This way we can check that the clipboard contains some pdfjs data and
consequently we can update correctly the context menu when we're in
editing mode.
Assignee | ||
Comment 3•3 years ago
|
||
Assignee | ||
Updated•3 years ago
|
Comment 5•3 years ago
|
||
Do we want random websites to be able to use that format? Why didn't we use application/x-moz-pdfjs
instead?
Updated•3 years ago
|
Comment 6•3 years ago
|
||
bugherder |
Assignee | ||
Comment 7•3 years ago
|
||
(In reply to Tom Schuster [:evilpie] from comment #5)
Do we want random websites to be able to use that format?
I don't know. What are the drawbacks ?
Why didn't we use
application/x-moz-pdfjs
instead?
If I use in this format in pdf.js then it will be wrapped into a application/x-moz-custom-clipdata
in the clipboard but then I can't test if the clipboard contains some pdfjs data.
My initial idea was to check for application/pdfjs
in the transferable and if present then just add something like transferable->SetTransferData("application/x-moz-pdfjs", nullptr);
, this way the pdfjs data are still under application/x-moz-custom-clipdata
and I can check for the presence of application/x-moz-pdfjs
in the clipboard. FYI, I tested this idea and it was working as expected, the main advantage was to avoid to expose something but it slightly increased the complexity compared to the current patch.
Description
•