Closed Bug 1951225 Opened 8 months ago Closed 6 months ago

Make {Async}GetNativeClipboardData() more flexible to use

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: edgar, Assigned: edgar)

References

(Blocks 1 open bug)

Details

Attachments

(7 files)

Currently, nsIClipboardDataSnapshot.getData{Sync}() retrieves only the first available type of nsITransferable and throws an error if nsITransferable contains a type not in the flavor list. This behavior is primarily due to how each platform implements GetNativeClipboardData(). So when we would like to get data for multiple types, we would need to create a temporary nsITransferable contains only one type for each type that we want to load, e.g. https://searchfox.org/mozilla-central/rev/3b3c7a0c930a5451be3b4088ed795ce01ddf002e/editor/libeditor/EditorBase.cpp#7368-7402.

I think we could try to make nsIClipboardDataSnapshot.getData{Sync}() more flexible to use to support load all available type in nsITransferable and ignore the type if it doesn't in the available flavor list (instead of throwing an error).

In order to support this, we might need to modify the GetNativeClipboardData to make it more flexible to use as well, for example

Result<nsCOMPtr<nsISupports>, nsresult> GetNativeClipboardData(ClipboardType aWhichClipboard, const nsACString& aFlavor);

which takes a MIME type and returns the corresponding data if it is available. Then we could build the behavior we want on the top of it.

Blocks: 1938618
Assignee: nobody → echen
Attachment #9481245 - Attachment description: Bug 1951225 - Part 1: Introduce new GetNativeClipboardData; → WIP: Bug 1951225 - Part 1: Introduce new GetNativeClipboardData();

This should not change behavior.

Attachment #9481245 - Attachment description: WIP: Bug 1951225 - Part 1: Introduce new GetNativeClipboardData(); → WIP: Bug 1951225 - Part 1: Introduce new {Async}GetNativeClipboardData();
Attachment #9481245 - Attachment description: WIP: Bug 1951225 - Part 1: Introduce new {Async}GetNativeClipboardData(); → Bug 1951225 - Part 1: Introduce new {Async}GetNativeClipboardData();
Attachment #9481259 - Attachment description: WIP: Bug 1951225 - Part 2-1: Implement new GetNativeClipboardData() on cocoa widget; → Bug 1951225 - Part 2-1: Implement new GetNativeClipboardData() on cocoa widget;
Attachment #9481261 - Attachment description: WIP: Bug 1951225 - Part 2-2: Implement new GetNativeClipboardData() on headless widget; → Bug 1951225 - Part 2-2: Implement new GetNativeClipboardData() on headless widget;
Attachment #9481369 - Attachment description: WIP: Bug 1951225 - Part 2-3: Implement new GetNativeClipboardData() on gtk widget; → Bug 1951225 - Part 2-3: Implement new GetNativeClipboardData() on gtk widget;
Attachment #9481417 - Attachment description: WIP: Bug 1951225 - Part 2-4: Implement new GetNativeClipboardData() on windows widget; → Bug 1951225 - Part 2-4: Implement new GetNativeClipboardData() on windows widget;
Attachment #9481478 - Attachment description: WIP: Bug 1951225 - Part 2-5: Implement new GetNativeClipboardData() on geckoview; → Bug 1951225 - Part 2-5: Implement new GetNativeClipboardData() on geckoview;
Attachment #9481511 - Attachment description: WIP: Bug 1951225 - Part 3: Get rid of old {Async}GetNativeClipboardData() method; → Bug 1951225 - Part 3: Get rid of old {Async}GetNativeClipboardData() method;

To minimize the scope, I’m going to focus this bug on re-implementing {Async}GetNativeClipboardData() to make it more flexible to use. This should not change any existing behavior.

The actual changes to nsIClipboardDataSnapshot.getData{Sync}() — which will then support loading multiple types at once — will be moved to a separate bug.

Summary: Consider modifying nsIClipboardDataSnapshot.getData{Sync}() to support retrieving data for multiple types at once → Make {Async}GetNativeClipboardData() more flexible to use
Blocks: 1965097
No longer blocks: 1938618
Pushed by echen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1ee8a4635947 Part 1: Introduce new {Async}GetNativeClipboardData(); r=gstoll https://hg.mozilla.org/integration/autoland/rev/5841957d7906 Part 2-1: Implement new GetNativeClipboardData() on cocoa widget; r=mac-reviewers,bradwerth https://hg.mozilla.org/integration/autoland/rev/e572e8ae8990 Part 2-2: Implement new GetNativeClipboardData() on headless widget; r=spohl https://hg.mozilla.org/integration/autoland/rev/3341c9f1f236 Part 2-3: Implement new GetNativeClipboardData() on gtk widget; r=stransky https://hg.mozilla.org/integration/autoland/rev/df86f6e87596 Part 2-4: Implement new GetNativeClipboardData() on windows widget; r=win-reviewers,gstoll https://hg.mozilla.org/integration/autoland/rev/d8cd5b882ef9 Part 2-5: Implement new GetNativeClipboardData() on geckoview; r=geckoview-reviewers,m_kato https://hg.mozilla.org/integration/autoland/rev/ed97f54128e1 Part 3: Get rid of old {Async}GetNativeClipboardData() method; r=gstoll
Pushed by agoloman@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/83c2fa1515ec Revert Bug 1951225 - for causing failures @test_clipboard_cache_chrome.html.

Backed out for causing failures @test_clipboard_cache_chrome.html.

Flags: needinfo?(echen)
Flags: needinfo?(echen)
Pushed by pstanciu@mozilla.com: https://hg.mozilla.org/mozilla-central/rev/969f19c27623 Part 1: Introduce new {Async}GetNativeClipboardData(); r=gstoll https://hg.mozilla.org/mozilla-central/rev/faa6ec3fbf52 Part 2-1: Implement new GetNativeClipboardData() on cocoa widget; r=mac-reviewers,bradwerth https://hg.mozilla.org/mozilla-central/rev/ca1719d6d9f3 Part 2-2: Implement new GetNativeClipboardData() on headless widget; r=spohl https://hg.mozilla.org/mozilla-central/rev/e510f759b8fa Part 2-3: Implement new GetNativeClipboardData() on gtk widget; r=stransky https://hg.mozilla.org/mozilla-central/rev/53dbe1e6b485 Part 2-4: Implement new GetNativeClipboardData() on windows widget; r=win-reviewers,gstoll https://hg.mozilla.org/mozilla-central/rev/7bc5a6f9ee17 Part 2-5: Implement new GetNativeClipboardData() on geckoview; r=geckoview-reviewers,m_kato https://hg.mozilla.org/mozilla-central/rev/36d8024d7f3f Part 3: Get rid of old {Async}GetNativeClipboardData() method; r=gstoll
QA Whiteboard: [qa-triage-done-c141/b140]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: