Bug 1244462 set isContentSelected before using it for the on-build-contextmenu notification, r=gijs draft
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 10 Feb 2016 11:47:31 -0800
changeset 330159 b0e000230042b198f39ae31cc3c21a5771fb305f
parent 329876 0e2df20590bdee51dbd978b350f050459d040bb7
child 514112 c54f425b13276fa26d198f8abd0d1c0a21227ee9
push id10691
push usermixedpuppy@gmail.com
push dateWed, 10 Feb 2016 20:15:13 +0000
reviewersgijs
bugs1244462
milestone47.0a1
Bug 1244462 set isContentSelected before using it for the on-build-contextmenu notification, r=gijs MozReview-Commit-ID: 8i9mGv3zFxM
browser/base/content/nsContextMenu.js
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -26,16 +26,17 @@ nsContextMenu.prototype = {
   initMenu: function CM_initMenu(aXulMenu, aIsShift) {
     // Get contextual info.
     this.setTarget(document.popupNode, document.popupRangeParent,
                    document.popupRangeOffset);
     if (!this.shouldDisplay)
       return;
 
     this.hasPageMenu = false;
+    this.isContentSelected = !this.selectionInfo.docSelectionIsCollapsed;
     if (!aIsShift) {
       if (this.isRemote) {
         this.hasPageMenu =
           PageMenuParent.addToPopup(gContextMenuContentData.customMenuItems,
                                     this.browser, aXulMenu);
       }
       else {
         this.hasPageMenu = PageMenuParent.buildAndAddToPopup(this.target, aXulMenu);
@@ -66,16 +67,18 @@ nsContextMenu.prototype = {
 
     this.isFrameImage = document.getElementById("isFrameImage");
     this.ellipsis = "\u2026";
     try {
       this.ellipsis = gPrefService.getComplexValue("intl.ellipsis",
                                                    Ci.nsIPrefLocalizedString).data;
     } catch (e) { }
 
+    // Reset after "on-build-contextmenu" notification in case selection was
+    // changed during the notification.
     this.isContentSelected = !this.selectionInfo.docSelectionIsCollapsed;
     this.onPlainTextLink = false;
 
     let bookmarkPage = document.getElementById("context-bookmarkpage");
     if (bookmarkPage)
       BookmarkingUI.onCurrentPageContextPopupShowing();
 
     // Initialize (disable/remove) menu items.