diff --git a/mozilla/layout/generic/nsPageContentFrame.cpp b/mozilla/layout/generic/nsPageContentFrame.cpp index b5f9bd76fb3..17b3efe4b98 100644 --- a/mozilla/layout/generic/nsPageContentFrame.cpp +++ b/mozilla/layout/generic/nsPageContentFrame.cpp @@ -69,6 +69,11 @@ NS_NewPageContentFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) return NS_OK; } +nsPageContentFrame::nsPageContentFrame() : + mClipRect(-1, -1, -1, -1) +{ +} + NS_IMETHODIMP nsPageContentFrame::Reflow(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, @@ -157,13 +162,23 @@ nsPageContentFrame::Paint(nsIPresContext* aPresContext, nsFramePaintLayer aWhichLayer, PRUint32 aFlags) { - PRBool clipEmpty; aRenderingContext.PushState(); - nsRect rect(0, 0, mRect.width, mRect.height); + + nsRect rect; + if (mClipRect.width != -1 || mClipRect.height != -1) { + rect = mClipRect; + } else { + rect = mRect; + } + rect.x = 0; + rect.y = 0; + PRBool clipEmpty; aRenderingContext.SetClipRect(rect, nsClipCombine_kReplace, clipEmpty); nsresult rv = nsContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); + aRenderingContext.PopState(clipEmpty); + return rv; } diff --git a/mozilla/layout/generic/nsPageContentFrame.h b/mozilla/layout/generic/nsPageContentFrame.h index c2a9ca2d9dd..2e11f9bc836 100644 --- a/mozilla/layout/generic/nsPageContentFrame.h +++ b/mozilla/layout/generic/nsPageContentFrame.h @@ -61,6 +61,8 @@ public: NS_IMETHOD IsPercentageBase(PRBool& aBase) const; + virtual void SetClipRect(nsRect* aClipRect) { mClipRect = *aClipRect; } + /** * Get the "type" of the frame * @@ -73,6 +75,9 @@ public: NS_IMETHOD GetFrameName(nsAString& aResult) const; #endif +protected: + nsPageContentFrame(); + nsRect mClipRect; }; #endif /* nsPageContentFrame_h___ */ diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 1e3a96e1c71..5289f673128 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -257,6 +257,16 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* 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); +} + + NS_IMETHODIMP nsPageFrame::GetFrameType(nsIAtom** aType) const { diff --git a/mozilla/layout/generic/nsPageFrame.h b/mozilla/layout/generic/nsPageFrame.h index 08828a8d7e7..2a5d22da052 100644 --- a/mozilla/layout/generic/nsPageFrame.h +++ b/mozilla/layout/generic/nsPageFrame.h @@ -88,7 +88,7 @@ public: virtual void SetPageNumInfo(PRInt32 aPageNumber, PRInt32 aTotalPages); virtual void SuppressHeadersAndFooters(PRBool aDoSup) { mSupressHF = aDoSup; } - virtual void SetClipRect(nsRect* aClipRect) { mClipRect = *aClipRect; } + virtual void SetClipRect(nsRect* aClipRect); virtual void SetSharedPageData(nsSharedPageData* aPD) { mPD = aPD; } diff --git a/mozilla/layout/html/base/src/nsPageContentFrame.cpp b/mozilla/layout/html/base/src/nsPageContentFrame.cpp index b5f9bd76fb3..17b3efe4b98 100644 --- a/mozilla/layout/html/base/src/nsPageContentFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageContentFrame.cpp @@ -69,6 +69,11 @@ NS_NewPageContentFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) return NS_OK; } +nsPageContentFrame::nsPageContentFrame() : + mClipRect(-1, -1, -1, -1) +{ +} + NS_IMETHODIMP nsPageContentFrame::Reflow(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, @@ -157,13 +162,23 @@ nsPageContentFrame::Paint(nsIPresContext* aPresContext, nsFramePaintLayer aWhichLayer, PRUint32 aFlags) { - PRBool clipEmpty; aRenderingContext.PushState(); - nsRect rect(0, 0, mRect.width, mRect.height); + + nsRect rect; + if (mClipRect.width != -1 || mClipRect.height != -1) { + rect = mClipRect; + } else { + rect = mRect; + } + rect.x = 0; + rect.y = 0; + PRBool clipEmpty; aRenderingContext.SetClipRect(rect, nsClipCombine_kReplace, clipEmpty); nsresult rv = nsContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); + aRenderingContext.PopState(clipEmpty); + return rv; } diff --git a/mozilla/layout/html/base/src/nsPageContentFrame.h b/mozilla/layout/html/base/src/nsPageContentFrame.h index c2a9ca2d9dd..2e11f9bc836 100644 --- a/mozilla/layout/html/base/src/nsPageContentFrame.h +++ b/mozilla/layout/html/base/src/nsPageContentFrame.h @@ -61,6 +61,8 @@ public: NS_IMETHOD IsPercentageBase(PRBool& aBase) const; + virtual void SetClipRect(nsRect* aClipRect) { mClipRect = *aClipRect; } + /** * Get the "type" of the frame * @@ -73,6 +75,9 @@ public: NS_IMETHOD GetFrameName(nsAString& aResult) const; #endif +protected: + nsPageContentFrame(); + nsRect mClipRect; }; #endif /* nsPageContentFrame_h___ */ diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 1e3a96e1c71..5289f673128 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -257,6 +257,16 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* 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); +} + + NS_IMETHODIMP nsPageFrame::GetFrameType(nsIAtom** aType) const { diff --git a/mozilla/layout/html/base/src/nsPageFrame.h b/mozilla/layout/html/base/src/nsPageFrame.h index 08828a8d7e7..2a5d22da052 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.h +++ b/mozilla/layout/html/base/src/nsPageFrame.h @@ -88,7 +88,7 @@ public: virtual void SetPageNumInfo(PRInt32 aPageNumber, PRInt32 aTotalPages); virtual void SuppressHeadersAndFooters(PRBool aDoSup) { mSupressHF = aDoSup; } - virtual void SetClipRect(nsRect* aClipRect) { mClipRect = *aClipRect; } + virtual void SetClipRect(nsRect* aClipRect); virtual void SetSharedPageData(nsSharedPageData* aPD) { mPD = aPD; }