Bug 1267462 part 5: Move WritingMode member-var earlier in FlexItem class. r=mats
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 08 Feb 2018 14:58:47 -0800
changeset 752933 60666668cf81676e5917e94c9a5ac34c73f944b7
parent 752932 2a4fea53334eb5aaf173559a56a704d3bab59f52
child 752934 ceef95f707fe6926cc7419495e61d1fe4223d52c
push id98429
push usermak77@bonardo.net
push dateFri, 09 Feb 2018 10:14:12 +0000
reviewersmats
bugs1267462
milestone60.0a1
Bug 1267462 part 5: Move WritingMode member-var earlier in FlexItem class. r=mats This patch doesn't affect behavior. It simply reorders a member variable to be near the beginning of the FlexItem class, so that the next patch in this series can use that member-variable when initializing another member in the constructor init list. (You're only allowed to use earlier member-vars like this, since member-vars get initialized in order.) MozReview-Commit-ID: 9v4Dr0Ir6i7
layout/generic/nsFlexContainerFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -800,25 +800,21 @@ public:
   // establish the cross size?
   bool CanMainSizeInfluenceCrossSize(const FlexboxAxisTracker& aAxisTracker) const;
 
 protected:
   // Helper called by the constructor, to set mNeedsMinSizeAutoResolution:
   void CheckForMinSizeAuto(const ReflowInput& aFlexItemReflowInput,
                            const FlexboxAxisTracker& aAxisTracker);
 
-  // Our frame:
-  nsIFrame* const mFrame;
-
-  // Values that we already know in constructor: (and are hence mostly 'const')
+  // Values that we already know in constructor (and are hence mostly 'const'):
+  nsIFrame* const mFrame; // The flex item's frame.
   const float mFlexGrow;
   const float mFlexShrink;
-
   const nsSize mIntrinsicRatio;
-
   const nsMargin mBorderPadding;
   nsMargin mMargin; // non-const because we need to resolve auto margins
 
   // These are non-const so that we can lazily update them with the item's
   // intrinsic size (obtained via a "measuring" reflow), when necessary.
   // (e.g. for "flex-basis:auto;height:auto" & "min-height:auto")
   nscoord mFlexBaseSize;
   nscoord mMainMinSize;
@@ -836,31 +832,32 @@ protected:
                            // via const pointer. See comment above SetAscent().
 
   // Temporary state, while we're resolving flexible widths (for our main size)
   // XXXdholbert To save space, we could use a union to make these variables
   // overlay the same memory as some other member vars that aren't touched
   // until after main-size has been resolved. In particular, these could share
   // memory with mMainPosn through mAscent, and mIsStretched.
   float mShareOfWeightSoFar;
+
+  const WritingMode mWM; // The flex item's writing mode.
   bool mIsFrozen;
   bool mHadMinViolation;
   bool mHadMaxViolation;
 
   // Misc:
   bool mHadMeasuringReflow; // Did this item get a preliminary reflow,
                             // to measure its desired height?
   bool mIsStretched; // See IsStretched() documentation
   bool mIsStrut;     // Is this item a "strut" left behind by an element
                      // with visibility:collapse?
 
   // Does this item need to resolve a min-[width|height]:auto (in main-axis).
   bool mNeedsMinSizeAutoResolution;
 
-  const WritingMode mWM; // The flex item's writing mode.
   uint8_t mAlignSelf; // My "align-self" computed value (with "auto"
                       // swapped out for parent"s "align-items" value,
                       // in our constructor).
 };
 
 /**
  * Represents a single flex line in a flex container.
  * Manages a linked list of the FlexItems that are in the line.
@@ -1793,24 +1790,24 @@ FlexItem::FlexItem(ReflowInput& aFlexIte
     mMainMaxSize(aMainMaxSize),
     mCrossMinSize(aCrossMinSize),
     mCrossMaxSize(aCrossMaxSize),
     mMainPosn(0),
     mCrossSize(aTentativeCrossSize),
     mCrossPosn(0),
     mAscent(0),
     mShareOfWeightSoFar(0.0f),
+    mWM(aFlexItemReflowInput.GetWritingMode()),
     mIsFrozen(false),
     mHadMinViolation(false),
     mHadMaxViolation(false),
     mHadMeasuringReflow(false),
     mIsStretched(false),
-    mIsStrut(false),
+    mIsStrut(false)
     // mNeedsMinSizeAutoResolution is initialized in CheckForMinSizeAuto()
-    mWM(aFlexItemReflowInput.GetWritingMode())
     // mAlignSelf, see below
 {
   MOZ_ASSERT(mFrame, "expecting a non-null child frame");
   MOZ_ASSERT(!mFrame->IsPlaceholderFrame(),
              "placeholder frames should not be treated as flex items");
   MOZ_ASSERT(!(mFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW),
              "out-of-flow frames should not be treated as flex items");
 
@@ -1888,24 +1885,26 @@ FlexItem::FlexItem(nsIFrame* aChildFrame
     mCrossMinSize(0),
     mCrossMaxSize(0),
     mMainSize(0),
     mMainPosn(0),
     mCrossSize(aCrossSize),
     mCrossPosn(0),
     mAscent(0),
     mShareOfWeightSoFar(0.0f),
+    // Struts don't do layout, so its WM doesn't matter at this point. So, we
+    // just share container's WM for simplicity:
+    mWM(aContainerWM),
     mIsFrozen(true),
     mHadMinViolation(false),
     mHadMaxViolation(false),
     mHadMeasuringReflow(false),
     mIsStretched(false),
     mIsStrut(true), // (this is the constructor for making struts, after all)
     mNeedsMinSizeAutoResolution(false),
-    mWM(aContainerWM),
     mAlignSelf(NS_STYLE_ALIGN_FLEX_START)
 {
   MOZ_ASSERT(mFrame, "expecting a non-null child frame");
   MOZ_ASSERT(NS_STYLE_VISIBILITY_COLLAPSE ==
              mFrame->StyleVisibility()->mVisible,
              "Should only make struts for children with 'visibility:collapse'");
   MOZ_ASSERT(!mFrame->IsPlaceholderFrame(),
              "placeholder frames should not be treated as flex items");