Backed out 3 changesets (bug 1364896) for causing bug 1376466.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 27 Jun 2017 14:32:07 -0400
changeset 417258 8f80d594c08d5c7a112e5d4b9eb44ffca717eb7b
parent 417257 f4e52135d9bdc6ce98bb37b450021445aed894ce
child 417358 f87e31ac8e9a3588e09a62bbb092806d75b324df
child 417481 62f76ccf9d13cb041a2ff72321aa62a762c26527
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1364896, 1376466
milestone56.0a1
backs out5c870a786e945197a770a308aeeececdff8bac18
134d9ee1e545d7da27888a4c0a3b8eae689bbbba
8f52f28a9eaa342c8f55441551d8ee109845f54b
first release with
nightly linux32
8f80d594c08d / 56.0a1 / 20170627183545 / files
nightly linux64
8f80d594c08d / 56.0a1 / 20170627183545 / files
nightly mac
8f80d594c08d / 56.0a1 / 20170627183537 / files
nightly win32
8f80d594c08d / 56.0a1 / 20170627113424 / files
nightly win64
8f80d594c08d / 56.0a1 / 20170627113424 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 3 changesets (bug 1364896) for causing bug 1376466. Backed out changeset 5c870a786e94 (bug 1364896) Backed out changeset 134d9ee1e545 (bug 1364896) Backed out changeset 8f52f28a9eaa (bug 1364896)
browser/base/content/browser.js
browser/base/content/nsContextMenu.js
browser/base/content/test/contextMenu/browser.ini
browser/base/content/test/contextMenu/browser_contextmenu_touch.js
browser/themes/windows/browser.css
layout/xul/nsXULPopupManager.cpp
layout/xul/nsXULPopupManager.h
testing/mochitest/tests/SimpleTest/EventUtils.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1629,20 +1629,16 @@ var gBrowserInit = {
     LightWeightThemeWebInstaller.init();
 
     if (Win7Features)
       Win7Features.onOpenWindow();
 
     FullScreen.init();
     PointerLock.init();
 
-    if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
-      ContextMenuTouchModeObserver.init();
-    }
-
     // initialize the sync UI
     gSync.init();
 
     if (AppConstants.MOZ_DATA_REPORTING)
       gDataNotificationInfoBar.init();
 
     gBrowserThumbnails.init();
 
@@ -1842,19 +1838,16 @@ var gBrowserInit = {
       } catch (ex) {
         Cu.reportError(ex);
       }
 
       if (this.gmpInstallManager) {
         this.gmpInstallManager.uninit();
       }
 
-      if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
-        ContextMenuTouchModeObserver.uninit();
-      }
       BrowserOffline.uninit();
       IndexedDBPromptHelper.uninit();
       PanelUI.uninit();
       AutoShowBookmarksToolbar.uninit();
     }
 
     // Final window teardown, do this last.
     window.XULBrowserWindow = null;
@@ -8221,87 +8214,16 @@ var RestoreLastSessionObserver = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference])
 };
 
 function restoreLastSession() {
   SessionStore.restoreLastSession();
 }
 
