Bug 1644337, add an isAnchored property to popups, as popups can be anchored to a rectangle as well as a node. This prevented the arrow from appearing in panels, r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D86099
This commit is contained in:
Neil Deakin 2020-08-10 09:47:38 +00:00
Родитель 154827069d
Коммит 707aba1b0b
4 изменённых файлов: 19 добавлений и 7 удалений

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

@ -142,6 +142,12 @@ interface XULPopupElement : XULElement
*/
readonly attribute Node? triggerNode;
/**
* True if the popup is anchored to a point or rectangle. False if it
* appears at a fixed screen coordinate.
*/
readonly attribute boolean isAnchored;
/**
* Retrieve the anchor that was specified to openPopup or for menupopups in a
* menu, the parent menu.

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

@ -188,6 +188,15 @@ nsINode* XULPopupElement::GetTriggerNode() const {
return nsMenuPopupFrame::GetTriggerContent(menuPopupFrame);
}
bool XULPopupElement::IsAnchored() const {
nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(GetPrimaryFrame());
if (!menuPopupFrame) {
return false;
}
return menuPopupFrame->IsAnchored();
}
// FIXME(emilio): should probably be renamed to GetAnchorElement?
Element* XULPopupElement::GetAnchorNode() const {
nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(GetPrimaryFrame());

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

@ -72,6 +72,8 @@ class XULPopupElement : public nsXULElement {
nsINode* GetTriggerNode() const;
bool IsAnchored() const;
Element* GetAnchorNode() const;
already_AddRefed<DOMRect> GetOuterScreenRect();

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

@ -96,12 +96,7 @@
}
adjustArrowPosition() {
if (!this.isArrowPanel) {
return;
}
var anchor = this.anchorNode;
if (!anchor) {
if (!this.isArrowPanel || !this.isAnchored) {
return;
}
@ -159,7 +154,7 @@
on_popupshowing(event) {
if (this.isArrowPanel && event.target == this) {
var arrow = this.shadowRoot.querySelector(".panel-arrow");
arrow.hidden = this.anchorNode == null;
arrow.hidden = !this.isAnchored;
this.shadowRoot
.querySelector(".panel-arrowbox")
.style.removeProperty("transform");