Bug 1152354 - Re-introduce the incremental reflow hack in nsSimplePageSequenceFrame for now, since the regressions are worse than the original problem (bug 1108104). r=roc, a=sledru
authorMats Palmgren <mats@mozilla.com>
Mon, 20 Apr 2015 05:46:00 -0400
changeset 265716 26cd78475d8bfccd990e72bd273238dbc378ccbe
parent 265715 17d1f11c999838d7b016deba159d439ee3888a9d
child 265717 250baad4c5d24e0756ba2f3671811e76f2aa42c8
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)
reviewersroc, sledru
bugs1152354, 1108104
milestone39.0a2
Bug 1152354 - Re-introduce the incremental reflow hack in nsSimplePageSequenceFrame for now, since the regressions are worse than the original problem (bug 1108104). r=roc, a=sledru
layout/generic/nsSimplePageSequenceFrame.cpp
layout/reftests/printing/reftest.list
layout/tables/nsTableOuterFrame.cpp
--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -165,16 +165,42 @@ 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/reftests/printing/reftest.list
+++ b/layout/reftests/printing/reftest.list
@@ -27,9 +27,9 @@ fails-if(B2G||Mulet) == 115199-1.html 11
 skip-if(B2G||Mulet) fuzzy-if(cocoaWidget,1,5000) == 745025-1.html 745025-1-ref.html # reftest-print doesn't work on B2G # Initial mulet triage: parity with B2G/B2G Desktop
 == 820496-1.html 820496-1-ref.html
 
 # NOTE: These tests don't yet rigorously test what they're
 # trying to test (shrink-to-fit behavior), due to bug 967311.
 random-if((B2G&&browserIsRemote)||Mulet) == 960822.html 960822-ref.html # reftest-print doesn't work on B2G (scrollbar difference only) # Initial mulet triage: parity with B2G/B2G Desktop
 == 966419-1.html 966419-1-ref.html
 == 966419-2.html 966419-2-ref.html
-# skip-if(B2G||Mulet) asserts(3) HTTP(..) == 1108104.html 1108104-ref.html # bug 1067755, 1135556 # Initial mulet triage: parity with B2G/B2G Desktop
+# skip-if(B2G||Mulet) asserts(3) HTTP(..) fails 1108104.html 1108104-ref.html # bug 1067755, 1135556 # Initial mulet triage: parity with B2G/B2G Desktop
--- a/layout/tables/nsTableOuterFrame.cpp
+++ b/layout/tables/nsTableOuterFrame.cpp
@@ -876,35 +876,16 @@ 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);