Bug 61997 - Cloning elements with shadow DOM does redundant element creation
Summary: Cloning elements with shadow DOM does redundant element creation
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Blocks: 61983
  Show dependency treegraph
Reported: 2011-06-03 00:53 PDT by Dominic Cooney
Modified: 2011-06-06 21:51 PDT (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Dominic Cooney 2011-06-03 00:53:42 PDT
Cloning an element with shadow DOM typically does redundant element creation.

For example, cloning an <input type="range" style="…"> creates one shadow slider element during the HTMLInputElement clone when it clones its type attribute (which creates a RangeInputType, which creates a shadow subtree for the slider.) Then Element::copyNonAttributeProperties destroys that shadow subtree and creates another shadow subtree that is a clone of the shadow subtree of the original node.

We only need one of these two shadow trees.
Comment 1 Kent Tamura 2011-06-03 03:32:28 PDT
So, reverting http://trac.webkit.org/changeset/84528/trunk/Source/WebCore/dom/Element.cpp will solve everything?
Comment 2 Kent Tamura 2011-06-03 03:33:08 PDT
I meant reverting http://trac.webkit.org/changeset/84528 .
Comment 3 Dominic Cooney 2011-06-03 03:42:16 PDT
Reverting 84528 will ensure that there is no redundant element creation. However it does not ensure that cloned elements end up with valid shadow trees. (For example, <keygen> has no hook to clone its shadow.)

I think we need a general solution where elements with shadow roots get notified when they are cloned, so that they can participate in the clone. For elements like <input type="…"> where setting the type attribute will create a shadow tree anyway, it can just assert that the shadow tree was created.

For elements like keygen, it can create the clone shadow tree at that point.
Comment 4 Kent Tamura 2011-06-03 03:53:44 PDT
(In reply to comment #3)
Keygen build the shadow tree in the constructor.   Cloning a keygen needs nothing else, right?
Comment 5 Dominic Cooney 2011-06-03 04:03:19 PDT
Yes, you’re right, keygen would work if r84528 was reverted. Maybe we should revert it…
Comment 6 Hajime Morrita 2011-06-06 21:36:36 PDT
Is this valid yet?
Comment 7 Dominic Cooney 2011-06-06 21:51:34 PDT
Since r84528 was reverted, this bug is no longer applicable.