diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 95262efebd5..960469c8853 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -1855,9 +1855,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, // 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; - rv = mViewManager->SetWindowOffset(tbounds.x, tbounds.y); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 95262efebd5..960469c8853 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -1855,9 +1855,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, // 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; - rv = mViewManager->SetWindowOffset(tbounds.x, tbounds.y); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/view/public/nsIViewManager.h b/mozilla/view/public/nsIViewManager.h index bc5d8cea93f..5a537453580 100644 --- a/mozilla/view/public/nsIViewManager.h +++ b/mozilla/view/public/nsIViewManager.h @@ -86,24 +86,11 @@ public: /** * Set the root of the view tree. Does not destroy the current root view. - * At least one of following must be true: - * a) the aWidget parameter is an nsIWidget instance to render into - * that is not owned by any view and aView has no widget, or - * b) aView has a nsIWidget instance and aWidget is null, or - * c) aView has a parent view managed by a different view manager and - * aWidget is null + * 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 - * @param aWidget widget to render into. (Can not be owned by a view) */ - NS_IMETHOD SetRootView(nsIView *aView, nsIWidget* aWidget = nsnull) = 0; - - /** - * Get/Set the offset within the root widget (see above) at which to render. - * @param aX out parameter for offset X in window in twips - * @param aY out parameter for offset Y in window in twips - */ - NS_IMETHOD GetWindowOffset(nscoord *aX, nscoord *aY) = 0; - NS_IMETHOD SetWindowOffset(nscoord aX, nscoord aY) = 0; + NS_IMETHOD SetRootView(nsIView *aView) = 0; /** * Get the dimensions of the root window. The dimensions are in @@ -433,11 +420,10 @@ public: NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget) = 0; /** - * Retrieve the widget that a view manager renders into - * @param aWidget the widget that aView renders into. - * @result error status + * Retrieve the widget at the root of the view manager. This is the + * widget associated with the root view, if the root view exists and has + * a widget. */ - NS_IMETHOD GetWidget(nsIWidget **aWidget) = 0; /** diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index abdab7df36f..9fd7068d38d 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -438,8 +438,6 @@ nsViewManager::nsViewManager() mVMCount++; // NOTE: we use a zeroing operator new, so all data members are // assumed to be cleared here. - mX = 0; - mY = 0; mCachingWidgetChanges = 0; mDefaultBackgroundColor = NS_RGBA(0, 0, 0, 0); mAllowDoubleBuffering = PR_TRUE; @@ -462,8 +460,6 @@ nsViewManager::~nsViewManager() eventQueue->RevokeEvents(this); mInvalidateEventQueue = nsnull; - NS_IF_RELEASE(mRootWindow); - mRootScrollable = nsnull; NS_ASSERTION((mVMCount > 0), "underflow of viewmanagers"); @@ -575,64 +571,25 @@ NS_IMETHODIMP nsViewManager::GetRootView(nsIView *&aView) return NS_OK; } -NS_IMETHODIMP nsViewManager::SetRootView(nsIView *aView, nsIWidget* aWidget) +NS_IMETHODIMP nsViewManager::SetRootView(nsIView *aView) { nsView* view = NS_STATIC_CAST(nsView*, aView); + NS_ASSERTION(view, "Must have a root view"); + // Do NOT destroy the current root view. It's the caller's responsibility // to destroy it mRootView = view; - //now get the window too. - NS_IF_RELEASE(mRootWindow); - - // The window must be specified through one of the following: - //* a) The aView has a nsIWidget instance or - //* b) the aWidget parameter is an nsIWidget instance to render into - //* that is not owned by a view. - //* c) aView has a parent view managed by a different view manager or - - if (nsnull != aWidget) { - mRootWindow = aWidget; - NS_ADDREF(mRootWindow); - return NS_OK; - } - - // case b) The aView has a nsIWidget instance - if (nsnull != mRootView) { + if (mRootView) { nsView* parent = mRootView->GetParent(); if (parent) { parent->InsertChild(mRootView, nsnull); } mRootView->SetZIndex(PR_FALSE, 0, PR_FALSE); - - mRootWindow = mRootView->GetWidget(); - if (mRootWindow) { - NS_ADDREF(mRootWindow); - return NS_OK; - } } - // case c) aView has a parent view managed by a different view manager - - return NS_OK; -} - -NS_IMETHODIMP nsViewManager::GetWindowOffset(nscoord *aX, nscoord *aY) -{ - NS_ASSERTION(aX != nsnull, "aX pointer is null"); - NS_ASSERTION(aY != nsnull, "aY pointer is null"); - - *aX = mX; - *aY = mY; - return NS_OK; -} - -NS_IMETHODIMP nsViewManager::SetWindowOffset(nscoord aX, nscoord aY) -{ - mX = aX; - mY = aY; return NS_OK; } @@ -1585,9 +1542,7 @@ NS_IMETHODIMP nsViewManager::Composite() { if (mUpdateCnt > 0) { - if (nsnull != mRootWindow) - mRootWindow->Update(); - + ForceUpdate(); mUpdateCnt = 0; } @@ -3286,15 +3241,9 @@ NS_IMETHODIMP nsViewManager::GetWidgetForView(nsIView *aView, nsIWidget **aWidge *aWidget = view->GetWidget(); NS_ADDREF(*aWidget); } else { - // No widget was found in the view hierachy, so use try to use the mRootWindow - if (nsnull != mRootWindow) { - NS_ASSERTION(this == view->GetViewManager(), - "Must use the view instance's view manager when calling GetWidgetForView"); - *aWidget = mRootWindow; - NS_ADDREF(mRootWindow); - } else { - *aWidget = nsnull; - } + // If there was a widget associated with our root view, we'd have found it + // above. So there are no widgets anywhere. + *aWidget = nsnull; } return NS_OK; @@ -3303,15 +3252,16 @@ NS_IMETHODIMP nsViewManager::GetWidgetForView(nsIView *aView, nsIWidget **aWidge NS_IMETHODIMP nsViewManager::GetWidget(nsIWidget **aWidget) { - NS_IF_ADDREF(mRootWindow); - *aWidget = mRootWindow; + *aWidget = GetWidget(); + NS_IF_ADDREF(*aWidget); return NS_OK; } NS_IMETHODIMP nsViewManager::ForceUpdate() { - if (mRootWindow) - mRootWindow->Update(); + nsIWidget* widget = GetWidget(); + if (widget) + widget->Update(); return NS_OK; } diff --git a/mozilla/view/src/nsViewManager.h b/mozilla/view/src/nsViewManager.h index 7d29e1a01b6..565e93ce1d3 100644 --- a/mozilla/view/src/nsViewManager.h +++ b/mozilla/view/src/nsViewManager.h @@ -126,10 +126,7 @@ public: NS_IMETHOD Init(nsIDeviceContext* aContext); NS_IMETHOD GetRootView(nsIView *&aView); - NS_IMETHOD SetRootView(nsIView *aView, nsIWidget* aWidget=nsnull); - - NS_IMETHOD GetWindowOffset(nscoord *aX, nscoord *aY); - NS_IMETHOD SetWindowOffset(nscoord aX, nscoord aY); + NS_IMETHOD SetRootView(nsIView *aView); NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height); NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height); @@ -202,7 +199,7 @@ public: NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget); NS_IMETHOD GetWidget(nsIWidget **aWidget); - nsIWidget* GetWidget() { return mRootWindow; } + nsIWidget* GetWidget() { return mRootView ? mRootView->GetWidget() : nsnull; } NS_IMETHOD ForceUpdate(); NS_IMETHOD IsCachingWidgetChanges(PRBool* aCaching); @@ -383,10 +380,6 @@ private: float mTwipsToPixels; float mPixelsToTwips; nsIViewObserver *mObserver; - nsIWidget *mRootWindow; - PRBool mRefreshEnabled; - PRBool mPainting; - PRBool mRecursiveRefreshPending; nsView *mMouseGrabber; nsView *mKeyGrabber; PRInt32 mUpdateCnt; @@ -394,8 +387,18 @@ private: nsIScrollableView *mRootScrollable; PRInt32 mCachingWidgetChanges; nscolor mDefaultBackgroundColor; - nsHashtable mMapPlaceholderViewToZTreeNode; + nsCOMPtr mBlender; + nsISupportsArray *mCompositeListeners; + nsCOMPtr mRegionFactory; + nsView *mRootView; + nsCOMPtr mEventQueueService; + nsCOMPtr mInvalidateEventQueue; + PRPackedBool mRefreshEnabled; + PRPackedBool mPainting; + PRPackedBool mRecursiveRefreshPending; + PRPackedBool mAllowDoubleBuffering; + PRPackedBool mHasPendingInvalidates; //from here to public should be static and locked... MMP static PRInt32 mVMCount; //number of viewmanagers @@ -406,20 +409,7 @@ private: //list of view managers static nsVoidArray *gViewManagers; - nsCOMPtr mBlender; - - nsISupportsArray *mCompositeListeners; void DestroyZTreeNode(DisplayZTreeNode* aNode); - - nsCOMPtr mRegionFactory; -protected: - nsView *mRootView; - nscoord mX; - nscoord mY; - PRBool mAllowDoubleBuffering; - PRBool mHasPendingInvalidates; - nsCOMPtr mEventQueueService; - nsCOMPtr mInvalidateEventQueue; void PostInvalidateEvent(); #ifdef NS_VM_PERF_METRICS