OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 "core/css/cssom/CSSTokenStreamValue.h" | |
6 | |
7 #include "bindings/core/v8/ExceptionState.h" | |
8 #include "bindings/core/v8/Iterable.h" | |
9 #include "bindings/core/v8/ScriptWrappable.h" | |
10 #include "core/CoreExport.h" | |
11 #include "core/css/CSSCustomIdentValue.h" | |
12 #include "core/css/CSSPrimitiveValue.h" | |
13 #include "core/css/CSSValueList.h" | |
14 #include "core/css/CSSVariableReferenceValue.h" | |
15 #include "core/css/cssom/CSSStyleValue.h" | |
16 #include "core/css/parser/CSSPropertyParser.h" | |
17 #include "core/css/parser/CSSTokenizer.h" | |
18 #include "core/dom/ExceptionCode.h" | |
19 #include "platform/heap/HeapAllocator.h" | |
20 #include "wtf/text/StringBuilder.h" | |
21 | |
22 | |
23 namespace blink { | |
24 | |
25 namespace { | |
26 | |
27 class TokenStreamValueIterationSource final : public ValueIterable<String>::Iter ationSource { | |
28 public: | |
29 explicit TokenStreamValueIterationSource(CSSTokenStreamValue* tokenStreamVal ue) | |
30 : m_tokenStreamValue(tokenStreamValue) | |
31 { | |
32 } | |
33 | |
34 bool next(ScriptState* scriptState, String& value, ExceptionState& exception State) 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.
| |
35 { | |
36 if (m_index >= m_tokenStreamValue->size()) | |
37 return false; | |
38 value = m_tokenStreamValue->referenceAtIndex(m_index); | |
39 return true; | |
40 } | |
41 | |
42 DEFINE_INLINE_VIRTUAL_TRACE() | |
43 { | |
44 visitor->trace(m_tokenStreamValue); | |
45 ValueIterable<String>::IterationSource::trace(visitor); | |
46 } | |
47 | |
48 private: | |
49 const Member<CSSTokenStreamValue> m_tokenStreamValue; | |
50 }; | |
51 | |
52 } // namespace | |
53 | |
54 ValueIterable<String>::IterationSource* CSSTokenStreamValue::startIteration(Scri ptState*, ExceptionState&) | |
55 { | |
56 return new TokenStreamValueIterationSource(this); | |
57 } | |
58 | |
59 CSSValue* CSSTokenStreamValue::toCSSValue() const | |
60 { | |
61 StringBuilder tokens; | |
62 | |
63 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.
| |
64 if (i) | |
65 tokens.append("/**/"); | |
66 tokens.append(m_listOfReferences[i]); | |
67 } | |
68 | |
69 CSSTokenizer::Scope scope(tokens.toString()); | |
70 | |
71 return CSSVariableReferenceValue::create(CSSVariableData::create(scope.token Range())); | |
72 } | |
73 | |
74 } // namespace blink | |
OLD | NEW |