--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -320,17 +320,17 @@ nsPrintEngine::InstallPrintPreviewListen
mPrt->mPPEventListeners = new nsPrintPreviewListener(target);
mPrt->mPPEventListeners->AddListeners();
}
}
}
//----------------------------------------------------------------------
nsresult
-nsPrintEngine::GetSeqFrameAndCountPagesInternal(nsPrintObject* aPO,
+nsPrintEngine::GetSeqFrameAndCountPagesInternal(const UniquePtr<nsPrintObject>& aPO,
nsIFrame*& aSeqFrame,
int32_t& aCount)
{
NS_ENSURE_ARG_POINTER(aPO);
// This is sometimes incorrectly called before the pres shell has been created
// (bug 1141756). MOZ_DIAGNOSTIC_ASSERT so we'll still see the crash in
// Nightly/Aurora in case the other patch fixes this.
@@ -352,17 +352,17 @@ nsPrintEngine::GetSeqFrameAndCountPagesI
return NS_OK;
}
//-----------------------------------------------------------------
nsresult nsPrintEngine::GetSeqFrameAndCountPages(nsIFrame*& aSeqFrame, int32_t& aCount)
{
NS_ASSERTION(mPrtPreview, "mPrtPreview can't be null!");
- return GetSeqFrameAndCountPagesInternal(mPrtPreview->mPrintObject.get(), aSeqFrame, aCount);
+ return GetSeqFrameAndCountPagesInternal(mPrtPreview->mPrintObject, aSeqFrame, aCount);
}
//---------------------------------------------------------------------------------
//-- Done: Methods needed by the DocViewer
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
//-- Section: nsIWebBrowserPrint
@@ -520,31 +520,31 @@ nsPrintEngine::DoCommonPrint(bool
NS_ENSURE_TRUE(mPrt->mPrintDocList.AppendElement(mPrt->mPrintObject.get()),
NS_ERROR_OUT_OF_MEMORY);
mPrt->mIsParentAFrameSet = IsParentAFrameSet(webContainer);
mPrt->mPrintObject->mFrameType = mPrt->mIsParentAFrameSet ? eFrameSet : eDoc;
// Build the "tree" of PrintObjects
BuildDocTree(mPrt->mPrintObject->mDocShell, &mPrt->mPrintDocList,
- mPrt->mPrintObject.get());
+ mPrt->mPrintObject);
}
if (!aIsPrintPreview) {
SetIsPrinting(true);
}
// XXX This isn't really correct...
if (!mPrt->mPrintObject->mDocument ||
!mPrt->mPrintObject->mDocument->GetRootElement())
return NS_ERROR_GFX_PRINTER_STARTDOC;
// Create the linkage from the sub-docs back to the content element
// in the parent document
- MapContentToWebShells(mPrt->mPrintObject.get(), mPrt->mPrintObject.get());
+ MapContentToWebShells(mPrt->mPrintObject, mPrt->mPrintObject);
mPrt->mIsIFrameSelected = IsThereAnIFrameSelected(webContainer, mPrt->mCurrentFocusWin, mPrt->mIsParentAFrameSet);
// Setup print options for UI
if (mPrt->mIsParentAFrameSet) {
if (mPrt->mCurrentFocusWin) {
mPrt->mPrintSettings->SetHowToEnableFrameUI(nsIPrintSettings::kFrameEnableAll);
} else {
@@ -716,17 +716,17 @@ nsPrintEngine::DoCommonPrint(bool
}
}
} else {
mPrt->mPrintSettings->GetPrintFrameType(&mPrt->mPrintFrameType);
}
}
if (mPrt->mPrintFrameType == nsIPrintSettings::kEachFrameSep) {
- CheckForChildFrameSets(mPrt->mPrintObject.get());
+ CheckForChildFrameSets(mPrt->mPrintObject);
}
if (NS_FAILED(EnablePOsForPrinting())) {
return NS_ERROR_FAILURE;
}
// Attach progressListener to catch network requests.
nsCOMPtr<nsIWebProgress> webProgress = do_QueryInterface(mPrt->mPrintObject->mDocShell);
@@ -873,17 +873,17 @@ nsPrintEngine::GetPrintPreviewNumPages(i
// When calling this function, the FinishPrintPreview() function might not
// been called as there are still some
if (mPrtPreview) {
prt = mPrtPreview.get();
} else {
prt = mPrt.get();
}
if ((!prt) ||
- NS_FAILED(GetSeqFrameAndCountPagesInternal(prt->mPrintObject.get(), seqFrame, *aPrintPreviewNumPages))) {
+ NS_FAILED(GetSeqFrameAndCountPagesInternal(prt->mPrintObject, seqFrame, *aPrintPreviewNumPages))) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
//----------------------------------------------------------------------------------
// Enumerate all the documents for their titles
NS_IMETHODIMP
@@ -1073,17 +1073,17 @@ nsPrintEngine::ShowPrintProgress(bool aI
getter_AddRefs(mPrt->mPrintProgressParams),
&aDoNotify);
if (NS_SUCCEEDED(rv)) {
if (printProgressListener) {
mPrt->mPrintProgressListeners.AppendObject(printProgressListener);
}
if (mPrt->mPrintProgressParams) {
- SetDocAndURLIntoProgress(mPrt->mPrintObject.get(), mPrt->mPrintProgressParams);
+ SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams);
}
}
}
}
}
//---------------------------------------------------------------------
bool
@@ -1154,17 +1154,17 @@ nsPrintEngine::IsParentAFrameSet(nsIDocS
//---------------------------------------------------------------------
// Recursively build a list of sub documents to be printed
// that mirrors the document tree
void
nsPrintEngine::BuildDocTree(nsIDocShell * aParentNode,
nsTArray<nsPrintObject*> * aDocList,
- nsPrintObject * aPO)
+ const UniquePtr<nsPrintObject>& aPO)
{
NS_ASSERTION(aParentNode, "Pointer is null!");
NS_ASSERTION(aDocList, "Pointer is null!");
NS_ASSERTION(aPO, "Pointer is null!");
int32_t childWebshellCount;
aParentNode->GetChildCount(&childWebshellCount);
if (childWebshellCount > 0) {
@@ -1175,23 +1175,23 @@ nsPrintEngine::BuildDocTree(nsIDocShell
nsCOMPtr<nsIContentViewer> viewer;
childAsShell->GetContentViewer(getter_AddRefs(viewer));
if (viewer) {
nsCOMPtr<nsIContentViewerFile> viewerFile(do_QueryInterface(viewer));
if (viewerFile) {
nsCOMPtr<nsIDOMDocument> doc = do_GetInterface(childAsShell);
auto po = MakeUnique<nsPrintObject>();
- po->mParent = aPO;
+ po->mParent = aPO.get();
nsresult rv = po->Init(childAsShell, doc, aPO->mPrintPreview);
if (NS_FAILED(rv))
NS_NOTREACHED("Init failed?");
aPO->mKids.AppendElement(Move(po));
aDocList->AppendElement(aPO->mKids.LastElement().get());
- BuildDocTree(childAsShell, aDocList, aPO->mKids.LastElement().get());
+ BuildDocTree(childAsShell, aDocList, aPO->mKids.LastElement());
}
}
}
}
}
//---------------------------------------------------------------------
void
@@ -1232,18 +1232,18 @@ nsPrintEngine::GetDocumentTitleAndURL(ns
//---------------------------------------------------------------------
// The walks the PO tree and for each document it walks the content
// tree looking for any content that are sub-shells
//
// It then sets the mContent pointer in the "found" PO object back to the
// the document that contained it.
void
-nsPrintEngine::MapContentToWebShells(nsPrintObject* aRootPO,
- nsPrintObject* aPO)
+nsPrintEngine::MapContentToWebShells(const UniquePtr<nsPrintObject>& aRootPO,
+ const UniquePtr<nsPrintObject>& aPO)
{
NS_ASSERTION(aRootPO, "Pointer is null!");
NS_ASSERTION(aPO, "Pointer is null!");
// Recursively walk the content from the root item
// XXX Would be faster to enumerate the subdocuments, although right now
// nsIDocument doesn't expose quite what would be needed.
nsCOMPtr<nsIContentViewer> viewer;
@@ -1259,17 +1259,17 @@ nsPrintEngine::MapContentToWebShells(nsP
if (rootElement) {
MapContentForPO(aPO, rootElement);
} else {
NS_WARNING("Null root content on (sub)document.");
}
// Continue recursively walking the chilren of this PO
for (const UniquePtr<nsPrintObject>& kid : aPO->mKids) {
- MapContentToWebShells(aRootPO, kid.get());
+ MapContentToWebShells(aRootPO, kid);
}
}
//-------------------------------------------------------
// A Frame's sub-doc may contain content or a FrameSet
// When it contains a FrameSet the mFrameType for the PrintObject
// is always set to an eFrame. Which is fine when printing "AsIs"
@@ -1279,26 +1279,26 @@ nsPrintEngine::MapContentToWebShells(nsP
//
// This method walks the PO tree and checks to see if the PrintObject is
// an eFrame and has children that are eFrames (meaning it's a Frame containing a FrameSet)
// If so, then the mFrameType need to be changed to eFrameSet
//
// Also note: We only want to call this we are printing "Each Frame Separately"
// when printing "As Is" leave it as an eFrame
void
-nsPrintEngine::CheckForChildFrameSets(nsPrintObject* aPO)
+nsPrintEngine::CheckForChildFrameSets(const UniquePtr<nsPrintObject>& aPO)
{
NS_ASSERTION(aPO, "Pointer is null!");
// Continue recursively walking the chilren of this PO
bool hasChildFrames = false;
for (const UniquePtr<nsPrintObject>& po : aPO->mKids) {
if (po->mFrameType == eFrame) {
hasChildFrames = true;
- CheckForChildFrameSets(po.get());
+ CheckForChildFrameSets(po);
}
}
if (hasChildFrames && aPO->mFrameType == eFrame) {
aPO->mFrameType = eFrameSet;
}
}
@@ -1313,17 +1313,17 @@ nsPrintEngine::CheckForChildFrameSets(ns
// This is used later to (after reflow) to find the absolute location
// of the sub-doc on its parent's page frame so it can be
// printed in the correct location.
//
// This method recursvely "walks" the content for a document finding
// all the Frames and IFrames, then sets the "mFrameType" data member
// which tells us what type of PO we have
void
-nsPrintEngine::MapContentForPO(nsPrintObject* aPO,
+nsPrintEngine::MapContentForPO(const UniquePtr<nsPrintObject>& aPO,
nsIContent* aContent)
{
NS_PRECONDITION(aPO && aContent, "Null argument");
nsIDocument* doc = aContent->GetComposedDoc();
NS_ASSERTION(doc, "Content without a document from a document tree?");
@@ -1417,17 +1417,17 @@ nsPrintEngine::SetPrintPO(nsPrintObject*
}
//---------------------------------------------------------------------
// This will first use a Title and/or URL from the PrintSettings
// if one isn't set then it uses the one from the document
// then if not title is there we will make sure we send something back
// depending on the situation.
void
-nsPrintEngine::GetDisplayTitleAndURL(nsPrintObject* aPO,
+nsPrintEngine::GetDisplayTitleAndURL(const UniquePtr<nsPrintObject>& aPO,
nsAString& aTitle,
nsAString& aURLStr,
eDocTitleDefault aDefType)
{
NS_ASSERTION(aPO, "Pointer is null!");
if (!mPrt)
return;
@@ -1477,17 +1477,17 @@ nsPrintEngine::GetDisplayTitleAndURL(nsP
}
}
}
//---------------------------------------------------------------------
nsresult nsPrintEngine::DocumentReadyForPrinting()
{
if (mPrt->mPrintFrameType == nsIPrintSettings::kEachFrameSep) {
- CheckForChildFrameSets(mPrt->mPrintObject.get());
+ CheckForChildFrameSets(mPrt->mPrintObject);
}
//
// Send the document to the printer...
//
nsresult rv = SetupToPrintContent();
if (NS_FAILED(rv)) {
// The print job was canceled or there was a problem
@@ -1716,17 +1716,17 @@ nsPrintEngine::SetupToPrintContent()
// On some platforms The BeginDocument needs to know the name of the file.
char16_t* fileName = nullptr;
mPrt->mPrintSettings->GetToFileName(&fileName);
fileNameStr = fileName;
}
nsAutoString docTitleStr;
nsAutoString docURLStr;
- GetDisplayTitleAndURL(mPrt->mPrintObject.get(), docTitleStr, docURLStr, eDocTitleDefURLDoc);
+ GetDisplayTitleAndURL(mPrt->mPrintObject, docTitleStr, docURLStr, eDocTitleDefURLDoc);
int32_t startPage = 1;
int32_t endPage = mPrt->mNumPrintablePages;
int16_t printRangeType = nsIPrintSettings::kRangeAllPages;
mPrt->mPrintSettings->GetPrintRange(&printRangeType);
if (printRangeType == nsIPrintSettings::kRangeSpecifiedPageRange) {
mPrt->mPrintSettings->GetStartPageRange(&startPage);
@@ -1761,49 +1761,50 @@ nsPrintEngine::SetupToPrintContent()
NS_ENSURE_SUCCESS(rv, rv);
// This will print the docshell document
// when it completes asynchronously in the DonePrintingPages method
// it will check to see if there are more docshells to be printed and
// then PrintDocContent will be called again.
if (mIsDoingPrinting) {
- PrintDocContent(mPrt->mPrintObject.get(), rv); // ignore return value
+ PrintDocContent(mPrt->mPrintObject, rv); // ignore return value
}
return rv;
}
//-------------------------------------------------------
// Recursively reflow each sub-doc and then calc
// all the frame locations of the sub-docs
nsresult
-nsPrintEngine::ReflowDocList(nsPrintObject* aPO, bool aSetPixelScale)
+nsPrintEngine::ReflowDocList(const UniquePtr<nsPrintObject>& aPO,
+ bool aSetPixelScale)
{
NS_ENSURE_ARG_POINTER(aPO);
// Check to see if the subdocument's element has been hidden by the parent document
if (aPO->mParent && aPO->mParent->mPresShell) {
nsIFrame* frame = aPO->mContent ? aPO->mContent->GetPrimaryFrame() : nullptr;
if (!frame || !frame->StyleVisibility()->IsVisible()) {
- SetPrintPO(aPO, false);
+ SetPrintPO(aPO.get(), false);
aPO->mInvisible = true;
return NS_OK;
}
}
- UpdateZoomRatio(aPO, aSetPixelScale);
+ UpdateZoomRatio(aPO.get(), aSetPixelScale);
nsresult rv;
// Reflow the PO
rv = ReflowPrintObject(aPO);
NS_ENSURE_SUCCESS(rv, rv);
for (const UniquePtr<nsPrintObject>& kid : aPO->mKids) {
- rv = ReflowDocList(kid.get(), aSetPixelScale);
+ rv = ReflowDocList(kid, aSetPixelScale);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
void
nsPrintEngine::FirePrintPreviewUpdateEvent()
{
@@ -1816,17 +1817,17 @@ nsPrintEngine::FirePrintPreviewUpdateEve
)->RunDOMEventWhenSafe();
}
}
nsresult
nsPrintEngine::InitPrintDocConstruction(bool aHandleError)
{
nsresult rv;
- rv = ReflowDocList(mPrt->mPrintObject.get(), DoSetPixelScale());
+ rv = ReflowDocList(mPrt->mPrintObject, DoSetPixelScale());
NS_ENSURE_SUCCESS(rv, rv);
FirePrintPreviewUpdateEvent();
if (mLoadCounter == 0) {
AfterNetworkPrint(aHandleError);
}
return rv;
@@ -2100,17 +2101,17 @@ nsPrintEngine::SetRootView(
// Setup hierarchical relationship in view manager
aPO->mViewManager->SetRootView(rootView);
return NS_OK;
}
// Reflow a nsPrintObject
nsresult
-nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
+nsPrintEngine::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO)
{
NS_ENSURE_STATE(aPO);
if (!aPO->IsPrintable()) {
return NS_OK;
}
NS_ASSERTION(!aPO->mPresContext, "Recreating prescontext");
@@ -2156,23 +2157,24 @@ nsPrintEngine::ReflowPrintObject(nsPrint
// The pres shell now owns the style set object.
bool doReturn = false;;
bool documentIsTopLevel = false;
nsSize adjSize;
- rv = SetRootView(aPO, doReturn, documentIsTopLevel, adjSize);
+ rv = SetRootView(aPO.get(), doReturn, documentIsTopLevel, adjSize);
if (NS_FAILED(rv) || doReturn) {
return rv;
}
- PR_PL(("In DV::ReflowPrintObject PO: %p pS: %p (%9s) Setting w,h to %d,%d\n", aPO, aPO->mPresShell.get(),
+ PR_PL(("In DV::ReflowPrintObject PO: %p pS: %p (%9s) Setting w,h to %d,%d\n",
+ aPO.get(), aPO->mPresShell.get(),
gFrameTypesStr[aPO->mFrameType], adjSize.width, adjSize.height));
// This docshell stuff is weird; will go away when we stop having multiple
// presentations per document
aPO->mPresContext->SetContainer(aPO->mDocShell);
aPO->mPresShell->BeginObservingDocument();
@@ -2194,17 +2196,17 @@ nsPrintEngine::ReflowPrintObject(nsPrint
rv = aPO->mPresShell->Initialize(adjSize.width, adjSize.height);
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(aPO->mPresShell, "Presshell should still be here");
// Process the reflow event Initialize posted
aPO->mPresShell->FlushPendingNotifications(FlushType::Layout);
- rv = UpdateSelectionAndShrinkPrintObject(aPO, documentIsTopLevel);
+ rv = UpdateSelectionAndShrinkPrintObject(aPO.get(), documentIsTopLevel);
NS_ENSURE_SUCCESS(rv, rv);
#ifdef EXTENDED_DEBUG_PRINTING
if (kPrintingLogMod && kPrintingLogMod->level == DUMP_LAYOUT_LEVEL) {
nsAutoCString docStr;
nsAutoCString urlStr;
GetDocTitleAndURL(aPO, docStr, urlStr);
char filename[256];
@@ -2269,31 +2271,32 @@ nsPrintEngine::CalcNumPrintablePages(int
//-----------------------------------------------------------------
//-- Section: Printing Methods
//-----------------------------------------------------------------
//-------------------------------------------------------
// Called for each DocShell that needs to be printed
bool
-nsPrintEngine::PrintDocContent(nsPrintObject* aPO, nsresult& aStatus)
+nsPrintEngine::PrintDocContent(const UniquePtr<nsPrintObject>& aPO,
+ nsresult& aStatus)
{
NS_ASSERTION(aPO, "Pointer is null!");
aStatus = NS_OK;
if (!aPO->mHasBeenPrinted && aPO->IsPrintable()) {
aStatus = DoPrint(aPO);
return true;
}
// If |aPO->mPrintAsIs| and |aPO->mHasBeenPrinted| are true,
// the kids frames are already processed in |PrintPage|.
if (!aPO->mInvisible && !(aPO->mPrintAsIs && aPO->mHasBeenPrinted)) {
for (const UniquePtr<nsPrintObject>& po : aPO->mKids) {
- bool printed = PrintDocContent(po.get(), aStatus);
+ bool printed = PrintDocContent(po, aStatus);
if (printed || NS_FAILED(aStatus)) {
return true;
}
}
}
return false;
}
@@ -2380,21 +2383,21 @@ static nsresult CloneSelection(nsIDocume
for (int32_t i = 0; i < rangeCount; ++i) {
CloneRangeToSelection(origSelection->GetRangeAt(i), aDoc, selection);
}
return NS_OK;
}
//-------------------------------------------------------
nsresult
-nsPrintEngine::DoPrint(nsPrintObject * aPO)
+nsPrintEngine::DoPrint(const UniquePtr<nsPrintObject>& aPO)
{
PR_PL(("\n"));
PR_PL(("**************************** %s ****************************\n", gFrameTypesStr[aPO->mFrameType]));
- PR_PL(("****** In DV::DoPrint PO: %p \n", aPO));
+ PR_PL(("****** In DV::DoPrint PO: %p \n", aPO.get()));
nsIPresShell* poPresShell = aPO->mPresShell;
nsPresContext* poPresContext = aPO->mPresContext;
NS_ASSERTION(poPresContext, "PrintObject has not been reflowed");
NS_ASSERTION(poPresContext->Type() != nsPresContext::eContext_PrintPreview,
"How did this context end up here?");
@@ -2520,27 +2523,27 @@ nsPrintEngine::DoPrint(nsPrintObject * a
SetIsPrinting(false);
return NS_ERROR_FAILURE;
}
mPageSeqFrame = seqFrame;
pageSequence->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr);
// Schedule Page to Print
- PR_PL(("Scheduling Print of PO: %p (%s) \n", aPO, gFrameTypesStr[aPO->mFrameType]));
+ PR_PL(("Scheduling Print of PO: %p (%s) \n", aPO.get(), gFrameTypesStr[aPO->mFrameType]));
StartPagePrintTimer(aPO);
}
}
return NS_OK;
}
//---------------------------------------------------------------------
void
-nsPrintEngine::SetDocAndURLIntoProgress(nsPrintObject* aPO,
+nsPrintEngine::SetDocAndURLIntoProgress(const UniquePtr<nsPrintObject>& aPO,
nsIPrintProgressParams* aParams)
{
NS_ASSERTION(aPO, "Must have valid nsPrintObject");
NS_ASSERTION(aParams, "Must have valid nsIPrintProgressParams");
if (!aPO || !aPO->mDocShell || !aParams) {
return;
}
@@ -3056,17 +3059,17 @@ nsPrintEngine::DonePrintingPages(nsPrint
if (mPageSeqFrame.IsAlive()) {
nsIPageSequenceFrame* pageSeqFrame = do_QueryFrame(mPageSeqFrame.GetFrame());
pageSeqFrame->ResetPrintCanvasList();
}
if (aPO && !mPrt->mIsAborted) {
aPO->mHasBeenPrinted = true;
nsresult rv;
- bool didPrint = PrintDocContent(mPrt->mPrintObject.get(), rv);
+ bool didPrint = PrintDocContent(mPrt->mPrintObject, rv);
if (NS_SUCCEEDED(rv) && didPrint) {
PR_PL(("****** In DV::DonePrintingPages PO: %p (%s) didPrint:%s (Not Done Printing)\n", aPO, gFrameTypesStr[aPO->mFrameType], PRT_YESNO(didPrint)));
return false;
}
}
if (NS_SUCCEEDED(aResult)) {
FirePrintCompletionEvent();
@@ -3482,17 +3485,17 @@ nsPrintEngine::FinishPrintPreview()
//-----------------------------------------------------------------
//-- Done: Finishing up or Cleaning up
//-----------------------------------------------------------------
/*=============== Timer Related Code ======================*/
nsresult
-nsPrintEngine::StartPagePrintTimer(nsPrintObject* aPO)
+nsPrintEngine::StartPagePrintTimer(const UniquePtr<nsPrintObject>& aPO)
{
if (!mPagePrintTimer) {
// Get the delay time in between the printing of each page
// this gives the user more time to press cancel
int32_t printPageDelay = 50;
mPrt->mPrintSettings->GetPrintPageDelay(&printPageDelay);
RefPtr<nsPagePrintTimer> timer =
@@ -3506,17 +3509,17 @@ nsPrintEngine::StartPagePrintTimer(nsPri
printSession->GetRemotePrintJob(getter_AddRefs(remotePrintJob));
if (NS_SUCCEEDED(rv) && remotePrintJob) {
remotePrintJob->SetPagePrintTimer(mPagePrintTimer);
remotePrintJob->SetPrintEngine(this);
}
}
}
- return mPagePrintTimer->Start(aPO);
+ return mPagePrintTimer->Start(aPO.get());
}
/*=============== nsIObserver Interface ======================*/
NS_IMETHODIMP
nsPrintEngine::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData)
{
nsresult rv = NS_ERROR_FAILURE;
@@ -3830,17 +3833,19 @@ static void DumpPrintObjectsTree(nsPrint
NS_ASSERTION(po, "nsPrintObject can't be null!");
for (int32_t k=0;k<aLevel;k++) fprintf(fd, " ");
fprintf(fd, "%s %p %p %p %p %d %d,%d,%d,%d\n", types[po->mFrameType], po, po->mDocShell.get(), po->mSeqFrame,
po->mPageFrame, po->mPageNum, po->mRect.x, po->mRect.y, po->mRect.width, po->mRect.height);
}
}
//-------------------------------------------------------------
-static void GetDocTitleAndURL(nsPrintObject* aPO, nsACString& aDocStr, nsACString& aURLStr)
+static void GetDocTitleAndURL(const UniquePtr<nsPrintObject>& aPO,
+ nsACString& aDocStr,
+ nsACString& aURLStr)
{
nsAutoString docTitleStr;
nsAutoString docURLStr;
nsPrintEngine::GetDisplayTitleAndURL(aPO,
docTitleStr, docURLStr,
nsPrintEngine::eDocTitleDefURLDoc);
aDocStr = NS_ConvertUTF16toUTF8(docTitleStr);
aURLStr = NS_ConvertUTF16toUTF8(docURLStr);
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -92,62 +92,64 @@ public:
nsresult DocumentReadyForPrinting();
nsresult GetSelectionDocument(nsIDeviceContextSpec * aDevSpec,
nsIDocument ** aNewDoc);
nsresult SetupToPrintContent();
nsresult EnablePOsForPrinting();
nsPrintObject* FindSmallestSTF();
- bool PrintDocContent(nsPrintObject* aPO, nsresult& aStatus);
- nsresult DoPrint(nsPrintObject * aPO);
+ bool PrintDocContent(const mozilla::UniquePtr<nsPrintObject>& aPO,
+ nsresult& aStatus);
+ nsresult DoPrint(const mozilla::UniquePtr<nsPrintObject>& aPO);
void SetPrintPO(nsPrintObject* aPO, bool aPrint);
void TurnScriptingOn(bool aDoTurnOn);
bool CheckDocumentForPPCaching();
void InstallPrintPreviewListener();
// nsIDocumentViewerPrint Printing Methods
bool HasPrintCallbackCanvas();
bool PrePrintPage();
bool PrintPage(nsPrintObject* aPOect, bool& aInRange);
bool DonePrintingPages(nsPrintObject* aPO, nsresult aResult);
//---------------------------------------------------------------------
void BuildDocTree(nsIDocShell * aParentNode,
nsTArray<nsPrintObject*> * aDocList,
- nsPrintObject * aPO);
- nsresult ReflowDocList(nsPrintObject * aPO, bool aSetPixelScale);
+ const mozilla::UniquePtr<nsPrintObject>& aPO);
+ nsresult ReflowDocList(const mozilla::UniquePtr<nsPrintObject>& aPO,
+ bool aSetPixelScale);
- nsresult ReflowPrintObject(nsPrintObject * aPO);
+ nsresult ReflowPrintObject(const mozilla::UniquePtr<nsPrintObject>& aPO);
- void CheckForChildFrameSets(nsPrintObject* aPO);
+ void CheckForChildFrameSets(const mozilla::UniquePtr<nsPrintObject>& aPO);
void CalcNumPrintablePages(int32_t& aNumPages);
void ShowPrintProgress(bool aIsForPrinting, bool& aDoNotify);
nsresult CleanupOnFailure(nsresult aResult, bool aIsPrinting);
// If FinishPrintPreview() fails, caller may need to reset the state of the
// object, for example by calling CleanupOnFailure().
nsresult FinishPrintPreview();
static void CloseProgressDialog(nsIWebProgressListener* aWebProgressListener);
- void SetDocAndURLIntoProgress(nsPrintObject* aPO,
+ void SetDocAndURLIntoProgress(const mozilla::UniquePtr<nsPrintObject>& aPO,
nsIPrintProgressParams* aParams);
void EllipseLongString(nsAString& aStr, const uint32_t aLen, bool aDoFront);
nsresult CheckForPrinters(nsIPrintSettings* aPrintSettings);
void CleanupDocTitleArray(char16_t**& aArray, int32_t& aCount);
bool IsThereARangeSelection(nsPIDOMWindowOuter* aDOMWin);
void FirePrintingErrorEvent(nsresult aPrintError);
//---------------------------------------------------------------------
// Timer Methods
- nsresult StartPagePrintTimer(nsPrintObject* aPO);
+ nsresult StartPagePrintTimer(const mozilla::UniquePtr<nsPrintObject>& aPO);
bool IsWindowsInOurSubTree(nsPIDOMWindowOuter* aDOMWindow);
static bool IsParentAFrameSet(nsIDocShell * aParent);
bool IsThereAnIFrameSelected(nsIDocShell* aDocShell,
nsPIDOMWindowOuter* aDOMWin,
bool& aIsParentFrameSet);
static nsPrintObject* FindPrintObjectByDOMWin(nsPrintObject* aParentObject,
@@ -157,17 +159,17 @@ public:
already_AddRefed<nsPIDOMWindowOuter> FindFocusedDOMWindow();
//---------------------------------------------------------------------
// Static Methods
//---------------------------------------------------------------------
static void GetDocumentTitleAndURL(nsIDocument* aDoc,
nsAString& aTitle,
nsAString& aURLStr);
- void GetDisplayTitleAndURL(nsPrintObject* aPO,
+ void GetDisplayTitleAndURL(const mozilla::UniquePtr<nsPrintObject>& aPO,
nsAString& aTitle,
nsAString& aURLStr,
eDocTitleDefault aDefType);
static bool HasFramesetChild(nsIContent* aContent);
bool CheckBeforeDestroy();
nsresult Cancelled();
@@ -211,17 +213,17 @@ protected:
nsIWebProgressListener* aWebProgressListener,
nsIDOMDocument* aDoc);
nsresult DoCommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
nsIWebProgressListener* aWebProgressListener,
nsIDOMDocument* aDoc);
void FirePrintCompletionEvent();
- static nsresult GetSeqFrameAndCountPagesInternal(nsPrintObject* aPO,
+ static nsresult GetSeqFrameAndCountPagesInternal(const mozilla::UniquePtr<nsPrintObject>& aPO,
nsIFrame*& aSeqFrame,
int32_t& aCount);
static nsresult FindSelectionBoundsWithList(nsFrameList::Enumerator& aChildFrames,
nsIFrame * aParentFrame,
nsRect& aRect,
nsIFrame *& aStartFrame,
nsRect& aStartRect,
@@ -238,19 +240,21 @@ protected:
static nsresult GetPageRangeForSelection(nsIPageSequenceFrame* aPageSeqFrame,
nsIFrame** aStartFrame,
int32_t& aStartPageNum,
nsRect& aStartRect,
nsIFrame** aEndFrame,
int32_t& aEndPageNum,
nsRect& aEndRect);
- static void MapContentForPO(nsPrintObject* aPO, nsIContent* aContent);
+ static void MapContentForPO(const mozilla::UniquePtr<nsPrintObject>& aPO,
+ nsIContent* aContent);
- static void MapContentToWebShells(nsPrintObject* aRootPO, nsPrintObject* aPO);
+ static void MapContentToWebShells(const mozilla::UniquePtr<nsPrintObject>& aRootPO,
+ const mozilla::UniquePtr<nsPrintObject>& aPO);
static void SetPrintAsIs(nsPrintObject* aPO, bool aAsIs = true);
void DisconnectPagePrintTimer();
// Static member variables
bool mIsCreatingPrintPreview;
bool mIsDoingPrinting;