Bug 241546 - [CSS Container Queries] Invalidate animation keyframes using container units on when container size changes
Summary: [CSS Container Queries] Invalidate animation keyframes using container units ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antti Koivisto
URL:
Keywords: InRadar
Depends on:
Blocks: 229659
  Show dependency treegraph
 
Reported: 2022-06-13 05:49 PDT by Antti Koivisto
Modified: 2022-06-15 13:01 PDT (History)
11 users (show)

See Also:


Attachments
Patch (11.83 KB, patch)
2022-06-13 05:54 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
Patch for landing (12.42 KB, patch)
2022-06-15 05:22 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
Patch for landing (12.42 KB, patch)
2022-06-15 11:48 PDT, Antti Koivisto
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (12.42 KB, patch)
2022-06-15 11:49 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 Antti Koivisto 2022-06-13 05:49:11 PDT
Fix a WPT
Comment 1 Antti Koivisto 2022-06-13 05:54:34 PDT
Created attachment 460197 [details]
Patch
Comment 2 Antoine Quint 2022-06-13 07:05:30 PDT
Comment on attachment 460197 [details]
Patch

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

> COMMIT_MESSAGE:6
> +Container size change changes the interpretation of container units used in keyframes..

Extra "." here.

> Source/WebCore/rendering/style/KeyframeList.cpp:226
> +    for (auto& keyframe : m_keyframes) {
> +        if (keyframe.style()->usesContainerUnits())
> +            return true;
> +    }
> +    return false;

I *think* this could be made to use std::any_of:

return std::any_of(m_keyframes.begin(), m_keyframes.end(), [] (auto& it) { return it.value->usesContainerUnits(); });

> Source/WebCore/style/StyleTreeResolver.cpp:583
> +    if (oldStyle && parent().needsUpdateQueryContainerDependentStyle)
> +        styleable.queryContainerDidChange();

While you're there, I think a FIXME to do something similar for viewport units would be good.

> Source/WebCore/style/Styleable.cpp:636
> +        auto* cssAnimation = dynamicDowncast<CSSAnimation>(animation.get());
> +        if (!cssAnimation)
> +            continue;

I *think* you should only check whether this is a `CSSTransition`, in which case I expect there is nothing to do here and the style invalidation mechanism would automatically update things based on the computed value changing. This would allow both `CSSAnimation` and vanilla `WebAnimation` objects to be updated.

Then you'd need to add testing coverage for animations created using the JS API. Perfectly fine to do as a separate patch, in which case a FIXME to that effect would be nice.
Comment 3 Antti Koivisto 2022-06-15 05:20:41 PDT
> I *think* you should only check whether this is a `CSSTransition`, in which
> case I expect there is nothing to do here and the style invalidation
> mechanism would automatically update things based on the computed value
> changing. This would allow both `CSSAnimation` and vanilla `WebAnimation`
> objects to be updated.

keyframesRuleDidChange is non-virtual function in CSSAnimation so I think that case requires something else.
Comment 4 Antti Koivisto 2022-06-15 05:22:07 PDT
Created attachment 460253 [details]
Patch for landing
Comment 5 EWS 2022-06-15 05:23:40 PDT
Commit message contains (OOPS!), blocking PR #None
Comment 6 Antti Koivisto 2022-06-15 11:48:04 PDT
Created attachment 460255 [details]
Patch for landing
Comment 7 Antti Koivisto 2022-06-15 11:49:23 PDT
Created attachment 460256 [details]
Patch for landing
Comment 8 EWS 2022-06-15 11:49:55 PDT
Commit message contains (OOPS!), blocking PR #None
Comment 9 EWS 2022-06-15 13:00:05 PDT
Committed r295569 (251574@main): <https://commits.webkit.org/251574@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 460256 [details].
Comment 10 Radar WebKit Bug Importer 2022-06-15 13:01:13 PDT
<rdar://problem/95231683>