Skip to content

Commit

Permalink
Backed out 2 changesets (bug 1875079) for causing bc failures on brow…
Browse files Browse the repository at this point in the history
…ser_menu_touch.js CLOSED TREE

Backed out changeset 015e7b62138b (bug 1875079)
Backed out changeset 3a62cca5ea26 (bug 1875079)
  • Loading branch information
Norisz Fay committed Jan 22, 2024
1 parent cf9660e commit 935e67e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 21 deletions.
23 changes: 23 additions & 0 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,7 @@ var gBrowserInit = {
}

FullScreen.init();
MenuTouchModeObserver.init();

if (AppConstants.MOZ_DATA_REPORTING) {
gDataNotificationInfoBar.init();
Expand Down Expand Up @@ -2568,6 +2569,7 @@ var gBrowserInit = {
);
Services.obs.removeObserver(gKeywordURIFixup, "keyword-uri-fixup");

MenuTouchModeObserver.uninit();
BrowserOffline.uninit();
CanvasPermissionPromptHelper.uninit();
WebAuthnPromptHelper.uninit();
Expand Down Expand Up @@ -8722,6 +8724,27 @@ var RestoreLastSessionObserver = {
]),
};

/* Observes menus and adjusts their size for better
* usability when opened via a touch screen. */
var MenuTouchModeObserver = {
init() {
window.addEventListener("popupshowing", this, true);
},

handleEvent(event) {
let target = event.originalTarget;
if (event.inputSource == MouseEvent.MOZ_SOURCE_TOUCH) {
target.setAttribute("touchmode", "true");
} else {
target.removeAttribute("touchmode");
}
},

uninit() {
window.removeEventListener("popupshowing", this, true);
},
};

// Prompt user to restart the browser in safe mode
function safeModeRestart() {
if (Services.appinfo.inSafeMode) {
Expand Down
8 changes: 1 addition & 7 deletions browser/components/customizableui/PanelMultiView.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,13 +1219,7 @@ export var PanelMultiView = class extends AssociatedToNode {
// this value will be easy to adjust.
const EXTRA_MARGIN_PX = 20;
maxHeight -= EXTRA_MARGIN_PX;

// if zoom factor is applied by touchmode then max-height will be zoomed
// too, which we do not want.
let zoomFactor = Number(
this._panel.ownerGlobal.getComputedStyle(this._panel).zoom ?? 1
);
return maxHeight / zoomFactor;
return maxHeight;
}

handleEvent(aEvent) {
Expand Down
31 changes: 31 additions & 0 deletions browser/themes/windows/browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,37 @@
margin-bottom: -10px;
}

/* Make menu items larger when opened through touch. */
panel[touchmode],
menupopup[touchmode] {
--arrowpanel-menuitem-padding-block: 12px;
--arrowpanel-menuitem-padding: var(--arrowpanel-menuitem-padding-block) var(--arrowpanel-menuitem-padding-inline);
/* The value for the header back icon padding is selected in a way that the
* height of the header and its separator will be equal to the panel inner
* top padding plus standard menuitem, so that the header's separator will
* be located excatly where a normal toolbarseparator would be located after
* the first menuitem, in a menu without a header. */
--arrowpanel-header-back-icon-padding: 10px;
}

:root[uidensity="compact"] panel[touchmode] {
--arrowpanel-header-back-icon-padding: 12px;
}

menupopup[touchmode] :is(menu, menuitem, menucaption) {
/* Use the var set in the rule above to increase menu items height in menupopups when
* they are opened through touch.
* Panel menu items already have their padding set in panelUI-shared.css with the same var. */
padding-block: var(--arrowpanel-menuitem-padding-block);
}

#contentAreaContextMenu[touchmode] > #context-navigation > menuitem {
/* The navigation menuitems are bigger to begin with because of their inner padding,
* so calculate the padding-block to match normal menuitems height when in touchmode.
* 3.5em is the desired menuitem height (~42px), minus the menuitem actual height devided by 2. */
padding-block: calc((3.5em - 32px) / 2);
}

/* Other menu separators don't extend all the way to the menu edges, but the
one below the navigation buttons in the content context menu should. */
#context-sep-navigation {
Expand Down
8 changes: 0 additions & 8 deletions layout/xul/nsXULPopupManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,12 +874,6 @@ void nsXULPopupManager::ShowPopupAtScreen(Element* aPopup, int32_t aXPos,
BeginShowingPopup(pendingPopup, aIsContextMenu, false);
}

void ToggleTouchMode(const PendingPopup& aPopup) {
aPopup.mPopup->SetBoolAttr(
nsGkAtoms::touchmode,
aPopup.MouseInputSource() == MouseEvent_Binding::MOZ_SOURCE_TOUCH);
}

bool nsXULPopupManager::ShowPopupAsNativeMenu(Element* aPopup, int32_t aXPos,
int32_t aYPos,
bool aIsContextMenu,
Expand Down Expand Up @@ -1623,8 +1617,6 @@ void nsXULPopupManager::BeginShowingPopup(const PendingPopup& aPendingPopup,

PopupType popupType = popupFrame->GetPopupType();

ToggleTouchMode(aPendingPopup);

nsEventStatus status = FirePopupShowingEvent(aPendingPopup, presContext);

// if a panel, blur whatever has focus so that the panel can take the focus.
Expand Down
5 changes: 0 additions & 5 deletions toolkit/themes/shared/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ panel {
padding: 0;
}
}

/* Make menu items larger when opened through touch. */
&[touchmode] {
zoom: 1.3;
}
}

menupopup {
Expand Down
1 change: 0 additions & 1 deletion xpcom/ds/StaticAtoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@
Atom("listitem", "listitem"),
Atom("load", "load"),
Atom("loading", "loading"),
Atom("touchmode", "touchmode"),
Atom("triggeringprincipal", "triggeringprincipal"),
Atom("localedir", "localedir"),
Atom("localName", "local-name"),
Expand Down

0 comments on commit 935e67e

Please sign in to comment.