Closed Bug 1766860 Opened 2 years ago Closed 2 years ago

Revise the prefs for clipboard API

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, task)

task

Tracking

()

RESOLVED FIXED
102 Branch
Tracking Status
firefox102 --- fixed

People

(Reporter: edgar, Assigned: edgar)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Currently, dom.events.asyncClipboard.clipboardItem is used to control Clipboard.write and also ClipboardItem interface, and dom.events.asyncClipboard.read is used to control Clipboard.read only.

But exposing Clipboard.read will also need to expose ClipboardItem interface. And we plan to work on Clipboard.read first.

So in this bug, I would like to

  • Make dom.events.asyncClipboard.read controls both Clipboard.read and ClipboardItem interface.
  • Rename dom.events.asyncClipboard.clipboardItem to dom.events.asyncClipboard.write and make it only controls Clipboard.write().

In my opinion we should only expose ClipboardItem together with Clipboard.write. Clipboard.read will work even without exposing ClipboardItem directly.

But Clipboard.read do return a ClipboardItem instance, but there is no ClipboardItem interface exposed, which is not trivial. We could hide the constructor for Clipboard.write. WDYT?

But Clipboard.read do return a ClipboardItem instance, but there is no ClipboardItem interface exposed, which is not trivial.

I am not sure what you mean "is not trivial". Only partially exposing these features is of course far from ideal, but I think exposing ClipboardItem and not clipboard.write will lead to compatibility issues. When you say hide the constructor, would that mean "window.ClipboardItem" doesn't exist?

(In reply to Tom Schuster [:evilpie] from comment #3)

When you say hide the constructor, would that mean "window.ClipboardItem" doesn't exist?

I mean https://searchfox.org/mozilla-central/rev/86c98c486f03b598d0f80356b69163fd400ec8aa/dom/webidl/Clipboard.webidl#36-38 doesn't exist.
Note that once someone calls clipboard.read(), window.ClipboardItem will also be defined, I think it might because we create a ClipboardItem instance.

(In reply to Tom Schuster [:evilpie] from comment #3)

I think exposing ClipboardItem and not clipboard.write will lead to compatibility issues.

Could you elaborate why?

Flags: needinfo?(evilpies)

Because I think it's quite likely that code (like this) will assume that when ClipboardItem is available then clipboard.write is also available.

Flags: needinfo?(evilpies)

Okay, thanks. So give that there is already an example for that, then I think we should expose them all together.

Pushed by echen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fbf680efd6dc
Revise the prefs for clipboard API; r=evilpie,nika
Blocks: 1619251
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: