Bug 1464363: Remove IMAGE_GOTINITIALREFLOW. r=dholbert
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 25 May 2018 12:23:06 +0200
changeset 421290 aadcedf5a07e2a80ad1763a88084bfec34b8ad5c
parent 421289 bd46d28842ff1c16a94281d42dab94b11bd01e15
child 421291 6f29a4a9da707b28058a425749a7d7335fe5ae68
push id34091
push userbtara@mozilla.com
push dateTue, 05 Jun 2018 13:52:34 +0000
treeherdermozilla-central@752465b44c79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1464363
milestone62.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 1464363: Remove IMAGE_GOTINITIALREFLOW. r=dholbert The methods where it's used don't run from reflow (they're image notifications that run off runnables and such), so should be an idempotent change. MozReview-Commit-ID: LdmSOcKDdw1
layout/generic/nsFrameStateBits.h
layout/generic/nsImageFrame.cpp
layout/generic/nsImageFrame.h
--- a/layout/generic/nsFrameStateBits.h
+++ b/layout/generic/nsFrameStateBits.h
@@ -555,17 +555,16 @@ FRAME_STATE_BIT(Block, 62, BULLET_FRAME_
 FRAME_STATE_BIT(Block, 63, BULLET_FRAME_IMAGE_LOADING)
 
 
 // == Frame state bits that apply to image frames =============================
 
 FRAME_STATE_GROUP(Image, nsImageFrame)
 
 FRAME_STATE_BIT(Image, 20, IMAGE_SIZECONSTRAINED)
-FRAME_STATE_BIT(Image, 21, IMAGE_GOTINITIALREFLOW)
 
 
 // == Frame state bits that apply to inline frames ============================
 
 FRAME_STATE_GROUP(Inline, nsInlineFrame)
 
 /**  In Bidi inline start (or end) margin/padding/border should be applied to
  *  first (or last) frame (or a continuation frame).
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -599,17 +599,17 @@ nsImageFrame::OnSizeAvailable(imgIReques
     mIntrinsicSize.width.SetCoordValue(0);
     mIntrinsicSize.height.SetCoordValue(0);
     mIntrinsicRatio.SizeTo(0, 0);
     intrinsicSizeChanged = true;
   }
 
   MarkNeedsDisplayItemRebuild();
 
-  if (intrinsicSizeChanged && (mState & IMAGE_GOTINITIALREFLOW)) {
+  if (intrinsicSizeChanged && GotInitialReflow()) {
     // Now we need to reflow if we have an unconstrained size and have
     // already gotten the initial reflow
     if (!(mState & IMAGE_SIZECONSTRAINED)) {
       PresShell()->FrameNeedsReflow(this, nsIPresShell::eStyleChange,
                                     NS_FRAME_IS_DIRTY);
     } else {
       // We've already gotten the initial reflow, and our size hasn't changed,
       // so we're ready to request a decode.
@@ -622,17 +622,17 @@ nsImageFrame::OnSizeAvailable(imgIReques
   return NS_OK;
 }
 
 nsresult
 nsImageFrame::OnFrameUpdate(imgIRequest* aRequest, const nsIntRect* aRect)
 {
   NS_ENSURE_ARG_POINTER(aRect);
 
-  if (!(mState & IMAGE_GOTINITIALREFLOW)) {
+  if (!GotInitialReflow()) {
     // Don't bother to do anything; we have a reflow coming up!
     return NS_OK;
   }
 
   if (mFirstFrameComplete && !StyleVisibility()->IsVisible()) {
     return NS_OK;
   }
 
@@ -687,17 +687,17 @@ nsImageFrame::OnLoadComplete(imgIRequest
 {
   NotifyNewCurrentRequest(aRequest, aStatus);
   return NS_OK;
 }
 
 void
 nsImageFrame::ResponsiveContentDensityChanged()
 {
-  if (!(mState & IMAGE_GOTINITIALREFLOW)) {
+  if (!GotInitialReflow()) {
     return;
   }
 
   if (!mImage) {
     return;
   }
 
   if (!UpdateIntrinsicSize(mImage) && !UpdateIntrinsicRatio(mImage)) {
@@ -728,17 +728,17 @@ nsImageFrame::NotifyNewCurrentRequest(im
     mImage = mPrevImage = nullptr;
 
     // Have to size to 0,0 so that GetDesiredSize recalculates the size
     mIntrinsicSize.width.SetCoordValue(0);
     mIntrinsicSize.height.SetCoordValue(0);
     mIntrinsicRatio.SizeTo(0, 0);
   }
 
-  if (mState & IMAGE_GOTINITIALREFLOW) { // do nothing if we haven't gotten the initial reflow yet
+  if (GotInitialReflow()) {
     if (intrinsicSizeChanged) {
       if (!(mState & IMAGE_SIZECONSTRAINED)) {
         PresShell()->FrameNeedsReflow(this, nsIPresShell::eStyleChange,
                                       NS_FRAME_IS_DIRTY);
       } else {
         // We've already gotten the initial reflow, and our size hasn't changed,
         // so we're ready to request a decode.
         MaybeDecodeForPredictedSize();
@@ -973,22 +973,16 @@ nsImageFrame::Reflow(nsPresContext*     
 
   // see if we have a frozen size (i.e. a fixed width and height)
   if (HaveFixedSize(aReflowInput)) {
     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) {
-    AddStateBits(IMAGE_GOTINITIALREFLOW);
-  }
-
   mComputedSize =
     nsSize(aReflowInput.ComputedWidth(), aReflowInput.ComputedHeight());
 
   aMetrics.Width() = mComputedSize.width;
   aMetrics.Height() = mComputedSize.height;
 
   // add borders and padding
   aMetrics.Width()  += aReflowInput.ComputedPhysicalBorderPadding().LeftRight();
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -186,16 +186,21 @@ private:
     : nsImageFrame(aStyle, kClassID) {}
 
 protected:
   nsImageFrame(ComputedStyle* aStyle, ClassID aID);
   virtual ~nsImageFrame();
 
   void EnsureIntrinsicSizeAndRatio();
 
+  bool GotInitialReflow() const
+  {
+    return !HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
+  }
+
   virtual mozilla::LogicalSize
   ComputeSize(gfxContext *aRenderingContext,
               mozilla::WritingMode aWritingMode,
               const mozilla::LogicalSize& aCBSize,
               nscoord aAvailableISize,
               const mozilla::LogicalSize& aMargin,
               const mozilla::LogicalSize& aBorder,
               const mozilla::LogicalSize& aPadding,