Bug 247734 - cssText serializes shorthand with var() even if some longhand is different
Summary: cssText serializes shorthand with var() even if some longhand is different
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Oriol Brufau
URL:
Keywords: InRadar
Depends on:
Blocks: 247741
  Show dependency treegraph
 
Reported: 2022-11-10 07:54 PST by Oriol Brufau
Modified: 2022-11-11 10:29 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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>