Bug 775624 Part 2 - Add bit-fields and methods for frame completion status. r?dholbert draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 13 Feb 2017 15:25:50 +0800
changeset 488464 1e5a45edb66e9dc2e26c92019c9d2fbd4a485200
parent 488463 fe7dec2afc815469e7a8094fec3f638876945c32
child 488465 3cfd3fd659ddc99b3714145e62a057554fd006ba
push id46538
push userbmo:tlin@mozilla.com
push dateThu, 23 Feb 2017 05:39:06 +0000
reviewersdholbert
bugs775624
milestone54.0a1
Bug 775624 Part 2 - Add bit-fields and methods for frame completion status. r?dholbert MozReview-Commit-ID: B2DEaWYTtAE
layout/generic/nsIFrame.h
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -192,56 +192,42 @@ enum nsSpread {
 
 // Carried out margin flags
 #define NS_CARRIED_TOP_MARGIN_IS_AUTO    0x1
 #define NS_CARRIED_BOTTOM_MARGIN_IS_AUTO 0x2
 
 //----------------------------------------------------------------------
 
 /**
- * Reflow status returned by the reflow methods. There are three
- * completion statuses, represented by two bit flags.
- *
- * NS_FRAME_COMPLETE means the frame is fully complete.
- *
- * NS_FRAME_NOT_COMPLETE bit flag means the frame does not map all its
- * content, and that the parent frame should create a continuing frame.
- * If this bit isn't set it means the frame does map all its content.
- * This bit is mutually exclusive with NS_FRAME_OVERFLOW_INCOMPLETE.
- *
- * NS_FRAME_OVERFLOW_INCOMPLETE bit flag means that the frame has
- * overflow that is not complete, but its own box is complete.
- * (This happens when content overflows a fixed-height box.)
- * The reflower should place and size the frame and continue its reflow,
- * but needs to create an overflow container as a continuation for this
- * frame. See nsContainerFrame.h for more information.
- * This bit is mutually exclusive with NS_FRAME_NOT_COMPLETE.
- * 
- * Please use the SET macro for handling
- * NS_FRAME_NOT_COMPLETE and NS_FRAME_OVERFLOW_INCOMPLETE.
- *
  * NS_FRAME_REFLOW_NEXTINFLOW bit flag means that the next-in-flow is
  * dirty, and also needs to be reflowed. This status only makes sense
  * for a frame that is not complete, i.e. you wouldn't set both
  * NS_FRAME_COMPLETE and NS_FRAME_REFLOW_NEXTINFLOW.
  *
  * The low 8 bits of the nsReflowStatus are reserved for future extensions;
  * the remaining 24 bits are zero (and available for extensions; however
  * API's that accept/return nsReflowStatus must not receive/return any
  * extension bits).
- *
- * @see #Reflow()
  */
 
+// Reflow status returned by the Reflow() methods.
 class nsReflowStatus final {
 public:
   nsReflowStatus()
     : mStatus(0)
+    , mIncomplete(false)
+    , mOverflowIncomplete(false)
   {}
 
+  // Reset all the bit-fields.
+  void Reset() {
+    mIncomplete = false;
+    mOverflowIncomplete = false;
+  }
+
   nsReflowStatus(uint32_t aStatus)
     : mStatus(aStatus)
   {}
 
   uint32_t& operator=(uint32_t aRhs) {
     mStatus = aRhs;
     return mStatus;
   }
@@ -269,18 +255,52 @@ public:
   bool operator==(uint32_t aRhs) const {
     return mStatus == aRhs;
   }
 
   bool operator!=(uint32_t aRhs) const {
     return !(*this == aRhs);
   }
 
+  // mIncomplete bit flag means the frame does not map all its content, and
+  // that the parent frame should create a continuing frame. If this bit
+  // isn't set, it means the frame does map all its content. This bit is
+  // mutually exclusive with mOverflowIncomplete.
+  //
+  // mOverflowIncomplete bit flag means that the frame has overflow that is
+  // not complete, but its own box is complete. (This happens when content
+  // overflows a fixed-height box.) The reflower should place and size the
+  // frame and continue its reflow, but needs to create an overflow
+  // container as a continuation for this frame. See nsContainerFrame.h for
+  // more information. This bit is mutually exclusive with mIncomplete.
+  //
+  // If both mIncomplete and mOverflowIncomplete are not set, the frame is
+  // fully complete.
+  bool IsComplete() const { return !mIncomplete; }
+  bool IsIncomplete() const { return mIncomplete; }
+  bool IsOverflowIncomplete() const { return mOverflowIncomplete; }
+  bool IsFullyComplete() const {
+    return !IsIncomplete() && !IsOverflowIncomplete();
+  }
+
+  void SetIncomplete() {
+    mIncomplete = true;
+    mOverflowIncomplete = false;
+  }
+  void SetOverflowIncomplete() {
+    mIncomplete = false;
+    mOverflowIncomplete = true;
+  }
+
 private:
   uint32_t mStatus;
+
+  // Frame completion status bit flags.
+  bool mIncomplete : 1;
+  bool mOverflowIncomplete : 1;
 };
 
 #define NS_FRAME_COMPLETE             0       // Note: not a bit!
 #define NS_FRAME_NOT_COMPLETE         0x1
 #define NS_FRAME_REFLOW_NEXTINFLOW    0x2
 #define NS_FRAME_OVERFLOW_INCOMPLETE  0x4
 
 #define NS_FRAME_IS_COMPLETE(status) \