From 25274d642f572f1bfbe5f67e386b2814782e73d6 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Sun, 10 Mar 2002 15:40:51 +0000 Subject: [PATCH] The problem is that on windows widget can only be positioned to a y coord of 32767. This ends up being about 32 pages. The nsPageFrame's view creates a widget for clipping absolutely positioned content and plugins. This fix will allow a document to have up to 32 pages of clipping after that it stops creating the widget. The down side is that any absolutely positioned content or plugins beyond page 32 will not be clippe din print preview. Also, fixed a leaked widget Bug 127263 r=dcone sr=attinasi a=asa --- layout/generic/nsPageFrame.cpp | 10 ++++++---- layout/generic/nsPageFrame.h | 7 +++++++ layout/generic/nsSimplePageSequence.cpp | 14 ++++++++++++++ layout/html/base/src/nsPageFrame.cpp | 10 ++++++---- layout/html/base/src/nsPageFrame.h | 7 +++++++ layout/html/base/src/nsSimplePageSequence.cpp | 14 ++++++++++++++ 6 files changed, 54 insertions(+), 8 deletions(-) diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index 8d4b2469c2ce..65ab958103dd 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -95,6 +95,8 @@ static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID); #define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) #endif +// XXX Part of Temporary fix for Bug 127263 +PRBool nsPageFrame::mDoCreateWidget = PR_TRUE; nsresult NS_NewPageFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) @@ -130,12 +132,12 @@ nsPageFrame::SetInitialChildList(nsIPresContext* aPresContext, { nsIView * view; aChildList->GetView(aPresContext, &view); - if (view != nsnull) { + if (view != nsnull && mDoCreateWidget) { nscoord dx, dy; - nsIWidget* widget; - view->GetOffsetFromWidget(&dx, &dy, widget); + nsCOMPtr widget; + view->GetOffsetFromWidget(&dx, &dy, *getter_AddRefs(widget)); nsCOMPtr ppContext = do_QueryInterface(aPresContext); - if (ppContext && widget != nsnull) { + if (ppContext && widget) { view->CreateWidget(kCChildCID); } } diff --git a/layout/generic/nsPageFrame.h b/layout/generic/nsPageFrame.h index 2a5d22da052c..7d1d4aa26bb7 100644 --- a/layout/generic/nsPageFrame.h +++ b/layout/generic/nsPageFrame.h @@ -92,6 +92,10 @@ public: virtual void SetSharedPageData(nsSharedPageData* aPD) { mPD = aPD; } +// XXX Part of Temporary fix for Bug 127263 + static void SetCreateWidget(PRBool aDoCreateWidget) { mDoCreateWidget = aDoCreateWidget; } + static PRBool GetCreateWidget() { return mDoCreateWidget; } + protected: nsPageFrame(); virtual ~nsPageFrame(); @@ -139,6 +143,9 @@ protected: nsSharedPageData* mPD; +// XXX Part of Temporary fix for Bug 127263 + static PRBool mDoCreateWidget; + private: void DrawBackground(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index 8998a91ee54d..1f250faa4e1e 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -391,6 +391,9 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, // in fact, all we want is the initial reflow y = mRect.height; } else { + // XXX Part of Temporary fix for Bug 127263 + nsPageFrame::SetCreateWidget(PR_TRUE); + nsReflowReason reflowReason = aReflowState.reason; SetPageSizes(pageSize, margin); @@ -435,6 +438,17 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, FinishReflowChild(kidFrame, aPresContext, nsnull, kidSize, x, y, 0); y += kidSize.height; + // XXX Temporary fix for Bug 127263 + // This tells the nsPageFrame class to stop creating clipping widgets + // once we reach the 32k boundary for positioning + if (nsPageFrame::GetCreateWidget()) { + float t2p; + aPresContext->GetTwipsToPixels(&t2p); + nscoord xp = NSTwipsToIntPixels(x, t2p); + nscoord yp = NSTwipsToIntPixels(y, t2p); + nsPageFrame::SetCreateWidget(xp < 0x8000 && yp < 0x8000); + } + // Leave a slight gap between the pages y += deadSpaceGap; diff --git a/layout/html/base/src/nsPageFrame.cpp b/layout/html/base/src/nsPageFrame.cpp index 8d4b2469c2ce..65ab958103dd 100644 --- a/layout/html/base/src/nsPageFrame.cpp +++ b/layout/html/base/src/nsPageFrame.cpp @@ -95,6 +95,8 @@ static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID); #define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) #endif +// XXX Part of Temporary fix for Bug 127263 +PRBool nsPageFrame::mDoCreateWidget = PR_TRUE; nsresult NS_NewPageFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) @@ -130,12 +132,12 @@ nsPageFrame::SetInitialChildList(nsIPresContext* aPresContext, { nsIView * view; aChildList->GetView(aPresContext, &view); - if (view != nsnull) { + if (view != nsnull && mDoCreateWidget) { nscoord dx, dy; - nsIWidget* widget; - view->GetOffsetFromWidget(&dx, &dy, widget); + nsCOMPtr widget; + view->GetOffsetFromWidget(&dx, &dy, *getter_AddRefs(widget)); nsCOMPtr ppContext = do_QueryInterface(aPresContext); - if (ppContext && widget != nsnull) { + if (ppContext && widget) { view->CreateWidget(kCChildCID); } } diff --git a/layout/html/base/src/nsPageFrame.h b/layout/html/base/src/nsPageFrame.h index 2a5d22da052c..7d1d4aa26bb7 100644 --- a/layout/html/base/src/nsPageFrame.h +++ b/layout/html/base/src/nsPageFrame.h @@ -92,6 +92,10 @@ public: virtual void SetSharedPageData(nsSharedPageData* aPD) { mPD = aPD; } +// XXX Part of Temporary fix for Bug 127263 + static void SetCreateWidget(PRBool aDoCreateWidget) { mDoCreateWidget = aDoCreateWidget; } + static PRBool GetCreateWidget() { return mDoCreateWidget; } + protected: nsPageFrame(); virtual ~nsPageFrame(); @@ -139,6 +143,9 @@ protected: nsSharedPageData* mPD; +// XXX Part of Temporary fix for Bug 127263 + static PRBool mDoCreateWidget; + private: void DrawBackground(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/layout/html/base/src/nsSimplePageSequence.cpp b/layout/html/base/src/nsSimplePageSequence.cpp index 8998a91ee54d..1f250faa4e1e 100644 --- a/layout/html/base/src/nsSimplePageSequence.cpp +++ b/layout/html/base/src/nsSimplePageSequence.cpp @@ -391,6 +391,9 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, // in fact, all we want is the initial reflow y = mRect.height; } else { + // XXX Part of Temporary fix for Bug 127263 + nsPageFrame::SetCreateWidget(PR_TRUE); + nsReflowReason reflowReason = aReflowState.reason; SetPageSizes(pageSize, margin); @@ -435,6 +438,17 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, FinishReflowChild(kidFrame, aPresContext, nsnull, kidSize, x, y, 0); y += kidSize.height; + // XXX Temporary fix for Bug 127263 + // This tells the nsPageFrame class to stop creating clipping widgets + // once we reach the 32k boundary for positioning + if (nsPageFrame::GetCreateWidget()) { + float t2p; + aPresContext->GetTwipsToPixels(&t2p); + nscoord xp = NSTwipsToIntPixels(x, t2p); + nscoord yp = NSTwipsToIntPixels(y, t2p); + nsPageFrame::SetCreateWidget(xp < 0x8000 && yp < 0x8000); + } + // Leave a slight gap between the pages y += deadSpaceGap;