Bug 1762152 - Remove XULPopupElement.isAnchored. r=Gijs

On Wayland popup flipping and such is not Firefox's responsibility.

Once we've decided the final popup position because the compositor told
us, we move the popup to a fixed position, and internally the popup
becomes unanchored.

Using this boolean to make decisions after the initial popuppositioned
event is wrong, so avoid exposing it to JS.

Differential Revision: https://phabricator.services.mozilla.com/D142679
This commit is contained in:
Emilio Cobos Álvarez 2022-04-04 13:29:30 +00:00
Родитель 76bffc61c5
Коммит 8edd7b11cf
6 изменённых файлов: 6 добавлений и 21 удалений

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

@ -5,6 +5,7 @@
*/
dictionary PopupPositionedEventInit : EventInit {
boolean isAnchored = false;
/**
* Returns the alignment position where the popup has appeared relative to its
* anchor node or point, accounting for any flipping that occurred.
@ -17,6 +18,7 @@ dictionary PopupPositionedEventInit : EventInit {
interface PopupPositionedEvent : Event {
constructor(DOMString type, optional PopupPositionedEventInit init = {});
readonly attribute boolean isAnchored;
readonly attribute DOMString alignmentPosition;
readonly attribute long alignmentOffset;
};

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

@ -167,12 +167,6 @@ 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.

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

@ -237,22 +237,12 @@ 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());
if (!menuPopupFrame) {
return nullptr;
}
return Element::FromNodeOrNull(menuPopupFrame->GetAnchor());
}

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

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

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

@ -2932,6 +2932,7 @@ nsXULPopupPositionedEvent::Run() {
PopupPositionedEventInit init;
init.mComposed = true;
init.mIsAnchored = popupFrame->IsAnchored();
init.mAlignmentOffset = popupOffset;
AlignmentPositionToString(popupFrame, init.mAlignmentPosition);
RefPtr<PopupPositionedEvent> event =

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

@ -92,7 +92,7 @@
}
_setSideAttribute(event) {
if (!this.isArrowPanel || !this.isAnchored) {
if (!this.isArrowPanel || !event.isAnchored) {
return;
}
@ -123,7 +123,7 @@
this.panelContent.style.display = "";
}
if (this.isArrowPanel && event.target == this) {
if (this.isAnchored && this.anchorNode) {
if (this.anchorNode) {
let anchorRoot =
this.anchorNode.closest("toolbarbutton, .anchor-root") ||
this.anchorNode;
@ -194,7 +194,7 @@
this.setAttribute("animate", "cancel");
}
if (this.isAnchored && this.anchorNode) {
if (this.anchorNode) {
let anchorRoot =
this.anchorNode.closest("toolbarbutton, .anchor-root") ||
this.anchorNode;