Bug 247734

Summary: cssText serializes shorthand with var() even if some longhand is different
Product: WebKit Reporter: Oriol Brufau <obrufau>
Component: CSSAssignee: Oriol Brufau <obrufau>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 247741    

Description Oriol Brufau 2022-11-10 07:54:19 PST
Run this:

    document.body.style.cssText = "margin: var(--m); margin-top: 1px";
    document.body.style.cssText;

Expected: "margin-right: ; margin-bottom: ; margin-left: ; margin-top: 1px;"

Actual: "margin: var(--m);"

The problem is that StyleProperties::asTextInternal() sees that margin-right is set to a pending-substitution value for margin:var(--m), and then https://searchfox.org/wubkat/rev/7a292520f6b12e8d4d9001d1480474b5c83cb0f8/Source/WebCore/css/StyleProperties.cpp#1795 sets value to "var(--m)".

    value = substitutionValue.shorthandValue().cssText();

The value should instead be obtained in https://searchfox.org/wubkat/rev/7a292520f6b12e8d4d9001d1480474b5c83cb0f8/Source/WebCore/css/StyleProperties.cpp#1823

    value = getPropertyValue(shorthandPropertyID);

which will properly detect that "var(--m)" is not a proper serialization.
Comment 1 Oriol Brufau 2022-11-10 11:49:08 PST
Pull request: https://github.com/WebKit/WebKit/pull/6356
Comment 2 EWS 2022-11-10 23:45:29 PST
Committed 256564@main (b7eeaa128fab): <https://commits.webkit.org/256564@main>

Reviewed commits have been landed. Closing PR #6356 and removing active labels.
Comment 3 Radar WebKit Bug Importer 2022-11-10 23:46:19 PST
<rdar://problem/102229765>