Bug 1138495 - pt 1 - Rename NS_FRAME_IN_CONSTRAINED_HEIGHT flag to NS_FRAME_IN_CONSTRAINED_BSIZE, and set it appropriately according to writing mode. r=smontagu
authorJonathan Kew <jkew@mozilla.com>
Tue, 10 Mar 2015 14:28:23 +0000
changeset 261610 77d2661c8d1af8699fbb7498fa44414ebb7250ef
parent 261609 3b2a45bc4307a0a5cff0949a4e30d3b86b5bdb0f
child 261611 9804af358570510831d3a46489194e2d6d942f56
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs1138495
milestone39.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 1138495 - pt 1 - Rename NS_FRAME_IN_CONSTRAINED_HEIGHT flag to NS_FRAME_IN_CONSTRAINED_BSIZE, and set it appropriately according to writing mode. r=smontagu
layout/base/nsLayoutUtils.cpp
layout/generic/nsFrameStateBits.h
layout/generic/nsHTMLReflowState.cpp
layout/generic/nsLineLayout.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -7299,24 +7299,24 @@ nsLayoutUtils::FontSizeInflationInner(co
 }
 
 static bool
 ShouldInflateFontsForContainer(const nsIFrame *aFrame)
 {
   // We only want to inflate fonts for text that is in a place
   // with room to expand.  The question is what the best heuristic for
   // that is...
-  // For now, we're going to use NS_FRAME_IN_CONSTRAINED_HEIGHT, which
+  // For now, we're going to use NS_FRAME_IN_CONSTRAINED_BSIZE, which
   // indicates whether the frame is inside something with a constrained
-  // height (propagating down the tree), but the propagation stops when
-  // we hit overflow-y: scroll or auto.
+  // block-size (propagating down the tree), but the propagation stops when
+  // we hit overflow-y [or -x, for vertical mode]: scroll or auto.
   const nsStyleText* styleText = aFrame->StyleText();
 
   return styleText->mTextSizeAdjust != NS_STYLE_TEXT_SIZE_ADJUST_NONE &&
-         !(aFrame->GetStateBits() & NS_FRAME_IN_CONSTRAINED_HEIGHT) &&
+         !(aFrame->GetStateBits() & NS_FRAME_IN_CONSTRAINED_BSIZE) &&
          // We also want to disable font inflation for containers that have
          // preformatted text.
          // MathML cells need special treatment. See bug 1002526 comment 56.
          (styleText->WhiteSpaceCanWrap(aFrame) ||
           aFrame->IsFrameOfType(nsIFrame::eMathML));
 }
 
 nscoord
--- a/layout/generic/nsFrameStateBits.h
+++ b/layout/generic/nsFrameStateBits.h
@@ -182,20 +182,20 @@ FRAME_STATE_BIT(Generic, 33, NS_FRAME_DR
 FRAME_STATE_BIT(Generic, 36, NS_FRAME_UPDATE_LAYER_TREE)
 
 // Frame can accept absolutely positioned children.
 FRAME_STATE_BIT(Generic, 37, NS_FRAME_HAS_ABSPOS_CHILDREN)
 
 // A display item for this frame has been painted as part of a PaintedLayer.
 FRAME_STATE_BIT(Generic, 38, NS_FRAME_PAINTED_THEBES)
 
-// Frame is or is a descendant of something with a fixed height, unless that
-// ancestor is a body or html element, and has no closer ancestor that is
+// Frame is or is a descendant of something with a fixed block-size, unless
+// that ancestor is a body or html element, and has no closer ancestor that is
 // overflow:auto or overflow:scroll.
-FRAME_STATE_BIT(Generic, 39, NS_FRAME_IN_CONSTRAINED_HEIGHT)
+FRAME_STATE_BIT(Generic, 39, NS_FRAME_IN_CONSTRAINED_BSIZE)
 
 // This is only set during painting
 FRAME_STATE_BIT(Generic, 40, NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO)
 
 // Is this frame a container for font size inflation, i.e., is it a
 // frame whose width is used to determine the inflation factor for
 // everything whose nearest ancestor container for this frame?
 FRAME_STATE_BIT(Generic, 41, NS_FRAME_FONT_INFLATION_CONTAINER)
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -374,62 +374,72 @@ nsHTMLReflowState::Init(nsPresContext* a
 
   InitConstraints(aPresContext, aContainingBlockWidth, aContainingBlockHeight,
                   aBorder, aPadding, type);
 
   InitResizeFlags(aPresContext, type);
 
   nsIFrame *parent = frame->GetParent();
   if (parent &&
-      (parent->GetStateBits() & NS_FRAME_IN_CONSTRAINED_HEIGHT) &&
+      (parent->GetStateBits() & NS_FRAME_IN_CONSTRAINED_BSIZE) &&
       !(parent->GetType() == nsGkAtoms::scrollFrame &&
         parent->StyleDisplay()->mOverflowY != NS_STYLE_OVERFLOW_HIDDEN)) {
-    frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_HEIGHT);
+    frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
   } else if (type == nsGkAtoms::svgForeignObjectFrame) {
-    // An SVG foreignObject frame is inherently constrained height.
-    frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_HEIGHT);
-  } else if ((mStylePosition->mHeight.GetUnit() != eStyleUnit_Auto ||
-              mStylePosition->mMaxHeight.GetUnit() != eStyleUnit_None) &&
-              // Don't set NS_FRAME_IN_CONSTRAINED_HEIGHT on body or html
-              // elements.
-             (frame->GetContent() &&
-            !(frame->GetContent()->IsAnyOfHTMLElements(nsGkAtoms::body,
-                                                       nsGkAtoms::html)))) {
+    // An SVG foreignObject frame is inherently constrained block-size.
+    frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
+  } else {
+    const bool vertical = mWritingMode.IsVertical();
+    const nsStyleCoord& bSizeCoord =
+      vertical ? mStylePosition->mWidth : mStylePosition->mHeight;
+    const nsStyleCoord& maxBSizeCoord =
+      vertical ? mStylePosition->mMaxWidth : mStylePosition->mMaxHeight;
+    if ((bSizeCoord.GetUnit() != eStyleUnit_Auto ||
+         maxBSizeCoord.GetUnit() != eStyleUnit_None) &&
+         // Don't set NS_FRAME_IN_CONSTRAINED_BSIZE on body or html elements.
+         (frame->GetContent() &&
+        !(frame->GetContent()->IsAnyOfHTMLElements(nsGkAtoms::body,
+                                                   nsGkAtoms::html)))) {
 
-    // If our height was specified as a percentage, then this could
-    // actually resolve to 'auto', based on:
-    // http://www.w3.org/TR/CSS21/visudet.html#the-height-property
-    nsIFrame* containingBlk = frame;
-    while (containingBlk) {
-      const nsStylePosition* stylePos = containingBlk->StylePosition();
-      if ((stylePos->mHeight.IsCoordPercentCalcUnit() &&
-           !stylePos->mHeight.HasPercent()) ||
-          (stylePos->mMaxHeight.IsCoordPercentCalcUnit() &&
-           !stylePos->mMaxHeight.HasPercent())) {
-        frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_HEIGHT);
-        break;
-      } else if ((stylePos->mHeight.IsCoordPercentCalcUnit() &&
-                  stylePos->mHeight.HasPercent()) ||
-                 (stylePos->mMaxHeight.IsCoordPercentCalcUnit() &&
-                  stylePos->mMaxHeight.HasPercent())) {
-        if (!(containingBlk = containingBlk->GetContainingBlock())) {
-          // If we've reached the top of the tree, then we don't have
-          // a constrained height.
-          frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_HEIGHT);
+      // If our block-size was specified as a percentage, then this could
+      // actually resolve to 'auto', based on:
+      // http://www.w3.org/TR/CSS21/visudet.html#the-height-property
+      nsIFrame* containingBlk = frame;
+      while (containingBlk) {
+        const nsStylePosition* stylePos = containingBlk->StylePosition();
+        const nsStyleCoord& bSizeCoord =
+          vertical ? stylePos->mWidth : stylePos->mHeight;
+        const nsStyleCoord& maxBSizeCoord =
+          vertical ? stylePos->mMaxWidth : stylePos->mMaxHeight;
+        if ((bSizeCoord.IsCoordPercentCalcUnit() &&
+             !bSizeCoord.HasPercent()) ||
+            (maxBSizeCoord.IsCoordPercentCalcUnit() &&
+             !maxBSizeCoord.HasPercent())) {
+          frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
+          break;
+        } else if ((bSizeCoord.IsCoordPercentCalcUnit() &&
+                    bSizeCoord.HasPercent()) ||
+                   (maxBSizeCoord.IsCoordPercentCalcUnit() &&
+                    maxBSizeCoord.HasPercent())) {
+          if (!(containingBlk = containingBlk->GetContainingBlock())) {
+            // If we've reached the top of the tree, then we don't have
+            // a constrained block-size.
+            frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
+            break;
+          }
+
+          continue;
+        } else {
+          frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
           break;
         }
-
-        continue;
-      } else {
-        frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_HEIGHT);
-        break;
       }
+    } else {
+      frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
     }
-  } else {
-    frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_HEIGHT);
   }
 
   NS_WARN_IF_FALSE((mFrameType == NS_CSS_FRAME_TYPE_INLINE &&
                     !frame->IsFrameOfType(nsIFrame::eReplaced)) ||
                    type == nsGkAtoms::textFrame ||
                    ComputedISize() != NS_UNCONSTRAINEDSIZE,
                    "have unconstrained inline-size; this should only result from "
                    "very large sizes, not attempts at intrinsic inline-size "
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -202,20 +202,20 @@ nsLineLayout::BeginLineReflow(nscoord aI
   PerSpanData* psd = NewPerSpanData();
   mCurrentSpan = mRootSpan = psd;
   psd->mReflowState = mBlockReflowState;
   psd->mIStart = aICoord;
   psd->mICoord = aICoord;
   psd->mIEnd = aICoord + aISize;
   mContainerSize = aContainerSize;
 
-  // If we're in a constrained height frame, then we don't allow a
+  // If we're in a constrained block-size frame, then we don't allow a
   // max line box width to take effect.
   if (!(LineContainerFrame()->GetStateBits() &
-        NS_FRAME_IN_CONSTRAINED_HEIGHT)) {
+        NS_FRAME_IN_CONSTRAINED_BSIZE)) {
 
     // If the available size is greater than the maximum line box width (if
     // specified), then we need to adjust the line box width to be at the max
     // possible width.
     nscoord maxLineBoxWidth =
       LineContainerFrame()->PresContext()->PresShell()->MaxLineBoxWidth();
 
     if (maxLineBoxWidth > 0 &&