Bug 233441. Make nsViewManager always have a root view, you can't change it. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2004-05-06 03:17:14 +00:00
Родитель 3bfbe6e239
Коммит e508d2a0ad
35 изменённых файлов: 114 добавлений и 414 удалений

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

@ -165,11 +165,7 @@ NS_IMETHODIMP nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument *aDoc, ns
nsIViewManager* viewManager = presShell->GetViewManager(); nsIViewManager* viewManager = presShell->GetViewManager();
if (!presContext || !viewManager) if (!presContext || !viewManager)
return NS_OK; return NS_OK;
nsIView *view = nsnull; nsIWidget* widget = viewManager->RootView()->GetWidget();
viewManager->GetRootView(view);
if (!view)
return NS_OK;
nsIWidget* widget = view->GetWidget();
if (!widget) if (!widget)
return NS_OK; return NS_OK;

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

@ -421,11 +421,7 @@ void nsDocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame)
} }
} }
else { else {
nsIView *view; viewBounds = vm->RootView()->GetBounds();
vm->GetRootView(view);
if (view) {
viewBounds = view->GetBounds();
}
} }
if (parentDoc) { // After first time thru loop if (parentDoc) { // After first time thru loop

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

@ -978,22 +978,4 @@ nsContentSink::StartLayout(PRBool aIsFrameset)
mRef = Substring(start, end); mRef = Substring(start, end);
} }
} }
if (!mRef.IsEmpty() || aIsFrameset) {
// Disable the scroll bars.
for (i = 0; i < ns; i++) {
nsIPresShell *shell = mDocument->GetShellAt(i);
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
nsIView* rootView = nsnull;
vm->GetRootView(rootView);
nsCOMPtr<nsIScrollableView> sview(do_QueryInterface(rootView));
if (sview) {
sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
}
}
}
}
} }

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

@ -456,7 +456,6 @@ protected:
// Class IDs // Class IDs
static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID);
static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID); static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
//------------------------------------------------------------------ //------------------------------------------------------------------
nsresult nsresult
@ -1653,11 +1652,7 @@ DocumentViewerImpl::SetEnableRendering(PRBool aOn)
if (mViewManager) { if (mViewManager) {
if (aOn) { if (aOn) {
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE); mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
nsIView* view; mViewManager->UpdateView(mViewManager->RootView(), NS_VMREFRESH_IMMEDIATE);
mViewManager->GetRootView(view); // views are not refCounted
if (view) {
mViewManager->UpdateView(view, NS_VMREFRESH_IMMEDIATE);
}
} }
else { else {
mViewManager->DisableRefresh(); mViewManager->DisableRefresh();
@ -1844,12 +1839,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
p2t = mPresContext->PixelsToTwips(); p2t = mPresContext->PixelsToTwips();
tbounds *= p2t; tbounds *= p2t;
// Initialize the view manager with an offset. This allows the viewmanager
// to manage a coordinate space offset from (0,0)
rv = mViewManager->Init(dx);
if (NS_FAILED(rv))
return rv;
// Reset the bounds offset so the root view is set to 0,0. The // Reset the bounds offset so the root view is set to 0,0. The
// offset is specified in nsIViewManager::Init above. // offset is specified in nsIViewManager::Init above.
// Besides, layout will reset the root view to (0,0) during reflow, // Besides, layout will reset the root view to (0,0) during reflow,
@ -1861,11 +1850,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
// Create a child window of the parent that is our "root view/window" // Create a child window of the parent that is our "root view/window"
// Create a view // Create a view
nsIView *view = nsnull;
rv = CallCreateInstance(kViewCID, &view);
if (NS_FAILED(rv))
return rv;
// if aParentWidget has a view, we'll hook our view manager up to its view tree // if aParentWidget has a view, we'll hook our view manager up to its view tree
void* clientData; void* clientData;
nsIView* containerView = nsnull; nsIView* containerView = nsnull;
@ -1908,10 +1892,13 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
} }
} }
rv = view->Init(mViewManager, tbounds, containerView); rv = mViewManager->Init(dx, containerView);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
nsIView* view = mViewManager->RootView();
mViewManager->ResizeView(view, tbounds);
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(mContainer)); nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(mContainer));
NS_ENSURE_TRUE(treeItem, NS_ERROR_FAILURE); NS_ENSURE_TRUE(treeItem, NS_ERROR_FAILURE);
PRInt32 itemType; PRInt32 itemType;
@ -1935,9 +1922,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
// Setup hierarchical relationship in view manager
mViewManager->SetRootView(view);
mWindow = view->GetWidget(); mWindow = view->GetWidget();
// This SetFocus is necessary so the Arrow Key and Page Key events // This SetFocus is necessary so the Arrow Key and Page Key events

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

@ -234,7 +234,6 @@ static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,nsIDeviceContext * aD
// Class IDs // Class IDs
static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID);
static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID); static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
static NS_DEFINE_IID(kDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID); static NS_DEFINE_IID(kDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
@ -2610,7 +2609,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
return rv; return rv;
} }
rv = aPO->mViewManager->Init(mPrt->mPrintDocDC); rv = aPO->mViewManager->Init(mPrt->mPrintDocDC, nsnull);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
delete aPO->mStyleSet; delete aPO->mStyleSet;
return rv; return rv;
@ -2659,12 +2658,8 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
nsRect tbounds = nsRect(0, 0, width, height); nsRect tbounds = nsRect(0, 0, width, height);
// Create a child window of the parent that is our "root view/window" aPO->mRootView = aPO->mViewManager->RootView();
rv = CallCreateInstance(kViewCID, &aPO->mRootView); rv = aPO->mViewManager->ResizeView(aPO->mRootView, tbounds);
if (NS_FAILED(rv)) {
return rv;
}
rv = (aPO->mRootView)->Init(aPO->mViewManager, tbounds, nsnull);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -2708,7 +2703,6 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
#endif // NS_PRINT_PREVIEW #endif // NS_PRINT_PREVIEW
// Setup hierarchical relationship in view manager // Setup hierarchical relationship in view manager
aPO->mViewManager->SetRootView(aPO->mRootView);
aPO->mPresShell->Init(aPO->mDocument, aPO->mPresContext, aPO->mPresShell->Init(aPO->mDocument, aPO->mPresContext,
aPO->mViewManager, aPO->mStyleSet, aPO->mViewManager, aPO->mStyleSet,
mPresContext->CompatibilityMode()); mPresContext->CompatibilityMode());
@ -4753,11 +4747,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out)
if (shell) { if (shell) {
nsIViewManager* vm = shell->GetViewManager(); nsIViewManager* vm = shell->GetViewManager();
if (vm) { if (vm) {
nsIView* root; vm->RootView()->List(out);
vm->GetRootView(root);
if (nsnull != root) {
root->List(out);
}
} }
} }
else { else {

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

@ -1584,11 +1584,7 @@ nsDocShell::SetZoom(float zoom)
if (scrollableView) if (scrollableView)
scrollableView->ComputeScrollOffsets(); scrollableView->ComputeScrollOffsets();
// get the root view vm->UpdateView(vm->RootView(), 0);
nsIView *rootView = nsnull; // views are not ref counted
vm->GetRootView(rootView);
if (rootView)
vm->UpdateView(rootView, 0);
return NS_OK; return NS_OK;
} }
@ -3269,13 +3265,8 @@ nsDocShell::GetVisibility(PRBool * aVisibility)
nsIViewManager* vm = presShell->GetViewManager(); nsIViewManager* vm = presShell->GetViewManager();
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
// get the root view
nsIView *view = nsnull; // views are not ref counted
NS_ENSURE_SUCCESS(vm->GetRootView(view), NS_ERROR_FAILURE);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
// if our root view is hidden, we are not visible // if our root view is hidden, we are not visible
if (view->GetVisibility() == nsViewVisibility_kHide) { if (vm->RootView()->GetVisibility() == nsViewVisibility_kHide) {
*aVisibility = PR_FALSE; *aVisibility = PR_FALSE;
return NS_OK; return NS_OK;
} }

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

@ -4279,29 +4279,6 @@ GlobalWindowImpl::GetObjectProperty(const PRUnichar *aProperty,
nsresult nsresult
GlobalWindowImpl::Activate() GlobalWindowImpl::Activate()
{ {
/*
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
if(treeOwnerAsWin)
treeOwnerAsWin->SetVisibility(PR_TRUE);
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsIViewManager* vm = presShell->GetViewManager();
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
nsIView* rootView;
vm->GetRootView(rootView);
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
nsIWidget* widget = rootView->GetWidget();
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
return widget->SetFocus();
*/
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin; nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin)); GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
if (treeOwnerAsWin) { if (treeOwnerAsWin) {
@ -4324,9 +4301,7 @@ GlobalWindowImpl::Activate()
nsIViewManager* vm = presShell->GetViewManager(); nsIViewManager* vm = presShell->GetViewManager();
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
nsIView *rootView; nsIView *rootView = vm->RootView();
vm->GetRootView(rootView);
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
// We're holding a STRONG REF to the widget to ensure it doesn't go away // We're holding a STRONG REF to the widget to ensure it doesn't go away
// during event processing // during event processing
@ -4353,9 +4328,7 @@ GlobalWindowImpl::Deactivate()
nsIViewManager* vm = presShell->GetViewManager(); nsIViewManager* vm = presShell->GetViewManager();
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
nsIView *rootView; nsIView *rootView = vm->RootView();
vm->GetRootView(rootView);
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
// Hold a STRONG REF to keep the widget around during event processing // Hold a STRONG REF to keep the widget around during event processing
nsCOMPtr<nsIWidget> widget = rootView->GetWidget(); nsCOMPtr<nsIWidget> widget = rootView->GetWidget();
@ -5696,9 +5669,7 @@ nsGlobalChromeWindow::SetCursor(const nsAString& aCursor)
nsIViewManager* vm = presShell->GetViewManager(); nsIViewManager* vm = presShell->GetViewManager();
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
nsIView *rootView; nsIView *rootView = vm->RootView();
vm->GetRootView(rootView);
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
nsIWidget* widget = rootView->GetWidget(); nsIWidget* widget = rootView->GetWidget();
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE); NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);

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

@ -1047,11 +1047,7 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
// begin hack repaint // begin hack repaint
nsIViewManager* viewmgr = ps->GetViewManager(); nsIViewManager* viewmgr = ps->GetViewManager();
if (viewmgr) { if (viewmgr) {
nsIView* view; viewmgr->UpdateView(viewmgr->RootView(),NS_VMREFRESH_IMMEDIATE);
viewmgr->GetRootView(view); // views are not refCounted
if (view) {
viewmgr->UpdateView(view,NS_VMREFRESH_IMMEDIATE);
}
} }
// end hack repaint // end hack repaint
#else #else
@ -1110,11 +1106,7 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
nsIViewManager* viewmgr = ps->GetViewManager(); nsIViewManager* viewmgr = ps->GetViewManager();
if (viewmgr) if (viewmgr)
{ {
nsIView* view; viewmgr->UpdateView(viewmgr->RootView(),NS_VMREFRESH_IMMEDIATE);
viewmgr->GetRootView(view); // views are not refCounted
if (view) {
viewmgr->UpdateView(view,NS_VMREFRESH_IMMEDIATE);
}
} }
// end hack repaint // end hack repaint
#else #else

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

@ -139,15 +139,9 @@ inLayoutUtils::GetClientOrigin(nsIPresContext* aPresContext,
nsPoint result(0,0); nsPoint result(0,0);
nsIView* view; nsIView* view;
aFrame->GetOffsetFromView(aPresContext, result, &view); aFrame->GetOffsetFromView(aPresContext, result, &view);
nsIView* rootView = nsnull;
if (view) {
nsIViewManager* viewManager = view->GetViewManager();
NS_ASSERTION(viewManager, "View must have a viewmanager");
viewManager->GetRootView(rootView);
}
while (view) { while (view) {
result += view->GetPosition(); result += view->GetPosition();
if (view == rootView) { if (view->ExternalIsRoot()) {
break; break;
} }
view = view->GetParent(); view = view->GetParent();

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

@ -473,11 +473,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out)
fprintf(out, "docshell=%p \n", NS_STATIC_CAST(void*, aDocShell)); fprintf(out, "docshell=%p \n", NS_STATIC_CAST(void*, aDocShell));
nsCOMPtr<nsIViewManager> vm(view_manager(aDocShell)); nsCOMPtr<nsIViewManager> vm(view_manager(aDocShell));
if (vm) { if (vm) {
nsIView* root; vm->RootView()->List(out);
vm->GetRootView(root);
if (nsnull != root) {
root->List(out);
}
} }
else { else {
fputs("null view manager\n", out); fputs("null view manager\n", out);
@ -564,11 +560,7 @@ void nsLayoutDebuggingTools::ForceRefresh()
nsCOMPtr<nsIViewManager> vm(view_manager(mDocShell)); nsCOMPtr<nsIViewManager> vm(view_manager(mDocShell));
if (!vm) if (!vm)
return; return;
nsIView* root = nsnull; vm->UpdateView(vm->RootView(), NS_VMREFRESH_IMMEDIATE);
vm->GetRootView(root);
if (root) {
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
}
} }
nsresult nsresult

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

@ -3645,9 +3645,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
// Bind the viewport frame to the root view // Bind the viewport frame to the root view
nsIViewManager* viewManager = aPresContext->GetViewManager(); nsIViewManager* viewManager = aPresContext->GetViewManager();
nsIView* rootView; nsIView* rootView = viewManager->RootView();
viewManager->GetRootView(rootView);
viewportFrame->SetView(rootView); viewportFrame->SetView(rootView);
nsContainerFrame::SyncFrameViewProperties(aPresContext, viewportFrame, nsContainerFrame::SyncFrameViewProperties(aPresContext, viewportFrame,

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

@ -2754,8 +2754,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
nsIViewManager* vm = aPresContext->GetViewManager(); nsIViewManager* vm = aPresContext->GetViewManager();
if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) { if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
nsIView* rootView; nsIView* rootView = vm->RootView();
vm->GetRootView(rootView);
if (!rootView->GetParent()) { if (!rootView->GetParent()) {
PRBool widgetIsTranslucent = PR_FALSE; PRBool widgetIsTranslucent = PR_FALSE;

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

@ -456,7 +456,6 @@ protected:
// Class IDs // Class IDs
static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID);
static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID); static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
//------------------------------------------------------------------ //------------------------------------------------------------------
nsresult nsresult
@ -1653,11 +1652,7 @@ DocumentViewerImpl::SetEnableRendering(PRBool aOn)
if (mViewManager) { if (mViewManager) {
if (aOn) { if (aOn) {
mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE); mViewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
nsIView* view; mViewManager->UpdateView(mViewManager->RootView(), NS_VMREFRESH_IMMEDIATE);
mViewManager->GetRootView(view); // views are not refCounted
if (view) {
mViewManager->UpdateView(view, NS_VMREFRESH_IMMEDIATE);
}
} }
else { else {
mViewManager->DisableRefresh(); mViewManager->DisableRefresh();
@ -1844,12 +1839,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
p2t = mPresContext->PixelsToTwips(); p2t = mPresContext->PixelsToTwips();
tbounds *= p2t; tbounds *= p2t;
// Initialize the view manager with an offset. This allows the viewmanager
// to manage a coordinate space offset from (0,0)
rv = mViewManager->Init(dx);
if (NS_FAILED(rv))
return rv;
// Reset the bounds offset so the root view is set to 0,0. The // Reset the bounds offset so the root view is set to 0,0. The
// offset is specified in nsIViewManager::Init above. // offset is specified in nsIViewManager::Init above.
// Besides, layout will reset the root view to (0,0) during reflow, // Besides, layout will reset the root view to (0,0) during reflow,
@ -1861,11 +1850,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
// Create a child window of the parent that is our "root view/window" // Create a child window of the parent that is our "root view/window"
// Create a view // Create a view
nsIView *view = nsnull;
rv = CallCreateInstance(kViewCID, &view);
if (NS_FAILED(rv))
return rv;
// if aParentWidget has a view, we'll hook our view manager up to its view tree // if aParentWidget has a view, we'll hook our view manager up to its view tree
void* clientData; void* clientData;
nsIView* containerView = nsnull; nsIView* containerView = nsnull;
@ -1908,10 +1892,13 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
} }
} }
rv = view->Init(mViewManager, tbounds, containerView); rv = mViewManager->Init(dx, containerView);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
nsIView* view = mViewManager->RootView();
mViewManager->ResizeView(view, tbounds);
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(mContainer)); nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(mContainer));
NS_ENSURE_TRUE(treeItem, NS_ERROR_FAILURE); NS_ENSURE_TRUE(treeItem, NS_ERROR_FAILURE);
PRInt32 itemType; PRInt32 itemType;
@ -1935,9 +1922,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
// Setup hierarchical relationship in view manager
mViewManager->SetRootView(view);
mWindow = view->GetWidget(); mWindow = view->GetWidget();
// This SetFocus is necessary so the Arrow Key and Page Key events // This SetFocus is necessary so the Arrow Key and Page Key events

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

@ -208,7 +208,6 @@ static void ColorToString(nscolor aColor, nsAutoString &aString);
// Class ID's // Class ID's
static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID); static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
#undef NOISY #undef NOISY
@ -5805,9 +5804,7 @@ PresShell::HandleEvent(nsIView *aView,
// from the root views widget. This is necessary to prevent us from // from the root views widget. This is necessary to prevent us from
// dispatching the SysColorChanged notification for each child window // dispatching the SysColorChanged notification for each child window
// which may be redundant. // which may be redundant.
nsIView *view; if (aView->IsRoot()) {
vm->GetRootView(view);
if (view == aView) {
aHandled = PR_TRUE; aHandled = PR_TRUE;
*aEventStatus = nsEventStatus_eConsumeDoDefault; *aEventStatus = nsEventStatus_eConsumeDoDefault;
return mPresContext->SysColorChanged(); return mPresContext->SysColorChanged();
@ -6434,9 +6431,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
if (GetVerifyReflowEnable()) { if (GetVerifyReflowEnable()) {
// First synchronously render what we have so far so that we can // First synchronously render what we have so far so that we can
// see it. // see it.
nsIView* rootView; mViewManager->UpdateView(mViewManager->RootView(), NS_VMREFRESH_IMMEDIATE);
mViewManager->GetRootView(rootView);
mViewManager->UpdateView(rootView, NS_VMREFRESH_IMMEDIATE);
mInVerifyReflow = PR_TRUE; mInVerifyReflow = PR_TRUE;
PRBool ok = VerifyIncrementalReflow(); PRBool ok = VerifyIncrementalReflow();
@ -7023,44 +7018,28 @@ PresShell::VerifyIncrementalReflow()
rv = cx->Init(dc); rv = cx->Init(dc);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// Get our scrolling preference void* nativeParentWidget = mViewManager->RootView()->GetWidget()
nsScrollPreference scrolling; ->GetNativeData(NS_NATIVE_WIDGET);
nsIView* rootView;
mViewManager->GetRootView(rootView);
nsIScrollableView* scrollView;
rv = rootView->QueryInterface(NS_GET_IID(nsIScrollableView),
(void**)&scrollView);
if (NS_SUCCEEDED (rv)) {
scrollView->GetScrollPreference(scrolling);
}
void* nativeParentWidget = rootView->GetWidget()->GetNativeData(NS_NATIVE_WIDGET);
// Create a new view manager. // Create a new view manager.
rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull,
NS_GET_IID(nsIViewManager), NS_GET_IID(nsIViewManager),
(void**) &vm); (void**) &vm);
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create view manager"); NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create view manager");
rv = vm->Init(dc); rv = vm->Init(dc, nsnull);
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to init view manager"); NS_ASSERTION(NS_SUCCEEDED (rv), "failed to init view manager");
// Create a child window of the parent that is our "root view/window" // Create a child window of the parent that is our "root view/window"
// Create a view // Create a view
nsRect tbounds = mPresContext->GetVisibleArea(); nsRect tbounds = mPresContext->GetVisibleArea();
nsIView* view;
rv = nsComponentManager::CreateInstance(kViewCID, nsnull,
NS_GET_IID(nsIView),
(void **) &view);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view"); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view");
rv = view->Init(vm, tbounds, nsnull); rv = vm->ResizeView(vm->RootView(), tbounds);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to init scroll view"); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to init scroll view");
//now create the widget for the view //now create the widget for the view
rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget, PR_TRUE); rv = vm->RootView()->CreateWidget(kWidgetCID, nsnull, nativeParentWidget, PR_TRUE);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view widget"); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view widget");
// Setup hierarchical relationship in view manager
vm->SetRootView(view);
// Make the new presentation context the same size as our // Make the new presentation context the same size as our
// presentation context. // presentation context.
nsRect r = mPresContext->GetVisibleArea(); nsRect r = mPresContext->GetVisibleArea();

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

