зеркало из https://github.com/mozilla/gecko-dev.git
Bug 326157: Get rid of unnecessary clipping code. r+sr=roc.
This commit is contained in:
Родитель
b33921c250
Коммит
8debca1822
|
@ -89,7 +89,6 @@ public:
|
|||
NS_IMETHOD GetPrintThisPage(PRBool* aPrintThisPage) = 0;
|
||||
NS_IMETHOD SetOffset(nscoord aX, nscoord aY) = 0;
|
||||
NS_IMETHOD SuppressHeadersAndFooters(PRBool aDoSup) = 0;
|
||||
NS_IMETHOD SetClipRect(nsPresContext* aPresContext, nsRect* aSize) = 0;
|
||||
NS_IMETHOD SetSelectionHeight(nscoord aYOffset, nscoord aHeight) = 0;
|
||||
|
||||
NS_IMETHOD SetTotalNumPages(PRInt32 aTotal) = 0;
|
||||
|
|
|
@ -60,8 +60,7 @@ NS_NewPageContentFrame(nsIPresShell* aPresShell)
|
|||
return new (aPresShell) nsPageContentFrame;
|
||||
}
|
||||
|
||||
nsPageContentFrame::nsPageContentFrame() :
|
||||
mClipRect(-1, -1, -1, -1)
|
||||
nsPageContentFrame::nsPageContentFrame()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -168,18 +167,10 @@ nsPageContentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||
const nsRect& aDirtyRect,
|
||||
const nsDisplayListSet& aLists)
|
||||
{
|
||||
nsRect rect;
|
||||
if (mClipRect.width != -1 || mClipRect.height != -1) {
|
||||
rect = mClipRect;
|
||||
} else {
|
||||
rect = mRect;
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
}
|
||||
|
||||
nsDisplayListCollection set;
|
||||
nsresult rv = nsContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, set);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return Clip(aBuilder, set, aLists, rect + aBuilder->ToReferenceFrame(this));
|
||||
return Clip(aBuilder, set, aLists,
|
||||
nsRect(aBuilder->ToReferenceFrame(this), GetSize()));
|
||||
}
|
||||
|
|
|
@ -60,8 +60,6 @@ public:
|
|||
|
||||
virtual PRBool IsContainingBlock() const;
|
||||
|
||||
virtual void SetClipRect(nsRect* aClipRect) { mClipRect = *aClipRect; }
|
||||
|
||||
virtual void SetSharedPageData(nsSharedPageData* aPD) { mPD = aPD; }
|
||||
|
||||
/**
|
||||
|
@ -79,7 +77,6 @@ public:
|
|||
protected:
|
||||
nsPageContentFrame();
|
||||
|
||||
nsRect mClipRect;
|
||||
nsSharedPageData* mPD;
|
||||
};
|
||||
|
||||
|
|
|
@ -102,8 +102,7 @@ NS_NewPageFrame(nsIPresShell* aPresShell)
|
|||
}
|
||||
|
||||
nsPageFrame::nsPageFrame() :
|
||||
mSupressHF(PR_FALSE),
|
||||
mClipRect(-1, -1, -1, -1)
|
||||
mSupressHF(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -234,16 +233,6 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsPageFrame::SetClipRect(nsRect* aClipRect)
|
||||
{
|
||||
mClipRect = *aClipRect;
|
||||
nsIFrame* firstFrame = mFrames.FirstChild();
|
||||
nsPageContentFrame* contentPage = NS_STATIC_CAST(nsPageContentFrame*, firstFrame);
|
||||
NS_ASSERTION(contentPage, "There should always be a content page");
|
||||
contentPage->SetClipRect(aClipRect);
|
||||
}
|
||||
|
||||
|
||||
nsIAtom*
|
||||
nsPageFrame::GetType() const
|
||||
{
|
||||
|
@ -569,14 +558,6 @@ nsPageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (mClipRect.width != -1 || mClipRect.height != -1) {
|
||||
#ifdef DEBUG_PRINTING
|
||||
printf("*** ClipRect: %5d,%5d,%5d,%5d\n", mClipRect.x, mClipRect.y, mClipRect.width, mClipRect.height);
|
||||
#endif
|
||||
return Clip(aBuilder, set, aLists,
|
||||
mClipRect + aBuilder->ToReferenceFrame(this));
|
||||
}
|
||||
|
||||
set.MoveTo(aLists);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ public:
|
|||
virtual void SetPageNumInfo(PRInt32 aPageNumber, PRInt32 aTotalPages);
|
||||
|
||||
virtual void SuppressHeadersAndFooters(PRBool aDoSup) { mSupressHF = aDoSup; }
|
||||
virtual void SetClipRect(nsRect* aClipRect);
|
||||
|
||||
virtual void SetSharedPageData(nsSharedPageData* aPD);
|
||||
|
||||
|
@ -145,7 +144,6 @@ protected:
|
|||
nsMargin mMargin;
|
||||
|
||||
PRPackedBool mSupressHF;
|
||||
nsRect mClipRect;
|
||||
|
||||
nsSharedPageData* mPD;
|
||||
|
||||
|
|
|
@ -844,9 +844,6 @@ nsSimplePageSequenceFrame::PrintNextPage(nsPresContext* aPresContext)
|
|||
if (pf != nsnull) {
|
||||
pf->SetPageNumInfo(mPrintedPageNum, mTotalPages);
|
||||
pf->SetSharedPageData(mPageData);
|
||||
if (mSelectionHeight > -1) {
|
||||
pf->SetClipRect(&slidingRect);
|
||||
}
|
||||
}
|
||||
|
||||
// Print the page
|
||||
|
@ -951,18 +948,6 @@ nsSimplePageSequenceFrame::SuppressHeadersAndFooters(PRBool aDoSup)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSimplePageSequenceFrame::SetClipRect(nsPresContext* aPresContext, nsRect* aRect)
|
||||
{
|
||||
for (nsIFrame* f = mFrames.FirstChild(); f; f = f->GetNextSibling()) {
|
||||
nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, f);
|
||||
if (pf != nsnull) {
|
||||
pf->SetClipRect(aRect);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsSimplePageSequenceFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
|
|
|
@ -120,7 +120,6 @@ public:
|
|||
NS_IMETHOD GetPrintThisPage(PRBool* aPrintThisPage) { *aPrintThisPage = mPrintThisPage; return NS_OK; }
|
||||
NS_IMETHOD SetOffset(nscoord aX, nscoord aY) { mOffsetX = aX; mOffsetY = aY; return NS_OK; }
|
||||
NS_IMETHOD SuppressHeadersAndFooters(PRBool aDoSup);
|
||||
NS_IMETHOD SetClipRect(nsPresContext* aPresContext, nsRect* aSize);
|
||||
|
||||
/**
|
||||
* Get the "type" of the frame
|
||||
|
|
|
@ -2383,14 +2383,6 @@ nsPrintEngine::SetupToPrintContent(nsIDeviceContext* aDContext,
|
|||
PR_PL(("-------------------------------------------------------\n"));
|
||||
PR_PL(("\n"));
|
||||
|
||||
// Set up the clipping rectangle for all documents
|
||||
// When frames are being printed as part of a frame set and also IFrames,
|
||||
// they are reflowed with a very large page height. We need to setup the
|
||||
// clipping so they do not rpint over top of anything else
|
||||
PR_PL(("SetClipRect-------------------------------------------------------\n"));
|
||||
nsRect clipRect(-1,-1,-1, -1);
|
||||
SetClipRect(mPrt->mPrintObject, clipRect, 0, 0, PR_FALSE);
|
||||
|
||||
CalcNumPrintableDocsAndPages(mPrt->mNumPrintableDocs, mPrt->mNumPrintablePages);
|
||||
|
||||
PR_PL(("--- Printing %d docs and %d pages\n", mPrt->mNumPrintableDocs, mPrt->mNumPrintablePages));
|
||||
|
@ -3508,40 +3500,6 @@ nsPrintEngine::PrintPage(nsPresContext* aPresContext,
|
|||
nsPrintData::DoOnProgressChange(mPrt->mPrintProgressListeners, curPage, endPage);
|
||||
}
|
||||
|
||||
// Set Clip when Printing "AsIs" or
|
||||
// when printing an IFrame for SelectedFrame or EachFrame
|
||||
PRBool setClip = PR_FALSE;
|
||||
switch (mPrt->mPrintFrameType) {
|
||||
|
||||
case nsIPrintSettings::kFramesAsIs:
|
||||
setClip = PR_TRUE;
|
||||
break;
|
||||
|
||||
case nsIPrintSettings::kSelectedFrame:
|
||||
if (aPO->mPrintAsIs) {
|
||||
if (aPO->mFrameType == eIFrame) {
|
||||
setClip = aPO != mPrt->mSelectedPO;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIPrintSettings::kEachFrameSep:
|
||||
if (aPO->mPrintAsIs) {
|
||||
if (aPO->mFrameType == eIFrame) {
|
||||
setClip = PR_TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
} //switch
|
||||
|
||||
if (setClip) {
|
||||
// Always set the clip x,y to zero because it isn't going to have any margins
|
||||
aPO->mClipRect.x = 0;
|
||||
aPO->mClipRect.y = 0;
|
||||
mPageSeqFrame->SetClipRect(aPO->mPresContext, &aPO->mClipRect);
|
||||
}
|
||||
|
||||
// Print the Page
|
||||
// if a print job was cancelled externally, an EndPage or BeginPage may
|
||||
// fail and the failure is passed back here.
|
||||
|
@ -4048,72 +4006,6 @@ nsPrintEngine::SetPrintAsIs(nsPrintObject* aPO, PRBool aAsIs)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Recursively sets the clip rect on all thchildren
|
||||
void
|
||||
nsPrintEngine::SetClipRect(nsPrintObject* aPO,
|
||||
const nsRect& aClipRect,
|
||||
nscoord aOffsetX,
|
||||
nscoord aOffsetY,
|
||||
PRBool aDoingSetClip)
|
||||
{
|
||||
NS_ASSERTION(aPO, "Pointer is null!");
|
||||
|
||||
nsRect clipRect = aClipRect;
|
||||
if (aDoingSetClip) {
|
||||
nscoord width = (aPO->mRect.x+aPO->mRect.width) > aClipRect.width?aClipRect.width-aPO->mRect.x:aPO->mRect.width;
|
||||
nscoord height = (aPO->mRect.y+aPO->mRect.height) > aClipRect.height?aClipRect.height-aPO->mRect.y:aPO->mRect.height;
|
||||
aPO->mClipRect.SetRect(aPO->mRect.x, aPO->mRect.y, width, height);
|
||||
|
||||
}
|
||||
|
||||
PRBool doClip = aDoingSetClip;
|
||||
|
||||
if (aPO->mFrameType == eFrame) {
|
||||
if (aDoingSetClip) {
|
||||
aPO->mClipRect.SetRect(aOffsetX, aOffsetY, aPO->mClipRect.width, aPO->mClipRect.height);
|
||||
clipRect = aPO->mClipRect;
|
||||
} else if (mPrt->mPrintFrameType == nsIPrintSettings::kFramesAsIs) {
|
||||
aPO->mClipRect.SetRect(aOffsetX, aOffsetY, aPO->mRect.width, aPO->mRect.height);
|
||||
clipRect = aPO->mClipRect;
|
||||
doClip = PR_TRUE;
|
||||
}
|
||||
|
||||
} else if (aPO->mFrameType == eIFrame) {
|
||||
|
||||
if (aDoingSetClip) {
|
||||
aPO->mClipRect.SetRect(aOffsetX, aOffsetY, aPO->mClipRect.width, aPO->mClipRect.height);
|
||||
clipRect = aPO->mClipRect;
|
||||
} else {
|
||||
|
||||
if (mPrt->mPrintFrameType == nsIPrintSettings::kSelectedFrame) {
|
||||
if (aPO->mParent && aPO->mParent == mPrt->mSelectedPO) {
|
||||
aPO->mClipRect.SetRect(aOffsetX, aOffsetY, aPO->mRect.width, aPO->mRect.height);
|
||||
clipRect = aPO->mClipRect;
|
||||
doClip = PR_TRUE;
|
||||
}
|
||||
} else {
|
||||
aPO->mClipRect.SetRect(aOffsetX, aOffsetY, aPO->mRect.width, aPO->mRect.height);
|
||||
clipRect = aPO->mClipRect;
|
||||
doClip = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
PR_PL(("In DV::SetClipRect PO: %p (%9s) ", aPO, gFrameTypesStr[aPO->mFrameType]));
|
||||
PR_PL(("%5d,%5d,%5d,%5d\n", aPO->mClipRect.x, aPO->mClipRect.y,aPO->mClipRect.width, aPO->mClipRect.height));
|
||||
|
||||
PRInt32 cnt = aPO->mKids.Count();
|
||||
for (PRInt32 i=0;i<cnt;i++) {
|
||||
SetClipRect((nsPrintObject *)aPO->mKids[i], clipRect,
|
||||
aOffsetX+aPO->mRect.x, aOffsetY+aPO->mRect.y, doClip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Given a DOMWindow it recursively finds the PO object that matches
|
||||
nsPrintObject*
|
||||
|
|
|
@ -170,11 +170,6 @@ public:
|
|||
nsPrintObject * aPO);
|
||||
nsresult ReflowDocList(nsPrintObject * aPO, PRBool aSetPixelScale,
|
||||
PRBool aDoCalcShrink);
|
||||
void SetClipRect(nsPrintObject* aPO,
|
||||
const nsRect& aClipRect,
|
||||
nscoord aOffsetX,
|
||||
nscoord aOffsetY,
|
||||
PRBool aDoingSetClip);
|
||||
|
||||
nsresult ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink);
|
||||
nsresult CalcPageFrameLocation(nsIPresShell * aPresShell,
|
||||
|
|
|
@ -48,7 +48,6 @@ nsPrintObject::nsPrintObject() :
|
|||
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), mInvisible(PR_FALSE),
|
||||
mClipRect(-1,-1, -1, -1),
|
||||
mImgAnimationMode(imgIContainer::kNormalAnimMode),
|
||||
mDocTitle(nsnull), mDocURL(nsnull), mShrinkRatio(1.0), mXMost(0)
|
||||
{
|
||||
|
|
|
@ -102,8 +102,6 @@ public:
|
|||
PRPackedBool mIsHidden; // Indicates PO is hidden, not reflowed, not shown
|
||||
PRPackedBool mInvisible; // Indicates PO is set to not visible by CSS
|
||||
|
||||
nsRect mClipRect;
|
||||
|
||||
PRUint16 mImgAnimationMode;
|
||||
PRUnichar* mDocTitle;
|
||||
PRUnichar* mDocURL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче