OLD | NEW |
---|---|
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/CSSSyntaxDescriptor.h" | 5 #include "core/css/CSSSyntaxDescriptor.h" |
6 | 6 |
7 #include "core/animation/CSSColorInterpolationType.h" | 7 #include "core/animation/CSSColorInterpolationType.h" |
8 #include "core/animation/CSSLengthInterpolationType.h" | 8 #include "core/animation/CSSLengthInterpolationType.h" |
9 #include "core/animation/CSSValueInterpolationType.h" | 9 #include "core/animation/CSSValueInterpolationType.h" |
10 #include "core/css/CSSCustomPropertyDeclaration.h" | 10 #include "core/css/CSSCustomPropertyDeclaration.h" |
11 #include "core/css/CSSURIValue.h" | 11 #include "core/css/CSSURIValue.h" |
12 #include "core/css/CSSValueList.h" | 12 #include "core/css/CSSValueList.h" |
13 #include "core/css/CSSVariableReferenceValue.h" | 13 #include "core/css/CSSVariableReferenceValue.h" |
14 #include "core/css/parser/CSSParserIdioms.h" | 14 #include "core/css/parser/CSSParserIdioms.h" |
15 #include "core/css/parser/CSSParserLocalContext.h" | |
15 #include "core/css/parser/CSSPropertyParserHelpers.h" | 16 #include "core/css/parser/CSSPropertyParserHelpers.h" |
16 #include "core/css/parser/CSSVariableParser.h" | 17 #include "core/css/parser/CSSVariableParser.h" |
18 #include "core/css/properties/CSSPropertyAPITransform.h" | |
17 #include "core/html/parser/HTMLParserIdioms.h" | 19 #include "core/html/parser/HTMLParserIdioms.h" |
18 | 20 |
19 namespace blink { | 21 namespace blink { |
20 | 22 |
21 void ConsumeWhitespace(const String& string, size_t& offset) { | 23 void ConsumeWhitespace(const String& string, size_t& offset) { |
22 while (IsHTMLSpace(string[offset])) | 24 while (IsHTMLSpace(string[offset])) |
23 offset++; | 25 offset++; |
24 } | 26 } |
25 | 27 |
26 bool ConsumeCharacterAndWhitespace(const String& string, | 28 bool ConsumeCharacterAndWhitespace(const String& string, |
(...skipping 23 matching lines...) Expand all Loading... | |
50 if (type == "url") | 52 if (type == "url") |
51 return CSSSyntaxType::kUrl; | 53 return CSSSyntaxType::kUrl; |
52 if (type == "integer") | 54 if (type == "integer") |
53 return CSSSyntaxType::kInteger; | 55 return CSSSyntaxType::kInteger; |
54 if (type == "angle") | 56 if (type == "angle") |
55 return CSSSyntaxType::kAngle; | 57 return CSSSyntaxType::kAngle; |
56 if (type == "time") | 58 if (type == "time") |
57 return CSSSyntaxType::kTime; | 59 return CSSSyntaxType::kTime; |
58 if (type == "resolution") | 60 if (type == "resolution") |
59 return CSSSyntaxType::kResolution; | 61 return CSSSyntaxType::kResolution; |
60 if (type == "transform-function") | 62 if (type == "transform-list") |
61 return CSSSyntaxType::kTransformFunction; | 63 return CSSSyntaxType::kTransformList; |
62 if (type == "custom-ident") | 64 if (type == "custom-ident") |
63 return CSSSyntaxType::kCustomIdent; | 65 return CSSSyntaxType::kCustomIdent; |
64 // Not an Ident, just used to indicate failure | 66 // Not an Ident, just used to indicate failure |
65 return CSSSyntaxType::kIdent; | 67 return CSSSyntaxType::kIdent; |
66 } | 68 } |
67 | 69 |
68 bool ConsumeSyntaxType(const String& input, | 70 bool ConsumeSyntaxType(const String& input, |
69 size_t& offset, | 71 size_t& offset, |
70 CSSSyntaxType& type) { | 72 CSSSyntaxType& type) { |
71 DCHECK_EQ(input[offset], '<'); | 73 DCHECK_EQ(input[offset], '<'); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 type = CSSSyntaxType::kIdent; | 117 type = CSSSyntaxType::kIdent; |
116 success = ConsumeSyntaxIdent(input, offset, ident); | 118 success = ConsumeSyntaxIdent(input, offset, ident); |
117 } | 119 } |
118 | 120 |
119 if (!success) { | 121 if (!success) { |
120 syntax_components_.clear(); | 122 syntax_components_.clear(); |
121 return; | 123 return; |
122 } | 124 } |
123 | 125 |
124 bool repeatable = ConsumeCharacterAndWhitespace(input, '+', offset); | 126 bool repeatable = ConsumeCharacterAndWhitespace(input, '+', offset); |
127 // <transform-list> is already a space separated list, | |
128 // <transform-list>+ is invalid. | |
129 if (type == CSSSyntaxType::kTransformList && repeatable) { | |
130 syntax_components_.clear(); | |
131 return; | |
132 } | |
125 ConsumeWhitespace(input, offset); | 133 ConsumeWhitespace(input, offset); |
126 syntax_components_.push_back(CSSSyntaxComponent(type, ident, repeatable)); | 134 syntax_components_.push_back(CSSSyntaxComponent(type, ident, repeatable)); |
127 | 135 |
128 } while (ConsumeCharacterAndWhitespace(input, '|', offset)); | 136 } while (ConsumeCharacterAndWhitespace(input, '|', offset)); |
129 | 137 |
130 if (offset != input.length()) | 138 if (offset != input.length()) |
131 syntax_components_.clear(); | 139 syntax_components_.clear(); |
132 } | 140 } |
133 | 141 |
134 const CSSValue* ConsumeSingleType(const CSSSyntaxComponent& syntax, | 142 const CSSValue* ConsumeSingleType(const CSSSyntaxComponent& syntax, |
(...skipping 26 matching lines...) Expand all Loading... | |
161 case CSSSyntaxType::kUrl: | 169 case CSSSyntaxType::kUrl: |
162 return ConsumeUrl(range, context); | 170 return ConsumeUrl(range, context); |
163 case CSSSyntaxType::kInteger: | 171 case CSSSyntaxType::kInteger: |
164 return ConsumeInteger(range); | 172 return ConsumeInteger(range); |
165 case CSSSyntaxType::kAngle: | 173 case CSSSyntaxType::kAngle: |
166 return ConsumeAngle(range, *context, WTF::Optional<WebFeature>()); | 174 return ConsumeAngle(range, *context, WTF::Optional<WebFeature>()); |
167 case CSSSyntaxType::kTime: | 175 case CSSSyntaxType::kTime: |
168 return ConsumeTime(range, ValueRange::kValueRangeAll); | 176 return ConsumeTime(range, ValueRange::kValueRangeAll); |
169 case CSSSyntaxType::kResolution: | 177 case CSSSyntaxType::kResolution: |
170 return ConsumeResolution(range); | 178 return ConsumeResolution(range); |
171 case CSSSyntaxType::kTransformFunction: | 179 case CSSSyntaxType::kTransformList: |
172 return nullptr; // TODO(timloh): Implement this. | 180 return CSSPropertyAPITransform::parseSingleValue(range, *context, |
181 CSSParserLocalContext()); | |
meade_UTC10
2017/06/21 06:57:44
I had a discussion with the team - and we decided
Hwanseung Lee
2017/06/22 00:39:53
i made CSSPropertyTransformUtils files(it was copi
| |
173 case CSSSyntaxType::kCustomIdent: | 182 case CSSSyntaxType::kCustomIdent: |
174 return ConsumeCustomIdent(range); | 183 return ConsumeCustomIdent(range); |
175 default: | 184 default: |
176 NOTREACHED(); | 185 NOTREACHED(); |
177 return nullptr; | 186 return nullptr; |
178 } | 187 } |
179 } | 188 } |
180 | 189 |
181 const CSSValue* ConsumeSyntaxComponent(const CSSSyntaxComponent& syntax, | 190 const CSSValue* ConsumeSyntaxComponent(const CSSSyntaxComponent& syntax, |
182 CSSParserTokenRange range, | 191 CSSParserTokenRange range, |
(...skipping 26 matching lines...) Expand all Loading... | |
209 for (const CSSSyntaxComponent& component : syntax_components_) { | 218 for (const CSSSyntaxComponent& component : syntax_components_) { |
210 if (const CSSValue* result = | 219 if (const CSSValue* result = |
211 ConsumeSyntaxComponent(component, range, context)) | 220 ConsumeSyntaxComponent(component, range, context)) |
212 return result; | 221 return result; |
213 } | 222 } |
214 return CSSVariableParser::ParseRegisteredPropertyValue(range, *context, true, | 223 return CSSVariableParser::ParseRegisteredPropertyValue(range, *context, true, |
215 is_animation_tainted); | 224 is_animation_tainted); |
216 } | 225 } |
217 | 226 |
218 } // namespace blink | 227 } // namespace blink |
OLD | NEW |