NEW119956
Support animation of CSS gradients
https://bugs.webkit.org/show_bug.cgi?id=119956
Summary Support animation of CSS gradients
Dirk Schulze
Reported 2013-08-17 11:33:25 PDT
Support animations of CSS gradients
Attachments
Rotating gradient example (404 bytes, text/html)
2013-08-19 03:41 PDT, Dirk Schulze
no flags
Patch (9.80 KB, patch)
2013-08-19 03:43 PDT, Dirk Schulze
no flags
Patch (23.57 KB, patch)
2013-09-08 14:03 PDT, Dirk Schulze
no flags
Dirk Schulze
Comment 1 2013-08-19 03:41:16 PDT
Created attachment 209074 [details] Rotating gradient example
Dirk Schulze
Comment 2 2013-08-19 03:43:39 PDT
Created attachment 209075 [details] Patch Wit this patch, linear gradient angles can be animated as well as colors from color-stops. Animating the angle as described by the spec at the moment, leads to weird wonky looking gradients, since the gradient length gets shrinked on the edges and stretched on the corners.
WebKit Commit Bot
Comment 3 2013-08-19 03:45:17 PDT
Attachment 209075 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/css/CSSGradientValue.cpp', u'Source/WebCore/css/CSSGradientValue.h', u'Source/WebCore/page/animation/CSSPropertyAnimation.cpp']" exit_code: 1 Source/WebCore/page/animation/CSSPropertyAnimation.cpp:37: Alphabetical sorting problem. [build/include_order] [4] Source/WebCore/css/CSSGradientValue.h:129: The parameter name "to" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 2 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Dirk Schulze
Comment 4 2013-08-21 07:45:45 PDT
I think the tasks can be divided into three parts that don't necessarily need to be done in one patch: Animation of Colors, Animation of Color stops (with the help of calc as requested by CSS specs) Animation of Gradient direction/position I am not particular keen about the last step, since that requires layout information that we might not have at animation time. The first part should be very easy (done in the patch already) and the most important use case anyway.
Dirk Schulze
Comment 5 2013-09-08 14:03:37 PDT
Created attachment 210992 [details] Patch color-stop animation from the latest proposal on www-style. Interpolate unordered color-stop list and use calc() to blend different types. The patch cleans up CSSGradientValue.cpp quite a bit as well.
WebKit Commit Bot
Comment 6 2013-09-08 14:06:12 PDT
Attachment 210992 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/css/CSSGradientValue.cpp', u'Source/WebCore/css/CSSGradientValue.h', u'Source/WebCore/page/animation/CSSPropertyAnimation.cpp']" exit_code: 1 Source/WebCore/css/CSSGradientValue.cpp:145: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] Source/WebCore/css/CSSGradientValue.h:129: The parameter name "to" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 2 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Radar WebKit Bug Importer
Comment 7 2016-01-20 09:21:47 PST
lukas
Comment 8 2026-08-11 14:20:08 PDT
Hello, I have added a PR on GitHub for this: https://github.com/WebKit/WebKit/pull/71381 The functionality can be validated with this CodeSandbox (it's a single HTML file, I can also attach it here if you want): https://codesandbox.io/p/sandbox/lzsh97
Simon Fraser (smfr)
Comment 9 2026-08-11 17:09:24 PDT
CSS specs[1] say that CSS background-image animation is "discrete", so we'll need some CSS spec changes to make it permissible to animate gradients. [1] https://drafts.csswg.org/css-backgrounds-4/#background-image
lukas
Comment 10 2026-08-11 17:17:45 PDT
Good point, the specs say for animation type "discrete": > The property’s values cannot be meaningfully combined [...] Source: https://www.w3.org/TR/web-animations/#discrete Which doesn't really apply to the case of two gradients (of the same type(?)), in which case the values can be meaningfully combined. Are you able to escalate this or can you point me to the correct people to contact about this?
Simon Fraser (smfr)
Comment 11 2026-08-11 17:30:25 PDT
A number of issues exist already: https://github.com/w3c/csswg-drafts/issues/3783 https://github.com/w3c/csswg-drafts/issues/5617 https://github.com/w3c/csswg-drafts/issues/12075 https://github.com/w3c/csswg-drafts/issues/578 and maybe others. You could pick which you think is most appropriate and try to get the issues moved along! We are happy to support.
lukas
Comment 12 2026-08-11 17:40:38 PDT
Thanks for the help. I decided to add a comment mentioning all related issues to the oldest one. https://github.com/w3c/csswg-drafts/issues/578#issuecomment-5260697019
Note You need to log in before you can comment on or make changes to this bug.