Bug 1359341 part 2 - Add a couple of private frame state bits to nsPlaceholderFrame to be used for propagating "line emptiness" during reflow. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Tue, 23 May 2017 19:09:26 +0200
changeset 360259 18e3dfae96fa6d6981f97311f33627b7b932bd59
parent 360258 ac1e17e452baac2e8214e795989172e7d545177d
child 360260 08e64a7a749562b2b857c51930d666e5bdda87e1
push id31872
push userryanvm@gmail.com
push dateTue, 23 May 2017 22:11:58 +0000
treeherdermozilla-central@96e18bec9fc8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1359341
milestone55.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 1359341 part 2 - Add a couple of private frame state bits to nsPlaceholderFrame to be used for propagating "line emptiness" during reflow. r=jfkthame MozReview-Commit-ID: Ds98Sn5PZav
layout/generic/nsFrameStateBits.h
layout/generic/nsIFrame.h
layout/generic/nsPlaceholderFrame.h
--- a/layout/generic/nsFrameStateBits.h
+++ b/layout/generic/nsFrameStateBits.h
@@ -619,16 +619,20 @@ FRAME_STATE_BIT(Placeholder, 24, PLACEHO
 // determined using the CSS Box Alignment properties
 // ([align,justify]-[self,content]).  When this is set, the placeholder frame's
 // position doesn't represent the static position, as it usually would --
 // rather, it represents the logical start corner of the alignment containing
 // block.  Then, after we've determined the out-of-flow frame's size, we can
 // resolve the actual static position using the alignment properties.
 FRAME_STATE_BIT(Placeholder, 25, PLACEHOLDER_STATICPOS_NEEDS_CSSALIGN)
 
+// Are all earlier frames on the same block line empty?
+FRAME_STATE_BIT(Placeholder, 26, PLACEHOLDER_LINE_IS_EMPTY_SO_FAR)
+// Does the above bit have a valid value?
+FRAME_STATE_BIT(Placeholder, 27, PLACEHOLDER_HAVE_LINE_IS_EMPTY_SO_FAR)
 
 // == Frame state bits that apply to table cell frames ========================
 
 FRAME_STATE_GROUP(TableCell, nsTableCellFrame)
 
 FRAME_STATE_BIT(TableCell, 28, NS_TABLE_CELL_HAS_PCT_OVER_BSIZE)
 FRAME_STATE_BIT(TableCell, 29, NS_TABLE_CELL_HAD_SPECIAL_REFLOW)
 FRAME_STATE_BIT(TableCell, 31, NS_TABLE_CELL_CONTENT_EMPTY)
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -1947,16 +1947,19 @@ public:
    */
   nsFrameState GetStateBits() const { return mState; }
 
   /**
    * Update the current frame-state value for this frame.
    */
   void AddStateBits(nsFrameState aBits) { mState |= aBits; }
   void RemoveStateBits(nsFrameState aBits) { mState &= ~aBits; }
+  void AddOrRemoveStateBits(nsFrameState aBits, bool aVal) {
+    aVal ? AddStateBits(aBits) : RemoveStateBits(aBits);
+  }
 
   /**
    * Checks if the current frame-state includes all of the listed bits
    */
   bool HasAllStateBits(nsFrameState aBits) const
   {
     return (mState & aBits) == aBits;
   }
--- a/layout/generic/nsPlaceholderFrame.h
+++ b/layout/generic/nsPlaceholderFrame.h
@@ -64,16 +64,17 @@ public:
    * Create a new placeholder frame.  aTypeBit must be one of the
    * PLACEHOLDER_FOR_* constants above.
    */
   friend nsIFrame* NS_NewPlaceholderFrame(nsIPresShell* aPresShell,
                                           nsStyleContext* aContext,
                                           nsFrameState aTypeBit);
   nsPlaceholderFrame(nsStyleContext* aContext, nsFrameState aTypeBit)
     : nsFrame(aContext, mozilla::LayoutFrameType::Placeholder)
+    , mOutOfFlowFrame(nullptr)
   {
     NS_PRECONDITION(aTypeBit == PLACEHOLDER_FOR_FLOAT ||
                     aTypeBit == PLACEHOLDER_FOR_ABSPOS ||
                     aTypeBit == PLACEHOLDER_FOR_FIXEDPOS ||
                     aTypeBit == PLACEHOLDER_FOR_POPUP ||
                     aTypeBit == PLACEHOLDER_FOR_TOPLAYER,
                     "Unexpected type bit");
     AddStateBits(aTypeBit);
@@ -116,16 +117,31 @@ public:
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif // DEBUG
 
   virtual bool IsEmpty() override { return true; }
   virtual bool IsSelfEmpty() override { return true; }
 
   virtual bool CanContinueTextRun() const override;
 
+  void SetLineIsEmptySoFar(bool aValue) {
+    AddOrRemoveStateBits(PLACEHOLDER_LINE_IS_EMPTY_SO_FAR, aValue);
+    AddStateBits(PLACEHOLDER_HAVE_LINE_IS_EMPTY_SO_FAR);
+  }
+  bool GetLineIsEmptySoFar(bool* aResult) const {
+    bool haveValue = HasAnyStateBits(PLACEHOLDER_HAVE_LINE_IS_EMPTY_SO_FAR);
+    if (haveValue) {
+      *aResult = HasAnyStateBits(PLACEHOLDER_LINE_IS_EMPTY_SO_FAR);
+    }
+    return haveValue;
+  }
+  void ForgetLineIsEmptySoFar() {
+    RemoveStateBits(PLACEHOLDER_HAVE_LINE_IS_EMPTY_SO_FAR);
+  }
+
 #ifdef ACCESSIBILITY
   virtual mozilla::a11y::AccType AccessibleType() override
   {
     nsIFrame* realFrame = GetRealFrameForPlaceholder(this);
     return realFrame ? realFrame->AccessibleType() :
                        nsFrame::AccessibleType();
   }
 #endif
@@ -161,12 +177,12 @@ public:
                     "Must have placeholder frame as input");
     nsIFrame* outOfFlow =
       static_cast<nsPlaceholderFrame*>(aFrame)->GetOutOfFlowFrame();
     NS_ASSERTION(outOfFlow, "Null out-of-flow for placeholder?");
     return outOfFlow;
   }
 
 protected:
-  nsIFrame* mOutOfFlowFrame { nullptr };
+  nsIFrame* mOutOfFlowFrame;
 };
 
 #endif /* nsPlaceholderFrame_h___ */