Title: [222402] trunk
Revision
222402
Author
[email protected]
Date
2017-09-22 13:15:14 -0700 (Fri, 22 Sep 2017)

Log Message

Add env() as an alias of constant()
https://bugs.webkit.org/show_bug.cgi?id=177371

Reviewed by Simon Fraser.

Source/WebCore:

* css/CSSValueKeywords.in:
* css/CSSVariableData.cpp:
(WebCore::CSSVariableData::checkVariablesForCyclesWithRange const):
(WebCore::CSSVariableData::resolveTokenRange const):
* css/parser/CSSVariableParser.cpp:
(WebCore::classifyBlock):
Add env() as an alias of constant() everywhere it is mentioned.

Source/WebInspectorUI:

* UserInterface/Models/CSSKeywordCompletions.js:
(WI.CSSKeywordCompletions.forProperty):
(WI.CSSKeywordCompletions.forFunction):
Add autocomplete support for env().

LayoutTests:

* TestExpectations:
* platform/ios-11/TestExpectations:
Duplicated constant() tests with env() instead.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222401 => 222402)


--- trunk/LayoutTests/ChangeLog	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/LayoutTests/ChangeLog	2017-09-22 20:15:14 UTC (rev 222402)
@@ -1,3 +1,14 @@
+2017-09-22  Tim Horton  <[email protected]>
+
+        Add env() as an alias of constant()
+        https://bugs.webkit.org/show_bug.cgi?id=177371
+
+        Reviewed by Simon Fraser.
+
+        * TestExpectations:
+        * platform/ios-11/TestExpectations:
+        Duplicated constant() tests with env() instead.
+
 2017-09-22  Ryan Haddad  <[email protected]>
 
         Unreviewed test gardening for iOS.

Modified: trunk/LayoutTests/TestExpectations (222401 => 222402)


--- trunk/LayoutTests/TestExpectations	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/LayoutTests/TestExpectations	2017-09-22 20:15:14 UTC (rev 222402)
@@ -35,6 +35,7 @@
 media/controls/ipad [ Skip ]
 fast/text-autosizing [ Skip ]
 fast/css/variables/constants/ios [ Skip ]
+fast/css/variables/env/ios [ Skip ]
 http/tests/preload/viewport [ Skip ]
 
 # window.showModalDialog is only tested in DumpRenderTree on Mac.

Added: trunk/LayoutTests/fast/css/variables/env/invalid-env-name-fallback-expected.html (0 => 222402)


--- trunk/LayoutTests/fast/css/variables/env/invalid-env-name-fallback-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/env/invalid-env-name-fallback-expected.html	2017-09-22 20:15:14 UTC (rev 222402)
@@ -0,0 +1,14 @@
+<style>
+div {
+    position: absolute;
+    left: 100px;
+    top: 100px;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+}
+</style>
+<body>
+<div></div>
+<p>The box should be at 100, 100.</p>
+

Added: trunk/LayoutTests/fast/css/variables/env/invalid-env-name-fallback.html (0 => 222402)


--- trunk/LayoutTests/fast/css/variables/env/invalid-env-name-fallback.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/env/invalid-env-name-fallback.html	2017-09-22 20:15:14 UTC (rev 222402)
@@ -0,0 +1,21 @@
+<script>
+if (window.internals)
+    internals.settings.setConstantPropertiesEnabled(true);
+</script>
+<style>
+div {
+    position: absolute;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+
+    --valid-fallback: 100px;
+
+    top: env(some-unknown-name, var(--valid-fallback));
+    left: env(--some-invalid-name, var(--valid-fallback));
+}
+</style>
+<body>
+<div></div>
+<p>The box should be at 100, 100.</p>
+

Added: trunk/LayoutTests/fast/css/variables/env/ios/safe-area-inset-env-set-expected.html (0 => 222402)


