diff --git a/mozilla/view/public/nsIViewManager.h b/mozilla/view/public/nsIViewManager.h index de4a3fa0e5f..4583bfd8159 100644 --- a/mozilla/view/public/nsIViewManager.h +++ b/mozilla/view/public/nsIViewManager.h @@ -58,9 +58,11 @@ public: * Note: this instance does not hold a reference to the viewobserver * because it holds a reference to this instance. * @param aContext the device context to use. + * @param aX X offset of the view manager's coordinate space in twips + * @param aY Y offset of the view manager's coordinate space in twips * @result The result of the initialization, NS_OK if no errors */ - NS_IMETHOD Init(nsIDeviceContext* aContext) = 0; + NS_IMETHOD Init(nsIDeviceContext* aContext, nscoord aX = 0, nscoord aY = 0) = 0; /** * Get the root of the view tree. @@ -461,6 +463,16 @@ public: NS_IMETHOD ForceUpdate() = 0; + + /** + * Get view manager offset specified in nsIViewManager::Init + * @param aX x offset in twips + * @param aY y offset in twips + * @result error status + */ + + NS_IMETHOD GetOffset(nscoord *aX, nscoord *aY) = 0; + }; diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index e3e5c4734c1..e2d02c225ed 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -825,8 +825,20 @@ NS_IMETHODIMP nsView :: IgnoreSetPosition(PRBool aShouldIgnore) } // XXX End Temporary fix for Bug #19416 -NS_IMETHODIMP nsView :: SetPosition(nscoord x, nscoord y) +NS_IMETHODIMP nsView :: SetPosition(nscoord aX, nscoord aY) { + nscoord x = aX; + nscoord y = aY; + if (IsRoot()) { + // Add view manager's coordinate offset to the root view + // This allows the view manager to offset it's coordinate space + // while allowing layout to assume it's coordinate space origin is (0,0) + nscoord offsetX; + nscoord offsetY; + mViewManager->GetOffset(&offsetX, &offsetY); + x += offsetX; + y += offsetY; + } mBounds.MoveTo(x, y); // XXX Start Temporary fix for Bug #19416 @@ -858,6 +870,7 @@ NS_IMETHODIMP nsView :: SetPosition(nscoord x, nscoord y) NS_IMETHODIMP nsView :: GetPosition(nscoord *x, nscoord *y) const { + nsIView *rootView; mViewManager->GetRootView(rootView); @@ -866,10 +879,13 @@ NS_IMETHODIMP nsView :: GetPosition(nscoord *x, nscoord *y) const *x = *y = 0; else { + *x = mBounds.x; *y = mBounds.y; + } + return NS_OK; } @@ -1511,3 +1527,16 @@ NS_IMETHODIMP nsView :: GetExtents(nsRect *aExtents) return NS_OK; } + +PRBool nsView :: IsRoot() +{ +nsIView *rootView; + + NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()"); + mViewManager->GetRootView(rootView); + if (rootView == this) { + return PR_TRUE; + } + + return PR_FALSE; +} diff --git a/mozilla/view/src/nsView.h b/mozilla/view/src/nsView.h index af47ce63842..65902c87fc1 100644 --- a/mozilla/view/src/nsView.h +++ b/mozilla/view/src/nsView.h @@ -116,6 +116,9 @@ public: // Helper function to get the view that's associated with a widget static nsIView* GetViewFor(nsIWidget* aWidget); + // Helper function to determine if the view instance is the root view + PRBool IsRoot(); + protected: virtual ~nsView(); // diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index d7328ca993d..c5189260176 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -120,6 +120,8 @@ nsViewManager :: nsViewManager() mVMCount++; mUpdateBatchCnt = 0; mCompositeListeners = nsnull; + mX = 0; + mY = 0; } nsViewManager :: ~nsViewManager() @@ -256,7 +258,7 @@ static nsresult CreateRegion(nsIComponentManager* componentManager, nsIRegion* * // We don't hold a reference to the presentation context because it // holds a reference to us. -NS_IMETHODIMP nsViewManager :: Init(nsIDeviceContext* aContext) +NS_IMETHODIMP nsViewManager :: Init(nsIDeviceContext* aContext, nscoord aX, nscoord aY) { nsresult rv; @@ -294,6 +296,9 @@ NS_IMETHODIMP nsViewManager :: Init(nsIDeviceContext* aContext) rv = CreateRegion(componentManager, &mTRgn); rv = CreateRegion(componentManager, &mRCRgn); } + + mX = aX; + mY = aY; return rv; } @@ -2547,6 +2552,15 @@ NS_IMETHODIMP nsViewManager::ForceUpdate() return NS_OK; } +NS_IMETHODIMP nsViewManager::GetOffset(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; +} + PRBool nsViewManager :: CreateDisplayList(nsIView *aView, PRInt32 *aIndex, nscoord aOriginX, nscoord aOriginY, nsIView *aRealView, diff --git a/mozilla/view/src/nsViewManager.h b/mozilla/view/src/nsViewManager.h index 23708ff5919..0450983eccd 100644 --- a/mozilla/view/src/nsViewManager.h +++ b/mozilla/view/src/nsViewManager.h @@ -51,7 +51,7 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD Init(nsIDeviceContext* aContext); + NS_IMETHOD Init(nsIDeviceContext* aContext, nscoord aX = 0, nscoord aY = 0); NS_IMETHOD GetRootView(nsIView *&aView); NS_IMETHOD SetRootView(nsIView *aView, nsIWidget* aWidget=nsnull); @@ -138,7 +138,8 @@ public: NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget); NS_IMETHOD GetWidget(nsIWidget **aWidget); NS_IMETHOD ForceUpdate(); - + NS_IMETHOD GetOffset(nscoord *aX, nscoord *aY); + protected: virtual ~nsViewManager(); @@ -266,6 +267,10 @@ public: nsIView *mRootView; PRUint32 mFrameRate; PRUint32 mTrueFrameRate; + +protected: + nscoord mX; + nscoord mY; }; #endif diff --git a/mozilla/view/src/nsViewManager2.cpp b/mozilla/view/src/nsViewManager2.cpp index c640a29e84a..5c351195e90 100755 --- a/mozilla/view/src/nsViewManager2.cpp +++ b/mozilla/view/src/nsViewManager2.cpp @@ -122,6 +122,8 @@ nsViewManager2::nsViewManager2() mVMCount++; // NOTE: we use a zeroing operator new, so all data members are // assumed to be cleared here. + mX = 0; + mY = 0; } nsViewManager2::~nsViewManager2() @@ -253,7 +255,7 @@ static nsresult CreateRegion(nsIComponentManager* componentManager, nsIRegion* * // We don't hold a reference to the presentation context because it // holds a reference to us. -NS_IMETHODIMP nsViewManager2::Init(nsIDeviceContext* aContext) +NS_IMETHODIMP nsViewManager2::Init(nsIDeviceContext* aContext, nscoord aX, nscoord aY) { nsresult rv; @@ -294,6 +296,9 @@ NS_IMETHODIMP nsViewManager2::Init(nsIDeviceContext* aContext) rv = CreateRegion(componentManager, &mTRgn); rv = CreateRegion(componentManager, &mRCRgn); } + + mX = aX; + mY = aY; return rv; } @@ -2121,6 +2126,15 @@ NS_IMETHODIMP nsViewManager2::ForceUpdate() return NS_OK; } +NS_IMETHODIMP nsViewManager2::GetOffset(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; +} + PRBool nsViewManager2::CreateDisplayList(nsIView *aView, PRInt32 *aIndex, nscoord aOriginX, nscoord aOriginY, nsIView *aRealView, diff --git a/mozilla/view/src/nsViewManager2.h b/mozilla/view/src/nsViewManager2.h index 21f5f6c69a8..6946df44e0f 100755 --- a/mozilla/view/src/nsViewManager2.h +++ b/mozilla/view/src/nsViewManager2.h @@ -53,7 +53,7 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD Init(nsIDeviceContext* aContext); + NS_IMETHOD Init(nsIDeviceContext* aContext, nscoord aX = 0, nscoord aY = 0); NS_IMETHOD GetRootView(nsIView *&aView); NS_IMETHOD SetRootView(nsIView *aView, nsIWidget* aWidget=nsnull); @@ -140,6 +140,7 @@ public: NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget); NS_IMETHOD GetWidget(nsIWidget **aWidget); NS_IMETHOD ForceUpdate(); + NS_IMETHOD GetOffset(nscoord *aX, nscoord *aY); protected: virtual ~nsViewManager2(); @@ -287,6 +288,10 @@ public: nsIView *mRootView; PRUint32 mFrameRate; PRUint32 mTrueFrameRate; + +protected: + nscoord mX; + nscoord mY; }; #endif /* nsViewManager2_h___ */