[CSS Grid Layout] CSSParser should reject <track-list> without a <track-size>
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Nov 2013 10:53:17 +0000 (10:53 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Nov 2013 10:53:17 +0000 (10:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=118025

Reviewed by Andreas Kling.

Source/WebCore:

From Blink r152914 by <jchaffraix@chromium.org>

Make sure that we parse at least 1 <track-size> inside each
<track-list>. The old parser code allowed track-lists exclusively
made of <track-name>. The way it was implemented eases the future
addition of parsing for the repeat() function.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseGridTrackList):
* css/StyleResolver.cpp:
(WebCore::createGridTrackList): ASSERT if we don't find any
<track-size> now that we detect their absence in the parser.

LayoutTests:

Added a new test that verifies that <track-list> exclusively made
of <track-name> are not supported.

* fast/css-grid-layout/named-grid-line-get-set-expected.txt:
* fast/css-grid-layout/named-grid-line-get-set.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158839 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/named-grid-line-get-set-expected.txt
LayoutTests/fast/css-grid-layout/named-grid-line-get-set.html
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/StyleResolver.cpp

index 9438506..a69b779 100644 (file)
@@ -1,5 +1,18 @@
 2013-11-06  Sergio Villar Senin  <svillar@igalia.com>
 
+        [CSS Grid Layout] CSSParser should reject <track-list> without a <track-size>
+        https://bugs.webkit.org/show_bug.cgi?id=118025
+
+        Reviewed by Andreas Kling.
+
+        Added a new test that verifies that <track-list> exclusively made
+        of <track-name> are not supported.
+
+        * fast/css-grid-layout/named-grid-line-get-set-expected.txt:
+        * fast/css-grid-layout/named-grid-line-get-set.html:
+
+2013-11-06  Sergio Villar Senin  <svillar@igalia.com>
+
         [CSS Grid Layout] Fix handling of 'inherit' and 'initial' for grid lines
         https://bugs.webkit.org/show_bug.cgi?id=115401
 
index e76a4aa..7f67eff 100644 (file)
@@ -46,6 +46,8 @@ PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-definition
 Test getting and setting invalid -webkit-grid-definition-columns and -webkit-grid-definition-rows through JS
 PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-definition-columns') is "none"
 PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-definition-rows') is "none"
+PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-definition-columns') is "none"
+PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-definition-rows') is "none"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 2b5e4ea..5ced29f 100644 (file)
@@ -147,6 +147,12 @@ if (window.testRunner)
     element.style.webkitGridDefinitionColumns = "'foo'";
     element.style.webkitGridDefinitionRows = "'bar";
     testValue(element, "none", "none");
+
+    element = document.createElement("div");
+    document.body.appendChild(element);
+    element.style.webkitGridDefinitionColumns = "'foo' 'bar'";
+    element.style.webkitGridDefinitionRows = "'bar' 'foo'";
+    testValue(element, "none", "none");
 </script>
 <script src="../../resources/js-test-post.js"></script>
 </body>
index 89f68fb..bd3ebbb 100644 (file)
@@ -1,5 +1,25 @@
 2013-11-06  Sergio Villar Senin  <svillar@igalia.com>
 
+        [CSS Grid Layout] CSSParser should reject <track-list> without a <track-size>
+        https://bugs.webkit.org/show_bug.cgi?id=118025
+
+        Reviewed by Andreas Kling.
+
+        From Blink r152914 by <jchaffraix@chromium.org>
+
+        Make sure that we parse at least 1 <track-size> inside each
+        <track-list>. The old parser code allowed track-lists exclusively
+        made of <track-name>. The way it was implemented eases the future
+        addition of parsing for the repeat() function.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseGridTrackList):
+        * css/StyleResolver.cpp:
+        (WebCore::createGridTrackList): ASSERT if we don't find any
+        <track-size> now that we detect their absence in the parser.
+
+2013-11-06  Sergio Villar Senin  <svillar@igalia.com>
+
         [CSS Grid Layout] Fix handling of 'inherit' and 'initial' for grid lines
         https://bugs.webkit.org/show_bug.cgi?id=115401
 
index 50c428e..ff18caa 100644 (file)
@@ -5023,23 +5023,32 @@ bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important)
     }
 
     RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
-    while (m_valueList->current()) {
-        while (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiveValue::CSS_STRING) {
-            RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueList->current());
-            values->append(name);
-            m_valueList->next();
-        }
-
-        // This allows trailing <string>* per the specification.
-        if (!m_valueList->current())
-            break;
+    // Handle leading track names
+    while (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiveValue::CSS_STRING) {
+        RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueList->current());
+        values->append(name.release());
+        m_valueList->next();
+    }
 
+    bool seenTrackSize = false;
+    while (m_valueList->current()) {
         RefPtr<CSSPrimitiveValue> primitiveValue = parseGridTrackSize();
         if (!primitiveValue)
             return false;
 
+        seenTrackSize = true;
         values->append(primitiveValue.release());
+
+        while (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiveValue::CSS_STRING) {
+            RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueList->current());
+            values->append(name.release());
+            m_valueList->next();
+        }
     }
+
+    if (!seenTrackSize)
+        return false;
+
     addProperty(propId, values.release(), important);
     return true;
 }
index 538c8d6..51c8e18 100644 (file)
@@ -1992,9 +1992,9 @@ static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSiz
         trackSizes.append(trackSize);
     }
 
-    if (trackSizes.isEmpty())
-        return false;
-
+    // The parser should have rejected any <track-list> without any <track-size> as
+    // this is not conformant to the syntax.
+    ASSERT(!trackSizes.isEmpty());
     return true;
 }