--- trunk/LayoutTests/fast/css/variables/env/ios/safe-area-inset-env-set-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/env/ios/safe-area-inset-env-set-expected.html	2017-09-22 20:15:14 UTC (rev 222402)
@@ -0,0 +1,32 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<head>
+    <script>
+    if (window.internals)
+        internals.settings.setViewportFitEnabled(true);
+    </script>
+    <meta name="viewport" content="initial-scale=1, viewport-fit=cover">
+    <style>
+    #a {
+        position: absolute;
+        left: 25px;
+        top: 50px;
+        width: 100px;
+        height: 100px;
+        background-color: green;
+    }
+
+    #b {
+        position: absolute;
+        left: 75px;
+        top: 100px;
+        width: 100px;
+        height: 100px;
+        background-color: blue;
+    }
+    </style>
+</head>
+<body>
+    <div id="a"></div>
+    <div id="b"></div>
+    <p>The boxes should be at 25, 50 and 75, 100.</p>
+</body>
\ No newline at end of file

Added: trunk/LayoutTests/fast/css/variables/env/ios/safe-area-inset-env-set.html (0 => 222402)


--- trunk/LayoutTests/fast/css/variables/env/ios/safe-area-inset-env-set.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/env/ios/safe-area-inset-env-set.html	2017-09-22 20:15:14 UTC (rev 222402)
@@ -0,0 +1,56 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<script>
+if (window.internals) {
+    internals.settings.setConstantPropertiesEnabled(true);
+    internals.settings.setViewportFitEnabled(true);
+}
+</script>
+<head>
+    <meta name="viewport" content="initial-scale=1, viewport-fit=cover">
+    <style>
+        #a {
+            position: absolute;
+            left: env(safe-area-inset-right);
+            top: env(safe-area-inset-top);
+            width: 100px;
+            height: 100px;
+            background-color: green;
+        }
+
+        #b {
+            position: absolute;
+            left: env(safe-area-inset-bottom);
+            top: env(safe-area-inset-left);
+            width: 100px;
+            height: 100px;
+            background-color: blue;
+        }
+    </style>
+    <script>
+        function getUIScript()
+        {
+            return `
+            (function() {
+                uiController.setSafeAreaInsets(50, 25, 75, 100);
+                uiController.doAfterVisibleContentRectUpdate(function () {
+                    uiController.uiScriptComplete();
+                });
+            })();`
+        }
+
+        if (window.testRunner) {
+            testRunner.waitUntilDone();
+            window._onload_ = function () {
+                testRunner.runUIScript(getUIScript(), function(result) {
+                    testRunner.notifyDone();
+                });
+            }
+        }
+    </script>
+</head>
+<body>
+    <div id="a"></div>
+    <div id="b"></div>
+    <p>The boxes should be at 25, 50 and 75, 100.</p>
+</body>
+

Added: trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-cannot-override-expected.html (0 => 222402)


--- trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-cannot-override-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-cannot-override-expected.html	2017-09-22 20:15:14 UTC (rev 222402)
@@ -0,0 +1,24 @@
+<style>
+#a {
+    position: absolute;
+    left: 0px;
+    top: 0px;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+}
+
+#b {
+    position: absolute;
+    left: 0px;
+    top: 0px;
+    width: 100px;
+    height: 100px;
+    background-color: blue;
+}
+</style>
+<body>
+<div id="a"></div>
+<div id="b"></div>
+<p>The boxes should both be at 0, 0.</p>
+

Added: trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-cannot-override.html (0 => 222402)


--- trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-cannot-override.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-cannot-override.html	2017-09-22 20:15:14 UTC (rev 222402)
@@ -0,0 +1,37 @@
+<script>
+if (window.internals)
+    internals.settings.setConstantPropertiesEnabled(true);
+</script>
+<style>
+html {
+    --safe-area-inset-bottom: 50px;
+    safe-area-inset-left: 50px;
+}
+
+#a {
+    position: absolute;
+    --safe-area-inset-right: 100px;
+    safe-area-inset-top: 100px;
+    left: env(safe-area-inset-right);
+    top: env(safe-area-inset-top);
+    width: 100px;
+    height: 100px;
+    background-color: green;
+}
+
+#b {
+    position: absolute;
+    --safe-area-inset-bottom: 200px;
+    safe-area-inset-left: 200px;
+    left: env(safe-area-inset-bottom);
+    top: env(safe-area-inset-left);
+    width: 100px;
+    height: 100px;
+    background-color: blue;
+}
+</style>
+<body>
+<div id="a"></div>
+<div id="b"></div>
+<p>The boxes should both be at 0, 0.</p>
+

