[webkit-dev] How to interrupt Webkit Dump Render Tree output

Simon Fraser simon.fraser at apple.com
Mon Jun 1 10:31:03 PDT 2009


There is a method on RenderObject to get the correct absolute  
coordinates of the renderer, which correctly takes transforms,  
scrolling etc into account: RenderObject::localToAbsolute(). This is  
not a trivial problem.

There are APIs exposed to JavaScript for this too: the offsetParent/ 
offsetX/offsetY, and getBoundingClientRect (see http://www.w3.org/TR/cssom-view/ 
); these, however, are not transform-aware.

What code are you in where you need these coordinates?
Simon

On Jun 1, 2009, at 10:00 AM, Lucius Fox wrote:

> Thank you.
>
> So to get absolute co-ordinates of each Render Object, I need to do
> something like:
>
> int absolute_x = 0;
> int absolute_y = 0;
>
> parent = renderObject.getParent()
>
> while (parent != RenderBody) {
>     absolute_x += parent.getX();
>     absolute_y += parent.getY();
>
> }
>
> Is that right?
>
> Thank you.
>
>
>
> On Sun, May 31, 2009 at 3:11 PM, Eric Seidel <macdome at gmail.com>  
> wrote:
>> To expand Darin's answer:   there are exceptions to the
>> relative-to-containing-block rule.  SVG results for example are  
>> absolute
>> (mostly).  There are also hacks the the DRT output, where we "lie"  
>> about
>> metrics in order to keep consistent with historical results (to  
>> minimize the
>> scope of a single patch).  If you're trying to use DRT for anything  
>> other
>> than testing, you will likely need to fork WebCore's  
>> RenderTreeAsText.cpp
>> and SVGRenderTreeAsText.cpp substantially to fit your needs.
>> -eric
>> On Sun, May 31, 2009 at 10:19 AM, Darin Adler <darin at apple.com>  
>> wrote:
>>>
>>> Coordinates in DumpRenderTree output are relative to the  
>>> containing block,
>>> not absolute.
>>>
>>>    -- Darin
>>>
>>> _______________________________________________
>>> webkit-dev mailing list
>>> webkit-dev at lists.webkit.org
>>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>>
>>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev



More information about the webkit-dev mailing list