Bug 1826622 - Constrain autocomplete popup like select. r=Gijs,sgalich

Depends on D175039

Differential Revision: https://phabricator.services.mozilla.com/D175040
This commit is contained in:
Emilio Cobos Álvarez 2023-04-11 19:59:06 +00:00
Родитель ccd60c00e5
Коммит ba8392212e
5 изменённых файлов: 19 добавлений и 14 удалений

Просмотреть файл

@ -319,7 +319,7 @@ class BasePopup {
browser.setAttribute("tooltip", "aHTMLTooltip");
browser.setAttribute("contextmenu", "contentAreaContextMenu");
browser.setAttribute("autocompletepopup", "PopupAutoComplete");
browser.setAttribute("selectmenuconstrained", "false");
browser.setAttribute("constrainpopups", "false");
// Ensure the browser will initially load in the same group as other
// browsers from the same extension.

Просмотреть файл

@ -258,6 +258,7 @@ export class AutoCompleteParent extends JSWindowActorParent {
this.openedPopup._normalMaxRows = this.openedPopup.maxRows;
this.openedPopup.mInput.maxRows = 10;
}
browser.constrainPopup(this.openedPopup);
this.openedPopup.addEventListener("popuphidden", this);
this.openedPopup.addEventListener("popupshowing", this);
this.openedPopup.openPopupAtScreenRect(

Просмотреть файл

@ -309,18 +309,7 @@ export var SelectParentHelper = {
menupopup.classList.toggle("isOpenedViaTouch", isOpenedViaTouch);
if (browser.getAttribute("selectmenuconstrained") != "false") {
let constraintRect = browser.getBoundingClientRect();
constraintRect = new win.DOMRect(
constraintRect.left + win.mozInnerScreenX,
constraintRect.top + win.mozInnerScreenY,
constraintRect.width,
constraintRect.height
);
menupopup.setConstraintRect(constraintRect);
} else {
menupopup.setConstraintRect(new win.DOMRect(0, 0, 0, 0));
}
browser.constrainPopup(menupopup);
menupopup.openPopupAtScreenRect(
AppConstants.platform == "macosx" ? "selection" : "after_start",
rect.left,

Просмотреть файл

@ -86,7 +86,7 @@ document.addEventListener(
e => {
window._initialized = PrintEventHandler.init().catch(e => console.error(e));
ourBrowser.setAttribute("flex", "0");
ourBrowser.setAttribute("selectmenuconstrained", "false");
ourBrowser.setAttribute("constrainpopups", "false");
ourBrowser.classList.add("printSettingsBrowser");
ourBrowser.closest(".dialogBox")?.classList.add("printDialogBox");
},

Просмотреть файл

@ -995,6 +995,21 @@
);
}
constrainPopup(popup) {
if (this.getAttribute("constrainpopups") != "false") {
let constraintRect = this.getBoundingClientRect();
constraintRect = new DOMRect(
constraintRect.left + window.mozInnerScreenX,
constraintRect.top + window.mozInnerScreenY,
constraintRect.width,
constraintRect.height
);
popup.setConstraintRect(constraintRect);
} else {
popup.setConstraintRect(new DOMRect(0, 0, 0, 0));
}
}
construct() {
elementsToDestroyOnUnload.add(this);
this.resetFields();