@ -601,8 +601,7 @@ SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext,
aView->SetHasUniformBackground(drawnOnUniformField); aView->SetHasUniformBackground(drawnOnUniformField);
if (isCanvas) { if (isCanvas) {
nsIView* rootView; nsIView* rootView = vm->RootView();
vm->GetRootView(rootView);
nsIView* rootParent = rootView->GetParent(); nsIView* rootParent = rootView->GetParent();
if (!rootParent) { if (!rootParent) {
// We're the root of a view manager hierarchy. We will have to // We're the root of a view manager hierarchy. We will have to

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

@ -1512,11 +1512,7 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext* aPresContext,
// Update the view immediately (make drag appear snappier) // Update the view immediately (make drag appear snappier)
nsIViewManager* vm = aPresContext->GetViewManager(); nsIViewManager* vm = aPresContext->GetViewManager();
if (vm) { if (vm) {
nsIView* root; vm->UpdateView(vm->RootView(), NS_VMREFRESH_IMMEDIATE);
vm->GetRootView(root);
if (root) {
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
}
} }
} }
} }

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

@ -1766,10 +1766,7 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
// first, lets find out how big the window is, in pixels // first, lets find out how big the window is, in pixels
nsIViewManager* vm = aPresContext->GetViewManager(); nsIViewManager* vm = aPresContext->GetViewManager();
if (vm) { if (vm) {
nsIView* view; nsIWidget* win = vm->RootView()->GetWidget();
vm->GetRootView(view);
if (view) {
nsIWidget* win = view->GetWidget();
if (win) { if (win) {
nsRect visibleRect; nsRect visibleRect;
win->GetBounds(visibleRect); win->GetBounds(visibleRect);
@ -1802,7 +1799,6 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
} }
} }
} }
}
#endif #endif
inst->SetWindow(window); inst->SetWindow(window);

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

