[HTMLTemplateElement] prevent the parser from removing nodes from the content when the foster agency is processing formatting elements
https://bugs.webkit.org/show_bug.cgi?id=108377

Reviewed by Adam Barth.

Source/WebCore:

https://dvcs.w3.org/hg/webcomponents/raw-file/50ce1f368c1a/spec/templates/index.html#in-body-addition

callTheAdoptionAgency now appends to the template's content when it previously would have appended to the template element itself.

New test added to html5lib.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::parserInsertBefore):
(WebCore::ContainerNode::parserAppendChild):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::callTheAdoptionAgency):

LayoutTests:

Note that dump-as-markup.js is modified here to put both template content and its direct children. This was an oversight and fixing it will make it
easier to spot parse errors like ones that arise from this bug, where nodes are appended directly to the template element.

* html5lib/resources/template.dat:
* resources/dump-as-markup.js:
(Markup._get):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
HTMLDocumentParser::insert should be aware of threaded parsing
https://bugs.webkit.org/show_bug.cgi?id=107764

Reviewed by Eric Seidel.

This patch is an incremental step towards recovering from
document.write invalidating our speculative parsing buffer. The
approach I've taken is to make it possible to transfer the
HTMLDocumentParser's HTMLTokenizer and HTMLToken to the background
thread. To make that possible, I've taught the HTMLDocumentParser how
to operate without a tokenizer or a token.

Not having a tokenizer or a token while parsing in the background also
helps us avoid accidentially feeding input to the main thread's
tokenizer when we're supposed to feed it to the background thread.

This patch shouldn't have any behavior change (other than possibly
fixing a crash in fast/parser when threading parsing is enabled).

* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::HTMLDocumentParser):
(WebCore::HTMLDocumentParser::didFailSpeculation):
(WebCore):
(WebCore::HTMLDocumentParser::insert):
(WebCore::HTMLDocumentParser::finish):
(WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):
* html/parser/HTMLDocumentParser.h:
(HTMLDocumentParser):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::constructTree):
(WebCore::HTMLTreeBuilder::processStartTagForInBody):
(WebCore::HTMLTreeBuilder::processEndTag):
(WebCore::HTMLTreeBuilder::processGenericRCDATAStartTag):
(WebCore::HTMLTreeBuilder::processGenericRawTextStartTag):
(WebCore::HTMLTreeBuilder::processScriptStartTag):
* html/parser/TextDocumentParser.cpp:
(WebCore::TextDocumentParser::TextDocumentParser):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141328 268f45cc-cd09-0410-ab3c-d52691b4dbfc