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

Side by Side Diff: Source/core/css/CSSVariableData.cpp

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ToTed Created 5 years, 4 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 | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698