Remove some duplication in compositing
Move Parser creation to its own function (issue #849).

This is the first step to implement innerHTML, as we need a way
create and initialize a parser object while setting the received
DOMString (which may be either text/html/whatever).