Граф коммитов

70 Коммитов

Автор SHA1 Сообщение Дата
Edgar Chen 873b371e46 Bug 1863843 - nsBaseClipboard::GetData should handle unsupported clipboard type; r=stransky
By design, nsBaseClipboard should always pass valid clipboard type to native
implementation of each platform,

Differential Revision: https://phabricator.services.mozilla.com/D196833
2023-12-19 13:09:15 +00:00
Edgar Chen 1b518042e4 Bug 1777448 - Part 2: Suppress the paste context menu when the clipboard data originates from a same-origin page; r=nika
And don't allow new request being associated with existing pending request if
the requests are from different origin.

This patch also set proper principal to nsItransferable for clipboard write in
various cases,
- Copy image via context menu.
- Copy current selection via keyboard shortcut or context menu.
- Data is provided by script when copy operation is triggered via keyboard
  shortcut or context menu.
- Clipboard data is put via async clipboard.

Depends on D190761

Differential Revision: https://phabricator.services.mozilla.com/D190796
2023-12-08 07:08:42 +00:00
Edgar Chen 35aaa07f46 Bug 1777448 - Part 1: Don't not show paste contextmenu for background tab; r=nika,hsivonen
Displaying the paste context menu for background tabs can be surprising and
confusing for users, so we reject the request and don't allow it being associated
with existing pending request.

Depends on D190405

Differential Revision: https://phabricator.services.mozilla.com/D190761
2023-12-08 07:08:42 +00:00
Cristian Tuns 7d3f682145 Backed out 2 changesets (bug 1777448) for causing bc failures in /browser_navigator_clipboard_contextmenu_suppression.js CLOSED TREE
Backed out changeset 6dee3dce64ad (bug 1777448)
Backed out changeset 32841cae9b3b (bug 1777448)
2023-12-06 19:55:14 -05:00
Edgar Chen 2ddaf2e2da Bug 1777448 - Part 2: Suppress the paste context menu when the clipboard data originates from a same-origin page; r=nika
And don't allow new request being associated with existing pending request if
the requests are from different origin.

This patch also set proper principal to nsItransferable for clipboard write in
various cases,
- Copy image via context menu.
- Copy current selection via keyboard shortcut or context menu.
- Data is provided by script when copy operation is triggered via keyboard
  shortcut or context menu.
- Clipboard data is put via async clipboard.

Depends on D190761

Differential Revision: https://phabricator.services.mozilla.com/D190796
2023-12-06 20:29:00 +00:00
Edgar Chen 14faf6cf89 Bug 1777448 - Part 1: Don't not show paste contextmenu for background tab; r=nika,hsivonen
Displaying the paste context menu for background tabs can be surprising and
confusing for users, so we reject the request and don't allow it being associated
with existing pending request.

Depends on D190405

Differential Revision: https://phabricator.services.mozilla.com/D190761
2023-12-06 20:29:00 +00:00
Edgar Chen fd9072b080 Bug 1866994 - Handle clipboard contextmenu in parent process; r=geckoview-reviewers,extension-reviewers,webidl,win-reviewers,saschanaz,robwu,nika,Gijs,m_kato,emilio
This patch makes the clipboard context menu trigger from the parent process rather
than the content process. A new method, `confirmUserPaste`, is added on `nsIPromptService`
to trigger frontend UI.

The behavior of handling multiple requests should remain unchanged, new tests are
added to ensure that.

Differential Revision: https://phabricator.services.mozilla.com/D190405
2023-11-28 15:38:01 +00:00
Edgar Chen 14d41cb7f9 Bug 1852947 - Redesign the async clipboard read API; r=nika
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async
clipboard API reads the clipboard data asynchronously. When reading, async
clipboard API first check the available types, and then retrieve the actual data
for that type. This process has a potential race condition: the clipboard content
might change between the time between the time we check the types and when we
retrieve the data. Although we currently fetch the actual data immediately after
checking available types (in line with the spec), this minimizes the chance of
encountering this race condition. However, if we would like to support retrieving
the data only when `getType()` is invoked (bug 1691825), this potential race
condition could become a significant issue.

Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress
the paste context menu when the clipboard data originates from a same-origin page.
This also requires a better way to track read requests, clipboard content and
invalidate the request when the system's clipboard content is changed.

After some refacting around nsBaseClipboard, all platform now use sequence
number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated
with a sequence number and deemed invalid if the associated sequence number isn't
matched the latest system value.

With these new API, it also becomes possible to write some tests.

Depends on D191409

