[webkit-dev] Shadow nodes in webkit

Giri Rao giri.rao at gmail.com
Fri Oct 24 13:08:34 PDT 2008

Hi Adele,

Here is my html fragment:

    <textarea rows="10" cols="30">The cat was playing in the

The dom tree consists of:
dom node for document
  -- dom node for html
    -- dom node for body
      -- dom node for text area

The dom tree stops here and does not give me a #text node for the textarea's
text.  Is there a way to get the text while traversing the dom tree?

The render tree consists of:
render object for document
  -- render object for html
     -- render object for body
        -- render object for text area
           -- A DIV shadow node
              -- a #text node whose nodeValue() returns The cat was playing
in the garden.

I was wondering if there could ever be a scenario where the shadow DIV node
contains more than one child?  In other words is it guaranteed that a shadow
node contains exactly one child?

Thanks in advance

On Thu, Oct 23, 2008 at 6:28 PM, Adele Peterson <adele at apple.com> wrote:

> Hi Giri,
> WebKit creates shadow nodes for many of the form controls.  As you noticed,
> these nodes are not visible from the DOM, but the renderers for those nodes
> can be traversed in the render tree.  For example, a text field or text area
> has a shadow DOM that contains all the text inside the control.  A file
> upload control has a shadow nodes for  the  "choose file" button.  This is
> just a way for WebKit to build elements using HTML without exposing the
> internal details to web content.
> - Adele
> On Oct 23, 2008, at 6:22 PM, Giri Rao wrote:
> Hi,
> I am running into a bit of a problem, let me try and explain the best I
> can:
> I am traversing RenderObject tree in webkit.  I notice that there are
> certain nodes (accessed using render_object->node()) which are shadow nodes
> (node->isShadow() returns true).  I note down the address of one such node,
> lets say the address is 100.  The node name of this node is "DIV"
> Now, I traverse the dom tree using Node, for each node I note down the
> node's address. I am noticing that I am not seeing any nodes while
> traversing the dom tree whose address is 100.
> So two questions:
> 1.  Why would webkit create a node which is not part of the dom tree?
> 2.  What are shadow nodes?
> Any insight is appreciated.
> Thanks
> Giri _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20081024/ad30c838/attachment.html>

More information about the webkit-dev mailing list