Bug 1298313 - Revert the third patch from bug 1256339 because it broke long-press context menus in non-e10s mode. r=backout a=ritu
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 29 Aug 2016 14:29:57 -0400
changeset 350004 16676fabf4c6da9a46ba08a408b87e37927573b5
parent 350003 845d630fe4a92ee297af9996f10d47e49171498b
child 350005 01a9a573e78df6fc97702c2d3d32a541f9107c31
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout, ritu
bugs1298313, 1256339
milestone50.0a2
Bug 1298313 - Revert the third patch from bug 1256339 because it broke long-press context menus in non-e10s mode. r=backout a=ritu MozReview-Commit-ID: FZEbH0TlY8L
browser/base/content/content.js
widget/windows/nsWindow.cpp
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -78,63 +78,33 @@ addEventListener("pageshow", function(ev
 });
 addEventListener("DOMAutoComplete", function(event) {
   LoginManagerContent.onUsernameInput(event);
 });
 addEventListener("blur", function(event) {
   LoginManagerContent.onUsernameInput(event);
 });
 
-var gLastContextMenuEvent = null; // null or a WeakReference to a contextmenu event
 var handleContentContextMenu = function (event) {
-  gLastContextMenuEvent = null;
   let defaultPrevented = event.defaultPrevented;
   if (!Services.prefs.getBoolPref("dom.event.contextmenu.enabled")) {
     let plugin = null;
     try {
       plugin = event.target.QueryInterface(Ci.nsIObjectLoadingContent);
     } catch (e) {}
     if (plugin && plugin.displayedType == Ci.nsIObjectLoadingContent.TYPE_PLUGIN) {
       // Don't open a context menu for plugins.
       return;
     }
 
     defaultPrevented = false;
   }
 
-  if (defaultPrevented) {
-    return;
-  }
-
-  if (event.mozInputSource == Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) {
-    // If this was triggered by touch, then we don't want to show the actual
-    // context menu until we get the APZ:LongTapUp notification. However, we
-    // will need the |event| object when we get that notification, so we save
-    // it in a WeakReference. That way it won't leak things if we never get
-    // the APZ:LongTapUp notification (which is quite possible).
-    gLastContextMenuEvent = Cu.getWeakReference(event);
+  if (defaultPrevented)
     return;
-  }
-
-  // For non-touch-derived contextmenu events, we can handle it right away.
-  showContentContextMenu(event);
-}
-
-var showContentContextMenu = function (event) {
-  if (event == null) {
-    // If we weren't given an event, then this is being invoked from the
-    // APZ:LongTapUp observer, and the contextmenu event is stashed in
-    // gLastContextMenuEvent.
-    event = (gLastContextMenuEvent ? gLastContextMenuEvent.get() : null);
-    gLastContextMenuEvent = null;
-    if (event == null) {
-      // Still no event? We can't do anything, bail out.
-      return;
-    }
-  }
 
   let addonInfo = {};
   let subject = {
     event: event,
     addonInfo: addonInfo,
   };
   subject.wrappedJSObject = subject;
   Services.obs.notifyObservers(subject, "content-contextmenu", null);
@@ -242,21 +212,16 @@ var showContentContextMenu = function (e
     };
   }
 }
 
 Cc["@mozilla.org/eventlistenerservice;1"]
   .getService(Ci.nsIEventListenerService)
   .addSystemEventListener(global, "contextmenu", handleContentContextMenu, false);
 
-Services.obs.addObserver(showContentContextMenu, "APZ:LongTapUp", false);
-addEventListener("unload", () => {
-  Services.obs.removeObserver(showContentContextMenu, "APZ:LongTapUp")
-}, false);
-
 // Values for telemtery bins: see TLS_ERROR_REPORT_UI in Histograms.json
 const TLS_ERROR_REPORT_TELEMETRY_UI_SHOWN = 0;
 const TLS_ERROR_REPORT_TELEMETRY_EXPANDED = 1;
 const TLS_ERROR_REPORT_TELEMETRY_SUCCESS  = 6;
 const TLS_ERROR_REPORT_TELEMETRY_FAILURE  = 7;
 
 const SEC_ERROR_BASE          = Ci.nsINSSErrorsService.NSS_SEC_ERROR_BASE;
 const MOZILLA_PKIX_ERROR_BASE = Ci.nsINSSErrorsService.MOZILLA_PKIX_ERROR_BASE;
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -5234,24 +5234,16 @@ nsWindow::ProcessMessage(UINT msg, WPARA
                          WidgetMouseEvent::eLeftButton,
                          nsIDOMMouseEvent::MOZ_SOURCE_PEN);
       InkCollector::sInkCollector->ClearTarget();
     }
     break;
 
     case WM_CONTEXTMENU:
     {
-      // If the context menu is brought up by a touch long-press, then
-      // the APZ code is responsble for dealing with this, so we don't
-      // need to do anything.
-      if (mAPZC && MOUSE_INPUT_SOURCE() == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
-        result = true;
-        break;
-      }
-
       // if the context menu is brought up from the keyboard, |lParam|
       // will be -1.
       LPARAM pos;
       bool contextMenukey = false;
       if (lParam == -1)
       {
         contextMenukey = true;
         pos = lParamToClient(GetMessagePos());