Bug 229437 - Redefining @keyframes does not work
Summary: Redefining @keyframes does not work
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: Safari 14
Hardware: All Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks: 235962
  Show dependency treegraph
 
Reported: 2021-08-23 21:05 PDT by Mu-An Chiou
Modified: 2022-02-01 10:21 PST (History)
9 users (show)

See Also:


Attachments
HTML file illustrating the problem. (716 bytes, text/html)
2021-08-23 21:05 PDT, Mu-An Chiou
no flags Details
Patch (5.77 KB, patch)
2022-02-01 06:29 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (9.39 KB, patch)
2022-02-01 06:37 PST, Antoine Quint
koivisto: review+
Details | Formatted Diff | Diff
Patch for landing (9.45 KB, patch)
2022-02-01 06:54 PST, Antoine Quint
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mu-An Chiou 2021-08-23 21:05:07 PDT
Created attachment 436262 [details]
HTML file illustrating the problem.

After a named @keyframes is defined, re-defining it by setting the styles again via script does not work.

In the attachment, clicking on "change color" will replace the CSS with an alternate animation color. This works in Chrome 92 as well as Firefox 91.

The demo opt to replace the style tag instead of resetting the style tag content because of https://bugs.webkit.org/show_bug.cgi?id=191265. 

This problem might be related to https://bugs.webkit.org/show_bug.cgi?id=201736 where CSS variables changes are found ineffective when used in keyframes.
Comment 1 Radar WebKit Bug Importer 2021-08-30 21:06:21 PDT
<rdar://problem/82563372>
Comment 2 Antoine Quint 2022-02-01 02:47:49 PST
I did some work in this area recently, specifically these:

https://bugs.webkit.org/show_bug.cgi?id=234895
https://bugs.webkit.org/show_bug.cgi?id=234955

However, fixing those bugs did not fix this particular bug.
Comment 3 Antoine Quint 2022-02-01 06:29:34 PST
Created attachment 450519 [details]
Patch
Comment 4 EWS Watchlist 2022-02-01 06:31:09 PST
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 5 Antoine Quint 2022-02-01 06:37:15 PST
Created attachment 450521 [details]
Patch
Comment 6 Antti Koivisto 2022-02-01 06:54:16 PST
Comment on attachment 450521 [details]
Patch

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

> Source/WebCore/style/StyleResolver.cpp:199
> +    m_keyframesRuleMap.set(animationName.impl(), WTFMove(rule));

Why does this map use AtomStringImpl* as a key instead of AtomString?
Comment 7 Antoine Quint 2022-02-01 06:54:41 PST
Created attachment 450522 [details]
Patch for landing
Comment 8 Antti Koivisto 2022-02-01 06:56:36 PST
Comment on attachment 450521 [details]
Patch

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

> Source/WebCore/style/StyleResolver.cpp:198
> +    AtomString animationName(rule->name());

This is probably not needed, rule->name() is an AtomString
Comment 9 Antoine Quint 2022-02-01 06:57:55 PST
(In reply to Antti Koivisto from comment #8)
> Comment on attachment 450521 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=450521&action=review
> 
> > Source/WebCore/style/StyleResolver.cpp:198
> > +    AtomString animationName(rule->name());
> 
> This is probably not needed, rule->name() is an AtomString

I have no idea, but I'll look into changing that in a followup patch.
Comment 10 EWS 2022-02-01 08:54:36 PST
Committed r288882 (246634@main): <https://commits.webkit.org/246634@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 450522 [details].
Comment 11 Antoine Quint 2022-02-01 10:21:07 PST
Will address refactor comments in bug 235962. The new WPT test landed in https://github.com/web-platform-tests/wpt/pull/32641.