Bug 239670 - [cssom] Some longhands indexed in computed style are not serialized
Summary: [cssom] Some longhands indexed in computed style are not serialized
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:
 
Reported: 2022-04-22 12:51 PDT by Oriol Brufau
Modified: 2022-05-09 23:53 PDT (History)
15 users (show)

See Also:


Attachments
Patch (12.34 KB, patch)
2022-05-02 08:55 PDT, Oriol Brufau
no flags Details | Formatted Diff | Diff
Patch (16.80 KB, patch)
2022-05-02 12:38 PDT, Oriol Brufau
no flags Details | Formatted Diff | Diff
Patch (30.81 KB, patch)
2022-05-02 16:25 PDT, Oriol Brufau
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oriol Brufau 2022-04-22 12:51:29 PDT
A computed style only indexes declarations for longhand properties:

    var cs = getComputedStyle(document.body);
    var longhands = new Set(cs);
    longhands.has("perspective-origin-x"); // true
    longhands.has("perspective-origin-y"); // true
    longhands.has("perspective-origin"); // false

However, then it fails to serialize some longhands:

    cs.getPropertyValue("perspective-origin-x"); // ""
    cs.getPropertyValue("perspective-origin-y"); // ""
    cs.getPropertyValue("perspective-origin"); // "960px 123.9375px"

If only the shorthand can be serialized, either index the shorthand instead of the longhands (perspective-origin-x/y are actually not standard, it may be OK to pretend they don't exist), or let the longhands serialize properly.
Comment 1 Radar WebKit Bug Importer 2022-04-29 12:52:14 PDT
<rdar://problem/92539244>
Comment 2 Oriol Brufau 2022-05-02 08:55:38 PDT
Created attachment 458684 [details]
Patch
Comment 3 EWS Watchlist 2022-05-02 08:58:08 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 4 Oriol Brufau 2022-05-02 12:38:48 PDT
Created attachment 458700 [details]
Patch
Comment 5 Oriol Brufau 2022-05-02 12:40:12 PDT
Is this good, or should I instead exclude these longhands from being indexed in the computed style?
Comment 6 Tim Nguyen (:ntim) 2022-05-02 13:54:42 PDT
Comment on attachment 458700 [details]
Patch

My issue with this is that perspective-origin-x/y and transform-origin-x/y/z aren't standard. Can we try to unship those (at least the unprefixed versions)?
Comment 7 Oriol Brufau 2022-05-02 13:58:40 PDT
I'm afraid of compat risks of completely unshipping them.
But the option of not indexing them in computed styles would be closer to that.
Comment 8 Tim Nguyen (:ntim) 2022-05-02 15:47:02 PDT
(In reply to Oriol Brufau from comment #7)
> I'm afraid of compat risks of completely unshipping them.
> But the option of not indexing them in computed styles would be closer to
> that.

Chrome ships the prefixed versions, but not the unprefixed ones. Seems like we could do a similar thing?

For this bug specifically, perspective-origin should be indexed, but not the other 2 longhands.
Comment 9 Oriol Brufau 2022-05-02 16:25:06 PDT
Created attachment 458713 [details]
Patch
Comment 10 Oriol Brufau 2022-05-02 16:34:55 PDT
(In reply to Tim Nguyen (:ntim) from comment #8)
> (In reply to Oriol Brufau from comment #7)
> > I'm afraid of compat risks of completely unshipping them.
> > But the option of not indexing them in computed styles would be closer to
> > that.
> 
> Chrome ships the prefixed versions, but not the unprefixed ones. Seems like
> we could do a similar thing?

Chrome treats both perspective-origin and -webkit-perspective-origin-{x,y} as longhands that share a computed value. But that's so broken for revert-layer: https://bugs.chromium.org/p/chromium/issues/detail?id=1319414

So I prefer not to do that.

> For this bug specifically, perspective-origin should be indexed, but not the
> other 2 longhands.

I have attached a new patch that does that, without unshipping the non-standard longhands.
Comment 11 Darin Adler 2022-05-04 11:54:19 PDT
I don’t mean to override Tim’s judgement here. May want to hear from him before landing.
Comment 12 Oriol Brufau 2022-05-04 12:15:50 PDT
To summarize the problem with unshipping perspective-origin-x/y while keeping -webkit-perspective-origin-x/y:

 a) If perspective-origin becomes a longhand, we have a problem with revert-layer (same as Blink).
 b) If perspective-origin becomes a shorthand of -webkit-perspective-origin-x/y, then we have the same problem as now:
    i) If -webkit-perspective-origin-x/y are indexed in computed styles instead of perspective-origin, then they should serialize.
    ii) Otherwise -webkit-perspective-origin-x/y should be skipped, and index perspective-origin instead.


Option a) seems undesirable. And option b) seems orthogonal: whatever needs to be done with -webkit-perspective-origin-x/y when unshipping perspective-origin-x/y is the same that needs to be done to perspective-origin-x/y when not unshipping them.

So I would land the patch as-is. Option b) can be considered in another bug.
Comment 13 Tim Nguyen (:ntim) 2022-05-09 22:53:54 PDT
(In reply to Darin Adler from comment #11)
> I don’t mean to override Tim’s judgement here. May want to hear from him
> before landing.

The current patch is fine as it is. I'll file a new bug to unship the unprefixed non-standard longhands.
Comment 14 EWS 2022-05-09 23:53:28 PDT
Committed r294002 (250438@main): <https://commits.webkit.org/250438@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 458713 [details].