W3C home > Mailing lists > Public > public-html@w3.org > February 2009

Re: Conditional branch in tree builder based on DOM state

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 11 Feb 2009 09:27:37 +0000 (UTC)
To: Henri Sivonen <hsivonen@iki.fi>
Cc: HTMLWG WG <public-html@w3.org>
Message-ID: <Pine.LNX.4.62.0902110914480.28232@hixie.dreamhostps.com>
On Fri, 2 Jan 2009, Henri Sivonen wrote:
> On Dec 25, 2008, at 12:59, Ian Hickson wrote:
> > On Tue, 9 Dec 2008, Henri Sivonen wrote:
> > 
> > > The spec change suggestion, therefore, is making step 7.5. of the AAA
> > > read "If node has any *parser-inserted* children, perform a shallow
> > > clone of node——".
> > [...]
> > While what you describe would make your particular implementation strategy
> > easier, it would in fact complicate implementations that support script
> > and operate on the DOM directly (i.e. all script-aware implementations
> > today).
> It would add a boolean flag to each stack node. The main complication 
> seems to be the setting the flag, which is pretty tame. Granted, it does 
> change the nature of the stack nodes a bit, since so far they've been 
> immutable.
> > Instead, I recommend passing along an _assertion_ along with the 
> > mutations, along the lines of "these elements have children" and 
> > "these elements don't have children", which the main thread can 
> > quickly check. If the assertions turn out to be false, which will only 
> > happen in rare caes, then the thread can synchronise with the main 
> > thread, getting itself updated on what nodes have children, and then 
> > try again from that point.
> This seems a lot more complicated than requiring all implementations to 
> maintain a flag on each stack node.

I still haven't added this, because there doesn't seem to be much interest 
in this beyond your request, and because I really do think that keeping 
extra state around is a lot more expensive than you suggest.

I don't think that synchronising is that complicated, as it is a 
relatively localised and well-understandable piece of code (though I admit 
the code wouldn't be trivial), and it has the advantage of only slowing 
down rare cases where there exists a script doing these crazy 
modifications _and_ the parser is threaded. Having extra state everywhere 
would mean (slightly) slowing down everyone in all cases.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 11 February 2009 09:28:15 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:42 UTC