@ -601,8 +601,7 @@ SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext,
aView->SetHasUniformBackground(drawnOnUniformField); aView->SetHasUniformBackground(drawnOnUniformField);
if (isCanvas) { if (isCanvas) {
nsIView* rootView; nsIView* rootView = vm->RootView();
vm->GetRootView(rootView);
nsIView* rootParent = rootView->GetParent(); nsIView* rootParent = rootView->GetParent();
if (!rootParent) { if (!rootParent) {
// We're the root of a view manager hierarchy. We will have to // We're the root of a view manager hierarchy. We will have to

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

@ -1766,10 +1766,7 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
// first, lets find out how big the window is, in pixels // first, lets find out how big the window is, in pixels
nsIViewManager* vm = aPresContext->GetViewManager(); nsIViewManager* vm = aPresContext->GetViewManager();
if (vm) { if (vm) {
nsIView* view; nsIWidget* win = vm->RootView()->GetWidget();
vm->GetRootView(view);
if (view) {
nsIWidget* win = view->GetWidget();
if (win) { if (win) {
nsRect visibleRect; nsRect visibleRect;
win->GetBounds(visibleRect); win->GetBounds(visibleRect);
@ -1802,7 +1799,6 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
} }
} }
} }
}
#endif #endif
inst->SetWindow(window); inst->SetWindow(window);

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

@ -208,7 +208,6 @@ static void ColorToString(nscolor aColor, nsAutoString &aString);
// Class ID's // Class ID's
static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID); static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
#undef NOISY #undef NOISY
@ -5805,9 +5804,7 @@ PresShell::HandleEvent(nsIView *aView,
// from the root views widget. This is necessary to prevent us from // from the root views widget. This is necessary to prevent us from
// dispatching the SysColorChanged notification for each child window // dispatching the SysColorChanged notification for each child window
// which may be redundant. // which may be redundant.
nsIView *view; if (aView->IsRoot()) {
vm->GetRootView(view);
if (view == aView) {
aHandled = PR_TRUE; aHandled = PR_TRUE;
*aEventStatus = nsEventStatus_eConsumeDoDefault; *aEventStatus = nsEventStatus_eConsumeDoDefault;
return mPresContext->SysColorChanged(); return mPresContext->SysColorChanged();
@ -6434,9 +6431,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
if (GetVerifyReflowEnable()) { if (GetVerifyReflowEnable()) {
// First synchronously render what we have so far so that we can // First synchronously render what we have so far so that we can
// see it. // see it.
nsIView* rootView; mViewManager->UpdateView(mViewManager->RootView(), NS_VMREFRESH_IMMEDIATE);
mViewManager->GetRootView(rootView);
mViewManager->UpdateView(rootView, NS_VMREFRESH_IMMEDIATE);
mInVerifyReflow = PR_TRUE; mInVerifyReflow = PR_TRUE;
PRBool ok = VerifyIncrementalReflow(); PRBool ok = VerifyIncrementalReflow();
@ -7023,44 +7018,28 @@ PresShell::VerifyIncrementalReflow()
rv = cx->Init(dc); rv = cx->Init(dc);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// Get our scrolling preference void* nativeParentWidget = mViewManager->RootView()->GetWidget()
nsScrollPreference scrolling; ->GetNativeData(NS_NATIVE_WIDGET);
nsIView* rootView;
mViewManager->GetRootView(rootView);
nsIScrollableView* scrollView;
rv = rootView->QueryInterface(NS_GET_IID(nsIScrollableView),
(void**)&scrollView);
if (NS_SUCCEEDED (rv)) {
scrollView->GetScrollPreference(scrolling);
}
void* nativeParentWidget = rootView->GetWidget()->GetNativeData(NS_NATIVE_WIDGET);
// Create a new view manager. // Create a new view manager.
rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull,
NS_GET_IID(nsIViewManager), NS_GET_IID(nsIViewManager),
(void**) &vm); (void**) &vm);
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create view manager"); NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create view manager");
rv = vm->Init(dc); rv = vm->Init(dc, nsnull);
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to init view manager"); NS_ASSERTION(NS_SUCCEEDED (rv), "failed to init view manager");
// Create a child window of the parent that is our "root view/window" // Create a child window of the parent that is our "root view/window"
// Create a view // Create a view
nsRect tbounds = mPresContext->GetVisibleArea(); nsRect tbounds = mPresContext->GetVisibleArea();
nsIView* view;
rv = nsComponentManager::CreateInstance(kViewCID, nsnull,
NS_GET_IID(nsIView),
(void **) &view);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view"); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view");
rv = view->Init(vm, tbounds, nsnull); rv = vm->ResizeView(vm->RootView(), tbounds);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to init scroll view"); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to init scroll view");
//now create the widget for the view //now create the widget for the view
rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget, PR_TRUE); rv = vm->RootView()->CreateWidget(kWidgetCID, nsnull, nativeParentWidget, PR_TRUE);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view widget"); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view widget");
// Setup hierarchical relationship in view manager
vm->SetRootView(view);
// Make the new presentation context the same size as our // Make the new presentation context the same size as our
// presentation context. // presentation context.
nsRect r = mPresContext->GetVisibleArea(); nsRect r = mPresContext->GetVisibleArea();

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

