static double getFraction(CSSTokenizerInputStream& input, unsigned& offset) { 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); }
static int getSign(CSSTokenizerInputStream& input, unsigned& offset) { int sign = 1; if (input.nextInputChar() == '+') { ++offset; } else if (input.peek(offset) == '-') { sign = -1; ++offset; } return sign; }
static NumericSign getSign(CSSTokenizerInputStream& input, unsigned& offset) { if (input.nextInputChar() == '+') { ++offset; return PlusSign; } if (input.nextInputChar() == '-') { ++offset; return MinusSign; } return NoSign; }
static double getInteger(CSSTokenizerInputStream& input, unsigned& offset) { unsigned intStartPos = offset; offset = input.skipWhilePredicate<isASCIIDigit>(offset); unsigned intEndPos = offset; return input.getDouble(intStartPos, intEndPos); }
static double getExponent(CSSTokenizerInputStream& input, unsigned& offset, int& sign) { unsigned exponentStartPos = 0; unsigned exponentEndPos = 0; if ((input.peek(offset) == 'E' || input.peek(offset) == 'e')) { int offsetBeforeExponent = offset; ++offset; if (input.peek(offset) == '+') { ++offset; } else if (input.peek(offset) =='-') { sign = -1; ++offset; } exponentStartPos = offset; offset = input.skipWhilePredicate<isASCIIDigit>(offset); exponentEndPos = offset; if (exponentEndPos == exponentStartPos) offset = offsetBeforeExponent; } return input.getDouble(exponentStartPos, exponentEndPos); }