Differential Revision: https://phabricator.services.mozilla.com/D182108
2023-11-14 09:21:24 +00:00
Noemi Erli 5b3d25d180 Backed out changeset b0ff38a7d9fb (bug 1852947) for causing aInstanceSize related assertion failures 2023-11-11 03:25:58 +02:00
Edgar Chen 02532aabad Bug 1852947 - Redesign the async clipboard read API; r=nika
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async
clipboard API reads the clipboard data asynchronously. When reading, async
clipboard API first check the available types, and then retrieve the actual data
for that type. This process has a potential race condition: the clipboard content
might change between the time between the time we check the types and when we
retrieve the data. Although we currently fetch the actual data immediately after
checking available types (in line with the spec), this minimizes the chance of
encountering this race condition. However, if we would like to support retrieving
the data only when `getType()` is invoked (bug 1691825), this potential race
condition could become a significant issue.

Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress
the paste context menu when the clipboard data originates from a same-origin page.
This also requires a better way to track read requests, clipboard content and
invalidate the request when the system's clipboard content is changed.

After some refacting around nsBaseClipboard, all platform now use sequence
number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated
with a sequence number and deemed invalid if the associated sequence number isn't
matched the latest system value.

With these new API, it also becomes possible to write some tests.

Depends on D191409

Differential Revision: https://phabricator.services.mozilla.com/D182108
2023-11-10 15:04:26 +00:00
Noemi Erli 2a178d7869 Backed out changeset 7355802744d1 (bug 1852947) for causing failures in test_clipboard_asyncGetData.html CLOSED TREE 2023-11-09 12:32:56 +02:00
Edgar Chen b131b4d3fc Bug 1852947 - Redesign the async clipboard read API; r=nika
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async
clipboard API reads the clipboard data asynchronously. When reading, async
clipboard API first check the available types, and then retrieve the actual data
for that type. This process has a potential race condition: the clipboard content
might change between the time between the time we check the types and when we
retrieve the data. Although we currently fetch the actual data immediately after
checking available types (in line with the spec), this minimizes the chance of
encountering this race condition. However, if we would like to support retrieving
the data only when `getType()` is invoked (bug 1691825), this potential race
condition could become a significant issue.

Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress
the paste context menu when the clipboard data originates from a same-origin page.
This also requires a better way to track read requests, clipboard content and
invalidate the request when the system's clipboard content is changed.

After some refacting around nsBaseClipboard, all platform now use sequence
number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated
with a sequence number and deemed invalid if the associated sequence number isn't
matched the latest system value.

With these new API, it also becomes possible to write some tests.

Depends on D191409

Differential Revision: https://phabricator.services.mozilla.com/D182108
2023-11-09 07:47:00 +00:00
Norisz Fay ced0683cec Backed out changeset c8561b4726a2 (bug 1852947) for causing bustage on nsClipboardProxy.cpp CLOSED TREE 2023-11-08 23:44:50 +02:00
Edgar Chen 820da1024f Bug 1852947 - Redesign the async clipboard read API; r=nika
In bug 1755863, we introduce two async APIs in `nsIClipboard` to make async
clipboard API reads the clipboard data asynchronously. When reading, async
clipboard API first check the available types, and then retrieve the actual data
for that type. This process has a potential race condition: the clipboard content
might change between the time between the time we check the types and when we
retrieve the data. Although we currently fetch the actual data immediately after
checking available types (in line with the spec), this minimizes the chance of
encountering this race condition. However, if we would like to support retrieving
the data only when `getType()` is invoked (bug 1691825), this potential race
condition could become a significant issue.

Furthermore, bug 1777448 aims to have a way to track the clipboard data and suppress
the paste context menu when the clipboard data originates from a same-origin page.
This also requires a better way to track read requests, clipboard content and
invalidate the request when the system's clipboard content is changed.

After some refacting around nsBaseClipboard, all platform now use sequence
number to track clipboard content, so `nsIAsyncGetClipboardData` can be associated
with a sequence number and deemed invalid if the associated sequence number isn't
matched the latest system value.

With these new API, it also becomes possible to write some tests.

Depends on D191409

Differential Revision: https://phabricator.services.mozilla.com/D182108
2023-11-08 20:11:08 +00:00
Edgar Chen 9529ca9444 Bug 1862956 - Use `FlavorsTransferableCanExport` to get the available flavor list from cached transferable; r=nika,spohl
Differential Revision: https://phabricator.services.mozilla.com/D192678
2023-11-03 16:50:11 +00:00
Edgar Chen 6103cbd875 Bug 1861927 - Part 1: Rename nsIAsyncSetClipboardDataCallback to nsIAsyncClipboardRequestCallback; r=nika
It is going to be reused for clipboard read, so make the name more generic.

