Bug 1557104. Merge nsIPageSequenceFrame and nsSimplePageSequenceFrame. r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D33817
This commit is contained in:
Jonathan Watt
2019-05-22 13:01:33 +01:00
parent 21150fa29a
commit d17e754362
16 changed files with 113 additions and 231 deletions

View File

@@ -67,7 +67,7 @@
#include "nsWindowSizes.h"
#include "nsCOMPtr.h"
#include "nsReadableUtils.h"
#include "nsIPageSequenceFrame.h"
#include "nsPageSequenceFrame.h"
#include "nsIPermissionManager.h"
#include "nsIMozBrowserFrame.h"
#include "nsCaret.h"
@@ -2440,9 +2440,8 @@ nsIScrollableFrame* PresShell::GetRootScrollFrameAsScrollable() const {
return scrollableFrame;
}
nsIPageSequenceFrame* PresShell::GetPageSequenceFrame() const {
nsIFrame* frame = mFrameConstructor->GetPageSequenceFrame();
return do_QueryFrame(frame);
nsPageSequenceFrame* PresShell::GetPageSequenceFrame() const {
return mFrameConstructor->GetPageSequenceFrame();
}
nsCanvasFrame* PresShell::GetCanvasFrame() const {

View File

@@ -80,7 +80,7 @@ class nsIDocShell;
class nsIFrame;
class nsILayoutHistoryState;
class nsINode;
class nsIPageSequenceFrame;
class nsPageSequenceFrame;
class nsIReflowCallback;
class nsIScrollableFrame;
class nsITimer;
@@ -453,7 +453,7 @@ class PresShell final : public nsStubDocumentObserver,
* Returns the page sequence frame associated with the frame hierarchy.
* Returns nullptr if not a paginated view.
*/
nsIPageSequenceFrame* GetPageSequenceFrame() const;
nsPageSequenceFrame* GetPageSequenceFrame() const;
/**
* Returns the canvas frame associated with the frame hierarchy.

View File

@@ -99,7 +99,7 @@
#include "nsFirstLetterFrame.h"
#include "nsGfxScrollFrame.h"
#include "nsPageFrame.h"
#include "nsSimplePageSequenceFrame.h"
#include "nsPageSequenceFrame.h"
#include "nsTableWrapperFrame.h"
#include "nsIScrollableFrame.h"
#include "nsBackdropFrame.h"
@@ -2517,7 +2517,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
Print presentation, non-XUL
ViewportFrame
nsSimplePageSequenceFrame
nsPageSequenceFrame
nsPageFrame
nsPageContentFrame [fixed-cb]
nsCanvasFrame [abs-cb]
@@ -2528,7 +2528,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
ViewportFrame
nsHTMLScrollFrame
nsSimplePageSequenceFrame
nsPageSequenceFrame
nsPageFrame
nsPageContentFrame [fixed-cb]
nsCanvasFrame [abs-cb]
@@ -2544,7 +2544,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
the root element.
mDocElementContainingBlock is the parent of mRootElementFrame
(i.e. nsCanvasFrame or nsRootBoxFrame)
mPageSequenceFrame is the nsSimplePageSequenceFrame, or null if there isn't
mPageSequenceFrame is the nsPageSequenceFrame, or null if there isn't
one
*/
@@ -2584,8 +2584,8 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock(
mDocElementContainingBlock = rootFrame;
} else {
// Create a page sequence frame
rootFrame = NS_NewSimplePageSequenceFrame(mPresShell, viewportPseudoStyle);
mPageSequenceFrame = rootFrame;
rootFrame = mPageSequenceFrame =
NS_NewPageSequenceFrame(mPresShell, viewportPseudoStyle);
rootPseudo = PseudoStyleType::pageSequence;
rootFrame->AddStateBits(NS_FRAME_OWNS_ANON_BOXES);
}

View File

@@ -34,6 +34,7 @@ class nsContainerFrame;
class nsFirstLineFrame;
class nsFirstLetterFrame;
class nsCSSAnonBoxPseudoStaticAtom;
class nsPageSequenceFrame;
class nsPageContentFrame;
struct PendingBinding;
@@ -342,7 +343,7 @@ class nsCSSFrameConstructor final : public nsFrameManager {
// This returns the frame for the root element that does not
// have a psuedo-element style
nsIFrame* GetRootElementStyleFrame() { return mRootElementStyleFrame; }
nsIFrame* GetPageSequenceFrame() { return mPageSequenceFrame; }
nsPageSequenceFrame* GetPageSequenceFrame() { return mPageSequenceFrame; }
// Get the frame that is the parent of the root element.
nsContainerFrame* GetDocElementContainingBlock() {
@@ -2125,7 +2126,7 @@ class nsCSSFrameConstructor final : public nsFrameManager {
// This is the containing block that contains the root element ---
// the real "initial containing block" according to CSS 2.1.
nsContainerFrame* mDocElementContainingBlock;
nsIFrame* mPageSequenceFrame;
nsPageSequenceFrame* mPageSequenceFrame;
// FrameConstructionItem arena + list of freed items available for re-use.
mozilla::ArenaAllocator<4096, 8> mFCItemPool;

View File

@@ -49,7 +49,7 @@
#include "nsViewManager.h"
#include "nsView.h"
#include "nsIPageSequenceFrame.h"
#include "nsPageSequenceFrame.h"
#include "nsNetUtil.h"
#include "nsIContentViewerEdit.h"
#include "mozilla/css/Loader.h"
@@ -2796,7 +2796,7 @@ nsDocumentViewer::SetFullZoom(float aFullZoom) {
mPrintPreviewZoom = aFullZoom;
pc->SetPrintPreviewScale(aFullZoom * mOriginalPrintPreviewScale);
nsIPageSequenceFrame* pf = presShell->GetPageSequenceFrame();
nsPageSequenceFrame* pf = presShell->GetPageSequenceFrame();
if (pf) {
nsIFrame* f = do_QueryFrame(pf);
presShell->FrameNeedsReflow(f, IntrinsicDirty::Resize, NS_FRAME_IS_DIRTY);
@@ -3644,7 +3644,6 @@ nsDocumentViewer::PrintPreviewNavigate(int16_t aType, int32_t aPageNum) {
return NS_OK;
}
// Finds the SimplePageSequencer frame
// in PP mPrtPreview->mPrintObject->mSeqFrame is null
nsIFrame* seqFrame = nullptr;
int32_t pageCount = 0;

View File

@@ -95,7 +95,7 @@ FRAME_CLASSES = [
Frame("nsScrollbarButtonFrame", "Box", NOT_LEAF),
Frame("nsScrollbarFrame", "Scrollbar", NOT_LEAF),
Frame("nsSelectsAreaFrame", "Block", NOT_LEAF),
Frame("nsSimplePageSequenceFrame", "Sequence", NOT_LEAF),
Frame("nsPageSequenceFrame", "Sequence", NOT_LEAF),
Frame("nsSliderFrame", "Slider", NOT_LEAF),
Frame("nsSplitterFrame", "Box", NOT_LEAF),
Frame("nsStackFrame", "Box", NOT_LEAF),
@@ -168,7 +168,6 @@ FRAME_CLASSES = [
AbstractFrame("nsIMathMLFrame"),
AbstractFrame("nsIMenuFrame"),
AbstractFrame("nsIObjectFrame"),
AbstractFrame("nsIPageSequenceFrame"),
AbstractFrame("nsIPercentBSizeObserver"),
AbstractFrame("nsIPopupContainer"),
AbstractFrame("nsIScrollableFrame"),

View File

@@ -93,7 +93,7 @@ FRAME_ID(nsRubyTextFrame, RubyText, NotLeaf)
FRAME_ID(nsScrollbarButtonFrame, Box, NotLeaf)
FRAME_ID(nsScrollbarFrame, Scrollbar, NotLeaf)
FRAME_ID(nsSelectsAreaFrame, Block, NotLeaf)
FRAME_ID(nsSimplePageSequenceFrame, Sequence, NotLeaf)
FRAME_ID(nsPageSequenceFrame, Sequence, NotLeaf)
FRAME_ID(nsSliderFrame, Slider, NotLeaf)
FRAME_ID(nsSplitterFrame, Box, NotLeaf)
FRAME_ID(nsStackFrame, Box, NotLeaf)
@@ -174,7 +174,6 @@ ABSTRACT_FRAME_ID(nsIListControlFrame)
ABSTRACT_FRAME_ID(nsIMathMLFrame)
ABSTRACT_FRAME_ID(nsIMenuFrame)
ABSTRACT_FRAME_ID(nsIObjectFrame)
ABSTRACT_FRAME_ID(nsIPageSequenceFrame)
ABSTRACT_FRAME_ID(nsIPercentBSizeObserver)
ABSTRACT_FRAME_ID(nsIPopupContainer)
ABSTRACT_FRAME_ID(nsIScrollableFrame)

View File

@@ -106,10 +106,10 @@ EXPORTS += [
'nsIFrameInlines.h',
'nsILineIterator.h',
'nsIObjectFrame.h',
'nsIPageSequenceFrame.h',
'nsIScrollableFrame.h',
'nsIScrollPositionListener.h',
'nsIStatefulFrame.h',
'nsPageSequenceFrame.h',
'nsPluginFrame.h',
'nsQueryFrame.h',
'nsRubyBaseContainerFrame.h',
@@ -189,6 +189,7 @@ UNIFIED_SOURCES += [
'nsLineLayout.cpp',
'nsPageContentFrame.cpp',
'nsPageFrame.cpp',
'nsPageSequenceFrame.cpp',
'nsPlaceholderFrame.cpp',
'nsRubyBaseContainerFrame.cpp',
'nsRubyBaseFrame.cpp',
@@ -196,7 +197,6 @@ UNIFIED_SOURCES += [
'nsRubyFrame.cpp',
'nsRubyTextContainerFrame.cpp',
'nsRubyTextFrame.cpp',
'nsSimplePageSequenceFrame.cpp',
'nsSplittableFrame.cpp',
'nsSubDocumentFrame.cpp',
'nsTextFrame.cpp',

View File

@@ -112,9 +112,9 @@ nsContainerFrame* NS_NewColumnSetFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle,
nsFrameState aStateFlags);
class nsSimplePageSequenceFrame;
nsSimplePageSequenceFrame* NS_NewSimplePageSequenceFrame(
mozilla::PresShell* aPresShell, mozilla::ComputedStyle* aStyle);
class nsPageSequenceFrame;
nsPageSequenceFrame* NS_NewPageSequenceFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle);
class nsPageFrame;
nsPageFrame* NS_NewPageFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle);

View File

@@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef nsIPageSequenceFrame_h___
#define nsIPageSequenceFrame_h___
#include "nsQueryFrame.h"
#include "nsCoord.h"
class nsPresContext;
class nsIPrintSettings;
class nsITimerCallback;
/**
* Interface for accessing special capabilities of the page sequence frame.
*
* Today all that exists are member functions for printing.
*/
class nsIPageSequenceFrame : public nsQueryFrame {
public:
NS_DECL_QUERYFRAME_TARGET(nsIPageSequenceFrame)
/**
* Print the set of pages.
*
* @param aPrintOptions options for printing
* @param aStatusCallback interface that the client provides to receive
* progress notifications. Can be nullptr
* @return NS_OK if successful
* NS_ERROR_ABORT if the client cancels printing using the callback
* interface
* NS_ERROR_INVALID_ARG if printing a range of pages (not all pages)
* and the start page is greater than the total number of pages
* NS_ERROR_FAILURE if there is an error
*/
NS_IMETHOD StartPrint(nsPresContext* aPresContext,
nsIPrintSettings* aPrintOptions,
const nsAString& aDocTitle,
const nsAString& aDocURL) = 0;
NS_IMETHOD PrePrintNextPage(nsITimerCallback* aCallback, bool* aDone) = 0;
NS_IMETHOD PrintNextPage() = 0;
NS_IMETHOD ResetPrintCanvasList() = 0;
NS_IMETHOD GetCurrentPageNum(int32_t* aPageNum) = 0;
NS_IMETHOD GetNumPages(int32_t* aNumPages) = 0;
NS_IMETHOD IsDoingPrintRange(bool* aDoing) = 0;
NS_IMETHOD GetPrintRange(int32_t* aFromPage, int32_t* aToPage) = 0;
NS_IMETHOD DoPageEnd() = 0;
// For Shrink To Fit
NS_IMETHOD GetSTFPercent(float& aSTFPercent) = 0;
};
#endif /* nsIPageSequenceFrame_h___ */

View File

@@ -10,7 +10,7 @@
#include "nsCSSFrameConstructor.h"
#include "nsPresContext.h"
#include "nsGkAtoms.h"
#include "nsSimplePageSequenceFrame.h"
#include "nsPageSequenceFrame.h"
using namespace mozilla;

View File

@@ -16,8 +16,8 @@
#include "nsGkAtoms.h"
#include "nsPageContentFrame.h"
#include "nsDisplayList.h"
#include "nsSimplePageSequenceFrame.h" // for nsSharedPageData
#include "nsTextFormatter.h" // for page number localization formatting
#include "nsPageSequenceFrame.h" // for nsSharedPageData
#include "nsTextFormatter.h" // for page number localization formatting
#include "nsBidiUtils.h"
#include "nsIPrintSettings.h"

View File

@@ -4,7 +4,7 @@
* 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/. */
#include "nsSimplePageSequenceFrame.h"
#include "nsPageSequenceFrame.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/HTMLCanvasElement.h"
@@ -37,16 +37,16 @@ mozilla::LazyLogModule gLayoutPrintingLog("printing-layout");
#define PR_PL(_p1) MOZ_LOG(gLayoutPrintingLog, mozilla::LogLevel::Debug, _p1)
nsSimplePageSequenceFrame* NS_NewSimplePageSequenceFrame(
PresShell* aPresShell, ComputedStyle* aStyle) {
nsPageSequenceFrame* NS_NewPageSequenceFrame(PresShell* aPresShell,
ComputedStyle* aStyle) {
return new (aPresShell)
nsSimplePageSequenceFrame(aStyle, aPresShell->GetPresContext());
nsPageSequenceFrame(aStyle, aPresShell->GetPresContext());
}
NS_IMPL_FRAMEARENA_HELPERS(nsSimplePageSequenceFrame)
NS_IMPL_FRAMEARENA_HELPERS(nsPageSequenceFrame)
nsSimplePageSequenceFrame::nsSimplePageSequenceFrame(
ComputedStyle* aStyle, nsPresContext* aPresContext)
nsPageSequenceFrame::nsPageSequenceFrame(ComputedStyle* aStyle,
nsPresContext* aPresContext)
: nsContainerFrame(aStyle, aPresContext, kClassID),
mTotalPages(-1),
mCalledBeginPage(false),
@@ -67,21 +67,20 @@ nsSimplePageSequenceFrame::nsSimplePageSequenceFrame(
SetPageNumberFormat("pageofpages", "%1$d of %2$d", false);
}
nsSimplePageSequenceFrame::~nsSimplePageSequenceFrame() {
nsPageSequenceFrame::~nsPageSequenceFrame() {
delete mPageData;
ResetPrintCanvasList();
}
NS_QUERYFRAME_HEAD(nsSimplePageSequenceFrame)
NS_QUERYFRAME_ENTRY(nsIPageSequenceFrame)
NS_QUERYFRAME_HEAD(nsPageSequenceFrame)
NS_QUERYFRAME_ENTRY(nsPageSequenceFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
//----------------------------------------------------------------------
void nsSimplePageSequenceFrame::SetDesiredSize(ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,
nscoord aWidth,
nscoord aHeight) {
void nsPageSequenceFrame::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.
@@ -99,7 +98,7 @@ void nsSimplePageSequenceFrame::SetDesiredSize(ReflowOutput& aDesiredSize,
// Helper function to compute the offset needed to center a child
// page-frame's margin-box inside our content-box.
nscoord nsSimplePageSequenceFrame::ComputeCenteringMargin(
nscoord nsPageSequenceFrame::ComputeCenteringMargin(
nscoord aContainerContentBoxWidth, nscoord aChildPaddingBoxWidth,
const nsMargin& aChildPhysicalMargin) {
// We'll be centering our child's margin-box, so get the size of that:
@@ -136,17 +135,17 @@ nscoord nsSimplePageSequenceFrame::ComputeCenteringMargin(
* \*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,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) {
void nsPageSequenceFrame::Reflow(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) {
MarkInReflow();
MOZ_ASSERT(aPresContext->IsRootPaginatedDocument(),
"A Page Sequence is only for real pages");
DO_GLOBAL_REFLOW_COUNT("nsSimplePageSequenceFrame");
DO_GLOBAL_REFLOW_COUNT("nsPageSequenceFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
NS_FRAME_TRACE_REFLOW_IN("nsSimplePageSequenceFrame::Reflow");
NS_FRAME_TRACE_REFLOW_IN("nsPageSequenceFrame::Reflow");
// Don't do incremental reflow until we've taught tables how to do
// it right in paginated mode.
@@ -317,59 +316,31 @@ void nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
mSize.width = maxXMost;
mSize.height = y;
NS_FRAME_TRACE_REFLOW_OUT("nsSimplePageSequeceFrame::Reflow", aStatus);
NS_FRAME_TRACE_REFLOW_OUT("nsPageSequenceFrame::Reflow", aStatus);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
}
//----------------------------------------------------------------------
#ifdef DEBUG_FRAME_DUMP
nsresult nsSimplePageSequenceFrame::GetFrameName(nsAString& aResult) const {
return MakeFrameName(NS_LITERAL_STRING("SimplePageSequence"), aResult);
nsresult nsPageSequenceFrame::GetFrameName(nsAString& aResult) const {
return MakeFrameName(NS_LITERAL_STRING("PageSequence"), aResult);
}
#endif
//====================================================================
//== Asynch Printing
//====================================================================
NS_IMETHODIMP
nsSimplePageSequenceFrame::GetCurrentPageNum(int32_t* aPageNum) {
NS_ENSURE_ARG_POINTER(aPageNum);
*aPageNum = mPageNum;
return NS_OK;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::GetNumPages(int32_t* aNumPages) {
NS_ENSURE_ARG_POINTER(aNumPages);
*aNumPages = mTotalPages;
return NS_OK;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::IsDoingPrintRange(bool* aDoing) {
NS_ENSURE_ARG_POINTER(aDoing);
*aDoing = mDoingPageRange;
return NS_OK;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::GetPrintRange(int32_t* aFromPage, int32_t* aToPage) {
NS_ENSURE_ARG_POINTER(aFromPage);
NS_ENSURE_ARG_POINTER(aToPage);
void nsPageSequenceFrame::GetPrintRange(int32_t* aFromPage,
int32_t* aToPage) const {
*aFromPage = mFromPageNum;
*aToPage = mToPageNum;
return NS_OK;
}
// Helper Function
void nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName,
const char* aDefPropVal,
bool aPageNumOnly) {
void nsPageSequenceFrame::SetPageNumberFormat(const char* aPropName,
const char* aDefPropVal,
bool aPageNumOnly) {
// Doing this here so we only have to go get these formats once
nsAutoString pageNumberFormat;
// Now go get the Localized Page Formating String
@@ -382,11 +353,10 @@ void nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName,
SetPageNumberFormat(pageNumberFormat, aPageNumOnly);
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
nsIPrintSettings* aPrintSettings,
const nsAString& aDocTitle,
const nsAString& aDocURL) {
nsresult nsPageSequenceFrame::StartPrint(nsPresContext* aPresContext,
nsIPrintSettings* aPrintSettings,
const nsAString& aDocTitle,
const nsAString& aDocURL) {
NS_ENSURE_ARG_POINTER(aPresContext);
NS_ENSURE_ARG_POINTER(aPrintSettings);
@@ -466,7 +436,7 @@ static void GetPrintCanvasElementsInFrame(
}
}
void nsSimplePageSequenceFrame::DetermineWhetherToPrintPage() {
void nsPageSequenceFrame::DetermineWhetherToPrintPage() {
// See whether we should print this page
mPrintThisPage = true;
bool printEvenPages, printOddPages;
@@ -514,7 +484,7 @@ void nsSimplePageSequenceFrame::DetermineWhetherToPrintPage() {
}
}
nsIFrame* nsSimplePageSequenceFrame::GetCurrentPageFrame() {
nsIFrame* nsPageSequenceFrame::GetCurrentPageFrame() {
int32_t i = 1;
for (nsFrameList::Enumerator childFrames(mFrames); !childFrames.AtEnd();
childFrames.Next()) {
@@ -526,9 +496,8 @@ nsIFrame* nsSimplePageSequenceFrame::GetCurrentPageFrame() {
return nullptr;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback,
bool* aDone) {
nsresult nsPageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback,
bool* aDone) {
nsIFrame* currentPage = GetCurrentPageFrame();
if (!currentPage) {
*aDone = true;
@@ -609,8 +578,7 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback,
return NS_OK;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::ResetPrintCanvasList() {
void nsPageSequenceFrame::ResetPrintCanvasList() {
for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0; i--) {
HTMLCanvasElement* canvas = mCurrentCanvasList[i];
canvas->ResetPrintCallback();
@@ -618,11 +586,9 @@ nsSimplePageSequenceFrame::ResetPrintCanvasList() {
mCurrentCanvasList.Clear();
mCurrentCanvasListSetup = false;
return NS_OK;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::PrintNextPage() {
nsresult nsPageSequenceFrame::PrintNextPage() {
// 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
@@ -671,8 +637,7 @@ nsSimplePageSequenceFrame::PrintNextPage() {
return rv;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::DoPageEnd() {
nsresult nsPageSequenceFrame::DoPageEnd() {
nsresult rv = NS_OK;
if (PresContext()->IsRootPaginatedDocument() && mPrintThisPage) {
PR_PL(("***************** End Page (DoPageEnd) *****************\n"));
@@ -694,8 +659,8 @@ inline gfx::Matrix4x4 ComputePageSequenceTransform(nsIFrame* aFrame,
return gfx::Matrix4x4::Scaling(scale, scale, 1);
}
void nsSimplePageSequenceFrame::BuildDisplayList(
nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) {
void nsPageSequenceFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
aBuilder->SetInPageSequence(true);
aBuilder->SetDisablePartialUpdates(true);
DisplayBorderBackgroundOutline(aBuilder, aLists);
@@ -733,8 +698,8 @@ void nsSimplePageSequenceFrame::BuildDisplayList(
}
//------------------------------------------------------------------------------
void nsSimplePageSequenceFrame::SetPageNumberFormat(const nsAString& aFormatStr,
bool aForPageNumOnly) {
void nsPageSequenceFrame::SetPageNumberFormat(const nsAString& aFormatStr,
bool aForPageNumOnly) {
NS_ASSERTION(mPageData != nullptr, "mPageData string cannot be null!");
if (aForPageNumOnly) {
@@ -745,25 +710,13 @@ void nsSimplePageSequenceFrame::SetPageNumberFormat(const nsAString& aFormatStr,
}
//------------------------------------------------------------------------------
void nsSimplePageSequenceFrame::SetDateTimeStr(const nsAString& aDateTimeStr) {
void nsPageSequenceFrame::SetDateTimeStr(const nsAString& aDateTimeStr) {
NS_ASSERTION(mPageData != nullptr, "mPageData string cannot be null!");
mPageData->mDateTimeStr = aDateTimeStr;
}
//------------------------------------------------------------------------------
// 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);
aSTFPercent = mPageData->mShrinkToFitRatio;
return NS_OK;
}
void nsSimplePageSequenceFrame::AppendDirectlyOwnedAnonBoxes(
void nsPageSequenceFrame::AppendDirectlyOwnedAnonBoxes(
nsTArray<OwnedAnonBox>& aResult) {
if (mFrames.NotEmpty()) {
aResult.AppendElement(mFrames.FirstChild());

View File

@@ -3,11 +3,11 @@
/* 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/. */
#ifndef nsSimplePageSequenceFrame_h___
#define nsSimplePageSequenceFrame_h___
#ifndef nsPageSequenceFrame_h___
#define nsPageSequenceFrame_h___
#include "mozilla/Attributes.h"
#include "nsIPageSequenceFrame.h"
#include "nsPageSequenceFrame.h"
#include "nsContainerFrame.h"
#include "nsIPrintSettings.h"
@@ -25,11 +25,11 @@ class HTMLCanvasElement;
//-----------------------------------------------
// This class maintains all the data that
// is used by all the page frame
// It lives while the nsSimplePageSequenceFrame lives
// It lives while the nsPageSequenceFrame lives
class nsSharedPageData {
public:
// This object a shared by all the nsPageFrames
// parented to a SimplePageSequenceFrame
// parented to a nsPageSequenceFrame
nsSharedPageData() : mShrinkToFitRatio(1.0f) {}
nsString mDateTimeStr;
@@ -55,14 +55,13 @@ class nsSharedPageData {
};
// Simple page sequence frame class. Used when we're in paginated mode
class nsSimplePageSequenceFrame final : public nsContainerFrame,
public nsIPageSequenceFrame {
class nsPageSequenceFrame final : public nsContainerFrame {
public:
friend nsSimplePageSequenceFrame* NS_NewSimplePageSequenceFrame(
friend nsPageSequenceFrame* NS_NewPageSequenceFrame(
mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS(nsSimplePageSequenceFrame)
NS_DECL_FRAMEARENA_HELPERS(nsPageSequenceFrame)
// nsIFrame
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
@@ -73,22 +72,20 @@ class nsSimplePageSequenceFrame final : public nsContainerFrame,
const nsDisplayListSet& aLists) override;
// For Shrink To Fit
NS_IMETHOD GetSTFPercent(float& aSTFPercent) override;
float GetSTFPercent() const { return mPageData->mShrinkToFitRatio; }
// Async Printing
NS_IMETHOD StartPrint(nsPresContext* aPresContext,
nsIPrintSettings* aPrintSettings,
const nsAString& aDocTitle,
const nsAString& aDocURL) override;
NS_IMETHOD PrePrintNextPage(nsITimerCallback* aCallback,
bool* aDone) override;
NS_IMETHOD PrintNextPage() override;
NS_IMETHOD ResetPrintCanvasList() override;
NS_IMETHOD GetCurrentPageNum(int32_t* aPageNum) override;
NS_IMETHOD GetNumPages(int32_t* aNumPages) override;
NS_IMETHOD IsDoingPrintRange(bool* aDoing) override;
NS_IMETHOD GetPrintRange(int32_t* aFromPage, int32_t* aToPage) override;
NS_IMETHOD DoPageEnd() override;
nsresult StartPrint(nsPresContext* aPresContext,
nsIPrintSettings* aPrintSettings,
const nsAString& aDocTitle, const nsAString& aDocURL);
nsresult PrePrintNextPage(nsITimerCallback* aCallback, bool* aDone);
nsresult PrintNextPage();
void ResetPrintCanvasList();
int32_t GetCurrentPageNum() const { return mPageNum; }
int32_t GetNumPages() const { return mTotalPages; }
bool IsDoingPrintRange() const { return mDoingPageRange; }
void GetPrintRange(int32_t* aFromPage, int32_t* aToPage) const;
nsresult DoPageEnd();
// We must allow Print Preview UI to have a background, no matter what the
// user's settings
@@ -106,8 +103,8 @@ class nsSimplePageSequenceFrame final : public nsContainerFrame,
#endif
protected:
nsSimplePageSequenceFrame(ComputedStyle*, nsPresContext*);
virtual ~nsSimplePageSequenceFrame();
nsPageSequenceFrame(ComputedStyle*, nsPresContext*);
virtual ~nsPageSequenceFrame();
void SetPageNumberFormat(const char* aPropName, const char* aDefPropVal,
bool aPageNumOnly);
@@ -154,4 +151,4 @@ class nsSimplePageSequenceFrame final : public nsContainerFrame,
bool mCurrentCanvasListSetup;
};
#endif /* nsSimplePageSequenceFrame_h___ */
#endif /* nsPageSequenceFrame_h___ */

View File

@@ -92,7 +92,7 @@ static const char kPrintingPromptService[] =
#include "nsDeviceContextSpecProxy.h"
#include "nsViewManager.h"
#include "nsIPageSequenceFrame.h"
#include "nsPageSequenceFrame.h"
#include "nsIURL.h"
#include "nsIContentViewerEdit.h"
#include "nsIInterfaceRequestor.h"
@@ -325,9 +325,7 @@ static nsresult GetSeqFrameAndCountPagesInternal(
return NS_ERROR_FAILURE;
}
// Finds the SimplePageSequencer frame
nsIPageSequenceFrame* seqFrame = aPO->mPresShell->GetPageSequenceFrame();
aSeqFrame = do_QueryFrame(seqFrame);
aSeqFrame = aPO->mPresShell->GetPageSequenceFrame();
if (!aSeqFrame) {
return NS_ERROR_FAILURE;
}
@@ -1724,7 +1722,7 @@ nsresult nsPrintJob::SetupToPrintContent() {
if (mIsCreatingPrintPreview) {
// Copy docTitleStr and docURLStr to the pageSequenceFrame, to be displayed
// in the header
nsIPageSequenceFrame* seqFrame =
nsPageSequenceFrame* seqFrame =
printData->mPrintObject->mPresShell->GetPageSequenceFrame();
if (seqFrame) {
seqFrame->StartPrint(printData->mPrintObject->mPresContext,
@@ -1964,10 +1962,9 @@ nsresult nsPrintJob::UpdateSelectionAndShrinkPrintObject(
// this is the frame where the right-hand side of the frame extends
// the furthest
if (mPrt->mShrinkToFit && aDocumentIsTopLevel) {
nsIPageSequenceFrame* pageSequence =
aPO->mPresShell->GetPageSequenceFrame();
NS_ENSURE_STATE(pageSequence);
pageSequence->GetSTFPercent(aPO->mShrinkRatio);
nsPageSequenceFrame* pageSeqFrame = aPO->mPresShell->GetPageSequenceFrame();
NS_ENSURE_STATE(pageSeqFrame);
aPO->mShrinkRatio = pageSeqFrame->GetSTFPercent();
// Limit the shrink-to-fit scaling for some text-ish type of documents.
nsAutoString contentType;
aPO->mPresShell->GetDocument()->GetContentType(contentType);
@@ -2235,9 +2232,7 @@ void nsPrintJob::CalcNumPrintablePages(int32_t& aNumPages) {
// IsPrintable() returns false, ReflowPrintObject bails before setting
// mPresContext)
if (po->mPresContext && po->mPresContext->IsRootPaginatedDocument()) {
nsIPageSequenceFrame* pageSequence =
po->mPresShell->GetPageSequenceFrame();
nsIFrame* seqFrame = do_QueryFrame(pageSequence);
nsPageSequenceFrame* seqFrame = po->mPresShell->GetPageSequenceFrame();
if (seqFrame) {
aNumPages += seqFrame->PrincipalChildList().GetLength();
}
@@ -2414,8 +2409,8 @@ nsresult nsPrintJob::DoPrint(const UniquePtr<nsPrintObject>& aPO) {
{
// Ask the page sequence frame to print all the pages
nsIPageSequenceFrame* pageSequence = poPresShell->GetPageSequenceFrame();
NS_ASSERTION(nullptr != pageSequence, "no page sequence frame");
nsPageSequenceFrame* seqFrame = poPresShell->GetPageSequenceFrame();
MOZ_ASSERT(seqFrame, "no page sequence frame");
// We are done preparing for printing, so we can turn this off
printData->mPreparingForPrint = false;
@@ -2441,15 +2436,14 @@ nsresult nsPrintJob::DoPrint(const UniquePtr<nsPrintObject>& aPO) {
nsAutoString docURLStr;
GetDisplayTitleAndURL(aPO, docTitleStr, docURLStr, eDocTitleDefBlank);
nsIFrame* seqFrame = do_QueryFrame(pageSequence);
if (!seqFrame) {
SetIsPrinting(false);
return NS_ERROR_FAILURE;
}
mPageSeqFrame = seqFrame;
pageSequence->StartPrint(poPresContext, printData->mPrintSettings,
docTitleStr, docURLStr);
seqFrame->StartPrint(poPresContext, printData->mPrintSettings, docTitleStr,
docURLStr);
// Schedule Page to Print
PR_PL(("Scheduling Print of PO: %p (%s) \n", aPO.get(),
@@ -2523,7 +2517,7 @@ bool nsPrintJob::PrePrintPage() {
// Ask mPageSeqFrame if the page is ready to be printed.
// If the page doesn't get printed at all, the |done| will be |true|.
bool done = false;
nsIPageSequenceFrame* pageSeqFrame = do_QueryFrame(mPageSeqFrame.GetFrame());
nsPageSequenceFrame* pageSeqFrame = do_QueryFrame(mPageSeqFrame.GetFrame());
nsresult rv = pageSeqFrame->PrePrintNextPage(mPagePrintTimer, &done);
if (NS_FAILED(rv)) {
// ??? ::PrintPage doesn't set |printData->mIsAborted = true| if
@@ -2568,13 +2562,12 @@ bool nsPrintJob::PrintPage(nsPrintObject* aPO, bool& aInRange) {
}
int32_t pageNum, numPages, endPage;
nsIPageSequenceFrame* pageSeqFrame = do_QueryFrame(mPageSeqFrame.GetFrame());
pageSeqFrame->GetCurrentPageNum(&pageNum);
pageSeqFrame->GetNumPages(&numPages);
nsPageSequenceFrame* pageSeqFrame = do_QueryFrame(mPageSeqFrame.GetFrame());
pageNum = pageSeqFrame->GetCurrentPageNum();
numPages = pageSeqFrame->GetNumPages();
bool donePrinting;
bool isDoingPrintRange;
pageSeqFrame->IsDoingPrintRange(&isDoingPrintRange);
bool isDoingPrintRange = pageSeqFrame->IsDoingPrintRange();
if (isDoingPrintRange) {
int32_t fromPage;
int32_t toPage;
@@ -2749,8 +2742,7 @@ bool nsPrintJob::DonePrintingPages(nsPrintObject* aPO, nsresult aResult) {
// that might call |Notify| on the pagePrintTimer after things are cleaned up
// and printing was marked as being done.
if (mPageSeqFrame.IsAlive()) {
nsIPageSequenceFrame* pageSeqFrame =
do_QueryFrame(mPageSeqFrame.GetFrame());
nsPageSequenceFrame* pageSeqFrame = do_QueryFrame(mPageSeqFrame.GetFrame());
pageSeqFrame->ResetPrintCanvasList();
}
@@ -3377,7 +3369,7 @@ static void DumpPrintObjectsList(const nsTArray<nsPrintObject*>& aDocList) {
if (po->mPresShell) {
rootFrame = po->mPresShell->GetRootFrame();
while (rootFrame != nullptr) {
nsIPageSequenceFrame* sqf = do_QueryFrame(rootFrame);
nsPageSequenceFrame* sqf = do_QueryFrame(rootFrame);
if (sqf) {
break;
}

View File

@@ -29,7 +29,7 @@ class nsIDocShell;
class nsIDocumentViewerPrint;
class nsPrintObject;
class nsIDocShell;
class nsIPageSequenceFrame;
class nsPageSequenceFrame;
namespace mozilla {
class PresShell;