WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
234895
[Web Animations] inserting a rule within a @keyframes rule should update animations
https://bugs.webkit.org/show_bug.cgi?id=234895
Summary
[Web Animations] inserting a rule within a @keyframes rule should update anim...
Antoine Quint
Reported
2022-01-05 13:21:52 PST
[Web Animations] inserting a rule within a @keyframes rule should update animations
Attachments
Patch
(20.31 KB, patch)
2022-01-05 13:34 PST
,
Antoine Quint
darin
: review+
Details
Formatted Diff
Diff
Patch for landing
(24.09 KB, patch)
2022-01-06 03:50 PST
,
Antoine Quint
no flags
Details
Formatted Diff
Diff
Patch for landing
(23.26 KB, patch)
2022-01-06 08:18 PST
,
Antoine Quint
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Antoine Quint
Comment 1
2022-01-05 13:34:56 PST
Created
attachment 448426
[details]
Patch
Darin Adler
Comment 2
2022-01-05 15:17:43 PST
Comment on
attachment 448426
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=448426&action=review
> Source/WebCore/animation/CSSAnimation.cpp:249 > + auto owningElement = this->owningElement();
Should this be RefPtr instead of auto?
> Source/WebCore/css/CSSKeyframesRule.cpp:168 > + if (CSSStyleSheet* parent = parentStyleSheet()) { > + if (Document* ownerDocument = parent->ownerDocument()) > + ownerDocument->cssKeyframesRuleDidChange(name()); > + }
Would be nice to not have this be pasted twice; a shared function perhaps. Separately, I suggest using auto more here.
> Source/WebCore/dom/Document.h:1541 > + void cssKeyframesRuleDidChange(String);
I am not sure that the "css" here is needed; is there any other kind of keyframes rule other than a CSS one? It’s not obvious that the string argument here is the name of the rule, so there should be an argument name "name" here. I suggest either StringView (preferred) or const String& as the type so we don’t do unnecessary reference count churn.
> Source/WebCore/dom/Element.cpp:4067 > + if (auto* animationData = animationRareData(pseudoId)) > + return animationData->isPendingKeyframesUpdate(); > + return false;
How I would write this: auto data = animationRareData(pseudoId); return data && data->isPendingKeyframesUpdate();
Antti Koivisto
Comment 3
2022-01-05 22:49:34 PST
Comment on
attachment 448426
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=448426&action=review
>> Source/WebCore/css/CSSKeyframesRule.cpp:168 >> + if (CSSStyleSheet* parent = parentStyleSheet()) { >> + if (Document* ownerDocument = parent->ownerDocument()) >> + ownerDocument->cssKeyframesRuleDidChange(name()); >> + } > > Would be nice to not have this be pasted twice; a shared function perhaps. Separately, I suggest using auto more here.
The shared function exist already. This should be done in CSSStyleSheet::didMutateRules. There should probably be a new RuleMutationType for it.
Antoine Quint
Comment 4
2022-01-06 03:50:10 PST
Created
attachment 448484
[details]
Patch for landing
Antoine Quint
Comment 5
2022-01-06 04:13:52 PST
(In reply to Darin Adler from
comment #2
)
> Comment on
attachment 448426
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=448426&action=review
> > > Source/WebCore/animation/CSSAnimation.cpp:249 > > + auto owningElement = this->owningElement(); > > Should this be RefPtr instead of auto?
I started a thread about this on Slack:
https://webkit.slack.com/archives/C01ARTA5TDM/p1641467768004500
.
> > Source/WebCore/css/CSSKeyframesRule.cpp:168 > > + if (CSSStyleSheet* parent = parentStyleSheet()) { > > + if (Document* ownerDocument = parent->ownerDocument()) > > + ownerDocument->cssKeyframesRuleDidChange(name()); > > + } > > Would be nice to not have this be pasted twice; a shared function perhaps. > Separately, I suggest using auto more here. > > > Source/WebCore/dom/Document.h:1541 > > + void cssKeyframesRuleDidChange(String); > > I am not sure that the "css" here is needed; is there any other kind of > keyframes rule other than a CSS one? > > It’s not obvious that the string argument here is the name of the rule, so > there should be an argument name "name" here. > > I suggest either StringView (preferred) or const String& as the type so we > don’t do unnecessary reference count churn.
Changed to `void keyframesRuleDidChange(const String& name);`
> > Source/WebCore/dom/Element.cpp:4067 > > + if (auto* animationData = animationRareData(pseudoId)) > > + return animationData->isPendingKeyframesUpdate(); > > + return false; > > How I would write this: > > auto data = animationRareData(pseudoId); > return data && data->isPendingKeyframesUpdate();
Fixed.
Antoine Quint
Comment 6
2022-01-06 04:14:14 PST
(In reply to Antti Koivisto from
comment #3
)
> Comment on
attachment 448426
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=448426&action=review
> > >> Source/WebCore/css/CSSKeyframesRule.cpp:168 > >> + if (CSSStyleSheet* parent = parentStyleSheet()) { > >> + if (Document* ownerDocument = parent->ownerDocument()) > >> + ownerDocument->cssKeyframesRuleDidChange(name()); > >> + } > > > > Would be nice to not have this be pasted twice; a shared function perhaps. Separately, I suggest using auto more here. > > The shared function exist already. This should be done in > CSSStyleSheet::didMutateRules. There should probably be a new > RuleMutationType for it.
This is addressed in the patch for landing.
Antti Koivisto
Comment 7
2022-01-06 07:09:19 PST
Comment on
attachment 448484
[details]
Patch for landing View in context:
https://bugs.webkit.org/attachment.cgi?id=448484&action=review
> Source/WebCore/css/CSSStyleSheet.h:105 > - RuleMutationScope(CSSStyleSheet*, RuleMutationType = OtherMutation, StyleRuleKeyframes* insertedKeyframesRule = nullptr); > + RuleMutationScope(CSSStyleSheet*, RuleMutationType = RuleMutationType::OtherMutation, StyleRuleKeyframes* insertedKeyframesRule = nullptr); > RuleMutationScope(CSSRule*);
I think it would be better to add RuleMutationType argument to the second constructor version and use it for CSSKeyframesRule mutations (or just test for CSSKeyframesRule in the constructor to set the appropriate mutation type). The idea here is that the first constructor is used when stylesheet is itself mutated while the seconds is used when some rule mutates.
Antoine Quint
Comment 8
2022-01-06 08:10:30 PST
(In reply to Antti Koivisto from
comment #7
)
> Comment on
attachment 448484
[details]
> Patch for landing > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=448484&action=review
> > > Source/WebCore/css/CSSStyleSheet.h:105 > > - RuleMutationScope(CSSStyleSheet*, RuleMutationType = OtherMutation, StyleRuleKeyframes* insertedKeyframesRule = nullptr); > > + RuleMutationScope(CSSStyleSheet*, RuleMutationType = RuleMutationType::OtherMutation, StyleRuleKeyframes* insertedKeyframesRule = nullptr); > > RuleMutationScope(CSSRule*); > > I think it would be better to add RuleMutationType argument to the second > constructor version and use it for CSSKeyframesRule mutations (or just test > for CSSKeyframesRule in the constructor to set the appropriate mutation > type). The idea here is that the first constructor is used when stylesheet > is itself mutated while the seconds is used when some rule mutates.
OK, I'll infer the mutation type from the CSSRule type and add a `String m_modifiedKeyframesRuleName` member to `RuleMutationScope` to track the modified @keyframes rule name.
Antoine Quint
Comment 9
2022-01-06 08:18:05 PST
Created
attachment 448504
[details]
Patch for landing
Darin Adler
Comment 10
2022-01-06 09:36:15 PST
Two other thoughts for refinement (tiny nits), neither urgent: I think that "hasPendingKeyframesUpdate" would be better than "isPendingKeyframesUpdate". One place here we have "is<CSSAnimation>(animation)" but it should be "is<CSSAnimation>(*animation)" since fact that the set uses pointers is an implementation detail and the pointers can never be null.
Antoine Quint
Comment 11
2022-01-06 11:57:46 PST
(In reply to Darin Adler from
comment #10
)
> Two other thoughts for refinement (tiny nits), neither urgent: > > I think that "hasPendingKeyframesUpdate" would be better than > "isPendingKeyframesUpdate".
I went back and forth between the two while writing the patch, but this tips me over to the other side. I've made that change to the commit.
> One place here we have "is<CSSAnimation>(animation)" but it should be > "is<CSSAnimation>(*animation)" since fact that the set uses pointers is an > implementation detail and the pointers can never be null.
Are you saying that the HashSet iterator skips over null values?
Antoine Quint
Comment 12
2022-01-06 11:57:52 PST
Committed
r287707
(
245793@trunk
): <
https://commits.webkit.org/245793@trunk
>
Radar WebKit Bug Importer
Comment 13
2022-01-06 11:59:40 PST
<
rdar://problem/87212387
>
Darin Adler
Comment 14
2022-01-06 13:07:16 PST
(In reply to Antoine Quint from
comment #11
)
> (In reply to Darin Adler from
comment #10
) > > I think that "hasPendingKeyframesUpdate" would be better than > > "isPendingKeyframesUpdate". > > I went back and forth between the two while writing the patch, but this tips > me over to the other side. I've made that change to the commit.
Great!
> Are you saying that the HashSet iterator skips over null values?
Sort of. You can’t put a nullptr into a HashSet of pointers, no values in the set can be nullptr. And yes the iterator does skip the null values, technically they are empty buckets.
Antti Koivisto
Comment 15
2022-01-06 21:12:40 PST
Comment on
attachment 448504
[details]
Patch for landing View in context:
https://bugs.webkit.org/attachment.cgi?id=448504&action=review
> Source/WebCore/css/CSSStyleSheet.cpp:181 > + if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !scope->activeStyleSheetsContains(this)) { > + if (insertedKeyframesRule) { > + if (auto* resolver = scope->resolverIfExists()) > + resolver->addKeyframeStyle(*insertedKeyframesRule); > + return; > + } > + scope->didChangeActiveStyleSheetCandidates(); > + return; > + }
We don't need two copies if this section of code!
Antoine Quint
Comment 16
2022-01-07 00:29:16 PST
(In reply to Antti Koivisto from
comment #15
)
> Comment on
attachment 448504
[details]
> Patch for landing > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=448504&action=review
> > > Source/WebCore/css/CSSStyleSheet.cpp:181 > > + if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !scope->activeStyleSheetsContains(this)) { > > + if (insertedKeyframesRule) { > > + if (auto* resolver = scope->resolverIfExists()) > > + resolver->addKeyframeStyle(*insertedKeyframesRule); > > + return; > > + } > > + scope->didChangeActiveStyleSheetCandidates(); > > + return; > > + } > > We don't need two copies if this section of code!
Oh no! Fixed in
r287741
.
Antoine Quint
Comment 17
2022-01-07 00:44:15 PST
(In reply to Darin Adler from
comment #14
)
> (In reply to Antoine Quint from
comment #11
) > > Are you saying that the HashSet iterator skips over null values? > > Sort of. You can’t put a nullptr into a HashSet of pointers, no values in > the set can be nullptr. And yes the iterator does skip the null values, > technically they are empty buckets.
Filed a patch to remove the null checks in
bug 234948
.
Antoine Quint
Comment 18
2022-12-09 04:07:45 PST
***
Bug 210989
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug