Chromium Code Reviews| Index: Source/core/css/resolver/StyleResolver.cpp |
| diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp |
| index 526c7f1f286fc268e23c518a069b7fcb7df2c1e4..68433351d1385a44e1747eddf083db05d385562d 100644 |
| --- a/Source/core/css/resolver/StyleResolver.cpp |
| +++ b/Source/core/css/resolver/StyleResolver.cpp |
| @@ -543,6 +543,33 @@ void StyleResolver::loadPendingResources(StyleResolverState& state) |
| document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); |
| } |
| +struct AnimationResolveData { |
| + |
| + AnimationResolveData(Element* element) |
| + : baseRenderStyle(nullptr) |
| + , useBaseRenderStyle(false) |
| + { |
| + if (!element) |
| + return; |
| + |
| + if (ActiveAnimations* animations = element->activeAnimations()) { |
| + useBaseRenderStyle = animations->isAnimationStyleChange(); |
| + if (useBaseRenderStyle) |
| + baseRenderStyle = animations->baseRenderStyle(); |
| + else |
| + animations->setBaseRenderStyle(nullptr); |
|
esprehn
2014/10/13 21:44:26
This really doesn't seem like the right place to h
rune
2014/10/13 22:24:49
There are a bunch of ways to do this. Do you think
|
| + |
| +#if ENABLE(ASSERT) |
| + // Force recalc of the base style to check that the cached one was correct. |
| + baseRenderStyle = nullptr; |
| +#endif // !ASSERT |
| + } |
| + } |
| + |
| + const RenderStyle* baseRenderStyle; |
| + bool useBaseRenderStyle; |
| +}; |
| + |
| PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderStyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| RuleMatchingBehavior matchingBehavior) |
| { |
| @@ -578,7 +605,12 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS |
| return sharedStyle.release(); |
| } |
| - if (state.parentStyle()) { |
| + |
| + AnimationResolveData animationData(element); |
| + |
| + if (animationData.baseRenderStyle) { |
| + state.setStyle(RenderStyle::clone(animationData.baseRenderStyle)); |
| + } else if (state.parentStyle()) { |
| state.setStyle(RenderStyle::create()); |
| state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); |
| } else { |
| @@ -607,12 +639,13 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS |
| state.style()->setInsideLink(linkState); |
| } |
| - bool needsCollection = false; |
| - CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element, needsCollection); |
| - if (needsCollection) |
| - collectFeatures(); |
| + if (!animationData.baseRenderStyle) { |
| + |
| + bool needsCollection = false; |
| + CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element, needsCollection); |
| + if (needsCollection) |
| + collectFeatures(); |
| - { |
| ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); |
| matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludingSMIL); |
| @@ -621,12 +654,15 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS |
| applyCallbackSelectors(state); |
| addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| - } |
| - // Cache our original display. |
| - state.style()->setOriginalDisplay(state.style()->display()); |
| + // Cache our original display. |
| + state.style()->setOriginalDisplay(state.style()->display()); |
| + |
| + adjustRenderStyle(state, element); |
| - adjustRenderStyle(state, element); |
| + if (animationData.useBaseRenderStyle) |
| + element->activeAnimations()->setBaseRenderStyle(RenderStyle::clone(state.style())); |
| + } |
| // FIXME: The CSSWG wants to specify that the effects of animations are applied before |
| // important rules, but this currently happens here as we require adjustment to have happened |
| @@ -761,7 +797,13 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo |
| StyleResolverParentScope::ensureParentStackIsPushed(); |
| - if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { |
| + Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
| + |
| + AnimationResolveData animationData(pseudoElement); |
| + |
| + if (animationData.baseRenderStyle) { |
| + state.setStyle(RenderStyle::clone(animationData.baseRenderStyle)); |
| + } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { |
| state.setStyle(RenderStyle::create()); |
| state.style()->inheritFrom(state.parentStyle()); |
| } else { |
| @@ -775,7 +817,7 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo |
| // Since we don't use pseudo-elements in any of our quirk/print |
| // user agent rules, don't waste time walking those rules. |
| - { |
| + if (!animationData.baseRenderStyle) { |
| // Check UA, user and author rules. |
| ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style()); |
| collector.setPseudoStyleRequest(pseudoStyleRequest); |
| @@ -790,19 +832,22 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo |
| applyCallbackSelectors(state); |
| addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| - } |
| - // Cache our original display. |
| - state.style()->setOriginalDisplay(state.style()->display()); |
| + // Cache our original display. |
| + state.style()->setOriginalDisplay(state.style()->display()); |
| - // FIXME: Passing 0 as the Element* introduces a lot of complexity |
| - // in the adjustRenderStyle code. |
| - adjustRenderStyle(state, 0); |
| + // FIXME: Passing 0 as the Element* introduces a lot of complexity |
| + // in the adjustRenderStyle code. |
| + adjustRenderStyle(state, 0); |
| + |
| + if (animationData.useBaseRenderStyle) |
| + pseudoElement->activeAnimations()->setBaseRenderStyle(RenderStyle::clone(state.style())); |
| + } |
| // FIXME: The CSSWG wants to specify that the effects of animations are applied before |
| // important rules, but this currently happens here as we require adjustment to have happened |
| // before deciding which properties to transition. |
| - if (applyAnimatedProperties(state, element.pseudoElement(pseudoStyleRequest.pseudoId))) |
| + if (applyAnimatedProperties(state, pseudoElement)) |
| adjustRenderStyle(state, 0); |
| didAccess(); |