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 #include "core/css/parser/CSSTokenizerInputStream.h" | 5 #include "core/css/parser/CSSTokenizerInputStream.h" |
6 | 6 |
7 #include "core/css/parser/CSSParserString.h" | |
8 #include "core/html/parser/InputStreamPreprocessor.h" | 7 #include "core/html/parser/InputStreamPreprocessor.h" |
9 | 8 |
10 namespace blink { | 9 namespace blink { |
11 | 10 |
12 CSSTokenizerInputStream::CSSTokenizerInputStream(String input) | 11 CSSTokenizerInputStream::CSSTokenizerInputStream(String input) |
13 : m_offset(0) | 12 : m_offset(0) |
14 , m_stringLength(input.length()) | 13 , m_stringLength(input.length()) |
15 , m_string(input.impl()) | 14 , m_string(input.impl()) |
16 { | 15 { |
17 } | 16 } |
(...skipping 20 matching lines...) Expand all Loading... |
38 if (start < end) { | 37 if (start < end) { |
39 if (m_string->is8Bit()) | 38 if (m_string->is8Bit()) |
40 result = charactersToDouble(m_string->characters8() + m_offset + sta
rt, end - start, &isResultOK); | 39 result = charactersToDouble(m_string->characters8() + m_offset + sta
rt, end - start, &isResultOK); |
41 else | 40 else |
42 result = charactersToDouble(m_string->characters16() + m_offset + st
art, end - start, &isResultOK); | 41 result = charactersToDouble(m_string->characters16() + m_offset + st
art, end - start, &isResultOK); |
43 } | 42 } |
44 // FIXME: It looks like callers ensure we have a valid number | 43 // FIXME: It looks like callers ensure we have a valid number |
45 return isResultOK ? result : 0.0; | 44 return isResultOK ? result : 0.0; |
46 } | 45 } |
47 | 46 |
48 CSSParserString CSSTokenizerInputStream::rangeAsCSSParserString(unsigned start,
unsigned length) const | 47 StringView CSSTokenizerInputStream::rangeAt(unsigned start, unsigned length) con
st |
49 { | 48 { |
50 ASSERT(start + length <= m_stringLength); | 49 ASSERT(start + length <= m_stringLength); |
51 CSSParserString result; | 50 return StringView(m_string.get(), start, length); |
52 if (m_string->is8Bit()) | |
53 result.init(m_string->characters8() + start, length); | |
54 else | |
55 result.init(m_string->characters16() + start, length); | |
56 return result; | |
57 } | 51 } |
58 | 52 |
59 } // namespace blink | 53 } // namespace blink |
OLD | NEW |