Commit 0cfce663 authored by sergio@webkit.org's avatar sergio@webkit.org
Browse files

[CSS Grid Layout] infinity should be defined as a negative value

https://bugs.webkit.org/show_bug.cgi?id=107053

Reviewed by Andreas Kling.

From Blink r154805 by <jchaffraix@chromium.org>

Source/WebCore:

Reject negative values for track-breadth at parse time as
mentioned in the latest versions of the spec.

Added some extra checks to the existing tests.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseGridBreadth):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeUsedBreadthOfMaxLength):

LayoutTests:

Added some new test cases to check that track-breadth cannot be a
negative value, either it's a length, a percentage...

* fast/css-grid-layout/grid-columns-rows-get-set-expected.txt:
* fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt:
* fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js:
* fast/css-grid-layout/resources/grid-columns-rows-get-set.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154730 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1022a8e8
2013-08-28 Sergio Villar Senin <svillar@igalia.com>
[CSS Grid Layout] infinity should be defined as a negative value
https://bugs.webkit.org/show_bug.cgi?id=107053
Reviewed by Andreas Kling.
From Blink r154805 by <jchaffraix@chromium.org>
Added some new test cases to check that track-breadth cannot be a
negative value, either it's a length, a percentage...
* fast/css-grid-layout/grid-columns-rows-get-set-expected.txt:
* fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt:
* fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js:
* fast/css-grid-layout/resources/grid-columns-rows-get-set.js:
2013-08-28 Sergio Villar Senin <svillar@igalia.com>
 
[Soup] WebTiming information not shown in the inspector
......@@ -70,6 +70,10 @@ PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-col
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows') is 'none'
Test setting grid-definition-columns and grid-definition-rows back to 'none' through JS
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns') is '18px'
......
......@@ -64,6 +64,10 @@ PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-col
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns') is 'none'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows') is 'none'
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -152,3 +152,18 @@ element.style.webkitGridDefinitionColumns = "auto minmax(16px, auto)";
element.style.webkitGridDefinitionRows = "minmax(auto, 15%) 10vw";
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns')", "'none'");
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows')", "'none'");
// Negative values are not allowed.
element = document.createElement("div");
document.body.appendChild(element);
element.style.webkitGridDefinitionColumns = "-10px minmax(16px, 32px)";
element.style.webkitGridDefinitionRows = "minmax(10%, 15%) -10vw";
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns')", "'none'");
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows')", "'none'");
element = document.createElement("div");
document.body.appendChild(element);
element.style.webkitGridDefinitionColumns = "10px minmax(16px, -1vw)";
element.style.webkitGridDefinitionRows = "minmax(-1%, 15%) 10vw";
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns')", "'none'");
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows')", "'none'");
......@@ -180,6 +180,17 @@ element.style.webkitGridDefinitionRows = "minmax(10vw, auto)";
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns')", "'none'");
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows')", "'none'");
// Negative values are not allowed.
element.style.webkitGridDefinitionColumns = "-1px";
element.style.webkitGridDefinitionRows = "-6em";
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns')", "'none'");
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows')", "'none'");
element.style.webkitGridDefinitionColumns = "minmax(-1%, 32%)";
element.style.webkitGridDefinitionRows = "minmax(2vw, -6em)";
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-columns')", "'none'");
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-definition-rows')", "'none'");
debug("");
debug("Test setting grid-definition-columns and grid-definition-rows back to 'none' through JS");
element.style.webkitGridDefinitionColumns = "18px";
......
2013-08-28 Sergio Villar Senin <svillar@igalia.com>
[CSS Grid Layout] infinity should be defined as a negative value
https://bugs.webkit.org/show_bug.cgi?id=107053
Reviewed by Andreas Kling.
From Blink r154805 by <jchaffraix@chromium.org>
Reject negative values for track-breadth at parse time as
mentioned in the latest versions of the spec.
Added some extra checks to the existing tests.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseGridBreadth):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeUsedBreadthOfMaxLength):
2013-08-28 Sergio Villar Senin <svillar@igalia.com>
 
[Soup] WebTiming information not shown in the inspector
......@@ -4925,7 +4925,7 @@ PassRefPtr<CSSPrimitiveValue> CSSParser::parseGridBreadth(CSSParserValue* curren
if (currentValue->id == CSSValueWebkitMinContent || currentValue->id == CSSValueWebkitMaxContent)
return cssValuePool().createIdentifierValue(currentValue->id);
if (!validUnit(currentValue, FLength | FPercent))
if (!validUnit(currentValue, FNonNeg | FLength | FPercent))
return 0;
return createPrimitiveNumericValue(currentValue);
......
......@@ -33,7 +33,7 @@
namespace WebCore {
static const int infinity = intMaxForLayoutUnit;
static const int infinity = -1;
class GridTrack {
public:
......@@ -303,8 +303,7 @@ LayoutUnit RenderGrid::computeUsedBreadthOfMaxLength(TrackSizingDirection direct
{
if (trackLength.isFixed() || trackLength.isPercent() || trackLength.isViewportPercentage()) {
LayoutUnit computedBreadth = computeUsedBreadthOfSpecifiedLength(direction, trackLength);
// FIXME: We should ASSERT that computedBreadth cannot return infinity but it's currently
// possible. See https://bugs.webkit.org/show_bug.cgi?id=107053
ASSERT(computedBreadth != infinity);
return computedBreadth;
}
......
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