[webkit-help] A question on RenderStyle

Eric Zhou englefly at gmail.com
Mon Nov 8 00:33:57 PST 2010


Hi all,

Safari provides a function "Inspect element". We could get the style
information from "computed Style" section.

Could someone show me some code to get this "computed style"?

I tried to get the style information from an element's RenderObject like
this

    int width = render->style()->width().rawValue();
    int height = render->style()->height().rawValue();
    int left = render->style()->left().rawValue();
    int top = render->style()->top().rawValue();

But most integers I got are zero. For example,

    <div id="d1" width=100>
        <div id="d2" >
    </div>

>From my code, the width of d1 is 100, but the width of d2 is zero.
>From safari's "Inspect element"-->"computed Style", the width of d2 is 100.

How can I get the Computed Style?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20101108/7e4a0bf7/attachment.html>


More information about the webkit-help mailing list