Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/cssom/CSSTokenStreamValue.cpp |
| diff --git a/third_party/WebKit/Source/core/css/cssom/CSSTokenStreamValue.cpp b/third_party/WebKit/Source/core/css/cssom/CSSTokenStreamValue.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c51d7d110994304cb71382f60f718a59d035da64 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/css/cssom/CSSTokenStreamValue.cpp |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2016 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 "core/css/cssom/CSSTokenStreamValue.h" |
| + |
| +#include "bindings/core/v8/ExceptionState.h" |
| +#include "bindings/core/v8/Iterable.h" |
| +#include "bindings/core/v8/ScriptWrappable.h" |
| +#include "core/CoreExport.h" |
| +#include "core/css/CSSCustomIdentValue.h" |
| +#include "core/css/CSSPrimitiveValue.h" |
| +#include "core/css/CSSValueList.h" |
| +#include "core/css/CSSVariableReferenceValue.h" |
| +#include "core/css/cssom/CSSStyleValue.h" |
| +#include "core/css/parser/CSSPropertyParser.h" |
| +#include "core/css/parser/CSSTokenizer.h" |
| +#include "core/dom/ExceptionCode.h" |
| +#include "platform/heap/HeapAllocator.h" |
| +#include "wtf/text/StringBuilder.h" |
| + |
| + |
| +namespace blink { |
| + |
| +namespace { |
| + |
| +class TokenStreamValueIterationSource final : public ValueIterable<String>::IterationSource { |
| +public: |
| + explicit TokenStreamValueIterationSource(CSSTokenStreamValue* tokenStreamValue) |
| + : m_tokenStreamValue(tokenStreamValue) |
| + { |
| + } |
| + |
| + bool next(ScriptState* scriptState, String& value, ExceptionState& exceptionState) override |
|
Timothy Loh
2016/07/19 03:40:20
You don't need to name arguments you don't referen
anthonyhkf
2016/07/19 03:55:14
Done.
|
| + { |
| + if (m_index >= m_tokenStreamValue->size()) |
| + return false; |
| + value = m_tokenStreamValue->referenceAtIndex(m_index); |
| + return true; |
| + } |
| + |
| + DEFINE_INLINE_VIRTUAL_TRACE() |
| + { |
| + visitor->trace(m_tokenStreamValue); |
| + ValueIterable<String>::IterationSource::trace(visitor); |
| + } |
| + |
| +private: |
| + const Member<CSSTokenStreamValue> m_tokenStreamValue; |
| +}; |
| + |
| +} // namespace |
| + |
| +ValueIterable<String>::IterationSource* CSSTokenStreamValue::startIteration(ScriptState*, ExceptionState&) |
| +{ |
| + return new TokenStreamValueIterationSource(this); |
| +} |
| + |
| +CSSValue* CSSTokenStreamValue::toCSSValue() const |
| +{ |
| + StringBuilder tokens; |
| + |
| + for (unsigned i = 0; i < m_listOfReferences.size(); ++i) { |
|
meade_UTC10
2016/07/08 00:29:08
nit: i++ for consistency
anthonyhkf
2016/07/19 03:55:15
Done.
|
| + if (i) |
| + tokens.append("/**/"); |
| + tokens.append(m_listOfReferences[i]); |
| + } |
| + |
| + CSSTokenizer::Scope scope(tokens.toString()); |
| + |
| + return CSSVariableReferenceValue::create(CSSVariableData::create(scope.tokenRange())); |
| +} |
| + |
| +} // namespace blink |