Bug 1301630 - Remove nsBlockFrame::SetFlags().
Per
bug 1299753 comment 20, SetFlags() is designed for flag propagation
to continuations during block reflow. To avoid misuse, I expand
SetFlags() directly in the only reasonable caller nsBlackFrame::Init(),
and replace other usages by AddStateBits().
MozReview-Commit-ID: GsbE2Z0Rps1
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5056,18 +5056,18 @@ nsCSSFrameConstructor::FlushAccumulatedB
blockContext = styleSet->
ResolveAnonymousBoxStyle(anonPseudo, parentContext);
// then, create a block frame that will wrap the child frames. Make it a
// MathML frame so that Get(Absolute/Float)ContainingBlockFor know that this
// is not a suitable block.
nsContainerFrame* blockFrame =
- NS_NewMathMLmathBlockFrame(mPresShell, blockContext,
- NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
+ NS_NewMathMLmathBlockFrame(mPresShell, blockContext);
+ blockFrame->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
InitAndRestoreFrame(aState, aContent, aParentFrame, blockFrame);
ReparentFrames(this, blockFrame, aBlockItems);
// abs-pos and floats are disabled in MathML children so we don't have to
// worry about messing up those.
blockFrame->SetInitialChildList(kPrincipalList, aBlockItems);
NS_ASSERTION(aBlockItems.IsEmpty(), "What happened?");
aBlockItems.Clear();
@@ -5097,17 +5097,17 @@ nsCSSFrameConstructor::FindMathMLData(El
if (aTag == nsGkAtoms::math) {
// This needs to match the test in EnsureBlockDisplay in
// nsRuleNode.cpp. Though the behavior here for the display:table
// case is pretty weird...
if (aStyleContext->StyleDisplay()->IsBlockOutsideStyle()) {
static const FrameConstructionData sBlockMathData =
FCDATA_DECL(FCDATA_FORCE_NULL_ABSPOS_CONTAINER |
FCDATA_WRAP_KIDS_IN_BLOCKS,
- NS_CreateNewMathMLmathBlockFrame);
+ NS_NewMathMLmathBlockFrame);
return &sBlockMathData;
}
static const FrameConstructionData sInlineMathData =
FCDATA_DECL(FCDATA_FORCE_NULL_ABSPOS_CONTAINER |
FCDATA_IS_LINE_PARTICIPANT |
FCDATA_WRAP_KIDS_IN_BLOCKS,
NS_NewMathMLmathInlineFrame);
--- a/layout/forms/nsSelectsAreaFrame.cpp
+++ b/layout/forms/nsSelectsAreaFrame.cpp
@@ -12,17 +12,17 @@ using namespace mozilla;
nsContainerFrame*
NS_NewSelectsAreaFrame(nsIPresShell* aShell, nsStyleContext* aContext, nsFrameState aFlags)
{
nsSelectsAreaFrame* it = new (aShell) nsSelectsAreaFrame(aContext);
// We need NS_BLOCK_FLOAT_MGR to ensure that the options inside the select
// aren't expanded by right floats outside the select.
- it->SetFlags(aFlags | NS_BLOCK_FLOAT_MGR);
+ it->AddStateBits(aFlags | NS_BLOCK_FLOAT_MGR);
return it;
}
NS_IMPL_FRAMEARENA_HELPERS(nsSelectsAreaFrame)
//---------------------------------------------------------
/**
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -6794,18 +6794,19 @@ nsBlockFrame::ChildIsDirty(nsIFrame* aCh
void
nsBlockFrame::Init(nsIContent* aContent,
nsContainerFrame* aParent,
nsIFrame* aPrevInFlow)
{
if (aPrevInFlow) {
// Copy over the inherited block frame bits from the prev-in-flow.
- SetFlags(aPrevInFlow->GetStateBits() &
- (NS_BLOCK_FLAGS_MASK & ~NS_BLOCK_FLAGS_NON_INHERITED_MASK));
+ RemoveStateBits(NS_BLOCK_FLAGS_MASK);
+ AddStateBits(aPrevInFlow->GetStateBits() &
+ (NS_BLOCK_FLAGS_MASK & ~NS_BLOCK_FLAGS_NON_INHERITED_MASK));
}
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
if (!aPrevInFlow ||
aPrevInFlow->GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION) {
AddStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
}
--- a/layout/generic/nsBlockFrame.h
+++ b/layout/generic/nsBlockFrame.h
@@ -391,21 +391,16 @@ protected:
nsFrameList& aFrameList, nsLineList& aLineList);
void TryAllLines(nsLineList::iterator* aIterator,
nsLineList::iterator* aStartIterator,
nsLineList::iterator* aEndIterator,
bool* aInOverflowLines,
FrameLines** aOverflowLines);
- void SetFlags(nsFrameState aFlags) {
- mState &= ~NS_BLOCK_FLAGS_MASK;
- mState |= aFlags;
- }
-
/** move the frames contained by aLine by aDeltaBCoord
* if aLine is a block, its child floats are added to the state manager
*/
void SlideLine(BlockReflowInput& aState,
nsLineBox* aLine, nscoord aDeltaBCoord);
void UpdateLineContainerSize(nsLineBox* aLine,
const nsSize& aNewContainerSize);
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -1578,22 +1578,19 @@ nsMathMLContainerFrame::ReportInvalidChi
{ aChildTag->GetUTF16String(),
mContent->NodeInfo()->NameAtom()->GetUTF16String() };
return ReportErrorToConsole("InvalidChild", argv, 2);
}
//==========================
nsContainerFrame*
-NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext,
- nsFrameState aFlags)
+NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
- nsMathMLmathBlockFrame* it = new (aPresShell) nsMathMLmathBlockFrame(aContext);
- it->SetFlags(aFlags);
- return it;
+ return new (aPresShell) nsMathMLmathBlockFrame(aContext);
}
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmathBlockFrame)
NS_QUERYFRAME_HEAD(nsMathMLmathBlockFrame)
NS_QUERYFRAME_ENTRY(nsMathMLmathBlockFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
--- a/layout/mathml/nsMathMLContainerFrame.h
+++ b/layout/mathml/nsMathMLContainerFrame.h
@@ -413,17 +413,17 @@ private:
// Issues: If/when mathml becomes a pluggable component, the separation will be needed.
class nsMathMLmathBlockFrame : public nsBlockFrame {
public:
NS_DECL_QUERYFRAME_TARGET(nsMathMLmathBlockFrame)
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
friend nsContainerFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell,
- nsStyleContext* aContext, nsFrameState aFlags);
+ nsStyleContext* aContext);
// beware, mFrames is not set by nsBlockFrame
// cannot use mFrames{.FirstChild()|.etc} since the block code doesn't set mFrames
virtual void
SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) override
{
NS_ASSERTION(aListID == kPrincipalList, "unexpected frame list");
@@ -476,17 +476,18 @@ public:
return mFrames.FirstChild() != mFrames.LastChild() ||
!mFrames.FirstChild();
}
protected:
explicit nsMathMLmathBlockFrame(nsStyleContext* aContext) : nsBlockFrame(aContext) {
// We should always have a float manager. Not that things can really try
// to float out of us anyway, but we need one for line layout.
- AddStateBits(NS_BLOCK_FLOAT_MGR);
+ // Bug 1301881: Do we still need to set NS_BLOCK_FLOAT_MGR?
+ // AddStateBits(NS_BLOCK_FLOAT_MGR);
}
virtual ~nsMathMLmathBlockFrame() {}
};
// --------------
class nsMathMLmathInlineFrame : public nsInlineFrame,
public nsMathMLFrame {
--- a/layout/mathml/nsMathMLParts.h
+++ b/layout/mathml/nsMathMLParts.h
@@ -31,15 +31,11 @@ nsContainerFrame* NS_NewMathMLmtrFrame(n
nsContainerFrame* NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsTableFrame* aTableFrame);
nsContainerFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmsqrtFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmrootFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmactionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame* NS_NewMathMLsemanticsFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
-nsContainerFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags);
+nsContainerFrame* NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsContainerFrame* NS_NewMathMLmathInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
-inline nsContainerFrame* NS_CreateNewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
-{
- return NS_NewMathMLmathBlockFrame(aPresShell, aContext, nsFrameState(0));
-}
#endif /* nsMathMLParts_h___ */
--- a/layout/xul/nsXULLabelFrame.cpp
+++ b/layout/xul/nsXULLabelFrame.cpp
@@ -11,18 +11,18 @@
#include "nsNameSpaceManager.h"
using namespace mozilla;
nsIFrame*
NS_NewXULLabelFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
nsXULLabelFrame* it = new (aPresShell) nsXULLabelFrame(aContext);
-
- it->SetFlags(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
+
+ it->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
return it;
}
NS_IMPL_FRAMEARENA_HELPERS(nsXULLabelFrame)
// If you make changes to this function, check its counterparts
// in nsBoxFrame and nsTextBoxFrame