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

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

Issue 2932593004: Update the snap points css properties (Closed)
Patch Set: Rebase and Add QuadLengthValue.h 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 } else {
majidvp 2017/06/15 13:57:11 nit: my preference is to use a more consistent if/
1260 if (ToCSSIdentifierValue(value).GetValueID() == CSSValueNone) {
1261 snapType.is_none = true;
1262 return snapType;
1263 }
1256 1264
1257 if (!value.IsFunctionValue()) 1265 snapType.is_none = false;
1258 return points; 1266 snapType.axis = ToCSSIdentifierValue(value).ConvertTo<SnapAxis>();
1259 1267 }
1260 const CSSFunctionValue& repeat_function = ToCSSFunctionValue(value); 1268 return snapType;
1261 SECURITY_DCHECK(repeat_function.length() == 1);
1262 points.repeat_offset =
1263 ConvertLength(state, ToCSSPrimitiveValue(repeat_function.Item(0)));
1264 points.has_repeat = true;
1265
1266 return points;
1267 } 1269 }
1268 1270
1269 Vector<LengthPoint> StyleBuilderConverter::ConvertSnapCoordinates( 1271 ScrollSnapAlign StyleBuilderConverter::ConvertSnapAlign(StyleResolverState&,
1270 StyleResolverState& state, 1272 const CSSValue& value) {
1271 const CSSValue& value) { 1273 ScrollSnapAlign snapAlign = ComputedStyle::InitialScrollSnapAlign();
1272 // Handles: none | <position># 1274 if (value.IsValuePair()) {
1273 Vector<LengthPoint> coordinates; 1275 const CSSValuePair& pair = ToCSSValuePair(value);
1274 1276 snapAlign.alignmentX =
1275 if (!value.IsValueList()) 1277 ToCSSIdentifierValue(pair.First()).ConvertTo<SnapAlignment>();
1276 return coordinates; 1278 snapAlign.alignmentY =
1277 1279 ToCSSIdentifierValue(pair.Second()).ConvertTo<SnapAlignment>();
1278 const CSSValueList& value_list = ToCSSValueList(value); 1280 } else {
1279 coordinates.ReserveInitialCapacity(value_list.length()); 1281 snapAlign.alignmentX =
1280 for (auto& snap_coordinate : value_list) { 1282 ToCSSIdentifierValue(value).ConvertTo<SnapAlignment>();
1281 coordinates.UncheckedAppend(ConvertPosition(state, *snap_coordinate)); 1283 snapAlign.alignmentY = snapAlign.alignmentX;
1282 } 1284 }
1283 1285 return snapAlign;
1284 return coordinates;
1285 } 1286 }
1286 1287
1287 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::ConvertTranslate( 1288 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::ConvertTranslate(
1288 StyleResolverState& state, 1289 StyleResolverState& state,
1289 const CSSValue& value) { 1290 const CSSValue& value) {
1290 if (value.IsIdentifierValue()) { 1291 if (value.IsIdentifierValue()) {
1291 DCHECK_EQ(ToCSSIdentifierValue(value).GetValueID(), CSSValueNone); 1292 DCHECK_EQ(ToCSSIdentifierValue(value).GetValueID(), CSSValueNone);
1292 return nullptr; 1293 return nullptr;
1293 } 1294 }
1294 const CSSValueList& list = ToCSSValueList(value); 1295 const CSSValueList& list = ToCSSValueList(value);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 } 1424 }
1424 1425
1425 const CSSValue& StyleBuilderConverter::ConvertRegisteredPropertyValue( 1426 const CSSValue& StyleBuilderConverter::ConvertRegisteredPropertyValue(
1426 const StyleResolverState& state, 1427 const StyleResolverState& state,
1427 const CSSValue& value) { 1428 const CSSValue& value) {
1428 return ComputeRegisteredPropertyValue(state.CssToLengthConversionData(), 1429 return ComputeRegisteredPropertyValue(state.CssToLengthConversionData(),
1429 value); 1430 value);
1430 } 1431 }
1431 1432
1432 } // namespace blink 1433 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698