Merge m-c to inbound. a=merge

This commit is contained in:
Ryan VanderMeulen 2017-06-27 20:06:39 -04:00
commit a8806a9105
11 changed files with 20333 additions and 20526 deletions

View File

@ -1634,10 +1634,6 @@ var gBrowserInit = {
FullScreen.init();
PointerLock.init();
if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
ContextMenuTouchModeObserver.init();
}
// initialize the sync UI
gSync.init();
@ -1847,9 +1843,6 @@ var gBrowserInit = {
this.gmpInstallManager.uninit();
}
if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
ContextMenuTouchModeObserver.uninit();
}
BrowserOffline.uninit();
IndexedDBPromptHelper.uninit();
PanelUI.uninit();
@ -8226,77 +8219,6 @@ 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) {

View File

@ -62,14 +62,14 @@ function openContextMenu(aMessage) {
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) {

View File

@ -4,5 +4,3 @@ support-files =
subtst_contextmenu_webext.html
[browser_contextmenu_mozextension.js]
[browser_contextmenu_touch.js]
skip-if = !(os == 'win' && os_version == '10.0')

View File

@ -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);
});

View File

@ -1970,8 +1970,8 @@ notification.pluginVulnerable > .notification-inner > .messageCloseButton {
%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;
}

View File

@ -771,7 +771,7 @@ nsXULPopupManager::ShowMenu(nsIContent *aMenu,
}
else {
nsCOMPtr<nsIContent> popupContent = popupFrame->GetContent();
FirePopupShowingEvent(popupContent, parentIsContextMenu, aSelectFirstItem, nullptr);
FirePopupShowingEvent(popupContent, parentIsContextMenu, aSelectFirstItem);
}
}
@ -795,7 +795,7 @@ nsXULPopupManager::ShowPopup(nsIContent* aPopup,
popupFrame->InitializePopup(aAnchorContent, triggerContent, aPosition,
aXPos, aYPos, MenuPopupAnchorType_Node, aAttributesOverride);
FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem, aTriggerEvent);
FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem);
}
void
@ -812,7 +812,7 @@ nsXULPopupManager::ShowPopupAtScreen(nsIContent* aPopup,
InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
popupFrame->InitializePopupAtScreen(triggerContent, aXPos, aYPos, aIsContextMenu);
FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
FirePopupShowingEvent(aPopup, aIsContextMenu, false);
}
void
@ -833,7 +833,7 @@ nsXULPopupManager::ShowPopupAtScreenRect(nsIContent* aPopup,
popupFrame->InitializePopupAtRect(triggerContent, aPosition,
aRect, aAttributesOverride);
FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
FirePopupShowingEvent(aPopup, aIsContextMenu, false);
}
void
@ -862,7 +862,7 @@ nsXULPopupManager::ShowTooltipAtScreen(nsIContent* aPopup,
popupFrame->InitializePopupAtScreen(aTriggerContent, aXPos, aYPos, false);
FirePopupShowingEvent(aPopup, false, false, nullptr);
FirePopupShowingEvent(aPopup, false, false);
}
void
@ -881,7 +881,7 @@ nsXULPopupManager::ShowPopupWithAnchorAlign(nsIContent* aPopup,
popupFrame->InitializePopupWithAnchorAlign(aAnchorContent, aAnchor,
aAlign, aXPos, aYPos);
FirePopupShowingEvent(aPopup, aIsContextMenu, false, nullptr);
FirePopupShowingEvent(aPopup, aIsContextMenu, false);
}
static void
@ -1429,8 +1429,7 @@ nsXULPopupManager::ExecuteMenu(nsIContent* aMenu, nsXULMenuCommandEvent* aEvent)
void
nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
bool aIsContextMenu,
bool aSelectFirstItem,
nsIDOMEvent* aTriggerEvent)
bool aSelectFirstItem)
{
nsCOMPtr<nsIContent> popup = aPopup; // keep a strong reference to the popup
@ -1476,14 +1475,6 @@ nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
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);
@ -2749,7 +2740,7 @@ nsXULPopupShowingEvent::Run()
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem, nullptr);
pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem);
}
return NS_OK;

View File

@ -731,14 +731,10 @@ protected:
* 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

View File

@ -1161,4 +1161,4 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
static const int32_t kUnknownId = -1;
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1506958615194000);
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1507044980295000);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -633,31 +633,6 @@ function sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, aEvent, aCallback, aWind
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)