compat icon indicating copy to clipboard operation
compat copied to clipboard

-webkit-background-size has behavioural differences to background-size

Open alancutter opened this issue 9 years ago • 12 comments

-webkit-background-size is listed as a simple alias for background-size when it has different syntactic behaviour. -webkit-background-size: 10px is equivalent to background-size: 10px 10px. background-size: 10px is equivalent to background-size: 10px auto (see https://drafts.csswg.org/css-backgrounds-3/#bg-size).

alancutter avatar Jan 15 '16 02:01 alancutter

Excellent feedback, thanks.

miketaylr avatar Jan 15 '16 16:01 miketaylr

Should this property always be serialized with two values, so that it can roundtrip with both the prefixed and unprefixed variants?

Demo http://software.hixie.ch/utilities/js/live-dom-viewer/saved/7809

Result in chrome

log: getting .style
log: 10px
log: setting .style to gCS
log: 10px
log: getting .style again
log: 10px 10px

zcorpan avatar Mar 06 '20 10:03 zcorpan

FWIW, I regret making the decision to default the second value to auto. If it were Web-compatible, I'd make the unprefixed property parse like -webkit-background-size.

@zcorpan Particularly given that single-value syntax isn't the same as doubling it, which is the typical pattern in CSS, serializing as two values feels pretty reasonable here.

fantasai avatar Sep 29 '20 04:09 fantasai

I was reviewing the tests in https://github.com/web-platform-tests/wpt/blob/master/compat/

And it doesn't seem to really work.

Safari

> document.body.style.webkitBackgroundSize
< ""
> document.body.style.webkitBackgroundSize = "10px"
< "10px"
> document.body.style.webkitBackgroundSize
< "10px"
> document.body.style.backgroundSize
< ""

Firefox

document.body.style.WebkitBackgroundSize
""
document.body.style.WebkitBackgroundSize = "10px"
"10px"
document.body.style.WebkitBackgroundSize
"10px"
document.body.style.backgroundSize
"10px" 

Chrome

document.body.style.webkitBackgroundSize
''
document.body.style.webkitBackgroundSize = "10px"
'10px'
document.body.style.webkitBackgroundSize
'10px 10px'
document.body.style.backgroundSize
'10px 10px'

fun!

I need to add more tests on the compat tests enumeration to test the behaviors of the values of the properties.

karlcow avatar Jun 22 '22 06:06 karlcow

I'm taking care of this in https://github.com/web-platform-tests/wpt/issues/34493

karlcow avatar Jun 22 '22 06:06 karlcow

cc @Loirooriol who did work on this in WebKit

nt1m avatar Jun 22 '22 16:06 nt1m

In WebKit -webkit-background-size and background-size are different longhands that share a computed value. It seems the only difference is in the parsing, so it should be easy to turn -webkit-background-size into a legacy shorthand of background-size, which would be the standard approach.

gCS should round-trip, so either serialize -webkit-background-size and background-size differently, or always use 2 values.

Loirooriol avatar Jun 22 '22 18:06 Loirooriol

If they're parsed differently, always serializing two values seems better.

Is there interest in trying to change the unprefixed property to match the -webkit- prefixed property as @fantasai suggested in https://github.com/whatwg/compat/issues/28#issuecomment-700427017 ?

zcorpan avatar Jun 30 '22 08:06 zcorpan

see https://github.com/WebKit/WebKit/pull/3372

karlcow avatar Aug 18 '22 07:08 karlcow

Should we also change the serialization of mask-size to always use two values, for consistency?

pxlcoder avatar Sep 23 '22 00:09 pxlcoder

There are two WPTs that current assume single-value serialization:

css/css-animations/KeyframeEffect-getKeyframes.tentative.html
quirks/unitless-length/excluded-properties-002.html

I would like to update these tests as part of the WebKit change.

@zcorpan @karlcow Do we have consensus from other engines on:

Always serialize `background-size` as two values.

pxlcoder avatar Sep 23 '22 18:09 pxlcoder

I filed an issue for the CSS WG for those questions: https://github.com/w3c/csswg-drafts/issues/7802

zcorpan avatar Sep 28 '22 08:09 zcorpan