Add implementation for Character Token case in in-body insertion mode

https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
This commit is contained in:
iska
2015-03-02 23:57:15 +01:00
parent d65463b4d6
commit 3ff1044c6d
3 changed files with 30 additions and 0 deletions
+23
View File
@@ -789,7 +789,30 @@
- (void)HTMLInsertionModeInBody:(HTMLToken *)token
{
switch (token.type) {
case HTMLTokenTypeCharacter:
{
NSMutableString *charactes = [token.asCharacterToken.characters mutableCopy];
NSUInteger nullCount = [charactes replaceOccurrencesOfString:@"\0"
withString:@""
options:NSLiteralSearch
range:NSMakeRange(0, charactes.length)];
for (int i = 0; i < nullCount; i++) {
[self emitParseError:@"Unexpected Character (0x0000) in <body>"];
}
if (charactes.length > 0) {
[self reconstructActiveFormattingElements];
[self insertCharacters:charactes];
if ([charactes containsHTMLWhitespace]) {
_framesetOkFlag = NO;
}
}
return;
}
default:
break;
}
}
- (void)HTMLInsertionModeText:(HTMLToken *)token
+1
View File
@@ -12,6 +12,7 @@
- (BOOL)isEqualToAny:(NSString *)first, ... NS_REQUIRES_NIL_TERMINATION;
- (BOOL)isHTMLWhitespaceString;
- (BOOL)containsHTMLWhitespace;
- (NSUInteger)leadingWhitespaceLength;
@end
+6
View File
@@ -34,6 +34,12 @@ NS_INLINE BOOL isHtmlWhitespaceChar(char c)
return [self rangeOfCharacterFromSet:set].location == NSNotFound;
}
- (BOOL)containsHTMLWhitespace
{
NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@" \t\n\f\r"];
return [self rangeOfCharacterFromSet:set].location != NSNotFound;
}
- (NSUInteger)leadingWhitespaceLength
{
const char *str = self.UTF8String;