Bug 1316051 part 5 - [css-grid] Subtract the caption size from the CB size that is used for stretching table items. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Fri, 18 Nov 2016 19:08:31 +0100
changeset 323466 70a0b4ff9d0886ce56078a3cd67aeb14af12be30
parent 323465 ca1c1dc37eb521f55ea779b3de8472562994c93f
child 323467 728c0feff62374ea8b2d117cdd80aa1751665c96
push id30978
push usercbook@mozilla.com
push dateMon, 21 Nov 2016 14:44:46 +0000
treeherdermozilla-central@0534254e9a40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1316051
milestone53.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 1316051 part 5 - [css-grid] Subtract the caption size from the CB size that is used for stretching table items. r=dholbert
layout/tables/nsTableWrapperFrame.cpp
--- a/layout/tables/nsTableWrapperFrame.cpp
+++ b/layout/tables/nsTableWrapperFrame.cpp
@@ -946,29 +946,50 @@ nsTableWrapperFrame::Reflow(nsPresContex
     OuterDoReflowChild(aPresContext, mCaptionFrames.FirstChild(),
                        *captionRI, *captionMet, capStatus);
     captionSize.ISize(wm) = captionMet->ISize(wm);
     captionSize.BSize(wm) = captionMet->BSize(wm);
     captionMargin =
       captionRI->ComputedLogicalMargin().ConvertTo(wm, captionWM);
     // Now that we know the bsize of the caption, reduce the available bsize
     // for the table frame if we are bsize constrained and the caption is above
-    // or below the inner table.
-    if (NS_UNCONSTRAINEDSIZE != aOuterRI.AvailableBSize()) {
+    // or below the inner table.  Also reduce the CB size that we store for
+    // our children in case we're a grid item, by the same amount.
+    LogicalSize* cbSize = Properties().Get(GridItemCBSizeProperty());
+    if (NS_UNCONSTRAINEDSIZE != aOuterRI.AvailableBSize() || cbSize) {
       nscoord captionBSize = 0;
+      nscoord captionISize = 0;
       switch (captionSide) {
         case NS_STYLE_CAPTION_SIDE_TOP:
         case NS_STYLE_CAPTION_SIDE_BOTTOM:
         case NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE:
         case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE:
           captionBSize = captionSize.BSize(wm) + captionMargin.BStartEnd(wm);
           break;
+        case NS_STYLE_CAPTION_SIDE_LEFT:
+        case NS_STYLE_CAPTION_SIDE_RIGHT:
+          captionISize = captionSize.ISize(wm) + captionMargin.IStartEnd(wm);
+          break;
       }
-      innerRI->AvailableBSize() =
-        std::max(0, innerRI->AvailableBSize() - captionBSize);
+      if (NS_UNCONSTRAINEDSIZE != aOuterRI.AvailableBSize()) {
+        innerRI->AvailableBSize() =
+          std::max(0, innerRI->AvailableBSize() - captionBSize);
+      }
+      if (cbSize) {
+        // Shrink the CB size by the size reserved for the caption.
+        LogicalSize oldCBSize = *cbSize;
+        cbSize->ISize(wm) = std::max(0, cbSize->ISize(wm) - captionISize);
+        cbSize->BSize(wm) = std::max(0, cbSize->BSize(wm) - captionBSize);
+        if (oldCBSize != *cbSize) {
+          // Reset the inner table's ReflowInput to stretch it to the new size.
+          innerRI.reset();
+          OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRI,
+                                innerRI, aOuterRI.ComputedSize(wm).ISize(wm));
+        }
+      }
     }
   }
 
   // Then, now that we know how much to reduce the isize of the inner
   // table to account for side captions, reflow the inner table.
   ReflowOutput innerMet(innerRI->GetWritingMode());
   OuterDoReflowChild(aPresContext, InnerTableFrame(), *innerRI,
                      innerMet, aStatus);