Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "core/css/parser/MediaQueryInputStream.h" | |
| 7 | |
| 8 #include "core/html/parser/InputStreamPreprocessor.h" | |
| 9 | |
| 10 namespace WebCore { | |
| 11 | |
| 12 MediaQueryInputStream::MediaQueryInputStream(String input) | |
| 13 : m_offset(0) | |
| 14 , m_string(input) | |
| 15 { | |
| 16 } | |
| 17 | |
| 18 UChar MediaQueryInputStream::currentInputChar() | |
| 19 { | |
| 20 if (m_offset >= m_string.length()) | |
|
eseidel
2014/03/11 20:14:19
Same here. Looks like thsi could be implemented i
| |
| 21 return kEndOfFileMarker; | |
| 22 return m_string[m_offset]; | |
| 23 } | |
| 24 | |
| 25 UChar MediaQueryInputStream::peek(unsigned lookaheadOffset) | |
| 26 { | |
| 27 if ((m_offset + lookaheadOffset) >= m_string.length()) | |
|
eseidel
2014/03/11 20:14:19
This is a bit odd. EOF should only be length + 1,
| |
| 28 return kEndOfFileMarker; | |
| 29 return m_string[m_offset + lookaheadOffset]; | |
| 30 } | |
| 31 | |
| 32 void MediaQueryInputStream::advance(unsigned offset) | |
| 33 { | |
| 34 ASSERT(m_offset + offset <= m_string.length() + 1); | |
|
eseidel
2014/03/11 20:14:19
Maybe we need a lengthIncludingEOF() helper, or ju
| |
| 35 m_offset += offset; | |
| 36 } | |
| 37 | |
| 38 void MediaQueryInputStream::pushBack(UChar cc) | |
| 39 { | |
| 40 --m_offset; | |
| 41 ASSERT(currentInputChar() == cc); | |
| 42 } | |
| 43 | |
| 44 unsigned long long MediaQueryInputStream::getUInt(unsigned start, unsigned end) | |
| 45 { | |
| 46 ASSERT(start <= end && ((m_offset + end) <= m_string.length())); | |
| 47 bool isResultOK = false; | |
| 48 if (start < end) { | |
| 49 unsigned long long result; | |
| 50 if (m_string.is8Bit()) | |
| 51 result = charactersToUInt64Strict(m_string.characters8() + m_offset + start, end - start, &isResultOK); | |
| 52 else | |
| 53 result = charactersToUInt64Strict(m_string.characters16() + m_offset + start, end - start, &isResultOK); | |
| 54 if (isResultOK) | |
| 55 return result; | |
| 56 } | |
| 57 return 0; | |
| 58 } | |
| 59 | |
| 60 double MediaQueryInputStream::getDouble(unsigned start, unsigned end) | |
| 61 { | |
| 62 ASSERT(start <= end && ((m_offset + end) <= m_string.length())); | |
| 63 bool isResultOK = false; | |
| 64 if (start < end) { | |
| 65 double result; | |
| 66 if (m_string.is8Bit()) | |
| 67 result = charactersToDouble(m_string.characters8() + m_offset + star t, end - start, &isResultOK); | |
| 68 else | |
| 69 result = charactersToDouble(m_string.characters16() + m_offset + sta rt, end - start, &isResultOK); | |
| 70 if (isResultOK) | |
| 71 return result; | |
| 72 } | |
| 73 return 0.0; | |
| 74 } | |
| 75 | |
| 76 } // namespace WebCore | |
| OLD | NEW |