Bug 292202

Summary: Add support for logical background-position shorthands
Product: WebKit Reporter: Sam Weinig <sam>
Component: CSSAssignee: Sam Weinig <sam>
Status: NEW    
Severity: Normal CC: koivisto, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 18   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 291857    

Sam Weinig
Reported 2025-04-28 10:14:10 PDT
Add support for logical background-position shorthands background-position-block and background-position-inline from CSS Backgrounds Module Level 4 - https://drafts.csswg.org/css-backgrounds-4/#propdef-background-position-inline - https://drafts.csswg.org/css-backgrounds-4/#propdef-background-position-block
Attachments
Sam Weinig
Comment 1 2025-04-28 10:47:36 PDT
Adding support for this raises a few complications: 1. It's the first logical / physical pair where the logical and physical longhands do not share the same grammar. This means that the automatic "logical property group" support already built will not be sufficient, and some conversion process from logical to physical will need to take place at style building (and perhaps some physical to logical conversion at computed value extraction time). 2. An additional complication is that, if we wanted to also support the logical / flow relative keywords (as defined in CSS Values 5 - https://drafts.csswg.org/css-values-5/#position) in the `background-position` and `position` shorthands, its not clear exactly how they would work. Consider the case of the `background-position` shorthand, which has the following grammar: ``` <'background-position'> = <bg-position># ``` (a comma separated list of <bg-position> productions). Let's start with an existing example where you have the following usage: ``` <div id="test1" style="background-position: left center, center top;">...</div> ``` In this example, the following assertions hold: ``` assert(document.getElementById("test1").style.backgroundPositionX == "left, center"); assert(document.getElementById("test1").style.backgroundPositionY == "center, top"); ``` Simple. When processing the shorthand, the parser split each background-position pair into an x and y component and created lists with them. Now, consider a case using the new logical keywords along with the old physical keywords: ``` <div id="test2" style="background-position: left center, center inline-end;">...</div> ``` What should the following assertions be? ``` assert(document.getElementById("test2").style.backgroundPositionX == ???); assert(document.getElementById("test2").style.backgroundPositionY == ???); assert(document.getElementById("test2").style.backgroundPositionBlock == ???); assert(document.getElementById("test2").style.backgroundPositionInline == ???); ``` From an implementation perspective, we could put a placeholder value in, so that style building works appropriately, but the serialization of the specified value remains an issue. The specification also suggests that further issues lurk when var() is included and https://github.com/w3c/csswg-drafts/issues/9690 is linked.
Sam Weinig
Comment 2 2025-04-28 11:42:48 PDT
Filed https://github.com/w3c/csswg-drafts/issues/12132 to track issue 2 mentioned above.
Sam Weinig
Comment 3 2025-04-30 09:19:05 PDT
Radar WebKit Bug Importer
Comment 4 2025-05-05 10:15:24 PDT
Note You need to log in before you can comment on or make changes to this bug.