Commit 7374df78 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

[css-properties-values-api] Put image and transform values behind flags.

This CL adds new runtime flags which makes it possible to ship without
support for <image>, <transform-function> and <transform-list>.

Also replace comment near CSSPaintAPIArguments with 'depends_on'. (Added
before I knew 'depends_on' existed).

R=chrishtr@chromium.org

Bug: 641877
Change-Id: Ic50bdaffc84a7037c23841c9eb53eb9b331ad680
Reviewed-on: https://chromium-review.googlesource.com/c/1273061Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Anders Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601534}
parent 109eabf2
...@@ -138,6 +138,11 @@ ...@@ -138,6 +138,11 @@
"base": "media/stable", "base": "media/stable",
"args": ["--stable-release-mode"] "args": ["--stable-release-mode"]
}, },
{
"prefix": "stable",
"base": "fast/css/stable",
"args": ["--stable-release-mode"]
},
{ {
"prefix": "feature-policy-permissions", "prefix": "feature-policy-permissions",
"base": "external/wpt/mediacapture-streams", "base": "external/wpt/mediacapture-streams",
......
This test suite runs fast/css/stable with --stable-release-mode.
<!DOCTYPE html>
<script src="../../../../../resources/testharness.js"></script>
<script src="../../../../../resources/testharnessreport.js"></script>
<script>
function assert_registration_failed(registrator) {
try {
registrator();
} catch (e) {
// We accept either of these errors:
let syntax_error = 'SyntaxError: Failed to execute \'registerProperty\' on \'CSS\':' +
' The syntax provided is not a valid custom property syntax.';
let type_error = 'TypeError: CSS.registerProperty is not a function';
assert_true(e.toString() == syntax_error || e.toString() == type_error, 'Unexpected error: ' + e);
return true;
}
assert_true(false, 'CSS.registerProperty did not throw');
}
test(function() {
assert_registration_failed(() => {
CSS.registerProperty({
name: '--transform-function',
syntax: '<transform-function>',
initialValue: 'rotateX(0deg)',
inherits: false
});
});
}, 'Custom properties with <transform-function> syntax should not be exposed to stable');
test(function() {
assert_registration_failed(() => {
CSS.registerProperty({
name: '--transform-list',
syntax: '<transform-list>',
initialValue: 'rotateX(0deg)',
inherits: false
});
});
}, 'Custom properties with <transform-list> syntax should not be exposed to stable');
test(function() {
assert_registration_failed(() => {
CSS.registerProperty({
name: '--image',
syntax: '<image>',
initialValue: 'url("a")',
inherits: false
});
});
}, 'Custom properties with <image> syntax should not be exposed to stable');
</script>
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h" #include "third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h"
#include "third_party/blink/renderer/core/css/parser/css_variable_parser.h" #include "third_party/blink/renderer/core/css/parser/css_variable_parser.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h" #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink { namespace blink {
...@@ -43,8 +44,10 @@ CSSSyntaxType ParseSyntaxType(String type) { ...@@ -43,8 +44,10 @@ CSSSyntaxType ParseSyntaxType(String type) {
return CSSSyntaxType::kLengthPercentage; return CSSSyntaxType::kLengthPercentage;
if (type == "color") if (type == "color")
return CSSSyntaxType::kColor; return CSSSyntaxType::kColor;
if (type == "image") if (RuntimeEnabledFeatures::CSSVariables2ImageValuesEnabled()) {
return CSSSyntaxType::kImage; if (type == "image")
return CSSSyntaxType::kImage;
}
if (type == "url") if (type == "url")
return CSSSyntaxType::kUrl; return CSSSyntaxType::kUrl;
if (type == "integer") if (type == "integer")
...@@ -55,10 +58,12 @@ CSSSyntaxType ParseSyntaxType(String type) { ...@@ -55,10 +58,12 @@ CSSSyntaxType ParseSyntaxType(String type) {
return CSSSyntaxType::kTime; return CSSSyntaxType::kTime;
if (type == "resolution") if (type == "resolution")
return CSSSyntaxType::kResolution; return CSSSyntaxType::kResolution;
if (type == "transform-function") if (RuntimeEnabledFeatures::CSSVariables2TransformValuesEnabled()) {
return CSSSyntaxType::kTransformFunction; if (type == "transform-function")
if (type == "transform-list") return CSSSyntaxType::kTransformFunction;
return CSSSyntaxType::kTransformList; if (type == "transform-list")
return CSSSyntaxType::kTransformList;
}
if (type == "custom-ident") if (type == "custom-ident")
return CSSSyntaxType::kCustomIdent; return CSSSyntaxType::kCustomIdent;
// Not an Ident, just used to indicate failure // Not an Ident, just used to indicate failure
......
...@@ -309,15 +309,10 @@ ...@@ -309,15 +309,10 @@
name: "CSSOMSmoothScroll", name: "CSSOMSmoothScroll",
status: "stable", status: "stable",
}, },
// Do not ship CSSPaintAPIArguments without shipping CSSVariables2 first.
//
// CSSPaintAPIArguments depends on parts of the the 'CSS Properties and
// Values API Level 1', specification (section 'Supported syntax strings').
// That specification is implemented behind the runtime enabled feature
// CSSVariables2.
{ {
name: "CSSPaintAPIArguments", name: "CSSPaintAPIArguments",
status: "experimental", status: "experimental",
depends_on: ["CSSVariables2"],
}, },
{ {
name: "CSSPartPseudoElement", name: "CSSPartPseudoElement",
...@@ -339,6 +334,19 @@ ...@@ -339,6 +334,19 @@
name: "CSSVariables2", name: "CSSVariables2",
status: "experimental", status: "experimental",
}, },
// Support for registered custom properties with <image> syntax.
{
name: "CSSVariables2ImageValues",
status: "test",
depends_on: ["CSSVariables2"],
},
// Support for registered custom properties with <transform-list> and
// <transform-function> syntax.
{
name: "CSSVariables2TransformValues",
status: "test",
depends_on: ["CSSVariables2"],
},
{ {
name: "CSSViewport", name: "CSSViewport",
status: "experimental", status: "experimental",
......
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