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

Side by Side Diff: sky/engine/core/css/resolver/StyleBuilderConverter.cpp

Issue 689853003: Remove CSS Grid Layout and grid media queries. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * * Redistributions of source code must retain the above copyright 4 * * Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer. 5 * notice, this list of conditions and the following disclaimer.
6 * * Redistributions in binary form must reproduce the above 6 * * Redistributions in binary form must reproduce the above
7 * copyright notice, this list of conditions and the following disclaimer 7 * copyright notice, this list of conditions and the following disclaimer
8 * in the documentation and/or other materials provided with the 8 * in the documentation and/or other materials provided with the
9 * distribution. 9 * distribution.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 11 matching lines...) Expand all
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/css/resolver/StyleBuilderConverter.h" 28 #include "core/css/resolver/StyleBuilderConverter.h"
29 29
30 #include "core/css/CSSFontFeatureValue.h" 30 #include "core/css/CSSFontFeatureValue.h"
31 #include "core/css/CSSFunctionValue.h" 31 #include "core/css/CSSFunctionValue.h"
32 #include "core/css/CSSGridLineNamesValue.h"
33 #include "core/css/CSSPrimitiveValueMappings.h" 32 #include "core/css/CSSPrimitiveValueMappings.h"
34 #include "core/css/CSSShadowValue.h" 33 #include "core/css/CSSShadowValue.h"
35 #include "core/css/Pair.h" 34 #include "core/css/Pair.h"
36 #include "core/css/Rect.h" 35 #include "core/css/Rect.h"
37 36
38 namespace blink { 37 namespace blink {
39 38
40 namespace {
41
42 static GridLength convertGridTrackBreadth(const StyleResolverState& state, CSSPr imitiveValue* primitiveValue)
43 {
44 if (primitiveValue->getValueID() == CSSValueMinContent)
45 return Length(MinContent);
46
47 if (primitiveValue->getValueID() == CSSValueMaxContent)
48 return Length(MaxContent);
49
50 // Fractional unit.
51 if (primitiveValue->isFlex())
52 return GridLength(primitiveValue->getDoubleValue());
53
54 return primitiveValue->convertToLength<FixedConversion | PercentConversion | AutoConversion>(state.cssToLengthConversionData());
55 }
56
57 } // namespace
58
59 Color StyleBuilderConverter::convertColor(StyleResolverState& state, CSSValue* v alue) 39 Color StyleBuilderConverter::convertColor(StyleResolverState& state, CSSValue* v alue)
60 { 40 {
61 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 41 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
62 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa lue, state.style()->color()); 42 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa lue, state.style()->color());
63 } 43 }
64 44
65 AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState & state, CSSValue* value) 45 AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState & state, CSSValue* value)
66 { 46 {
67 return nullAtom; 47 return nullAtom;
68 } 48 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 124 }
145 } 125 }
146 return ligatures; 126 return ligatures;
147 } 127 }
148 128
149 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); 129 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue());
150 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal); 130 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal);
151 return FontDescription::VariantLigatures(); 131 return FontDescription::VariantLigatures();
152 } 132 }
153 133
154 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value* value)
155 {
156 // We accept the specification's grammar:
157 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust om-ident> ] ] | <custom-ident>
158
159 GridPosition position;
160
161 if (value->isPrimitiveValue()) {
162 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
163 // We translate <custom-ident> to <string> during parsing as it
164 // makes handling it more simple.
165 if (primitiveValue->isString()) {
166 position.setNamedGridArea(primitiveValue->getStringValue());
167 return position;
168 }
169
170 ASSERT(primitiveValue->getValueID() == CSSValueAuto);
171 return position;
172 }
173
174 CSSValueList* values = toCSSValueList(value);
175 ASSERT(values->length());
176
177 bool isSpanPosition = false;
178 // The specification makes the <integer> optional, in which case it default to '1'.
179 int gridLineNumber = 1;
180 String gridLineName;
181
182 CSSValueListIterator it = values;
183 CSSPrimitiveValue* currentValue = toCSSPrimitiveValue(it.value());
184 if (currentValue->getValueID() == CSSValueSpan) {
185 isSpanPosition = true;
186 it.advance();
187 currentValue = it.hasMore() ? toCSSPrimitiveValue(it.value()) : 0;
188 }
189
190 if (currentValue && currentValue->isNumber()) {
191 gridLineNumber = currentValue->getIntValue();
192 it.advance();
193 currentValue = it.hasMore() ? toCSSPrimitiveValue(it.value()) : 0;
194 }
195
196 if (currentValue && currentValue->isString()) {
197 gridLineName = currentValue->getStringValue();
198 it.advance();
199 }
200
201 ASSERT(!it.hasMore());
202 if (isSpanPosition)
203 position.setSpanPosition(gridLineNumber, gridLineName);
204 else
205 position.setExplicitPosition(gridLineNumber, gridLineName);
206
207 return position;
208 }
209
210 GridTrackSize StyleBuilderConverter::convertGridTrackSize(StyleResolverState& st ate, CSSValue* value)
211 {
212 if (value->isPrimitiveValue())
213 return GridTrackSize(convertGridTrackBreadth(state, toCSSPrimitiveValue( value)));
214
215 CSSFunctionValue* minmaxFunction = toCSSFunctionValue(value);
216 CSSValueList* arguments = minmaxFunction->arguments();
217 ASSERT_WITH_SECURITY_IMPLICATION(arguments->length() == 2);
218 GridLength minTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu e(arguments->item(0))));
219 GridLength maxTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu e(arguments->item(1))));
220 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
221 }
222
223 bool StyleBuilderConverter::convertGridTrackList(CSSValue* value, Vector<GridTra ckSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& o rderedNamedGridLines, StyleResolverState& state)
224 {
225 // Handle 'none'.
226 if (value->isPrimitiveValue()) {
227 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
228 return primitiveValue->getValueID() == CSSValueNone;
229 }
230
231 if (!value->isValueList())
232 return false;
233
234 size_t currentNamedGridLine = 0;
235 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
236 CSSValue* currValue = i.value();
237 if (currValue->isGridLineNamesValue()) {
238 CSSGridLineNamesValue* lineNamesValue = toCSSGridLineNamesValue(curr Value);
239 for (CSSValueListIterator j = lineNamesValue; j.hasMore(); j.advance ()) {
240 String namedGridLine = toCSSPrimitiveValue(j.value())->getString Value();
241 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>());
242 result.storedValue->value.append(currentNamedGridLine);
243 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>());
244 orderedInsertionResult.storedValue->value.append(namedGridLine);
245 }
246 continue;
247 }
248
249 ++currentNamedGridLine;
250 trackSizes.append(convertGridTrackSize(state, currValue));
251 }
252
253 // The parser should have rejected any <track-list> without any <track-size> as
254 // this is not conformant to the syntax.
255 ASSERT(!trackSizes.isEmpty());
256 return true;
257 }
258
259 void StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(const Named GridAreaMap& namedGridAreas, NamedGridLinesMap& namedGridLines, GridTrackSizingD irection direction)
260 {
261 NamedGridAreaMap::const_iterator end = namedGridAreas.end();
262 for (NamedGridAreaMap::const_iterator it = namedGridAreas.begin(); it != end ; ++it) {
263 GridSpan areaSpan = direction == ForRows ? it->value.rows : it->value.co lumns;
264 {
265 NamedGridLinesMap::AddResult startResult = namedGridLines.add(it->ke y + "-start", Vector<size_t>());
266 startResult.storedValue->value.append(areaSpan.resolvedInitialPositi on.toInt());
267 std::sort(startResult.storedValue->value.begin(), startResult.stored Value->value.end());
268 }
269 {
270 NamedGridLinesMap::AddResult endResult = namedGridLines.add(it->key + "-end", Vector<size_t>());
271 endResult.storedValue->value.append(areaSpan.resolvedFinalPosition.t oInt() + 1);
272 std::sort(endResult.storedValue->value.begin(), endResult.storedValu e->value.end());
273 }
274 }
275 }
276
277 Length StyleBuilderConverter::convertLength(StyleResolverState& state, CSSValue* value) 134 Length StyleBuilderConverter::convertLength(StyleResolverState& state, CSSValue* value)
278 { 135 {
279 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 136 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
280 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon version>(state.cssToLengthConversionData()); 137 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon version>(state.cssToLengthConversionData());
281 result.setQuirk(primitiveValue->isQuirkValue()); 138 result.setQuirk(primitiveValue->isQuirkValue());
282 return result; 139 return result;
283 } 140 }
284 141
285 Length StyleBuilderConverter::convertLengthOrAuto(StyleResolverState& state, CSS Value* value) 142 Length StyleBuilderConverter::convertLengthOrAuto(StyleResolverState& state, CSS Value* value)
286 { 143 {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 { 280 {
424 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 281 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
425 if (primitiveValue->getValueID()) { 282 if (primitiveValue->getValueID()) {
426 float multiplier = convertLineWidth<float>(state, value); 283 float multiplier = convertLineWidth<float>(state, value);
427 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData()); 284 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData());
428 } 285 }
429 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( )); 286 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( ));
430 } 287 }
431 288
432 } // namespace blink 289 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/resolver/StyleBuilderConverter.h ('k') | sky/engine/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698