Commit 07aaeee6 authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

CSS: Negative radii are invalid in radial-gradient

https://drafts.csswg.org/css-images-3/#radial-gradients
"Negative values are invalid."

We now reject negative radii during radial-gradient parsing.

Bug: 978790
Change-Id: I2f5341cb19209e46299bab1982870cbe0cb52321
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677071Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672478}
parent 5009eff4
......@@ -1380,13 +1380,14 @@ static CSSValue* ConsumeRadialGradient(CSSParserTokenRange& args,
}
} else {
CSSPrimitiveValue* center =
ConsumeLengthOrPercent(args, context.Mode(), kValueRangeAll);
ConsumeLengthOrPercent(args, context.Mode(), kValueRangeNonNegative);
if (!center)
break;
if (horizontal_size)
return nullptr;
horizontal_size = center;
center = ConsumeLengthOrPercent(args, context.Mode(), kValueRangeAll);
center =
ConsumeLengthOrPercent(args, context.Mode(), kValueRangeNonNegative);
if (center) {
vertical_size = center;
++i;
......
......@@ -5,7 +5,9 @@
<title>CSS Backgrounds and Borders Module Level 3: parsing background-image with invalid values</title>
<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds/#background-image">
<link rel="help" href="https://drafts.csswg.org/css-images/#radial-gradients">
<meta name="assert" content="background-image supports only the grammar '<bg-image>#'.">
<meta name="assert" content="Negative radial-gradient radii are invalid.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
......@@ -13,6 +15,14 @@
<body>
<script>
test_invalid_value("background-image", "none, auto");
// Negative radii are invalid.
test_invalid_value("background-image", "radial-gradient(circle -10px at center, red, blue)");
test_invalid_value("background-image", "repeating-radial-gradient(-10px at center, red, blue)");
test_invalid_value("background-image", "radial-gradient(ellipse -20px 30px at center, red, blue)");
test_invalid_value("background-image", "repeating-radial-gradient(-20% 30% at center, red, blue)");
test_invalid_value("background-image", "radial-gradient(20px -30px at center, red, blue)");
test_invalid_value("background-image", "repeating-radial-gradient(20px -30px ellipse at center, red, blue)");
</script>
</body>
</html>
<!DOCTYPE html>
<head>
<style>
div {
background-image: repeating-radial-gradient(-100% -50% at center, red, green);
}
</style>
</head>
<body>
<div style="width: 100px; height: 100px;"></div>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment