Commit c5689553 authored by Masayuki Nakano's avatar Masayuki Nakano
Browse files

Bug 1855345 - Make `AutoCopyListener` ignore any selection changes caused by...

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

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
parent 9cc1d42a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3329,6 +3329,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.