[webkit-dev] How to find out how many children in a RenderObject

David Hyatt hyatt at apple.com
Fri Jun 26 13:03:15 PDT 2009


On Jun 26, 2009, at 12:59 AM, n179911 wrote:

> Can you please tell me how can I find out how many children in a  
> RenderObject?
> In RenderObject, I only see these method, I can't find a way which
> return the number of children from a given RenderObject
>
> RenderObject* childAt(unsigned) const;
> RenderObject* firstLeafChild() const;
> RenderObject* lastLeafChild() const;
>
> Thank you.

Assuming you mean immediate children and not descendants...

unsigned count = 0;
for (RenderObject* current = firstChild(); current; current = current- 
 >nextSibling())
	count++;

dave
(hyatt at apple.com)



More information about the webkit-dev mailing list