Commit 37dedbdf authored by Oriol Brufau's avatar Oriol Brufau Committed by Commit Bot

Prevent disabled shorthands from matching enabled longhands

The cssText style serialization attempts to minimize the output by
converting different longhand declarations into a single shorthand one.
However, this shouldn't happen if the shorthand is disabled behind a
runtime flag.

BUG=876913

TEST=fast/css/inset-serialize.html

Change-Id: I264dff3352c452ab5407e34ccbcf94a519107a99
Reviewed-on: https://chromium-review.googlesource.com/1187102
Commit-Queue: Oriol Brufau <obrufau@igalia.com>
Reviewed-by: default avatarJavier Fernandez <jfernandez@igalia.com>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585839}
parent 1366c0c2
<!DOCTYPE html>
<meta charset="utf-8" />
<title>CSS Logical Properties: serialization of the inset properties</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" />
<link rel="help" href="https://drafts.csswg.org/css-logical/#inset-properties" />
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function setCSSLogicalEnabled(test, value) {
let initialValue = internals.runtimeFlags.cssLogicalEnabled;
internals.runtimeFlags.cssLogicalEnabled = value;
test.add_cleanup(() => {
internals.runtimeFlags.cssLogicalEnabled = initialValue;
});
}
function check(inStyle, outStyle) {
let element = document.createElement("div");
element.style.cssText = inStyle;
assert_equals(element.style.cssText, outStyle);
}
test(function(t) {
setCSSLogicalEnabled(t, true);
check("top: 1px; right: 2px; bottom: 3px; left: 4px;", "inset: 1px 2px 3px 4px;");
}, "Inset shorthand serializes longhands when enabled");
test(function(t) {
setCSSLogicalEnabled(t, false);
let style = "top: 1px; right: 2px; bottom: 3px; left: 4px;";
check(style, style);
}, "Inset longhands serialize as-is when shorthand is disabled");
</script>
...@@ -83,7 +83,8 @@ void getMatchingShorthandsForLonghand( ...@@ -83,7 +83,8 @@ void getMatchingShorthandsForLonghand(
{% for longhand_id, shorthands in longhands_dictionary.items() %} {% for longhand_id, shorthands in longhands_dictionary.items() %}
case {{longhand_id}}: { case {{longhand_id}}: {
{% for shorthand in shorthands %} {% for shorthand in shorthands %}
result->UncheckedAppend({{shorthand.name.to_lower_camel_case()}}Shorthand()); if (CSSProperty::Get({{shorthand.property_id}}).IsEnabled())
result->UncheckedAppend({{shorthand.name.to_lower_camel_case()}}Shorthand());
{% endfor %} {% endfor %}
break; break;
} }
......
...@@ -270,6 +270,7 @@ ...@@ -270,6 +270,7 @@
{ {
name: "CSSLogical", name: "CSSLogical",
status: "experimental", status: "experimental",
settable_from_internals: true,
}, },
{ {
name: "CSSMaskSourceType", name: "CSSMaskSourceType",
......
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