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

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

Issue 148293008: [CSS Grid Layout] Add support to place items using named grid lines (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing v3. Fix for Debug bot Created 6 years, 7 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 if (angle <= 45.0f || angle > 315.0f) 98 if (angle <= 45.0f || angle > 315.0f)
99 return GO_0DEG; 99 return GO_0DEG;
100 if (angle > 45.0f && angle <= 135.0f) 100 if (angle > 45.0f && angle <= 135.0f)
101 return GO_90DEG; 101 return GO_90DEG;
102 if (angle > 135.0f && angle <= 225.0f) 102 if (angle > 135.0f && angle <= 225.0f)
103 return GO_180DEG; 103 return GO_180DEG;
104 return GO_270DEG; 104 return GO_270DEG;
105 } 105 }
106 106
107
108 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value* value) 107 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value* value)
109 { 108 {
110 // We accept the specification's grammar: 109 // We accept the specification's grammar:
111 // 'auto' | [ <integer> || <string> ] | [ span && [ <integer> || string ] ] | <ident> 110 // 'auto' | [ <integer> || <string> ] | [ span && [ <integer> || string ] ] | <ident>
112 111
113 GridPosition position; 112 GridPosition position;
114 113
115 if (value->isPrimitiveValue()) { 114 if (value->isPrimitiveValue()) {
116 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 115 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
117 // We translate <ident> to <string> during parsing as it 116 // We translate <ident> to <string> during parsing as it
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 ++currentNamedGridLine; 202 ++currentNamedGridLine;
204 trackSizes.append(convertGridTrackSize(state, currValue)); 203 trackSizes.append(convertGridTrackSize(state, currValue));
205 } 204 }
206 205
207 // The parser should have rejected any <track-list> without any <track-size> as 206 // The parser should have rejected any <track-list> without any <track-size> as
208 // this is not conformant to the syntax. 207 // this is not conformant to the syntax.
209 ASSERT(!trackSizes.isEmpty()); 208 ASSERT(!trackSizes.isEmpty());
210 return true; 209 return true;
211 } 210 }
212 211
212 void StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(const Named GridAreaMap& namedGridAreas, NamedGridLinesMap& namedGridLines, GridTrackSizingD irection direction)
213 {
214 NamedGridAreaMap::const_iterator end = namedGridAreas.end();
215 for (NamedGridAreaMap::const_iterator it = namedGridAreas.begin(); it != end ; ++it) {
216 GridSpan areaSpan = direction == ForRows ? it->value.rows : it->value.co lumns;
217 {
218 NamedGridLinesMap::AddResult startResult = namedGridLines.add(it->ke y + "-start", Vector<size_t>());
219 startResult.storedValue->value.append(areaSpan.resolvedInitialPositi on.toInt());
220 std::sort(startResult.storedValue->value.begin(), startResult.stored Value->value.end());
221 }
222 {
223 NamedGridLinesMap::AddResult endResult = namedGridLines.add(it->key + "-end", Vector<size_t>());
224 endResult.storedValue->value.append(areaSpan.resolvedFinalPosition.t oInt() + 1);
225 std::sort(endResult.storedValue->value.begin(), endResult.storedValu e->value.end());
226 }
227 }
228 }
229
213 Length StyleBuilderConverter::convertLength(StyleResolverState& state, CSSValue* value) 230 Length StyleBuilderConverter::convertLength(StyleResolverState& state, CSSValue* value)
214 { 231 {
215 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 232 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
216 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon version>(state.cssToLengthConversionData()); 233 Length result = primitiveValue->convertToLength<FixedConversion | PercentCon version>(state.cssToLengthConversionData());
217 result.setQuirk(primitiveValue->isQuirkValue()); 234 result.setQuirk(primitiveValue->isQuirkValue());
218 return result; 235 return result;
219 } 236 }
220 237
221 Length StyleBuilderConverter::convertLengthOrAuto(StyleResolverState& state, CSS Value* value) 238 Length StyleBuilderConverter::convertLengthOrAuto(StyleResolverState& state, CSS Value* value)
222 { 239 {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 { 449 {
433 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 450 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
434 if (primitiveValue->getValueID()) { 451 if (primitiveValue->getValueID()) {
435 float multiplier = convertLineWidth<float>(state, value); 452 float multiplier = convertLineWidth<float>(state, value);
436 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData()); 453 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData());
437 } 454 }
438 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( )); 455 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( ));
439 } 456 }
440 457
441 } // namespace WebCore 458 } // namespace WebCore
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