Bug 1642236. Make all printing "print as is" printing. r=bobowen

nsPrintObject::InitAsNestedObject made sure that all nsPrintObjects were set to
print-as-is except for frameset documents and their sub-documents. (Note the
setting of mParent->mPrintAsIs, which would actually set the root nsPrintObject
to print-as-is if it wasn't a frameset document!).

The SetPrintAsIs() calls in nsPrintJob::EnablePOsForPrinting would then
subsequently also set those frameset and frame nsPrintObjects to be print-as-is
in all but one edge case, namely printing a selection when there isn't a focused
window (which I'm not sure is even be possible).

Differential Revision: https://phabricator.services.mozilla.com/D77621
This commit is contained in:
Jonathan Watt 2020-06-02 15:18:04 +00:00
Родитель 3a3972c388
Коммит 3e4c61adb7
3 изменённых файлов: 4 добавлений и 38 удалений

Просмотреть файл

@ -2073,9 +2073,11 @@ bool nsPrintJob::PrintDocContent(const UniquePtr<nsPrintObject>& aPO,
return true;
}
// If |aPO->mPrintAsIs| and |aPO->mHasBeenPrinted| are true,
// If |aPO->mHasBeenPrinted| is true,
// the kids frames are already processed in |PrintPage|.
if (!aPO->mInvisible && !(aPO->mPrintAsIs && aPO->mHasBeenPrinted)) {
// XXX This should be removed. Since bug 1552785 it has no longer been
// possible for us to have to print multiple subdocuments consecutively.
if (!aPO->mHasBeenPrinted && !aPO->mInvisible) {
for (const UniquePtr<nsPrintObject>& po : aPO->mKids) {
bool printed = PrintDocContent(po, aStatus);
if (printed || NS_FAILED(aStatus)) {
@ -2576,22 +2578,6 @@ nsresult nsPrintJob::EnablePOsForPrinting() {
if (printRangeType == nsIPrintSettings::kRangeAllPages ||
printRangeType == nsIPrintSettings::kRangeSpecifiedPageRange) {
printData->mPrintObject->EnablePrinting(true);
if (printData->mIsParentAFrameSet) {
printData->mPrintObject->SetPrintAsIs(true);
return NS_OK;
}
// Set the children so they are PrinAsIs
// In this case, the children are probably IFrames
if (printData->mPrintObject->mKids.Length() > 0) {
for (const UniquePtr<nsPrintObject>& po :
printData->mPrintObject->mKids) {
NS_ASSERTION(po, "nsPrintObject can't be null!");
po->SetPrintAsIs(true);
}
}
PR_PL(("PrintRange: %s \n", gPrintRangeStr[printRangeType]));
return NS_OK;
}
@ -2622,9 +2608,6 @@ nsresult nsPrintJob::EnablePOsForPrinting() {
return NS_OK;
}
// Makes sure all of its children are be printed "AsIs"
po->SetPrintAsIs(true);
// Now, only enable this POs (the selected PO) and all of its children
po->EnablePrinting(true);

Просмотреть файл

@ -34,7 +34,6 @@ nsPrintObject::nsPrintObject()
mFrameType(eFrame),
mParent(nullptr),
mHasBeenPrinted(false),
mPrintAsIs(false),
mInvisible(false),
mDidCreateDocShell(false),
mShrinkRatio(1.0),
@ -229,8 +228,6 @@ nsresult nsPrintObject::InitAsNestedObject(nsIDocShell* aDocShell,
} else {
// Assume something iframe-like, i.e. iframe, object, or embed
mFrameType = eIFrame;
mParent->mPrintAsIs = true;
SetPrintAsIs(true);
}
return NS_OK;
@ -250,13 +247,6 @@ void nsPrintObject::DestroyPresentation() {
mViewManager = nullptr;
}
void nsPrintObject::SetPrintAsIs(bool aAsIs) {
mPrintAsIs = aAsIs;
for (const UniquePtr<nsPrintObject>& kid : mKids) {
kid->SetPrintAsIs(aAsIs);
}
}
void nsPrintObject::EnablePrinting(bool aEnable) {
mPrintingIsEnabled = aEnable;

Просмотреть файл

@ -42,12 +42,6 @@ class nsPrintObject {
void DestroyPresentation();
/**
* Recursively sets the PO items to be printed "As Is"
* from the given item down into the treei
*/
void SetPrintAsIs(bool aAsIs);
/**
* Recursively sets all the PO items to be printed
* from the given item down into the tree
@ -70,7 +64,6 @@ class nsPrintObject {
nsTArray<mozilla::UniquePtr<nsPrintObject>> mKids;
nsPrintObject* mParent; // This is a non-owning pointer.
bool mHasBeenPrinted;
bool mPrintAsIs;
bool mInvisible; // Indicates PO is set to not visible by CSS
bool mDidCreateDocShell;
float mShrinkRatio;