[webkit-dev] Question about A Usage of RefPtr

Yuxiang Luo luoyx at google.com
Wed Aug 4 01:28:06 PDT 2010


On Wed, Aug 4, 2010 at 4:05 PM, Yuxiang Luo <luoyx at google.com> wrote:

> Hi,
>
> I'm currently looking into a bug (42799), and find that class
> CSSComputedStyleDeclaration has a property 'RefPtr<Node> m_node', which
> means this class takes ownership of the Node to which the computedStyle
> object belongs back to. Does this mean that if the computedStyle object get
> released, the owner Node will be released too?
>
I have figured out the issue, there is no problem for the two objects to Ref
the Node. Actually the usage case is the just purpose the RefPtr...

>
> For example, the class Position owns the node object 'RefPtr<Node>
> m_anchorNode',  and in method 'Position::computedStyle',  it passed the raw
> pointer m_anchorNode.get() to CSSComputedStyleDeclaration, after that, both
> 'Position' and 'CSSComputedStyleDeclaration' own the Node pointer. Is this a
> mistake in CSSComputedStyleDeclaration which incorrectly uses RefPtr to wrap
> the Node? (another similar class CSSMutableStyleDeclaration only has the raw
> pointer)
>
> Another question is, as the bug 42799 shows,  when getting 'pixel*' or
> 'pos*' properties, if the unit type is 'em' or 'ex', the result is not
> multiplied with factor. The factor for these two unit types depends on the
> RenderStyle of corresponding element, but the class CSSStyleDeclaration
> does't provide any access to corresponding element/node. I find that
> both CSSComputedStyleDeclaration and CSSMutableStyleDeclaration have the
> field 'm_node’. So to fix the bug, we might need to put the field up to the
> base class CSSStyleDeclaration. But I'm not very familiar with the code base
> yet, and not sure whether the change will break other logic?  Thanks in
> advance for your help.
>
> Best Regards.
>
> --
> Yuxiang Luo
> Engineer at Google
> <luoyx at google.com>
>



-- 
Yuxiang Luo
Engineer at Google
<luoyx at google.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100804/c5ed0794/attachment.html>


More information about the webkit-dev mailing list