Differential Revision: https://phabricator.services.mozilla.com/D188526
2023-10-30 09:46:19 +00:00
Edgar Chen 96afd3a327 Bug 1856052 - Remove unused parameter from SetNativeClipboardData; r=geckoview-reviewers,win-reviewers,spohl,mhowell,m_kato
After bug 1851817, all platforms uses nsBaseClipboard as base class and clipboard
owner is handled there, so nsIClipboardOwner parameter is unused.

Differential Revision: https://phabricator.services.mozilla.com/D190236
2023-10-17 13:15:31 +00:00
Edgar Chen ef8617b3e8 Bug 1851817 - Part 5: Merge ClipboardSetDataHelper into nsBaseClipboard; r=spohl
Now all platform uses nsBaseClipboard, so we could just merge ClipboardSetDataHelper
into nsBaseClipboard.

Depends on D188252

Differential Revision: https://phabricator.services.mozilla.com/D188253
2023-10-04 20:47:40 +00:00
Edgar Chen d1b1de4748 Bug 1851817 - Part 4: Make GTK nsClipboard use nsBaseClipboard; r=stransky
Depends on D188251

Differential Revision: https://phabricator.services.mozilla.com/D188252
2023-10-04 20:47:40 +00:00
Edgar Chen c4dc8a2dfd Bug 1851817 - Part 2: Add AsyncGetNativeClipboardData; r=spohl,stransky
This is mainly added for GTK which supports getting clipboard data asynchrously.
For other platforms that don't support asynchrously reading, they could use
the default implementation which just wraps the `GetNativeClipboardData` instead.

Depends on D188249

Differential Revision: https://phabricator.services.mozilla.com/D188250
2023-10-04 20:47:39 +00:00
Edgar Chen 36a50deceb Bug 1851817 - Part 1: Add AsyncHasNativeClipboardDataMatchingFlavors; r=spohl,stransky
This is mainly added for GTK which supports getting clipboard data asynchrously.
For other platforms that don't support asynchrously reading, they could use
the default implementation which just wraps the `HasNativeClipboardDataMatchingFlavors`
instead.

Differential Revision: https://phabricator.services.mozilla.com/D188249
2023-10-04 20:47:39 +00:00
Sandor Molnar f15867f9fe Backed out 5 changesets (bug 1851817) for causing wpt failures on clipboard-apis/async-promise-write-blobs-read-blobs.https.html CLOSED TREE
Backed out changeset 72e7e4417cc9 (bug 1851817)
Backed out changeset 7c035f460830 (bug 1851817)
Backed out changeset 0ea5e417de98 (bug 1851817)
Backed out changeset b46e4efa80ae (bug 1851817)
Backed out changeset f3c15030aa8a (bug 1851817)
2023-10-04 05:22:17 +03:00
Edgar Chen 9fac1a5c4e Bug 1851817 - Part 5: Merge ClipboardSetDataHelper into nsBaseClipboard; r=spohl
Now all platform uses nsBaseClipboard, so we could just merge ClipboardSetDataHelper
into nsBaseClipboard.

Depends on D188252

Differential Revision: https://phabricator.services.mozilla.com/D188253
2023-10-03 22:49:11 +00:00
Edgar Chen eecfc4f330 Bug 1851817 - Part 4: Make GTK nsClipboard use nsBaseClipboard; r=stransky
Depends on D188251

Differential Revision: https://phabricator.services.mozilla.com/D188252
2023-10-03 22:49:10 +00:00
Edgar Chen 87bc02d46b Bug 1851817 - Part 2: Add AsyncGetNativeClipboardData; r=spohl,stransky
This is mainly added for GTK which supports getting clipboard data asynchrously.
For other platforms that don't support asynchrously reading, they could use
the default implementation which just wraps the `GetNativeClipboardData` instead.

Depends on D188249

Differential Revision: https://phabricator.services.mozilla.com/D188250
2023-10-03 22:49:09 +00:00
Edgar Chen 4e896d22fe Bug 1851817 - Part 1: Add AsyncHasNativeClipboardDataMatchingFlavors; r=spohl,stransky
This is mainly added for GTK which supports getting clipboard data asynchrously.
For other platforms that don't support asynchrously reading, they could use
the default implementation which just wraps the `HasNativeClipboardDataMatchingFlavors`
instead.

