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

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

Issue 2367663002: [WIP] Attempt to move everything cssom into a cssom namespace (Closed)
Patch Set: Created 4 years, 2 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 namespace cssom {
12 13
13 namespace { 14 namespace {
14 15
15 class UnparsedValueIterationSource final : public ValueIterable<StringOrCSSVaria bleReferenceValue>::IterationSource { 16 class UnparsedValueIterationSource final : public ValueIterable<StringOrCSSVaria bleReferenceValue>::IterationSource {
16 public: 17 public:
17 explicit UnparsedValueIterationSource(CSSUnparsedValue* unparsedValue) 18 explicit UnparsedValueIterationSource(CSSUnparsedValue* unparsedValue)
18 : m_unparsedValue(unparsedValue) 19 : m_unparsedValue(unparsedValue)
19 { 20 {
20 } 21 }
21 22
22 bool next(ScriptState*, StringOrCSSVariableReferenceValue& value, ExceptionS tate&) override 23 bool next(blink::ScriptState*, StringOrCSSVariableReferenceValue& value, Exc eptionState&) override
23 { 24 {
24 if (m_index >= m_unparsedValue->size()) 25 if (m_index >= m_unparsedValue->size())
25 return false; 26 return false;
26 value = m_unparsedValue->fragmentAtIndex(m_index); 27 value = m_unparsedValue->fragmentAtIndex(m_index);
27 return true; 28 return true;
28 } 29 }
29 30
30 DEFINE_INLINE_VIRTUAL_TRACE() 31 DEFINE_INLINE_VIRTUAL_TRACE()
31 { 32 {
32 visitor->trace(m_unparsedValue); 33 visitor->trace(m_unparsedValue);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 range.consume().serialize(builder); 75 range.consume().serialize(builder);
75 } 76 }
76 } 77 }
77 if (!builder.isEmpty()) 78 if (!builder.isEmpty())
78 fragments.append(StringOrCSSVariableReferenceValue::fromString(builder.t oString())); 79 fragments.append(StringOrCSSVariableReferenceValue::fromString(builder.t oString()));
79 return fragments; 80 return fragments;
80 } 81 }
81 82
82 } // namespace 83 } // namespace
83 84
84 ValueIterable<StringOrCSSVariableReferenceValue>::IterationSource* CSSUnparsedVa lue::startIteration(ScriptState*, ExceptionState&) 85 ValueIterable<StringOrCSSVariableReferenceValue>::IterationSource* CSSUnparsedVa lue::startIteration(blink::ScriptState*, ExceptionState&)
85 { 86 {
86 return new UnparsedValueIterationSource(this); 87 return new UnparsedValueIterationSource(this);
87 } 88 }
88 89
89 CSSUnparsedValue* CSSUnparsedValue::fromCSSValue(const CSSVariableReferenceValue & cssVariableReferenceValue) 90 CSSUnparsedValue* CSSUnparsedValue::fromCSSValue(const CSSVariableReferenceValue & cssVariableReferenceValue)
90 { 91 {
91 return CSSUnparsedValue::create(parserTokenRangeToFragments(cssVariableRefer enceValue.variableDataValue()->tokenRange())); 92 return CSSUnparsedValue::create(parserTokenRangeToFragments(cssVariableRefer enceValue.variableDataValue()->tokenRange()));
92 } 93 }
93 94
94 CSSValue* CSSUnparsedValue::toCSSValue() const 95 CSSValue* CSSUnparsedValue::toCSSValue() const
95 { 96 {
96 StringBuilder tokens; 97 StringBuilder tokens;
97 98
98 for (unsigned i = 0; i < m_fragments.size(); i++) { 99 for (unsigned i = 0; i < m_fragments.size(); i++) {
99 if (i) 100 if (i)
100 tokens.append("/**/"); 101 tokens.append("/**/");
101 if (m_fragments[i].isString()) 102 if (m_fragments[i].isString())
102 tokens.append(m_fragments[i].getAsString()); 103 tokens.append(m_fragments[i].getAsString());
103 else if (m_fragments[i].isCSSVariableReferenceValue()) 104 else if (m_fragments[i].isCSSVariableReferenceValue())
104 tokens.append(m_fragments[i].getAsCSSVariableReferenceValue()->varia ble()); 105 tokens.append(m_fragments[i].getAsCSSVariableReferenceValue()->varia ble());
105 else 106 else
106 NOTREACHED(); 107 NOTREACHED();
107 } 108 }
108 109
109 CSSTokenizer::Scope scope(tokens.toString()); 110 CSSTokenizer::Scope scope(tokens.toString());
110 111
111 return CSSVariableReferenceValue::create(CSSVariableData::create(scope.token Range())); 112 return CSSVariableReferenceValue::create(CSSVariableData::create(scope.token Range()));
112 } 113 }
113 114
115 } // namespace cssom
114 } // namespace blink 116 } // namespace blink
117
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698