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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 2052883002: Clamp filter functions {grayscale, invert, opacity, sepia} to 100% (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@filter-js-tests
Patch Set: Additional test fixup Created 4 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 | « third_party/WebKit/LayoutTests/css3/filters/filter-property-parsing-invalid.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/parser/CSSPropertyParser.h" 5 #include "core/css/parser/CSSPropertyParser.h"
6 6
7 #include "core/StylePropertyShorthand.h" 7 #include "core/StylePropertyShorthand.h"
8 #include "core/css/CSSBasicShapeValues.h" 8 #include "core/css/CSSBasicShapeValues.h"
9 #include "core/css/CSSBorderImage.h" 9 #include "core/css/CSSBorderImage.h"
10 #include "core/css/CSSContentDistributionValue.h" 10 #include "core/css/CSSContentDistributionValue.h"
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 } else if (filterType == CSSValueHueRotate) { 1448 } else if (filterType == CSSValueHueRotate) {
1449 parsedValue = consumeAngle(args); 1449 parsedValue = consumeAngle(args);
1450 } else if (filterType == CSSValueBlur) { 1450 } else if (filterType == CSSValueBlur) {
1451 parsedValue = consumeLength(args, HTMLStandardMode, ValueRangeNonNeg ative); 1451 parsedValue = consumeLength(args, HTMLStandardMode, ValueRangeNonNeg ative);
1452 } else { 1452 } else {
1453 // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5) 1453 // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
1454 parsedValue = consumePercent(args, ValueRangeNonNegative); 1454 parsedValue = consumePercent(args, ValueRangeNonNegative);
1455 if (!parsedValue) 1455 if (!parsedValue)
1456 parsedValue = consumeNumber(args, ValueRangeNonNegative); 1456 parsedValue = consumeNumber(args, ValueRangeNonNegative);
1457 if (parsedValue && filterType != CSSValueSaturate && filterType != C SSValueContrast) { 1457 if (parsedValue && filterType != CSSValueSaturate && filterType != C SSValueContrast) {
1458 double maxAllowed = toCSSPrimitiveValue(parsedValue)->isPercenta ge() ? 100.0 : 1.0; 1458 bool isPercentage = toCSSPrimitiveValue(parsedValue)->isPercenta ge();
1459 if (toCSSPrimitiveValue(parsedValue)->getDoubleValue() > maxAllo wed) 1459 double maxAllowed = isPercentage ? 100.0 : 1.0;
1460 return nullptr; 1460 if (toCSSPrimitiveValue(parsedValue)->getDoubleValue() > maxAllo wed) {
1461 parsedValue = CSSPrimitiveValue::create(
1462 maxAllowed,
1463 isPercentage ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveValue::UnitType::Number);
1464 }
1461 } 1465 }
1462 } 1466 }
1463 } 1467 }
1464 if (!parsedValue || !args.atEnd()) 1468 if (!parsedValue || !args.atEnd())
1465 return nullptr; 1469 return nullptr;
1466 filterValue->append(parsedValue); 1470 filterValue->append(parsedValue);
1467 return filterValue; 1471 return filterValue;
1468 } 1472 }
1469 1473
1470 static CSSValue* consumeFilter(CSSParserTokenRange& range, CSSParserMode cssPars erMode) 1474 static CSSValue* consumeFilter(CSSParserTokenRange& range, CSSParserMode cssPars erMode)
(...skipping 3720 matching lines...) Expand 10 before | Expand all | Expand 10 after
5191 case CSSPropertyGridTemplate: 5195 case CSSPropertyGridTemplate:
5192 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); 5196 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important);
5193 case CSSPropertyGrid: 5197 case CSSPropertyGrid:
5194 return consumeGridShorthand(important); 5198 return consumeGridShorthand(important);
5195 default: 5199 default:
5196 return false; 5200 return false;
5197 } 5201 }
5198 } 5202 }
5199 5203
5200 } // namespace blink 5204 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/css3/filters/filter-property-parsing-invalid.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698