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::updateTokens() | |
14 { | |
15 const CharacterType* currentOffset = m_string.getCharacters<CharacterType>() ; | |
16 for (auto&& token : m_tokens) { | |
17 if (!token.needsStringBacking()) | |
18 continue; | |
19 | |
20 token.m_valueDataCharRaw = currentOffset; | |
Timothy Loh
2015/09/30 02:09:27
How about building m_tokens in this function inste
| |
21 currentOffset += token.m_valueLength; | |
22 } | |
23 ASSERT(currentOffset == m_string.getCharacters<CharacterType>() + m_string.l ength()); | |
24 } | |
25 | |
26 void CSSVariableData::consumeAndUpdateTokens(const CSSParserTokenRange& range) | |
27 { | |
28 StringBuilder stringBuilder; | |
29 CSSParserTokenRange localRange = range; | |
30 | |
31 while (!localRange.atEnd()) { | |
32 CSSParserToken token = localRange.consume(); | |
33 if (token.needsStringBacking()) { | |
34 if (token.valueIs8Bit()) | |
Timothy Loh
2015/09/30 02:09:27
Let's just get the string data off token.value() i
| |
35 stringBuilder.append(static_cast<const LChar*>(token.m_valueData CharRaw), token.m_valueLength); | |
36 else | |
37 stringBuilder.append(static_cast<const UChar*>(token.m_valueData CharRaw), token.m_valueLength); | |
38 } | |
39 m_tokens.append(token); | |
40 } | |
41 m_string = stringBuilder.toString(); | |
42 if (m_string.is8Bit()) | |
43 updateTokens<LChar>(); | |
44 else | |
45 updateTokens<UChar>(); | |
46 } | |
47 | |
48 CSSVariableData::CSSVariableData(const CSSParserTokenRange& range, bool needsVar iableResolution) | |
49 : m_needsVariableResolution(needsVariableResolution) | |
50 { | |
51 ASSERT(!range.atEnd()); | |
52 consumeAndUpdateTokens(range); | |
53 } | |
54 | |
55 } // namespace blink | |
OLD | NEW |