Bug 89172

Summary: [Shadow] parentTreeScope() of nested shadow DOM subtree returns document().
Product: WebKit Reporter: Takashi Sakamoto <tasak>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: hayato, morrita, naginenis, shinyak, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 89073    
Attachments:
Description Flags
Patch
none
Patch none

Description Takashi Sakamoto 2012-06-14 22:51:26 PDT
<body>
<div id="test">
</div>
<script>
    var div = document.getElementById("test");
    var shadow1 = new WebKitShadowRoot(div);
    shadow1.innerHTML = "<div id='E'></div>";

    var e = shadow1.getElementById("E");
    var shadow2 = new WebKitShadowRoot(e);
    shadow2.innerHTML = "<div id='F'></div>";

    var f = shadow2.getElementById("F");
    var shadow3 = new WebKitShadowRoot(f);
    shadow3.innerHTML = "<div id='G'></div>";
</script>
</body>

The shadow1, shadow2, and shadow3's parentTreeScope() are the same as document(). If creating the same DOM tree by using the following script, parentTreeScope() returns correct parent tree scope.

<script>
    var f = document.createElement("div");
    var shadow3 = new WebKitShadowRoot(f);
    shadow3.innerHTML = "<div id='G'></div>";

    var e = document.createElement("div");
    var shadow2 = new WebKitShadowRoot(e);
    shadow2.appendChild(f);

    var test = document.getElementById("test");
    var shadow1 = new WebKitShadowRoot(test);
    shadow1.appendChild(e);
</script>
Comment 1 Takashi Sakamoto 2012-06-15 01:05:55 PDT
Created attachment 147770 [details]
Patch
Comment 2 Shinya Kawanaka 2012-06-20 14:09:47 PDT
Looks sane for me, wait for the reviewers' comment!
Comment 3 Hajime Morrita 2012-06-20 19:14:42 PDT
Comment on attachment 147770 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=147770&action=review

> Source/WebCore/testing/Internals.cpp:208
> +Node* Internals::parentTreeScopeRootNode(Node* node, ExceptionCode& ec)

Why not just pass a TreeScope and make this parentScope() or something?
I hope Internals APIs be a set of thin wrappers of private DOM API to make them orthogonal.
Comment 4 Shinya Kawanaka 2012-06-21 17:32:19 PDT
Comment on attachment 147770 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=147770&action=review

>> Source/WebCore/testing/Internals.cpp:208
>> +Node* Internals::parentTreeScopeRootNode(Node* node, ExceptionCode& ec)
> 
> Why not just pass a TreeScope and make this parentScope() or something?
> I hope Internals APIs be a set of thin wrappers of private DOM API to make them orthogonal.

Is TreeScope available from JS...?
Comment 5 Takashi Sakamoto 2012-06-21 20:36:06 PDT
Created attachment 148952 [details]
Patch
Comment 6 WebKit Review Bot 2012-06-22 09:01:03 PDT
Comment on attachment 148952 [details]
Patch

Clearing flags on attachment: 148952

Committed r121027: <http://trac.webkit.org/changeset/121027>
Comment 7 WebKit Review Bot 2012-06-22 09:01:08 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Sudarsana Nagineni (babu) 2012-07-13 05:21:59 PDT
*** Bug 89694 has been marked as a duplicate of this bug. ***