2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2013-09-25 01:43:43 +00:00
|
|
|
|
2014-02-18 08:58:22 +00:00
|
|
|
#include "nsSimplePageSequenceFrame.h"
|
2013-09-25 01:43:43 +00:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2014-10-20 09:55:49 +00:00
|
|
|
#include "nsDeviceContext.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2008-04-08 00:32:48 +00:00
|
|
|
#include "gfxContext.h"
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-12-07 03:43:02 +00:00
|
|
|
#include "nsIPresShell.h"
|
2002-01-01 12:58:53 +00:00
|
|
|
#include "nsIPrintSettings.h"
|
2001-01-27 14:09:34 +00:00
|
|
|
#include "nsPageFrame.h"
|
2012-08-31 00:24:35 +00:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2002-08-30 03:32:05 +00:00
|
|
|
#include "nsRegion.h"
|
2004-01-21 23:05:10 +00:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2004-04-29 23:34:19 +00:00
|
|
|
#include "nsContentUtils.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2012-08-31 00:24:35 +00:00
|
|
|
#include "nsHTMLCanvasFrame.h"
|
2013-01-04 05:16:14 +00:00
|
|
|
#include "mozilla/dom/HTMLCanvasElement.h"
|
2012-08-31 00:24:35 +00:00
|
|
|
#include "nsICanvasRenderingContextInternal.h"
|
2013-08-22 18:32:52 +00:00
|
|
|
#include "nsIDateTimeFormat.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
2001-11-28 15:19:47 +00:00
|
|
|
|
2001-09-26 14:01:26 +00:00
|
|
|
// DateTime Includes
|
|
|
|
#include "nsDateTimeFormatCID.h"
|
|
|
|
|
2001-01-27 14:09:34 +00:00
|
|
|
#define OFFSET_NOT_SET -1
|
|
|
|
|
|
|
|
// Print Options
|
|
|
|
#include "nsIPrintOptions.h"
|
2002-05-14 14:15:19 +00:00
|
|
|
|
2011-05-25 06:32:00 +00:00
|
|
|
using namespace mozilla;
|
2013-01-04 05:16:14 +00:00
|
|
|
using namespace mozilla::dom;
|
2011-05-25 06:32:00 +00:00
|
|
|
|
2002-05-14 14:32:42 +00:00
|
|
|
static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1";
|
2002-05-14 12:05:00 +00:00
|
|
|
|
2001-01-27 14:09:34 +00:00
|
|
|
//
|
1998-12-07 03:43:02 +00:00
|
|
|
|
2002-06-19 21:51:13 +00:00
|
|
|
#include "prlog.h"
|
|
|
|
#ifdef PR_LOGGING
|
2012-10-29 23:32:10 +00:00
|
|
|
PRLogModuleInfo *
|
|
|
|
GetLayoutPrintingLog()
|
|
|
|
{
|
|
|
|
static PRLogModuleInfo *sLog;
|
|
|
|
if (!sLog)
|
|
|
|
sLog = PR_NewLogModule("printing-layout");
|
|
|
|
return sLog;
|
|
|
|
}
|
|
|
|
#define PR_PL(_p1) PR_LOG(GetLayoutPrintingLog(), PR_LOG_DEBUG, _p1)
|
2002-06-19 21:51:13 +00:00
|
|
|
#else
|
|
|
|
#define PR_PL(_p1)
|
2001-04-12 13:04:29 +00:00
|
|
|
#endif
|
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
nsSimplePageSequenceFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-05-11 22:03:29 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsSimplePageSequenceFrame(aContext);
|
1999-05-11 22:03:29 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSimplePageSequenceFrame)
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsSimplePageSequenceFrame::nsSimplePageSequenceFrame(nsStyleContext* aContext) :
|
|
|
|
nsContainerFrame(aContext),
|
2002-02-12 13:33:39 +00:00
|
|
|
mTotalPages(-1),
|
2001-11-03 14:59:39 +00:00
|
|
|
mSelectionHeight(-1),
|
2012-08-31 00:24:35 +00:00
|
|
|
mYSelOffset(0),
|
2012-10-10 05:00:05 +00:00
|
|
|
mCalledBeginPage(false),
|
|
|
|
mCurrentCanvasListSetup(false)
|
2001-01-27 14:09:34 +00:00
|
|
|
{
|
2010-08-13 09:58:04 +00:00
|
|
|
nscoord halfInch = PresContext()->CSSTwipsToAppUnits(NS_INCHES_TO_TWIPS(0.5));
|
2001-01-27 14:09:34 +00:00
|
|
|
mMargin.SizeTo(halfInch, halfInch, halfInch, halfInch);
|
|
|
|
|
2006-07-14 16:07:28 +00:00
|
|
|
// XXX Unsafe to assume successful allocation
|
2001-11-03 14:59:39 +00:00
|
|
|
mPageData = new nsSharedPageData();
|
2012-01-25 23:52:26 +00:00
|
|
|
mPageData->mHeadFootFont =
|
2013-07-24 11:48:55 +00:00
|
|
|
*PresContext()->GetDefaultFont(kGenericFont_serif,
|
|
|
|
aContext->StyleFont()->mLanguage);
|
|
|
|
mPageData->mHeadFootFont.size = nsPresContext::CSSPointsToAppUnits(10);
|
2001-11-03 14:59:39 +00:00
|
|
|
|
2001-01-27 14:09:34 +00:00
|
|
|
nsresult rv;
|
2002-05-14 14:32:42 +00:00
|
|
|
mPageData->mPrintOptions = do_GetService(sPrintOptionsContractID, &rv);
|
2001-11-03 14:59:39 +00:00
|
|
|
|
|
|
|
// Doing this here so we only have to go get these formats once
|
2011-10-17 14:59:28 +00:00
|
|
|
SetPageNumberFormat("pagenumber", "%1$d", true);
|
|
|
|
SetPageNumberFormat("pageofpages", "%1$d of %2$d", false);
|
2001-01-27 14:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSimplePageSequenceFrame::~nsSimplePageSequenceFrame()
|
1999-05-11 22:03:29 +00:00
|
|
|
{
|
2011-05-17 14:01:36 +00:00
|
|
|
delete mPageData;
|
2012-10-02 17:42:21 +00:00
|
|
|
ResetPrintCanvasList();
|
1999-05-11 22:03:29 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsSimplePageSequenceFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIPageSequenceFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
1998-12-07 03:43:02 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
1998-11-04 23:21:50 +00:00
|
|
|
|
2011-06-10 10:07:26 +00:00
|
|
|
void
|
|
|
|
nsSimplePageSequenceFrame::SetDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
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.
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Width() = std::max(aReflowState.AvailableWidth(),
|
2011-06-10 10:07:26 +00:00
|
|
|
nscoord(aWidth * PresContext()->GetPrintPreviewScale()));
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Height() = std::max(aReflowState.ComputedHeight(),
|
2011-06-10 10:07:26 +00:00
|
|
|
nscoord(aHeight * PresContext()->GetPrintPreviewScale()));
|
|
|
|
}
|
|
|
|
|
2014-10-08 01:37:50 +00:00
|
|
|
// 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,
|
|
|
|
const nsMargin& aChildPhysicalMargin)
|
|
|
|
{
|
|
|
|
// We'll be centering our child's margin-box, so get the size of that:
|
|
|
|
nscoord childMarginBoxWidth =
|
|
|
|
aChildPaddingBoxWidth + aChildPhysicalMargin.LeftRight();
|
|
|
|
|
|
|
|
// When rendered, our child's rect will actually be scaled up by the
|
|
|
|
// print-preview scale factor, via ComputePageSequenceTransform().
|
|
|
|
// We really want to center *that scaled-up rendering* inside of
|
|
|
|
// aContainerContentBoxWidth. So, we scale up its margin-box here...
|
|
|
|
auto ppScale = PresContext()->GetPrintPreviewScale();
|
|
|
|
nscoord scaledChildMarginBoxWidth =
|
|
|
|
NSToCoordRound(childMarginBoxWidth * ppScale);
|
|
|
|
|
|
|
|
// ...and see we how much space is left over, when we subtract that scaled-up
|
|
|
|
// size from the container width:
|
|
|
|
nscoord scaledExtraSpace =
|
|
|
|
aContainerContentBoxWidth - scaledChildMarginBoxWidth;
|
|
|
|
|
|
|
|
if (scaledExtraSpace <= 0) {
|
|
|
|
// (Don't bother centering if there's zero/negative space.)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
1998-11-04 23:21:50 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2015-03-29 22:38:40 +00:00
|
|
|
MarkInReflow();
|
2006-04-11 01:48:48 +00:00
|
|
|
NS_PRECONDITION(aPresContext->IsRootPaginatedDocument(),
|
|
|
|
"A Page Sequence is only for real pages");
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsSimplePageSequenceFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1998-11-04 23:21:50 +00:00
|
|
|
NS_FRAME_TRACE_REFLOW_IN("nsSimplePageSequenceFrame::Reflow");
|
|
|
|
|
1999-03-09 22:34:51 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE; // we're always complete
|
1998-11-04 23:21:50 +00:00
|
|
|
|
2015-04-20 09:46:00 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2002-01-18 22:45:06 +00:00
|
|
|
// See if we can get a Print Settings from the Context
|
2004-07-29 19:41:39 +00:00
|
|
|
if (!mPageData->mPrintSettings &&
|
2006-12-26 17:47:52 +00:00
|
|
|
aPresContext->Medium() == nsGkAtoms::print) {
|
2004-07-29 19:41:39 +00:00
|
|
|
mPageData->mPrintSettings = aPresContext->GetPrintSettings();
|
2002-01-18 22:45:06 +00:00
|
|
|
}
|
|
|
|
|
2007-11-21 05:09:58 +00:00
|
|
|
// now get out margins & edges
|
2002-01-18 22:45:06 +00:00
|
|
|
if (mPageData->mPrintSettings) {
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntMargin unwriteableTwips;
|
2008-03-19 20:51:42 +00:00
|
|
|
mPageData->mPrintSettings->GetUnwriteableMarginInTwips(unwriteableTwips);
|
|
|
|
NS_ASSERTION(unwriteableTwips.left >= 0 && unwriteableTwips.top >= 0 &&
|
|
|
|
unwriteableTwips.right >= 0 && unwriteableTwips.bottom >= 0,
|
|
|
|
"Unwriteable twips should be non-negative");
|
|
|
|
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntMargin marginTwips;
|
2007-02-07 07:46:44 +00:00
|
|
|
mPageData->mPrintSettings->GetMarginInTwips(marginTwips);
|
2010-08-13 09:58:04 +00:00
|
|
|
mMargin = aPresContext->CSSTwipsToAppUnits(marginTwips + unwriteableTwips);
|
2008-03-19 20:51:42 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t printType;
|
2002-04-11 00:34:59 +00:00
|
|
|
mPageData->mPrintSettings->GetPrintRange(&printType);
|
|
|
|
mPrintRangeType = printType;
|
2007-11-21 05:09:58 +00:00
|
|
|
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntMargin edgeTwips;
|
2007-11-21 05:09:58 +00:00
|
|
|
mPageData->mPrintSettings->GetEdgeInTwips(edgeTwips);
|
|
|
|
|
2008-01-29 07:38:20 +00:00
|
|
|
// sanity check the values. three inches are sometimes needed
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t inchInTwips = NS_INCHES_TO_INT_TWIPS(3.0);
|
2011-10-28 18:33:28 +00:00
|
|
|
edgeTwips.top = clamped(edgeTwips.top, 0, inchInTwips);
|
|
|
|
edgeTwips.bottom = clamped(edgeTwips.bottom, 0, inchInTwips);
|
|
|
|
edgeTwips.left = clamped(edgeTwips.left, 0, inchInTwips);
|
|
|
|
edgeTwips.right = clamped(edgeTwips.right, 0, inchInTwips);
|
2007-11-21 05:09:58 +00:00
|
|
|
|
|
|
|
mPageData->mEdgePaperMargin =
|
2010-08-13 09:58:04 +00:00
|
|
|
aPresContext->CSSTwipsToAppUnits(edgeTwips + unwriteableTwips);
|
2002-01-18 22:45:06 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 14:59:39 +00:00
|
|
|
// *** Special Override ***
|
|
|
|
// If this is a sub-sdoc (meaning it doesn't take the whole page)
|
|
|
|
// and if this Document is in the upper left hand corner
|
|
|
|
// we need to suppress the top margin or it will reflow too small
|
2006-03-30 00:27:42 +00:00
|
|
|
|
|
|
|
nsSize pageSize = aPresContext->GetPageSize();
|
|
|
|
|
|
|
|
mPageData->mReflowSize = pageSize;
|
2008-04-22 01:18:26 +00:00
|
|
|
// If we're printing a selection, we need to reflow with
|
|
|
|
// unconstrained height, to make sure we'll get to the selection
|
|
|
|
// even if it's beyond the first page of content.
|
|
|
|
if (nsIPrintSettings::kRangeSelection == mPrintRangeType) {
|
|
|
|
mPageData->mReflowSize.height = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
2006-04-11 01:48:48 +00:00
|
|
|
mPageData->mReflowMargin = mMargin;
|
2001-11-03 14:59:39 +00:00
|
|
|
|
2011-06-10 10:07:26 +00:00
|
|
|
// We use the CSS "margin" property on the -moz-page pseudoelement
|
|
|
|
// to determine the space between each page in print preview.
|
|
|
|
// Keep a running y-offset for each page.
|
|
|
|
nscoord y = 0;
|
|
|
|
nscoord maxXMost = 0;
|
1998-11-04 23:21:50 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Tile the pages vertically
|
2013-12-31 13:50:31 +00:00
|
|
|
nsHTMLReflowMetrics kidSize(aReflowState);
|
2014-08-08 05:07:15 +00:00
|
|
|
for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
|
|
|
|
nsIFrame* kidFrame = e.get();
|
2008-02-09 02:54:55 +00:00
|
|
|
// Set the shared data into the page frame before reflow
|
|
|
|
nsPageFrame * pf = static_cast<nsPageFrame*>(kidFrame);
|
|
|
|
pf->SetSharedPageData(mPageData);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Reflow the page
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
2014-07-24 08:28:46 +00:00
|
|
|
LogicalSize(kidFrame->GetWritingMode(),
|
|
|
|
pageSize));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsReflowStatus status;
|
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
kidReflowState.SetComputedWidth(kidReflowState.AvailableWidth());
|
|
|
|
//kidReflowState.SetComputedHeight(kidReflowState.AvailableHeight());
|
|
|
|
PR_PL(("AV W: %d H: %d\n", kidReflowState.AvailableWidth(), kidReflowState.AvailableHeight()));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
nsMargin pageCSSMargin = kidReflowState.ComputedPhysicalMargin();
|
2011-06-10 10:07:26 +00:00
|
|
|
y += pageCSSMargin.top;
|
|
|
|
|
2014-10-08 01:37:50 +00:00
|
|
|
nscoord x = pageCSSMargin.left;
|
|
|
|
|
|
|
|
// Place and size the page.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, x, y, 0, status);
|
|
|
|
|
2014-10-08 01:37:50 +00:00
|
|
|
// If the page is narrower than our width, then center it horizontally:
|
|
|
|
x += ComputeCenteringMargin(aReflowState.ComputedWidth(),
|
|
|
|
kidSize.Width(), pageCSSMargin);
|
|
|
|
|
2014-01-17 01:34:44 +00:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, kidSize, nullptr, x, y, 0);
|
2013-12-27 17:59:52 +00:00
|
|
|
y += kidSize.Height();
|
2011-06-10 10:07:26 +00:00
|
|
|
y += pageCSSMargin.bottom;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2013-12-27 17:59:52 +00:00
|
|
|
maxXMost = std::max(maxXMost, x + kidSize.Width() + pageCSSMargin.right);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// Is the page complete?
|
|
|
|
nsIFrame* kidNextInFlow = kidFrame->GetNextInFlow();
|
|
|
|
|
2007-10-02 05:57:45 +00:00
|
|
|
if (NS_FRAME_IS_FULLY_COMPLETE(status)) {
|
2009-09-18 11:09:35 +00:00
|
|
|
NS_ASSERTION(!kidNextInFlow, "bad child flow list");
|
|
|
|
} else if (!kidNextInFlow) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// The page isn't complete and it doesn't have a next-in-flow, so
|
2009-09-18 11:09:35 +00:00
|
|
|
// create a continuing page.
|
2013-03-20 01:47:49 +00:00
|
|
|
nsIFrame* continuingPage = aPresContext->PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(aPresContext, kidFrame, this);
|
1998-11-04 23:21:50 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Add it to our child list
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.InsertFrame(nullptr, kidFrame, continuingPage);
|
1998-11-04 23:21:50 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
2001-09-26 14:01:26 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Get Total Page Count
|
2014-08-08 05:07:15 +00:00
|
|
|
// XXXdholbert technically we could calculate this in the loop above,
|
|
|
|
// instead of needing a separate walk.
|
|
|
|
int32_t pageTot = mFrames.GetLength();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// Set Page Number Info
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t pageNum = 1;
|
2014-08-08 05:07:15 +00:00
|
|
|
for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
|
2014-08-08 05:07:16 +00:00
|
|
|
MOZ_ASSERT(e.get()->GetType() == nsGkAtoms::pageFrame,
|
|
|
|
"only expecting nsPageFrame children. Other children will make "
|
|
|
|
"this static_cast bogus & probably violate other assumptions");
|
|
|
|
nsPageFrame* pf = static_cast<nsPageFrame*>(e.get());
|
|
|
|
pf->SetPageNumInfo(pageNum, pageTot);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
pageNum++;
|
|
|
|
}
|
2001-09-26 14:01:26 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Create current Date/Time String
|
2014-05-13 00:47:52 +00:00
|
|
|
if (!mDateFormatter) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
mDateFormatter = do_CreateInstance(NS_DATETIMEFORMAT_CONTRACTID);
|
2014-05-13 00:47:52 +00:00
|
|
|
}
|
|
|
|
if (!mDateFormatter) {
|
|
|
|
return;
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsAutoString formattedDateString;
|
|
|
|
time_t ltime;
|
|
|
|
time( <ime );
|
2012-07-30 14:20:58 +00:00
|
|
|
if (NS_SUCCEEDED(mDateFormatter->FormatTime(nullptr /* nsILocale* locale */,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
kDateFormatShort,
|
|
|
|
kTimeFormatNoSeconds,
|
|
|
|
ltime,
|
|
|
|
formattedDateString))) {
|
2013-07-24 11:48:54 +00:00
|
|
|
SetDateTimeStr(formattedDateString);
|
1998-11-04 23:21:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return our desired size
|
2011-06-10 10:07:26 +00:00
|
|
|
// Adjust the reflow size by PrintPreviewScale so the scrollbars end up the
|
2007-02-13 22:36:59 +00:00
|
|
|
// correct size
|
2011-06-10 10:07:26 +00:00
|
|
|
SetDesiredSize(aDesiredSize, aReflowState, maxXMost, y);
|
1998-11-04 23:21:50 +00:00
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2006-04-01 01:19:28 +00:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
|
|
|
|
2001-11-03 14:59:39 +00:00
|
|
|
// cache the size so we can set the desired size
|
|
|
|
// for the other reflows that happen
|
2011-06-10 10:07:26 +00:00
|
|
|
mSize.width = maxXMost;
|
2009-03-08 19:01:02 +00:00
|
|
|
mSize.height = y;
|
2001-11-03 14:59:39 +00:00
|
|
|
|
1998-11-04 23:21:50 +00:00
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("nsSimplePageSequeceFrame::Reflow", aStatus);
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-11-04 23:21:50 +00:00
|
|
|
}
|
|
|
|
|
1998-12-07 03:43:02 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2001-11-14 01:33:42 +00:00
|
|
|
nsSimplePageSequenceFrame::GetFrameName(nsAString& aResult) const
|
1998-11-04 23:21:50 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SimplePageSequence"), aResult);
|
1998-11-04 23:21:50 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-11-04 23:21:50 +00:00
|
|
|
|
2001-03-27 11:56:03 +00:00
|
|
|
//====================================================================
|
|
|
|
//== Asynch Printing
|
|
|
|
//====================================================================
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSimplePageSequenceFrame::GetCurrentPageNum(int32_t* aPageNum)
|
2001-03-27 11:56:03 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPageNum);
|
|
|
|
|
|
|
|
*aPageNum = mPageNum;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSimplePageSequenceFrame::GetNumPages(int32_t* aNumPages)
|
2001-03-27 11:56:03 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumPages);
|
|
|
|
|
|
|
|
*aNumPages = mTotalPages;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSimplePageSequenceFrame::IsDoingPrintRange(bool* aDoing)
|
2001-03-27 11:56:03 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDoing);
|
|
|
|
|
|
|
|
*aDoing = mDoingPageRange;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSimplePageSequenceFrame::GetPrintRange(int32_t* aFromPage, int32_t* aToPage)
|
2001-03-27 11:56:03 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFromPage);
|
|
|
|
NS_ENSURE_ARG_POINTER(aToPage);
|
|
|
|
|
|
|
|
*aFromPage = mFromPageNum;
|
|
|
|
*aToPage = mToPageNum;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-09-26 14:01:26 +00:00
|
|
|
// Helper Function
|
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName, const char* aDefPropVal, bool aPageNumOnly)
|
2001-09-26 14:01:26 +00:00
|
|
|
{
|
|
|
|
// Doing this here so we only have to go get these formats once
|
2005-01-18 23:46:59 +00:00
|
|
|
nsXPIDLString pageNumberFormat;
|
2001-09-26 14:01:26 +00:00
|
|
|
// Now go get the Localized Page Formating String
|
2004-12-17 20:40:48 +00:00
|
|
|
nsresult rv =
|
|
|
|
nsContentUtils::GetLocalizedString(nsContentUtils::ePRINTING_PROPERTIES,
|
|
|
|
aPropName, pageNumberFormat);
|
2002-01-07 13:31:18 +00:00
|
|
|
if (NS_FAILED(rv)) { // back stop formatting
|
2004-07-25 12:18:04 +00:00
|
|
|
pageNumberFormat.AssignASCII(aDefPropVal);
|
2001-09-26 14:01:26 +00:00
|
|
|
}
|
2002-01-07 13:31:18 +00:00
|
|
|
|
2013-07-24 11:48:54 +00:00
|
|
|
SetPageNumberFormat(pageNumberFormat, aPageNumOnly);
|
2001-09-26 14:01:26 +00:00
|
|
|
}
|
2001-03-27 11:56:03 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-07-24 11:48:37 +00:00
|
|
|
nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
|
2002-05-07 12:03:37 +00:00
|
|
|
nsIPrintSettings* aPrintSettings,
|
2013-07-24 11:48:37 +00:00
|
|
|
const nsAString& aDocTitle,
|
|
|
|
const nsAString& aDocURL)
|
2001-03-27 11:56:03 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPresContext);
|
2002-01-01 12:58:53 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aPrintSettings);
|
|
|
|
|
|
|
|
if (!mPageData->mPrintSettings) {
|
|
|
|
mPageData->mPrintSettings = aPrintSettings;
|
|
|
|
}
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2013-07-24 11:48:37 +00:00
|
|
|
if (!aDocTitle.IsEmpty()) {
|
|
|
|
mPageData->mDocTitle = aDocTitle;
|
|
|
|
}
|
|
|
|
if (!aDocURL.IsEmpty()) {
|
|
|
|
mPageData->mDocURL = aDocURL;
|
|
|
|
}
|
2002-05-07 12:03:37 +00:00
|
|
|
|
2002-01-01 12:58:53 +00:00
|
|
|
aPrintSettings->GetStartPageRange(&mFromPageNum);
|
|
|
|
aPrintSettings->GetEndPageRange(&mToPageNum);
|
2011-12-07 04:45:06 +00:00
|
|
|
aPrintSettings->GetPageRanges(mPageRanges);
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2002-01-01 12:58:53 +00:00
|
|
|
mDoingPageRange = nsIPrintSettings::kRangeSpecifiedPageRange == mPrintRangeType ||
|
|
|
|
nsIPrintSettings::kRangeSelection == mPrintRangeType;
|
2001-03-27 11:56:03 +00:00
|
|
|
|
|
|
|
// If printing a range of pages make sure at least the starting page
|
|
|
|
// number is valid
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t totalPages = mFrames.GetLength();
|
2001-03-27 11:56:03 +00:00
|
|
|
|
|
|
|
if (mDoingPageRange) {
|
|
|
|
if (mFromPageNum > totalPages) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Begin printing of the document
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Determine if we are rendering only the selection
|
2002-01-01 12:58:53 +00:00
|
|
|
aPresContext->SetIsRenderingOnlySelection(nsIPrintSettings::kRangeSelection == mPrintRangeType);
|
2001-03-27 11:56:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (mDoingPageRange) {
|
|
|
|
// XXX because of the hack for making the selection all print on one page
|
|
|
|
// we must make sure that the page is sized correctly before printing.
|
2007-11-21 05:09:58 +00:00
|
|
|
nscoord height = aPresContext->GetPageSize().height;
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t pageNum = 1;
|
2001-11-03 14:59:39 +00:00
|
|
|
nscoord y = 0;//mMargin.top;
|
2001-12-01 14:31:45 +00:00
|
|
|
|
2014-08-08 05:07:15 +00:00
|
|
|
for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
|
|
|
|
nsIFrame* page = e.get();
|
2007-02-25 22:26:47 +00:00
|
|
|
if (pageNum >= mFromPageNum && pageNum <= mToPageNum) {
|
2003-06-30 18:52:23 +00:00
|
|
|
nsRect rect = page->GetRect();
|
2001-03-27 11:56:03 +00:00
|
|
|
rect.y = y;
|
|
|
|
rect.height = height;
|
2003-06-30 18:52:23 +00:00
|
|
|
page->SetRect(rect);
|
2001-03-27 11:56:03 +00:00
|
|
|
y += rect.height + mMargin.top + mMargin.bottom;
|
|
|
|
}
|
|
|
|
pageNum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// adjust total number of pages
|
2002-02-12 13:33:39 +00:00
|
|
|
if (nsIPrintSettings::kRangeSelection != mPrintRangeType) {
|
2001-03-27 11:56:03 +00:00
|
|
|
totalPages = pageNum - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-24 11:48:55 +00:00
|
|
|
mPageNum = 1;
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2002-02-12 13:33:39 +00:00
|
|
|
if (mTotalPages == -1) {
|
|
|
|
mTotalPages = totalPages;
|
|
|
|
}
|
|
|
|
|
2001-03-27 11:56:03 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-08-31 00:24:35 +00:00
|
|
|
void
|
2013-01-04 05:16:14 +00:00
|
|
|
GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArray<nsRefPtr<HTMLCanvasElement> >* aArr)
|
2001-03-27 11:56:03 +00:00
|
|
|
{
|
2012-09-05 19:02:27 +00:00
|
|
|
if (!aFrame) {
|
|
|
|
return;
|
|
|
|
}
|
2012-08-31 00:24:35 +00:00
|
|
|
for (nsIFrame::ChildListIterator childLists(aFrame);
|
|
|
|
!childLists.IsDone(); childLists.Next()) {
|
|
|
|
|
|
|
|
nsFrameList children = childLists.CurrentList();
|
|
|
|
for (nsFrameList::Enumerator e(children); !e.AtEnd(); e.Next()) {
|
|
|
|
nsIFrame* child = e.get();
|
|
|
|
|
|
|
|
// Check if child is a nsHTMLCanvasFrame.
|
|
|
|
nsHTMLCanvasFrame* canvasFrame = do_QueryFrame(child);
|
|
|
|
|
|
|
|
// If there is a canvasFrame, try to get actual canvas element.
|
|
|
|
if (canvasFrame) {
|
2013-01-04 05:16:14 +00:00
|
|
|
HTMLCanvasElement* canvas =
|
|
|
|
HTMLCanvasElement::FromContentOrNull(canvasFrame->GetContent());
|
2013-09-11 22:35:51 +00:00
|
|
|
if (canvas && canvas->GetMozPrintCallback()) {
|
2012-08-31 00:24:35 +00:00
|
|
|
aArr->AppendElement(canvas);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2012-08-31 00:24:35 +00:00
|
|
|
if (!child->GetFirstPrincipalChild()) {
|
|
|
|
nsSubDocumentFrame* subdocumentFrame = do_QueryFrame(child);
|
|
|
|
if (subdocumentFrame) {
|
|
|
|
// Descend into the subdocument
|
|
|
|
nsIFrame* root = subdocumentFrame->GetSubdocumentRootFrame();
|
|
|
|
child = root;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// The current child is not a nsHTMLCanvasFrame OR it is but there is
|
2013-01-04 05:16:14 +00:00
|
|
|
// no HTMLCanvasElement on it. Check if children of `child` might
|
|
|
|
// contain a HTMLCanvasElement.
|
2012-08-31 00:24:35 +00:00
|
|
|
GetPrintCanvasElementsInFrame(child, aArr);
|
|
|
|
}
|
2001-03-27 11:56:03 +00:00
|
|
|
}
|
2012-08-31 00:24:35 +00:00
|
|
|
}
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2012-08-31 00:24:35 +00:00
|
|
|
void
|
|
|
|
nsSimplePageSequenceFrame::DetermineWhetherToPrintPage()
|
|
|
|
{
|
|
|
|
// See whether we should print this page
|
|
|
|
mPrintThisPage = true;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool printEvenPages, printOddPages;
|
2002-01-01 12:58:53 +00:00
|
|
|
mPageData->mPrintSettings->GetPrintOptions(nsIPrintSettings::kPrintEvenPages, &printEvenPages);
|
|
|
|
mPageData->mPrintSettings->GetPrintOptions(nsIPrintSettings::kPrintOddPages, &printOddPages);
|
2001-03-27 11:56:03 +00:00
|
|
|
|
|
|
|
// If printing a range of pages check whether the page number is in the
|
|
|
|
// range of pages to print
|
|
|
|
if (mDoingPageRange) {
|
|
|
|
if (mPageNum < mFromPageNum) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mPrintThisPage = false;
|
2001-03-27 11:56:03 +00:00
|
|
|
} else if (mPageNum > mToPageNum) {
|
|
|
|
mPageNum++;
|
2012-08-31 00:24:35 +00:00
|
|
|
mPrintThisPage = false;
|
|
|
|
return;
|
2011-12-07 04:45:06 +00:00
|
|
|
} else {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t length = mPageRanges.Length();
|
2011-12-07 04:45:06 +00:00
|
|
|
|
|
|
|
// Page ranges are pairs (start, end)
|
|
|
|
if (length && (length % 2 == 0)) {
|
|
|
|
mPrintThisPage = false;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i;
|
2011-12-07 04:45:06 +00:00
|
|
|
for (i = 0; i < length; i += 2) {
|
|
|
|
if (mPageRanges[i] <= mPageNum && mPageNum <= mPageRanges[i+1]) {
|
|
|
|
mPrintThisPage = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-03-27 11:56:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for printing of odd and even pages
|
|
|
|
if (mPageNum & 0x1) {
|
|
|
|
if (!printOddPages) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mPrintThisPage = false; // don't print odd numbered page
|
2001-03-27 11:56:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!printEvenPages) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mPrintThisPage = false; // don't print even numbered page
|
2001-03-27 11:56:03 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-30 00:27:42 +00:00
|
|
|
|
|
|
|
if (nsIPrintSettings::kRangeSelection == mPrintRangeType) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mPrintThisPage = true;
|
2006-03-30 00:27:42 +00:00
|
|
|
}
|
2012-08-31 00:24:35 +00:00
|
|
|
}
|
|
|
|
|
2013-07-24 11:48:55 +00:00
|
|
|
nsIFrame*
|
|
|
|
nsSimplePageSequenceFrame::GetCurrentPageFrame()
|
|
|
|
{
|
|
|
|
int32_t i = 1;
|
|
|
|
for (nsFrameList::Enumerator childFrames(mFrames); !childFrames.AtEnd();
|
|
|
|
childFrames.Next()) {
|
|
|
|
if (i == mPageNum) {
|
|
|
|
return childFrames.get();
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-08-31 00:24:35 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* aDone)
|
|
|
|
{
|
2013-07-24 11:48:55 +00:00
|
|
|
nsIFrame* currentPage = GetCurrentPageFrame();
|
|
|
|
if (!currentPage) {
|
2012-08-31 00:24:35 +00:00
|
|
|
*aDone = true;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
DetermineWhetherToPrintPage();
|
|
|
|
// Nothing to do if the current page doesn't get printed OR rendering to
|
|
|
|
// preview. For preview, the `CallPrintCallback` is called from within the
|
2013-01-04 05:16:14 +00:00
|
|
|
// HTMLCanvasElement::HandlePrintCallback.
|
2012-08-31 00:24:35 +00:00
|
|
|
if (!mPrintThisPage || !PresContext()->IsRootPaginatedDocument()) {
|
|
|
|
*aDone = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the canvasList is null, then generate it and start the render
|
|
|
|
// process for all the canvas.
|
|
|
|
if (!mCurrentCanvasListSetup) {
|
|
|
|
mCurrentCanvasListSetup = true;
|
2013-07-24 11:48:55 +00:00
|
|
|
GetPrintCanvasElementsInFrame(currentPage, &mCurrentCanvasList);
|
2012-08-31 00:24:35 +00:00
|
|
|
|
|
|
|
if (mCurrentCanvasList.Length() != 0) {
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Begin printing of the document
|
|
|
|
nsDeviceContext *dc = PresContext()->DeviceContext();
|
|
|
|
PR_PL(("\n"));
|
|
|
|
PR_PL(("***************** BeginPage *****************\n"));
|
|
|
|
rv = dc->BeginPage();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
mCalledBeginPage = true;
|
|
|
|
|
2014-10-31 20:08:49 +00:00
|
|
|
nsRefPtr<gfxContext> renderingContext = dc->CreateRenderingContext();
|
2012-08-31 00:24:35 +00:00
|
|
|
|
|
|
|
nsRefPtr<gfxASurface> renderingSurface =
|
2014-10-31 20:08:49 +00:00
|
|
|
renderingContext->CurrentSurface();
|
2012-08-31 00:24:35 +00:00
|
|
|
NS_ENSURE_TRUE(renderingSurface, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
2012-09-06 14:11:28 +00:00
|
|
|
for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) {
|
2013-01-04 05:16:14 +00:00
|
|
|
HTMLCanvasElement* canvas = mCurrentCanvasList[i];
|
2012-08-31 00:24:35 +00:00
|
|
|
nsIntSize size = canvas->GetSize();
|
|
|
|
|
|
|
|
nsRefPtr<gfxASurface> printSurface = renderingSurface->
|
|
|
|
CreateSimilarSurface(
|
2014-01-23 18:26:40 +00:00
|
|
|
gfxContentType::COLOR_ALPHA,
|
2012-08-31 00:24:35 +00:00
|
|
|
size
|
|
|
|
);
|
|
|
|
|
2013-01-14 22:45:53 +00:00
|
|
|
if (!printSurface) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-08-31 00:24:35 +00:00
|
|
|
nsICanvasRenderingContextInternal* ctx = canvas->GetContextAtIndex(0);
|
|
|
|
|
|
|
|
if (!ctx) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the context with the new printSurface.
|
2013-10-08 18:47:21 +00:00
|
|
|
ctx->InitializeWithSurface(nullptr, printSurface, size.width, size.height);
|
2012-08-31 00:24:35 +00:00
|
|
|
|
|
|
|
// Start the rendering process.
|
|
|
|
nsWeakFrame weakFrame = this;
|
|
|
|
canvas->DispatchPrintCallback(aCallback);
|
|
|
|
NS_ENSURE_STATE(weakFrame.IsAlive());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-11 21:33:25 +00:00
|
|
|
uint32_t doneCounter = 0;
|
2012-09-06 14:11:28 +00:00
|
|
|
for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) {
|
2013-01-04 05:16:14 +00:00
|
|
|
HTMLCanvasElement* canvas = mCurrentCanvasList[i];
|
2012-08-31 00:24:35 +00:00
|
|
|
|
|
|
|
if (canvas->IsPrintCallbackDone()) {
|
|
|
|
doneCounter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If all canvas have finished rendering, return true, otherwise false.
|
|
|
|
*aDone = doneCounter == mCurrentCanvasList.Length();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::ResetPrintCanvasList()
|
|
|
|
{
|
2012-09-06 14:11:28 +00:00
|
|
|
for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) {
|
2013-01-04 05:16:14 +00:00
|
|
|
HTMLCanvasElement* canvas = mCurrentCanvasList[i];
|
2012-08-31 00:24:35 +00:00
|
|
|
canvas->ResetPrintCallback();
|
|
|
|
}
|
|
|
|
|
|
|
|
mCurrentCanvasList.Clear();
|
|
|
|
mCurrentCanvasListSetup = false;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::PrintNextPage()
|
|
|
|
{
|
|
|
|
// Print each specified page
|
|
|
|
// pageNum keeps track of the current page and what pages are printing
|
|
|
|
//
|
|
|
|
// printedPageNum keeps track of the current page number to be printed
|
|
|
|
// Note: When print al the pages or a page range the printed page shows the
|
|
|
|
// actual page number, when printing selection it prints the page number starting
|
|
|
|
// with the first page of the selection. For example if the user has a
|
|
|
|
// selection that starts on page 2 and ends on page 3, the page numbers when
|
|
|
|
// print are 1 and then two (which is different than printing a page range, where
|
|
|
|
// the page numbers would have been 2 and then 3)
|
|
|
|
|
2013-07-24 11:48:55 +00:00
|
|
|
nsIFrame* currentPage = GetCurrentPageFrame();
|
|
|
|
if (!currentPage) {
|
2012-08-31 00:24:35 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
DetermineWhetherToPrintPage();
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2001-04-12 13:04:29 +00:00
|
|
|
if (mPrintThisPage) {
|
2012-08-31 00:24:35 +00:00
|
|
|
// Begin printing of the document
|
|
|
|
nsDeviceContext* dc = PresContext()->DeviceContext();
|
|
|
|
|
2001-11-03 14:59:39 +00:00
|
|
|
// XXX This is temporary fix for printing more than one page of a selection
|
|
|
|
// This does a poor man's "dump" pagination (see Bug 89353)
|
|
|
|
// It has laid out as one long page and now we are just moving or view up/down
|
|
|
|
// one page at a time and printing the contents of what is exposed by the rect.
|
|
|
|
// currently this does not work for IFrames
|
|
|
|
// I will soon improve this to work with IFrames
|
2011-09-29 06:19:26 +00:00
|
|
|
bool continuePrinting = true;
|
2007-11-21 05:09:58 +00:00
|
|
|
nscoord width, height;
|
2007-03-30 21:11:41 +00:00
|
|
|
width = PresContext()->GetPageSize().width;
|
|
|
|
height = PresContext()->GetPageSize().height;
|
2001-11-03 14:59:39 +00:00
|
|
|
height -= mMargin.top + mMargin.bottom;
|
|
|
|
width -= mMargin.left + mMargin.right;
|
|
|
|
nscoord selectionY = height;
|
2013-07-24 11:48:55 +00:00
|
|
|
nsIFrame* conFrame = currentPage->GetFirstPrincipalChild();
|
2007-11-21 05:09:58 +00:00
|
|
|
if (mSelectionHeight >= 0) {
|
2007-02-25 22:26:47 +00:00
|
|
|
conFrame->SetPosition(conFrame->GetPosition() + nsPoint(0, -mYSelOffset));
|
2008-04-28 22:55:04 +00:00
|
|
|
nsContainerFrame::PositionChildViews(conFrame);
|
2001-03-27 11:56:03 +00:00
|
|
|
}
|
|
|
|
|
2006-03-30 00:27:42 +00:00
|
|
|
// cast the frame to be a page frame
|
2013-07-24 11:48:55 +00:00
|
|
|
nsPageFrame * pf = static_cast<nsPageFrame*>(currentPage);
|
2006-03-30 00:27:42 +00:00
|
|
|
pf->SetPageNumInfo(mPageNum, mTotalPages);
|
|
|
|
pf->SetSharedPageData(mPageData);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t printedPageNum = 1;
|
2001-11-03 14:59:39 +00:00
|
|
|
while (continuePrinting) {
|
2007-03-30 21:11:41 +00:00
|
|
|
if (PresContext()->IsRootPaginatedDocument()) {
|
2012-08-31 00:24:35 +00:00
|
|
|
if (!mCalledBeginPage) {
|
|
|
|
PR_PL(("\n"));
|
|
|
|
PR_PL(("***************** BeginPage *****************\n"));
|
|
|
|
rv = dc->BeginPage();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
} else {
|
|
|
|
mCalledBeginPage = false;
|
|
|
|
}
|
2002-02-12 13:33:39 +00:00
|
|
|
}
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2009-09-07 00:35:14 +00:00
|
|
|
PR_PL(("SeqFr::PrintNextPage -> %p PageNo: %d", pf, mPageNum));
|
2001-04-12 13:04:29 +00:00
|
|
|
|
2014-10-31 20:08:49 +00:00
|
|
|
nsRenderingContext renderingContext(dc->CreateRenderingContext());
|
2008-04-08 00:32:48 +00:00
|
|
|
|
2013-07-24 11:48:55 +00:00
|
|
|
nsRect drawingRect(nsPoint(0, 0), currentPage->GetSize());
|
2007-02-25 23:23:09 +00:00
|
|
|
nsRegion drawingRegion(drawingRect);
|
2014-10-31 20:08:49 +00:00
|
|
|
nsLayoutUtils::PaintFrame(&renderingContext, currentPage,
|
2009-09-12 22:44:18 +00:00
|
|
|
drawingRegion, NS_RGBA(0,0,0,0),
|
|
|
|
nsLayoutUtils::PAINT_SYNC_DECODE_IMAGES);
|
2001-11-03 14:59:39 +00:00
|
|
|
|
2007-11-21 05:09:58 +00:00
|
|
|
if (mSelectionHeight >= 0 && selectionY < mSelectionHeight) {
|
2001-11-03 14:59:39 +00:00
|
|
|
selectionY += height;
|
2006-03-30 00:27:42 +00:00
|
|
|
printedPageNum++;
|
|
|
|
pf->SetPageNumInfo(printedPageNum, mTotalPages);
|
2007-02-25 22:26:47 +00:00
|
|
|
conFrame->SetPosition(conFrame->GetPosition() + nsPoint(0, -height));
|
2008-06-24 16:30:55 +00:00
|
|
|
nsContainerFrame::PositionChildViews(conFrame);
|
2002-02-12 13:33:39 +00:00
|
|
|
|
2006-03-30 00:27:42 +00:00
|
|
|
PR_PL(("***************** End Page (PrintNextPage) *****************\n"));
|
|
|
|
rv = dc->EndPage();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-11-03 14:59:39 +00:00
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
continuePrinting = false;
|
2001-04-12 13:04:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-03-30 00:27:42 +00:00
|
|
|
nsSimplePageSequenceFrame::DoPageEnd()
|
2001-04-12 13:04:29 +00:00
|
|
|
{
|
2006-03-30 00:27:42 +00:00
|
|
|
nsresult rv = NS_OK;
|
2007-03-30 21:11:41 +00:00
|
|
|
if (PresContext()->IsRootPaginatedDocument() && mPrintThisPage) {
|
2006-03-30 00:27:42 +00:00
|
|
|
PR_PL(("***************** End Page (DoPageEnd) *****************\n"));
|
2007-03-30 21:11:41 +00:00
|
|
|
rv = PresContext()->DeviceContext()->EndPage();
|
2006-03-30 00:27:42 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-03-27 11:56:03 +00:00
|
|
|
}
|
|
|
|
|
2012-08-31 00:24:35 +00:00
|
|
|
ResetPrintCanvasList();
|
|
|
|
|
2001-03-27 11:56:03 +00:00
|
|
|
mPageNum++;
|
2001-04-25 14:26:28 +00:00
|
|
|
|
|
|
|
return rv;
|
2001-04-12 13:04:29 +00:00
|
|
|
}
|
2001-03-27 11:56:03 +00:00
|
|
|
|
2014-10-08 01:37:50 +00:00
|
|
|
inline gfx::Matrix4x4
|
2012-09-19 23:26:35 +00:00
|
|
|
ComputePageSequenceTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
|
2007-02-13 22:36:59 +00:00
|
|
|
{
|
2012-09-19 23:26:35 +00:00
|
|
|
float scale = aFrame->PresContext()->GetPrintPreviewScale();
|
2014-10-08 03:43:00 +00:00
|
|
|
return gfx::Matrix4x4::Scaling(scale, scale, 1);
|
2007-02-13 22:36:59 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsSimplePageSequenceFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2013-02-14 11:08:08 +00:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2012-09-19 23:26:35 +00:00
|
|
|
nsDisplayList content;
|
2013-04-15 07:10:19 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// Clear clip state while we construct the children of the
|
|
|
|
// nsDisplayTransform, since they'll be in a different coordinate system.
|
|
|
|
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
|
|
|
|
clipState.Clear();
|
|
|
|
|
|
|
|
nsIFrame* child = GetFirstPrincipalChild();
|
2014-07-17 03:39:39 +00:00
|
|
|
nsRect dirty = aDirtyRect;
|
|
|
|
dirty.ScaleInverseRoundOut(PresContext()->GetPrintPreviewScale());
|
|
|
|
|
2013-04-15 07:10:19 +00:00
|
|
|
while (child) {
|
2014-07-17 03:39:39 +00:00
|
|
|
if (child->GetVisualOverflowRectRelativeToParent().Intersects(dirty)) {
|
|
|
|
child->BuildDisplayListForStackingContext(aBuilder,
|
|
|
|
dirty - child->GetPosition(), &content);
|
|
|
|
aBuilder->ResetMarkedFramesForDisplayList();
|
|
|
|
}
|
2013-04-15 07:10:19 +00:00
|
|
|
child = child->GetNextSibling();
|
|
|
|
}
|
2012-09-19 23:26:35 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:08:08 +00:00
|
|
|
content.AppendNewToTop(new (aBuilder)
|
2014-07-15 11:47:46 +00:00
|
|
|
nsDisplayTransform(aBuilder, this, &content, content.GetVisibleRect(),
|
|
|
|
::ComputePageSequenceTransform));
|
2007-02-13 22:36:59 +00:00
|
|
|
|
2012-09-19 23:26:35 +00:00
|
|
|
aLists.Content()->AppendToTop(&content);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsSimplePageSequenceFrame::GetType() const
|
2002-03-04 12:55:20 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::sequenceFrame;
|
2002-03-04 12:55:20 +00:00
|
|
|
}
|
2001-11-03 14:59:39 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void
|
2013-07-24 11:48:54 +00:00
|
|
|
nsSimplePageSequenceFrame::SetPageNumberFormat(const nsAString& aFormatStr, bool aForPageNumOnly)
|
2001-11-03 14:59:39 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(mPageData != nullptr, "mPageData string cannot be null!");
|
2001-11-03 14:59:39 +00:00
|
|
|
|
|
|
|
if (aForPageNumOnly) {
|
|
|
|
mPageData->mPageNumFormat = aFormatStr;
|
|
|
|
} else {
|
|
|
|
mPageData->mPageNumAndTotalsFormat = aFormatStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void
|
2013-07-24 11:48:54 +00:00
|
|
|
nsSimplePageSequenceFrame::SetDateTimeStr(const nsAString& aDateTimeStr)
|
2001-11-03 14:59:39 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(mPageData != nullptr, "mPageData string cannot be null!");
|
2001-11-03 14:59:39 +00:00
|
|
|
|
|
|
|
mPageData->mDateTimeStr = aDateTimeStr;
|
|
|
|
}
|
|
|
|
|
2002-09-19 21:45:07 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// For Shrink To Fit
|
|
|
|
//
|
|
|
|
// Return the percentage that the page needs to shrink to
|
|
|
|
//
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::GetSTFPercent(float& aSTFPercent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mPageData, NS_ERROR_UNEXPECTED);
|
2014-02-04 02:12:13 +00:00
|
|
|
aSTFPercent = mPageData->mShrinkToFitRatio;
|
2002-09-19 21:45:07 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|