Diff
Modified: trunk/Source/WebCore/ChangeLog (289013 => 289014)
--- trunk/Source/WebCore/ChangeLog 2022-02-03 00:30:52 UTC (rev 289013)
+++ trunk/Source/WebCore/ChangeLog 2022-02-03 00:32:25 UTC (rev 289014)
@@ -1,3 +1,28 @@
+2022-02-02 Antoine Quint <[email protected]>
+
+ Keyframe resolution methods should use reference instead of pointer parameters
+ https://bugs.webkit.org/show_bug.cgi?id=236020
+
+ Reviewed by Dean Jackson.
+
+ The Style::Resolver::styleForKeyframe() method would take in a `const RenderStyle*`
+ and a `const StyleRuleKeyframe*` but these parameters were used without null checks.
+ This patch changes this method signature to take in references instead, which involves
+ also changing the signature for Style::Resolver::keyframeStylesForAnimation().
+
+ * animation/KeyframeEffect.cpp:
+ (WebCore::KeyframeEffect::getKeyframes):
+ (WebCore::KeyframeEffect::updateBlendingKeyframes):
+ (WebCore::KeyframeEffect::computeCSSAnimationBlendingKeyframes):
+ (WebCore::KeyframeEffect::applyPendingAcceleratedActions):
+ * rendering/style/KeyframeList.cpp:
+ (WebCore::KeyframeList::fillImplicitKeyframes):
+ * rendering/style/KeyframeList.h:
+ * style/StyleResolver.cpp:
+ (WebCore::Style::Resolver::styleForKeyframe):
+ (WebCore::Style::Resolver::keyframeStylesForAnimation):
+ * style/StyleResolver.h:
+
2022-02-02 Myles C. Maxfield <[email protected]>
Percentage word spacing doesn't incorporate synthetic bold expansion
Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (289013 => 289014)
--- trunk/Source/WebCore/animation/KeyframeEffect.cpp 2022-02-03 00:30:52 UTC (rev 289013)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp 2022-02-03 00:32:25 UTC (rev 289014)
@@ -602,12 +602,13 @@
auto* target = m_target.get();
auto* renderer = this->renderer();
auto* lastStyleChangeEventStyle = targetStyleable()->lastStyleChangeEventStyle();
+ auto& elementStyle = lastStyleChangeEventStyle ? *lastStyleChangeEventStyle : currentStyle();
ComputedStyleExtractor computedStyleExtractor { target, false, m_pseudoId };
KeyframeList computedKeyframeList(m_blendingKeyframes.animationName());
computedKeyframeList.copyKeyframes(m_blendingKeyframes);
- computedKeyframeList.fillImplicitKeyframes(*m_target, m_target->styleResolver(), lastStyleChangeEventStyle, nullptr);
+ computedKeyframeList.fillImplicitKeyframes(*m_target, m_target->styleResolver(), elementStyle, nullptr);
auto keyframeRules = [&]() -> const Vector<Ref<StyleRuleKeyframe>> {
if (!is<CSSAnimation>(animation()))
@@ -848,7 +849,7 @@
keyframeList.addProperty(styleProperties->propertyAt(i).id());
auto keyframeRule = StyleRuleKeyframe::create(WTFMove(styleProperties));
- keyframeValue.setStyle(styleResolver.styleForKeyframe(*m_target, &elementStyle, resolutionContext, keyframeRule.ptr(), keyframeValue));
+ keyframeValue.setStyle(styleResolver.styleForKeyframe(*m_target, elementStyle, resolutionContext, keyframeRule.get(), keyframeValue));
keyframeList.insert(WTFMove(keyframeValue));
}
@@ -1047,7 +1048,7 @@
KeyframeList keyframeList(backingAnimation.name().string);
if (auto* styleScope = Style::Scope::forOrdinal(*m_target, backingAnimation.nameStyleScopeOrdinal()))
- styleScope->resolver().keyframeStylesForAnimation(*m_target, &unanimatedStyle, resolutionContext, keyframeList);
+ styleScope->resolver().keyframeStylesForAnimation(*m_target, unanimatedStyle, resolutionContext, keyframeList);
// Ensure resource loads for all the frames.
for (auto& keyframe : keyframeList) {
@@ -1777,7 +1778,7 @@
KeyframeList explicitKeyframes(m_blendingKeyframes.animationName());
explicitKeyframes.copyKeyframes(m_blendingKeyframes);
- explicitKeyframes.fillImplicitKeyframes(*m_target, m_target->styleResolver(), underlyingStyle.get(), nullptr);
+ explicitKeyframes.fillImplicitKeyframes(*m_target, m_target->styleResolver(), *underlyingStyle, nullptr);
return renderer->startAnimation(timeOffset, backingAnimationForCompositedRenderer(), explicitKeyframes) ? RunningAccelerated::Yes : RunningAccelerated::No;
};
Modified: trunk/Source/WebCore/rendering/style/KeyframeList.cpp (289013 => 289014)
--- trunk/Source/WebCore/rendering/style/KeyframeList.cpp 2022-02-03 00:30:52 UTC (rev 289013)
+++ trunk/Source/WebCore/rendering/style/KeyframeList.cpp 2022-02-03 00:32:25 UTC (rev 289014)
@@ -116,13 +116,13 @@
return rule.get().get();
}
-void KeyframeList::fillImplicitKeyframes(const Element& element, Style::Resolver& styleResolver, const RenderStyle* elementStyle, const RenderStyle* parentElementStyle)
+void KeyframeList::fillImplicitKeyframes(const Element& element, Style::Resolver& styleResolver, const RenderStyle& elementStyle, const RenderStyle* parentElementStyle)
{
// If the 0% keyframe is missing, create it (but only if there is at least one other keyframe).
auto initialSize = size();
if (initialSize > 0 && m_keyframes[0].key()) {
KeyframeValue keyframeValue(0, nullptr);
- keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, { parentElementStyle }, &zeroPercentKeyframe(), keyframeValue));
+ keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, { parentElementStyle }, zeroPercentKeyframe(), keyframeValue));
insert(WTFMove(keyframeValue));
}
@@ -129,7 +129,7 @@
// If the 100% keyframe is missing, create it (but only if there is at least one other keyframe).
if (initialSize > 0 && (m_keyframes[size() - 1].key() != 1)) {
KeyframeValue keyframeValue(1, nullptr);
- keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, { parentElementStyle }, &hundredPercentKeyframe(), keyframeValue));
+ keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, { parentElementStyle }, hundredPercentKeyframe(), keyframeValue));
insert(WTFMove(keyframeValue));
}
}
Modified: trunk/Source/WebCore/rendering/style/KeyframeList.h (289013 => 289014)
--- trunk/Source/WebCore/rendering/style/KeyframeList.h 2022-02-03 00:30:52 UTC (rev 289013)
+++ trunk/Source/WebCore/rendering/style/KeyframeList.h 2022-02-03 00:32:25 UTC (rev 289014)
@@ -100,7 +100,7 @@
void copyKeyframes(KeyframeList&);
bool hasImplicitKeyframes() const;
- void fillImplicitKeyframes(const Element&, Style::Resolver&, const RenderStyle* elementStyle, const RenderStyle* parentElementStyle);
+ void fillImplicitKeyframes(const Element&, Style::Resolver&, const RenderStyle& elementStyle, const RenderStyle* parentElementStyle);
auto begin() const { return m_keyframes.begin(); }
auto end() const { return m_keyframes.end(); }
Modified: trunk/Source/WebCore/style/StyleResolver.cpp (289013 => 289014)
--- trunk/Source/WebCore/style/StyleResolver.cpp 2022-02-03 00:30:52 UTC (rev 289013)
+++ trunk/Source/WebCore/style/StyleResolver.cpp 2022-02-03 00:32:25 UTC (rev 289014)
@@ -275,15 +275,15 @@
return { state.takeStyle(), WTFMove(elementStyleRelations) };
}
-std::unique_ptr<RenderStyle> Resolver::styleForKeyframe(const Element& element, const RenderStyle* elementStyle, const ResolutionContext& context, const StyleRuleKeyframe* keyframe, KeyframeValue& keyframeValue)
+std::unique_ptr<RenderStyle> Resolver::styleForKeyframe(const Element& element, const RenderStyle& elementStyle, const ResolutionContext& context, const StyleRuleKeyframe& keyframe, KeyframeValue& keyframeValue)
{
MatchResult result;
- result.authorDeclarations.append({ &keyframe->properties(), SelectorChecker::MatchAll, propertyAllowlistForPseudoId(elementStyle->styleType()) });
+ result.authorDeclarations.append({ &keyframe.properties(), SelectorChecker::MatchAll, propertyAllowlistForPseudoId(elementStyle.styleType()) });
auto state = State(element, nullptr, context.documentElementStyle);
- state.setStyle(RenderStyle::clonePtr(*elementStyle));
- state.setParentStyle(RenderStyle::clonePtr(context.parentStyle ? *context.parentStyle : *elementStyle));
+ state.setStyle(RenderStyle::clonePtr(elementStyle));
+ state.setParentStyle(RenderStyle::clonePtr(context.parentStyle ? *context.parentStyle : elementStyle));
Builder builder(*state.style(), builderContext(state), result, CascadeLevel::Author);
builder.applyAllProperties();
@@ -292,9 +292,9 @@
adjuster.adjust(*state.style(), state.userAgentAppearanceStyle());
// Add all the animating properties to the keyframe.
- unsigned propertyCount = keyframe->properties().propertyCount();
+ unsigned propertyCount = keyframe.properties().propertyCount();
for (unsigned i = 0; i < propertyCount; ++i) {
- CSSPropertyID property = keyframe->properties().propertyAt(i).id();
+ CSSPropertyID property = keyframe.properties().propertyAt(i).id();
// The animation-composition and animation-timing-function within keyframes are special
// because they are not animated; they just describe the composite operation and timing
// function between this keyframe and the next.
@@ -393,7 +393,7 @@
return deduplicatedKeyframes;
}
-void Resolver::keyframeStylesForAnimation(const Element& element, const RenderStyle* elementStyle, const ResolutionContext& context, KeyframeList& list)
+void Resolver::keyframeStylesForAnimation(const Element& element, const RenderStyle& elementStyle, const ResolutionContext& context, KeyframeList& list)
{
list.clear();
@@ -406,7 +406,7 @@
// Add this keyframe style to all the indicated key times
for (auto key : keyframeRule->keys()) {
KeyframeValue keyframeValue(0, nullptr);
- keyframeValue.setStyle(styleForKeyframe(element, elementStyle, context, keyframeRule.ptr(), keyframeValue));
+ keyframeValue.setStyle(styleForKeyframe(element, elementStyle, context, keyframeRule.get(), keyframeValue));
keyframeValue.setKey(key);
if (auto timingFunctionCSSValue = keyframeRule->properties().getPropertyCSSValue(CSSPropertyAnimationTimingFunction))
keyframeValue.setTimingFunction(TimingFunction::createFromCSSValue(*timingFunctionCSSValue.get()));
Modified: trunk/Source/WebCore/style/StyleResolver.h (289013 => 289014)
--- trunk/Source/WebCore/style/StyleResolver.h 2022-02-03 00:30:52 UTC (rev 289013)
+++ trunk/Source/WebCore/style/StyleResolver.h 2022-02-03 00:32:25 UTC (rev 289014)
@@ -98,7 +98,7 @@
ElementStyle styleForElement(const Element&, const ResolutionContext&, RuleMatchingBehavior = RuleMatchingBehavior::MatchAllRules);
- void keyframeStylesForAnimation(const Element&, const RenderStyle* elementStyle, const ResolutionContext&, KeyframeList&);
+ void keyframeStylesForAnimation(const Element&, const RenderStyle& elementStyle, const ResolutionContext&, KeyframeList&);
WEBCORE_EXPORT std::unique_ptr<RenderStyle> pseudoStyleForElement(const Element&, const PseudoElementRequest&, const ResolutionContext&);
@@ -118,7 +118,7 @@
void addCurrentSVGFontFaceRules();
- std::unique_ptr<RenderStyle> styleForKeyframe(const Element&, const RenderStyle* elementStyle, const ResolutionContext&, const StyleRuleKeyframe*, KeyframeValue&);
+ std::unique_ptr<RenderStyle> styleForKeyframe(const Element&, const RenderStyle& elementStyle, const ResolutionContext&, const StyleRuleKeyframe&, KeyframeValue&);
bool isAnimationNameValid(const String&);
// These methods will give back the set of rules that matched for a given element (or a pseudo-element).