Issue #1916 - Part 1: Convert flags passed to ReflowChild, FinishReflowChild, etc into an enum class.

Backported from Mozilla bug 1571250.
This commit is contained in:
Job Bautista 2022-06-17 16:05:57 +08:00 committed by roytam1
commit 0423d83560
51 changed files with 365 additions and 303 deletions

View file

@ -235,16 +235,14 @@ nsBox::SetXULBounds(nsBoxLayoutState& aState, const nsRect& aRect, bool aRemoveO
nsRect rect(mRect);
uint32_t flags = GetXULLayoutFlags();
ReflowChildFlags flags = GetXULLayoutFlags() | aState.LayoutFlags();
uint32_t stateFlags = aState.LayoutFlags();
flags |= stateFlags;
if ((flags & NS_FRAME_NO_MOVE_FRAME) == NS_FRAME_NO_MOVE_FRAME)
if ((flags & ReflowChildFlags::NoMoveFrame) ==
ReflowChildFlags::NoMoveFrame) {
SetSize(aRect.Size());
else
} else {
SetRect(aRect);
}
// Nuke the overflow area. The caller is responsible for restoring
// it if necessary.
@ -253,8 +251,7 @@ nsBox::SetXULBounds(nsBoxLayoutState& aState, const nsRect& aRect, bool aRemoveO
ClearOverflowRects();
}
if (!(flags & NS_FRAME_NO_MOVE_VIEW))
{
if (!(flags & ReflowChildFlags::NoMoveView)) {
nsContainerFrame::PositionFrameView(this);
if ((rect.x != aRect.x) || (rect.y != aRect.y))
nsContainerFrame::PositionChildViews(this);
@ -533,11 +530,7 @@ nsBox::SyncLayout(nsBoxLayoutState& aState)
nsPresContext* presContext = aState.PresContext();
uint32_t flags = GetXULLayoutFlags();
uint32_t stateFlags = aState.LayoutFlags();
flags |= stateFlags;
ReflowChildFlags flags = GetXULLayoutFlags() | aState.LayoutFlags();
nsRect visualOverflow;

View file

@ -905,8 +905,8 @@ nsBoxFrame::GetXULFlex()
NS_IMETHODIMP
nsBoxFrame::DoXULLayout(nsBoxLayoutState& aState)
{
uint32_t oldFlags = aState.LayoutFlags();
aState.SetLayoutFlags(0);
ReflowChildFlags oldFlags = aState.LayoutFlags();
aState.SetLayoutFlags(ReflowChildFlags::Default);
nsresult rv = NS_OK;
if (mLayoutManager) {

View file

@ -19,7 +19,7 @@ nsBoxLayoutState::nsBoxLayoutState(nsPresContext* aPresContext,
: mPresContext(aPresContext)
, mRenderingContext(aRenderingContext)
, mOuterReflowInput(aOuterReflowInput)
, mLayoutFlags(0)
, mLayoutFlags(nsIFrame::ReflowChildFlags::Default)
, mReflowDepth(aReflowDepth)
, mPaintingDisabled(false)
{

View file

@ -15,6 +15,7 @@
#include "nsCOMPtr.h"
#include "nsPresContext.h"
#include "nsIFrame.h"
#include "nsIPresShell.h"
class nsRenderingContext;
@ -38,8 +39,10 @@ public:
nsPresContext* PresContext() const { return mPresContext; }
nsIPresShell* PresShell() const { return mPresContext->PresShell(); }
uint32_t LayoutFlags() const { return mLayoutFlags; }
void SetLayoutFlags(uint32_t aFlags) { mLayoutFlags = aFlags; }
nsIFrame::ReflowChildFlags LayoutFlags() const { return mLayoutFlags; }
void SetLayoutFlags(nsIFrame::ReflowChildFlags aFlags) {
mLayoutFlags = aFlags;
}
// if true no one under us will paint during reflow.
void SetPaintingDisabled(bool aDisable) { mPaintingDisabled = aDisable; }
@ -68,7 +71,7 @@ private:
RefPtr<nsPresContext> mPresContext;
nsRenderingContext *mRenderingContext;
const ReflowInput *mOuterReflowInput;
uint32_t mLayoutFlags;
nsIFrame::ReflowChildFlags mLayoutFlags;
uint16_t mReflowDepth;
bool mPaintingDisabled;
};

View file

@ -202,8 +202,9 @@ nsDeckFrame::DoXULLayout(nsBoxLayoutState& aState)
{
// Make sure we tweak the state so it does not resize our children.
// We will do that.
uint32_t oldFlags = aState.LayoutFlags();
aState.SetLayoutFlags(NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_VISIBILITY);
ReflowChildFlags oldFlags = aState.LayoutFlags();
aState.SetLayoutFlags(ReflowChildFlags::NoSizeView |
ReflowChildFlags::NoVisibility);
// do a normal layout
nsresult rv = nsBoxFrame::DoXULLayout(aState);

View file

@ -531,7 +531,7 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu,
}
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
nsContainerFrame::SyncFrameViewProperties(pc, this, nullptr, view, 0);
nsContainerFrame::SyncFrameViewProperties(pc, this, nullptr, view);
}
// finally, if the popup just opened, send a popupshown event
@ -993,10 +993,9 @@ nsMenuPopupFrame::HidePopup(bool aDeselectMenu, nsPopupState aNewState)
}
}
uint32_t
nsMenuPopupFrame::GetXULLayoutFlags()
{
return NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_MOVE_VIEW | NS_FRAME_NO_VISIBILITY;
nsIFrame::ReflowChildFlags nsMenuPopupFrame::GetXULLayoutFlags() {
return ReflowChildFlags::NoSizeView | ReflowChildFlags::NoMoveView |
ReflowChildFlags::NoVisibility;
}
///////////////////////////////////////////////////////////////////////////////

View file

@ -447,7 +447,7 @@ protected:
nsPopupLevel PopupLevel(bool aIsNoAutoHide) const;
// redefine to tell the box system not to move the views.
virtual uint32_t GetXULLayoutFlags() override;
ReflowChildFlags GetXULLayoutFlags() override;
void InitPositionFromAnchorAlign(const nsAString& aAnchor,
const nsAString& aAlign);