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

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

Issue 2683853005: bindings: Make some value iterator properties aliases to Array.prototype functions (Closed)
Patch Set: Remove constexpr from Internals.h to fix the Android build Created 3 years, 10 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/cssom/CSSUnparsedValue.h" 5 #include "core/css/cssom/CSSUnparsedValue.h"
6 6
7 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" 7 #include "core/css/cssom/CSSStyleVariableReferenceValue.h"
8 #include "core/css/parser/CSSTokenizer.h" 8 #include "core/css/parser/CSSTokenizer.h"
9 #include "wtf/text/StringBuilder.h" 9 #include "wtf/text/StringBuilder.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 namespace { 13 namespace {
14 14
15 class UnparsedValueIterationSource final
16 : public ValueIterable<StringOrCSSVariableReferenceValue>::IterationSource {
17 public:
18 explicit UnparsedValueIterationSource(CSSUnparsedValue* unparsedValue)
19 : m_unparsedValue(unparsedValue) {}
20
21 bool next(ScriptState*,
22 StringOrCSSVariableReferenceValue& value,
23 ExceptionState&) override {
24 if (m_index >= m_unparsedValue->size())
25 return false;
26 value = m_unparsedValue->fragmentAtIndex(m_index);
27 return true;
28 }
29
30 DEFINE_INLINE_VIRTUAL_TRACE() {
31 visitor->trace(m_unparsedValue);
32 ValueIterable<StringOrCSSVariableReferenceValue>::IterationSource::trace(
33 visitor);
34 }
35
36 private:
37 const Member<CSSUnparsedValue> m_unparsedValue;
38 };
39
40 StringView findVariableName(CSSParserTokenRange& range) { 15 StringView findVariableName(CSSParserTokenRange& range) {
41 range.consumeWhitespace(); 16 range.consumeWhitespace();
42 return range.consume().value(); 17 return range.consume().value();
43 } 18 }
44 19
45 StringOrCSSVariableReferenceValue variableReferenceValue( 20 StringOrCSSVariableReferenceValue variableReferenceValue(
46 const StringView& variableName, 21 const StringView& variableName,
47 const HeapVector<StringOrCSSVariableReferenceValue>& fragments) { 22 const HeapVector<StringOrCSSVariableReferenceValue>& fragments) {
48 CSSUnparsedValue* unparsedValue; 23 CSSUnparsedValue* unparsedValue;
49 if (fragments.size() == 0) 24 if (fragments.size() == 0)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 57 }
83 if (!builder.isEmpty()) { 58 if (!builder.isEmpty()) {
84 fragments.push_back( 59 fragments.push_back(
85 StringOrCSSVariableReferenceValue::fromString(builder.toString())); 60 StringOrCSSVariableReferenceValue::fromString(builder.toString()));
86 } 61 }
87 return fragments; 62 return fragments;
88 } 63 }
89 64
90 } // namespace 65 } // namespace
91 66
92 ValueIterable<StringOrCSSVariableReferenceValue>::IterationSource*
93 CSSUnparsedValue::startIteration(ScriptState*, ExceptionState&) {
94 return new UnparsedValueIterationSource(this);
95 }
96
97 CSSUnparsedValue* CSSUnparsedValue::fromCSSValue( 67 CSSUnparsedValue* CSSUnparsedValue::fromCSSValue(
98 const CSSVariableReferenceValue& cssVariableReferenceValue) { 68 const CSSVariableReferenceValue& cssVariableReferenceValue) {
99 return CSSUnparsedValue::create(parserTokenRangeToFragments( 69 return CSSUnparsedValue::create(parserTokenRangeToFragments(
100 cssVariableReferenceValue.variableDataValue()->tokenRange())); 70 cssVariableReferenceValue.variableDataValue()->tokenRange()));
101 } 71 }
102 72
103 CSSValue* CSSUnparsedValue::toCSSValue() const { 73 CSSValue* CSSUnparsedValue::toCSSValue() const {
104 StringBuilder tokens; 74 StringBuilder tokens;
105 75
106 for (unsigned i = 0; i < m_fragments.size(); i++) { 76 for (unsigned i = 0; i < m_fragments.size(); i++) {
(...skipping 10 matching lines...) Expand all
117 } 87 }
118 } 88 }
119 89
120 CSSTokenizer tokenizer(tokens.toString()); 90 CSSTokenizer tokenizer(tokens.toString());
121 return CSSVariableReferenceValue::create(CSSVariableData::create( 91 return CSSVariableReferenceValue::create(CSSVariableData::create(
122 tokenizer.tokenRange(), false /* isAnimationTainted */, 92 tokenizer.tokenRange(), false /* isAnimationTainted */,
123 true /* needsVariableResolution */)); 93 true /* needsVariableResolution */));
124 } 94 }
125 95
126 } // namespace blink 96 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698