Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp

Issue 2532953008: Apply custom property animations (Closed)
Patch Set: Make animatedElement usage consistent Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 bool CSSAnimations::isTransitionAnimationForInspector( 225 bool CSSAnimations::isTransitionAnimationForInspector(
226 const Animation& animation) const { 226 const Animation& animation) const {
227 for (const auto& it : m_transitions) { 227 for (const auto& it : m_transitions) {
228 if (it.value.animation->sequenceNumber() == animation.sequenceNumber()) 228 if (it.value.animation->sequenceNumber() == animation.sequenceNumber())
229 return true; 229 return true;
230 } 230 }
231 return false; 231 return false;
232 } 232 }
233 233
234 void CSSAnimations::calculateUpdate(const Element* animatingElement, 234 void CSSAnimations::calculateCompositorAndTransitionUpdate(
235 Element& element, 235 const Element* animatingElement,
236 const ComputedStyle& style, 236 Element& element,
237 ComputedStyle* parentStyle, 237 const ComputedStyle& style,
238 CSSAnimationUpdate& animationUpdate, 238 ComputedStyle* parentStyle,
239 StyleResolver* resolver) { 239 CSSAnimationUpdate& animationUpdate) {
240 calculateCompositorAnimationUpdate(animationUpdate, animatingElement, element, 240 calculateCompositorAnimationUpdate(animationUpdate, animatingElement, element,
241 style, parentStyle); 241 style, parentStyle);
242 calculateAnimationUpdate(animationUpdate, animatingElement, element, style,
243 parentStyle, resolver);
244 calculateAnimationActiveInterpolations(animationUpdate, animatingElement);
245 calculateTransitionUpdate(animationUpdate, animatingElement, style); 242 calculateTransitionUpdate(animationUpdate, animatingElement, style);
246 calculateTransitionActiveInterpolations(animationUpdate, animatingElement);
247 } 243 }
248 244
249 static const KeyframeEffectModelBase* getKeyframeEffectModelBase( 245 static const KeyframeEffectModelBase* getKeyframeEffectModelBase(
250 const AnimationEffectReadOnly* effect) { 246 const AnimationEffectReadOnly* effect) {
251 if (!effect) 247 if (!effect)
252 return nullptr; 248 return nullptr;
253 const EffectModel* model = nullptr; 249 const EffectModel* model = nullptr;
254 if (effect->isKeyframeEffectReadOnly()) 250 if (effect->isKeyframeEffectReadOnly())
255 model = toKeyframeEffectReadOnly(effect)->model(); 251 model = toKeyframeEffectReadOnly(effect)->model();
256 else if (effect->isInertEffect()) 252 else if (effect->isInertEffect())
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 const ElementAnimations* elementAnimations = 313 const ElementAnimations* elementAnimations =
318 animatingElement ? animatingElement->elementAnimations() : nullptr; 314 animatingElement ? animatingElement->elementAnimations() : nullptr;
319 315
320 bool isAnimationStyleChange = 316 bool isAnimationStyleChange =
321 elementAnimations && elementAnimations->isAnimationStyleChange(); 317 elementAnimations && elementAnimations->isAnimationStyleChange();
322 318
323 #if !DCHECK_IS_ON() 319 #if !DCHECK_IS_ON()
324 // If we're in an animation style change, no animations can have started, been 320 // If we're in an animation style change, no animations can have started, been
325 // cancelled or changed play state. When DCHECK is enabled, we verify this 321 // cancelled or changed play state. When DCHECK is enabled, we verify this
326 // optimization. 322 // optimization.
327 if (isAnimationStyleChange) 323 if (isAnimationStyleChange) {
324 calculateAnimationActiveInterpolations(update, animatingElement);
328 return; 325 return;
326 }
329 #endif 327 #endif
330 328
331 const CSSAnimationData* animationData = style.animations(); 329 const CSSAnimationData* animationData = style.animations();
332 const CSSAnimations* cssAnimations = 330 const CSSAnimations* cssAnimations =
333 elementAnimations ? &elementAnimations->cssAnimations() : nullptr; 331 elementAnimations ? &elementAnimations->cssAnimations() : nullptr;
334 const Element* elementForScoping = 332 const Element* elementForScoping =
335 animatingElement ? animatingElement : &element; 333 animatingElement ? animatingElement : &element;
336 334
337 Vector<bool> cancelRunningAnimationFlags( 335 Vector<bool> cancelRunningAnimationFlags(
338 cssAnimations ? cssAnimations->m_runningAnimations.size() : 0); 336 cssAnimations ? cssAnimations->m_runningAnimations.size() : 0);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 418 }
421 } 419 }
422 420
423 for (size_t i = 0; i < cancelRunningAnimationFlags.size(); i++) { 421 for (size_t i = 0; i < cancelRunningAnimationFlags.size(); i++) {
424 if (cancelRunningAnimationFlags[i]) { 422 if (cancelRunningAnimationFlags[i]) {
425 DCHECK(cssAnimations && !isAnimationStyleChange); 423 DCHECK(cssAnimations && !isAnimationStyleChange);
426 update.cancelAnimation(i, 424 update.cancelAnimation(i,
427 *cssAnimations->m_runningAnimations[i]->animation); 425 *cssAnimations->m_runningAnimations[i]->animation);
428 } 426 }
429 } 427 }
428
429 calculateAnimationActiveInterpolations(update, animatingElement);
430 } 430 }
431 431
432 void CSSAnimations::snapshotCompositorKeyframes( 432 void CSSAnimations::snapshotCompositorKeyframes(
433 Element& element, 433 Element& element,
434 CSSAnimationUpdate& update, 434 CSSAnimationUpdate& update,
435 const ComputedStyle& style, 435 const ComputedStyle& style,
436 const ComputedStyle* parentStyle) { 436 const ComputedStyle* parentStyle) {
437 const auto& snapshot = [&element, &style, 437 const auto& snapshot = [&element, &style,
438 parentStyle](const AnimationEffectReadOnly* effect) { 438 parentStyle](const AnimationEffectReadOnly* effect) {
439 const KeyframeEffectModelBase* keyframeEffect = 439 const KeyframeEffectModelBase* keyframeEffect =
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 for (const auto& entry : *activeTransitions) { 819 for (const auto& entry : *activeTransitions) {
820 CSSPropertyID id = entry.key; 820 CSSPropertyID id = entry.key;
821 if (!anyTransitionHadTransitionAll && !animationStyleRecalc && 821 if (!anyTransitionHadTransitionAll && !animationStyleRecalc &&
822 !listedProperties.test(id - firstCSSProperty)) { 822 !listedProperties.test(id - firstCSSProperty)) {
823 update.cancelTransition(id); 823 update.cancelTransition(id);
824 } else if (entry.value.animation->finishedInternal()) { 824 } else if (entry.value.animation->finishedInternal()) {
825 update.finishTransition(id); 825 update.finishTransition(id);
826 } 826 }
827 } 827 }
828 } 828 }
829 calculateTransitionActiveInterpolations(update, animatingElement);
829 } 830 }
830 831
831 void CSSAnimations::cancel() { 832 void CSSAnimations::cancel() {
832 for (const auto& runningAnimation : m_runningAnimations) { 833 for (const auto& runningAnimation : m_runningAnimations) {
833 runningAnimation->animation->cancel(); 834 runningAnimation->animation->cancel();
834 runningAnimation->animation->update(TimingUpdateOnDemand); 835 runningAnimation->animation->update(TimingUpdateOnDemand);
835 } 836 }
836 837
837 for (const auto& entry : m_transitions) { 838 for (const auto& entry : m_transitions) {
838 entry.value.animation->cancel(); 839 entry.value.animation->cancel();
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 // and from their shadow sub-trees if they are shadow hosts. 1088 // and from their shadow sub-trees if they are shadow hosts.
1088 if (element.treeScope() == treeScope) 1089 if (element.treeScope() == treeScope)
1089 return true; 1090 return true;
1090 if (!isShadowHost(element)) 1091 if (!isShadowHost(element))
1091 return false; 1092 return false;
1092 if (treeScope.rootNode() == treeScope.document()) 1093 if (treeScope.rootNode() == treeScope.document())
1093 return false; 1094 return false;
1094 return toShadowRoot(treeScope.rootNode()).host() == element; 1095 return toShadowRoot(treeScope.rootNode()).host() == element;
1095 } 1096 }
1096 1097
1098 bool CSSAnimations::isCustomPropertyHandle(const PropertyHandle& property) {
1099 return property.isCSSProperty() &&
1100 property.cssProperty() == CSSPropertyVariable;
1101 }
1102
1103 bool CSSAnimations::isAnimatingCustomProperties(
1104 const ElementAnimations* elementAnimations) {
1105 return elementAnimations &&
1106 elementAnimations->effectStack().affectsProperties(
1107 isCustomPropertyHandle);
1108 }
1109
1097 DEFINE_TRACE(CSSAnimations) { 1110 DEFINE_TRACE(CSSAnimations) {
1098 visitor->trace(m_transitions); 1111 visitor->trace(m_transitions);
1099 visitor->trace(m_pendingUpdate); 1112 visitor->trace(m_pendingUpdate);
1100 visitor->trace(m_runningAnimations); 1113 visitor->trace(m_runningAnimations);
1101 } 1114 }
1102 1115
1103 } // namespace blink 1116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698