Index: Source/core/css/parser/CSSTokenizer.cpp |
diff --git a/Source/core/css/parser/CSSTokenizer.cpp b/Source/core/css/parser/CSSTokenizer.cpp |
index 955fb19459dbac83fe298f37a23df689b1eb4627..069150f6ca923cae3c797c76a59694211a93a0e6 100644 |
--- a/Source/core/css/parser/CSSTokenizer.cpp |
+++ b/Source/core/css/parser/CSSTokenizer.cpp |
@@ -275,17 +275,13 @@ static unsigned long long getInteger(CSSTokenizerInputStream& input, unsigned& o |
return input.getUInt(intStartPos, intEndPos); |
} |
-static double getFraction(CSSTokenizerInputStream& input, unsigned& offset, unsigned& digitsNumber) |
+static double getFraction(CSSTokenizerInputStream& input, unsigned& offset) |
{ |
- unsigned fractionStartPos = 0; |
- unsigned fractionEndPos = 0; |
- if (input.peek(offset) == '.' && isASCIIDigit(input.peek(++offset))) { |
- fractionStartPos = offset - 1; |
- offset = input.skipWhilePredicate<isASCIIDigit>(offset); |
- fractionEndPos = offset; |
- } |
- digitsNumber = fractionEndPos- fractionStartPos; |
- return input.getDouble(fractionStartPos, fractionEndPos); |
+ if (input.peek(offset) != '.' || !isASCIIDigit(input.peek(offset + 1))) |
+ return 0; |
+ unsigned startOffset = offset; |
+ offset = input.skipWhilePredicate<isASCIIDigit>(offset + 1); |
+ return input.getDouble(startOffset, offset); |
} |
Yoav Weiss
2014/10/20 07:06:45
So beyond the refactoring (which I like), and the
Timothy Loh
2014/10/20 07:18:24
There's a change here which is to only consume the
Yoav Weiss
2014/10/20 07:26:14
Oh, right. So the move from 'isASCIIDigit(input.pe
|
static unsigned long long getExponent(CSSTokenizerInputStream& input, unsigned& offset, int& sign) |
@@ -320,16 +316,17 @@ CSSParserToken CSSTokenizer::consumeNumber() |
double value = 0; |
unsigned offset = 0; |
int exponentSign = 1; |
- unsigned fractionDigits; |
int sign = getSign(m_input, offset); |
unsigned long long integerPart = getInteger(m_input, offset); |
- double fractionPart = getFraction(m_input, offset, fractionDigits); |
+ unsigned integerPartEndOffset = offset; |
+ |
+ double fractionPart = getFraction(m_input, offset); |
unsigned long long exponentPart = getExponent(m_input, offset, exponentSign); |
double exponent = pow(10, (float)exponentSign * (double)exponentPart); |
value = (double)sign * ((double)integerPart + fractionPart) * exponent; |
m_input.advance(offset); |
- if (fractionDigits > 0) |
+ if (offset != integerPartEndOffset) |
Yoav Weiss
2014/10/20 07:06:45
This is where the magic happens, and exponents are
Timothy Loh
2014/10/20 07:18:24
Yep
|
type = NumberValueType; |
return CSSParserToken(NumberToken, value, type); |