From 2ec308723b1686c1ddd68d8de08d56a60226836e Mon Sep 17 00:00:00 2001 From: Robert Longson Date: Wed, 15 Feb 2023 21:35:46 +0000 Subject: [PATCH] Bug 1651129 - Convert uses of mState to various StateBits methods and make mState private r=emilio Differential Revision: https://phabricator.services.mozilla.com/D169943 --- layout/generic/nsBlockFrame.cpp | 14 +++++++------- layout/generic/nsBlockFrame.h | 4 ++-- layout/generic/nsHTMLCanvasFrame.cpp | 2 +- layout/generic/nsIFrame.cpp | 12 ++++++------ layout/generic/nsIFrame.h | 2 ++ layout/generic/nsImageFrame.cpp | 4 ++-- layout/generic/nsTextFrame.cpp | 26 +++++++++++++------------- layout/generic/nsVideoFrame.cpp | 2 +- layout/tables/nsTableColFrame.cpp | 2 +- layout/xul/nsBoxFrame.cpp | 6 +++--- layout/xul/nsTextBoxFrame.cpp | 2 +- 11 files changed, 39 insertions(+), 37 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index b65ff4d9437b..fd70237f75a5 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -4490,14 +4490,14 @@ void nsBlockFrame::DoReflowInlineFrames( // XXX Unfortunately we need to know this before reflowing the first // inline frame in the line. FIX ME. - if ((0 == aLineLayout.GetLineNumber()) && - (NS_BLOCK_HAS_FIRST_LETTER_CHILD & mState) && - (NS_BLOCK_HAS_FIRST_LETTER_STYLE & mState)) { + if (0 == aLineLayout.GetLineNumber() && + HasAllStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD | + NS_BLOCK_HAS_FIRST_LETTER_STYLE)) { aLineLayout.SetFirstLetterStyleOK(true); } - NS_ASSERTION( - !((NS_BLOCK_HAS_FIRST_LETTER_CHILD & mState) && GetPrevContinuation()), - "first letter child bit should only be on first continuation"); + NS_ASSERTION(!(HasAnyStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD) && + GetPrevContinuation()), + "first letter child bit should only be on first continuation"); // Reflow the frames that are already on the line first LineReflowStatus lineReflowStatus = LineReflowStatus::OK; @@ -7517,7 +7517,7 @@ void nsBlockFrame::SetInitialChildList(ChildListID aListID, !IsColumnSetWrapperFrame() && RefPtr(GetFirstLetterStyle(PresContext())) != nullptr; NS_ASSERTION(haveFirstLetterStyle == - ((mState & NS_BLOCK_HAS_FIRST_LETTER_STYLE) != 0), + HasAnyStateBits(NS_BLOCK_HAS_FIRST_LETTER_STYLE), "NS_BLOCK_HAS_FIRST_LETTER_STYLE state out of sync"); #endif diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 7a3f85270152..72614a9223a7 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -251,14 +251,14 @@ class nsBlockFrame : public nsContainerFrame { * @return true if this frame has an inside ::marker frame. */ bool HasInsideMarker() const { - return 0 != (mState & NS_BLOCK_FRAME_HAS_INSIDE_MARKER); + return HasAnyStateBits(NS_BLOCK_FRAME_HAS_INSIDE_MARKER); } /** * @return true if this frame has an outside ::marker frame. */ bool HasOutsideMarker() const { - return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_MARKER); + return HasAnyStateBits(NS_BLOCK_FRAME_HAS_OUTSIDE_MARKER); } /** diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 8e1e74865f78..980d1e3e2225 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -444,7 +444,7 @@ void nsHTMLCanvasFrame::Reflow(nsPresContext* aPresContext, ("enter nsHTMLCanvasFrame::Reflow: availSize=%d,%d", aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight())); - MOZ_ASSERT(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow"); + MOZ_ASSERT(HasAnyStateBits(NS_FRAME_IN_REFLOW), "frame is not in reflow"); WritingMode wm = aReflowInput.GetWritingMode(); const LogicalSize finalSize = aReflowInput.ComputedSizeWithBorderPadding(wm); diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index b21092038893..7b2a9382e83d 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -841,7 +841,7 @@ void nsIFrame::DestroyFrom(nsIFrame* aDestructRoot, nsPresContext* presContext = PresContext(); mozilla::PresShell* presShell = presContext->GetPresShell(); - if (mState & NS_FRAME_OUT_OF_FLOW) { + if (HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { nsPlaceholderFrame* placeholder = GetPlaceholderFrame(); NS_ASSERTION( !placeholder || (aDestructRoot != this), @@ -899,7 +899,7 @@ void nsIFrame::DestroyFrom(nsIFrame* aDestructRoot, presShell->NotifyDestroyingFrame(this); - if (mState & NS_FRAME_EXTERNAL_REFERENCE) { + if (HasAnyStateBits(NS_FRAME_EXTERNAL_REFERENCE)) { presShell->ClearFrameRefs(this); } @@ -1829,7 +1829,7 @@ bool nsIFrame::IsSVGTransformed(gfx::Matrix* aOwnTransforms, bool nsIFrame::Extend3DContext(const nsStyleDisplay* aStyleDisplay, const nsStyleEffects* aStyleEffects, mozilla::EffectSet* aEffectSetForOpacity) const { - if (!(mState & NS_FRAME_MAY_BE_TRANSFORMED)) { + if (!HasAnyStateBits(NS_FRAME_MAY_BE_TRANSFORMED)) { return false; } const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay); @@ -9973,7 +9973,7 @@ bool nsIFrame::FinishAndStoreOverflow(OverflowAreas& aOverflowAreas, DebugOnly r = &aOverflowAreas.Overflow(otype); NS_ASSERTION(aNewSize.width == 0 || aNewSize.height == 0 || r->width == nscoord_MAX || r->height == nscoord_MAX || - (mState & NS_FRAME_SVG_LAYOUT) || + HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || r->Contains(nsRect(nsPoint(0, 0), aNewSize)), "Computed overflow area must contain frame bounds"); } @@ -10431,13 +10431,13 @@ ComputedStyle* nsIFrame::DoGetParentComputedStyle( } } - if (!(mState & NS_FRAME_OUT_OF_FLOW)) { + if (!HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { /* * If this frame is an anonymous block created when an inline with a block * inside it got split, then the parent style is on its preceding inline. We * can get to it using GetIBSplitSiblingForAnonymousBlock. */ - if (mState & NS_FRAME_PART_OF_IBSPLIT) { + if (HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)) { nsIFrame* ibSplitSibling = GetIBSplitSiblingForAnonymousBlock(this); if (ibSplitSibling) { return (*aProviderFrame = ibSplitSibling)->Style(); diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 58d3bad66243..d9a10e8c5c3f 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -5066,8 +5066,10 @@ class nsIFrame : public nsQueryFrame { AddStateBits(NS_FRAME_IN_REFLOW); } + private: nsFrameState mState; + protected: /** * List of properties attached to the frame. */ diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 444f4b37a2b7..fe3553321bd8 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1332,7 +1332,7 @@ void nsImageFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics, ("enter nsImageFrame::Reflow: availSize=%d,%d", aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight())); - MOZ_ASSERT(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow"); + MOZ_ASSERT(HasAnyStateBits(NS_FRAME_IN_REFLOW), "frame is not in reflow"); // see if we have a frozen size (i.e. a fixed width and height) if (!SizeDependsOnIntrinsicSize(aReflowInput)) { @@ -1368,7 +1368,7 @@ void nsImageFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics, if (aPresContext->IsPaginated() && ((loadStatus & imgIRequest::STATUS_SIZE_AVAILABLE) || - (mState & IMAGE_SIZECONSTRAINED)) && + HasAnyStateBits(IMAGE_SIZECONSTRAINED)) && NS_UNCONSTRAINEDSIZE != aReflowInput.AvailableHeight() && aMetrics.Height() > aReflowInput.AvailableHeight()) { // our desired height was greater than 0, so to avoid infinite diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 41aef03c2916..e543cb8e8f74 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -791,7 +791,7 @@ struct FlowLengthProperty { }; int32_t nsTextFrame::GetInFlowContentLength() { - if (!(mState & NS_FRAME_IS_BIDI)) { + if (!HasAnyStateBits(NS_FRAME_IS_BIDI)) { return mContent->TextLength() - mContentOffset; } @@ -7827,7 +7827,7 @@ void nsTextFrame::SelectionStateChanged(uint32_t aStart, uint32_t aEnd, SelectionType aSelectionType) { NS_ASSERTION(!GetPrevContinuation(), "Should only be called for primary frame"); - DEBUG_VERIFY_NOT_DIRTY(mState); + DEBUG_VERIFY_NOT_DIRTY(GetStateBits()); InvalidateSelectionState(); @@ -7919,8 +7919,8 @@ nsresult nsTextFrame::GetPointFromOffset(int32_t inOffset, nsPoint* outPoint) { return NS_ERROR_NULL_POINTER; } - DEBUG_VERIFY_NOT_DIRTY(mState); - if (mState & NS_FRAME_IS_DIRTY) { + DEBUG_VERIFY_NOT_DIRTY(GetStateBits()); + if (HasAnyStateBits(NS_FRAME_IS_DIRTY)) { return NS_ERROR_UNEXPECTED; } @@ -7950,8 +7950,8 @@ nsresult nsTextFrame::GetPointFromOffset(int32_t inOffset, nsPoint* outPoint) { nsresult nsTextFrame::GetCharacterRectsInRange(int32_t aInOffset, int32_t aLength, nsTArray& aRects) { - DEBUG_VERIFY_NOT_DIRTY(mState); - if (mState & NS_FRAME_IS_DIRTY) { + DEBUG_VERIFY_NOT_DIRTY(GetStateBits()); + if (HasAnyStateBits(NS_FRAME_IS_DIRTY)) { return NS_ERROR_UNEXPECTED; } @@ -8041,9 +8041,9 @@ nsresult nsTextFrame::GetChildFrameContainingOffset(int32_t aContentOffset, bool aHint, int32_t* aOutOffset, nsIFrame** aOutFrame) { - DEBUG_VERIFY_NOT_DIRTY(mState); + DEBUG_VERIFY_NOT_DIRTY(GetStateBits()); #if 0 // XXXrbs disable due to bug 310227 - if (mState & NS_FRAME_IS_DIRTY) + if (HasAnyStateBits(NS_FRAME_IS_DIRTY)) return NS_ERROR_UNEXPECTED; #endif @@ -10531,9 +10531,9 @@ nsIFrame::RenderedText nsTextFrame::GetRenderedText( /* virtual */ bool nsTextFrame::IsEmpty() { - NS_ASSERTION(!(mState & TEXT_IS_ONLY_WHITESPACE) || - !(mState & TEXT_ISNOT_ONLY_WHITESPACE), - "Invalid state"); + NS_ASSERTION( + !HasAllStateBits(TEXT_IS_ONLY_WHITESPACE | TEXT_ISNOT_ONLY_WHITESPACE), + "Invalid state"); // XXXldb Should this check compatibility mode as well??? const nsStyleText* textStyle = StyleText(); @@ -10547,11 +10547,11 @@ bool nsTextFrame::IsEmpty() { !GetContent()->GetParent()->IsHTMLElement(nsGkAtoms::input); } - if (mState & TEXT_ISNOT_ONLY_WHITESPACE) { + if (HasAnyStateBits(TEXT_ISNOT_ONLY_WHITESPACE)) { return false; } - if (mState & TEXT_IS_ONLY_WHITESPACE) { + if (HasAnyStateBits(TEXT_IS_ONLY_WHITESPACE)) { return true; } diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index db4dfdd70b6b..c12396524a13 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -233,7 +233,7 @@ void nsVideoFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics, ("enter nsVideoFrame::Reflow: availSize=%d,%d", aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight())); - MOZ_ASSERT(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow"); + MOZ_ASSERT(HasAnyStateBits(NS_FRAME_IN_REFLOW), "frame is not in reflow"); const WritingMode myWM = aReflowInput.GetWritingMode(); nscoord contentBoxBSize = aReflowInput.ComputedBSize(); diff --git a/layout/tables/nsTableColFrame.cpp b/layout/tables/nsTableColFrame.cpp index 92c98deba7c3..d5f5fc87914d 100644 --- a/layout/tables/nsTableColFrame.cpp +++ b/layout/tables/nsTableColFrame.cpp @@ -50,7 +50,7 @@ nsTableColFrame::nsTableColFrame(ComputedStyle* aStyle, nsTableColFrame::~nsTableColFrame() = default; nsTableColType nsTableColFrame::GetColType() const { - return (nsTableColType)((mState & COL_TYPE_BITS) >> COL_TYPE_OFFSET); + return (nsTableColType)((GetStateBits() & COL_TYPE_BITS) >> COL_TYPE_OFFSET); } void nsTableColFrame::SetColType(nsTableColType aType) { diff --git a/layout/xul/nsBoxFrame.cpp b/layout/xul/nsBoxFrame.cpp index 0751dc66798c..619a9bf3637d 100644 --- a/layout/xul/nsBoxFrame.cpp +++ b/layout/xul/nsBoxFrame.cpp @@ -203,7 +203,7 @@ void nsBoxFrame::CacheAttributes() { GetInitialVAlignment(mValign); GetInitialHAlignment(mHalign); - bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH); + bool autostretch = HasAnyStateBits(NS_STATE_AUTO_STRETCH); GetInitialAutoStretch(autostretch); if (autostretch) AddStateBits(NS_STATE_AUTO_STRETCH); @@ -349,7 +349,7 @@ bool nsBoxFrame::GetInitialAutoStretch(bool& aStretch) { void nsBoxFrame::DidReflow(nsPresContext* aPresContext, const ReflowInput* aReflowInput) { nsFrameState preserveBits = - mState & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN); + GetStateBits() & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN); nsIFrame::DidReflow(aPresContext, aReflowInput); AddStateBits(preserveBits); if (preserveBits & NS_FRAME_IS_DIRTY) { @@ -815,7 +815,7 @@ nsresult nsBoxFrame::AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, GetInitialVAlignment(mValign); GetInitialHAlignment(mHalign); - bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH); + bool autostretch = HasAnyStateBits(NS_STATE_AUTO_STRETCH); GetInitialAutoStretch(autostretch); if (autostretch) AddStateBits(NS_STATE_AUTO_STRETCH); diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index 48b4104300e5..288c13cfa245 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -482,7 +482,7 @@ void nsTextBoxFrame::DrawText(gfxContext& aRenderingContext, nsresult rv = NS_ERROR_FAILURE; - if (mState & NS_FRAME_IS_BIDI) { + if (HasAnyStateBits(NS_FRAME_IS_BIDI)) { presContext->SetBidiEnabled(); mozilla::intl::BidiEmbeddingLevel level = nsBidiPresUtils::BidiLevelFromStyle(Style());