From 7c89b4af6bc4bc50718747c4496b8b690fe35754 Mon Sep 17 00:00:00 2001 From: "kmcclusk%netscape.com" Date: Thu, 10 Dec 1998 18:47:02 +0000 Subject: [PATCH] Removed temporary ReflowWithNoWidget method from nsFormControlFrame. Reflow without a widget is now handled by the standard Reflow method. git-svn-id: svn://10.0.0.236/trunk@16169 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsFormControlFrame.cpp | 128 +++--------------- mozilla/layout/forms/nsFormControlFrame.h | 8 -- .../html/forms/src/nsFormControlFrame.cpp | 128 +++--------------- .../html/forms/src/nsFormControlFrame.h | 8 -- 4 files changed, 32 insertions(+), 240 deletions(-) diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index 043a8a67115..12f116ebcd2 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -227,26 +227,16 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext, { nsresult result = NS_OK; - //XXX:PRINTING Temporary to force GFX rendered widgets to appear on the display. This - //Will be used to debug GFX rendered widgets for printing. This should be removed when - //Printing is completely working. - PRBool renderToScreen = PR_FALSE; nsIDeviceContext* dx = nsnull; dx = aPresContext.GetDeviceContext(); - PRBool supportsWidgets = PR_FALSE; + PRBool supportsWidgets = PR_TRUE; if (nsnull != dx) { PRBool native = PR_FALSE; dx->SupportsNativeWidgets(supportsWidgets); - NS_RELEASE(dx); } - if ((PR_TRUE == renderToScreen) || (PR_FALSE == supportsWidgets)) { - return(ReflowWithNoWidget(aPresContext, aDesiredSize, aReflowState, aStatus)); - } - - GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize); if (!mDidInit) { @@ -284,14 +274,16 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext, SetView(view); } - const nsIID& id = GetCID(); - nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted - view->CreateWidget(id, initData); - - if (nsnull != initData) { - delete(initData); - } + const nsIID& id = GetCID(); + if (PR_TRUE == supportsWidgets) { + // Do the following only if a widget is created + nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted + view->CreateWidget(id, initData); + if (nsnull != initData) { + delete(initData); + } + // set our widget result = GetWidget(view, &mWidget); if ((NS_OK == result) && mWidget) { // keep the ref on mWidget @@ -302,11 +294,15 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext, formControl->SetWidget(mWidget); NS_RELEASE(formControl); } - PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height); - mDidInit = PR_TRUE; + // PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height); + // mDidInit = PR_TRUE; } else { NS_ASSERTION(0, "could not get widget"); } + } + + PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height); + mDidInit = PR_TRUE; if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) { viewMan->ResizeView(view, aDesiredSize.width, aDesiredSize.height); @@ -964,98 +960,6 @@ nsFormControlFrame::Reset() } -//XXX:PRINTING Temporary to force GFX rendered widgets to appear on the display. This -//Will be used to debug GFX rendered widgets for printing. This should be removed when -//Printing is completely working. - -NS_IMETHODIMP -nsFormControlFrame::ReflowWithNoWidget(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus) -{ - nsresult result = NS_OK; - - GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize); - - if (!mDidInit) { - nsIPresShell *presShell = aPresContext.GetShell(); // need to release - nsIViewManager *viewMan = presShell->GetViewManager(); // need to release - NS_RELEASE(presShell); - nsRect boundBox(0, 0, aDesiredSize.width, aDesiredSize.height); - - // absolutely positioned controls already have a view but not a widget - nsIView* view = nsnull; - GetView(view); - if (nsnull == view) { - result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); - if (!NS_SUCCEEDED(result)) { - NS_ASSERTION(0, "Could not create view for form control"); - aStatus = NS_FRAME_NOT_COMPLETE; - return result; - } - - nsIFrame* parWithView; - nsIView *parView; - - GetParentWithView(parWithView); - parWithView->GetView(parView); - - // initialize the view as hidden since we don't know the (x,y) until Paint - result = view->Init(viewMan, boundBox, parView, nsnull, nsViewVisibility_kHide); - if (NS_OK != result) { - NS_ASSERTION(0, "view initialization failed"); - aStatus = NS_FRAME_NOT_COMPLETE; - return NS_OK; - } - - viewMan->InsertChild(parView, view, 0); - SetView(view); - } - - const nsIID& id = GetCID(); - nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted - //view->CreateWidget(id, initData); - - if (nsnull != initData) { - delete(initData); - } - - // set our widget - //result = GetWidget(view, &mWidget); - //if ((NS_OK == result) && mWidget) { // keep the ref on mWidget - //nsIFormControl* formControl = nsnull; - //result = mContent->QueryInterface(kIFormControlIID, (void**)&formControl); - //if ((NS_OK == result) && formControl) { - // set the content's widget, so it can get content modified by the widget - //formControl->SetWidget(mWidget); - //NS_RELEASE(formControl); - //} - PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height); - mDidInit = PR_TRUE; - //} else { - // NS_ASSERTION(0, "could not get widget"); - //} - - if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) { - viewMan->ResizeView(view, aDesiredSize.width, aDesiredSize.height); - } - - NS_IF_RELEASE(viewMan); - } - - aDesiredSize.ascent = aDesiredSize.height; - aDesiredSize.descent = 0; - - if (nsnull != aDesiredSize.maxElementSize) { - aDesiredSize.maxElementSize->width = aDesiredSize.width; - aDesiredSize.maxElementSize->height = aDesiredSize.height; - } - - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - void nsFormControlFrame::DrawLine(nsIRenderingContext& aRenderingContext, nscoord aSX, nscoord aSY, nscoord aEX, nscoord aEY, diff --git a/mozilla/layout/forms/nsFormControlFrame.h b/mozilla/layout/forms/nsFormControlFrame.h index 0dca78e084e..2fd42a07c83 100644 --- a/mozilla/layout/forms/nsFormControlFrame.h +++ b/mozilla/layout/forms/nsFormControlFrame.h @@ -128,14 +128,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** - * Respond to the request to print the control - * - */ - NS_IMETHOD ReflowWithNoWidget(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild, diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index 043a8a67115..12f116ebcd2 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -227,26 +227,16 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext, { nsresult result = NS_OK; - //XXX:PRINTING Temporary to force GFX rendered widgets to appear on the display. This - //Will be used to debug GFX rendered widgets for printing. This should be removed when - //Printing is completely working. - PRBool renderToScreen = PR_FALSE; nsIDeviceContext* dx = nsnull; dx = aPresContext.GetDeviceContext(); - PRBool supportsWidgets = PR_FALSE; + PRBool supportsWidgets = PR_TRUE; if (nsnull != dx) { PRBool native = PR_FALSE; dx->SupportsNativeWidgets(supportsWidgets); - NS_RELEASE(dx); } - if ((PR_TRUE == renderToScreen) || (PR_FALSE == supportsWidgets)) { - return(ReflowWithNoWidget(aPresContext, aDesiredSize, aReflowState, aStatus)); - } - - GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize); if (!mDidInit) { @@ -284,14 +274,16 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext, SetView(view); } - const nsIID& id = GetCID(); - nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted - view->CreateWidget(id, initData); - - if (nsnull != initData) { - delete(initData); - } + const nsIID& id = GetCID(); + if (PR_TRUE == supportsWidgets) { + // Do the following only if a widget is created + nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted + view->CreateWidget(id, initData); + if (nsnull != initData) { + delete(initData); + } + // set our widget result = GetWidget(view, &mWidget); if ((NS_OK == result) && mWidget) { // keep the ref on mWidget @@ -302,11 +294,15 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext, formControl->SetWidget(mWidget); NS_RELEASE(formControl); } - PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height); - mDidInit = PR_TRUE; + // PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height); + // mDidInit = PR_TRUE; } else { NS_ASSERTION(0, "could not get widget"); } + } + + PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height); + mDidInit = PR_TRUE; if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) { viewMan->ResizeView(view, aDesiredSize.width, aDesiredSize.height); @@ -964,98 +960,6 @@ nsFormControlFrame::Reset() } -//XXX:PRINTING Temporary to force GFX rendered widgets to appear on the display. This -//Will be used to debug GFX rendered widgets for printing. This should be removed when -//Printing is completely working. - -NS_IMETHODIMP -nsFormControlFrame::ReflowWithNoWidget(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus) -{ - nsresult result = NS_OK; - - GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize); - - if (!mDidInit) { - nsIPresShell *presShell = aPresContext.GetShell(); // need to release - nsIViewManager *viewMan = presShell->GetViewManager(); // need to release - NS_RELEASE(presShell); - nsRect boundBox(0, 0, aDesiredSize.width, aDesiredSize.height); - - // absolutely positioned controls already have a view but not a widget - nsIView* view = nsnull; - GetView(view); - if (nsnull == view) { - result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); - if (!NS_SUCCEEDED(result)) { - NS_ASSERTION(0, "Could not create view for form control"); - aStatus = NS_FRAME_NOT_COMPLETE; - return result; - } - - nsIFrame* parWithView; - nsIView *parView; - - GetParentWithView(parWithView); - parWithView->GetView(parView); - - // initialize the view as hidden since we don't know the (x,y) until Paint - result = view->Init(viewMan, boundBox, parView, nsnull, nsViewVisibility_kHide); - if (NS_OK != result) { - NS_ASSERTION(0, "view initialization failed"); - aStatus = NS_FRAME_NOT_COMPLETE; - return NS_OK; - } - - viewMan->InsertChild(parView, view, 0); - SetView(view); - } - - const nsIID& id = GetCID(); - nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted - //view->CreateWidget(id, initData); - - if (nsnull != initData) { - delete(initData); - } - - // set our widget - //result = GetWidget(view, &mWidget); - //if ((NS_OK == result) && mWidget) { // keep the ref on mWidget - //nsIFormControl* formControl = nsnull; - //result = mContent->QueryInterface(kIFormControlIID, (void**)&formControl); - //if ((NS_OK == result) && formControl) { - // set the content's widget, so it can get content modified by the widget - //formControl->SetWidget(mWidget); - //NS_RELEASE(formControl); - //} - PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height); - mDidInit = PR_TRUE; - //} else { - // NS_ASSERTION(0, "could not get widget"); - //} - - if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) { - viewMan->ResizeView(view, aDesiredSize.width, aDesiredSize.height); - } - - NS_IF_RELEASE(viewMan); - } - - aDesiredSize.ascent = aDesiredSize.height; - aDesiredSize.descent = 0; - - if (nsnull != aDesiredSize.maxElementSize) { - aDesiredSize.maxElementSize->width = aDesiredSize.width; - aDesiredSize.maxElementSize->height = aDesiredSize.height; - } - - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - void nsFormControlFrame::DrawLine(nsIRenderingContext& aRenderingContext, nscoord aSX, nscoord aSY, nscoord aEX, nscoord aEY, diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.h b/mozilla/layout/html/forms/src/nsFormControlFrame.h index 0dca78e084e..2fd42a07c83 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.h +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.h @@ -128,14 +128,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** - * Respond to the request to print the control - * - */ - NS_IMETHOD ReflowWithNoWidget(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild,