Bug 1918856 - Do serialization of computed border-spacing in stylo r=emilio
Reland of D222204: This fixes an issues in `test_transitions_per_property.html` where `border-spacing` was assumed to serialize to `0px 0px`. It follows the pattern used by other properties that do not serialize this way. Differential Revision: https://phabricator.services.mozilla.com/D227460
This commit is contained in:
@@ -55,9 +55,6 @@ def method(prop):
|
||||
|
||||
# TODO(emilio): Get this to zero.
|
||||
LONGHANDS_NOT_SERIALIZED_WITH_SERVO = [
|
||||
# Servo serializes one value when both are the same, a few tests expect two.
|
||||
"border-spacing",
|
||||
|
||||
# These resolve auto to zero in a few cases, but not all.
|
||||
"max-height",
|
||||
"max-width",
|
||||
|
||||
@@ -1748,18 +1748,6 @@ already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetPaddingRight() {
|
||||
return GetPaddingWidthFor(eSideRight);
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetBorderSpacing() {
|
||||
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
|
||||
|
||||
const nsStyleTableBorder* border = StyleTableBorder();
|
||||
valueList->AppendCSSValue(
|
||||
PixelsToCSSValue(border->mBorderSpacing.width.ToCSSPixels()));
|
||||
valueList->AppendCSSValue(
|
||||
PixelsToCSSValue(border->mBorderSpacing.height.ToCSSPixels()));
|
||||
|
||||
return valueList.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetBorderTopWidth() {
|
||||
return GetBorderWidthFor(eSideTop);
|
||||
}
|
||||
|
||||
@@ -254,9 +254,6 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
|
||||
already_AddRefed<CSSValue> DoGetPaddingLeft();
|
||||
already_AddRefed<CSSValue> DoGetPaddingRight();
|
||||
|
||||
/* Table Properties */
|
||||
already_AddRefed<CSSValue> DoGetBorderSpacing();
|
||||
|
||||
/* Border Properties */
|
||||
already_AddRefed<CSSValue> DoGetBorderTopWidth();
|
||||
already_AddRefed<CSSValue> DoGetBorderBottomWidth();
|
||||
|
||||
@@ -2395,11 +2395,11 @@ function test_length_pair_transition_clamped(prop) {
|
||||
div.style.setProperty("transition-timing-function", FUNC_NEGATIVE, "");
|
||||
div.style.setProperty("transition-property", "none", "");
|
||||
div.style.setProperty(prop, "0px 0px", "");
|
||||
is(cs.getPropertyValue(prop), "0px 0px",
|
||||
is(cs.getPropertyValue(prop), "0px",
|
||||
"length-valued property " + prop + ": flush before clamping test");
|
||||
div.style.setProperty("transition-property", prop, "");
|
||||
div.style.setProperty(prop, "30px 50px", "");
|
||||
is(cs.getPropertyValue(prop), "0px 0px",
|
||||
is(cs.getPropertyValue(prop), "0px",
|
||||
"length-valued property " + prop + ": clamping of negatives");
|
||||
div.style.setProperty("transition-timing-function", "linear", "");
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
<script>
|
||||
assert_inherited('border-collapse', 'separate', 'collapse');
|
||||
assert_inherited('border-spacing', '0px 0px', '10px 20px');
|
||||
assert_inherited('border-spacing', '0px', '10px 20px');
|
||||
assert_inherited('caption-side', 'top', 'bottom');
|
||||
assert_inherited('empty-cells', 'show', 'hide');
|
||||
assert_not_inherited('table-layout', 'auto', 'fixed');
|
||||
|
||||
@@ -18,7 +18,13 @@
|
||||
</style>
|
||||
<script>
|
||||
test_computed_value("border-spacing", "10px 20px");
|
||||
test_computed_value("border-spacing", "0", "0px 0px");
|
||||
|
||||
// This should be "0px" and not "0px 0px" due to the shortest serialization principle:
|
||||
// https://drafts.csswg.org/cssom/#serializing-css-values
|
||||
// > If component values can be omitted or replaced with a shorter
|
||||
// > representation without changing the meaning of the value, omit/replace them.
|
||||
test_computed_value("border-spacing", "0", "0px");
|
||||
|
||||
test_computed_value("border-spacing", "calc(10px + 0.5em) calc(10px - 0.5em)", "30px 0px");
|
||||
test_computed_value("border-spacing", "calc(10px - 0.5em) calc(10px + 0.5em)", "0px 30px");
|
||||
</script>
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
{
|
||||
testName:"Simple substitution test",
|
||||
propertyName:"border-spacing",
|
||||
expectedValue:"20px 20px",
|
||||
expectedValue:"20px",
|
||||
style:"--gap: 20px;border-spacing: var(--gap);"
|
||||
},
|
||||
{
|
||||
testName:"You can't build up a single token where part of it is provided by a variable",
|
||||
propertyName:"border-spacing",
|
||||
expectedValue:"0px 0px",
|
||||
expectedValue:"0px",
|
||||
style:"--gap: 20;border-spacing: var(--gap)px;"
|
||||
},
|
||||
{
|
||||
@@ -59,13 +59,13 @@
|
||||
{
|
||||
testName:"Fallback value",
|
||||
propertyName:"border-spacing",
|
||||
expectedValue:"11px 11px",
|
||||
expectedValue:"11px",
|
||||
style:"border-spacing:var(--gap,11px);"
|
||||
},
|
||||
{
|
||||
testName:"Fallback value which is also a variable reference",
|
||||
propertyName:"border-spacing",
|
||||
expectedValue:"27px 27px",
|
||||
expectedValue:"27px",
|
||||
style:"--gap2: 27px; border-spacing:var(--gap,var(--gap2));"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -106,7 +106,7 @@ function commonHeightTest(id, attr, value, cssProp, expected, type="", divClass)
|
||||
// table#bordercolor
|
||||
commonTest("table", "bordercolor", "red", "border-color", "rgb(255, 0, 0)");
|
||||
// table#cellspacing
|
||||
commonTest("table", "cellspacing", "10", "border-spacing", "10px 10px", "10");
|
||||
commonTest("table", "cellspacing", "10", "border-spacing", "10px", "10");
|
||||
|
||||
// {table, thead, body, tfoot, tr, td, th}#background
|
||||
// {table, thead, body, tfoot, tr, td, th}#bgcolor
|
||||
|
||||
@@ -164,7 +164,7 @@ const lengthType = {
|
||||
};
|
||||
|
||||
const lengthPairType = {
|
||||
testInterpolation: (property, setup) => {
|
||||
testInterpolation: (property, setup, serializesToSingleValue = true) => {
|
||||
test(t => {
|
||||
const idlName = propertyToIDL(property);
|
||||
const target = createTestElement(t, setup);
|
||||
@@ -172,8 +172,14 @@ const lengthPairType = {
|
||||
{ [idlName]: ['10px 10px', '50px 50px'] },
|
||||
{ duration: 1000, fill: 'both' }
|
||||
);
|
||||
|
||||
let expected = '30px 30px';
|
||||
if (serializesToSingleValue) {
|
||||
expected = '30px';
|
||||
}
|
||||
|
||||
testAnimationSamples(animation, idlName,
|
||||
[{ time: 500, expected: '30px 30px' }]);
|
||||
[{ time: 500, expected }]);
|
||||
}, `${property} supports animating as a length pair`);
|
||||
|
||||
test(t => {
|
||||
@@ -183,12 +189,18 @@ const lengthPairType = {
|
||||
{ [idlName]: ['1rem 1rem', '5rem 5rem'] },
|
||||
{ duration: 1000, fill: 'both' }
|
||||
);
|
||||
|
||||
let expected = '30px 30px';
|
||||
if (serializesToSingleValue) {
|
||||
expected = '30px';
|
||||
}
|
||||
|
||||
testAnimationSamples(animation, idlName,
|
||||
[{ time: 500, expected: '30px 30px' }]);
|
||||
[{ time: 500, expected }]);
|
||||
}, `${property} supports animating as a length pair of rem`);
|
||||
},
|
||||
|
||||
testAdditionOrAccumulation: (property, setup, composite) => {
|
||||
testAdditionOrAccumulation: (property, setup, composite, serializesToSingleValue = true) => {
|
||||
test(t => {
|
||||
const idlName = propertyToIDL(property);
|
||||
const target = createTestElement(t, setup);
|
||||
@@ -197,10 +209,16 @@ const lengthPairType = {
|
||||
{ [idlName]: ['10px 10px', '50px 50px'] },
|
||||
{ duration: 1000, composite }
|
||||
);
|
||||
|
||||
let expected = '20px 20px';
|
||||
if (serializesToSingleValue) {
|
||||
expected = '20px';
|
||||
}
|
||||
|
||||
testAnimationSamples(
|
||||
animation,
|
||||
idlName,
|
||||
[{ time: 0, expected: '20px 20px' }]
|
||||
[{ time: 0, expected }]
|
||||
);
|
||||
}, `${property}: length pair`);
|
||||
|
||||
@@ -212,10 +230,17 @@ const lengthPairType = {
|
||||
{ [idlName]: ['1rem 1rem', '5rem 5rem'] },
|
||||
{ duration: 1000, composite }
|
||||
);
|
||||
|
||||
|
||||
let expected = '20px 20px';
|
||||
if (serializesToSingleValue) {
|
||||
expected = '20px';
|
||||
}
|
||||
|
||||
testAnimationSamples(
|
||||
animation,
|
||||
idlName,
|
||||
[{ time: 0, expected: '20px 20px' }]
|
||||
[{ time: 0, expected }]
|
||||
);
|
||||
}, `${property}: length pair of rem`);
|
||||
},
|
||||
@@ -2708,7 +2733,7 @@ const boxShadowListType = {
|
||||
|
||||
const positionType = {
|
||||
testInterpolation: (property, setup) => {
|
||||
lengthPairType.testInterpolation(property, setup);
|
||||
lengthPairType.testInterpolation(property, setup, false);
|
||||
|
||||
test(t => {
|
||||
const idlName = propertyToIDL(property);
|
||||
@@ -2722,7 +2747,7 @@ const positionType = {
|
||||
},
|
||||
|
||||
testAdditionOrAccumulation: (property, setup, composite) => {
|
||||
lengthPairType.testAddition(property, setup);
|
||||
lengthPairType.testAdditionOrAccumulation(property, setup, composite, false);
|
||||
|
||||
test(t => {
|
||||
const idlName = propertyToIDL(property);
|
||||
|
||||
Reference in New Issue
Block a user