[webkit-help] A question on RenderStyle

Umesh Singh sumeshfirst at gmail.com
Mon Nov 8 01:07:38 PST 2010


Hello Eric,
                   To get the style you can use RenderStyle object :
        RefPtr<RenderStyle> style = pNode->styleForRenderer();

        RenderStyle* displayStyle = style.get();

Now with the help of displayStyle you can get the things you want.

Regards,

Umesh





On Mon, Nov 8, 2010 at 2:03 PM, Eric Zhou <englefly at gmail.com> wrote:

> 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!
>
> _______________________________________________
> webkit-help mailing list
> webkit-help at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-help
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20101108/dda51e82/attachment.html>


More information about the webkit-help mailing list