| Index: Source/core/css/CSSVariableData.cpp
|
| diff --git a/Source/core/css/CSSVariableData.cpp b/Source/core/css/CSSVariableData.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..97511047e4f3c33764ad307778065a4b4ff0a61f
|
| --- /dev/null
|
| +++ b/Source/core/css/CSSVariableData.cpp
|
| @@ -0,0 +1,47 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "config.h"
|
| +#include "core/css/CSSVariableData.h"
|
| +
|
| +#include "core/css/parser/CSSParserTokenRange.h"
|
| +#include "wtf/text/StringBuilder.h"
|
| +
|
| +namespace blink {
|
| +
|
| +template<typename CharacterType> void CSSVariableData::consumeAndUpdateTokens(const CSSParserTokenRange& range)
|
| +{
|
| + StringBuilder stringBuilder;
|
| + CSSParserTokenRange localRange = range;
|
| + const CharacterType* currentOffset = nullptr;
|
| +
|
| + while (!localRange.atEnd()) {
|
| + CSSParserToken token = localRange.consume();
|
| + const CharacterType* tokenLocation = static_cast<const CharacterType*>(token.m_valueDataCharRaw);
|
| + stringBuilder.append(tokenLocation, token.m_valueLength);
|
| + currentOffset += token.m_valueLength;
|
| + m_tokens.append(token);
|
| + }
|
| + m_string = stringBuilder.toString();
|
| + currentOffset = m_string.getCharacters<CharacterType>();
|
| + for (auto&& token : m_tokens) {
|
| + token.m_valueDataCharRaw = currentOffset;
|
| + currentOffset += token.m_valueLength;
|
| + }
|
| + ASSERT(currentOffset = m_string.getCharacters<CharacterType>() + m_string.length());
|
| +}
|
| +
|
| +CSSVariableData::CSSVariableData(const CSSParserTokenRange& range, bool needsVariableResolution)
|
| + : m_needsVariableResolution(needsVariableResolution)
|
| +{
|
| + ASSERT(!range.atEnd());
|
| + // TODO(leviw): We probably can't assume that the first value being 8bit guarantees
|
| + // that all are.
|
| + if (range.peek().valueIs8Bit())
|
| + consumeAndUpdateTokens<LChar>(range);
|
| + else
|
| + consumeAndUpdateTokens<UChar>(range);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|