Diff
Modified: trunk/Source/WebCore/ChangeLog (272897 => 272898)
--- trunk/Source/WebCore/ChangeLog 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/ChangeLog 2021-02-16 08:56:50 UTC (rev 272898)
@@ -1,3 +1,44 @@
+2021-02-16 Antoine Quint <grao...@webkit.org>
+
+ Style::Resolver::styleForKeyframe() should take in the parent style
+ https://bugs.webkit.org/show_bug.cgi?id=221926
+
+ Reviewed by Darin Adler.
+
+ Address the FIXME in Style::TreeResolver::createAnimatedElementUpdate() such that the parent
+ style is passed all the way from that function down to Style::Resolver::styleForKeyframe()
+ removing the need for Style::Resolver::setParentElementStyleForKeyframes().
+
+ This is a refactoring change only, so there is no new test.
+
+ * animation/AnimationTimeline.cpp:
+ (WebCore::AnimationTimeline::updateCSSAnimationsForStyleable):
+ * animation/AnimationTimeline.h:
+ * animation/CSSAnimation.cpp:
+ (WebCore::CSSAnimation::create):
+ * animation/CSSAnimation.h:
+ * animation/CSSTransition.cpp:
+ (WebCore::CSSTransition::create):
+ * animation/DeclarativeAnimation.cpp:
+ (WebCore::DeclarativeAnimation::initialize):
+ * animation/DeclarativeAnimation.h:
+ * animation/KeyframeEffect.cpp:
+ (WebCore::KeyframeEffect::updateBlendingKeyframes):
+ (WebCore::KeyframeEffect::computeDeclarativeAnimationBlendingKeyframes):
+ (WebCore::KeyframeEffect::computeCSSAnimationBlendingKeyframes):
+ (WebCore::KeyframeEffect::applyPendingAcceleratedActions):
+ * animation/KeyframeEffect.h:
+ * 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:
+ (WebCore::Style::Resolver::setParentElementStyleForKeyframes): Deleted.
+ * style/StyleTreeResolver.cpp:
+ (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
+
2021-02-15 John Wilander <wilan...@apple.com>
PCM: Add high entropy attributionSourceNonce attribute to anchor tags
Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (272897 => 272898)
--- trunk/Source/WebCore/animation/AnimationTimeline.cpp 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp 2021-02-16 08:56:50 UTC (rev 272898)
@@ -200,7 +200,7 @@
return false;
}
-void AnimationTimeline::updateCSSAnimationsForStyleable(const Styleable& styleable, const RenderStyle* currentStyle, const RenderStyle& newStyle)
+void AnimationTimeline::updateCSSAnimationsForStyleable(const Styleable& styleable, const RenderStyle* currentStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle)
{
auto& keyframeEffectStack = styleable.ensureKeyframeEffectStack();
@@ -250,7 +250,7 @@
}
if (!foundMatchingAnimation)
- newAnimations.add(CSSAnimation::create(styleable, currentAnimation, currentStyle, newStyle));
+ newAnimations.add(CSSAnimation::create(styleable, currentAnimation, currentStyle, newStyle, parentElementStyle));
}
}
Modified: trunk/Source/WebCore/animation/AnimationTimeline.h (272897 => 272898)
--- trunk/Source/WebCore/animation/AnimationTimeline.h 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/AnimationTimeline.h 2021-02-16 08:56:50 UTC (rev 272898)
@@ -71,7 +71,7 @@
void removeDeclarativeAnimationFromListsForOwningElement(WebAnimation&, const Styleable&);
- void updateCSSAnimationsForStyleable(const Styleable&, const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle);
+ void updateCSSAnimationsForStyleable(const Styleable&, const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle, const RenderStyle* parentElementStyle);
void updateCSSTransitionsForStyleable(const Styleable&, const RenderStyle& currentStyle, const RenderStyle& newStyle);
protected:
Modified: trunk/Source/WebCore/animation/CSSAnimation.cpp (272897 => 272898)
--- trunk/Source/WebCore/animation/CSSAnimation.cpp 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/CSSAnimation.cpp 2021-02-16 08:56:50 UTC (rev 272898)
@@ -36,10 +36,10 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSAnimation);
-Ref<CSSAnimation> CSSAnimation::create(const Styleable& owningElement, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle)
+Ref<CSSAnimation> CSSAnimation::create(const Styleable& owningElement, const Animation& backingAnimation, const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle)
{
auto result = adoptRef(*new CSSAnimation(owningElement, backingAnimation));
- result->initialize(oldStyle, newStyle);
+ result->initialize(oldStyle, newStyle, parentElementStyle);
InspectorInstrumentation::didCreateWebAnimation(result.get());
Modified: trunk/Source/WebCore/animation/CSSAnimation.h (272897 => 272898)
--- trunk/Source/WebCore/animation/CSSAnimation.h 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/CSSAnimation.h 2021-02-16 08:56:50 UTC (rev 272898)
@@ -38,7 +38,7 @@
class CSSAnimation final : public DeclarativeAnimation {
WTF_MAKE_ISO_ALLOCATED(CSSAnimation);
public:
- static Ref<CSSAnimation> create(const Styleable&, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle);
+ static Ref<CSSAnimation> create(const Styleable&, const Animation&, const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle);
~CSSAnimation() = default;
bool isCSSAnimation() const override { return true; }
Modified: trunk/Source/WebCore/animation/CSSTransition.cpp (272897 => 272898)
--- trunk/Source/WebCore/animation/CSSTransition.cpp 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/CSSTransition.cpp 2021-02-16 08:56:50 UTC (rev 272898)
@@ -41,7 +41,7 @@
{
ASSERT(oldStyle);
auto result = adoptRef(*new CSSTransition(owningElement, property, generationTime, backingAnimation, *oldStyle, newStyle, reversingAdjustedStartStyle, reversingShorteningFactor));
- result->initialize(oldStyle, newStyle);
+ result->initialize(oldStyle, newStyle, nullptr);
result->setTimingProperties(delay, duration);
InspectorInstrumentation::didCreateWebAnimation(result.get());
Modified: trunk/Source/WebCore/animation/DeclarativeAnimation.cpp (272897 => 272898)
--- trunk/Source/WebCore/animation/DeclarativeAnimation.cpp 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/DeclarativeAnimation.cpp 2021-02-16 08:56:50 UTC (rev 272898)
@@ -106,7 +106,7 @@
syncPropertiesWithBackingAnimation();
}
-void DeclarativeAnimation::initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle)
+void DeclarativeAnimation::initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle)
{
// We need to suspend invalidation of the animation's keyframe effect during its creation
// as it would otherwise trigger invalidation of the document's style and this would be
@@ -117,7 +117,7 @@
setEffect(KeyframeEffect::create(*m_owningElement, m_owningPseudoId));
setTimeline(&m_owningElement->document().timeline());
- downcast<KeyframeEffect>(effect())->computeDeclarativeAnimationBlendingKeyframes(oldStyle, newStyle);
+ downcast<KeyframeEffect>(effect())->computeDeclarativeAnimationBlendingKeyframes(oldStyle, newStyle, parentElementStyle);
syncPropertiesWithBackingAnimation();
if (backingAnimation().playState() == AnimationPlayState::Playing)
play();
Modified: trunk/Source/WebCore/animation/DeclarativeAnimation.h (272897 => 272898)
--- trunk/Source/WebCore/animation/DeclarativeAnimation.h 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/DeclarativeAnimation.h 2021-02-16 08:56:50 UTC (rev 272898)
@@ -75,7 +75,7 @@
protected:
DeclarativeAnimation(const Styleable&, const Animation&);
- virtual void initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle);
+ virtual void initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle);
virtual void syncPropertiesWithBackingAnimation();
// elapsedTime is the animation's current time at the time the event is added and is exposed through the DOM API, timelineTime is the animations'
// timeline current time and is not exposed through the DOM API but used by the DocumentTimeline for sorting events before dispatch.
Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (272897 => 272898)
--- trunk/Source/WebCore/animation/KeyframeEffect.cpp 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp 2021-02-16 08:56:50 UTC (rev 272898)
@@ -827,7 +827,7 @@
keyframeList.addProperty(styleProperties->propertyAt(i).id());
auto keyframeRule = StyleRuleKeyframe::create(WTFMove(styleProperties));
- keyframeValue.setStyle(styleResolver.styleForKeyframe(*m_target, &elementStyle, keyframeRule.ptr(), keyframeValue));
+ keyframeValue.setStyle(styleResolver.styleForKeyframe(*m_target, &elementStyle, nullptr, keyframeRule.ptr(), keyframeValue));
keyframeList.insert(WTFMove(keyframeValue));
}
@@ -985,16 +985,16 @@
});
}
-void KeyframeEffect::computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle)
+void KeyframeEffect::computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle)
{
ASSERT(is<DeclarativeAnimation>(animation()));
if (is<CSSAnimation>(animation()))
- computeCSSAnimationBlendingKeyframes(newStyle);
+ computeCSSAnimationBlendingKeyframes(newStyle, parentElementStyle);
else if (is<CSSTransition>(animation()))
computeCSSTransitionBlendingKeyframes(oldStyle, newStyle);
}
-void KeyframeEffect::computeCSSAnimationBlendingKeyframes(const RenderStyle& unanimatedStyle)
+void KeyframeEffect::computeCSSAnimationBlendingKeyframes(const RenderStyle& unanimatedStyle, const RenderStyle* parentElementStyle)
{
ASSERT(is<CSSAnimation>(animation()));
ASSERT(document());
@@ -1004,7 +1004,7 @@
KeyframeList keyframeList(backingAnimation.name());
if (auto* styleScope = Style::Scope::forOrdinal(*m_target, backingAnimation.nameStyleScopeOrdinal()))
- styleScope->resolver().keyframeStylesForAnimation(*m_target, &unanimatedStyle, keyframeList);
+ styleScope->resolver().keyframeStylesForAnimation(*m_target, &unanimatedStyle, parentElementStyle, keyframeList);
// Ensure resource loads for all the frames.
for (auto& keyframe : keyframeList.keyframes()) {
@@ -1727,7 +1727,7 @@
KeyframeList explicitKeyframes(m_blendingKeyframes.animationName());
explicitKeyframes.copyKeyframes(m_blendingKeyframes);
- explicitKeyframes.fillImplicitKeyframes(*m_target, m_target->styleResolver(), lastStyleChangeEventStyle);
+ explicitKeyframes.fillImplicitKeyframes(*m_target, m_target->styleResolver(), lastStyleChangeEventStyle, nullptr);
return renderer->startAnimation(timeOffset, backingAnimationForCompositedRenderer(), explicitKeyframes) ? RunningAccelerated::Yes : RunningAccelerated::No;
};
Modified: trunk/Source/WebCore/animation/KeyframeEffect.h (272897 => 272898)
--- trunk/Source/WebCore/animation/KeyframeEffect.h 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/animation/KeyframeEffect.h 2021-02-16 08:56:50 UTC (rev 272898)
@@ -154,7 +154,7 @@
#endif
bool colorFilterFunctionListsMatch() const override { return m_colorFilterFunctionListsMatch; }
- void computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle);
+ void computeDeclarativeAnimationBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle, const RenderStyle* parentElementStyle);
const KeyframeList& blendingKeyframes() const { return m_blendingKeyframes; }
const HashSet<CSSPropertyID>& animatedProperties() const { return m_blendingKeyframes.properties(); }
bool animatesProperty(CSSPropertyID) const;
@@ -199,7 +199,7 @@
void computeSomeKeyframesUseStepsTimingFunction();
void clearBlendingKeyframes();
void updateBlendingKeyframes(RenderStyle&);
- void computeCSSAnimationBlendingKeyframes(const RenderStyle&);
+ void computeCSSAnimationBlendingKeyframes(const RenderStyle& unanimatedStyle, const RenderStyle* parentElementStyle);
void computeCSSTransitionBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle);
void computeAcceleratedPropertiesState();
void setBlendingKeyframes(KeyframeList&);
Modified: trunk/Source/WebCore/rendering/style/KeyframeList.cpp (272897 => 272898)
--- trunk/Source/WebCore/rendering/style/KeyframeList.cpp 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/rendering/style/KeyframeList.cpp 2021-02-16 08:56:50 UTC (rev 272898)
@@ -113,13 +113,13 @@
return rule.get().get();
}
-void KeyframeList::fillImplicitKeyframes(const Element& element, Style::Resolver& styleResolver, const RenderStyle* elementStyle)
+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, &zeroPercentKeyframe(), keyframeValue));
+ keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, parentElementStyle, &zeroPercentKeyframe(), keyframeValue));
insert(WTFMove(keyframeValue));
}
@@ -126,7 +126,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, &hundredPercentKeyframe(), keyframeValue));
+ keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, parentElementStyle, &hundredPercentKeyframe(), keyframeValue));
insert(WTFMove(keyframeValue));
}
}
Modified: trunk/Source/WebCore/rendering/style/KeyframeList.h (272897 => 272898)
--- trunk/Source/WebCore/rendering/style/KeyframeList.h 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/rendering/style/KeyframeList.h 2021-02-16 08:56:50 UTC (rev 272898)
@@ -95,7 +95,7 @@
void copyKeyframes(KeyframeList&);
bool hasImplicitKeyframes() const;
- void fillImplicitKeyframes(const Element&, Style::Resolver&, const RenderStyle*);
+ void fillImplicitKeyframes(const Element&, Style::Resolver&, const RenderStyle* elementStyle, const RenderStyle* parentElementStyle);
private:
AtomString m_animationName;
Modified: trunk/Source/WebCore/style/StyleResolver.cpp (272897 => 272898)
--- trunk/Source/WebCore/style/StyleResolver.cpp 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/style/StyleResolver.cpp 2021-02-16 08:56:50 UTC (rev 272898)
@@ -249,7 +249,7 @@
return { state.takeStyle(), WTFMove(elementStyleRelations) };
}
-std::unique_ptr<RenderStyle> Resolver::styleForKeyframe(const Element& element, const RenderStyle* elementStyle, const StyleRuleKeyframe* keyframe, KeyframeValue& keyframeValue)
+std::unique_ptr<RenderStyle> Resolver::styleForKeyframe(const Element& element, const RenderStyle* elementStyle, const RenderStyle* parentElementStyle, const StyleRuleKeyframe* keyframe, KeyframeValue& keyframeValue)
{
RELEASE_ASSERT(!m_isDeleted);
@@ -259,7 +259,7 @@
auto state = State(element, nullptr, m_overrideDocumentElementStyle);
state.setStyle(RenderStyle::clonePtr(*elementStyle));
- state.setParentStyle(RenderStyle::clonePtr(m_parentElementStyleForKeyframes ? *m_parentElementStyleForKeyframes : *elementStyle));
+ state.setParentStyle(RenderStyle::clonePtr(parentElementStyle ? *parentElementStyle : *elementStyle));
Builder builder(*state.style(), builderContext(state), result, { CascadeLevel::Author });
builder.applyAllProperties();
@@ -285,7 +285,7 @@
return m_keyframesRuleMap.find(AtomString(name).impl()) != m_keyframesRuleMap.end();
}
-void Resolver::keyframeStylesForAnimation(const Element& element, const RenderStyle* elementStyle, KeyframeList& list)
+void Resolver::keyframeStylesForAnimation(const Element& element, const RenderStyle* elementStyle, const RenderStyle* parentElementStyle, KeyframeList& list)
{
list.clear();
@@ -347,7 +347,7 @@
// Add this keyframe style to all the indicated key times
for (auto key : keyframe->keys()) {
KeyframeValue keyframeValue(0, nullptr);
- keyframeValue.setStyle(styleForKeyframe(element, elementStyle, keyframe.ptr(), keyframeValue));
+ keyframeValue.setStyle(styleForKeyframe(element, elementStyle, parentElementStyle, keyframe.ptr(), keyframeValue));
keyframeValue.setKey(key);
if (auto timingFunctionCSSValue = keyframe->properties().getPropertyCSSValue(CSSPropertyAnimationTimingFunction))
keyframeValue.setTimingFunction(TimingFunction::createFromCSSValue(*timingFunctionCSSValue.get()));
@@ -355,7 +355,7 @@
}
}
- list.fillImplicitKeyframes(element, *this, elementStyle);
+ list.fillImplicitKeyframes(element, *this, elementStyle, parentElementStyle);
}
std::unique_ptr<RenderStyle> Resolver::pseudoStyleForElement(const Element& element, const PseudoElementRequest& pseudoElementRequest, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const SelectorFilter* selectorFilter)
Modified: trunk/Source/WebCore/style/StyleResolver.h (272897 => 272898)
--- trunk/Source/WebCore/style/StyleResolver.h 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/style/StyleResolver.h 2021-02-16 08:56:50 UTC (rev 272898)
@@ -87,7 +87,7 @@
ElementStyle styleForElement(const Element&, const RenderStyle* parentStyle, const RenderStyle* parentBoxStyle = nullptr, RuleMatchingBehavior = RuleMatchingBehavior::MatchAllRules, const SelectorFilter* = nullptr);
- void keyframeStylesForAnimation(const Element&, const RenderStyle*, KeyframeList&);
+ void keyframeStylesForAnimation(const Element&, const RenderStyle* elementStyle, const RenderStyle* parentElementStyle, KeyframeList&);
WEBCORE_EXPORT std::unique_ptr<RenderStyle> pseudoStyleForElement(const Element&, const PseudoElementRequest&, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle = nullptr, const SelectorFilter* = nullptr);
@@ -108,12 +108,9 @@
const RenderStyle* overrideDocumentElementStyle() const { return m_overrideDocumentElementStyle; }
void setOverrideDocumentElementStyle(const RenderStyle* style) { m_overrideDocumentElementStyle = style; }
- // FIXME: Remove and pass this through the animation system normally.
- void setParentElementStyleForKeyframes(const RenderStyle* style) { m_parentElementStyleForKeyframes = style; }
-
void addCurrentSVGFontFaceRules();
- std::unique_ptr<RenderStyle> styleForKeyframe(const Element&, const RenderStyle*, const StyleRuleKeyframe*, KeyframeValue&);
+ std::unique_ptr<RenderStyle> styleForKeyframe(const Element&, const RenderStyle* elementStyle, const RenderStyle* parentElementStyle, 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).
@@ -191,7 +188,6 @@
Document& m_document;
const RenderStyle* m_overrideDocumentElementStyle { nullptr };
- const RenderStyle* m_parentElementStyleForKeyframes { nullptr };
InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (272897 => 272898)
--- trunk/Source/WebCore/style/StyleTreeResolver.cpp 2021-02-16 08:54:40 UTC (rev 272897)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp 2021-02-16 08:56:50 UTC (rev 272898)
@@ -332,14 +332,8 @@
// The order in which CSS Transitions and CSS Animations are updated matters since CSS Transitions define the after-change style
// to use CSS Animations as defined in the previous style change event. As such, we update CSS Animations after CSS Transitions
// such that when CSS Transitions are updated the CSS Animations data is the same as during the previous style change event.
- if ((oldStyle && oldStyle->hasAnimations()) || newStyle->hasAnimations()) {
- // FIXME: Remove this hack and pass the parent style via updateCSSAnimationsForStyleable.
- scope().resolver.setParentElementStyleForKeyframes(&parent().style);
-
- m_document.timeline().updateCSSAnimationsForStyleable(styleable, oldStyle, *newStyle);
-
- scope().resolver.setParentElementStyleForKeyframes(nullptr);
- }
+ if ((oldStyle && oldStyle->hasAnimations()) || newStyle->hasAnimations())
+ m_document.timeline().updateCSSAnimationsForStyleable(styleable, oldStyle, *newStyle, &parent().style);
}
// Now we can update all Web animations, which will include CSS Animations as well