diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 63946d87ac22..c7f6eb09c0c3 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -6386,8 +6386,8 @@ LayerManagerForDocumentInternal(nsIDocument *aDoc, bool aRequirePersistent, if (shell) { nsIViewManager* VM = shell->GetViewManager(); if (VM) { - nsIView* rootView = nsnull; - if (NS_SUCCEEDED(VM->GetRootView(rootView)) && rootView) { + nsIView* rootView = VM->GetRootView(); + if (rootView) { nsIView* displayRoot = GetDisplayRootFor(rootView); if (displayRoot) { nsIWidget* widget = displayRoot->GetNearestWidget(nsnull); diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c24e96a90d67..948c9b73497e 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -4758,8 +4758,7 @@ nsDocShell::GetVisibility(PRBool * aVisibility) 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); + nsIView *view = vm->GetRootView(); // views are not ref counted NS_ENSURE_TRUE(view, NS_ERROR_FAILURE); // if our root view is hidden, we are not visible @@ -7047,8 +7046,7 @@ nsDocShell::RestoreFromHistory() if (oldPresShell) { nsIViewManager *vm = oldPresShell->GetViewManager(); if (vm) { - nsIView *oldRootView = nsnull; - vm->GetRootView(oldRootView); + nsIView *oldRootView = vm->GetRootView(); if (oldRootView) { rootViewSibling = oldRootView->GetNextSibling(); @@ -7255,9 +7253,7 @@ nsDocShell::RestoreFromHistory() nsDocShell::GetPresShell(getter_AddRefs(shell)); nsIViewManager *newVM = shell ? shell->GetViewManager() : nsnull; - nsIView *newRootView = nsnull; - if (newVM) - newVM->GetRootView(newRootView); + nsIView *newRootView = newVM ? newVM->GetRootView() : nsnull; // Insert the new root view at the correct location in the view tree. if (rootViewParent) { @@ -7350,7 +7346,7 @@ nsDocShell::RestoreFromHistory() // When we insert the root view above the resulting invalidate is // dropped because painting is suppressed in the presshell until we // call Thaw. So we issue the invalidate here. - newVM->GetRootView(newRootView); + newRootView = newVM->GetRootView(); if (newRootView) { newVM->UpdateView(newRootView, NS_VMREFRESH_NO_SYNC); } diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 9ee4fca00f91..ec8c94672e53 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -448,7 +448,6 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType, appPerDev); event.ignoreRootScrollFrame = aIgnoreRootScrollFrame; - nsresult rv; nsEventStatus status; if (aToWindow) { nsIPresShell* presShell = presContext->PresShell(); @@ -460,17 +459,14 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType, nsIViewManager* viewManager = presShell->GetViewManager(); if (!viewManager) return NS_ERROR_FAILURE; - nsIView* view = nsnull; - rv = viewManager->GetRootView(view); - if (NS_FAILED(rv) || !view) + nsIView* view = viewManager->GetRootView(); + if (!view) return NS_ERROR_FAILURE; status = nsEventStatus_eIgnore; - rv = vo->HandleEvent(view, &event, PR_FALSE, &status); - } else { - rv = widget->DispatchEvent(&event, status); + return vo->HandleEvent(view, &event, PR_FALSE, &status); } - return rv; + return widget->DispatchEvent(&event, status); } NS_IMETHODIMP diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 9317f716584c..9ede8224c03a 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -10144,8 +10144,7 @@ nsGlobalChromeWindow::SetCursor(const nsAString& aCursor) nsIViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); - nsIView *rootView; - vm->GetRootView(rootView); + nsIView* rootView = vm->GetRootView(); NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE); nsIWidget* widget = rootView->GetNearestWidget(nsnull); diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index eab547201214..2834073bcac0 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -1,6 +1,5 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version @@ -1570,8 +1569,7 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer, if (shell) { nsIViewManager* vm = shell->GetViewManager(); if (vm) { - nsIView* view; - vm->GetRootView(view); + nsIView* view = vm->GetRootView(); if (view) { nsPoint offset; widget = view->GetNearestWidget(&offset); diff --git a/extensions/widgetutils/src/nsWidgetUtils.cpp b/extensions/widgetutils/src/nsWidgetUtils.cpp index 07a12ec6f0f2..57cf60749829 100644 --- a/extensions/widgetutils/src/nsWidgetUtils.cpp +++ b/extensions/widgetutils/src/nsWidgetUtils.cpp @@ -284,8 +284,7 @@ nsWidgetUtils::MouseMove(nsIDOMEvent* aDOMEvent) if(g_lastX == MIN_INT || g_lastY == MIN_INT) return NS_OK; - nsIView *aView = nsnull; - mViewManager->GetRootView(aView); + nsIView* aView = mViewManager->GetRootView(); if (!aView) if (NS_FAILED(UpdateFromEvent(aDOMEvent))) return NS_OK; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 02e5d6681b33..f4bcbcc9c6d4 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2549,8 +2549,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIFrame** aNewFrame) viewportFrame->Init(nsnull, nsnull, nsnull); // Bind the viewport frame to the root view - nsIView* rootView; - mPresShell->GetViewManager()->GetRootView(rootView); + nsIView* rootView = mPresShell->GetViewManager()->GetRootView(); viewportFrame->SetView(rootView); nsContainerFrame::SyncFrameViewProperties(mPresShell->GetPresContext(), viewportFrame, diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index e9a9a5858693..d6a7e6e20268 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1419,9 +1419,7 @@ DocumentViewerImpl::Open(nsISupports *aState, nsISHEntry *aSHEntry) nsIViewManager *vm = GetViewManager(); NS_ABORT_IF_FALSE(vm, "no view manager"); - nsIView *v; - nsresult rv = vm->GetRootView(v); - NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "failed in getting the root view"); + nsIView* v = vm->GetRootView(); NS_ABORT_IF_FALSE(v, "no root view"); NS_ABORT_IF_FALSE(mParentWidget, "no mParentWidget to set"); v->AttachToTopLevelWidget(mParentWidget); @@ -1566,8 +1564,7 @@ DocumentViewerImpl::Destroy() if (mPresShell) { nsIViewManager *vm = mPresShell->GetViewManager(); if (vm) { - nsIView *rootView = nsnull; - vm->GetRootView(rootView); + nsIView *rootView = vm->GetRootView(); if (rootView) { // The invalidate that removing this view causes is dropped because @@ -2363,8 +2360,7 @@ void DocumentViewerImpl::DetachFromTopLevelWidget() { if (mViewManager) { - nsIView* oldView = nsnull; - mViewManager->GetRootView(oldView); + nsIView* oldView = mViewManager->GetRootView(); if (oldView && oldView->IsAttachedToTopLevel()) { oldView->DetachFromTopLevelWidget(); } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 69808d782fa5..66bb19ed9808 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2436,9 +2436,8 @@ nsPresContext::IsRootContentDocument() return PR_FALSE; } // We may not have a root frame, so use views. - nsIViewManager* vm = PresShell()->GetViewManager(); - nsIView* view = nsnull; - if (NS_FAILED(vm->GetRootView(view)) || !view) { + nsIView* view = PresShell()->GetViewManager()->GetRootView(); + if (!view) { return PR_FALSE; } view = view->GetParent(); // anonymous inner view diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index cff3af76ea4c..e39bfa0512c7 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4844,8 +4844,8 @@ PresShell::FlushPendingNotifications(mozFlushType aType) } #ifdef DEBUG if (!mIsDestroying) { - nsIView* rootView; - if (NS_SUCCEEDED(mViewManager->GetRootView(rootView)) && rootView) { + nsIView* rootView = mViewManager->GetRootView(); + if (rootView) { nsRect bounds = rootView->GetBounds(); NS_ASSERTION(bounds.Size() == mPresContext->GetVisibleArea().Size(), "root view / pres context visible size mismatch"); @@ -5906,8 +5906,8 @@ LayerManager* PresShell::GetLayerManager() { NS_ASSERTION(mViewManager, "Should have view manager"); - nsIView* rootView; - if (NS_SUCCEEDED(mViewManager->GetRootView(rootView)) && rootView) { + nsIView* rootView = mViewManager->GetRootView(); + if (rootView) { if (nsIWidget* widget = rootView->GetWidget()) { return widget->GetLayerManager(); } @@ -6270,8 +6270,7 @@ PresShell::RetargetEventToParent(nsGUIEvent* aEvent, } // Fake the event as though it'ss from the parent pres shell's root view. - nsIView *parentRootView; - parentPresShell->GetViewManager()->GetRootView(parentRootView); + nsIView *parentRootView = parentPresShell->GetViewManager()->GetRootView(); return parentViewObserver->HandleEvent(parentRootView, aEvent, PR_TRUE, aEventStatus); } @@ -6362,10 +6361,8 @@ PresShell::HandleEvent(nsIView *aView, if (!viewObserver) return NS_ERROR_FAILURE; - nsIView *view; - presShell->GetViewManager()->GetRootView(view); - nsresult rv = viewObserver->HandleEvent(view, aEvent, PR_TRUE, aEventStatus); - return rv; + nsIView* view = presShell->GetViewManager()->GetRootView(); + return viewObserver->HandleEvent(view, aEvent, PR_TRUE, aEventStatus); } } } @@ -6394,8 +6391,7 @@ PresShell::HandleEvent(nsIView *aView, // from the root views widget. This is necessary to prevent us from // dispatching the SysColorChanged notification for each child window // which may be redundant. - nsIView *view; - vm->GetRootView(view); + nsIView* view = vm->GetRootView(); if (view == aView) { *aEventStatus = nsEventStatus_eConsumeDoDefault; mPresContext->SysColorChanged(); @@ -6586,8 +6582,7 @@ PresShell::HandleEvent(nsIView *aView, nsContentUtils::ContentIsCrossDocDescendantOf(activeShell->GetDocument(), shell->GetDocument())) { shell = static_cast(activeShell); - nsIView* activeShellRootView; - shell->GetViewManager()->GetRootView(activeShellRootView); + nsIView* activeShellRootView = shell->GetViewManager()->GetRootView(); frame = static_cast(activeShellRootView->GetClientData()); } } @@ -6596,8 +6591,7 @@ PresShell::HandleEvent(nsIView *aView, // Handle the event in the correct shell. // Prevent deletion until we're done with event handling (bug 336582). nsCOMPtr kungFuDeathGrip(shell); - nsIView* subshellRootView; - shell->GetViewManager()->GetRootView(subshellRootView); + nsIView* subshellRootView = shell->GetViewManager()->GetRootView(); // We pass the subshell's root view as the view to start from. This is // the only correct alternative; if the event was captured then it // must have been captured by us or some ancestor shell and we @@ -6663,8 +6657,7 @@ PresShell::HandleEvent(nsIView *aView, nsIPresShell* shell = targetDoc->GetShell(); nsCOMPtr vo = do_QueryInterface(shell); if (vo) { - nsIView* root = nsnull; - shell->GetViewManager()->GetRootView(root); + nsIView* root = shell->GetViewManager()->GetRootView(); rv = static_cast(shell)->HandleRetargetedEvent(aEvent, root, aEventStatus, @@ -7850,8 +7843,7 @@ PresShell::DoVerifyReflow() if (GetVerifyReflowEnable()) { // First synchronously render what we have so far so that we can // see it. - nsIView* rootView; - mViewManager->GetRootView(rootView); + nsIView* rootView = mViewManager->GetRootView(); mViewManager->UpdateView(rootView, NS_VMREFRESH_IMMEDIATE); FlushPendingNotifications(Flush_Layout); @@ -8495,8 +8487,7 @@ PresShell::VerifyIncrementalReflow() NS_ENSURE_SUCCESS(rv, PR_FALSE); // Get our scrolling preference - nsIView* rootView; - mViewManager->GetRootView(rootView); + nsIView* rootView = mViewManager->GetRootView(); NS_ENSURE_TRUE(rootView->HasWidget(), PR_FALSE); nsIWidget* parentWidget = rootView->GetWidget(); diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 7aab68d348c6..5f71e7cb174c 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -475,8 +475,7 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext, return; nsIViewManager* vm = aView->GetViewManager(); - nsIView* rootView; - vm->GetRootView(rootView); + nsIView* rootView = vm->GetRootView(); if (aView != rootView) return; diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 7bf057e17ebb..3409347de898 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -1546,8 +1546,7 @@ nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext, // Update the view immediately (make drag appear snappier) nsIViewManager* vm = aPresContext->GetPresShell()->GetViewManager(); if (vm) { - nsIView* root; - vm->GetRootView(root); + nsIView* root = vm->GetRootView(); if (root) { vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE); } diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index d2c82ef680ee..ff4310e317e1 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -3537,9 +3537,8 @@ DumpViews(nsIDocShell* aDocShell, FILE* out) if (shell) { nsIViewManager* vm = shell->GetViewManager(); if (vm) { - nsIView* root; - vm->GetRootView(root); - if (nsnull != root) { + nsIView* root = vm->GetRootView(); + if (root) { root->List(out); } } diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index f0a5252df964..0a00d4a754a6 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -475,9 +475,8 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) fprintf(out, "docshell=%p \n", static_cast(aDocShell)); nsCOMPtr vm(view_manager(aDocShell)); if (vm) { - nsIView* root; - vm->GetRootView(root); - if (nsnull != root) { + nsIView* root = vm->GetRootView(); + if (root) { root->List(out); } } @@ -568,8 +567,7 @@ void nsLayoutDebuggingTools::ForceRefresh() nsCOMPtr vm(view_manager(mDocShell)); if (!vm) return; - nsIView* root = nsnull; - vm->GetRootView(root); + nsIView* root = vm->GetRootView(); if (root) { vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE); } diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 9ec8c4eded7c..061689f92bfe 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -1869,7 +1869,7 @@ nsBoxFrame::CreateViewForFrame(nsPresContext* aPresContext, // Create a view if (aIsPopup) { - viewManager->GetRootView(parentView); + parentView = viewManager->GetRootView(); visibility = nsViewVisibility_kHide; zIndex = PR_INT32_MAX; } diff --git a/view/public/nsIViewManager.h b/view/public/nsIViewManager.h index 260187c23524..99b543ee92ea 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsIViewManager.h @@ -49,9 +49,9 @@ class nsRegion; class nsIDeviceContext; class nsIViewObserver; -#define NS_IVIEWMANAGER_IID \ - { 0x4017112c, 0x64d7, 0x47bc, \ - { 0xab, 0x66, 0x4e, 0x5f, 0xff, 0x83, 0xec, 0x7c } } +#define NS_IVIEWMANAGER_IID \ +{ 0xa47cdaf9, 0x50fd, 0x40d8, \ + { 0x92, 0xe5, 0x93, 0x4f, 0xfb, 0x01, 0xdd, 0x98 } } class nsIViewManager : public nsISupports { @@ -86,7 +86,7 @@ public: * Get the root of the view tree. * @result the root view */ - NS_IMETHOD GetRootView(nsIView *&aView) = 0; + NS_IMETHOD_(nsIView*) GetRootView() = 0; /** * Set the root of the view tree. Does not destroy the current root view. diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 72d1ad461481..37b2deecf720 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -240,7 +240,7 @@ nsView::~nsView() { DropMouseGrabbing(); - nsView *rootView = mViewManager->GetRootView(); + nsView *rootView = mViewManager->GetRootViewImpl(); if (rootView) { @@ -446,7 +446,7 @@ void nsView::DoResetWidgetBounds(PRBool aMoveOnly, PRBool aInvalidateChangedSize) { // The geometry of a root view's widget is controlled externally, // NOT by sizing or positioning the view - if (mViewManager->GetRootView() == this) { + if (mViewManager->GetRootViewImpl() == this) { return; } @@ -568,7 +568,7 @@ NS_IMETHODIMP nsView::SetFloating(PRBool aFloatingView) void nsView::InvalidateHierarchy(nsViewManager *aViewManagerParent) { - if (mViewManager->GetRootView() == this) + if (mViewManager->GetRootViewImpl() == this) mViewManager->InvalidateHierarchy(); for (nsView *child = mFirstChild; child; child = child->GetNextSibling()) @@ -601,7 +601,7 @@ void nsView::InsertChild(nsView *aChild, nsView *aSibling) // on all view managers in the new subtree. nsViewManager *vm = aChild->GetViewManager(); - if (vm->GetRootView() == aChild) + if (vm->GetRootViewImpl() == aChild) { aChild->InvalidateHierarchy(nsnull); // don't care about releasing grabs } @@ -637,7 +637,7 @@ void nsView::RemoveChild(nsView *child) // on all view managers in the removed subtree. nsViewManager *vm = child->GetViewManager(); - if (vm->GetRootView() == child) + if (vm->GetRootViewImpl() == child) { child->InvalidateHierarchy(GetViewManager()); } @@ -1142,7 +1142,7 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const PRInt32 aAPD) const PRBool nsIView::IsRoot() const { NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()"); - return mViewManager->GetRootView() == this; + return mViewManager->GetRootViewImpl() == this; } PRBool nsIView::ExternalIsRoot() const @@ -1176,7 +1176,7 @@ nsView::GetBoundsInParentUnits() const { nsView* parent = GetParent(); nsViewManager* VM = GetViewManager(); - if (this != VM->GetRootView() || !parent) { + if (this != VM->GetRootViewImpl() || !parent) { return mDimBounds; } PRInt32 ourAPD = VM->AppUnitsPerDevPixel(); diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index a6b38c190e1c..f94463bbadef 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -242,10 +242,10 @@ nsViewManager::CreateView(const nsRect& aBounds, return v; } -NS_IMETHODIMP nsViewManager::GetRootView(nsIView *&aView) +NS_IMETHODIMP_(nsIView*) +nsViewManager::GetRootView() { - aView = mRootView; - return NS_OK; + return mRootView; } NS_IMETHODIMP nsViewManager::SetRootView(nsIView *aView) @@ -659,7 +659,7 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) if (vo && vo->ShouldIgnoreInvalidation()) { return PR_TRUE; } - nsView* view = aVM->GetRootView()->GetParent(); + nsView* view = aVM->GetRootViewImpl()->GetParent(); aVM = view ? view->GetViewManager() : nsnull; } return PR_FALSE; diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 0befd8b554aa..e0681fd24577 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -106,7 +106,7 @@ public: const nsIView* aParent, nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); - NS_IMETHOD GetRootView(nsIView *&aView); + NS_IMETHOD_(nsIView*) GetRootView(); NS_IMETHOD SetRootView(nsIView *aView); NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height); @@ -253,7 +253,7 @@ private: nsresult UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags); public: // NOT in nsIViewManager, so private to the view module - nsView* GetRootView() const { return mRootView; } + nsView* GetRootViewImpl() const { return mRootView; } nsViewManager* RootViewManager() const { return mRootViewManager; } PRBool IsRootVM() const { return this == RootViewManager(); }