Differential Revision: https://phabricator.services.mozilla.com/D188249
2023-10-03 22:49:09 +00:00
Edgar Chen ccc65e5dd8 Bug 1854934 - Part 3: Rename CLIPBOARD_LOG* to MOZ_CLIPBOARD_LOG*; r=rkraesig,win-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D189157
2023-09-26 15:29:13 +00:00
Edgar Chen 0ed25be1fa Bug 1854934 - Part 2: Dump more information for debugging; r=win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D189146
2023-09-26 15:29:12 +00:00
Sandor Molnar ea5cdb14e2 Backed out 3 changesets (bug 1854934) for causing build bustages on widget/windows/nsClipboard.cpp CLOSED TREE
Backed out changeset ac9c246562ad (bug 1854934)
Backed out changeset 8375f7aa627d (bug 1854934)
Backed out changeset a06a8bb37aad (bug 1854934)
2023-09-26 13:33:54 +03:00
Edgar Chen f4e078021b Bug 1854934 - Part 3: Rename CLIPBOARD_LOG* to MOZ_CLIPBOARD_LOG*; r=rkraesig,win-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D189157
2023-09-26 09:07:40 +00:00
Edgar Chen 751bed5627 Bug 1854934 - Part 2: Dump more information for debugging; r=win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D189146
2023-09-26 09:07:39 +00:00
Edgar Chen f29deb388a Bug 1829148 - Update MOZ_DIAGNOSTIC_ASSERT for mIgnoreEmptyNotification; r=cmartin
The MOZ_DIAGNOSTIC_ASSERT is added to identify the scenarios where we
might run into this check. From the crash report, this could occur
when we attempt to retry OleSetClipboard, which could be due to the
clipboard being opened by another application at the moment.

Previously, nsBaseClipboard used to set clipboard owner before it calls
into OleSetClipboard, see
https://searchfox.org/mozilla-central/rev/db616599807ac9acda96df74d24bcb25f3ba44e1/widget/nsBaseClipboard.cpp#181.
So we need to use `mIgnoreEmptyNotification` to prevent the clipboard
owner from being cleared in such case.

However, after https://phabricator.services.mozilla.com/D178777,
nsBaseClipboard now set clipboard owner after OleSetClipboard succeed,
so `mIgnoreEmptyNotification` should no longer be necessary. This patch
updates the MOZ_DIAGNOSTIC_ASSERT to verify this, if there is no
reported crashes, I believe we can safely remove
`mIgnoreEmptyNotification`.

Differential Revision: https://phabricator.services.mozilla.com/D182907
2023-07-10 19:59:54 +00:00
Edgar Chen 3e0be37306 Bug 1835059 - [Cocoa] Make clipboard supports all operations on kSelectionCache type; r=mstange
There is no real usage so far, but this could make clipbord code and test more generic.

Depends on D180000

Differential Revision: https://phabricator.services.mozilla.com/D181568
2023-06-27 14:29:03 +00:00
Edgar Chen 5d10dd9171 Bug 1810850 - Part 4: Refactor around nsBase::ClipboardEmptyClipboard; r=cmartin,mstange
mEmptyingForSetData flag can be removed since it's used for clearing
cache data without emptying system clipboard and now we could just call
ClipboardCache::Clear().

Depends on D179999

Differential Revision: https://phabricator.services.mozilla.com/D180000
2023-06-26 21:02:40 +00:00
Edgar Chen 1d8c57b7a7 Bug 1810850 - Part 3: Move clipboard cache code for HasDataMatchingFlavors to nsBaseClipboard; r=cmartin,mstange
Depends on D179993

Differential Revision: https://phabricator.services.mozilla.com/D179999
2023-06-26 21:02:40 +00:00
Edgar Chen 2dd7f27175 Bug 1810850 - Part 2: Move clipboard cache code for GetData to nsBaseClipboard; r=cmartin,mstange
This patch introduce a preference for getting the data from cache
directly which is enabled on Mac only. And now we really support getting
data from cache for each type simultaneously, instead of only using the
one that has the latest cached transferable.

Depends on D178777

Differential Revision: https://phabricator.services.mozilla.com/D179993
2023-06-26 21:02:40 +00:00
Edgar Chen daea3055b6 Bug 1810850 - Part 1: Track clipboard change count in clipboard cache; r=cmartin,mstange
We also need to update clipboard cache after setting native clipboard,
in order to obtain the correct clipboard change count.