@ -1512,11 +1512,7 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext* aPresContext,
// Update the view immediately (make drag appear snappier) // Update the view immediately (make drag appear snappier)
nsIViewManager* vm = aPresContext->GetViewManager(); nsIViewManager* vm = aPresContext->GetViewManager();
if (vm) { if (vm) {
nsIView* root; vm->UpdateView(vm->RootView(), NS_VMREFRESH_IMMEDIATE);
vm->GetRootView(root);
if (root) {
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
}
} }
} }
} }

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

@ -3645,9 +3645,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
// Bind the viewport frame to the root view // Bind the viewport frame to the root view
nsIViewManager* viewManager = aPresContext->GetViewManager(); nsIViewManager* viewManager = aPresContext->GetViewManager();
nsIView* rootView; nsIView* rootView = viewManager->RootView();
viewManager->GetRootView(rootView);
viewportFrame->SetView(rootView); viewportFrame->SetView(rootView);
nsContainerFrame::SyncFrameViewProperties(aPresContext, viewportFrame, nsContainerFrame::SyncFrameViewProperties(aPresContext, viewportFrame,

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

@ -2754,8 +2754,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
nsIViewManager* vm = aPresContext->GetViewManager(); nsIViewManager* vm = aPresContext->GetViewManager();
if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) { if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
nsIView* rootView; nsIView* rootView = vm->RootView();
vm->GetRootView(rootView);
if (!rootView->GetParent()) { if (!rootView->GetParent()) {
PRBool widgetIsTranslucent = PR_FALSE; PRBool widgetIsTranslucent = PR_FALSE;

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

@ -478,17 +478,9 @@ GeometryTest::GeometryTest(BasicTest *aDoc)
fprintf(out, "bad view manager"); fprintf(out, "bad view manager");
NS_ASSERTION(PR_FALSE, "bad view manager"); NS_ASSERTION(PR_FALSE, "bad view manager");
} }
vm->Init(pc); vm->Init(pc, nsnull);
nsIView * rootView = nsnull; nsIView * rootView = vm->GetRootView();
// Create a view
static NS_DEFINE_IID(kScrollingViewCID, NS_SCROLL_PORT_VIEW_CID);
status = nsComponentManager::CreateInstance(kScrollingViewCID,
nsnull,
NS_GET_IID(nsIView),
(void **)&rootView);
if ((NS_FAILED(status)) || nsnull==rootView) if ((NS_FAILED(status)) || nsnull==rootView)
{ {
@ -496,9 +488,7 @@ GeometryTest::GeometryTest(BasicTest *aDoc)
NS_ASSERTION(PR_FALSE, "bad view"); NS_ASSERTION(PR_FALSE, "bad view");
} }
nsRect bounds(0, 0, 10000, 10000); nsRect bounds(0, 0, 10000, 10000);
rootView->Init(vm, bounds, nsnull); vm->ResizeView(rootView, bounds);
vm->SetRootView(rootView);
nsCOMPtr<nsIStyleSet> ss(do_CreateInstance(kStyleSetCID,&status)); nsCOMPtr<nsIStyleSet> ss(do_CreateInstance(kStyleSetCID,&status));
if ((NS_FAILED(status))) if ((NS_FAILED(status)))
@ -566,7 +556,7 @@ void GeometryTest::CreateGeometry(BasicTest * aDoc, nsIPresContext *aPC)
fprintf(out, "bad view manager"); fprintf(out, "bad view manager");
NS_ASSERTION(PR_FALSE, ""); NS_ASSERTION(PR_FALSE, "");
} }
nsIView* rootView = mViewManager->GetRootView(); nsIView* rootView = mViewManager->RootView();
NS_ASSERTION(nsnull!=rootView, "bad root view"); NS_ASSERTION(nsnull!=rootView, "bad root view");
mRootFrame->SetView(rootView); mRootFrame->SetView(rootView);
NS_RELEASE(rootView); NS_RELEASE(rootView);

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

@ -234,7 +234,6 @@ static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,nsIDeviceContext * aD
// Class IDs // Class IDs
static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID);
static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID); static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
static NS_DEFINE_IID(kDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID); static NS_DEFINE_IID(kDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
@ -2610,7 +2609,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
return rv; return rv;
} }
rv = aPO->mViewManager->Init(mPrt->mPrintDocDC); rv = aPO->mViewManager->Init(mPrt->mPrintDocDC, nsnull);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
delete aPO->mStyleSet; delete aPO->mStyleSet;
return rv; return rv;
@ -2659,12 +2658,8 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
nsRect tbounds = nsRect(0, 0, width, height); nsRect tbounds = nsRect(0, 0, width, height);
// Create a child window of the parent that is our "root view/window" aPO->mRootView = aPO->mViewManager->RootView();
rv = CallCreateInstance(kViewCID, &aPO->mRootView); rv = aPO->mViewManager->ResizeView(aPO->mRootView, tbounds);
if (NS_FAILED(rv)) {
return rv;
}
rv = (aPO->mRootView)->Init(aPO->mViewManager, tbounds, nsnull);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -2708,7 +2703,6 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
#endif // NS_PRINT_PREVIEW #endif // NS_PRINT_PREVIEW
// Setup hierarchical relationship in view manager // Setup hierarchical relationship in view manager
aPO->mViewManager->SetRootView(aPO->mRootView);
aPO->mPresShell->Init(aPO->mDocument, aPO->mPresContext, aPO->mPresShell->Init(aPO->mDocument, aPO->mPresContext,
aPO->mViewManager, aPO->mStyleSet, aPO->mViewManager, aPO->mStyleSet,
mPresContext->CompatibilityMode()); mPresContext->CompatibilityMode());
@ -4753,11 +4747,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out)
if (shell) { if (shell) {
nsIViewManager* vm = shell->GetViewManager(); nsIViewManager* vm = shell->GetViewManager();
if (vm) { if (vm) {
nsIView* root; vm->RootView()->List(out);
vm->GetRootView(root);
if (nsnull != root) {
root->List(out);
}
} }
} }
else { else {

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

@ -190,8 +190,7 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext,
viewManager->RemoveChild(ourView); viewManager->RemoveChild(ourView);
// Reinsert ourselves as the root view with a maximum z-index. // Reinsert ourselves as the root view with a maximum z-index.
nsIView* rootView; nsIView* rootView = viewManager->RootView();
viewManager->GetRootView(rootView);
viewManager->SetViewZIndex(ourView, PR_FALSE, kMaxZ); viewManager->SetViewZIndex(ourView, PR_FALSE, kMaxZ);
viewManager->InsertChild(rootView, ourView, nsnull, PR_TRUE); viewManager->InsertChild(rootView, ourView, nsnull, PR_TRUE);
@ -415,8 +414,7 @@ nsMenuPopupFrame::GetViewOffset(nsIView* aView, nsPoint& aPoint)
aPoint.y = 0; aPoint.y = 0;
// Keep track of the root view so that we know to stop there // Keep track of the root view so that we know to stop there
nsIView* rootView; nsIView* rootView = aView->GetViewManager()->RootView();
aView->GetViewManager()->GetRootView(rootView);
nsIView *parent; nsIView *parent;
@ -490,7 +488,7 @@ nsMenuPopupFrame::GetRootViewForPopup(nsIPresContext* aPresContext,
if (view) { if (view) {
nsIView* rootView = nsnull; nsIView* rootView = nsnull;
if (aStopAtViewManagerRoot) { if (aStopAtViewManagerRoot) {
view->GetViewManager()->GetRootView(rootView); rootView = view->GetViewManager()->RootView();
} }
while (view) { while (view) {
@ -561,9 +559,7 @@ nsMenuPopupFrame::AdjustClientXYForNestedDocuments ( nsIDOMXULDocument* inPopupD
nsIWidget* popupDocumentWidget = nsnull; nsIWidget* popupDocumentWidget = nsnull;
nsIViewManager* viewManager = inPopupShell->GetViewManager(); nsIViewManager* viewManager = inPopupShell->GetViewManager();
if ( viewManager ) { if ( viewManager ) {
nsIView* rootView; nsIView* rootView = viewManager->RootView();
viewManager->GetRootView(rootView);
if ( rootView )
popupDocumentWidget = rootView->GetNearestWidget(nsnull); popupDocumentWidget = rootView->GetNearestWidget(nsnull);
} }
NS_WARN_IF_FALSE(popupDocumentWidget, "ACK, BAD WIDGET"); NS_WARN_IF_FALSE(popupDocumentWidget, "ACK, BAD WIDGET");
@ -605,11 +601,8 @@ nsMenuPopupFrame::AdjustClientXYForNestedDocuments ( nsIDOMXULDocument* inPopupD
// widget. // widget.
nsIViewManager* viewManagerTarget = shell->GetViewManager(); nsIViewManager* viewManagerTarget = shell->GetViewManager();
if ( viewManagerTarget ) { if ( viewManagerTarget ) {
nsIView* rootViewTarget; nsIView* rootViewTarget = viewManagerTarget->RootView();
viewManagerTarget->GetRootView(rootViewTarget);
if ( rootViewTarget ) {
targetDocumentWidget = rootViewTarget->GetNearestWidget(nsnull); targetDocumentWidget = rootViewTarget->GetNearestWidget(nsnull);
}
} }
} }
} }

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

@ -183,10 +183,8 @@ public:
* *
* The view destroys its child views, and destroys and releases its * The view destroys its child views, and destroys and releases its
* widget (if it has one). * widget (if it has one).
*
* Also informs the view manager that the view is destroyed by calling * Also informs the view manager that the view is destroyed by calling
* SetRootView(NULL) if the view is the root view and calling RemoveChild() * RemoveChild() if the view is not the root view.
* otherwise.
*/ */
void Destroy(); void Destroy();

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

@ -50,6 +50,7 @@ struct nsRect;
class nsRegion; class nsRegion;
class nsIDeviceContext; class nsIDeviceContext;
class nsIViewObserver; class nsIViewObserver;
class nsView;
enum nsRectVisibility { enum nsRectVisibility {
nsRectVisibility_kVisible, nsRectVisibility_kVisible,
@ -70,35 +71,20 @@ class nsIViewManager : public nsISupports
public: public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID) NS_DEFINE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID)
/** /**
* Initialize the ViewManager * Initialize the ViewManager
* Note: this instance does not hold a reference to the viewobserver * Note: this instance does not hold a reference to the viewobserver
* because it holds a reference to this instance. * because it holds a reference to this instance.
* @result The result of the initialization, NS_OK if no errors * This constructs the root view with the given parent.
*/ */
NS_IMETHOD Init(nsIDeviceContext* aContext) = 0; virtual nsresult Init(nsIDeviceContext* aContext, nsIView *aParent) = 0;
/** /**
* Get the root of the view tree. * Get the root of the view tree.
* @result the root view * @result the root view
*/ */
NS_IMETHOD GetRootView(nsIView *&aView) = 0; nsIView* RootView() { return mRootView; }
/**
* Set the root of the view tree. Does not destroy the current root view.
* aView may have a parent view managed by a different view manager.
* aView may have a widget (anything but printing) or may not (printing).
* @param aView view to set as root
*/
NS_IMETHOD SetRootView(nsIView *aView) = 0;
/**
* Get the dimensions of the root window. The dimensions are in
* twips
* @param aWidth out parameter for width of window in twips
* @param aHeight out parameter for height of window in twips
*/
NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) = 0;
/** /**
* Set the dimensions of the root window. * Set the dimensions of the root window.
@ -510,6 +496,8 @@ public:
PRUint16 aMinTwips, PRUint16 aMinTwips,
nsRectVisibility *aRectVisibility)=0; nsRectVisibility *aRectVisibility)=0;
protected:
nsIView* mRootView;
}; };
//update view now? //update view now?

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

@ -125,27 +125,12 @@ nsView::~nsView()
if (mViewManager) if (mViewManager)
{ {
nsView *rootView = mViewManager->GetRootView();
if (rootView)
{
// Root views can have parents! // Root views can have parents!
if (mParent) if (mParent)
{ {
mViewManager->RemoveChild(this); mViewManager->RemoveChild(this);
} }
if (rootView == this)
{
// Inform the view manager that the root view has gone away...
mViewManager->SetRootView(nsnull);
}
}
else if (mParent)
{
mParent->RemoveChild(this);
}
mViewManager = nsnull; mViewManager = nsnull;
} }
else if (mParent) else if (mParent)
@ -249,7 +234,12 @@ nsresult nsIView::Init(nsIViewManager* aManager,
void nsIView::Destroy() void nsIView::Destroy()
{ {
delete this; // We don't want to tear down the root view when the viewport frame
// (which has the root view as its view) goes away. The root view will
// be deleted when the view manager dies.
if (!IsRoot()) {
delete this;
}
} }
NS_IMETHODIMP nsView::Paint(nsIRenderingContext& rc, const nsRect& rect, NS_IMETHODIMP nsView::Paint(nsIRenderingContext& rc, const nsRect& rect,
@ -749,7 +739,7 @@ nsresult nsView::GetDirtyRegion(nsIRegion*& aRegion)
PRBool nsIView::IsRoot() const PRBool nsIView::IsRoot() const
{ {
NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()"); NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()");
return mViewManager->GetRootView() == this; return mViewManager->RootView() == this;
} }
PRBool nsIView::ExternalIsRoot() const PRBool nsIView::ExternalIsRoot() const

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

@ -447,9 +447,9 @@ nsViewManager::nsViewManager()
nsViewManager::~nsViewManager() nsViewManager::~nsViewManager()
{ {
if (mRootView) { if (RootView()) {
// Destroy any remaining views // Destroy any remaining views
mRootView->Destroy(); delete RootView();
mRootView = nsnull; mRootView = nsnull;
} }
@ -538,7 +538,7 @@ nsViewManager::CreateRegion(nsIRegion* *result)
// We don't hold a reference to the presentation context because it // We don't hold a reference to the presentation context because it
// holds a reference to us. // holds a reference to us.
NS_IMETHODIMP nsViewManager::Init(nsIDeviceContext* aContext) nsresult nsViewManager::Init(nsIDeviceContext* aContext, nsIView* aParent)
{ {
NS_PRECONDITION(nsnull != aContext, "null ptr"); NS_PRECONDITION(nsnull != aContext, "null ptr");
@ -557,68 +557,34 @@ NS_IMETHODIMP nsViewManager::Init(nsIDeviceContext* aContext)
mMouseGrabber = nsnull; mMouseGrabber = nsnull;
mKeyGrabber = nsnull; mKeyGrabber = nsnull;
mRootView = new nsView();
if (!mRootView) {
return NS_ERROR_OUT_OF_MEMORY;
}
mRootView->Init(this, nsRect(0, 0, 0, 0), aParent);
if (aParent) {
NS_STATIC_CAST(nsView*, aParent)->InsertChild(RootView(), nsnull);
}
if (nsnull == mEventQueueService) { if (nsnull == mEventQueueService) {
mEventQueueService = do_GetService(kEventQueueServiceCID); mEventQueueService = do_GetService(kEventQueueServiceCID);
NS_ASSERTION(mEventQueueService, "couldn't get event queue service"); NS_ASSERTION(mEventQueueService, "couldn't get event queue service");
} }
return NS_OK;
}
NS_IMETHODIMP nsViewManager::GetRootView(nsIView *&aView)
{
aView = mRootView;
return NS_OK;
}
NS_IMETHODIMP nsViewManager::SetRootView(nsIView *aView)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
// Do NOT destroy the current root view. It's the caller's responsibility
// to destroy it
mRootView = view;
if (mRootView) {
nsView* parent = mRootView->GetParent();
if (parent) {
parent->InsertChild(mRootView, nsnull);
}
mRootView->SetZIndex(PR_FALSE, 0, PR_FALSE);
}
return NS_OK;
}
NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight)
{
if (nsnull != mRootView) {
nsRect dim;
mRootView->GetDimensions(dim);
*aWidth = dim.width;
*aHeight = dim.height;
}
else
{
*aWidth = 0;
*aHeight = 0;
}
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight)
{ {
// Resize the root view // Resize the root view
if (nsnull != mRootView) {
nsRect dim(0, 0, aWidth, aHeight); nsRect dim(0, 0, aWidth, aHeight);
mRootView->SetDimensions(dim); RootView()->SetDimensions(dim);
}
//printf("new dims: %d %d\n", aWidth, aHeight); //printf("new dims: %d %d\n", aWidth, aHeight);
// Inform the presentation shell that we've been resized // Inform the presentation shell that we've been resized
if (nsnull != mObserver) if (nsnull != mObserver)
mObserver->ResizeReflow(mRootView, aWidth, aHeight); mObserver->ResizeReflow(RootView(), aWidth, aHeight);
//printf("reflow done\n"); //printf("reflow done\n");
return NS_OK; return NS_OK;
@ -1573,7 +1539,7 @@ nsViewManager::UpdateViewAfterScroll(nsIView *aView, PRInt32 aDX, PRInt32 aDY)
return; return;
} }
nsView* realRoot = mRootView; nsView* realRoot = RootView();
while (realRoot->GetParent()) { while (realRoot->GetParent()) {
realRoot = realRoot->GetParent(); realRoot = realRoot->GetParent();
} }
@ -1717,7 +1683,7 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU
} else { } else {
damagedRect.MoveBy(ComputeViewOffset(view)); damagedRect.MoveBy(ComputeViewOffset(view));
nsView* realRoot = mRootView; nsView* realRoot = RootView();
while (realRoot->GetParent()) { while (realRoot->GetParent()) {
realRoot = realRoot->GetParent(); realRoot = realRoot->GetParent();
} }
@ -1741,7 +1707,7 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU
NS_IMETHODIMP nsViewManager::UpdateAllViews(PRUint32 aUpdateFlags) NS_IMETHODIMP nsViewManager::UpdateAllViews(PRUint32 aUpdateFlags)
{ {
UpdateViews(mRootView, aUpdateFlags); UpdateViews(RootView(), aUpdateFlags);
return NS_OK; return NS_OK;
} }
@ -1780,7 +1746,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
// The root view may not be set if this is the resize associated with // The root view may not be set if this is the resize associated with
// window creation // window creation
if (view == mRootView) if (view == RootView())
{ {
// Convert from pixels to twips // Convert from pixels to twips
float p2t; float p2t;
@ -1937,14 +1903,14 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
nsView *parent; nsView *parent;
parent = baseView; parent = baseView;
while (mRootView != parent) { while (RootView() != parent) {
parent->ConvertToParentCoords(&offset.x, &offset.y); parent->ConvertToParentCoords(&offset.x, &offset.y);
parent = parent->GetParent(); parent = parent->GetParent();
} }
//Subtract back offset from root of view //Subtract back offset from root of view
parent = view; parent = view;
while (mRootView != parent) { while (RootView() != parent) {
parent->ConvertFromParentCoords(&offset.x, &offset.y); parent->ConvertFromParentCoords(&offset.x, &offset.y);
parent = parent->GetParent(); parent = parent->GetParent();
} }
@ -2751,7 +2717,7 @@ PRBool nsViewManager::CanScrollWithBitBlt(nsView* aView)
if (IsAncestorOf(NS_STATIC_CAST(const nsView*, scrollableClipView), aView)) { if (IsAncestorOf(NS_STATIC_CAST(const nsView*, scrollableClipView), aView)) {
// add areas of fixed views to the opaque area. // add areas of fixed views to the opaque area.
// This is a bit of a hack. We should not be doing special case processing for fixed views. // This is a bit of a hack. We should not be doing special case processing for fixed views.
nsView* fixedView = mRootView->GetFirstChild(); nsView* fixedView = RootView()->GetFirstChild();
while (fixedView != nsnull) { while (fixedView != nsnull) {
if (fixedView->GetZParent() != nsnull && fixedView->GetZIndex() >= 0) { if (fixedView->GetZParent() != nsnull && fixedView->GetZIndex() >= 0) {
opaqueRegion.Or(opaqueRegion, fixedView->GetBounds()); opaqueRegion.Or(opaqueRegion, fixedView->GetBounds());
@ -2871,7 +2837,7 @@ NS_IMETHODIMP nsViewManager::SetViewVisibility(nsIView *aView, nsViewVisibility
PRBool nsViewManager::IsViewInserted(nsView *aView) PRBool nsViewManager::IsViewInserted(nsView *aView)
{ {
if (mRootView == aView) { if (RootView() == aView) {
return PR_TRUE; return PR_TRUE;
} else if (aView->GetParent() == nsnull) { } else if (aView->GetParent() == nsnull) {
return PR_FALSE; return PR_FALSE;
@ -2896,7 +2862,7 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, P
// don't allow the root view's z-index to be changed. It should always be zero. // don't allow the root view's z-index to be changed. It should always be zero.
// This could be removed and replaced with a style rule, or just removed altogether, with interesting consequences // This could be removed and replaced with a style rule, or just removed altogether, with interesting consequences
if (aView == mRootView) { if (aView == RootView()) {
return rv; return rv;
} }
@ -3097,7 +3063,7 @@ NS_IMETHODIMP nsViewManager::EnableRefresh(PRUint32 aUpdateFlags)
mRefreshEnabled = PR_TRUE; mRefreshEnabled = PR_TRUE;
if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) { if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) {
ProcessPendingUpdates(mRootView); ProcessPendingUpdates(RootView());
mHasPendingInvalidates = PR_FALSE; mHasPendingInvalidates = PR_FALSE;
Composite(); Composite();
} else { } else {
@ -3943,7 +3909,7 @@ nsViewManager::CacheWidgetChanges(PRBool aCache)
// if we turned it off. Then move and size all the widgets. // if we turned it off. Then move and size all the widgets.
if (mCachingWidgetChanges == 0) if (mCachingWidgetChanges == 0)
ProcessWidgetChanges(mRootView); ProcessWidgetChanges(RootView());
#endif #endif
return NS_OK; return NS_OK;
@ -3967,7 +3933,7 @@ NS_IMETHODIMP
nsViewManager::FlushPendingInvalidates() nsViewManager::FlushPendingInvalidates()
{ {
if (mHasPendingInvalidates) { if (mHasPendingInvalidates) {
ProcessPendingUpdates(mRootView); ProcessPendingUpdates(RootView());
mHasPendingInvalidates = PR_FALSE; mHasPendingInvalidates = PR_FALSE;
} }
return NS_OK; return NS_OK;

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

@ -123,12 +123,8 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext); virtual nsresult Init(nsIDeviceContext* aContext, nsIView* aParent);
NS_IMETHOD GetRootView(nsIView *&aView);
NS_IMETHOD SetRootView(nsIView *aView);
NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height);
NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height); NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height);
NS_IMETHOD ResetScrolling(void); NS_IMETHOD ResetScrolling(void);
@ -351,7 +347,7 @@ private:
void GetMaxWidgetBounds(nsRect& aMaxWidgetBounds) const; void GetMaxWidgetBounds(nsRect& aMaxWidgetBounds) const;
public: // NOT in nsIViewManager, so private to the view module public: // NOT in nsIViewManager, so private to the view module
nsView* GetRootView() const { return mRootView; } nsView* RootView() const { return NS_STATIC_CAST(nsView*, mRootView); }
nsView* GetMouseEventGrabber() const { return mMouseGrabber; } nsView* GetMouseEventGrabber() const { return mMouseGrabber; }
nsView* GetKeyEventGrabber() const { return mKeyGrabber; } nsView* GetKeyEventGrabber() const { return mKeyGrabber; }
@ -377,11 +373,11 @@ public: // NOT in nsIViewManager, so private to the view module
private: private:
nsIDeviceContext *mContext; nsIDeviceContext *mContext;
nsView *mMouseGrabber;
nsView *mKeyGrabber;
float mTwipsToPixels; float mTwipsToPixels;
float mPixelsToTwips; float mPixelsToTwips;
nsIViewObserver *mObserver; nsIViewObserver *mObserver;
nsView *mMouseGrabber;
nsView *mKeyGrabber;
PRInt32 mUpdateCnt; PRInt32 mUpdateCnt;
PRInt32 mUpdateBatchCnt; PRInt32 mUpdateBatchCnt;
nsIScrollableView *mRootScrollable; nsIScrollableView *mRootScrollable;
@ -391,7 +387,6 @@ private:
nsCOMPtr<nsIBlender> mBlender; nsCOMPtr<nsIBlender> mBlender;
nsISupportsArray *mCompositeListeners; nsISupportsArray *mCompositeListeners;
nsCOMPtr<nsIFactory> mRegionFactory; nsCOMPtr<nsIFactory> mRegionFactory;
nsView *mRootView;
nsCOMPtr<nsIEventQueueService> mEventQueueService; nsCOMPtr<nsIEventQueueService> mEventQueueService;
nsCOMPtr<nsIEventQueue> mInvalidateEventQueue; nsCOMPtr<nsIEventQueue> mInvalidateEventQueue;
PRPackedBool mRefreshEnabled; PRPackedBool mRefreshEnabled;

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

@ -1157,11 +1157,7 @@ NS_IMETHODIMP nsBrowserWindow::ForceRefresh()
nsCOMPtr<nsIViewManager> vm; nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm)); shell->GetViewManager(getter_AddRefs(vm));
if (vm) { if (vm) {
nsIView* root; vm->UpdateView(vm->RootView(), NS_VMREFRESH_IMMEDIATE);
vm->GetRootView(root);
if (nsnull != root) {
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
}
} }
NS_RELEASE(shell); NS_RELEASE(shell);
} }
@ -2487,11 +2483,7 @@ DumpViewsRecurse(nsIDocShell* aDocShell, FILE* out)
nsCOMPtr<nsIViewManager> vm; nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm)); shell->GetViewManager(getter_AddRefs(vm));
if (vm) { if (vm) {
nsIView* root; vm->RootView()->List(out);
vm->GetRootView(root);
if (nsnull != root) {
root->List(out);
}
} }
NS_RELEASE(shell); NS_RELEASE(shell);
} }

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

@ -445,9 +445,7 @@ nsWebCrawler::OnStateChange(nsIWebProgress* aWebProgress,
nsCOMPtr<nsIViewManager> vm; nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm)); shell->GetViewManager(getter_AddRefs(vm));
if (vm) { if (vm) {
nsIView* rootView; vm->UpdateView(vm->RootView(), NS_VMREFRESH_IMMEDIATE);
vm->GetRootView(rootView);
vm->UpdateView(rootView, NS_VMREFRESH_IMMEDIATE);
} }
if (mJiggleLayout) { if (mJiggleLayout) {

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

@ -261,11 +261,7 @@ void nsXPBaseWindow::ForceRefresh()
nsCOMPtr<nsIViewManager> vm; nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm)); shell->GetViewManager(getter_AddRefs(vm));
if (vm) { if (vm) {
nsIView* root; vm->UpdateView(vm->RootView(), NS_VMREFRESH_IMMEDIATE);
vm->GetRootView(root);
if (nsnull != root) {
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
}
} }
NS_RELEASE(shell); NS_RELEASE(shell);
} }

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

@ -85,12 +85,8 @@ nsIWidget *nsBaseFilePicker::DOMWindowToWidget(nsIDOMWindow *dw)
nsresult rv = docShell->GetPresShell(getter_AddRefs(presShell)); nsresult rv = docShell->GetPresShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv) && presShell) { if (NS_SUCCEEDED(rv) && presShell) {
nsIView *view; nsIView *view = presShell->GetViewManager()->RootView();
rv = presShell->GetViewManager()->GetRootView(view);
if (NS_SUCCEEDED(rv)) {
return view->GetWidget(); return view->GetWidget();
}
} }
} }
} }