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

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: Fix comment 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
« no previous file with comments | « Source/core/css/CSSValueKeywords.in ('k') | Source/core/css/parser/CSSParserFastPaths.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
1328 PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledNode, bool allowVisitedStyle) 1364 PassRefPtrWillBeRawPtr<CSSValue> ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledNode, bool allowVisitedStyle)
1329 { 1365 {
1330 const SVGComputedStyle& svgStyle = style.svgStyle(); 1366 const SVGComputedStyle& svgStyle = style.svgStyle();
1331 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style.di rection(), style.writingMode()); 1367 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style.di rection(), style.writingMode());
1332 switch (propertyID) { 1368 switch (propertyID) {
1333 case CSSPropertyInvalid: 1369 case CSSPropertyInvalid:
1334 return nullptr; 1370 return nullptr;
1335 1371
1336 case CSSPropertyBackgroundColor: 1372 case CSSPropertyBackgroundColor:
1337 return allowVisitedStyle ? cssValuePool().createColorValue(style.visited DependentColor(CSSPropertyBackgroundColor).rgb()) : currentColorOrValidColor(sty le, style.backgroundColor()); 1373 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: 2613 case CSSPropertyX:
2578 return zoomAdjustedPixelValueForLength(svgStyle.x(), style); 2614 return zoomAdjustedPixelValueForLength(svgStyle.x(), style);
2579 case CSSPropertyY: 2615 case CSSPropertyY:
2580 return zoomAdjustedPixelValueForLength(svgStyle.y(), style); 2616 return zoomAdjustedPixelValueForLength(svgStyle.y(), style);
2581 case CSSPropertyR: 2617 case CSSPropertyR:
2582 return zoomAdjustedPixelValueForLength(svgStyle.r(), style); 2618 return zoomAdjustedPixelValueForLength(svgStyle.r(), style);
2583 case CSSPropertyRx: 2619 case CSSPropertyRx:
2584 return zoomAdjustedPixelValueForLength(svgStyle.rx(), style); 2620 return zoomAdjustedPixelValueForLength(svgStyle.rx(), style);
2585 case CSSPropertyRy: 2621 case CSSPropertyRy:
2586 return zoomAdjustedPixelValueForLength(svgStyle.ry(), style); 2622 return zoomAdjustedPixelValueForLength(svgStyle.ry(), style);
2623 case CSSPropertyScrollSnapType:
2624 return cssValuePool().createValue(style.scrollSnapType());
2625 case CSSPropertyScrollSnapPointsX:
2626 return valueForScrollSnapPoints(style.scrollSnapPointsX(), style);
2627 case CSSPropertyScrollSnapPointsY:
2628 return valueForScrollSnapPoints(style.scrollSnapPointsY(), style);
2629 case CSSPropertyScrollSnapCoordinate:
2630 return valueForScrollSnapCoordinate(style.scrollSnapCoordinate(), style) ;
2631 case CSSPropertyScrollSnapDestination:
2632 return valueForScrollSnapDestination(style.scrollSnapDestination(), styl e);
2587 2633
2588 case CSSPropertyAll: 2634 case CSSPropertyAll:
2589 return nullptr; 2635 return nullptr;
2590 default: 2636 default:
2591 break; 2637 break;
2592 } 2638 }
2593 ASSERT_NOT_REACHED(); 2639 ASSERT_NOT_REACHED();
2594 return nullptr; 2640 return nullptr;
2595 } 2641 }
2596 2642
2597 } 2643 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSValueKeywords.in ('k') | Source/core/css/parser/CSSParserFastPaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698