From 1c6c3011c34084db83b35ca5b1cd3b758db7372e Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Sat, 22 Feb 2003 21:48:39 +0000 Subject: [PATCH] Bug 180921. Make nsDocumentViewer::Show call nsDocumentViewer::MakeWindow instead of duplicating code. Fixes a bug where subdoc view linkage was added to MakeWindow but not Show. r=jkeiser,sr=jst --- content/base/src/nsDocumentViewer.cpp | 51 ++------------------------- layout/base/nsDocumentViewer.cpp | 51 ++------------------------- 2 files changed, 4 insertions(+), 98 deletions(-) diff --git a/content/base/src/nsDocumentViewer.cpp b/content/base/src/nsDocumentViewer.cpp index 1173fcaa241c..84c7f2c4cf8a 100644 --- a/content/base/src/nsDocumentViewer.cpp +++ b/content/base/src/nsDocumentViewer.cpp @@ -1413,55 +1413,10 @@ DocumentViewerImpl::Show(void) nsRect tbounds; mParentWidget->GetBounds(tbounds); - float p2t; - mPresContext->GetPixelsToTwips(&p2t); - tbounds *= p2t; - - // Create the view manager - mViewManager = do_CreateInstance(kViewManagerCID); - NS_ENSURE_TRUE(mViewManager, NS_ERROR_NOT_AVAILABLE); - - // Initialize the view manager with an offset. This allows the - // viewmanager to manage a coordinate space offset from (0,0) - rv = mViewManager->Init(mDeviceContext); + rv = MakeWindow(mParentWidget, tbounds); if (NS_FAILED(rv)) return rv; - rv = mViewManager->SetWindowOffset(tbounds.x, tbounds.y); - if (NS_FAILED(rv)) - return rv; - - // Reset the bounds offset so the root view is set to 0,0. The - // offset is specified in nsIViewManager::Init above. - // Besides, layout will reset the root view to (0,0) during reflow, - // so changing it to 0,0 eliminates placing the root view in the - // wrong place initially. - tbounds.x = 0; - tbounds.y = 0; - - // Create a child window of the parent that is our "root - // view/window" Create a view - - nsIView *view = nsnull; - rv = CallCreateInstance(kViewCID, &view); - if (NS_FAILED(rv)) - return rv; - rv = view->Init(mViewManager, tbounds, nsnull); - if (NS_FAILED(rv)) - return rv; - - rv = view->CreateWidget(kWidgetCID, nsnull, - mParentWidget->GetNativeData(NS_NATIVE_WIDGET), - PR_TRUE, PR_FALSE); - - if (NS_FAILED(rv)) - return rv; - - // Setup hierarchical relationship in view manager - mViewManager->SetRootView(view); - - view->GetWidget(*getter_AddRefs(mWindow)); - if (mPresContext && mContainer) { nsCOMPtr linkHandler(do_GetInterface(mContainer)); @@ -1800,8 +1755,6 @@ DocumentViewerImpl::IsWebShellAFrameSet(nsIWebShell * aWebShell) return doesContainFrameSet; } - - nsresult DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, const nsRect& aBounds) @@ -1906,7 +1859,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, rv = view->CreateWidget(kWidgetCID, nsnull, containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET), PR_TRUE, PR_FALSE); - if (rv != NS_OK) + if (NS_FAILED(rv)) return rv; // Setup hierarchical relationship in view manager diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 1173fcaa241c..84c7f2c4cf8a 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1413,55 +1413,10 @@ DocumentViewerImpl::Show(void) nsRect tbounds; mParentWidget->GetBounds(tbounds); - float p2t; - mPresContext->GetPixelsToTwips(&p2t); - tbounds *= p2t; - - // Create the view manager - mViewManager = do_CreateInstance(kViewManagerCID); - NS_ENSURE_TRUE(mViewManager, NS_ERROR_NOT_AVAILABLE); - - // Initialize the view manager with an offset. This allows the - // viewmanager to manage a coordinate space offset from (0,0) - rv = mViewManager->Init(mDeviceContext); + rv = MakeWindow(mParentWidget, tbounds); if (NS_FAILED(rv)) return rv; - rv = mViewManager->SetWindowOffset(tbounds.x, tbounds.y); - if (NS_FAILED(rv)) - return rv; - - // Reset the bounds offset so the root view is set to 0,0. The - // offset is specified in nsIViewManager::Init above. - // Besides, layout will reset the root view to (0,0) during reflow, - // so changing it to 0,0 eliminates placing the root view in the - // wrong place initially. - tbounds.x = 0; - tbounds.y = 0; - - // Create a child window of the parent that is our "root - // view/window" Create a view - - nsIView *view = nsnull; - rv = CallCreateInstance(kViewCID, &view); - if (NS_FAILED(rv)) - return rv; - rv = view->Init(mViewManager, tbounds, nsnull); - if (NS_FAILED(rv)) - return rv; - - rv = view->CreateWidget(kWidgetCID, nsnull, - mParentWidget->GetNativeData(NS_NATIVE_WIDGET), - PR_TRUE, PR_FALSE); - - if (NS_FAILED(rv)) - return rv; - - // Setup hierarchical relationship in view manager - mViewManager->SetRootView(view); - - view->GetWidget(*getter_AddRefs(mWindow)); - if (mPresContext && mContainer) { nsCOMPtr linkHandler(do_GetInterface(mContainer)); @@ -1800,8 +1755,6 @@ DocumentViewerImpl::IsWebShellAFrameSet(nsIWebShell * aWebShell) return doesContainFrameSet; } - - nsresult DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, const nsRect& aBounds) @@ -1906,7 +1859,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, rv = view->CreateWidget(kWidgetCID, nsnull, containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET), PR_TRUE, PR_FALSE); - if (rv != NS_OK) + if (NS_FAILED(rv)) return rv; // Setup hierarchical relationship in view manager