Commit 78ab5353 authored by Jonathan Watt's avatar Jonathan Watt
Browse files

Bug 1642167. Further simplify nsPrintJob::EnablePOsForPrinting. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D77601
parent a26f4f24
......@@ -2708,11 +2708,27 @@ nsresult nsPrintJob::EnablePOsForPrinting() {
MOZ_ASSERT(printRangeType == nsIPrintSettings::kRangeSelection);
// If the currentFocusDOMWin can'r be null if something is selected
if (printData->mCurrentFocusWin) {
if (!printData->mCurrentFocusWin) {
for (uint32_t i = 0; i < printData->mPrintDocList.Length(); i++) {
nsPrintObject* po = printData->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsCOMPtr<nsPIDOMWindowOuter> domWin = po->mDocShell->GetWindow();
if (IsThereARangeSelection(domWin)) {
printData->mCurrentFocusWin = std::move(domWin);
po->EnablePrinting(true);
break;
}
}
return NS_OK;
}
// Find the selected IFrame
nsPrintObject* po = FindPrintObjectByDOMWin(printData->mPrintObject.get(),
printData->mCurrentFocusWin);
if (po) {
if (!po) {
return NS_OK;
}
// Makes sure all of its children are be printed "AsIs"
po->SetPrintAsIs(true);
......@@ -2733,40 +2749,6 @@ nsresult nsPrintJob::EnablePOsForPrinting() {
printData->mPrintSettings->SetPrintRange(printRangeType);
}
PR_PL(("PrintRange: %s \n", gPrintRangeStr[printRangeType]));
return NS_OK;
}
} else {
for (uint32_t i = 0; i < printData->mPrintDocList.Length(); i++) {
nsPrintObject* po = printData->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsCOMPtr<nsPIDOMWindowOuter> domWin = po->mDocShell->GetWindow();
if (IsThereARangeSelection(domWin)) {
printData->mCurrentFocusWin = std::move(domWin);
po->EnablePrinting(true);
break;
}
}
return NS_OK;
}
if ((printData->mIsParentAFrameSet && printData->mCurrentFocusWin) ||
printData->mIsIFrameSelected) {
nsPrintObject* po = FindPrintObjectByDOMWin(printData->mPrintObject.get(),
printData->mCurrentFocusWin);
if (po) {
// NOTE: Calling this sets the "po" and
// we don't want to do this for documents that have no children,
// because then the "DoEndPage" gets called and it shouldn't
if (po->mKids.Length() > 0) {
// Makes sure that itself, and all of its children are printed "AsIs"
po->SetPrintAsIs(true);
}
// Now, only enable this POs (the selected PO) and all of its children
po->EnablePrinting(true);
}
}
return NS_OK;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment