Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.cpp

Issue 2107503002: Add missing const on CSSTokenizerInputStream methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/html/parser/HTMLParserIdioms.h" 7 #include "core/html/parser/HTMLParserIdioms.h"
8 #include "core/html/parser/InputStreamPreprocessor.h" 8 #include "core/html/parser/InputStreamPreprocessor.h"
9 #include "wtf/text/StringToNumber.h" 9 #include "wtf/text/StringToNumber.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 CSSTokenizerInputStream::CSSTokenizerInputStream(String input) 13 CSSTokenizerInputStream::CSSTokenizerInputStream(String input)
14 : m_offset(0) 14 : m_offset(0)
15 , m_stringLength(input.length()) 15 , m_stringLength(input.length())
16 , m_string(input.impl()) 16 , m_string(input.impl())
17 { 17 {
18 } 18 }
19 19
20 UChar CSSTokenizerInputStream::peek(unsigned lookaheadOffset) 20 UChar CSSTokenizerInputStream::peek(unsigned lookaheadOffset) const
21 { 21 {
22 if ((m_offset + lookaheadOffset) >= m_stringLength) 22 if ((m_offset + lookaheadOffset) >= m_stringLength)
23 return kEndOfFileMarker; 23 return kEndOfFileMarker;
24 UChar result = (*m_string)[m_offset + lookaheadOffset]; 24 UChar result = (*m_string)[m_offset + lookaheadOffset];
25 return result ? result : 0xFFFD; 25 return result ? result : 0xFFFD;
26 } 26 }
27 27
28 void CSSTokenizerInputStream::pushBack(UChar cc)
29 {
30 --m_offset;
31 ASSERT(nextInputChar() == cc);
32 }
33
34 void CSSTokenizerInputStream::advanceUntilNonWhitespace() 28 void CSSTokenizerInputStream::advanceUntilNonWhitespace()
35 { 29 {
36 // Using HTML space here rather than CSS space since we don't do preprocessi ng 30 // Using HTML space here rather than CSS space since we don't do preprocessi ng
37 if (m_string->is8Bit()) { 31 if (m_string->is8Bit()) {
38 const LChar* characters = m_string->characters8(); 32 const LChar* characters = m_string->characters8();
39 while (m_offset < m_stringLength && isHTMLSpace(characters[m_offset])) 33 while (m_offset < m_stringLength && isHTMLSpace(characters[m_offset]))
40 ++m_offset; 34 ++m_offset;
41 } else { 35 } else {
42 const UChar* characters = m_string->characters16(); 36 const UChar* characters = m_string->characters16();
43 while (m_offset < m_stringLength && isHTMLSpace(characters[m_offset])) 37 while (m_offset < m_stringLength && isHTMLSpace(characters[m_offset]))
44 ++m_offset; 38 ++m_offset;
45 } 39 }
46 } 40 }
47 41
48 double CSSTokenizerInputStream::getDouble(unsigned start, unsigned end) 42 double CSSTokenizerInputStream::getDouble(unsigned start, unsigned end) const
49 { 43 {
50 ASSERT(start <= end && ((m_offset + end) <= m_stringLength)); 44 DCHECK(start <= end && ((m_offset + end) <= m_stringLength));
51 bool isResultOK = false; 45 bool isResultOK = false;
52 double result = 0.0; 46 double result = 0.0;
53 if (start < end) { 47 if (start < end) {
54 if (m_string->is8Bit()) 48 if (m_string->is8Bit())
55 result = charactersToDouble(m_string->characters8() + m_offset + sta rt, end - start, &isResultOK); 49 result = charactersToDouble(m_string->characters8() + m_offset + sta rt, end - start, &isResultOK);
56 else 50 else
57 result = charactersToDouble(m_string->characters16() + m_offset + st art, end - start, &isResultOK); 51 result = charactersToDouble(m_string->characters16() + m_offset + st art, end - start, &isResultOK);
58 } 52 }
59 // FIXME: It looks like callers ensure we have a valid number 53 // FIXME: It looks like callers ensure we have a valid number
60 return isResultOK ? result : 0.0; 54 return isResultOK ? result : 0.0;
61 } 55 }
62 56
63 StringView CSSTokenizerInputStream::rangeAt(unsigned start, unsigned length) con st 57 StringView CSSTokenizerInputStream::rangeAt(unsigned start, unsigned length) con st
64 { 58 {
65 ASSERT(start + length <= m_stringLength); 59 DCHECK(start + length <= m_stringLength);
66 return StringView(m_string.get(), start, length); 60 return StringView(m_string.get(), start, length);
67 } 61 }
68 62
69 } // namespace blink 63 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698