OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CSSTokenizerInputStream_h | 5 #ifndef CSSTokenizerInputStream_h |
6 #define CSSTokenizerInputStream_h | 6 #define CSSTokenizerInputStream_h |
7 | 7 |
| 8 #include "wtf/text/StringView.h" |
8 #include "wtf/text/WTFString.h" | 9 #include "wtf/text/WTFString.h" |
9 | 10 |
10 namespace blink { | 11 namespace blink { |
11 | 12 |
12 struct CSSParserString; | |
13 | |
14 class CSSTokenizerInputStream { | 13 class CSSTokenizerInputStream { |
15 WTF_MAKE_NONCOPYABLE(CSSTokenizerInputStream); | 14 WTF_MAKE_NONCOPYABLE(CSSTokenizerInputStream); |
16 USING_FAST_MALLOC(CSSTokenizerInputStream); | 15 USING_FAST_MALLOC(CSSTokenizerInputStream); |
17 public: | 16 public: |
18 CSSTokenizerInputStream(String input); | 17 CSSTokenizerInputStream(String input); |
19 | 18 |
20 UChar peek(unsigned); | 19 UChar peek(unsigned); |
21 inline UChar nextInputChar() | 20 inline UChar nextInputChar() |
22 { | 21 { |
23 return peek(0); | 22 return peek(0); |
(...skipping 15 matching lines...) Expand all Loading... |
39 | 38 |
40 template<bool characterPredicate(UChar)> | 39 template<bool characterPredicate(UChar)> |
41 unsigned skipWhilePredicate(unsigned offset) | 40 unsigned skipWhilePredicate(unsigned offset) |
42 { | 41 { |
43 while ((m_offset + offset) < m_stringLength && characterPredicate((*m_st
ring)[m_offset + offset])) | 42 while ((m_offset + offset) < m_stringLength && characterPredicate((*m_st
ring)[m_offset + offset])) |
44 ++offset; | 43 ++offset; |
45 return offset; | 44 return offset; |
46 } | 45 } |
47 | 46 |
48 unsigned offset() const { return std::min(m_offset, m_stringLength); } | 47 unsigned offset() const { return std::min(m_offset, m_stringLength); } |
49 CSSParserString rangeAsCSSParserString(unsigned start, unsigned length) cons
t; | 48 StringView rangeAt(unsigned start, unsigned length) const; |
50 | 49 |
51 private: | 50 private: |
52 size_t m_offset; | 51 size_t m_offset; |
53 const size_t m_stringLength; | 52 const size_t m_stringLength; |
54 const RefPtr<StringImpl> m_string; | 53 const RefPtr<StringImpl> m_string; |
55 }; | 54 }; |
56 | 55 |
57 } // namespace blink | 56 } // namespace blink |
58 | 57 |
59 #endif // CSSTokenizerInputStream_h | 58 #endif // CSSTokenizerInputStream_h |
60 | 59 |
OLD | NEW |