From 34b98c1b02220beffe149a3bd5e95e2281c70f09 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Thu, 28 Apr 2005 22:17:40 +0000 Subject: [PATCH] Bug 282708. Position 's view before creating its widget, to avoid flicker from creating it in the wrong position and then instantly moving it. r+sr=bzbarsky,a=asa --- layout/generic/nsObjectFrame.cpp | 27 +++++++++++++-------------- view/src/nsView.cpp | 7 ++++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 053bde102b9..2b3f979830d 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -819,6 +819,18 @@ nsObjectFrame::CreateWidget(nscoord aWidth, viewMan->AllowDoubleBuffering(doubleBuffer); #endif + //this is ugly. it was ripped off from didreflow(). MMP + // Position and size view relative to its parent, not relative to our + // parent frame (our parent frame may not have a view). + + nsIView* parentWithView; + nsPoint origin; + nsRect r(0, 0, mRect.width, mRect.height); + + GetOffsetFromView(origin, &parentWithView); + viewMan->ResizeView(view, r); + viewMan->MoveViewTo(view, origin.x, origin.y); + if (!aViewOnly && !view->HasWidget()) { nsresult rv = CreateWidgetForView(view); if (NS_FAILED(rv)) { @@ -841,22 +853,9 @@ nsObjectFrame::CreateWidget(nscoord aWidth, } } - - //this is ugly. it was ripped off from didreflow(). MMP - // Position and size view relative to its parent, not relative to our - // parent frame (our parent frame may not have a view). - - nsIView* parentWithView; - nsPoint origin; - nsRect r(0, 0, mRect.width, mRect.height); - - GetOffsetFromView(origin, &parentWithView); - viewMan->ResizeView(view, r); - viewMan->MoveViewTo(view, origin.x, origin.y); - viewMan->SetViewVisibility(view, nsViewVisibility_kShow); } - SetView(view); + viewMan->SetViewVisibility(view, nsViewVisibility_kShow); return NS_OK; } diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 49f1dc94864..c31d113f1e4 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -602,13 +602,12 @@ nsresult nsIView::CreateWidget(const nsIID &aWindowIID, { nsIDeviceContext *dx; nsRect trect = mDimBounds; - float scale; NS_ASSERTION(!mWindow, "We already have a window for this view? BAD"); NS_IF_RELEASE(mWindow); mViewManager->GetDeviceContext(dx); - scale = dx->AppUnitsToDevUnits(); + float scale = dx->AppUnitsToDevUnits(); trect *= scale; @@ -641,8 +640,10 @@ nsresult nsIView::CreateWidget(const nsIID &aWindowIID, GetParent()->GetViewManager() != mViewManager) initData.mListenForResizes = PR_TRUE; - nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nsnull) + nsPoint offset(0, 0); + nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(&offset) : nsnull; + trect += offset; if (aWidgetInitData->mWindowType == eWindowType_popup) { mWindow->Create(parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);