Bug 107819

Summary: Web Inspector: each node in a detached DOM tree is shown in its own "detached DOM tree" entry in heap profiler
Product: WebKit Reporter: Yury Semikhatsky <yurys>
Component: Web Inspector (Deprecated)Assignee: Yury Semikhatsky <yurys>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, apavlov, haraken, japhet, keishi, loislo, pfeldman, pmuellr, vsevik, web-inspector-bugs, webkit.review.bot, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 100707    
Bug Blocks: 108202, 108322    
Attachments:
Description Flags
Test page
none
Heap profiler screenshot
none
Patch
none
Patch without static_cast<Node*> abarth: review+

Description Yury Semikhatsky 2013-01-24 06:16:32 PST
Created attachment 184478 [details]
Test page

After http://trac.webkit.org/changeset/133044/trunk/Source/WebCore/bindings/v8/V8GCController.cpp each js node wrapper became a root of a separate detached DOM tree.

On the attached page we have a detached DOM tree with 3 divs. Each of them becomes a seperate DOM tree(see screenshot).
Comment 1 Yury Semikhatsky 2013-01-24 06:17:03 PST
Created attachment 184480 [details]
Heap profiler screenshot
Comment 2 Yury Semikhatsky 2013-01-24 07:35:10 PST
Created attachment 184491 [details]
Patch
Comment 3 Adam Barth 2013-01-24 19:15:07 PST
Comment on attachment 184491 [details]
Patch

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

> Source/WebCore/bindings/v8/V8GCController.cpp:106
> +                OwnPtr<RetainedObjectInfo> retainedObjectInfo;
> +                if (group[0].WrapperClassId() == v8DOMNodeClassId)
> +                    retainedObjectInfo = adoptPtr(new RetainedDOMInfo(static_cast<Node*>(root)));

Why is this static cast valid?
Comment 4 Yury Semikhatsky 2013-01-25 02:57:25 PST
Comment on attachment 184491 [details]
Patch

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

>> Source/WebCore/bindings/v8/V8GCController.cpp:106
>> +                    retainedObjectInfo = adoptPtr(new RetainedDOMInfo(static_cast<Node*>(root)));
> 
> Why is this static cast valid?

Because V8DOMWrapper::associateObjectWithWrapper will set wrapper class id to v8DOMNodeClassId only if the wrapped object is a DOM node and the opaque root for DOM nodes is always a node. I started with a patch that introduced NodeImplicitConnection and ObjectImplicitConnection derived from ImplicitConnection and made the compiler control that the root is a node. But it looked unnecessarily complicated.
Comment 5 Yury Semikhatsky 2013-01-25 03:23:10 PST
Created attachment 184715 [details]
Patch without static_cast<Node*>
Comment 6 Adam Barth 2013-01-25 09:28:43 PST
Comment on attachment 184715 [details]
Patch without static_cast<Node*>

Yay for no static_cast.  Thanks!
Comment 7 Adam Barth 2013-01-25 09:29:09 PST
Comment on attachment 184491 [details]
Patch

IMHO the later patch is better.
Comment 8 Yury Semikhatsky 2013-01-28 00:07:14 PST
Committed r140949: <http://trac.webkit.org/changeset/140949>