| 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/StringView.h" |
| 9 #include "wtf/text/WTFString.h" | 9 #include "wtf/text/WTFString.h" |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 { | 43 { |
| 44 --m_offset; | 44 --m_offset; |
| 45 DCHECK(nextInputChar() == cc); | 45 DCHECK(nextInputChar() == cc); |
| 46 } | 46 } |
| 47 | 47 |
| 48 double getDouble(unsigned start, unsigned end) const; | 48 double getDouble(unsigned start, unsigned end) const; |
| 49 | 49 |
| 50 template<bool characterPredicate(UChar)> | 50 template<bool characterPredicate(UChar)> |
| 51 unsigned skipWhilePredicate(unsigned offset) | 51 unsigned skipWhilePredicate(unsigned offset) |
| 52 { | 52 { |
| 53 while ((m_offset + offset) < m_stringLength && characterPredicate((*m_st
ring)[m_offset + offset])) | 53 if (m_string->is8Bit()) { |
| 54 ++offset; | 54 const LChar* characters8 = m_string->characters8(); |
| 55 while ((m_offset + offset) < m_stringLength && characterPredicate(ch
aracters8[m_offset + offset])) |
| 56 ++offset; |
| 57 } else { |
| 58 const UChar* characters16 = m_string->characters16(); |
| 59 while ((m_offset + offset) < m_stringLength && characterPredicate(ch
aracters16[m_offset + offset])) |
| 60 ++offset; |
| 61 } |
| 55 return offset; | 62 return offset; |
| 56 } | 63 } |
| 57 | 64 |
| 58 void advanceUntilNonWhitespace(); | 65 void advanceUntilNonWhitespace(); |
| 59 | 66 |
| 60 unsigned length() const { return m_stringLength; } | 67 unsigned length() const { return m_stringLength; } |
| 61 unsigned offset() const { return std::min(m_offset, m_stringLength); } | 68 unsigned offset() const { return std::min(m_offset, m_stringLength); } |
| 62 | 69 |
| 63 StringView rangeAt(unsigned start, unsigned length) const | 70 StringView rangeAt(unsigned start, unsigned length) const |
| 64 { | 71 { |
| 65 DCHECK(start + length <= m_stringLength); | 72 DCHECK(start + length <= m_stringLength); |
| 66 return StringView(*m_string, start, length); | 73 return StringView(*m_string, start, length); |
| 67 } | 74 } |
| 68 | 75 |
| 69 private: | 76 private: |
| 70 size_t m_offset; | 77 size_t m_offset; |
| 71 const size_t m_stringLength; | 78 const size_t m_stringLength; |
| 72 const RefPtr<StringImpl> m_string; | 79 const RefPtr<StringImpl> m_string; |
| 73 }; | 80 }; |
| 74 | 81 |
| 75 } // namespace blink | 82 } // namespace blink |
| 76 | 83 |
| 77 #endif // CSSTokenizerInputStream_h | 84 #endif // CSSTokenizerInputStream_h |
| 78 | 85 |
| OLD | NEW |