Skip to content

Commit

Permalink
[cgiowt] (2) Instead of cloning elements in the DOM, use the original…
Browse files Browse the repository at this point in the history
… tokens to reconstruct elements. (credit: hs) (bug 6743)

git-svn-id: http://svn.whatwg.org/webapps@2947 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Apr 1, 2009
1 parent a96e30c commit 88d7870
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 59 deletions.
62 changes: 31 additions & 31 deletions index
Expand Up @@ -52256,6 +52256,11 @@ interface <dfn id=messageport>MessagePort</dfn> {
prevent formatting from "leaking" into <code><a href=#the-applet-element>applet</a></code> elements,
buttons, <code><a href=#the-object-element>object</a></code> elements, marquees, and tables.</p>

<p>In addition, each element in the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a> 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 id=reconstruct-the-active-formatting-elements>reconstruct the
active formatting elements</dfn>, the UA must perform the following
steps:</p>
Expand Down Expand Up @@ -52289,20 +52294,20 @@ interface <dfn id=messageport>MessagePort</dfn> {
<var title="">entry</var> in the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a>.</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><a href=#create-an-element-for-the-token>Create an element for the token</a> 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 <a href=#current-node>current
<li>Append <var title="">new element</var> to the <a href=#current-node>current
node</a> and push it onto the <a href=#stack-of-open-elements>stack of open
elements</a> so that it is the new <a href=#current-node>current
node</a>.</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 <a href=#list-of-active-formatting-elements>list of
active formatting elements</a> 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
<a href=#list-of-active-formatting-elements>list of active formatting elements</a> is not the last
entry in the list, return to step 7.</li>

</ol><p>This has the effect of reopening all the formatting elements that
were opened in the current body, cell, or caption (whichever is
Expand Down Expand Up @@ -55218,13 +55223,14 @@ interface <dfn id=messageport>MessagePort</dfn> {
bookmark to be immediately after the <var title="">node</var> in the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a>.</li>

<li>Perform a shallow
clone of <var title="">node</var>, replace the entry for
<var title="">node</var> in the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a> with an entry for the clone, replace the
entry for <var title="">node</var> in the <a href=#stack-of-open-elements>stack of open
elements</a> with an entry for the clone, and let
<var title="">node</var> be the clone.</li>
<li><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the
element <var title="">node</var> was created, replace the entry
for <var title="">node</var> in the <a href=#list-of-active-formatting-elements>list of active
formatting elements</a> with an entry for the new element,
replace the entry for <var title="">node</var> in the
<a href=#stack-of-open-elements>stack of open elements</a> 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
parent node if any.</li>
Expand All @@ -55251,41 +55257,35 @@ interface <dfn id=messageport>MessagePort</dfn> {

</li>

<li><p>Perform a shallow clone of the <var title="">formatting
element</var>.</li>
<li><p><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the
<var title="">formatting element</var> was created.</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.</li>

<li><p>Append that clone to the <var title="">furthest
<li><p>Append that new element to the <var title="">furthest
block</var>.</li>

<li><p>Remove the <var title="">formatting element</var> from the
<a href=#list-of-active-formatting-elements>list of active formatting elements</a>, and insert
the clone into the <a href=#list-of-active-formatting-elements>list of active formatting
<a href=#list-of-active-formatting-elements>list of active formatting elements</a>, and insert the
new element into the <a href=#list-of-active-formatting-elements>list of active formatting
elements</a> at the position of the aforementioned
bookmark.</li>

<li><p>Remove the <var title="">formatting element</var> from the
<a href=#stack-of-open-elements>stack of open elements</a>, and insert the clone into
the <a href=#stack-of-open-elements>stack of open elements</a> immediately below the
position of the <var title="">furthest block</var> in that
<a href=#stack-of-open-elements>stack of open elements</a>, and insert the new element
into the <a href=#stack-of-open-elements>stack of open elements</a> immediately below
the position of the <var title="">furthest block</var> in that
stack.</li>

<li><p>Jump back to step 1 in this series of steps.</li>

</ol><p class=note>The way these steps are defined, only elements
in the <a href=#formatting>formatting</a> category ever get cloned by
this algorithm.</p>

<!--XXX
</ol><!--XXX
<div class="example">
<p class="XXX">Need an example.</p>
</div>
-->

<p class=note>Because of the way this algorithm causes elements to
--><p class=note>Because of the way this algorithm causes elements to
change parents, it has been dubbed the "adoption agency algorithm"
(in contrast with other possibly algorithms for dealing with
misnested content, which included the "incest algorithm", the
Expand Down
58 changes: 30 additions & 28 deletions source
Expand Up @@ -64172,6 +64172,11 @@ interface <dfn>MessagePort</dfn> {
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>
Expand Down Expand Up @@ -64207,21 +64212,21 @@ interface <dfn>MessagePort</dfn> {
<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>

Expand Down Expand Up @@ -67483,13 +67488,14 @@ interface <dfn>MessagePort</dfn> {
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
Expand Down Expand Up @@ -67519,36 +67525,32 @@ interface <dfn>MessagePort</dfn> {

</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>
Expand Down

0 comments on commit 88d7870

Please sign in to comment.