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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSTokenStreamValue.cpp

Issue 2122193003: [Typed-OM] Add CSSTokenStreamValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test for CSSTokenStreamValue Created 4 years, 5 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
OLDNEW
(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 "core/css/CSSVariableReferenceValue.h"
8 #include "core/css/parser/CSSTokenizer.h"
9 #include "wtf/text/StringBuilder.h"
10
11 namespace blink {
12
13 namespace {
14
15 class TokenStreamValueIterationSource final : public ValueIterable<String>::Iter ationSource {
16 public:
17 explicit TokenStreamValueIterationSource(CSSTokenStreamValue* tokenStreamVal ue)
18 : m_tokenStreamValue(tokenStreamValue)
19 {
20 }
21
22 bool next(ScriptState*, String& value, ExceptionState&) override
23 {
24 if (m_index >= m_tokenStreamValue->size())
25 return false;
26 value = m_tokenStreamValue->fragmentAtIndex(m_index);
27 return true;
28 }
29
30 DEFINE_INLINE_VIRTUAL_TRACE()
31 {
32 visitor->trace(m_tokenStreamValue);
33 ValueIterable<String>::IterationSource::trace(visitor);
34 }
35
36 private:
37 const Member<CSSTokenStreamValue> m_tokenStreamValue;
38 };
39
40 } // namespace
41
42 ValueIterable<String>::IterationSource* CSSTokenStreamValue::startIteration(Scri ptState*, ExceptionState&)
43 {
44 return new TokenStreamValueIterationSource(this);
45 }
46
47 CSSValue* CSSTokenStreamValue::toCSSValue() const
48 {
49 StringBuilder tokens;
50
51 for (unsigned i = 0; i < m_fragments.size(); i++) {
52 if (i)
53 tokens.append("/**/");
54 tokens.append(m_fragments[i]);
55 }
56
57 CSSTokenizer::Scope scope(tokens.toString());
58
59 return CSSVariableReferenceValue::create(CSSVariableData::create(scope.token Range()));
60 }
61
62 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698