mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
added GetExtents().
This commit is contained in:
parent
8706314a4e
commit
fdc84978d8
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user