Fix a crash in printing pages with non-visible elements. Bug 275262, r+sr=roc

This commit is contained in:
smontagu%smontagu.org 2004-12-21 11:51:13 +00:00
parent 2b7389a5e2
commit 6a9211d8aa
3 changed files with 17 additions and 10 deletions

View File

@ -2491,6 +2491,7 @@ nsPrintEngine::ReflowDocList(nsPrintObject* aPO, PRBool aSetPixelScale, PRBool a
if (frame) {
if (!frame->GetStyleVisibility()->IsVisible()) {
aPO->mDontPrint = PR_TRUE;
aPO->mInvisible = PR_TRUE;
return NS_OK;
}
}
@ -3024,11 +3025,13 @@ nsPrintEngine::PrintDocContent(nsPrintObject* aPO, nsresult& aStatus)
}
}
for (PRInt32 i=0;i<aPO->mKids.Count();i++) {
nsPrintObject* po = (nsPrintObject*)aPO->mKids[i];
PRBool printed = PrintDocContent(po, aStatus);
if (printed || NS_FAILED(aStatus)) {
return PR_TRUE;
if (!aPO->mInvisible) {
for (PRInt32 i=0;i<aPO->mKids.Count();i++) {
nsPrintObject* po = (nsPrintObject*)aPO->mKids[i];
PRBool printed = PrintDocContent(po, aStatus);
if (printed || NS_FAILED(aStatus)) {
return PR_TRUE;
}
}
}
return PR_FALSE;
@ -3087,6 +3090,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO, PRBool aDoSyncPrinting, PRBool& aDon
nsIView* poRootView = aPO->mRootView;
NS_ASSERTION(webShell, "The WebShell can't be NULL!");
NS_ASSERTION(poPresContext, "PrintObject has not been reflowed");
if (mPrt->mPrintProgressParams) {
SetDocAndURLIntoProgress(aPO, mPrt->mPrintProgressParams);
@ -4399,10 +4403,12 @@ nsPrintEngine::ShowDocListInternal(nsPrintObject* aPO, PRBool aShow)
}
}
PRInt32 cnt = aPO->mKids.Count();
for (PRInt32 i=0;i<cnt;i++) {
if (NS_FAILED(ShowDocListInternal((nsPrintObject *)aPO->mKids[i], aShow))) {
return NS_ERROR_FAILURE;
if (!aPO->mInvisible) {
PRInt32 cnt = aPO->mKids.Count();
for (PRInt32 i=0;i<cnt;i++) {
if (NS_FAILED(ShowDocListInternal((nsPrintObject *)aPO->mKids[i], aShow))) {
return NS_ERROR_FAILURE;
}
}
}

View File

@ -47,7 +47,7 @@ nsPrintObject::nsPrintObject() :
mSeqFrame(nsnull), mPageFrame(nsnull), mPageNum(-1),
mRect(0,0,0,0), mReflowRect(0,0,0,0),
mParent(nsnull), mHasBeenPrinted(PR_FALSE), mDontPrint(PR_TRUE),
mPrintAsIs(PR_FALSE), mSkippedPageEject(PR_FALSE), mSharedPresShell(PR_FALSE), mIsHidden(PR_FALSE),
mPrintAsIs(PR_FALSE), mSkippedPageEject(PR_FALSE), mSharedPresShell(PR_FALSE), mIsHidden(PR_FALSE), mInvisible(PR_FALSE),
mClipRect(-1,-1, -1, -1),
mImgAnimationMode(imgIContainer::kNormalAnimMode),
mDocTitle(nsnull), mDocURL(nsnull), mShrinkRatio(1.0), mXMost(0)

View File

@ -102,6 +102,7 @@ public:
PRPackedBool mSkippedPageEject;
PRPackedBool mSharedPresShell;
PRPackedBool mIsHidden; // Indicates PO is hidden, not reflowed, not shown
PRPackedBool mInvisible; // Indicates PO is set to not visible by CSS
nsRect mClipRect;