mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 16:22:00 +00:00
Bug 1901769 - Make MenuPopupAnchorType an enum class. r=layout-reviewers,jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D217933
This commit is contained in:
parent
86a995b3f0
commit
496683f083
@ -482,7 +482,7 @@ nscoord nsMenuPopupFrame::IntrinsicISize(gfxContext* aContext,
|
||||
if (nsIFrame* menuList = GetInFlowParent()) {
|
||||
menuListOrAnchorWidth = menuList->GetRect().width;
|
||||
}
|
||||
if (mAnchorType == MenuPopupAnchorType_Rect) {
|
||||
if (mAnchorType == MenuPopupAnchorType::Rect) {
|
||||
menuListOrAnchorWidth = std::max(menuListOrAnchorWidth, mScreenRect.width);
|
||||
}
|
||||
// Input margin doesn't have contents, so account for it for popup sizing
|
||||
@ -776,7 +776,7 @@ void nsMenuPopupFrame::InitializePopup(nsIContent* aAnchorContent,
|
||||
// if aAttributesOverride is true, then the popupanchor, popupalign and
|
||||
// position attributes on the <menupopup> override those values passed in.
|
||||
// If false, those attributes are only used if the values passed in are empty
|
||||
if (aAnchorContent || aAnchorType == MenuPopupAnchorType_Rect) {
|
||||
if (aAnchorContent || aAnchorType == MenuPopupAnchorType::Rect) {
|
||||
nsAutoString anchor, align, position;
|
||||
mContent->AsElement()->GetAttr(nsGkAtoms::popupanchor, anchor);
|
||||
mContent->AsElement()->GetAttr(nsGkAtoms::popupalign, align);
|
||||
@ -901,7 +901,7 @@ void nsMenuPopupFrame::InitializePopupAtScreen(nsIContent* aTriggerContent,
|
||||
mIsContextMenu = aIsContextMenu;
|
||||
mIsTopLevelContextMenu = aIsContextMenu;
|
||||
mIsNativeMenu = false;
|
||||
mAnchorType = MenuPopupAnchorType_Point;
|
||||
mAnchorType = MenuPopupAnchorType::Point;
|
||||
mPositionedOffset = 0;
|
||||
mPositionedByMoveToRect = false;
|
||||
}
|
||||
@ -922,7 +922,7 @@ void nsMenuPopupFrame::InitializePopupAsNativeContextMenu(
|
||||
mIsContextMenu = true;
|
||||
mIsTopLevelContextMenu = true;
|
||||
mIsNativeMenu = true;
|
||||
mAnchorType = MenuPopupAnchorType_Point;
|
||||
mAnchorType = MenuPopupAnchorType::Point;
|
||||
mPositionedOffset = 0;
|
||||
mPositionedByMoveToRect = false;
|
||||
}
|
||||
@ -932,7 +932,7 @@ void nsMenuPopupFrame::InitializePopupAtRect(nsIContent* aTriggerContent,
|
||||
const nsIntRect& aRect,
|
||||
bool aAttributesOverride) {
|
||||
InitializePopup(nullptr, aTriggerContent, aPosition, 0, 0,
|
||||
MenuPopupAnchorType_Rect, aAttributesOverride);
|
||||
MenuPopupAnchorType::Rect, aAttributesOverride);
|
||||
mScreenRect = ToAppUnits(aRect, AppUnitsPerCSSPixel());
|
||||
}
|
||||
|
||||
@ -1445,7 +1445,7 @@ auto nsMenuPopupFrame::GetRects(const nsSize& aPrefSize) const -> Rects {
|
||||
result.mAnchorRect = result.mUntransformedAnchorRect = [&] {
|
||||
// If anchored to a rectangle, use that rectangle. Otherwise, determine
|
||||
// the rectangle from the anchor.
|
||||
if (mAnchorType == MenuPopupAnchorType_Rect) {
|
||||
if (mAnchorType == MenuPopupAnchorType::Rect) {
|
||||
return mScreenRect;
|
||||
}
|
||||
// if the frame is not specified, use the anchor node passed to OpenPopup.
|
||||
@ -1465,7 +1465,7 @@ auto nsMenuPopupFrame::GetRects(const nsSize& aPrefSize) const -> Rects {
|
||||
// When doing this reposition, we want to move the popup to the side with
|
||||
// the most room. The combination of anchor and alignment dictate if we
|
||||
// readjust above/below or to the left/right.
|
||||
if (mAnchorContent || mAnchorType == MenuPopupAnchorType_Rect) {
|
||||
if (mAnchorContent || mAnchorType == MenuPopupAnchorType::Rect) {
|
||||
// move the popup according to the anchor and alignment. This will also
|
||||
// tell us which axis the popup is flush against in case we have to move
|
||||
// it around later. The AdjustPositionForAnchorAlign method accounts for
|
||||
@ -1728,12 +1728,12 @@ void nsMenuPopupFrame::PerformMove(const Rects& aRects) {
|
||||
// by the anchor are lost, but this is super-old behavior.
|
||||
const bool fixPositionToPoint =
|
||||
IsNoAutoHide() && (GetPopupLevel() != PopupLevel::Parent ||
|
||||
mAnchorType == MenuPopupAnchorType_Rect);
|
||||
mAnchorType == MenuPopupAnchorType::Rect);
|
||||
if (fixPositionToPoint) {
|
||||
// Account for the margin that will end up being added to the screen
|
||||
// coordinate the next time SetPopupPosition is called.
|
||||
const auto& margin = GetMargin();
|
||||
mAnchorType = MenuPopupAnchorType_Point;
|
||||
mAnchorType = MenuPopupAnchorType::Point;
|
||||
mScreenRect.x = aRects.mUsedRect.x - margin.left;
|
||||
mScreenRect.y = aRects.mUsedRect.y - margin.top;
|
||||
}
|
||||
@ -1741,8 +1741,8 @@ void nsMenuPopupFrame::PerformMove(const Rects& aRects) {
|
||||
// For anchored popups that shouldn't follow the anchor, fix the original
|
||||
// anchor rect.
|
||||
if (IsAnchored() && !ShouldFollowAnchor() && !mUsedScreenRect.IsEmpty() &&
|
||||
mAnchorType != MenuPopupAnchorType_Rect) {
|
||||
mAnchorType = MenuPopupAnchorType_Rect;
|
||||
mAnchorType != MenuPopupAnchorType::Rect) {
|
||||
mAnchorType = MenuPopupAnchorType::Rect;
|
||||
mScreenRect = aRects.mUntransformedAnchorRect;
|
||||
}
|
||||
|
||||
@ -2207,7 +2207,7 @@ void nsMenuPopupFrame::MoveTo(const CSSPoint& aPos, bool aUpdateAttrs,
|
||||
|
||||
mPositionedByMoveToRect = aByMoveToRect;
|
||||
mScreenRect.MoveTo(appUnitsPos);
|
||||
if (mAnchorType == MenuPopupAnchorType_Rect) {
|
||||
if (mAnchorType == MenuPopupAnchorType::Rect) {
|
||||
// This ensures that the anchor width is still honored, to prevent it from
|
||||
// changing spuriously.
|
||||
mScreenRect.height = 0;
|
||||
@ -2217,7 +2217,7 @@ void nsMenuPopupFrame::MoveTo(const CSSPoint& aPos, bool aUpdateAttrs,
|
||||
mPopupAnchor = POPUPALIGNMENT_BOTTOMLEFT;
|
||||
mXPos = mYPos = 0;
|
||||
} else {
|
||||
mAnchorType = MenuPopupAnchorType_Point;
|
||||
mAnchorType = MenuPopupAnchorType::Point;
|
||||
}
|
||||
|
||||
SetPopupPosition(true);
|
||||
@ -2241,7 +2241,7 @@ void nsMenuPopupFrame::MoveToAnchor(nsIContent* aAnchorContent,
|
||||
|
||||
nsPopupState oldstate = mPopupState;
|
||||
InitializePopup(aAnchorContent, mTriggerContent, aPosition, aXPos, aYPos,
|
||||
MenuPopupAnchorType_Node, aAttributesOverride);
|
||||
MenuPopupAnchorType::Node, aAttributesOverride);
|
||||
// InitializePopup changed the state so reset it.
|
||||
mPopupState = oldstate;
|
||||
|
||||
@ -2335,7 +2335,7 @@ void nsMenuPopupFrame::CreatePopupView() {
|
||||
}
|
||||
|
||||
bool nsMenuPopupFrame::ShouldFollowAnchor() const {
|
||||
if (mAnchorType != MenuPopupAnchorType_Node || !mAnchorContent) {
|
||||
if (mAnchorType != MenuPopupAnchorType::Node || !mAnchorContent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -63,10 +63,10 @@ enum FlipType {
|
||||
FlipType_Slide = 3 // allow the arrow to "slide" instead of resizing
|
||||
};
|
||||
|
||||
enum MenuPopupAnchorType {
|
||||
MenuPopupAnchorType_Node = 0, // anchored to a node
|
||||
MenuPopupAnchorType_Point = 1, // unanchored and positioned at a screen point
|
||||
MenuPopupAnchorType_Rect = 2, // anchored at a screen rectangle
|
||||
enum class MenuPopupAnchorType : uint8_t {
|
||||
Node = 0, // anchored to a node
|
||||
Point = 1, // unanchored, and positioned at a screen point
|
||||
Rect = 2, // anchored at a screen rectangle
|
||||
};
|
||||
|
||||
// values are selected so that the direction can be flipped just by
|
||||
@ -383,7 +383,7 @@ class nsMenuPopupFrame final : public nsBlockFrame {
|
||||
void PerformMove(const Rects&);
|
||||
|
||||
// Return true if the popup is positioned relative to an anchor.
|
||||
bool IsAnchored() const { return mAnchorType != MenuPopupAnchorType_Point; }
|
||||
bool IsAnchored() const { return mAnchorType != MenuPopupAnchorType::Point; }
|
||||
|
||||
// Return the anchor if there is one.
|
||||
nsIContent* GetAnchor() const { return mAnchorContent; }
|
||||
@ -634,7 +634,7 @@ class nsMenuPopupFrame final : public nsBlockFrame {
|
||||
mutable nscoord mPositionedOffset = 0;
|
||||
|
||||
// How the popup is anchored.
|
||||
MenuPopupAnchorType mAnchorType = MenuPopupAnchorType_Node;
|
||||
MenuPopupAnchorType mAnchorType = MenuPopupAnchorType::Node;
|
||||
|
||||
nsRect mOverrideConstraintRect;
|
||||
|
||||
|
@ -855,7 +855,7 @@ void nsXULPopupManager::ShowMenu(nsIContent* aMenu, bool aSelectFirstItem) {
|
||||
|
||||
// there is no trigger event for menus
|
||||
popupFrame->InitializePopup(aMenu, nullptr, position, 0, 0,
|
||||
MenuPopupAnchorType_Node, true);
|
||||
MenuPopupAnchorType::Node, true);
|
||||
PendingPopup pendingPopup(&popupFrame->PopupElement(), nullptr);
|
||||
BeginShowingPopup(pendingPopup, parentIsContextMenu, aSelectFirstItem);
|
||||
}
|
||||
@ -897,7 +897,7 @@ void nsXULPopupManager::ShowPopup(Element* aPopup, nsIContent* aAnchorContent,
|
||||
nsCOMPtr<nsIContent> triggerContent = pendingPopup.GetTriggerContent();
|
||||
|
||||
popupFrame->InitializePopup(aAnchorContent, triggerContent, aPosition, aXPos,
|
||||
aYPos, MenuPopupAnchorType_Node,
|
||||
aYPos, MenuPopupAnchorType::Node,
|
||||
aAttributesOverride);
|
||||
|
||||
BeginShowingPopup(pendingPopup, aIsContextMenu, aSelectFirstItem);
|
||||
|
Loading…
Reference in New Issue
Block a user