Bug 1399824, part 2 - Always use nsIFrame::AddStateBits instead of manual bit twiddling. r=xidorn
authorJonathan Watt <jwatt@jwatt.org>
Thu, 24 Aug 2017 12:09:42 +0100
changeset 433739 f6898bbd82dc172db88189c959857fa7acf3266e
parent 433738 e442edb7870d5099ef5650623d00b339ded41638
child 433740 c863089c7166d0753860043539cb7f8050329ec2
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1399824
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1399824, part 2 - Always use nsIFrame::AddStateBits instead of manual bit twiddling. r=xidorn MozReview-Commit-ID: JoEiQQI2kZ5
layout/forms/nsTextControlFrame.cpp
layout/generic/ViewportFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
layout/generic/nsImageFrame.cpp
layout/generic/nsTextFrame.cpp
layout/svg/SVGTextFrame.cpp
layout/xul/nsBox.cpp
layout/xul/nsBoxFrame.cpp
layout/xul/nsScrollbarFrame.cpp
layout/xul/nsSliderFrame.cpp
layout/xul/nsSplitterFrame.cpp
layout/xul/nsTextBoxFrame.cpp
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -312,17 +312,17 @@ nsTextControlFrame::EnsureEditorInitiali
   return NS_OK;
 }
 
 nsresult
 nsTextControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
 {
   NS_ASSERTION(mContent, "We should have a content!");
 
-  mState |= NS_FRAME_INDEPENDENT_SELECTION;
+  AddStateBits(NS_FRAME_INDEPENDENT_SELECTION);
 
   nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
   NS_ASSERTION(txtCtrl, "Content not a text control element");
 
   // Bind the frame to its text control
   nsresult rv = txtCtrl->BindToFrame(this);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/layout/generic/ViewportFrame.cpp
+++ b/layout/generic/ViewportFrame.cpp
@@ -43,17 +43,17 @@ ViewportFrame::Init(nsIContent*       aC
   nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
   // No need to call CreateView() here - the frame ctor will call SetView()
   // with the ViewManager's root view, so we'll assign it in SetViewInternal().
 
   nsIFrame* parent = nsLayoutUtils::GetCrossDocParentFrame(this);
   if (parent) {
     nsFrameState state = parent->GetStateBits();
 
-    mState |= state & (NS_FRAME_IN_POPUP);
+    AddStateBits(state & (NS_FRAME_IN_POPUP));
   }
 }
 
 void
 ViewportFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                 const nsDisplayListSet& aLists)
 {
   AUTO_PROFILER_LABEL("ViewportFrame::BuildDisplayList", GRAPHICS);
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -618,46 +618,46 @@ nsFrame::Init(nsIContent*       aContent
 
   if (aPrevInFlow) {
     mWritingMode = aPrevInFlow->GetWritingMode();
 
     // Make sure the general flags bits are the same
     nsFrameState state = aPrevInFlow->GetStateBits();
 
     // Make bits that are currently off (see constructor) the same:
-    mState |= state & (NS_FRAME_INDEPENDENT_SELECTION |
-                       NS_FRAME_PART_OF_IBSPLIT |
-                       NS_FRAME_MAY_BE_TRANSFORMED |
-                       NS_FRAME_MAY_HAVE_GENERATED_CONTENT |
-                       NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
+    AddStateBits(state & (NS_FRAME_INDEPENDENT_SELECTION |
+                          NS_FRAME_PART_OF_IBSPLIT |
+                          NS_FRAME_MAY_BE_TRANSFORMED |
+                          NS_FRAME_MAY_HAVE_GENERATED_CONTENT |
+                          NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN));
   } else {
     PresContext()->ConstructedFrame();
   }
   if (GetParent()) {
     nsFrameState state = GetParent()->GetStateBits();
 
     // Make bits that are currently off (see constructor) the same:
-    mState |= state & (NS_FRAME_INDEPENDENT_SELECTION |
-                       NS_FRAME_GENERATED_CONTENT |
-                       NS_FRAME_IS_SVG_TEXT |
-                       NS_FRAME_IN_POPUP |
-                       NS_FRAME_IS_NONDISPLAY);
+    AddStateBits(state & (NS_FRAME_INDEPENDENT_SELECTION |
+                          NS_FRAME_GENERATED_CONTENT |
+                          NS_FRAME_IS_SVG_TEXT |
+                          NS_FRAME_IN_POPUP |
+                          NS_FRAME_IS_NONDISPLAY));
 
     if (HasAnyStateBits(NS_FRAME_IN_POPUP) && TrackingVisibility()) {
       // Assume all frames in popups are visible.
       IncApproximateVisibleCount();
     }
   }
   const nsStyleDisplay *disp = StyleDisplay();
   if (disp->HasTransform(this) ||
       (IsFrameOfType(eSupportsCSSTransforms) &&
        nsLayoutUtils::HasAnimationOfProperty(this, eCSSProperty_transform))) {
     // The frame gets reconstructed if we toggle the -moz-transform
     // property, so we can set this bit here and then ignore it.
-    mState |= NS_FRAME_MAY_BE_TRANSFORMED;
+    AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED);
   }
   if (disp->mPosition == NS_STYLE_POSITION_STICKY &&
       !aPrevInFlow &&
       !(mState & NS_FRAME_IS_NONDISPLAY) &&
       !disp->IsInnerTableStyle()) {
     // Note that we only add first continuations, but we really only
     // want to add first continuation-or-ib-split-siblings.  But since we
     // don't yet know if we're a later part of a block-in-inline split,
@@ -6992,17 +6992,17 @@ nsFrame::UnionChildOverflow(nsOverflowAr
 
 bool
 nsFrame::IsFrameTreeTooDeep(const ReflowInput& aReflowInput,
                             ReflowOutput& aMetrics,
                             nsReflowStatus& aStatus)
 {
   if (aReflowInput.mReflowDepth >  MAX_FRAME_DEPTH) {
     NS_WARNING("frame tree too deep; setting zero size and returning");
-    mState |= NS_FRAME_TOO_DEEP_IN_FRAME_TREE;
+    AddStateBits(NS_FRAME_TOO_DEEP_IN_FRAME_TREE);
     ClearOverflowRects();
     aMetrics.ClearSize();
     aMetrics.SetBlockStartAscent(0);
     aMetrics.mCarriedOutBEndMargin.Zero();
     aMetrics.mOverflowAreas.Clear();
 
     aStatus.Reset();
     if (GetNextInFlow()) {
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -4095,17 +4095,17 @@ protected:
    */
   inline void PropagateRootElementWritingMode(mozilla::WritingMode aRootElemWM);
 
   void MarkInReflow() {
 #ifdef DEBUG_dbaron_off
     // bug 81268
     NS_ASSERTION(!(mState & NS_FRAME_IN_REFLOW), "frame is already in reflow");
 #endif
-    mState |= NS_FRAME_IN_REFLOW;
+    AddStateBits(NS_FRAME_IN_REFLOW);
   }
 
   nsFrameState     mState;
 
   /**
    * List of properties attached to the frame.
    */
   FrameProperties  mProperties;
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -986,25 +986,25 @@ nsImageFrame::Reflow(nsPresContext*     
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
                   ("enter nsImageFrame::Reflow: availSize=%d,%d",
                   aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
 
   NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
 
   // see if we have a frozen size (i.e. a fixed width and height)
   if (HaveFixedSize(aReflowInput)) {
-    mState |= IMAGE_SIZECONSTRAINED;
+    AddStateBits(IMAGE_SIZECONSTRAINED);
   } else {
     RemoveStateBits(IMAGE_SIZECONSTRAINED);
   }
 
   // XXXldb These two bits are almost exact opposites (except in the
   // middle of the initial reflow); remove IMAGE_GOTINITIALREFLOW.
   if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
-    mState |= IMAGE_GOTINITIALREFLOW;
+    AddStateBits(IMAGE_GOTINITIALREFLOW);
   }
 
   mComputedSize =
     nsSize(aReflowInput.ComputedWidth(), aReflowInput.ComputedHeight());
 
   aMetrics.Width() = mComputedSize.width;
   aMetrics.Height() = mComputedSize.height;
 
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -4544,17 +4544,17 @@ nsContinuingTextFrame::Init(nsIContent* 
         MOZ_ASSERT(nextBidiData.precedingControl == kBidiLevelNone,
                    "There shouldn't be any virtual bidi formatting character "
                    "between continuations");
 #endif
         nextContinuation->mContentOffset = mContentOffset;
         nextContinuation = nextContinuation->GetNextContinuation();
       }
     }
-    mState |= NS_FRAME_IS_BIDI;
+    AddStateBits(NS_FRAME_IS_BIDI);
   } // prev frame is bidi
 }
 
 void
 nsContinuingTextFrame::DestroyFrom(nsIFrame* aDestructRoot)
 {
   ClearFrameOffsetCache();
 
@@ -10315,17 +10315,17 @@ nsTextFrame::IsEmpty()
 
   if (mState & TEXT_IS_ONLY_WHITESPACE) {
     return true;
   }
 
   bool isEmpty =
     IsAllWhitespace(mContent->GetText(),
                     textStyle->mWhiteSpace != mozilla::StyleWhiteSpace::PreLine);
-  mState |= (isEmpty ? TEXT_IS_ONLY_WHITESPACE : TEXT_ISNOT_ONLY_WHITESPACE);
+  AddStateBits(isEmpty ? TEXT_IS_ONLY_WHITESPACE : TEXT_ISNOT_ONLY_WHITESPACE);
   return isEmpty;
 }
 
 #ifdef DEBUG_FRAME_DUMP
 // Translate the mapped content into a string that's printable
 void
 nsTextFrame::ToCString(nsCString& aBuf, int32_t* aTotalContentLength) const
 {
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -5310,17 +5310,17 @@ SVGTextFrame::DoReflow()
     presContext->PresShell()->CreateReferenceRenderingContext();
 
   if (UpdateFontSizeScaleFactor()) {
     // If the font size scale factor changed, we need the block to report
     // an updated preferred width.
     kid->MarkIntrinsicISizesDirty();
   }
 
-  mState |= NS_STATE_SVG_TEXT_IN_REFLOW;
+  AddStateBits(NS_STATE_SVG_TEXT_IN_REFLOW);
 
   nscoord inlineSize = kid->GetPrefISize(renderingContext);
   WritingMode wm = kid->GetWritingMode();
   ReflowInput reflowInput(presContext, kid,
                                 renderingContext,
                                 LogicalSize(wm, inlineSize,
                                             NS_UNCONSTRAINEDSIZE));
   ReflowOutput desiredSize(reflowInput);
--- a/layout/xul/nsBox.cpp
+++ b/layout/xul/nsBox.cpp
@@ -126,17 +126,17 @@ nsBox::BeginXULLayout(nsBoxLayoutState& 
   XULDumpBox(stdout);
   printf("\n");
   gIndent++;
 #endif
 
   // mark ourselves as dirty so no child under us
   // can post an incremental layout.
   // XXXldb Is this still needed?
-  mState |= NS_FRAME_HAS_DIRTY_CHILDREN;
+  AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
 
   if (GetStateBits() & NS_FRAME_IS_DIRTY)
   {
     // If the parent is dirty, all the children are dirty (ReflowInput
     // does this too).
     nsIFrame* box;
     for (box = GetChildXULBox(this); box; box = GetNextXULBox(box))
       box->AddStateBits(NS_FRAME_IS_DIRTY);
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -119,21 +119,20 @@ NS_QUERYFRAME_TAIL_INHERITING(nsContaine
 nsBoxFrame::nsBoxFrame(nsStyleContext* aContext,
                        ClassID aID,
                        bool aIsRoot,
                        nsBoxLayout* aLayoutManager)
   : nsContainerFrame(aContext, aID)
   , mFlex(0)
   , mAscent(0)
 {
-  mState |= NS_STATE_IS_HORIZONTAL;
-  mState |= NS_STATE_AUTO_STRETCH;
+  AddStateBits(NS_STATE_IS_HORIZONTAL | NS_STATE_AUTO_STRETCH);
 
   if (aIsRoot)
-     mState |= NS_STATE_IS_ROOT;
+     AddStateBits(NS_STATE_IS_ROOT);
 
   mValign = vAlign_Top;
   mHalign = hAlign_Left;
 
   // if no layout manager specified us the static sprocket layout
   nsCOMPtr<nsBoxLayout> layout = aLayoutManager;
 
   if (layout == nullptr) {
@@ -230,52 +229,52 @@ nsBoxFrame::CacheAttributes()
    */
 
   mValign = vAlign_Top;
   mHalign = hAlign_Left;
 
   bool orient = false;
   GetInitialOrientation(orient);
   if (orient)
-    mState |= NS_STATE_IS_HORIZONTAL;
+    AddStateBits(NS_STATE_IS_HORIZONTAL);
   else
     RemoveStateBits(NS_STATE_IS_HORIZONTAL);
 
   bool normal = true;
   GetInitialDirection(normal);
   if (normal)
-    mState |= NS_STATE_IS_DIRECTION_NORMAL;
+    AddStateBits(NS_STATE_IS_DIRECTION_NORMAL);
   else
     RemoveStateBits(NS_STATE_IS_DIRECTION_NORMAL);
 
   GetInitialVAlignment(mValign);
   GetInitialHAlignment(mHalign);
 
   bool equalSize = false;
   GetInitialEqualSize(equalSize);
   if (equalSize)
-        mState |= NS_STATE_EQUAL_SIZE;
+        AddStateBits(NS_STATE_EQUAL_SIZE);
     else
         RemoveStateBits(NS_STATE_EQUAL_SIZE);
 
   bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
   GetInitialAutoStretch(autostretch);
   if (autostretch)
-        mState |= NS_STATE_AUTO_STRETCH;
+        AddStateBits(NS_STATE_AUTO_STRETCH);
      else
         RemoveStateBits(NS_STATE_AUTO_STRETCH);
 
 
 #ifdef DEBUG_LAYOUT
   bool debug = mState & NS_STATE_SET_TO_DEBUG;
   bool debugSet = GetInitialDebug(debug);
   if (debugSet) {
-        mState |= NS_STATE_DEBUG_WAS_SET;
+        AddStateBits(NS_STATE_DEBUG_WAS_SET);
         if (debug)
-            mState |= NS_STATE_SET_TO_DEBUG;
+            AddStateBits(NS_STATE_SET_TO_DEBUG);
         else
             RemoveStateBits(NS_STATE_SET_TO_DEBUG);
   } else {
         RemoveStateBits(NS_STATE_DEBUG_WAS_SET);
   }
 #endif
 }
 
@@ -561,17 +560,17 @@ nsBoxFrame::GetInitialAutoStretch(bool& 
 void
 nsBoxFrame::DidReflow(nsPresContext*           aPresContext,
                       const ReflowInput*  aReflowInput,
                       nsDidReflowStatus         aStatus)
 {
   nsFrameState preserveBits =
     mState & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN);
   nsFrame::DidReflow(aPresContext, aReflowInput, aStatus);
-  mState |= preserveBits;
+  AddStateBits(preserveBits);
 }
 
 bool
 nsBoxFrame::HonorPrintBackgroundSettings()
 {
   return (!mContent || !mContent->IsInNativeAnonymousSubtree()) &&
     nsContainerFrame::HonorPrintBackgroundSettings();
 }
@@ -975,17 +974,17 @@ nsBoxFrame::SetXULDebug(nsBoxLayoutState
   // see if our state matches the given debug state
   bool debugSet = mState & NS_STATE_CURRENTLY_IN_DEBUG;
   bool debugChanged = (!aDebug && debugSet) || (aDebug && !debugSet);
 
   // if it doesn't then tell each child below us the new debug state
   if (debugChanged)
   {
      if (aDebug) {
-         mState |= NS_STATE_CURRENTLY_IN_DEBUG;
+         AddStateBits(NS_STATE_CURRENTLY_IN_DEBUG);
      } else {
          RemoveStateBits(NS_STATE_CURRENTLY_IN_DEBUG);
      }
 
      SetDebugOnChildList(aState, mFirstChild, aDebug);
 
     MarkIntrinsicISizesDirty();
   }
@@ -1169,56 +1168,56 @@ nsBoxFrame::AttributeChanged(int32_t aNa
         aAttribute == nsGkAtoms::dir) {
 
       mValign = nsBoxFrame::vAlign_Top;
       mHalign = nsBoxFrame::hAlign_Left;
 
       bool orient = true;
       GetInitialOrientation(orient);
       if (orient)
-        mState |= NS_STATE_IS_HORIZONTAL;
+        AddStateBits(NS_STATE_IS_HORIZONTAL);
       else
         RemoveStateBits(NS_STATE_IS_HORIZONTAL);
 
       bool normal = true;
       GetInitialDirection(normal);
       if (normal)
-        mState |= NS_STATE_IS_DIRECTION_NORMAL;
+        AddStateBits(NS_STATE_IS_DIRECTION_NORMAL);
       else
         RemoveStateBits(NS_STATE_IS_DIRECTION_NORMAL);
 
       GetInitialVAlignment(mValign);
       GetInitialHAlignment(mHalign);
 
       bool equalSize = false;
       GetInitialEqualSize(equalSize);
       if (equalSize)
-        mState |= NS_STATE_EQUAL_SIZE;
+        AddStateBits(NS_STATE_EQUAL_SIZE);
       else
         RemoveStateBits(NS_STATE_EQUAL_SIZE);
 
 #ifdef DEBUG_LAYOUT
       bool debug = mState & NS_STATE_SET_TO_DEBUG;
       bool debugSet = GetInitialDebug(debug);
       if (debugSet) {
-        mState |= NS_STATE_DEBUG_WAS_SET;
+        AddStateBits(NS_STATE_DEBUG_WAS_SET);
 
         if (debug)
-          mState |= NS_STATE_SET_TO_DEBUG;
+          AddStateBits(NS_STATE_SET_TO_DEBUG);
         else
           RemoveStateBits(NS_STATE_SET_TO_DEBUG);
       } else {
         RemoveStateBits(NS_STATE_DEBUG_WAS_SET);
       }
 #endif
 
       bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
       GetInitialAutoStretch(autostretch);
       if (autostretch)
-        mState |= NS_STATE_AUTO_STRETCH;
+        AddStateBits(NS_STATE_AUTO_STRETCH);
       else
         RemoveStateBits(NS_STATE_AUTO_STRETCH);
     }
     else if (aAttribute == nsGkAtoms::left ||
              aAttribute == nsGkAtoms::top ||
              aAttribute == nsGkAtoms::right ||
              aAttribute == nsGkAtoms::bottom ||
              aAttribute == nsGkAtoms::start ||
--- a/layout/xul/nsScrollbarFrame.cpp
+++ b/layout/xul/nsScrollbarFrame.cpp
@@ -46,17 +46,17 @@ nsScrollbarFrame::Init(nsIContent*      
                        nsIFrame*         aPrevInFlow)
 {
   nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
 
   // We want to be a reflow root since we use reflows to move the
   // slider.  Any reflow inside the scrollbar frame will be a reflow to
   // move the slider and will thus not change anything outside of the
   // scrollbar or change the size of the scrollbar frame.
-  mState |= NS_FRAME_REFLOW_ROOT;
+  AddStateBits(NS_FRAME_REFLOW_ROOT);
 }
 
 void
 nsScrollbarFrame::Reflow(nsPresContext*          aPresContext,
                          ReflowOutput&     aDesiredSize,
                          const ReflowInput& aReflowInput,
                          nsReflowStatus&          aStatus)
 {
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -1527,17 +1527,17 @@ nsSliderFrame::GetXULMaxSize(nsBoxLayout
 
 void
 nsSliderFrame::EnsureOrient()
 {
   nsIFrame* scrollbarBox = GetScrollbar();
 
   bool isHorizontal = (scrollbarBox->GetStateBits() & NS_STATE_IS_HORIZONTAL) != 0;
   if (isHorizontal)
-      mState |= NS_STATE_IS_HORIZONTAL;
+      AddStateBits(NS_STATE_IS_HORIZONTAL);
   else
       RemoveStateBits(NS_STATE_IS_HORIZONTAL);
 }
 
 
 void
 nsSliderFrame::Notify(void)
 {
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -879,17 +879,17 @@ nsSplitterFrameInner::UpdateState()
   mState = newState;
 }
 
 void
 nsSplitterFrameInner::EnsureOrient()
 {
   bool isHorizontal = !(mParentBox->GetStateBits() & NS_STATE_IS_HORIZONTAL);
   if (isHorizontal)
-    mOuter->mState |= NS_STATE_IS_HORIZONTAL;
+    mOuter->AddStateBits(NS_STATE_IS_HORIZONTAL);
   else
     mOuter->RemoveStateBits(NS_STATE_IS_HORIZONTAL);
 }
 
 void
 nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext)
 {
   EnsureOrient();
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -640,17 +640,17 @@ nsTextBoxFrame::CalculateTitleForWidth(g
     // see if the text will completely fit in the width given
     nscoord titleWidth =
       nsLayoutUtils::AppUnitWidthOfStringBidi(mTitle, this, *fm,
                                               aRenderingContext);
     if (titleWidth <= aWidth) {
         mCroppedTitle = mTitle;
         if (HasRTLChars(mTitle) ||
             StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
-            mState |= NS_FRAME_IS_BIDI;
+            AddStateBits(NS_FRAME_IS_BIDI);
         }
         return titleWidth;  // fits, done.
     }
 
     const nsDependentString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
     if (mCropType != CropNone) {
       // start with an ellipsis
       mCroppedTitle.Assign(kEllipsis);
@@ -699,17 +699,17 @@ nsTextBoxFrame::CalculateTitleForWidth(g
                 charWidth = nsLayoutUtils::AppUnitWidthOfString(pos, length,
                                                                 *fm,
                                                                 drawTarget);
                 if (totalWidth + charWidth > aWidth) {
                     break;
                 }
 
                 if (UCS2_CHAR_IS_BIDI(*pos)) {
-                    mState |= NS_FRAME_IS_BIDI;
+                    AddStateBits(NS_FRAME_IS_BIDI);
                 }
                 pos = nextPos;
                 totalWidth += charWidth;
             }
 
             if (pos == dataBegin) {
                 return titleWidth;
             }
@@ -736,17 +736,17 @@ nsTextBoxFrame::CalculateTitleForWidth(g
                 charWidth = nsLayoutUtils::AppUnitWidthOfString(pos, length,
                                                                 *fm,
                                                                 drawTarget);
                 if (totalWidth + charWidth > aWidth) {
                     break;
                 }
 
                 if (UCS2_CHAR_IS_BIDI(*pos)) {
-                    mState |= NS_FRAME_IS_BIDI;
+                    AddStateBits(NS_FRAME_IS_BIDI);
                 }
                 prevPos = pos;
                 totalWidth += charWidth;
             }
 
             if (prevPos == dataEnd) {
                 return titleWidth;
             }
@@ -788,17 +788,17 @@ nsTextBoxFrame::CalculateTitleForWidth(g
                 charWidth = nsLayoutUtils::AppUnitWidthOfString(leftPos, length,
                                                                 *fm,
                                                                 drawTarget);
                 if (totalWidth + charWidth > aWidth) {
                     break;
                 }
 
                 if (UCS2_CHAR_IS_BIDI(*leftPos)) {
-                    mState |= NS_FRAME_IS_BIDI;
+                    AddStateBits(NS_FRAME_IS_BIDI);
                 }
 
                 leftString.Append(leftPos, length);
                 leftPos = pos;
                 totalWidth += charWidth;
 
                 if (leftPos >= rightPos) {
                     break;
@@ -810,17 +810,17 @@ nsTextBoxFrame::CalculateTitleForWidth(g
                 charWidth = nsLayoutUtils::AppUnitWidthOfString(pos, length,
                                                                 *fm,
                                                                 drawTarget);
                 if (totalWidth + charWidth > aWidth) {
                     break;
                 }
 
                 if (UCS2_CHAR_IS_BIDI(*pos)) {
-                    mState |= NS_FRAME_IS_BIDI;
+                    AddStateBits(NS_FRAME_IS_BIDI);
                 }
 
                 rightString.Insert(pos, 0, length);
                 rightPos = pos;
                 totalWidth += charWidth;
             }
 
             mCroppedTitle = leftString + kEllipsis + rightString;