Bug 194749 - Relative font size values (em) within CSS animations compound
Summary: Relative font size values (em) within CSS animations compound
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: Safari 12
Hardware: All All
: P2 Critical
Assignee: Nobody
URL: https://codepen.io/scottkellum/pen/7c...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-02-16 14:05 PST by Scott Kellum
Modified: 2020-06-12 08:15 PDT (History)
10 users (show)

See Also:


Attachments
patch (6.25 KB, patch)
2020-06-10 08:20 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (6.28 KB, patch)
2020-06-10 08:21 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (130.57 KB, patch)
2020-06-11 05:24 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (128.62 KB, patch)
2020-06-11 07:13 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (132.18 KB, patch)
2020-06-12 04:15 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (137.57 KB, patch)
2020-06-12 05:52 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Kellum 2019-02-16 14:05:18 PST
If the font size is set in `em` and the font size within the keyframes of an animation are set in `em` then the values will compound instead of interpolating.

Here is an example: https://codepen.io/scottkellum/pen/7c4e82c2744e9dfc0caf706bc525d83f

Behavior in Safari 12 (iOS and Desktop): the text grows and shrinks.

Expected behavior: the animation is between 2em and 2em so it should do nothing. No change in size should occur.
Comment 1 Scott Kellum 2019-02-16 14:11:08 PST
Note on importance: This is a blocker/critical for me because Iā€™m building a fluid typesetting system on top of animations and users want to set text in ems, preventing easy integrations into some websites.
Comment 2 Scott Kellum 2019-02-17 13:29:05 PST
Possibly related bug: https://bugs.webkit.org/show_bug.cgi?id=194765
Comment 3 Simon Fraser (smfr) 2019-02-18 11:34:15 PST
Different bug. This one reproduces without Web Animations enabled. We're not resolving 'em' styles correctly in animation keyframes.
Comment 4 Radar WebKit Bug Importer 2019-02-18 11:34:35 PST
<rdar://problem/48171898>
Comment 5 Kevin Lorenz 2019-04-02 06:35:38 PDT
This has already caused a lot of frustration on my end. Typo centered layout design is dependent on this to work correctly :(
Comment 6 Antti Koivisto 2020-06-10 08:20:00 PDT
Created attachment 401543 [details]
patch
Comment 7 Antti Koivisto 2020-06-10 08:21:20 PDT
Created attachment 401544 [details]
patch
Comment 8 Antoine Quint 2020-06-10 10:20:10 PDT
Sooo many new WPT PASS results!
Comment 9 Antti Koivisto 2020-06-11 05:24:27 PDT
Created attachment 401635 [details]
patch
Comment 10 Antti Koivisto 2020-06-11 07:13:26 PDT
Created attachment 401640 [details]
patch
Comment 11 Antti Koivisto 2020-06-12 04:15:51 PDT
Created attachment 401720 [details]
patch
Comment 12 Antti Koivisto 2020-06-12 05:52:46 PDT
Created attachment 401721 [details]
patch
Comment 13 Antoine Quint 2020-06-12 06:11:22 PDT
Comment on attachment 401721 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401721&action=review

> LayoutTests/animations/keyframe-em-unit.html:5
> +div {
> +  font-size: 2em;
> +  animation: div 3s infinite alternate;
> +}

You can make the duration any value and add `freeze` to ensure the animated style will override the base style. You can remove `alternate` for sure.

> Source/WebCore/style/StyleTreeResolver.cpp:324
> +                // FIXME: Remove this hack and pass the parent style via updateCSSAnimationsForElement.

Can you file a bug and assign it to me to do this refactor?
Comment 14 EWS 2020-06-12 07:40:42 PDT
Committed r262946: <https://trac.webkit.org/changeset/262946>

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