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,34 +2708,7 @@ nsresult nsPrintJob::EnablePOsForPrinting() {
MOZ_ASSERT(printRangeType == nsIPrintSettings::kRangeSelection);
// If the currentFocusDOMWin can'r be null if something is selected
if (printData->mCurrentFocusWin) {
// Find the selected IFrame
nsPrintObject* po = FindPrintObjectByDOMWin(printData->mPrintObject.get(),
printData->mCurrentFocusWin);
if (po) {
// 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);
// check to see if we have a range selection,
// as oppose to a insert selection
// this means if the user just clicked on the IFrame then
// there will not be a selection so we want the entire page to print
//
// XXX this is sort of a hack right here to make the page
// not try to reposition itself when printing selection
nsPIDOMWindowOuter* domWin =
po->mDocument->GetOriginalDocument()->GetWindow();
if (!IsThereARangeSelection(domWin)) {
printRangeType = nsIPrintSettings::kRangeAllPages;
printData->mPrintSettings->SetPrintRange(printRangeType);
}
PR_PL(("PrintRange: %s \n", gPrintRangeStr[printRangeType]));
return NS_OK;
}
} else {
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!");
......@@ -2749,24 +2722,33 @@ nsresult nsPrintJob::EnablePOsForPrinting() {
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);
}
// Find the selected IFrame
nsPrintObject* po = FindPrintObjectByDOMWin(printData->mPrintObject.get(),
printData->mCurrentFocusWin);
if (!po) {
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);
// check to see if we have a range selection,
// as oppose to a insert selection
// this means if the user just clicked on the IFrame then
// there will not be a selection so we want the entire page to print
//
// XXX this is sort of a hack right here to make the page
// not try to reposition itself when printing selection
nsPIDOMWindowOuter* domWin =
po->mDocument->GetOriginalDocument()->GetWindow();
if (!IsThereARangeSelection(domWin)) {
printRangeType = nsIPrintSettings::kRangeAllPages;
printData->mPrintSettings->SetPrintRange(printRangeType);
}
PR_PL(("PrintRange: %s \n", gPrintRangeStr[printRangeType]));
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