Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h |
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h b/third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h |
| index b8a2f480df9071103c9bfae8978b5d7d2d3cce6c..4185753751bf66b8fd6b4ee11383c90b28837837 100644 |
| --- a/third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h |
| +++ b/third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h |
| @@ -5,6 +5,7 @@ |
| #ifndef CSSTokenizerInputStream_h |
| #define CSSTokenizerInputStream_h |
| +#include "core/html/parser/InputStreamPreprocessor.h" |
| #include "wtf/text/WTFString.h" |
| namespace blink { |
| @@ -13,21 +14,25 @@ struct CSSParserString; |
| class CSSTokenizerInputStream { |
| WTF_MAKE_NONCOPYABLE(CSSTokenizerInputStream); |
| - USING_FAST_MALLOC(CSSTokenizerInputStream); |
| + DISALLOW_NEW(); |
|
esprehn
2016/04/22 23:30:58
always on the stack or a member :)
|
| public: |
| - CSSTokenizerInputStream(String input); |
| + explicit CSSTokenizerInputStream(const String& input) |
| + : m_offset(0) |
| + , m_string(input.impl()) |
| + { |
| + } |
| - UChar peek(unsigned); |
| - inline UChar nextInputChar() |
|
esprehn
2016/04/22 23:30:58
missing const on both, also don't need inline in t
|
| + UChar peek(unsigned) const; |
| + UChar nextInputChar() const |
| { |
| return peek(0); |
| } |
| // For fast-path code, don't replace nulls with replacement characters |
| - UChar peekWithoutReplacement(unsigned lookaheadOffset) |
| + UChar peekWithoutReplacement(unsigned lookaheadOffset) const |
| { |
| - ASSERT((m_offset + lookaheadOffset) <= m_stringLength); |
| - if ((m_offset + lookaheadOffset) == m_stringLength) |
| + ASSERT((m_offset + lookaheadOffset) <= length()); |
| + if ((m_offset + lookaheadOffset) == length()) |
| return '\0'; |
| return (*m_string)[m_offset + lookaheadOffset]; |
| } |
| @@ -35,25 +40,39 @@ public: |
| void advance(unsigned offset = 1) { m_offset += offset; } |
| void pushBack(UChar); |
| - double getDouble(unsigned start, unsigned end); |
|
esprehn
2016/04/22 23:30:58
missing const
|
| + double getDouble(unsigned start, unsigned end) const; |
| template<bool characterPredicate(UChar)> |
| unsigned skipWhilePredicate(unsigned offset) |
| { |
| - while ((m_offset + offset) < m_stringLength && characterPredicate((*m_string)[m_offset + offset])) |
| + while ((m_offset + offset) < length() && characterPredicate((*m_string)[m_offset + offset])) |
| ++offset; |
| return offset; |
| } |
| - unsigned offset() const { return std::min(m_offset, m_stringLength); } |
| + unsigned length() const { return m_string->length(); } |
| + unsigned offset() const { return std::min(m_offset, length()); } |
| CSSParserString rangeAsCSSParserString(unsigned start, unsigned length) const; |
| private: |
| - size_t m_offset; |
| - const size_t m_stringLength; |
|
esprehn
2016/04/22 23:30:58
There's no reason to store the length, we have it
|
| + unsigned m_offset; |
| const RefPtr<StringImpl> m_string; |
| }; |
| +inline UChar CSSTokenizerInputStream::peek(unsigned lookaheadOffset) const |
| +{ |
| + if ((m_offset + lookaheadOffset) >= length()) |
| + return kEndOfFileMarker; |
| + UChar result = (*m_string)[m_offset + lookaheadOffset]; |
| + return result ? result : 0xFFFD; |
| +} |
| + |
| +inline void CSSTokenizerInputStream::pushBack(UChar cc) |
| +{ |
| + --m_offset; |
| + ASSERT(nextInputChar() == cc); |
| +} |
| + |
| } // namespace blink |
| #endif // CSSTokenizerInputStream_h |