Bug 1341981 Part 3 - Convert inline break status to a tri-state enum class. r=dholbert
authorTing-Yu Lin <tlin@mozilla.com>
Sun, 26 Feb 2017 00:25:12 +0800
changeset 374393 693036540bcf73be5c4ebb9aa2fccc1b773c3481
parent 374392 6e42654118543c89b90e1ac424a7d14fde04e278
child 374394 2da1219f234788ee0d09565dd204628e6fa693f1
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1341981
milestone54.0a1
Bug 1341981 Part 3 - Convert inline break status to a tri-state enum class. r=dholbert MozReview-Commit-ID: DwbffoPR0Q5
layout/generic/nsIFrame.h
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -197,42 +197,39 @@ enum nsSpread {
 //----------------------------------------------------------------------
 // Reflow status returned by the Reflow() methods.
 class nsReflowStatus final {
   using StyleClear = mozilla::StyleClear;
 
 public:
   nsReflowStatus()
     : mBreakType(StyleClear::None)
+    , mInlineBreak(InlineBreak::None)
     , mCompletion(Completion::FullyComplete)
     , mNextInFlowNeedsReflow(false)
     , mTruncated(false)
-    , mInlineBreak(false)
-    , mInlineBreakAfter(false)
     , mFirstLetterComplete(false)
   {}
 
   // Reset all the member variables.
   void Reset() {
     mBreakType = StyleClear::None;
+    mInlineBreak = InlineBreak::None;
     mCompletion = Completion::FullyComplete;
     mNextInFlowNeedsReflow = false;
     mTruncated = false;
-    mInlineBreak = false;
-    mInlineBreakAfter = false;
     mFirstLetterComplete = false;
   }
 
   // Return true if all member variables have their default values.
   bool IsEmpty() const {
     return (IsFullyComplete() &&
+            !IsInlineBreak() &&
             !mNextInFlowNeedsReflow &&
             !mTruncated &&
-            !mInlineBreak &&
-            !mInlineBreakAfter &&
             !mFirstLetterComplete);
   }
 
   // There are three possible completion statuses, represented by
   // mCompletion.
   //
   // Incomplete means the frame does *not* map all its content, and the
   // parent frame should create a continuing frame.
@@ -300,58 +297,69 @@ public:
     static_assert(Completion::Incomplete > Completion::OverflowIncomplete &&
                   Completion::OverflowIncomplete > Completion::FullyComplete,
                   "mCompletion merging won't work without this!");
 
     mNextInFlowNeedsReflow |= aStatus.mNextInFlowNeedsReflow;
     mTruncated |= aStatus.mTruncated;
   }
 
-  // mInlineBreak bit flag means a break is requested.
-  bool IsInlineBreak() const { return mInlineBreak; }
-
-  // Suppose a break is requested. When mInlineBreakAfter is set, the break
-  // should occur after the frame just reflowed; when mInlineBreakAfter is
-  // clear, the break should occur before the frame just reflowed.
-  bool IsInlineBreakBefore() const { return mInlineBreak && !mInlineBreakAfter; }
-  bool IsInlineBreakAfter() const { return mInlineBreak && mInlineBreakAfter; }
+  // There are three possible inline-break statuses, represented by
+  // mInlineBreak.
+  //
+  // "None" means no break is requested.
+  // "Before" means the break should occur before the frame.
+  // "After" means the break should occur after the frame.
+  // (Here, "the frame" is the frame whose reflow results are being reported by
+  // this nsReflowStatus.)
+  //
+  enum class InlineBreak : uint8_t {
+    None,
+    Before,
+    After,
+  };
+
+  bool IsInlineBreak() const { return mInlineBreak != InlineBreak::None; }
+  bool IsInlineBreakBefore() const {
+    return mInlineBreak == InlineBreak::Before;
+  }
+  bool IsInlineBreakAfter() const {
+    return mInlineBreak == InlineBreak::After;
+  }
   StyleClear BreakType() const { return mBreakType; }
 
   // Set the inline line-break-before status, and reset other bit flags. The
   // break type is StyleClear::Line. Note that other frame completion status
   // isn't expected to matter after calling this method.
   void SetInlineLineBreakBeforeAndReset() {
     Reset();
     mBreakType = StyleClear::Line;
-    mInlineBreak = true;
-    mInlineBreakAfter = false;
+    mInlineBreak = InlineBreak::Before;
   }
 
   // Set the inline line-break-after status. The break type can be changed
   // via the optional aBreakType param.
   void SetInlineLineBreakAfter(StyleClear aBreakType = StyleClear::Line) {
+    MOZ_ASSERT(aBreakType != StyleClear::None,
+               "Break-after with StyleClear::None is meaningless!");
     mBreakType = aBreakType;
-    mInlineBreak = true;
-    mInlineBreakAfter = true;
+    mInlineBreak = InlineBreak::After;
   }
 
   // mFirstLetterComplete bit flag means the break was induced by
   // completion of a first-letter.
   bool FirstLetterComplete() const { return mFirstLetterComplete; }
   void SetFirstLetterComplete() { mFirstLetterComplete = true; }
 
 private:
   StyleClear mBreakType;
+  InlineBreak mInlineBreak;
   Completion mCompletion;
   bool mNextInFlowNeedsReflow : 1;
   bool mTruncated : 1;
-
-  // Inline break status bit flags.
-  bool mInlineBreak : 1;
-  bool mInlineBreakAfter : 1;
   bool mFirstLetterComplete : 1;
 };
 
 #define NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aMetrics) \
   aStatus.UpdateTruncated(aReflowInput, aMetrics);
 
 #ifdef DEBUG
 // Convert nsReflowStatus to a human-readable string.