[whatwg] Polynomial DOM growth with active formatting elements

Kartikaya Gupta lists.whatwg at stakface.com
Tue Nov 10 10:55:57 PST 2009


If you have a page like this:

<!DOCTYPE HTML>
<html><body>
<font size="2" face="Verdana">
<p align="left">Some text
<font size="2" face="Verdana">
<p align="left">Some text
</body></html>

according to the HTML5 parser rules, I believe this should create a DOM with 3 font elements that looks something like this:

<!DOCTYPE HTML><HTML><HEAD></HEAD><BODY>
<FONT face="Verdana" size="2">
<P align="left">Some text
<FONT face="Verdana" size="2">
</FONT></P><P align="left"><FONT size="2" face="Verdana">Some text

</FONT></P></FONT></BODY></HTML>

However, if you add extend the original source with another font/p combination, like so:

<!DOCTYPE HTML>
<html><body>
<font size="2" face="Verdana">
<p align="left">Some text
<font size="2" face="Verdana">
<p align="left">Some text
<font size="2" face="Verdana">
<p align="left">Some text
</body></html>

You end up with a DOM which has 6 font elements:

<!DOCTYPE HTML><HTML><HEAD></HEAD><BODY>
<FONT face="Verdana" size="2">
<P align="left">Some text
<FONT face="Verdana" size="2">
</FONT></P><P align="left"><FONT size="2" face="Verdana">Some text
<FONT face="Verdana" size="2">
</FONT></FONT></P><P align="left"><FONT face="Verdana" size="2"><FONT size="2" face="Verdana">Some text

</FONT></FONT></P></FONT></BODY></HTML>

.. and so on. In general the number of font elements in the DOM grows polynomially, with the result that pages like [1] and [2] end up with hundreds of thousands of font elements. I haven't even been able to successfully parse [3] with either our own HTML5 parser or the one at validator.nu, it just gobbles up all available memory and asks for more.

Is this behavior expected, or is it a bug in the spec? Obviously shipping browsers don't demonstrate this behavior (nor does Firefox's HTML5 parser - see bugzilla 525960) so I'm wondering if the spec could be modified to not have this polynomial-growth behavior.

Cheers,
kats

[1] http://www.miprepzone.com/past.asp?Category=%27news%27
[2] http://info4.juridicas.unam.mx/ijure/tcfed/8.htm?s=
[3] http://info4.juridicas.unam.mx/ijure/tcfed/1.htm?s=



More information about the whatwg mailing list