diff --git a/mozilla/view/public/nsIView.h b/mozilla/view/public/nsIView.h index 14678fe98c4..4b435ea4fa7 100644 --- a/mozilla/view/public/nsIView.h +++ b/mozilla/view/public/nsIView.h @@ -452,6 +452,14 @@ public: */ NS_IMETHOD GetScratchPoint(nsPoint **aPoint) = 0; + /** + * Get the extents of the view tree from 'this' down. + * 'this' is the coordinate system origin. + * @param aExtents out paramemter for extents + * @return error status + */ + NS_IMETHOD GetExtents(nsRect *aExtents) = 0; + private: NS_IMETHOD_(nsrefcnt) AddRef(void) = 0; NS_IMETHOD_(nsrefcnt) Release(void) = 0; diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index 9216be74069..edd23caa8da 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -1371,3 +1371,37 @@ NS_IMETHODIMP nsView :: GetScratchPoint(nsPoint **aPoint) return NS_OK; } + +static void calc_extents(nsIView *view, nsRect *extents, nscoord ox, nscoord oy) +{ + nsIView *kid; + PRInt32 numkids, cnt; + nsRect bounds; + + view->GetChildCount(numkids); + + for (cnt = 0; cnt < numkids; cnt++) + { + view->GetChild(cnt, kid); + kid->GetBounds(bounds); + + bounds.x += ox; + bounds.y += oy; + + extents->IntersectRect(*extents, bounds); + + calc_extents(kid, extents, bounds.x, bounds.y); + } +} + +NS_IMETHODIMP nsView :: GetExtents(nsRect *aExtents) +{ + GetBounds(*aExtents); + + aExtents->x = 0; + aExtents->y = 0; + + calc_extents(this, aExtents, 0, 0); + + return NS_OK; +} diff --git a/mozilla/view/src/nsView.h b/mozilla/view/src/nsView.h index 4ef2573dca3..5f1da5e4f56 100644 --- a/mozilla/view/src/nsView.h +++ b/mozilla/view/src/nsView.h @@ -97,6 +97,7 @@ public: NS_IMETHOD ClearViewFlags(PRUint32 aFlags); NS_IMETHOD GetViewFlags(PRUint32 *aFlags); NS_IMETHOD GetScratchPoint(nsPoint **aPoint); + NS_IMETHOD GetExtents(nsRect *aExtents); // Helper function to get the view that's associated with a widget static nsIView* GetViewFor(nsIWidget* aWidget);