Added: trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-zero-expected.html (0 => 222402)


--- trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-zero-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-zero-expected.html	2017-09-22 20:15:14 UTC (rev 222402)
@@ -0,0 +1,14 @@
+<style>
+div {
+    position: absolute;
+    left: 0px;
+    top: 0px;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+}
+</style>
+<body>
+<div></div>
+<p>The box should be at 0, 0.</p>
+

Added: trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-zero.html (0 => 222402)


--- trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-zero.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/env/safe-area-inset-env-zero.html	2017-09-22 20:15:14 UTC (rev 222402)
@@ -0,0 +1,21 @@
+<script>
+if (window.internals)
+    internals.settings.setConstantPropertiesEnabled(true);
+</script>
+<style>
+div {
+    position: absolute;
+    left: 100px;
+    top: 100px;
+    width: 100px;
+    height: 100px;
+    background-color: green;
+
+    top: env(safe-area-inset-top);
+    left: env(safe-area-inset-left);
+}
+</style>
+<body>
+<div></div>
+<p>The box should be at 0, 0.</p>
+

Modified: trunk/LayoutTests/platform/ios/TestExpectations (222401 => 222402)


--- trunk/LayoutTests/platform/ios/TestExpectations	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2017-09-22 20:15:14 UTC (rev 222402)
@@ -506,6 +506,7 @@
 fast/viewport/ios/viewport-fit-cover.html [ Pass ]
 fast/viewport/ios/viewport-fit-auto.html [ Pass ]
 fast/css/variables/constants/ios [ Pass ]
+fast/css/variables/env/ios [ Pass ]
 
 # This test relies on APIs not available on iOS
 fast/images/animated-image-mp4.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (222401 => 222402)


--- trunk/Source/WebCore/ChangeLog	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/Source/WebCore/ChangeLog	2017-09-22 20:15:14 UTC (rev 222402)
@@ -1,3 +1,18 @@
+2017-09-22  Tim Horton  <[email protected]>
+
+        Add env() as an alias of constant()
+        https://bugs.webkit.org/show_bug.cgi?id=177371
+
+        Reviewed by Simon Fraser.
+
+        * css/CSSValueKeywords.in:
+        * css/CSSVariableData.cpp:
+        (WebCore::CSSVariableData::checkVariablesForCyclesWithRange const):
+        (WebCore::CSSVariableData::resolveTokenRange const):
+        * css/parser/CSSVariableParser.cpp:
+        (WebCore::classifyBlock):
+        Add env() as an alias of constant() everywhere it is mentioned.
+
 2017-09-22  Basuke Suzuki  <[email protected]>
 
         [Curl] Use didReceiveBuffer instead of didReceiveData

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (222401 => 222402)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2017-09-22 20:15:14 UTC (rev 222402)
@@ -847,9 +847,10 @@
 -internal-variable-value
 
 //
-// UA Constants
+// Environment Variables
 //
 constant
+env
 
 //
 // CSS_PROP_BREAK_BEFORE/AFTER/INSIDE

Modified: trunk/Source/WebCore/css/CSSVariableData.cpp (222401 => 222402)


