--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -81,24 +81,29 @@ NS_QUERYFRAME_TAIL_INHERITING(nsContaine
//----------------------------------------------------------------------
void
nsSimplePageSequenceFrame::SetDesiredSize(ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,
nscoord aWidth,
nscoord aHeight)
{
- // Aim to fill the whole size of the document, not only so we
- // can act as a background in print preview but also handle overflow
- // in child page frames correctly.
- // Use availableWidth so we don't cause a needless horizontal scrollbar.
- aDesiredSize.Width() = std::max(aReflowInput.AvailableWidth(),
- nscoord(aWidth * PresContext()->GetPrintPreviewScale()));
- aDesiredSize.Height() = std::max(aReflowInput.ComputedHeight(),
- nscoord(aHeight * PresContext()->GetPrintPreviewScale()));
+ // Aim to fill the whole size of the document, not only so we
+ // can act as a background in print preview but also handle overflow
+ // in child page frames correctly.
+ // Use availableISize so we don't cause a needless horizontal scrollbar.
+ WritingMode wm = aReflowInput.GetWritingMode();
+ nscoord scaledWidth = aWidth * PresContext()->GetPrintPreviewScale();
+ nscoord scaledHeight = aHeight * PresContext()->GetPrintPreviewScale();
+
+ nscoord scaledISize = (wm.IsVertical() ? scaledHeight : scaledWidth);
+ nscoord scaledBSize = (wm.IsVertical() ? scaledWidth : scaledHeight);
+
+ aDesiredSize.ISize(wm) = std::max(scaledISize, aReflowInput.AvailableISize());
+ aDesiredSize.BSize(wm) = std::max(scaledBSize, aReflowInput.ComputedBSize());
}
// Helper function to compute the offset needed to center a child
// page-frame's margin-box inside our content-box.
nscoord
nsSimplePageSequenceFrame::ComputeCenteringMargin(
nscoord aContainerContentBoxWidth,
nscoord aChildPaddingBoxWidth,
@@ -128,21 +133,26 @@ nsSimplePageSequenceFrame::ComputeCenter
// To center the child, we want to give it an additional left-margin of half
// of the extra space. And then, we have to scale that space back down, so
// that it'll produce the correct scaled-up amount when we render (because
// rendering will scale it back up):
return NSToCoordRound(scaledExtraSpace * 0.5 / ppScale);
}
+/*
+ * Note: we largely position/size out our children (page frames) using
+ * \*physical\* x/y/width/height values, because the print preview UI is always
+ * arranged in the same orientation, regardless of writing mode.
+ */
void
-nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
- ReflowOutput& aDesiredSize,
+nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
+ ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,
- nsReflowStatus& aStatus)
+ nsReflowStatus& aStatus)
{
MarkInReflow();
NS_PRECONDITION(aPresContext->IsRootPaginatedDocument(),
"A Page Sequence is only for real pages");
DO_GLOBAL_REFLOW_COUNT("nsSimplePageSequenceFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
NS_FRAME_TRACE_REFLOW_IN("nsSimplePageSequenceFrame::Reflow");
@@ -158,17 +168,17 @@ nsSimplePageSequenceFrame::Reflow(nsPres
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(aReflowInput.ComputedWidth(),
- child->GetRect().width,
+ child->GetRect().Width(),
pageCSSMargin);
nscoord newX = pageCSSMargin.left + centeringMargin;
// Adjust the child's x-position:
child->MovePositionBy(nsPoint(newX - child->GetNormalPosition().x, 0));
}
}
return;
@@ -237,23 +247,25 @@ nsSimplePageSequenceFrame::Reflow(nsPres
for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
nsIFrame* kidFrame = e.get();
// Set the shared data into the page frame before reflow
nsPageFrame * pf = static_cast<nsPageFrame*>(kidFrame);
pf->SetSharedPageData(mPageData);
// Reflow the page
ReflowInput kidReflowInput(aPresContext, aReflowInput, kidFrame,
- LogicalSize(kidFrame->GetWritingMode(),
+ LogicalSize(kidFrame->GetWritingMode(),
pageSize));
nsReflowStatus status;
- kidReflowInput.SetComputedWidth(kidReflowInput.AvailableWidth());
+ kidReflowInput.SetComputedISize(kidReflowInput.AvailableISize());
//kidReflowInput.SetComputedHeight(kidReflowInput.AvailableHeight());
- PR_PL(("AV W: %d H: %d\n", kidReflowInput.AvailableWidth(), kidReflowInput.AvailableHeight()));
+ PR_PL(("AV ISize: %d BSize: %d\n",
+ kidReflowInput.AvailableISize(),
+ kidReflowInput.AvailableBSize()));
nsMargin pageCSSMargin = kidReflowInput.ComputedPhysicalMargin();
y += pageCSSMargin.top;
nscoord x = pageCSSMargin.left;
// Place and size the page.
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowInput, x, y, 0, status);