Bugzilla – Bug 543
Instead of cloning elements in the DOM, use the original tokens to reconstruct elements. (credit: hs) (bug 6743)
Last modified: 2009-11-23 17:17:27 CET
Index: source =================================================================== --- source (revision 2946) +++ source (revision 2947) @@ -64172,6 +64172,11 @@ prevent formatting from "leaking" into <code>applet</code> elements, buttons, <code>object</code> elements, marquees, and tables.</p> + <p>In addition, each element in the <span>list of active formatting + elements</span> is associated with the token for which it was + created, so that further elements can be created for that token if + necessary.</p> + <p>When the steps below require the UA to <dfn>reconstruct the active formatting elements</dfn>, the UA must perform the following steps:</p> @@ -64207,21 +64212,21 @@ <var title="">entry</var> in the <span>list of active formatting elements</span>.</li> - <li>Perform a shallow clone of the element <var title="">entry</var> to - obtain <var title="">clone</var>. <a - href="#refsDOM3CORE">[DOM3CORE]</a></li> + <li><span>Create an element for the token</span> for which the + element <var title="">entry</var> was created, to obtain <var + title="">new element</var>.</li> - <li>Append <var title="">clone</var> to the <span>current + <li>Append <var title="">new element</var> to the <span>current node</span> and push it onto the <span>stack of open elements</span> so that it is the new <span>current node</span>.</li> <li>Replace the entry for <var title="">entry</var> in the list - with an entry for <var title="">clone</var>.</li> + with an entry for <var title="">new element</var>.</li> - <li>If the entry for <var title="">clone</var> in the <span>list of - active formatting elements</span> is not the last entry in the - list, return to step 7.</li> + <li>If the entry for <var title="">new element</var> in the + <span>list of active formatting elements</span> is not the last + entry in the list, return to step 7.</li> </ol> @@ -67483,13 +67488,14 @@ title="">node</var> in the <span>list of active formatting elements</span>.</li> - <li>Perform a shallow - clone of <var title="">node</var>, replace the entry for - <var title="">node</var> in the <span>list of active formatting - elements</span> with an entry for the clone, replace the - entry for <var title="">node</var> in the <span>stack of open - elements</span> with an entry for the clone, and let - <var title="">node</var> be the clone.</li> + <li><span>Create an element for the token</span> for which the + element <var title="">node</var> was created, replace the entry + for <var title="">node</var> in the <span>list of active + formatting elements</span> with an entry for the new element, + replace the entry for <var title="">node</var> in the + <span>stack of open elements</span> with an entry for the new + element, and let <var title="">node</var> be the new + element.</li> <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous @@ -67519,36 +67525,32 @@ </li> - <li><p>Perform a shallow clone of the <var title="">formatting - element</var>.</p></li> + <li><p><span>Create an element for the token</span> for which the + <var title="">formatting element</var> was created.</p></li> <li><p>Take all of the child nodes of the <var title="">furthest - block</var> and append them to the clone created in the last + block</var> and append them to the element created in the last step.</p></li> - <li><p>Append that clone to the <var title="">furthest + <li><p>Append that new element to the <var title="">furthest block</var>.</p></li> <li><p>Remove the <var title="">formatting element</var> from the - <span>list of active formatting elements</span>, and insert - the clone into the <span>list of active formatting + <span>list of active formatting elements</span>, and insert the + new element into the <span>list of active formatting elements</span> at the position of the aforementioned bookmark.</p></li> <li><p>Remove the <var title="">formatting element</var> from the - <span>stack of open elements</span>, and insert the clone into - the <span>stack of open elements</span> immediately below the - position of the <var title="">furthest block</var> in that + <span>stack of open elements</span>, and insert the new element + into the <span>stack of open elements</span> immediately below + the position of the <var title="">furthest block</var> in that stack.</p></li> <li><p>Jump back to step 1 in this series of steps.</p></li> </ol> - <p class="note">The way these steps are defined, only elements - in the <span>formatting</span> category ever get cloned by - this algorithm.</p> - <!--XXX <div class="example"> <p class="XXX">Need an example.</p>