Bug 1256754 - Add padding to contextmenu items when opened through touch. r=dao
MozReview-Commit-ID: C7z6Pnzf2nb
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -51,16 +51,24 @@ function openContextMenu(aMessage) {
selectionInfo: data.selectionInfo,
disableSetDesktopBackground: data.disableSetDesktopBg,
loginFillInfo: data.loginFillInfo,
parentAllowsMixedContent: data.parentAllowsMixedContent,
userContextId: data.userContextId,
};
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
let event = gContextMenuContentData.event;
+
+ // 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(event.screenX, event.screenY, true);
}
function nsContextMenu(aXulMenu, aIsShift) {
this.shouldDisplay = true;
this.initMenu(aXulMenu, aIsShift);
}
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -2009,16 +2009,28 @@ 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. */
+#contentAreaContextMenu[touchmode] menu,
+#contentAreaContextMenu[touchmode] menuitem {
+ padding-top: 12px;
+ padding-bottom: 12px;
+}
+
+#contentAreaContextMenu[touchmode] > #context-navigation > menuitem {
+ padding-top: 7px;
+ padding-bottom: 7px;
+}
+
#context-navigation {
background-color: menu;
padding-bottom: 4px;
}
#context-sep-navigation {
margin-inline-start: -28px;
margin-top: -4px;