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

This commit is contained in:
roc+%cs.cmu.edu 2003-02-22 21:48:39 +00:00
Родитель 4a4741d884
Коммит 1c6c3011c3
2 изменённых файлов: 4 добавлений и 98 удалений

Просмотреть файл

@ -1413,55 +1413,10 @@ DocumentViewerImpl::Show(void)
nsRect tbounds; nsRect tbounds;
mParentWidget->GetBounds(tbounds); mParentWidget->GetBounds(tbounds);
float p2t; rv = MakeWindow(mParentWidget, tbounds);
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);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return 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) { if (mPresContext && mContainer) {
nsCOMPtr<nsILinkHandler> linkHandler(do_GetInterface(mContainer)); nsCOMPtr<nsILinkHandler> linkHandler(do_GetInterface(mContainer));
@ -1800,8 +1755,6 @@ DocumentViewerImpl::IsWebShellAFrameSet(nsIWebShell * aWebShell)
return doesContainFrameSet; return doesContainFrameSet;
} }
nsresult nsresult
DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
const nsRect& aBounds) const nsRect& aBounds)
@ -1906,7 +1859,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
rv = view->CreateWidget(kWidgetCID, nsnull, rv = view->CreateWidget(kWidgetCID, nsnull,
containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET), containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET),
PR_TRUE, PR_FALSE); PR_TRUE, PR_FALSE);
if (rv != NS_OK) if (NS_FAILED(rv))
return rv; return rv;
// Setup hierarchical relationship in view manager // Setup hierarchical relationship in view manager

Просмотреть файл

@ -1413,55 +1413,10 @@ DocumentViewerImpl::Show(void)
nsRect tbounds; nsRect tbounds;
mParentWidget->GetBounds(tbounds); mParentWidget->GetBounds(tbounds);
float p2t; rv = MakeWindow(mParentWidget, tbounds);
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);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return 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) { if (mPresContext && mContainer) {
nsCOMPtr<nsILinkHandler> linkHandler(do_GetInterface(mContainer)); nsCOMPtr<nsILinkHandler> linkHandler(do_GetInterface(mContainer));
@ -1800,8 +1755,6 @@ DocumentViewerImpl::IsWebShellAFrameSet(nsIWebShell * aWebShell)
return doesContainFrameSet; return doesContainFrameSet;
} }
nsresult nsresult
DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
const nsRect& aBounds) const nsRect& aBounds)
@ -1906,7 +1859,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
rv = view->CreateWidget(kWidgetCID, nsnull, rv = view->CreateWidget(kWidgetCID, nsnull,
containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET), containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET),
PR_TRUE, PR_FALSE); PR_TRUE, PR_FALSE);
if (rv != NS_OK) if (NS_FAILED(rv))
return rv; return rv;
// Setup hierarchical relationship in view manager // Setup hierarchical relationship in view manager