Differential Revision: https://phabricator.services.mozilla.com/D178777
2023-06-26 21:02:40 +00:00
Cristina Horotan c92d9850e8 Backed out 4 changesets (bug 1810850) for causing build bustages at nsClipboard.h CLOSED TREE
Backed out changeset 012b23b12de6 (bug 1810850)
Backed out changeset 15caa51b406a (bug 1810850)
Backed out changeset 0c8e0e9a9481 (bug 1810850)
Backed out changeset bf1e71a4935a (bug 1810850)
2023-06-26 13:38:46 +03:00
Edgar Chen 25cfc40dd5 Bug 1810850 - Part 4: Refactor around nsBase::ClipboardEmptyClipboard; r=cmartin,mstange
mEmptyingForSetData flag can be removed since it's used for clearing
cache data without emptying system clipboard and now we could just call
ClipboardCache::Clear().

Depends on D179999

Differential Revision: https://phabricator.services.mozilla.com/D180000
2023-06-26 10:03:23 +00:00
Edgar Chen 68f942a08e Bug 1810850 - Part 3: Move clipboard cache code for HasDataMatchingFlavors to nsBaseClipboard; r=cmartin,mstange
Depends on D179993

Differential Revision: https://phabricator.services.mozilla.com/D179999
2023-06-26 10:03:23 +00:00
Edgar Chen 07bafff927 Bug 1810850 - Part 2: Move clipboard cache code for GetData to nsBaseClipboard; r=cmartin,mstange
This patch introduce a preference for getting the data from cache
directly which is enabled on Mac only. And now we really support getting
data from cache for each type simultaneously, instead of only using the
one that has the latest cached transferable.

Depends on D178777

Differential Revision: https://phabricator.services.mozilla.com/D179993
2023-06-26 10:03:22 +00:00
Edgar Chen 94708c1baf Bug 1810850 - Part 1: Track clipboard change count in clipboard cache; r=cmartin,mstange
We also need to update clipboard cache after setting native clipboard,
in order to obtain the correct clipboard change count.

Differential Revision: https://phabricator.services.mozilla.com/D178777
2023-06-26 10:03:22 +00:00
Edgar Chen 7fd07edd61 Bug 1834374 - Do not call EmptyClipboard() in nsBaseClipboard destructor; r=nika
Calling it in destructor doesn't work as expected at all, since it's a virtual
function. Furthermore, it doesn't make sense to clear clipboard data every time
Firefox is closed.

Differential Revision: https://phabricator.services.mozilla.com/D178697
2023-06-02 08:00:08 +00:00
Edgar Chen 1950c56084 Bug 1812078 - Part 1: Have separated clipboard caches for each clipbaord type to track clipboard owner; r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D167997
2023-06-01 07:16:30 +00:00
Edgar Chen 3a6c9d70ce Bug 1834710 - Have a generic way to initialize clipboard capabilities; r=cmartin
Differential Revision: https://phabricator.services.mozilla.com/D173009
2023-05-24 10:46:43 +00:00
Edgar Chen 8a1d360c1a Bug 1712122 - Part 3: Cancel pending write request when a new write request is made; r=nika,geckoview-reviewers,m_kato
The Async Clipboard API now allows using arbitrary promises for passing write data,
potentially enabling websites to delay writing data to an arbitrary future, which
may surprise the user. This patch introduces a solution: a new write request will
automatically cancel any previous pending request.

To implement that, this patch introduces a new method to nsIClipboard, new XPCOM
interfaces, and new IPC to efficiently track individual write requests. Additionally,
a new helper base class, ClipboardSetDataHelper, is introduced in widget to facilitate
platform code sharing.

Differential Revision: https://phabricator.services.mozilla.com/D174090
2023-05-14 21:02:08 +00:00
Edgar Chen 38bdecc2a6 Bug 1812543 - [Cocoa] Check cached transferable properly in nsClipboard::HasDataMatchingFlavors; r=spohl
Differential Revision: https://phabricator.services.mozilla.com/D167932
2023-01-26 20:04:30 +00:00
Edgar Chen 9837388293 Bug 1811835 - Add a MOZ_DIAGNOSTIC_ASSERT in nsBaseClipboard::EmptyClipboard; r=cmartin
to figure out if we could remove mIgnoreEmptyNotification check.

Differential Revision: https://phabricator.services.mozilla.com/D167581
2023-01-24 08:55:18 +00:00
Edgar Chen e5fe0a40c0 Bug 1796548 - Introduce a generic method to check clipboard capabilities in nsIClipboard; r=geckoview-reviewers,nika,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D166475
2023-01-16 19:50:17 +00:00
Edgar Chen cc7905e7ab Bug 1785913 - Update mIgnoreEmptyNotification in nsBaseClipboard; r=NeilDeakin
Differential Revision: https://phabricator.services.mozilla.com/D148923
2022-08-23 11:05:45 +00:00