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

Side by Side Diff: Source/core/css/resolver/StyleBuilderConverter.cpp

Issue 642303002: Move style building for grid-auto-flow to StyleBuilderConverter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 /* 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 if (angle <= 45.0f || angle > 315.0f) 332 if (angle <= 45.0f || angle > 315.0f)
333 return GO_0DEG; 333 return GO_0DEG;
334 if (angle > 45.0f && angle <= 135.0f) 334 if (angle > 45.0f && angle <= 135.0f)
335 return GO_90DEG; 335 return GO_90DEG;
336 if (angle > 135.0f && angle <= 225.0f) 336 if (angle > 135.0f && angle <= 225.0f)
337 return GO_180DEG; 337 return GO_180DEG;
338 return GO_270DEG; 338 return GO_270DEG;
339 } 339 }
340 340
341 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, CSS Value* value)
342 {
343 CSSValueList* list = toCSSValueList(value);
344
345 CSSPrimitiveValue* first = list->length() >= 1 ? toCSSPrimitiveValue(list->i tem(0)) : nullptr;
346
347 if (!first)
348 return RenderStyle::initialGridAutoFlow();
Timothy Loh 2014/10/10 14:38:45 Looks like the parser always puts at least one val
349
350 CSSPrimitiveValue* second = list->length() == 2 ? toCSSPrimitiveValue(list-> item(1)) : nullptr;
Timothy Loh 2014/10/10 14:38:45 All the logic here should probably get moved to th
Timothy Loh 2014/10/10 16:12:20 Err probably we'd have either a single value for t
351
352 switch (first->getValueID()) {
353 case CSSValueRow:
354 if (second) {
355 if (second->getValueID() == CSSValueDense)
356 return AutoFlowRowDense;
357 return AutoFlowStackRow;
358 }
359 return AutoFlowRow;
360 case CSSValueColumn:
361 if (second) {
362 if (second->getValueID() == CSSValueDense)
363 return AutoFlowColumnDense;
364 return AutoFlowStackColumn;
365 }
366 return AutoFlowColumn;
367 case CSSValueDense:
368 if (second && second->getValueID() == CSSValueColumn)
369 return AutoFlowColumnDense;
370 return AutoFlowRowDense;
371 case CSSValueStack:
372 if (second && second->getValueID() == CSSValueColumn)
373 return AutoFlowStackColumn;
374 return AutoFlowStackRow;
375 default:
376 ASSERT_NOT_REACHED();
377 return RenderStyle::initialGridAutoFlow();
378 }
379 }
380
341 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value* value) 381 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value* value)
342 { 382 {
343 // We accept the specification's grammar: 383 // We accept the specification's grammar:
344 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust om-ident> ] ] | <custom-ident> 384 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust om-ident> ] ] | <custom-ident>
345 385
346 GridPosition position; 386 GridPosition position;
347 387
348 if (value->isPrimitiveValue()) { 388 if (value->isPrimitiveValue()) {
349 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 389 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
350 // We translate <custom-ident> to <string> during parsing as it 390 // We translate <custom-ident> to <string> during parsing as it
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 { 723 {
684 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 724 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
685 if (primitiveValue->getValueID()) { 725 if (primitiveValue->getValueID()) {
686 float multiplier = convertLineWidth<float>(state, value); 726 float multiplier = convertLineWidth<float>(state, value);
687 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData()); 727 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData());
688 } 728 }
689 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( )); 729 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( ));
690 } 730 }
691 731
692 } // namespace blink 732 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleBuilderConverter.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698