Add implementation for the parser's Initial Insertion Mode

https://html.spec.whatwg.org/multipage/syntax.html#the-initial-insertion-mode
This commit is contained in:
iska
2015-02-28 01:03:02 +01:00
parent c2086e482e
commit 7717cb7472
+40
View File
@@ -347,7 +347,47 @@
- (void)HTMLInsertionModeInitial:(HTMLToken *)token
{
switch (token.type) {
case HTMLTokenTypeCharacter:
{
if ([token.asCharacterToken isWhitespaceToken]) {
return;
}
break;
}
case HTMLTokenTypeComment:
{
[self insertComment:token.asCommentToken asChildOfNode:_document];
return;
}
case HTMLTokenTypeDoctype:
{
HTMLDOCTYPEToken *doctypeToken = token.asDoctypeToken;
HTMLDocumentType *doctype = [[HTMLDocumentType alloc] initWithName:doctypeToken.name
publicIdentifier:doctypeToken.publicIdentifier
systemIdentifier:doctypeToken.systemIdentifier];
if (!doctype.isValid) {
[self emitParseError:@"Invalid DOCTYPE"];
}
_document.documentType = doctype;
_document.quirksMode = doctype.quirksMode;
if (doctypeToken.forceQuirks) {
_document.quirksMode = HTMLQuirksModeQuirks;
}
[self switchInsertionMode:HTMLInsertionModeBeforeHTML];
return;
}
default:
break;
}
#warning Check "iframe srcdoc"
[self switchInsertionMode:HTMLInsertionModeBeforeHTML];
[self reprocessToken:token];
}
- (void)HTMLInsertionModeBeforeHTML:(HTMLToken *)token