Closed Bug 1208217 Opened 9 years ago Closed 8 years ago

paste event listener doesn't fire in documents with no editor component

Categories

(Core :: DOM: Events, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: nika, Assigned: nika)

References

Details

Attachments

(1 file, 2 obsolete files)

Appears (at first impression) to be due to a regression after bug 1159490 (probably related to menu item fixes).

For STR see bug 1159490 comment 10 - the problem doesn't occur when there is a contenteditable node in the page.
(In reply to Michael Layzell [:mystor] from comment #0)
> Appears (at first impression) to be due to a regression after bug 1159490
> (probably related to menu item fixes).
> 
> For STR see bug 1159490 comment 10 - the problem doesn't occur when there is
> a contenteditable node in the page.

Back when I filed this, I checked, and this isn't a regression, but rather a feature which I meant to add in bug 1159490 and didn't.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Blocks: 846674
Do you plan to fix this, Michael?
Flags: needinfo?(michael)
This patch whitelists the paste command in documents without an editor component. It appears to fix the problem.

try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=9e6b541a5663
Attachment #8752292 - Flags: review?(bugs)
Assignee: nobody → michael
Flags: needinfo?(michael)
Comment on attachment 8752292 [details] [diff] [review]
Enable paste event listener in documents with no editor component

My review queue is long. Enn, perhaps you could take a look at this.
Attachment #8752292 - Flags: review?(bugs) → review?(enndeakin)
Comment on attachment 8752292 [details] [diff] [review]
Enable paste event listener in documents with no editor component

># HG changeset patch
># User Michael Layzell <michael@thelayzells.com>
>
>Bug 1208217 - Enable paste event listener in documents with no editor component, r=smaug
>
>diff --git a/dom/base/nsGlobalWindowCommands.cpp b/dom/base/nsGlobalWindowCommands.cpp
>index 110af14..f3b204f 100644
>--- a/dom/base/nsGlobalWindowCommands.cpp
>+++ b/dom/base/nsGlobalWindowCommands.cpp
>@@ -479,17 +479,18 @@ NS_IMPL_ISUPPORTS(nsClipboardCommand, nsIControllerCommand)
> nsresult
> nsClipboardCommand::IsCommandEnabled(const char* aCommandName, nsISupports *aContext, bool *outCmdEnabled)
...
>-      strcmp(aCommandName, "cmd_cut"))
>+      strcmp(aCommandName, "cmd_cut") &&
>+      strcmp(aCommandName, "cmd_paste"))
>     return NS_OK;
> 
>   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryInterface(aContext);
>   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
> 
>   nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
>   if (doc->IsHTMLOrXHTML()) {
>     // In HTML and XHTML documents, we always want cut and copy commands to be enabled.

Update the comment here.

>    *outCmdEnabled = true;
>  } else {
>    // Cut isn't enabled in xul documents which use nsClipboardCommand
>    if (strcmp(aCommandName, "cmd_cut")) {
>      *outCmdEnabled = nsCopySupport::CanCopy(doc);
>    }
>  }

The else clause will need to be changed. Better if it explicitly matches only the two copy commands.
  
>   EventMessage eventMessage = eCopy;
>   if (strcmp(aCommandName, "cmd_cut") == 0) {
>     eventMessage = eCut;
>   }
>+  if (strcmp(aCommandName, "cmd_paste") == 0) {
>+    eventMessage = ePaste;
>+  }

else if

>   bool actionTaken = false;
>   nsCopySupport::FireClipboardEvent(eventMessage,
>                                     nsIClipboard::kGlobalClipboard,
>                                     presShell, nullptr, &actionTaken);
> 
>   if (!strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) {
>     dom::Selection *sel =

While you're here can you update this to not do this last conditional block for cmd_copyAndCollapseToEnd when FireClipboardEvent returns true?
Attachment #8752292 - Attachment is obsolete: true
Attachment #8752292 - Flags: review?(enndeakin)
Fix some test failures on try
Attachment #8752954 - Flags: review?(enndeakin)
Attachment #8752870 - Attachment is obsolete: true
Attachment #8752870 - Flags: review?(enndeakin)
Attachment #8752954 - Flags: review?(enndeakin) → review+
https://hg.mozilla.org/mozilla-central/rev/f4d91d214441
Status: REOPENED → RESOLVED
Closed: 8 years ago8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
See Also: → 1271897
Depends on: 1317322
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: