OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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/CSSVariableData.h" | |
7 | |
8 #include "core/css/parser/CSSParserTokenRange.h" | |
9 #include "wtf/text/StringBuilder.h" | |
10 | |
11 namespace blink { | |
12 | |
13 template<typename CharacterType> void CSSVariableData::consumeAndUpdateTokens(co nst CSSParserTokenRange& range) | |
14 { | |
15 StringBuilder stringBuilder; | |
16 CSSParserTokenRange localRange = range; | |
17 const CharacterType* currentOffset = nullptr; | |
18 | |
19 while (!localRange.atEnd()) { | |
20 CSSParserToken token = localRange.consume(); | |
Timothy Loh
2015/08/25 09:21:09
const CSSParserToken&
| |
21 const CharacterType* tokenLocation = static_cast<const CharacterType*>(t oken.m_valueDataCharRaw); | |
Timothy Loh
2015/08/25 09:21:09
We should check the token type is string-y (probab
| |
22 stringBuilder.append(tokenLocation, token.m_valueLength); | |
23 currentOffset += token.m_valueLength; | |
Timothy Loh
2015/08/25 09:21:09
Not used? Just define the variable below when it's
| |
24 m_tokens.append(token); | |
25 } | |
26 m_string = stringBuilder.toString(); | |
27 currentOffset = m_string.getCharacters<CharacterType>(); | |
28 for (auto&& token : m_tokens) { | |
29 token.m_valueDataCharRaw = currentOffset; | |
30 currentOffset += token.m_valueLength; | |
31 } | |
32 ASSERT(currentOffset == m_string.getCharacters<CharacterType>() + m_string.l ength()); | |
33 } | |
34 | |
35 CSSVariableData::CSSVariableData(const CSSParserTokenRange& range, bool needsVar iableResolution) | |
36 : m_needsVariableResolution(needsVariableResolution) | |
37 { | |
38 ASSERT(!range.atEnd()); | |
39 // TODO(leviw): We probably can't assume that the first value being 8bit gua rantees | |
Timothy Loh
2015/08/25 09:21:09
It doesn't; just fix up the function above to call
| |
40 // that all are. | |
41 if (range.peek().valueIs8Bit()) | |
42 consumeAndUpdateTokens<LChar>(range); | |
43 else | |
44 consumeAndUpdateTokens<UChar>(range); | |
45 } | |
46 | |
47 } // namespace blink | |
OLD | NEW |