Bug 1108104 part 2 - Move incremental reflow hack from nsSimplePageSequenceFrame::Reflow to nsTableOuterFrame. This is to avoid breaking pages that don't even use tables. r=roc
authorMats Palmgren <mats@mozilla.com>
Sun, 14 Dec 2014 17:22:06 +0000
changeset 245500 940e9ff05cfe7589dc93034778415d95d307890f
parent 245499 c85d2fa3b4cb04c4c95c07bbddf7fad307a4f7e5
child 245501 9a373a63d7de93b0720c4740a84b5c6bead0dc0d
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1108104
milestone37.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 1108104 part 2 - Move incremental reflow hack from nsSimplePageSequenceFrame::Reflow to nsTableOuterFrame. This is to avoid breaking pages that don't even use tables. r=roc
layout/generic/nsSimplePageSequenceFrame.cpp
layout/tables/nsTableOuterFrame.cpp
--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -164,42 +164,16 @@ nsSimplePageSequenceFrame::Reflow(nsPres
   NS_PRECONDITION(aPresContext->IsRootPaginatedDocument(),
                   "A Page Sequence is only for real pages");
   DO_GLOBAL_REFLOW_COUNT("nsSimplePageSequenceFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
   NS_FRAME_TRACE_REFLOW_IN("nsSimplePageSequenceFrame::Reflow");
 
   aStatus = NS_FRAME_COMPLETE;  // we're always complete
 
-  // Don't do incremental reflow until we've taught tables how to do
-  // it right in paginated mode.
-  if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
-    // Return our desired size
-    SetDesiredSize(aDesiredSize, aReflowState, mSize.width, mSize.height);
-    aDesiredSize.SetOverflowAreasToDesiredBounds();
-    FinishAndStoreOverflow(&aDesiredSize);
-
-    if (GetRect().Width() != aDesiredSize.Width()) {
-      // Our width is changing; we need to re-center our children (our pages).
-      for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
-        nsIFrame* child = e.get();
-        nsMargin pageCSSMargin = child->GetUsedMargin();
-        nscoord centeringMargin =
-          ComputeCenteringMargin(aReflowState.ComputedWidth(),
-                                 child->GetRect().width,
-                                 pageCSSMargin);
-        nscoord newX = pageCSSMargin.left + centeringMargin;
-
-        // Adjust the child's x-position:
-        child->MovePositionBy(nsPoint(newX - child->GetNormalPosition().x, 0));
-      }
-    }
-    return;
-  }
-
   // See if we can get a Print Settings from the Context
   if (!mPageData->mPrintSettings &&
       aPresContext->Medium() == nsGkAtoms::print) {
       mPageData->mPrintSettings = aPresContext->GetPrintSettings();
   }
 
   // now get out margins & edges
   if (mPageData->mPrintSettings) {
--- a/layout/tables/nsTableOuterFrame.cpp
+++ b/layout/tables/nsTableOuterFrame.cpp
@@ -997,16 +997,35 @@ nsTableOuterFrame::Reflow(nsPresContext*
     wm = mCaptionFrames.FirstChild()->GetWritingMode();
     OuterBeginReflowChild(aPresContext, mCaptionFrames.FirstChild(), aOuterRS,
                           captionRSSpace, aOuterRS.ComputedSize(wm).ISize(wm));
     wm = InnerTableFrame()->GetWritingMode();
     OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
                           innerRSSpace, aOuterRS.ComputedSize(wm).ISize(wm));
   }
 
+  // Don't do incremental reflow until we've taught tables how to do
+  // it right in paginated mode.
+  if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
+      aPresContext->IsPaginated() &&
+      GetNextInFlow()) {
+    nsIFrame* nif = GetNextInFlow();
+    bool oc = nif->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER;
+    NS_MergeReflowStatusInto(&aStatus,
+        oc ? NS_FRAME_OVERFLOW_INCOMPLETE : NS_FRAME_NOT_COMPLETE);
+    nsMargin innerMargin = innerRS->ComputedPhysicalMargin();
+    nsMargin captionMargin;
+    if (mCaptionFrames.NotEmpty()) {
+      captionMargin = captionRS->ComputedPhysicalMargin();
+    }
+    UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, captionMargin);
+    FinishAndStoreOverflow(&aDesiredSize);
+    return;
+  }
+
   // First reflow the caption.
   nsHTMLReflowMetrics captionMet(captionRS->GetWritingMode());
   nsSize captionSize;
   nsMargin captionMargin;
   if (mCaptionFrames.NotEmpty()) {
     nsReflowStatus capStatus; // don't let the caption cause incomplete
     OuterDoReflowChild(aPresContext, mCaptionFrames.FirstChild(),
                        *captionRS, captionMet, capStatus);