[CSS Grid Layout] Limit the size of explicit/implicit grid
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Nov 2014 16:26:06 +0000 (16:26 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Nov 2014 16:26:06 +0000 (16:26 +0000)
commit2b45b9f6bbef0d841708665488a89911e4c12097
tree82a67934157cf9ecdd00bb125c95f6f940c2d816
parentcaaa0c65b81927c75c42d13f4a7aca5fb192eea0
[CSS Grid Layout] Limit the size of explicit/implicit grid
https://bugs.webkit.org/show_bug.cgi?id=136217

Reviewed by Andreas Kling.

Source/WebCore:

A recent change in the specs allow us to set a limit (maximum
size) for both the explicit and implicit grids so we can protect
ourselves from absurdly huge grid specifications. It was decided
to use the recommended limit which is 1 million.

This means that we can remove the old limitation for the number of
repetitions in repeat(). Instead we now clamp the number of
repetitions to the maximum value that allow us to have the maximum
number of whole repetitions without exceeding the track number
limit.

* WebCore.xcodeproj/project.pbxproj:
* css/CSSParser.cpp:
(WebCore::CSSParser::parseGridTrackRepeatFunction): Replaced the
old limit by the new one.
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid): Use the amount of tracks
provided by GridResolvedPosition.
(WebCore::RenderGrid::populateExplicitGridAndOrderIterator): Ditto.
* rendering/style/GridCoordinate.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/GridResolvedPosition.cpp:
(WebCore::GridResolvedPosition::explicitGridColumnCount): Bring
the static function back to life.
(WebCore::GridResolvedPosition::explicitGridRowCount): Ditto.
(WebCore::explicitGridSizeForSide):
* rendering/style/GridResolvedPosition.h:

Tools:

Added a new unit test for the CSS parser. Right now it only checks
that we properly clamp the maximum number of tracks on a grid to a
maximum of 1 million.

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/PlatformEfl.cmake:
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/CSSParser.cpp: Added.
(TestWebKitAPI::computeNumberOfTracks): Helper function.
(TestWebKitAPI::TEST): Added a
CSSPropertyParserTest.GridTrackLimits test case.

LayoutTests:

Removed as they are now part of the WebCore's CSSParser.cpp unit
test. The reason why it was moved there is because the test would
require huge (~1000000 tracks) grid allocations, making the test
quite slow specially on Debug builds.

* fast/css-grid-layout/grid-element-repeat-max-repetitions-expected.txt: Removed.
* fast/css-grid-layout/grid-element-repeat-max-repetitions.html: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-element-repeat-max-repetitions-expected.txt [deleted file]
LayoutTests/fast/css-grid-layout/grid-element-repeat-max-repetitions.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSParser.cpp
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/style/GridCoordinate.h
Source/WebCore/rendering/style/GridResolvedPosition.cpp
Source/WebCore/rendering/style/GridResolvedPosition.h
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/PlatformEfl.cmake
Tools/TestWebKitAPI/PlatformGTK.cmake
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebCore/CSSParser.cpp [new file with mode: 0644]