Bug 1088025 - part 1 - Ensure nsBlockReflowState has a constrained mContainerWidth before we reflow lines into the container. r=dbaron
authorJonathan Kew <jkew@mozilla.com>
Thu, 13 Nov 2014 08:58:03 +0000
changeset 215477 355036dd6de6bc355c4962296594c7a8ef8708ab
parent 215476 97219a3030c136bdc3b6297ef869506964dccb1d
child 215478 633acdbe6568a204f8e4dfd07cec213bd36bb279
push id27817
push usercbook@mozilla.com
push dateThu, 13 Nov 2014 15:21:11 +0000
treeherdermozilla-central@ae27ae77e32f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1088025
milestone36.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 1088025 - part 1 - Ensure nsBlockReflowState has a constrained mContainerWidth before we reflow lines into the container. r=dbaron
layout/generic/nsBlockReflowState.cpp
layout/generic/nsBlockReflowState.h
layout/generic/nsLineBox.h
layout/generic/nsLineLayout.h
--- a/layout/generic/nsBlockReflowState.cpp
+++ b/layout/generic/nsBlockReflowState.cpp
@@ -49,18 +49,29 @@ nsBlockReflowState::nsBlockReflowState(c
   WritingMode wm = aReflowState.GetWritingMode();
   SetFlag(BRS_ISFIRSTINFLOW, aFrame->GetPrevInFlow() == nullptr);
   SetFlag(BRS_ISOVERFLOWCONTAINER, IS_TRUE_OVERFLOW_CONTAINER(aFrame));
 
   nsIFrame::LogicalSides logicalSkipSides =
     aFrame->GetLogicalSkipSides(&aReflowState);
   mBorderPadding.ApplySkipSides(logicalSkipSides);
 
-  // Note that mContainerWidth is the physical width!
-  mContainerWidth = aReflowState.ComputedWidth() + mBorderPadding.LeftRight(wm);
+  // Note that mContainerWidth is the physical width, needed to convert
+  // logical block-coordinates in vertical-rl writing mode (measured from a
+  // RHS origin) to physical coordinates within the containing block.
+  // If aReflowState doesn't have a constrained ComputedWidth(), we set it to
+  // zero, which means lines will be positioned (physically) incorrectly;
+  // we will fix them up at the end of nsBlockFrame::Reflow, after we know
+  // the total block-size of the frame.
+  mContainerWidth = aReflowState.ComputedWidth();
+  if (mContainerWidth == NS_UNCONSTRAINEDSIZE) {
+    mContainerWidth = 0;
+  }
+
+  mContainerWidth += mBorderPadding.LeftRight(wm);
 
   if ((aBStartMarginRoot && !logicalSkipSides.BStart()) ||
       0 != mBorderPadding.BStart(wm)) {
     SetFlag(BRS_ISBSTARTMARGINROOT, true);
     SetFlag(BRS_APPLYBSTARTMARGIN, true);
   }
   if ((aBEndMarginRoot && !logicalSkipSides.BEnd()) ||
       0 != mBorderPadding.BEnd(wm)) {
--- a/layout/generic/nsBlockReflowState.h
+++ b/layout/generic/nsBlockReflowState.h
@@ -198,16 +198,18 @@ public:
   }
   nscoord ContentBEnd() const {
     return mContentArea.BEnd(mReflowState.GetWritingMode());
   }
   mozilla::LogicalSize ContentSize(mozilla::WritingMode aWM) const {
     mozilla::WritingMode wm = mReflowState.GetWritingMode();
     return mContentArea.Size(wm).ConvertTo(aWM, wm);
   }
+
+  // Physical width. Use only for physical <-> logical coordinate conversion.
   nscoord mContainerWidth;
 
   // Continuation out-of-flow float frames that need to move to our
   // next in flow are placed here during reflow.  It's a pointer to
   // a frame list stored in the block's property table.
   nsFrameList *mPushedFloats;
   // This method makes sure pushed floats are accessible to
   // StealFrame. Call it before adding any frames to mPushedFloats.
--- a/layout/generic/nsLineBox.h
+++ b/layout/generic/nsLineBox.h
@@ -582,19 +582,23 @@ public:
 
 #ifdef DEBUG
   static int32_t GetCtorCount();
 #endif
 
   nsIFrame* mFirstChild;
 
   mozilla::WritingMode mWritingMode;
+
+  // Physical width. Use only for physical <-> logical coordinate conversion.
   nscoord mContainerWidth;
+
  private:
   mozilla::LogicalRect mBounds;
+
  public:
   const mozilla::LogicalRect& GetBounds() { return mBounds; }
   nsRect GetPhysicalBounds() const
   {
     if (mBounds.IsAllZero()) {
       return nsRect(0, 0, 0, 0);
     }
 
--- a/layout/generic/nsLineLayout.h
+++ b/layout/generic/nsLineLayout.h
@@ -532,16 +532,17 @@ protected:
   // Final computed line-bSize value after VerticalAlignFrames for
   // the block has been called.
   nscoord mFinalLineBSize;
   
   // Amount of trimmable whitespace inline size for the trailing text
   // frame, if any
   nscoord mTrimmableISize;
 
+  // Physical width. Use only for physical <-> logical coordinate conversion.
   nscoord mContainerWidth;
 
   bool mFirstLetterStyleOK      : 1;
   bool mIsTopOfPage             : 1;
   bool mImpactedByFloats        : 1;
   bool mLastFloatWasLetterFrame : 1;
   bool mLineIsEmpty             : 1;
   bool mLineEndsInBR            : 1;