--- trunk/Source/WebCore/css/CSSVariableData.cpp	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/Source/WebCore/css/CSSVariableData.cpp	2017-09-22 20:15:14 UTC (rev 222402)
@@ -100,7 +100,7 @@
 bool CSSVariableData::checkVariablesForCyclesWithRange(CSSParserTokenRange range, CustomPropertyValueMap& customProperties, HashSet<AtomicString>& seenProperties, HashSet<AtomicString>& invalidProperties) const
 {
     while (!range.atEnd()) {
-        if (range.peek().functionId() == CSSValueVar || range.peek().functionId() == CSSValueConstant) {
+        if (range.peek().functionId() == CSSValueVar || range.peek().functionId() == CSSValueConstant || range.peek().functionId() == CSSValueEnv) {
             CSSParserTokenRange block = range.consumeBlock();
             
             block.consumeWhitespace();
@@ -170,7 +170,7 @@
 {
     bool success = true;
     while (!range.atEnd()) {
-        if (range.peek().functionId() == CSSValueVar || range.peek().functionId() == CSSValueConstant)
+        if (range.peek().functionId() == CSSValueVar || range.peek().functionId() == CSSValueConstant || range.peek().functionId() == CSSValueEnv)
             success &= resolveVariableReference(customProperties, range.consumeBlock(), result);
         else
             result.append(range.consume());

Modified: trunk/Source/WebCore/css/parser/CSSVariableParser.cpp (222401 => 222402)


--- trunk/Source/WebCore/css/parser/CSSVariableParser.cpp	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/Source/WebCore/css/parser/CSSVariableParser.cpp	2017-09-22 20:15:14 UTC (rev 222402)
@@ -70,7 +70,7 @@
                 hasReferences = true;
                 continue;
             }
-            if (token.functionId() == CSSValueConstant && parserContext.constantPropertiesEnabled) {
+            if ((token.functionId() == CSSValueConstant || token.functionId() == CSSValueEnv) && parserContext.constantPropertiesEnabled) {
                 if (!isValidConstantReference(block, hasAtApplyRule, parserContext))
                     return false; // Bail if any references are invalid
                 hasReferences = true;

Modified: trunk/Source/WebInspectorUI/ChangeLog (222401 => 222402)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-09-22 20:15:14 UTC (rev 222402)
@@ -1,3 +1,15 @@
+2017-09-22  Tim Horton  <[email protected]>
+
+        Add env() as an alias of constant()
+        https://bugs.webkit.org/show_bug.cgi?id=177371
+
+        Reviewed by Simon Fraser.
+
+        * UserInterface/Models/CSSKeywordCompletions.js:
+        (WI.CSSKeywordCompletions.forProperty):
+        (WI.CSSKeywordCompletions.forFunction):
+        Add autocomplete support for env().
+
 2017-09-21  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Add autocompletion suggestions for CSS functions (constant(), linear-gradient(), etc)

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js (222401 => 222402)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js	2017-09-22 20:15:14 UTC (rev 222402)
@@ -97,7 +97,7 @@
                 return;
 
             var propertyNamesForCodeMirror = {};
-            var valueKeywordsForCodeMirror = {"inherit": true, "initial": true, "unset": true, "revert": true, "var": true, "constant": true};
+            var valueKeywordsForCodeMirror = {"inherit": true, "initial": true, "unset": true, "revert": true, "var": true, "constant": true, "env": true};
             var colorKeywordsForCodeMirror = {};
 
             function nameForCodeMirror(name)

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js (222401 => 222402)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2017-09-22 19:57:11 UTC (rev 222401)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2017-09-22 20:15:14 UTC (rev 222402)
@@ -33,7 +33,7 @@
 
 WI.CSSKeywordCompletions.forProperty = function(propertyName)
 {
-    let acceptedKeywords = ["initial", "unset", "revert", "var()", "constant()"];
+    let acceptedKeywords = ["initial", "unset", "revert", "var()", "constant()", "env()"];
     let isNotPrefixed = propertyName.charAt(0) !== "-";
 
     if (propertyName in WI.CSSKeywordCompletions._propertyKeywordMap)
@@ -68,7 +68,7 @@
 
     if (functionName === "var")
         suggestions = [];
-    else if (functionName === "constant")
+    else if (functionName === "constant" || functionName == "env")
         suggestions = suggestions.concat(["safe-area-inset-top", "safe-area-inset-right", "safe-area-inset-bottom", "safe-area-inset-left"]);
     else if (functionName === "image-set")
         suggestions.push("url()");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to