Bug 1855345 - Make `AutoCopyListener` ignore any selection changes caused by Selection API r=karlt,smaug

Even though there is a reasonable usabe like bug 1567160, we should
ensure that `AutoCopyListener` never update clipboard when the selection
change is caused by a Selection API call.

Differential Revision: https://phabricator.services.mozilla.com/D191585
This commit is contained in:
Masayuki Nakano 2023-10-26 04:05:02 +00:00
Родитель 539c7a6ffc
Коммит 3e86e21ebe
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -3328,6 +3328,13 @@ void AutoCopyListener::OnSelectionChange(Document* aDocument,
int16_t aReason) {
MOZ_ASSERT(IsValidClipboardID(sClipboardID));
// For now, we should prevent any updates caused by a call of Selection API.
// We should allow this in some cases later, though. See the valid usage in
// bug 1567160.
if (aReason & nsISelectionListener::JS_REASON) {
return;
}
if (sClipboardID == nsIClipboard::kSelectionCache) {
// Do nothing if this isn't in the active window and,
// in the case of Web content, in the frontmost tab.