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

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

Issue 2932593004: Update the snap points css properties (Closed)
Patch Set: Fix nits Created 3 years, 6 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 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 DCHECK(list.Item(0).IsPrimitiveValue() || list.Item(0).IsIdentifierValue()); 1240 DCHECK(list.Item(0).IsPrimitiveValue() || list.Item(0).IsIdentifierValue());
1241 DCHECK(list.Item(1).IsPrimitiveValue() || list.Item(1).IsIdentifierValue()); 1241 DCHECK(list.Item(1).IsPrimitiveValue() || list.Item(1).IsIdentifierValue());
1242 DCHECK(list.Item(2).IsPrimitiveValue()); 1242 DCHECK(list.Item(2).IsPrimitiveValue());
1243 1243
1244 return TransformOrigin( 1244 return TransformOrigin(
1245 ConvertPositionLength<CSSValueLeft, CSSValueRight>(state, list.Item(0)), 1245 ConvertPositionLength<CSSValueLeft, CSSValueRight>(state, list.Item(0)),
1246 ConvertPositionLength<CSSValueTop, CSSValueBottom>(state, list.Item(1)), 1246 ConvertPositionLength<CSSValueTop, CSSValueBottom>(state, list.Item(1)),
1247 StyleBuilderConverter::ConvertComputedLength<float>(state, list.Item(2))); 1247 StyleBuilderConverter::ConvertComputedLength<float>(state, list.Item(2)));
1248 } 1248 }
1249 1249
1250 ScrollSnapPoints StyleBuilderConverter::ConvertSnapPoints( 1250 ScrollSnapType StyleBuilderConverter::ConvertSnapType(StyleResolverState&,
1251 StyleResolverState& state, 1251 const CSSValue& value) {
1252 const CSSValue& value) { 1252 ScrollSnapType snapType = ComputedStyle::InitialScrollSnapType();
1253 // Handles: none | repeat(<length>) 1253 if (value.IsValuePair()) {
1254 ScrollSnapPoints points; 1254 const CSSValuePair& pair = ToCSSValuePair(value);
1255 points.has_repeat = false; 1255 snapType.is_none = false;
1256 snapType.axis = ToCSSIdentifierValue(pair.First()).ConvertTo<SnapAxis>();
1257 snapType.strictness =
1258 ToCSSIdentifierValue(pair.Second()).ConvertTo<SnapStrictness>();
1259 return snapType;
1260 }
1256 1261
1257 if (!value.IsFunctionValue()) 1262 if (ToCSSIdentifierValue(value).GetValueID() == CSSValueNone) {
1258 return points; 1263 snapType.is_none = true;
1264 return snapType;
1265 }
1259 1266
1260 const CSSFunctionValue& repeat_function = ToCSSFunctionValue(value); 1267 snapType.is_none = false;
1261 SECURITY_DCHECK(repeat_function.length() == 1); 1268 snapType.axis = ToCSSIdentifierValue(value).ConvertTo<SnapAxis>();
1262 points.repeat_offset = 1269 return snapType;
1263 ConvertLength(state, ToCSSPrimitiveValue(repeat_function.Item(0)));
1264 points.has_repeat = true;
1265
1266 return points;
1267 } 1270 }
1268 1271
1269 Vector<LengthPoint> StyleBuilderConverter::ConvertSnapCoordinates( 1272 ScrollSnapAlign StyleBuilderConverter::ConvertSnapAlign(StyleResolverState&,
1270 StyleResolverState& state, 1273 const CSSValue& value) {
1271 const CSSValue& value) { 1274 ScrollSnapAlign snapAlign = ComputedStyle::InitialScrollSnapAlign();
1272 // Handles: none | <position># 1275 if (value.IsValuePair()) {
1273 Vector<LengthPoint> coordinates; 1276 const CSSValuePair& pair = ToCSSValuePair(value);
1274 1277 snapAlign.alignmentX =
1275 if (!value.IsValueList()) 1278 ToCSSIdentifierValue(pair.First()).ConvertTo<SnapAlignment>();
1276 return coordinates; 1279 snapAlign.alignmentY =
1277 1280 ToCSSIdentifierValue(pair.Second()).ConvertTo<SnapAlignment>();
1278 const CSSValueList& value_list = ToCSSValueList(value); 1281 } else {
1279 coordinates.ReserveInitialCapacity(value_list.length()); 1282 snapAlign.alignmentX =
1280 for (auto& snap_coordinate : value_list) { 1283 ToCSSIdentifierValue(value).ConvertTo<SnapAlignment>();
1281 coordinates.UncheckedAppend(ConvertPosition(state, *snap_coordinate)); 1284 snapAlign.alignmentY = snapAlign.alignmentX;
1282 } 1285 }
1283 1286 return snapAlign;
1284 return coordinates;
1285 } 1287 }
1286 1288
1287 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::ConvertTranslate( 1289 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::ConvertTranslate(
1288 StyleResolverState& state, 1290 StyleResolverState& state,
1289 const CSSValue& value) { 1291 const CSSValue& value) {
1290 if (value.IsIdentifierValue()) { 1292 if (value.IsIdentifierValue()) {
1291 DCHECK_EQ(ToCSSIdentifierValue(value).GetValueID(), CSSValueNone); 1293 DCHECK_EQ(ToCSSIdentifierValue(value).GetValueID(), CSSValueNone);
1292 return nullptr; 1294 return nullptr;
1293 } 1295 }
1294 const CSSValueList& list = ToCSSValueList(value); 1296 const CSSValueList& list = ToCSSValueList(value);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 } 1425 }
1424 1426
1425 const CSSValue& StyleBuilderConverter::ConvertRegisteredPropertyValue( 1427 const CSSValue& StyleBuilderConverter::ConvertRegisteredPropertyValue(
1426 const StyleResolverState& state, 1428 const StyleResolverState& state,
1427 const CSSValue& value) { 1429 const CSSValue& value) {
1428 return ComputeRegisteredPropertyValue(state.CssToLengthConversionData(), 1430 return ComputeRegisteredPropertyValue(state.CssToLengthConversionData(),
1429 value); 1431 value);
1430 } 1432 }
1431 1433
1432 } // namespace blink 1434 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698