Bug 1796735 - Remove XULPopupElement.autoPosition. r=dao

This was used to prevent reflows due to popuppositioned events during
view transitions.

The previous patch should've prevented the popuppositioned events to
begin with, plus we no longer use arrows that need positioning etc,
which means we shouldn't be triggering the reflows anyways.

Since this is the only consumer of autoPosition = true/false, we can
remove the code supporting it. It's a bit bogus as per the commit
message of the previous patch and, while fixable, it doesn't seem worth
fixing if we can just get rid of it.

Depends on D159936

Differential Revision: https://phabricator.services.mozilla.com/D159937
This commit is contained in:
Emilio Cobos Álvarez 2022-10-21 13:13:54 +00:00
Родитель 02e4309f1e
Коммит ed02e6e84e
7 изменённых файлов: 2 добавлений и 64 удалений

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

@ -656,17 +656,6 @@ var PanelMultiView = class extends AssociatedToNode {
* subview when a "title" attribute is not specified. * subview when a "title" attribute is not specified.
*/ */
showSubView(viewIdOrNode, anchor) { showSubView(viewIdOrNode, anchor) {
// When autoPosition is true, the popup window manager would attempt to re-position
// the panel as subviews are opened and it changes size. The resulting popoppositioned
// events triggers the binding's arrow position adjustment - and its reflow.
// This is not needed here, as we calculated and set maxHeight so it is known
// to fit the screen while open.
// We do need autoposition for cases where the panel's anchor moves, which can happen
// especially with the "page actions" button in the URL bar (see bug 1520607), so
// we only set this to false when showing a subview, and set it back to true after we
// activate the subview.
this._panel.autoPosition = false;
this._showSubView(viewIdOrNode, anchor).catch(Cu.reportError); this._showSubView(viewIdOrNode, anchor).catch(Cu.reportError);
} }
async _showSubView(viewIdOrNode, anchor) { async _showSubView(viewIdOrNode, anchor) {
@ -894,9 +883,6 @@ var PanelMultiView = class extends AssociatedToNode {
panelView.focusWhenActive = false; panelView.focusWhenActive = false;
} }
panelView.dispatchCustomEvent("ViewShown"); panelView.dispatchCustomEvent("ViewShown");
// Re-enable panel autopositioning.
this._panel.autoPosition = true;
} }
} }

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

