Title: [168108] trunk
Revision
168108
Author
commit-qu...@webkit.org
Date
2014-05-01 10:48:38 -0700 (Thu, 01 May 2014)

Log Message

[CSS Grid Layout] Clamping the number of repetitions in repeat()
https://bugs.webkit.org/show_bug.cgi?id=131023

Patch by Javier Fernandez <jfernan...@igalia.com> on 2014-05-01
Reviewed by Brent Fulgham.

Source/WebCore:
The ED suggests now to be able to clamp the number of repetitions when
using the repeat() function, taking precautions about excessive memory
usage.

The implemented max repetitions is 10K.

Test: fast/css-grid-layout/grid-element-repeat-max-repetitions.html

* css/CSSParser.cpp:
(WebCore::CSSParser::parseGridTrackRepeatFunction):

LayoutTests:
Test to ensure the number of repetitions used in the repeat() function
is clamped to 10K.

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (168107 => 168108)


--- trunk/LayoutTests/ChangeLog	2014-05-01 17:26:24 UTC (rev 168107)
+++ trunk/LayoutTests/ChangeLog	2014-05-01 17:48:38 UTC (rev 168108)
@@ -1,3 +1,16 @@
+2014-05-01  Javier Fernandez  <jfernan...@igalia.com>
+
+        [CSS Grid Layout] Clamping the number of repetitions in repeat()
+        https://bugs.webkit.org/show_bug.cgi?id=131023
+
+        Reviewed by Brent Fulgham.
+
+        Test to ensure the number of repetitions used in the repeat() function
+        is clamped to 10K.
+
+        * fast/css-grid-layout/grid-element-repeat-max-repetitions-expected.txt: Added.
+        * fast/css-grid-layout/grid-element-repeat-max-repetitions.html: Added.
+
 2014-05-01  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r167964.

Added: trunk/LayoutTests/fast/css-grid-layout/grid-element-repeat-max-repetitions-expected.txt (0 => 168108)


--- trunk/LayoutTests/fast/css-grid-layout/grid-element-repeat-max-repetitions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-element-repeat-max-repetitions-expected.txt	2014-05-01 17:48:38 UTC (rev 168108)
@@ -0,0 +1,4 @@
+Test the values greater than the maximum repetitions value are clamped through CSS.
+PASS
+PASS
+PASS

Added: trunk/LayoutTests/fast/css-grid-layout/grid-element-repeat-max-repetitions.html (0 => 168108)


--- trunk/LayoutTests/fast/css-grid-layout/grid-element-repeat-max-repetitions.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-element-repeat-max-repetitions.html	2014-05-01 17:48:38 UTC (rev 168108)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner)
+    testRunner.overridePreference("WebKitCSSGridLayoutEnabled", 1);
+</script>
+<link href="" rel="stylesheet">
+<style>
+.clampRepetitionsBelowLimit {
+    -webkit-grid-template-rows: repeat(9995, 1px);
+}
+
+.clampRepetitionsOnLimit {
+    -webkit-grid-template-rows: repeat(10000, 1px);
+}
+
+.clampRepetitionsAboveLimit {
+    -webkit-grid-template-rows: repeat(10005, 1px);
+}
+</style>
+<script src=""
+</head>
+<body _onload_="checkLayout('.grid')">
+
+<div>Test the values greater than the maximum repetitions value are clamped through CSS.</div>
+
+<div class="grid clampRepetitionsBelowLimit" data-expected-height="9995"></div>
+
+<div class="grid clampRepetitionsOnLimit" data-expected-height="10000"></div>
+
+<div class="grid clampRepetitionsAboveLimit" data-expected-height="10000"></div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (168107 => 168108)


--- trunk/Source/WebCore/ChangeLog	2014-05-01 17:26:24 UTC (rev 168107)
+++ trunk/Source/WebCore/ChangeLog	2014-05-01 17:48:38 UTC (rev 168108)
@@ -1,3 +1,21 @@
+2014-05-01  Javier Fernandez  <jfernan...@igalia.com>
+
+        [CSS Grid Layout] Clamping the number of repetitions in repeat()
+        https://bugs.webkit.org/show_bug.cgi?id=131023
+
+        Reviewed by Brent Fulgham.
+
+        The ED suggests now to be able to clamp the number of repetitions when
+        using the repeat() function, taking precautions about excessive memory
+        usage.
+
+        The implemented max repetitions is 10K.
+
+        Test: fast/css-grid-layout/grid-element-repeat-max-repetitions.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseGridTrackRepeatFunction):
+
 2014-04-30  Jer Noble  <jer.no...@apple.com>
 
         [MSE] Seeking between two buffered ranges enquues incorrect buffers.

Modified: trunk/Source/WebCore/css/CSSParser.cpp (168107 => 168108)


--- trunk/Source/WebCore/css/CSSParser.cpp	2014-05-01 17:26:24 UTC (rev 168107)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2014-05-01 17:48:38 UTC (rev 168108)
@@ -150,6 +150,7 @@
 
 static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX;
 static const double MAX_SCALE = 1000000;
+static const unsigned MAX_GRID_TRACK_REPETITIONS = 10000;
 
 template <unsigned N>
 static bool equal(const CSSParserString& a, const char (&b)[N])
@@ -5037,6 +5038,10 @@
 
     ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0);
     size_t repetitions = arguments->valueAt(0)->fValue;
+    // Clamp repetitions at MAX_GRID_TRACK_REPETITIONS.
+    // http://www.w3.org/TR/css-grid-1/#repeat-notation
+    if (repetitions > MAX_GRID_TRACK_REPETITIONS)
+        repetitions = MAX_GRID_TRACK_REPETITIONS;
     RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated();
     arguments->next(); // Skip the repetition count.
     arguments->next(); // Skip the comma.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to