Fix consume CSS identifier input stream method

http://www.w3.org/TR/CSS21/syndata.html#characters
https://drafts.csswg.org/css-syntax/#consume-name
This commit is contained in:
iska
2015-11-24 23:01:11 +01:00
parent c57d3453fc
commit c8dd1d7791
2 changed files with 25 additions and 0 deletions
+19
View File
@@ -113,6 +113,25 @@ NS_INLINE BOOL isValidEscapedCodePoint(UTF32Char codePoint)
codePoint <= 0x10FFFF);
}
NS_INLINE BOOL isValidIdentifierStart(UTF32Char first, UTF32Char second, UTF32Char third)
{
if (first == HYPHEN_MINUS) {
if (isNameStart(second) ||
second == HYPHEN_MINUS ||
isValidEscape(second, third)) {
return YES;
} else {
return NO;
}
} else if (isNameStart(first)) {
return YES;
} else if (first == REVERSE_SOLIDUS) {
return isValidEscape(first, second);
} else {
return NO;
}
}
NS_INLINE void AppendCodePoint(CFMutableStringRef string, UTF32Char codePoint)
{
UniChar pair[2];
+6
View File
@@ -26,6 +26,12 @@
{
CFMutableStringRef value = CFStringCreateMutable(kCFAllocatorDefault, 0);
if (!isValidIdentifierStart([self inputCharacterPointAtOffset:0],
[self inputCharacterPointAtOffset:1],
[self inputCharacterPointAtOffset:2])) {
return nil;
}
while (YES) {
UTF32Char codePoint = [self consumeNextInputCharacter];
if (codePoint == EOF) {