[whatwg] Question about the bookmark in the adoption agency algorithm

Ian Hickson ian at hixie.ch
Tue Dec 13 15:50:08 PST 2011

On Thu, 6 Oct 2011, David Flanagan wrote:
> I'm trying to implement the HTML parser's adoption agency algorithm and am
> puzzled by this step:
> > Let a bookmark note the position of the formatting element in the list of
> > active formatting elements
> > <http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#list-of-active-formatting-elements>
> > relative to the elements on either side of it in the list.
> The metaphor of a bookmark is such that it marks a position between two 
> pages (or list elements in this case), and I'm having trouble with the 
> phrase "the elements on either side of it": I don't understand how this 
> bookmark can mark the position of one element relative to both the 
> element before and the element after.  That would require two bookmarks!  
> My guess, from the other steps that involve the bookmark is that it is 
> supposed to mark the position after the formatting element, but I'm 
> hoping that someone can confirm that for me.
> The second time the bookmark is mentioned it is to be moved " 
> immediately after the new node".  This is a bookmark position that I can 
> understand. And the final time the bookmark is mentioned, it is to " 
> insert the new element into the list...at the position of the 
> aforementioned bookmark." Like a cursor in text, a bookmark works as an 
> insertion position, so I get this part.
> I think that the first mention of the bookmark in the spec should be 
> clarified so that it is clear whether the bookmark marks the position 
> before the formatting element or the position after the formatting 
> element.

The formatting element referenced above is removed before the bookmark is 
used. Thus the bookmark is literally keeping track of the position of the 
formatting element itself, as if it was itself the bookmark. You can 
picture this as the bookmark being wrapped around the formatting element.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list