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

Side by Side Diff: Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 1148873005: Parsing CSS properties for scroll snap points (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address review feedback Created 5 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) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * Copyright (C) 2015 Google Inc. All rights reserved. 7 * Copyright (C) 2015 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 default: 1318 default:
1319 ASSERT_NOT_REACHED(); 1319 ASSERT_NOT_REACHED();
1320 break; 1320 break;
1321 } 1321 }
1322 list->append(filterValue.release()); 1322 list->append(filterValue.release());
1323 } 1323 }
1324 1324
1325 return list.release(); 1325 return list.release();
1326 } 1326 }
1327 1327
1328 static PassRefPtrWillBeRawPtr<CSSValue> valueForScrollSnapDestination(const Leng thPoint& destination, const ComputedStyle& style)
1329 {
1330 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
1331 list->append(zoomAdjustedPixelValueForLength(destination.x(), style));
1332 list->append(zoomAdjustedPixelValueForLength(destination.y(), style));
1333 return list.release();
1334 }
1335
1336 static PassRefPtrWillBeRawPtr<CSSValue> valueForScrollSnapPoints(const ScrollSna pPoints& points, const ComputedStyle& style)
1337 {
1338 if (points.hasRepeat) {
1339 RefPtrWillBeRawPtr<CSSFunctionValue> repeat = CSSFunctionValue::create(C SSValueRepeat);
1340 repeat->append(zoomAdjustedPixelValueForLength(points.repeatOffset, styl e));
1341 return repeat.release();
1342 }
1343
1344 return cssValuePool().createIdentifierValue(CSSValueNone);
1345 }
1346
1347 static PassRefPtrWillBeRawPtr<CSSValue> valueForScrollSnapCoordinate(const Vecto r<LengthPoint>& coordinates, const ComputedStyle& style)
1348 {
1349 if (coordinates.isEmpty())
1350 return cssValuePool().createIdentifierValue(CSSValueNone);
1351
1352 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
1353
1354 for (auto& coordinate : coordinates) {
1355 auto pair = CSSValueList::createSpaceSeparated();
1356 pair->append(zoomAdjustedPixelValueForLength(coordinate.x(), style));
1357 pair->append(zoomAdjustedPixelValueForLength(coordinate.y(), style));
1358 list->append(pair);
1359 }
1360
1361 return list.release();
1362 }
1363
1364
1328 PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledNode, bool allowVisitedStyle) 1365 PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledNode, bool allowVisitedStyle)
1329 { 1366 {
1330 const SVGComputedStyle& svgStyle = style.svgStyle(); 1367 const SVGComputedStyle& svgStyle = style.svgStyle();
1331 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style.di rection(), style.writingMode()); 1368 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style.di rection(), style.writingMode());
1332 switch (propertyID) { 1369 switch (propertyID) {
1333 case CSSPropertyInvalid: 1370 case CSSPropertyInvalid:
1334 return nullptr; 1371 return nullptr;
1335 1372
1336 case CSSPropertyBackgroundColor: 1373 case CSSPropertyBackgroundColor:
1337 return allowVisitedStyle ? cssValuePool().createColorValue(style.visited DependentColor(CSSPropertyBackgroundColor).rgb()) : currentColorOrValidColor(sty le, style.backgroundColor()); 1374 return allowVisitedStyle ? cssValuePool().createColorValue(style.visited DependentColor(CSSPropertyBackgroundColor).rgb()) : currentColorOrValidColor(sty le, style.backgroundColor());
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2577 case CSSPropertyX: 2614 case CSSPropertyX:
2578 return zoomAdjustedPixelValueForLength(svgStyle.x(), style); 2615 return zoomAdjustedPixelValueForLength(svgStyle.x(), style);
2579 case CSSPropertyY: 2616 case CSSPropertyY:
2580 return zoomAdjustedPixelValueForLength(svgStyle.y(), style); 2617 return zoomAdjustedPixelValueForLength(svgStyle.y(), style);
2581 case CSSPropertyR: 2618 case CSSPropertyR:
2582 return zoomAdjustedPixelValueForLength(svgStyle.r(), style); 2619 return zoomAdjustedPixelValueForLength(svgStyle.r(), style);
2583 case CSSPropertyRx: 2620 case CSSPropertyRx:
2584 return zoomAdjustedPixelValueForLength(svgStyle.rx(), style); 2621 return zoomAdjustedPixelValueForLength(svgStyle.rx(), style);
2585 case CSSPropertyRy: 2622 case CSSPropertyRy:
2586 return zoomAdjustedPixelValueForLength(svgStyle.ry(), style); 2623 return zoomAdjustedPixelValueForLength(svgStyle.ry(), style);
2624 case CSSPropertyScrollSnapType:
2625 return cssValuePool().createValue(style.scrollSnapType());
2626 case CSSPropertyScrollSnapPointsX:
2627 return valueForScrollSnapPoints(style.scrollSnapPointsX(), style);
2628 case CSSPropertyScrollSnapPointsY:
2629 return valueForScrollSnapPoints(style.scrollSnapPointsY(), style);
2630 case CSSPropertyScrollSnapCoordinate:
2631 return valueForScrollSnapCoordinate(style.scrollSnapCoordinate(), style) ;
2632 case CSSPropertyScrollSnapDestination:
2633 return valueForScrollSnapDestination(style.scrollSnapDestination(), styl e);
2587 2634
2588 case CSSPropertyAll: 2635 case CSSPropertyAll:
2589 return nullptr; 2636 return nullptr;
2590 default: 2637 default:
2591 break; 2638 break;
2592 } 2639 }
2593 ASSERT_NOT_REACHED(); 2640 ASSERT_NOT_REACHED();
2594 return nullptr; 2641 return nullptr;
2595 } 2642 }
2596 2643
2597 } 2644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698