@ -34,11 +34,6 @@ interface XULPopupElement : XULElement
{ {
[HTMLConstructor] constructor(); [HTMLConstructor] constructor();
/**
* Allow the popup to automatically position itself.
*/
attribute boolean autoPosition;
/** /**
* Open the popup relative to a specified node at a specific location. * Open the popup relative to a specified node at a specific location.
* *

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

@ -188,21 +188,6 @@ void XULPopupElement::SizeTo(int32_t aWidth, int32_t aHeight) {
} }
} }
bool XULPopupElement::AutoPosition() {
nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(GetPrimaryFrame());
if (menuPopupFrame) {
return menuPopupFrame->GetAutoPosition();
}
return true;
}
void XULPopupElement::SetAutoPosition(bool aShouldAutoPosition) {
nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(GetPrimaryFrame());
if (menuPopupFrame) {
menuPopupFrame->SetAutoPosition(aShouldAutoPosition);
}
}
void XULPopupElement::GetState(nsString& aState) { void XULPopupElement::GetState(nsString& aState) {
// set this here in case there's no frame for the popup // set this here in case there's no frame for the popup
aState.AssignLiteral("closed"); aState.AssignLiteral("closed");

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

@ -51,10 +51,6 @@ class XULPopupElement : public nsXULElement {
SetXULAttr(nsGkAtoms::position, aValue, rv); SetXULAttr(nsGkAtoms::position, aValue, rv);
} }
bool AutoPosition();
void SetAutoPosition(bool aShouldAutoPosition);
void OpenPopup(Element* aAnchorElement, void OpenPopup(Element* aAnchorElement,
const StringOrOpenPopupOptions& aOptions, int32_t aXPos, const StringOrOpenPopupOptions& aOptions, int32_t aXPos,
int32_t aYPos, bool aIsContextMenu, bool aAttributesOverride, int32_t aYPos, bool aIsContextMenu, bool aAttributesOverride,

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

@ -118,7 +118,6 @@ nsMenuPopupFrame::nsMenuPopupFrame(ComputedStyle* aStyle,
mFlip(FlipType_Default), mFlip(FlipType_Default),
mIsOpenChanged(false), mIsOpenChanged(false),
mMenuCanOverlapOSBar(false), mMenuCanOverlapOSBar(false),
mShouldAutoPosition(true),
mInContentShell(true), mInContentShell(true),
mIsMenuLocked(false), mIsMenuLocked(false),
mIsOffset(false), mIsOffset(false),
@ -1023,8 +1022,6 @@ void nsMenuPopupFrame::ShowPopup(bool aIsContextMenu) {
if (sound) sound->PlayEventSound(nsISound::EVENT_MENU_POPUP); if (sound) sound->PlayEventSound(nsISound::EVENT_MENU_POPUP);
} }
} }
mShouldAutoPosition = true;
} }
void nsMenuPopupFrame::ClearTriggerContentIncludingDocument() { void nsMenuPopupFrame::ClearTriggerContentIncludingDocument() {
@ -1440,10 +1437,6 @@ static nsIFrame* MaybeDelegatedAnchorFrame(nsIFrame* aFrame) {
nsresult nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, nsresult nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame,
bool aIsMove, bool aSizedToPopup) { bool aIsMove, bool aSizedToPopup) {
if (!mShouldAutoPosition) {
return NS_OK;
}
// If this is due to a move, return early if the popup hasn't been laid out // If this is due to a move, return early if the popup hasn't been laid out
// yet. On Windows, this can happen when using a drag popup before it opens. // yet. On Windows, this can happen when using a drag popup before it opens.
if (aIsMove && (mPrefSize.width == -1 || mPrefSize.height == -1)) { if (aIsMove && (mPrefSize.width == -1 || mPrefSize.height == -1)) {
@ -2487,16 +2480,6 @@ void nsMenuPopupFrame::MoveToAnchor(nsIContent* aAnchorContent,
SetPopupPosition(nullptr, false, false); SetPopupPosition(nullptr, false, false);
} }
bool nsMenuPopupFrame::GetAutoPosition() { return mShouldAutoPosition; }
void nsMenuPopupFrame::SetAutoPosition(bool aShouldAutoPosition) {
mShouldAutoPosition = aShouldAutoPosition;
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
pm->UpdateFollowAnchor(this);
}
}
int8_t nsMenuPopupFrame::GetAlignmentPosition() const { int8_t nsMenuPopupFrame::GetAlignmentPosition() const {
// The code below handles most cases of alignment, anchor and position values. // The code below handles most cases of alignment, anchor and position values.
// Those that are not handled just return POPUPPOSITION_UNKNOWN. // Those that are not handled just return POPUPPOSITION_UNKNOWN.
@ -2585,8 +2568,7 @@ void nsMenuPopupFrame::CreatePopupView() {
} }
bool nsMenuPopupFrame::ShouldFollowAnchor() { bool nsMenuPopupFrame::ShouldFollowAnchor() {
if (!mShouldAutoPosition || mAnchorType != MenuPopupAnchorType_Node || if (mAnchorType != MenuPopupAnchorType_Node || !mAnchorContent) {
!mAnchorContent) {
return false; return false;
} }

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

@ -324,9 +324,6 @@ class nsMenuPopupFrame final : public nsBoxFrame,
void MoveToAnchor(nsIContent* aAnchorContent, const nsAString& aPosition, void MoveToAnchor(nsIContent* aAnchorContent, const nsAString& aPosition,
int32_t aXPos, int32_t aYPos, bool aAttributesOverride); int32_t aXPos, int32_t aYPos, bool aAttributesOverride);
bool GetAutoPosition();
void SetAutoPosition(bool aShouldAutoPosition);
nsIScrollableFrame* GetScrollFrame(nsIFrame* aStart); nsIScrollableFrame* GetScrollFrame(nsIFrame* aStart);
void SetOverrideConstraintRect(mozilla::LayoutDeviceIntRect aRect) { void SetOverrideConstraintRect(mozilla::LayoutDeviceIntRect aRect) {
@ -396,7 +393,6 @@ class nsMenuPopupFrame final : public nsBoxFrame,
void ShowWithPositionedEvent() { void ShowWithPositionedEvent() {
mPopupState = ePopupPositioning; mPopupState = ePopupPositioning;
mShouldAutoPosition = true;
} }
// Checks for the anchor to change and either moves or hides the popup // Checks for the anchor to change and either moves or hides the popup
@ -618,8 +614,6 @@ class nsMenuPopupFrame final : public nsBoxFrame,
bool mIsTopLevelContextMenu = false; // true for the topmost context menu. bool mIsTopLevelContextMenu = false; // true for the topmost context menu.
bool mMenuCanOverlapOSBar; // can we appear over the taskbar/menubar? bool mMenuCanOverlapOSBar; // can we appear over the taskbar/menubar?
bool mShouldAutoPosition; // Should SetPopupPosition be allowed to auto
// position popup?
bool mInContentShell; // True if the popup is in a content shell bool mInContentShell; // True if the popup is in a content shell
bool mIsMenuLocked; // Should events inside this menu be ignored? bool mIsMenuLocked; // Should events inside this menu be ignored?

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

@ -519,7 +519,7 @@ void nsXULPopupManager::AdjustPopupsOnWindowChange(
// only move popups that are within the same window and where auto // only move popups that are within the same window and where auto
// positioning has not been disabled // positioning has not been disabled
nsMenuPopupFrame* frame = item->Frame(); nsMenuPopupFrame* frame = item->Frame();
if (item->IsNoAutoHide() && frame->GetAutoPosition()) { if (item->IsNoAutoHide()) {
nsIContent* popup = frame->GetContent(); nsIContent* popup = frame->GetContent();
if (popup) { if (popup) {
Document* document = popup->GetUncomposedDoc(); Document* document = popup->GetUncomposedDoc();