-/* Observes context menus and adjusts their size for better
- * usability when opened via a touch screen. */
-var ContextMenuTouchModeObserver = {
-  get _searchBarContextMenu() {
-    let searchbar = document.getElementById("searchbar");
-    let textBox = document.getAnonymousElementByAttribute(searchbar,
-                                        "anonid", "searchbar-textbox");
-    let inputBox = document.getAnonymousElementByAttribute(textBox,
-                                        "anonid", "textbox-input-box");
-    let menu = document.getAnonymousElementByAttribute(inputBox,
-                                        "anonid", "input-box-contextmenu");
-    return menu;
-  },
-
-  get _urlBarContextMenu() {
-    let urlbar = document.getElementById("urlbar");
-    let textBox = document.getAnonymousElementByAttribute(urlbar,
-                                        "anonid", "textbox-input-box");
-    let menu = document.getAnonymousElementByAttribute(textBox,
-                                        "anonid", "input-box-contextmenu");
-    return menu;
-  },
-
-  _addListener(el) {
-    el.addEventListener("popupshowing", this);
-  },
-
-  _removeListener(el) {
-    el.removeEventListener("popupshowing", this);
-  },
-
-  init() {
-    // Start observing different context menus for popupshowing.
-
-    // The main popup set, which contains several context menus,
-    // e.g. the page content area context menu.
-    this._addListener(document.getElementById("mainPopupSet"));
-
-    // The navigation context menu of the back and forward button.
-    this._addListener(document.getElementById("back-button"));
-    this._addListener(document.getElementById("forward-button"));
-
-    // The search bar context menu.
-    this._addListener(this._searchBarContextMenu);
-
-    // The url bar context menu.
-    this._addListener(this._urlBarContextMenu);
-  },
-
-  handleEvent(event) {
-    let target = event.target;
-    if (target.localName != "menupopup") {
-      return;
-    }
-
-    if (event.mozInputSource == MouseEvent.MOZ_SOURCE_TOUCH) {
-      target.setAttribute("touchmode", "true");
-    } else {
-      target.removeAttribute("touchmode");
-    }
-  },
-
-  uninit() {
-    this._removeListener(document.getElementById("mainPopupSet"));
-    this._removeListener(document.getElementById("back-button"));
-    this._removeListener(document.getElementById("forward-button"));
-    this._removeListener(this._searchBarContextMenu);
-    this._removeListener(this._urlBarContextMenu);
-  },
-};
-
 var TabContextMenu = {
   contextTab: null,
   _updateToggleMuteMenuItem(aTab, aConditionFn) {
     ["muted", "soundplaying"].forEach(attr => {
       if (!aConditionFn || aConditionFn(attr)) {
         if (aTab.hasAttribute(attr)) {
           aTab.toggleMuteMenuItem.setAttribute(attr, "true");
         } else {
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -57,24 +57,24 @@ function openContextMenu(aMessage) {
                               disableSetDesktopBackground: data.disableSetDesktopBg,
                               loginFillInfo: data.loginFillInfo,
                               parentAllowsMixedContent: data.parentAllowsMixedContent,
                               userContextId: data.userContextId,
                             };
   let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
   let event = gContextMenuContentData.event;
 
-  // The event is a CPOW that can't be passed into the native openPopupAtScreen
-  // function. Therefore we synthesize a new MouseEvent to propagate the
-  // inputSource to the subsequently triggered popupshowing event.
-  var newEvent = document.createEvent("MouseEvent");
-  newEvent.initNSMouseEvent("contextmenu", true, true, null, 0, event.screenX, event.screenY,
-                            0, 0, false, false, false, false, 0, null, 0, event.mozInputSource);
+  // Set touch mode to get larger menu items.
+  if (event.mozInputSource == MouseEvent.MOZ_SOURCE_TOUCH) {
+    popup.setAttribute("touchmode", "true");
+  } else {
+    popup.removeAttribute("touchmode");
+  }
 
-  popup.openPopupAtScreen(newEvent.screenX, newEvent.screenY, true, newEvent);
+  popup.openPopupAtScreen(event.screenX, event.screenY, true);
 }
 
 function nsContextMenu(aXulMenu, aIsShift) {
   this.shouldDisplay = true;
   this.initMenu(aXulMenu, aIsShift);
 }
 
 // Prototype for nsContextMenu "class."
--- a/browser/base/content/test/contextMenu/browser.ini
+++ b/browser/base/content/test/contextMenu/browser.ini
@@ -1,8 +1,6 @@
 [DEFAULT]
 support-files =
   !/browser/base/content/test/general/contextmenu_common.js
   subtst_contextmenu_webext.html
 
 [browser_contextmenu_mozextension.js]
-[browser_contextmenu_touch.js]
-skip-if = !(os == 'win' && os_version == '10.0')
deleted file mode 100644
--- a/browser/base/content/test/contextMenu/browser_contextmenu_touch.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* This test checks that context menus are in touchmode
- * when opened through a touch event (long tap). */
-
-async function openAndCheckContextMenu(contextMenu, target) {
-  is(contextMenu.state, "closed", "Context menu is initally closed.");
-
-  let popupshown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
-  EventUtils.synthesizeNativeTapAtCenter(target, true);
-  await popupshown;
-
-  is(contextMenu.state, "open", "Context menu is open.");
-  is(contextMenu.getAttribute("touchmode"), "true", "Context menu is in touchmode.");
-
-  contextMenu.hidePopup();
-
-  popupshown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
-  EventUtils.synthesizeMouseAtCenter(target, {type: "contextmenu"});
-  await popupshown;
-
-  is(contextMenu.state, "open", "Context menu is open.");
-  ok(!contextMenu.hasAttribute("touchmode"), "Context menu is not in touchmode.");
-
-  contextMenu.hidePopup();
-}
-
-// Test the content area context menu.
-add_task(async function test_contentarea_contextmenu_touch() {
-  await BrowserTestUtils.withNewTab("about:blank", async function(browser) {
-    let contextMenu = document.getElementById("contentAreaContextMenu");
-    await openAndCheckContextMenu(contextMenu, browser);
-  });
-});
-
-// Test the back and forward buttons.
-add_task(async function test_back_forward_button_contextmenu_touch() {
-  await BrowserTestUtils.withNewTab("http://example.com", async function(browser) {
-    let contextMenu = document.getElementById("backForwardMenu");
-
-    let backbutton = document.getElementById("back-button");
-    let notDisabled = BrowserTestUtils.waitForCondition(() => !backbutton.hasAttribute("disabled"));
-    BrowserTestUtils.loadURI(browser, "http://example.org");
-    await notDisabled;
-    await openAndCheckContextMenu(contextMenu, backbutton);
-
-
-    let forwardbutton = document.getElementById("forward-button");
-    notDisabled = BrowserTestUtils.waitForCondition(() => !forwardbutton.hasAttribute("disabled"));
-    backbutton.click();
-    await notDisabled;
-    await openAndCheckContextMenu(contextMenu, forwardbutton);
-  });
-});
-
-// Test the toolbar context menu.
-add_task(async function test_toolbar_contextmenu_touch() {
-  let toolbarContextMenu = document.getElementById("toolbar-context-menu");
-  let target = document.getElementById("PanelUI-menu-button");
-  await openAndCheckContextMenu(toolbarContextMenu, target);
-});
-
-// Test the urlbar input context menu.
-add_task(async function test_urlbar_contextmenu_touch() {
-  let urlbar = document.getElementById("urlbar");
-  let textBox = document.getAnonymousElementByAttribute(urlbar,
-                                      "anonid", "textbox-input-box");
-  let menu = document.getAnonymousElementByAttribute(textBox,
-                                      "anonid", "input-box-contextmenu");
-  await openAndCheckContextMenu(menu, textBox);
-});
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -1965,18 +1965,18 @@ notification.pluginVulnerable > .notific
   margin-left: -10px;
   margin-right: -10px;
   margin-bottom: -10px;
 }
 
 %include ../shared/contextmenu.inc.css
 
 /* Make context menu items larger when opened through touch. */
-menupopup[touchmode] menu,
-menupopup[touchmode] menuitem {
+#contentAreaContextMenu[touchmode] menu,
+#contentAreaContextMenu[touchmode] menuitem {
   padding-top: 12px;
   padding-bottom: 12px;
 }
 
 #contentAreaContextMenu[touchmode] > #context-navigation > menuitem {
   padding-top: 7px;
   padding-bottom: 7px;
 }
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -766,17 +766,17 @@ nsXULPopupManager::ShowMenu(nsIContent *
       new nsXULPopupShowingEvent(popupFrame->GetContent(),
                                  parentIsContextMenu, aSelectFirstItem);
     aMenu->OwnerDoc()->Dispatch("nsXULPopupShowingEvent",
                                 TaskCategory::Other,
                                 event.forget());
   }
   else {
     nsCOMPtr<nsIContent> popupContent = popupFrame->GetContent();
-    FirePopupShowingEvent(popupContent, parentIsContextMenu, aSelectFirstItem, nullptr);
+    FirePopupShowingEvent(popupContent, parentIsContextMenu, aSelectFirstItem);
   }
 }
 
 void
 nsXULPopupManager::ShowPopup(nsIContent* aPopup,
                              nsIContent* aAnchorContent,
                              const nsAString& aPosition,
                              int32_t aXPos, int32_t aYPos,
@@ -790,34 +790,34 @@ nsXULPopupManager::ShowPopup(nsIContent*
     return;
 
   nsCOMPtr<nsIContent> triggerContent;
   InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
 
   popupFrame->InitializePopup(aAnchorContent, triggerContent, aPosition,
                               aXPos, aYPos, MenuPopupAnchorType_Node, aAttributesOverride);
 
-  FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem, aTriggerEvent);
+  FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem);
 }
 
 void
 nsXULPopupManager::ShowPopupAtScreen(nsIContent* aPopup,
                                      int32_t aXPos, int32_t aYPos,
                                      bool aIsContextMenu,
                                      nsIDOMEvent* aTriggerEvent)
 {
   nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
   if (!popupFrame || !MayShowPopup(popupFrame))
     return;
 
   nsCOMPtr<nsIContent> triggerContent;
   InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
 
   popupFrame->InitializePopupAtScreen(triggerContent, aXPos, aYPos, aIsContextMenu);
-  FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
+  FirePopupShowingEvent(aPopup, aIsContextMenu, false);
 }
 
 void
 nsXULPopupManager::ShowPopupAtScreenRect(nsIContent* aPopup,
                                          const nsAString& aPosition,
                                          const nsIntRect& aRect,
                                          bool aIsContextMenu,
                                          bool aAttributesOverride,
@@ -828,17 +828,17 @@ nsXULPopupManager::ShowPopupAtScreenRect
     return;
 
   nsCOMPtr<nsIContent> triggerContent;
   InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
 
   popupFrame->InitializePopupAtRect(triggerContent, aPosition,
                                     aRect, aAttributesOverride);
 
-  FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
+  FirePopupShowingEvent(aPopup, aIsContextMenu, false);
 }
 
 void
 nsXULPopupManager::ShowTooltipAtScreen(nsIContent* aPopup,
                                        nsIContent* aTriggerContent,
                                        int32_t aXPos, int32_t aYPos)
 {
   nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
@@ -857,17 +857,17 @@ nsXULPopupManager::ShowTooltipAtScreen(n
     nsIWidget *rootWidget = rootPresContext->GetRootWidget();
     if (rootWidget) {
       mCachedMousePoint -= rootWidget->WidgetToScreenOffset();
     }
   }
 
   popupFrame->InitializePopupAtScreen(aTriggerContent, aXPos, aYPos, false);
 
-  FirePopupShowingEvent(aPopup, false, false, nullptr);
+  FirePopupShowingEvent(aPopup, false, false);
 }
 
 void
 nsXULPopupManager::ShowPopupWithAnchorAlign(nsIContent* aPopup,
                                             nsIContent* aAnchorContent,
                                             nsAString& aAnchor,
                                             nsAString& aAlign,
                                             int32_t aXPos, int32_t aYPos,
@@ -876,17 +876,17 @@ nsXULPopupManager::ShowPopupWithAnchorAl
   nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
   if (!popupFrame || !MayShowPopup(popupFrame))
     return;
 
   InitTriggerEvent(nullptr, nullptr, nullptr);
 
   popupFrame->InitializePopupWithAnchorAlign(aAnchorContent, aAnchor,
                                              aAlign, aXPos, aYPos);
-  FirePopupShowingEvent(aPopup, aIsContextMenu, false, nullptr);
+  FirePopupShowingEvent(aPopup, aIsContextMenu, false);
 }
 
 static void
 CheckCaretDrawingState()
 {
   // There is 1 caret per document, we need to find the focused
   // document and erase its caret.
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
@@ -1424,18 +1424,17 @@ nsXULPopupManager::ExecuteMenu(nsIConten
   aMenu->OwnerDoc()->Dispatch("nsXULMenuCommandEvent",
                               TaskCategory::Other,
                               event.forget());
 }
 
 void
 nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
                                          bool aIsContextMenu,
-                                         bool aSelectFirstItem,
-                                         nsIDOMEvent* aTriggerEvent)
+                                         bool aSelectFirstItem)
 {
   nsCOMPtr<nsIContent> popup = aPopup; // keep a strong reference to the popup
 
   nsMenuPopupFrame* popupFrame = do_QueryFrame(aPopup->GetPrimaryFrame());
   if (!popupFrame)
     return;
 
   nsPresContext *presContext = popupFrame->PresContext();
@@ -1471,24 +1470,16 @@ nsXULPopupManager::FirePopupShowingEvent
   if (rootPresContext) {
     rootPresContext->PresShell()->GetViewManager()->
       GetRootWidget(getter_AddRefs(event.mWidget));
   }
   else {
     event.mWidget = nullptr;
   }
 
-  if (aTriggerEvent) {
-    WidgetMouseEventBase* mouseEvent =
-      aTriggerEvent->WidgetEventPtr()->AsMouseEventBase();
-    if (mouseEvent) {
-      event.inputSource = mouseEvent->inputSource;
-    }
-  }
-
   event.mRefPoint = mCachedMousePoint;
   event.mModifiers = mCachedModifiers;
   EventDispatcher::Dispatch(popup, presContext, &event, nullptr, &status);
 
   mCachedMousePoint = LayoutDeviceIntPoint(0, 0);
   mOpeningPopup = nullptr;
 
   mCachedModifiers = 0;
@@ -2744,17 +2735,17 @@ nsXULPopupManager::KeyPress(nsIDOMKeyEve
   return NS_OK; // I am consuming event
 }
 
 NS_IMETHODIMP
 nsXULPopupShowingEvent::Run()
 {
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
   if (pm) {
-    pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem, nullptr);
+    pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXULPopupHidingEvent::Run()
 {
--- a/layout/xul/nsXULPopupManager.h
+++ b/layout/xul/nsXULPopupManager.h
@@ -726,24 +726,20 @@ protected:
                          bool aDeselectMenu);
 
   /**
    * Fire a popupshowing event on the popup and then open the popup.
    *
    * aPopup - the popup to open
    * aIsContextMenu - true for context menus
    * aSelectFirstItem - true to select the first item in the menu
-   * aTriggerEvent - the event that triggered the showing event.
-   *                 This is currently used to propagate the
-   *                 inputSource attribute. May be null.
    */
   void FirePopupShowingEvent(nsIContent* aPopup,
                              bool aIsContextMenu,
-                             bool aSelectFirstItem,
-                             nsIDOMEvent* aTriggerEvent);
+                             bool aSelectFirstItem);
 
   /**
    * Fire a popuphiding event and then hide the popup. This will be called
    * recursively if aNextPopup and aLastPopup are set in order to hide a chain
    * of open menus. If these are not set, only one popup is closed. However,
    * if the popup type indicates a menu, yet the next popup is not a menu,
    * then this ends the closing of popups. This allows a menulist inside a
    * non-menu to close up the menu but not close up the panel it is contained
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -628,41 +628,16 @@ function sendWheelAndPaint(aTarget, aOff
   };
 
   // Listen for the system wheel event, because it happens after all of
   // the other wheel events, including legacy events.
   SpecialPowers.addSystemEventListener(aWindow, "wheel", onwheel);
   synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow);
 }
 
-function synthesizeNativeTapAtCenter(aTarget, aLongTap = false, aCallback = null, aWindow = window) {
-  let rect = aTarget.getBoundingClientRect();
-  return synthesizeNativeTap(aTarget, rect.width / 2, rect.height / 2, aLongTap, aCallback, aWindow);
-}
-
-function synthesizeNativeTap(aTarget, aOffsetX, aOffsetY, aLongTap = false, aCallback = null, aWindow = window) {
-  let utils = _getDOMWindowUtils(aWindow);
-  if (!utils)
-    return;
-
-  let scale = utils.screenPixelsPerCSSPixel;
-  let rect = aTarget.getBoundingClientRect();
-  let x = (aWindow.mozInnerScreenX + rect.left + aOffsetX) * scale;
-  let y = (aWindow.mozInnerScreenY + rect.top + aOffsetY) * scale;
-
-  let observer = {
-    observe: (subject, topic, data) => {
-      if (aCallback && topic == "mouseevent") {
-        aCallback(data);
-      }
-    }
-  };
-  utils.sendNativeTouchTap(x, y, aLongTap, observer);
-}
-
 function synthesizeNativeMouseMove(aTarget, aOffsetX, aOffsetY, aCallback, aWindow = window) {
   var utils = _getDOMWindowUtils(aWindow);
   if (!utils)
     return;
 
   var rect = aTarget.getBoundingClientRect();
   var x = aOffsetX + window.mozInnerScreenX + rect.left;
   var y = aOffsetY + window.mozInnerScreenY + rect.top;