Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 | 193 |
| 194 bool CSSAnimations::isTransitionAnimationForInspector(const Animation& animation ) const | 194 bool CSSAnimations::isTransitionAnimationForInspector(const Animation& animation ) const |
| 195 { | 195 { |
| 196 for (const auto& it : m_transitions) { | 196 for (const auto& it : m_transitions) { |
| 197 if (it.value.animation->sequenceNumber() == animation.sequenceNumber()) | 197 if (it.value.animation->sequenceNumber() == animation.sequenceNumber()) |
| 198 return true; | 198 return true; |
| 199 } | 199 } |
| 200 return false; | 200 return false; |
| 201 } | 201 } |
| 202 | 202 |
| 203 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(const Element* animatingElement, Element& element, const ComputedStyle& style, Compute dStyle* parentStyle, StyleResolver* resolver) | 203 void CSSAnimations::calculateUpdate(const Element* animatingElement, Element& el ement, StyleResolverState& state, StyleResolver* resolver) |
|
alancutter (OOO until 2018)
2015/08/19 02:46:30
We should avoid passing StyleResolverState around
haraken
2015/08/19 05:46:08
Done.
| |
| 204 { | 204 { |
| 205 OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = adoptPtrWillBeNoop(new CSSAn imationUpdate()); | 205 calculateAnimationUpdate(state.animationUpdate(), animatingElement, element, *state.style(), state.parentStyle(), resolver); |
| 206 calculateAnimationUpdate(update.get(), animatingElement, element, style, par entStyle, resolver); | 206 calculateAnimationActiveInterpolations(state.animationUpdate(), animatingEle ment, element.document().timeline().currentTimeInternal()); |
| 207 calculateAnimationActiveInterpolations(update.get(), animatingElement, eleme nt.document().timeline().currentTimeInternal()); | 207 calculateTransitionUpdate(state.animationUpdate(), animatingElement, *state. style()); |
| 208 calculateTransitionUpdate(update.get(), animatingElement, style); | 208 calculateTransitionActiveInterpolations(state.animationUpdate(), animatingEl ement, element.document().timeline().currentTimeInternal()); |
| 209 calculateTransitionActiveInterpolations(update.get(), animatingElement, elem ent.document().timeline().currentTimeInternal()); | |
| 210 return update->isEmpty() ? nullptr : update.release(); | |
| 211 } | 209 } |
| 212 | 210 |
| 213 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E lement* animatingElement, Element& element, const ComputedStyle& style, Computed Style* parentStyle, StyleResolver* resolver) | 211 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate& update, const E lement* animatingElement, Element& element, const ComputedStyle& style, Computed Style* parentStyle, StyleResolver* resolver) |
| 214 { | 212 { |
| 215 const ElementAnimations* elementAnimations = animatingElement ? animatingEle ment->elementAnimations() : nullptr; | 213 const ElementAnimations* elementAnimations = animatingElement ? animatingEle ment->elementAnimations() : nullptr; |
| 216 | 214 |
| 217 bool isAnimationStyleChange = elementAnimations && elementAnimations->isAnim ationStyleChange(); | 215 bool isAnimationStyleChange = elementAnimations && elementAnimations->isAnim ationStyleChange(); |
| 218 | 216 |
| 219 #if !ENABLE(ASSERT) | 217 #if !ENABLE(ASSERT) |
| 220 // If we're in an animation style change, no animations can have started, be en cancelled or changed play state. | 218 // If we're in an animation style change, no animations can have started, be en cancelled or changed play state. |
| 221 // When ASSERT is enabled, we verify this optimization. | 219 // When ASSERT is enabled, we verify this optimization. |
| 222 if (isAnimationStyleChange) | 220 if (isAnimationStyleChange) |
| 223 return; | 221 return; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 253 if (cssAnimations) { | 251 if (cssAnimations) { |
| 254 AnimationMap::const_iterator existing(cssAnimations->m_animation s.find(animationName)); | 252 AnimationMap::const_iterator existing(cssAnimations->m_animation s.find(animationName)); |
| 255 if (existing != cssAnimations->m_animations.end()) { | 253 if (existing != cssAnimations->m_animations.end()) { |
| 256 inactive.remove(animationName); | 254 inactive.remove(animationName); |
| 257 | 255 |
| 258 const RunningAnimation* runningAnimation = existing->value.g et(); | 256 const RunningAnimation* runningAnimation = existing->value.g et(); |
| 259 Animation* animation = runningAnimation->animation.get(); | 257 Animation* animation = runningAnimation->animation.get(); |
| 260 | 258 |
| 261 if (keyframesRule != runningAnimation->styleRule || keyframe sRule->version() != runningAnimation->styleRuleVersion || runningAnimation->spec ifiedTiming != specifiedTiming) { | 259 if (keyframesRule != runningAnimation->styleRule || keyframe sRule->version() != runningAnimation->styleRuleVersion || runningAnimation->spec ifiedTiming != specifiedTiming) { |
| 262 ASSERT(!isAnimationStyleChange); | 260 ASSERT(!isAnimationStyleChange); |
| 263 update->updateAnimation(animationName, animation, InertE ffect::create( | 261 update.updateAnimation(animationName, animation, InertEf fect::create( |
| 264 createKeyframeEffectModel(resolver, animatingElement , element, &style, parentStyle, animationName, keyframeTimingFunction.get()), | 262 createKeyframeEffectModel(resolver, animatingElement , element, &style, parentStyle, animationName, keyframeTimingFunction.get()), |
| 265 timing, isPaused, animation->unlimitedCurrentTimeInt ernal()), specifiedTiming, keyframesRule); | 263 timing, isPaused, animation->unlimitedCurrentTimeInt ernal()), specifiedTiming, keyframesRule); |
| 266 } else if (!isAnimationStyleChange && animation->effect() && animation->effect()->isAnimation()) { | 264 } else if (!isAnimationStyleChange && animation->effect() && animation->effect()->isAnimation()) { |
| 267 EffectModel* model = toKeyframeEffect(animation->effect( ))->model(); | 265 EffectModel* model = toKeyframeEffect(animation->effect( ))->model(); |
| 268 if (model && model->isKeyframeEffectModel()) { | 266 if (model && model->isKeyframeEffectModel()) { |
| 269 KeyframeEffectModelBase* keyframeEffect = toKeyframe EffectModelBase(model); | 267 KeyframeEffectModelBase* keyframeEffect = toKeyframe EffectModelBase(model); |
| 270 if (keyframeEffect->hasSyntheticKeyframes()) | 268 if (keyframeEffect->hasSyntheticKeyframes()) |
| 271 update->updateAnimationStyle(animation, keyframe Effect, animatingElement->layoutObject(), style); | 269 update.updateAnimationStyle(animation, keyframeE ffect, animatingElement->layoutObject(), style); |
| 272 } | 270 } |
| 273 } | 271 } |
| 274 | 272 |
| 275 if (isPaused != animation->paused()) { | 273 if (isPaused != animation->paused()) { |
| 276 ASSERT(!isAnimationStyleChange); | 274 ASSERT(!isAnimationStyleChange); |
| 277 update->toggleAnimationPaused(animationName); | 275 update.toggleAnimationPaused(animationName); |
| 278 } | 276 } |
| 279 | 277 |
| 280 continue; | 278 continue; |
| 281 } | 279 } |
| 282 } | 280 } |
| 283 | 281 |
| 284 ASSERT(!isAnimationStyleChange); | 282 ASSERT(!isAnimationStyleChange); |
| 285 update->startAnimation(animationName, InertEffect::create( | 283 update.startAnimation(animationName, InertEffect::create( |
| 286 createKeyframeEffectModel(resolver, animatingElement, element, & style, parentStyle, animationName, keyframeTimingFunction.get()), | 284 createKeyframeEffectModel(resolver, animatingElement, element, & style, parentStyle, animationName, keyframeTimingFunction.get()), |
| 287 timing, isPaused, 0), specifiedTiming, keyframesRule); | 285 timing, isPaused, 0), specifiedTiming, keyframesRule); |
| 288 } | 286 } |
| 289 } | 287 } |
| 290 | 288 |
| 291 ASSERT(inactive.isEmpty() || cssAnimations); | 289 ASSERT(inactive.isEmpty() || cssAnimations); |
| 292 for (const AtomicString& animationName : inactive) { | 290 for (const AtomicString& animationName : inactive) { |
| 293 ASSERT(!isAnimationStyleChange); | 291 ASSERT(!isAnimationStyleChange); |
| 294 update->cancelAnimation(animationName, *cssAnimations->m_animations.get( animationName)->animation); | 292 update.cancelAnimation(animationName, *cssAnimations->m_animations.get(a nimationName)->animation); |
| 295 } | 293 } |
| 296 } | 294 } |
| 297 | 295 |
| 298 void CSSAnimations::maybeApplyPendingUpdate(Element* element) | 296 void CSSAnimations::maybeApplyPendingUpdate(Element* element) |
| 299 { | 297 { |
| 300 if (!m_pendingUpdate) { | 298 if (m_pendingUpdate.isEmpty()) { |
| 301 m_previousActiveInterpolationsForAnimations.clear(); | 299 m_previousActiveInterpolationsForAnimations.clear(); |
| 302 return; | 300 return; |
| 303 } | 301 } |
| 304 | 302 |
| 305 OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = m_pendingUpdate.release(); | 303 m_previousActiveInterpolationsForAnimations.swap(m_pendingUpdate.activeInter polationsForAnimations()); |
| 306 | |
| 307 m_previousActiveInterpolationsForAnimations.swap(update->activeInterpolation sForAnimations()); | |
| 308 | 304 |
| 309 // FIXME: cancelling, pausing, unpausing animations all query compositingSta te, which is not necessarily up to date here | 305 // FIXME: cancelling, pausing, unpausing animations all query compositingSta te, which is not necessarily up to date here |
| 310 // since we call this from recalc style. | 306 // since we call this from recalc style. |
| 311 // https://code.google.com/p/chromium/issues/detail?id=339847 | 307 // https://code.google.com/p/chromium/issues/detail?id=339847 |
| 312 DisableCompositingQueryAsserts disabler; | 308 DisableCompositingQueryAsserts disabler; |
| 313 | 309 |
| 314 for (const AtomicString& animationName : update->cancelledAnimationNames()) { | 310 for (const AtomicString& animationName : m_pendingUpdate.cancelledAnimationN ames()) { |
| 315 RefPtrWillBeRawPtr<Animation> animation = m_animations.take(animationNam e)->animation; | 311 RefPtrWillBeRawPtr<Animation> animation = m_animations.take(animationNam e)->animation; |
| 316 animation->cancel(); | 312 animation->cancel(); |
| 317 animation->update(TimingUpdateOnDemand); | 313 animation->update(TimingUpdateOnDemand); |
| 318 } | 314 } |
| 319 | 315 |
| 320 for (const AtomicString& animationName : update->animationsWithPauseToggled( )) { | 316 for (const AtomicString& animationName : m_pendingUpdate.animationsWithPause Toggled()) { |
| 321 Animation* animation = m_animations.get(animationName)->animation.get(); | 317 Animation* animation = m_animations.get(animationName)->animation.get(); |
| 322 if (animation->paused()) | 318 if (animation->paused()) |
| 323 animation->unpause(); | 319 animation->unpause(); |
| 324 else | 320 else |
| 325 animation->pause(); | 321 animation->pause(); |
| 326 if (animation->outdated()) | 322 if (animation->outdated()) |
| 327 animation->update(TimingUpdateOnDemand); | 323 animation->update(TimingUpdateOnDemand); |
| 328 } | 324 } |
| 329 | 325 |
| 330 for (const auto& styleUpdate : update->animationsWithStyleUpdates()) { | 326 for (const auto& styleUpdate : m_pendingUpdate.animationsWithStyleUpdates()) { |
| 331 styleUpdate.model->forEachInterpolation([](Interpolation& interpolation) { | 327 styleUpdate.model->forEachInterpolation([](Interpolation& interpolation) { |
| 332 if (interpolation.isStyleInterpolation() && toStyleInterpolation(int erpolation).isDeferredLegacyStyleInterpolation()) | 328 if (interpolation.isStyleInterpolation() && toStyleInterpolation(int erpolation).isDeferredLegacyStyleInterpolation()) |
| 333 toDeferredLegacyStyleInterpolation(toStyleInterpolation(interpol ation)).underlyingStyleChanged(); | 329 toDeferredLegacyStyleInterpolation(toStyleInterpolation(interpol ation)).underlyingStyleChanged(); |
| 334 }); | 330 }); |
| 335 | 331 |
| 336 bool updated = false; | 332 bool updated = false; |
| 337 if (styleUpdate.snapshot.opacity) | 333 if (styleUpdate.snapshot.opacity) |
| 338 updated |= styleUpdate.model->updateNeutralKeyframeAnimatableValues( CSSPropertyOpacity, styleUpdate.snapshot.opacity); | 334 updated |= styleUpdate.model->updateNeutralKeyframeAnimatableValues( CSSPropertyOpacity, styleUpdate.snapshot.opacity); |
| 339 if (styleUpdate.snapshot.transform) | 335 if (styleUpdate.snapshot.transform) |
| 340 updated |= styleUpdate.model->updateNeutralKeyframeAnimatableValues( CSSPropertyTransform, styleUpdate.snapshot.transform); | 336 updated |= styleUpdate.model->updateNeutralKeyframeAnimatableValues( CSSPropertyTransform, styleUpdate.snapshot.transform); |
| 341 if (styleUpdate.snapshot.webkitFilter) | 337 if (styleUpdate.snapshot.webkitFilter) |
| 342 updated |= styleUpdate.model->updateNeutralKeyframeAnimatableValues( CSSPropertyWebkitFilter, styleUpdate.snapshot.webkitFilter); | 338 updated |= styleUpdate.model->updateNeutralKeyframeAnimatableValues( CSSPropertyWebkitFilter, styleUpdate.snapshot.webkitFilter); |
| 343 if (updated) { | 339 if (updated) { |
| 344 styleUpdate.animation->setOutdated(); | 340 styleUpdate.animation->setOutdated(); |
| 345 styleUpdate.animation->setCompositorPending(true); | 341 styleUpdate.animation->setCompositorPending(true); |
| 346 } | 342 } |
| 347 } | 343 } |
| 348 | 344 |
| 349 for (const auto& entry : update->animationsWithUpdates()) { | 345 for (const auto& entry : m_pendingUpdate.animationsWithUpdates()) { |
| 350 KeyframeEffect* effect = toKeyframeEffect(entry.animation->effect()); | 346 KeyframeEffect* effect = toKeyframeEffect(entry.animation->effect()); |
| 351 | 347 |
| 352 effect->setModel(entry.effect->model()); | 348 effect->setModel(entry.effect->model()); |
| 353 effect->updateSpecifiedTiming(entry.effect->specifiedTiming()); | 349 effect->updateSpecifiedTiming(entry.effect->specifiedTiming()); |
| 354 | 350 |
| 355 m_animations.find(entry.name)->value->update(entry); | 351 m_animations.find(entry.name)->value->update(entry); |
| 356 } | 352 } |
| 357 | 353 |
| 358 for (const auto& entry : update->newAnimations()) { | 354 for (const auto& entry : m_pendingUpdate.newAnimations()) { |
| 359 const InertEffect* inertAnimation = entry.effect.get(); | 355 const InertEffect* inertAnimation = entry.effect.get(); |
| 360 OwnPtrWillBeRawPtr<AnimationEventDelegate> eventDelegate = adoptPtrWillB eNoop(new AnimationEventDelegate(element, entry.name)); | 356 OwnPtrWillBeRawPtr<AnimationEventDelegate> eventDelegate = adoptPtrWillB eNoop(new AnimationEventDelegate(element, entry.name)); |
| 361 RefPtrWillBeRawPtr<KeyframeEffect> effect = KeyframeEffect::create(eleme nt, inertAnimation->model(), inertAnimation->specifiedTiming(), KeyframeEffect:: DefaultPriority, eventDelegate.release()); | 357 RefPtrWillBeRawPtr<KeyframeEffect> effect = KeyframeEffect::create(eleme nt, inertAnimation->model(), inertAnimation->specifiedTiming(), KeyframeEffect:: DefaultPriority, eventDelegate.release()); |
| 362 effect->setName(inertAnimation->name()); | 358 effect->setName(inertAnimation->name()); |
| 363 RefPtrWillBeRawPtr<Animation> animation = element->document().timeline() .play(effect.get()); | 359 RefPtrWillBeRawPtr<Animation> animation = element->document().timeline() .play(effect.get()); |
| 364 if (inertAnimation->paused()) | 360 if (inertAnimation->paused()) |
| 365 animation->pause(); | 361 animation->pause(); |
| 366 animation->update(TimingUpdateOnDemand); | 362 animation->update(TimingUpdateOnDemand); |
| 367 | 363 |
| 368 m_animations.set(entry.name, adoptRefWillBeNoop(new RunningAnimation(ani mation, entry))); | 364 m_animations.set(entry.name, adoptRefWillBeNoop(new RunningAnimation(ani mation, entry))); |
| 369 } | 365 } |
| 370 | 366 |
| 371 // Transitions that are run on the compositor only update main-thread state | 367 // Transitions that are run on the compositor only update main-thread state |
| 372 // lazily. However, we need the new state to know what the from state shoud | 368 // lazily. However, we need the new state to know what the from state shoud |
| 373 // be when transitions are retargeted. Instead of triggering complete style | 369 // be when transitions are retargeted. Instead of triggering complete style |
| 374 // recalculation, we find these cases by searching for new transitions that | 370 // recalculation, we find these cases by searching for new transitions that |
| 375 // have matching cancelled animation property IDs on the compositor. | 371 // have matching cancelled animation property IDs on the compositor. |
| 376 WillBeHeapHashMap<CSSPropertyID, std::pair<RefPtrWillBeMember<KeyframeEffect >, double>> retargetedCompositorTransitions; | 372 WillBeHeapHashMap<CSSPropertyID, std::pair<RefPtrWillBeMember<KeyframeEffect >, double>> retargetedCompositorTransitions; |
| 377 for (CSSPropertyID id : update->cancelledTransitions()) { | 373 for (CSSPropertyID id : m_pendingUpdate.cancelledTransitions()) { |
| 378 ASSERT(m_transitions.contains(id)); | 374 ASSERT(m_transitions.contains(id)); |
| 379 | 375 |
| 380 RefPtrWillBeRawPtr<Animation> animation = m_transitions.take(id).animati on; | 376 RefPtrWillBeRawPtr<Animation> animation = m_transitions.take(id).animati on; |
| 381 KeyframeEffect* effect = toKeyframeEffect(animation->effect()); | 377 KeyframeEffect* effect = toKeyframeEffect(animation->effect()); |
| 382 if (effect->hasActiveAnimationsOnCompositor(id) && update->newTransition s().find(id) != update->newTransitions().end() && !animation->limited()) | 378 if (effect->hasActiveAnimationsOnCompositor(id) && m_pendingUpdate.newTr ansitions().find(id) != m_pendingUpdate.newTransitions().end() && !animation->li mited()) |
| 383 retargetedCompositorTransitions.add(id, std::pair<RefPtrWillBeMember <KeyframeEffect>, double>(effect, animation->startTimeInternal())); | 379 retargetedCompositorTransitions.add(id, std::pair<RefPtrWillBeMember <KeyframeEffect>, double>(effect, animation->startTimeInternal())); |
| 384 animation->cancel(); | 380 animation->cancel(); |
| 385 // after cancelation, transitions must be downgraded or they'll fail | 381 // after cancelation, transitions must be downgraded or they'll fail |
| 386 // to be considered when retriggering themselves. This can happen if | 382 // to be considered when retriggering themselves. This can happen if |
| 387 // the transition is captured through getAnimations then played. | 383 // the transition is captured through getAnimations then played. |
| 388 if (animation->effect() && animation->effect()->isAnimation()) | 384 if (animation->effect() && animation->effect()->isAnimation()) |
| 389 toKeyframeEffect(animation->effect())->downgradeToNormal(); | 385 toKeyframeEffect(animation->effect())->downgradeToNormal(); |
| 390 animation->update(TimingUpdateOnDemand); | 386 animation->update(TimingUpdateOnDemand); |
| 391 } | 387 } |
| 392 | 388 |
| 393 for (CSSPropertyID id : update->finishedTransitions()) { | 389 for (CSSPropertyID id : m_pendingUpdate.finishedTransitions()) { |
| 394 // This transition can also be cancelled and finished at the same time | 390 // This transition can also be cancelled and finished at the same time |
| 395 if (m_transitions.contains(id)) { | 391 if (m_transitions.contains(id)) { |
| 396 RefPtrWillBeRawPtr<Animation> animation = m_transitions.take(id).ani mation; | 392 RefPtrWillBeRawPtr<Animation> animation = m_transitions.take(id).ani mation; |
| 397 // Transition must be downgraded | 393 // Transition must be downgraded |
| 398 if (animation->effect() && animation->effect()->isAnimation()) | 394 if (animation->effect() && animation->effect()->isAnimation()) |
| 399 toKeyframeEffect(animation->effect())->downgradeToNormal(); | 395 toKeyframeEffect(animation->effect())->downgradeToNormal(); |
| 400 } | 396 } |
| 401 } | 397 } |
| 402 | 398 |
| 403 for (const auto& entry : update->newTransitions()) { | 399 for (const auto& entry : m_pendingUpdate.newTransitions()) { |
| 404 const CSSAnimationUpdate::NewTransition& newTransition = entry.value; | 400 const CSSAnimationUpdate::NewTransition& newTransition = entry.value; |
| 405 | 401 |
| 406 RunningTransition runningTransition; | 402 RunningTransition runningTransition; |
| 407 runningTransition.from = newTransition.from; | 403 runningTransition.from = newTransition.from; |
| 408 runningTransition.to = newTransition.to; | 404 runningTransition.to = newTransition.to; |
| 409 | 405 |
| 410 CSSPropertyID id = newTransition.id; | 406 CSSPropertyID id = newTransition.id; |
| 411 InertEffect* inertAnimation = newTransition.effect.get(); | 407 InertEffect* inertAnimation = newTransition.effect.get(); |
| 412 OwnPtrWillBeRawPtr<TransitionEventDelegate> eventDelegate = adoptPtrWill BeNoop(new TransitionEventDelegate(element, id)); | 408 OwnPtrWillBeRawPtr<TransitionEventDelegate> eventDelegate = adoptPtrWill BeNoop(new TransitionEventDelegate(element, id)); |
| 413 | 409 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 444 RefPtrWillBeRawPtr<Animation> animation = element->document().timeline() .play(transition.get()); | 440 RefPtrWillBeRawPtr<Animation> animation = element->document().timeline() .play(transition.get()); |
| 445 // Set the current time as the start time for retargeted transitions | 441 // Set the current time as the start time for retargeted transitions |
| 446 if (retargetedCompositorTransitions.contains(id)) | 442 if (retargetedCompositorTransitions.contains(id)) |
| 447 animation->setStartTime(element->document().timeline().currentTime() ); | 443 animation->setStartTime(element->document().timeline().currentTime() ); |
| 448 animation->update(TimingUpdateOnDemand); | 444 animation->update(TimingUpdateOnDemand); |
| 449 runningTransition.animation = animation; | 445 runningTransition.animation = animation; |
| 450 m_transitions.set(id, runningTransition); | 446 m_transitions.set(id, runningTransition); |
| 451 ASSERT(id != CSSPropertyInvalid); | 447 ASSERT(id != CSSPropertyInvalid); |
| 452 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); | 448 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); |
| 453 } | 449 } |
| 450 | |
| 451 clearPendingUpdate(); | |
| 454 } | 452 } |
| 455 | 453 |
| 456 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const CSSTransitionData& transitionData, size_t transitionIndex, const ComputedStyle& oldStyle, const ComputedStyle& style, const TransitionMap* activeTransitions, C SSAnimationUpdate* update, const Element* element) | 454 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const CSSTransitionData& transitionData, size_t transitionIndex, const ComputedStyle& oldStyle, const ComputedStyle& style, const TransitionMap* activeTransitions, C SSAnimationUpdate& update, const Element* element) |
| 457 { | 455 { |
| 458 RefPtrWillBeRawPtr<AnimatableValue> to = nullptr; | 456 RefPtrWillBeRawPtr<AnimatableValue> to = nullptr; |
| 459 if (activeTransitions) { | 457 if (activeTransitions) { |
| 460 TransitionMap::const_iterator activeTransitionIter = activeTransitions-> find(id); | 458 TransitionMap::const_iterator activeTransitionIter = activeTransitions-> find(id); |
| 461 if (activeTransitionIter != activeTransitions->end()) { | 459 if (activeTransitionIter != activeTransitions->end()) { |
| 462 to = CSSAnimatableValueFactory::create(id, style); | 460 to = CSSAnimatableValueFactory::create(id, style); |
| 463 const AnimatableValue* activeTo = activeTransitionIter->value.to; | 461 const AnimatableValue* activeTo = activeTransitionIter->value.to; |
| 464 if (to->equals(activeTo)) | 462 if (to->equals(activeTo)) |
| 465 return; | 463 return; |
| 466 update->cancelTransition(id); | 464 update.cancelTransition(id); |
| 467 ASSERT(!element->elementAnimations() || !element->elementAnimations( )->isAnimationStyleChange()); | 465 ASSERT(!element->elementAnimations() || !element->elementAnimations( )->isAnimationStyleChange()); |
| 468 } | 466 } |
| 469 } | 467 } |
| 470 | 468 |
| 471 if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style)) | 469 if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style)) |
| 472 return; | 470 return; |
| 473 if (!to) | 471 if (!to) |
| 474 to = CSSAnimatableValueFactory::create(id, style); | 472 to = CSSAnimatableValueFactory::create(id, style); |
| 475 | 473 |
| 476 RefPtrWillBeRawPtr<AnimatableValue> from = CSSAnimatableValueFactory::create (id, oldStyle); | 474 RefPtrWillBeRawPtr<AnimatableValue> from = CSSAnimatableValueFactory::create (id, oldStyle); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 503 startKeyframe->setEasing(timing.timingFunction.release()); | 501 startKeyframe->setEasing(timing.timingFunction.release()); |
| 504 timing.timingFunction = LinearTimingFunction::shared(); | 502 timing.timingFunction = LinearTimingFunction::shared(); |
| 505 keyframes.append(startKeyframe); | 503 keyframes.append(startKeyframe); |
| 506 | 504 |
| 507 RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKey frame::create(); | 505 RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKey frame::create(); |
| 508 endKeyframe->setPropertyValue(id, to.get()); | 506 endKeyframe->setPropertyValue(id, to.get()); |
| 509 endKeyframe->setOffset(1); | 507 endKeyframe->setOffset(1); |
| 510 keyframes.append(endKeyframe); | 508 keyframes.append(endKeyframe); |
| 511 | 509 |
| 512 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> model = AnimatableVal ueKeyframeEffectModel::create(keyframes); | 510 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> model = AnimatableVal ueKeyframeEffectModel::create(keyframes); |
| 513 update->startTransition(id, from.get(), to.get(), InertEffect::create(model, timing, false, 0)); | 511 update.startTransition(id, from.get(), to.get(), InertEffect::create(model, timing, false, 0)); |
| 514 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni mationStyleChange()); | 512 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni mationStyleChange()); |
| 515 } | 513 } |
| 516 | 514 |
| 517 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const Element* animatingElement, const ComputedStyle& style) | 515 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate& update, const Element* animatingElement, const ComputedStyle& style) |
| 518 { | 516 { |
| 519 if (!animatingElement) | 517 if (!animatingElement) |
| 520 return; | 518 return; |
| 521 | 519 |
| 522 ElementAnimations* elementAnimations = animatingElement->elementAnimations() ; | 520 ElementAnimations* elementAnimations = animatingElement->elementAnimations() ; |
| 523 const TransitionMap* activeTransitions = elementAnimations ? &elementAnimati ons->cssAnimations().m_transitions : nullptr; | 521 const TransitionMap* activeTransitions = elementAnimations ? &elementAnimati ons->cssAnimations().m_transitions : nullptr; |
| 524 const CSSTransitionData* transitionData = style.transitions(); | 522 const CSSTransitionData* transitionData = style.transitions(); |
| 525 | 523 |
| 526 #if ENABLE(ASSERT) | 524 #if ENABLE(ASSERT) |
| 527 // In debug builds we verify that it would have been safe to avoid populatin g and testing listedProperties if the style recalc is due to animation. | 525 // In debug builds we verify that it would have been safe to avoid populatin g and testing listedProperties if the style recalc is due to animation. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 556 if (!animateAll) { | 554 if (!animateAll) { |
| 557 if (CSSPropertyMetadata::isInterpolableProperty(id)) | 555 if (CSSPropertyMetadata::isInterpolableProperty(id)) |
| 558 listedProperties.set(id); | 556 listedProperties.set(id); |
| 559 else | 557 else |
| 560 continue; | 558 continue; |
| 561 } | 559 } |
| 562 | 560 |
| 563 // FIXME: We should transition if an !important property changes even when an animation is running, | 561 // FIXME: We should transition if an !important property changes even when an animation is running, |
| 564 // but this is a bit hard to do with the current applyMatchedPro perties system. | 562 // but this is a bit hard to do with the current applyMatchedPro perties system. |
| 565 PropertyHandle property = PropertyHandle(id); | 563 PropertyHandle property = PropertyHandle(id); |
| 566 if (!update->activeInterpolationsForAnimations().contains(proper ty) | 564 if (!update.activeInterpolationsForAnimations().contains(propert y) |
| 567 && (!elementAnimations || !elementAnimations->cssAnimations( ).m_previousActiveInterpolationsForAnimations.contains(property))) { | 565 && (!elementAnimations || !elementAnimations->cssAnimations( ).m_previousActiveInterpolationsForAnimations.contains(property))) { |
| 568 calculateTransitionUpdateForProperty(id, *transitionData, i, oldStyle, style, activeTransitions, update, animatingElement); | 566 calculateTransitionUpdateForProperty(id, *transitionData, i, oldStyle, style, activeTransitions, update, animatingElement); |
| 569 } | 567 } |
| 570 } | 568 } |
| 571 } | 569 } |
| 572 } | 570 } |
| 573 | 571 |
| 574 if (activeTransitions) { | 572 if (activeTransitions) { |
| 575 for (const auto& entry : *activeTransitions) { | 573 for (const auto& entry : *activeTransitions) { |
| 576 CSSPropertyID id = entry.key; | 574 CSSPropertyID id = entry.key; |
| 577 if (!anyTransitionHadTransitionAll && !animationStyleRecalc && !list edProperties.get(id)) { | 575 if (!anyTransitionHadTransitionAll && !animationStyleRecalc && !list edProperties.get(id)) { |
| 578 // TODO: Figure out why this fails on Chrome OS login page. crbu g.com/365507 | 576 // TODO: Figure out why this fails on Chrome OS login page. crbu g.com/365507 |
| 579 // ASSERT(animation.playStateInternal() == Animation::Finished | | !(elementAnimations && elementAnimations->isAnimationStyleChange())); | 577 // ASSERT(animation.playStateInternal() == Animation::Finished | | !(elementAnimations && elementAnimations->isAnimationStyleChange())); |
| 580 update->cancelTransition(id); | 578 update.cancelTransition(id); |
| 581 } else if (entry.value.animation->finishedInternal()) { | 579 } else if (entry.value.animation->finishedInternal()) { |
| 582 update->finishTransition(id); | 580 update.finishTransition(id); |
| 583 } | 581 } |
| 584 } | 582 } |
| 585 } | 583 } |
| 586 } | 584 } |
| 587 | 585 |
| 588 void CSSAnimations::cancel() | 586 void CSSAnimations::cancel() |
| 589 { | 587 { |
| 590 for (const auto& entry : m_animations) { | 588 for (const auto& entry : m_animations) { |
| 591 entry.value->animation->cancel(); | 589 entry.value->animation->cancel(); |
| 592 entry.value->animation->update(TimingUpdateOnDemand); | 590 entry.value->animation->update(TimingUpdateOnDemand); |
| 593 } | 591 } |
| 594 | 592 |
| 595 for (const auto& entry : m_transitions) { | 593 for (const auto& entry : m_transitions) { |
| 596 entry.value.animation->cancel(); | 594 entry.value.animation->cancel(); |
| 597 entry.value.animation->update(TimingUpdateOnDemand); | 595 entry.value.animation->update(TimingUpdateOnDemand); |
| 598 } | 596 } |
| 599 | 597 |
| 600 m_animations.clear(); | 598 m_animations.clear(); |
| 601 m_transitions.clear(); | 599 clearPendingUpdate(); |
| 602 m_pendingUpdate = nullptr; | |
| 603 } | 600 } |
| 604 | 601 |
| 605 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate* u pdate, const Element* animatingElement, double timelineCurrentTime) | 602 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate& u pdate, const Element* animatingElement, double timelineCurrentTime) |
| 606 { | 603 { |
| 607 ElementAnimations* elementAnimations = animatingElement ? animatingElement-> elementAnimations() : nullptr; | 604 ElementAnimations* elementAnimations = animatingElement ? animatingElement-> elementAnimations() : nullptr; |
| 608 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def aultStack() : nullptr; | 605 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def aultStack() : nullptr; |
| 609 | 606 |
| 610 if (update->newAnimations().isEmpty() && update->suppressedAnimations().isEm pty()) { | 607 if (update.newAnimations().isEmpty() && update.suppressedAnimations().isEmpt y()) { |
| 611 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack: :activeInterpolations(animationStack, 0, 0, KeyframeEffect::DefaultPriority, tim elineCurrentTime)); | 608 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack: :activeInterpolations(animationStack, 0, 0, KeyframeEffect::DefaultPriority, tim elineCurrentTime)); |
| 612 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn imations); | 609 update.adoptActiveInterpolationsForAnimations(activeInterpolationsForAni mations); |
| 613 return; | 610 return; |
| 614 } | 611 } |
| 615 | 612 |
| 616 WillBeHeapVector<RawPtrWillBeMember<InertEffect>> newEffects; | 613 WillBeHeapVector<RawPtrWillBeMember<InertEffect>> newEffects; |
| 617 for (const auto& newAnimation : update->newAnimations()) | 614 for (const auto& newAnimation : update.newAnimations()) |
| 618 newEffects.append(newAnimation.effect.get()); | 615 newEffects.append(newAnimation.effect.get()); |
| 619 for (const auto& updatedAnimation : update->animationsWithUpdates()) | 616 for (const auto& updatedAnimation : update.animationsWithUpdates()) |
| 620 newEffects.append(updatedAnimation.effect.get()); // Animations with upd ates use a temporary InertEffect for the current frame. | 617 newEffects.append(updatedAnimation.effect.get()); // Animations with upd ates use a temporary InertEffect for the current frame. |
| 621 | 618 |
| 622 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack::act iveInterpolations(animationStack, &newEffects, &update->suppressedAnimations(), KeyframeEffect::DefaultPriority, timelineCurrentTime)); | 619 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack::act iveInterpolations(animationStack, &newEffects, &update.suppressedAnimations(), K eyframeEffect::DefaultPriority, timelineCurrentTime)); |
| 623 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat ions); | 620 update.adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimati ons); |
| 624 } | 621 } |
| 625 | 622 |
| 626 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate* update, const Element* animatingElement, double timelineCurrentTime) | 623 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate& update, const Element* animatingElement, double timelineCurrentTime) |
| 627 { | 624 { |
| 628 ElementAnimations* elementAnimations = animatingElement ? animatingElement-> elementAnimations() : nullptr; | 625 ElementAnimations* elementAnimations = animatingElement ? animatingElement-> elementAnimations() : nullptr; |
| 629 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def aultStack() : nullptr; | 626 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def aultStack() : nullptr; |
| 630 | 627 |
| 631 ActiveInterpolationMap activeInterpolationsForTransitions; | 628 ActiveInterpolationMap activeInterpolationsForTransitions; |
| 632 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE mpty()) { | 629 if (update.newTransitions().isEmpty() && update.cancelledTransitions().isEmp ty()) { |
| 633 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, 0, 0, KeyframeEffect::TransitionPriority, timelineCurrentTime) ; | 630 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, 0, 0, KeyframeEffect::TransitionPriority, timelineCurrentTime) ; |
| 634 } else { | 631 } else { |
| 635 WillBeHeapVector<RawPtrWillBeMember<InertEffect>> newTransitions; | 632 WillBeHeapVector<RawPtrWillBeMember<InertEffect>> newTransitions; |
| 636 for (const auto& entry : update->newTransitions()) | 633 for (const auto& entry : update.newTransitions()) |
| 637 newTransitions.append(entry.value.effect.get()); | 634 newTransitions.append(entry.value.effect.get()); |
| 638 | 635 |
| 639 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> cancelledAnimatio ns; | 636 WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> cancelledAnimatio ns; |
| 640 if (!update->cancelledTransitions().isEmpty()) { | 637 if (!update.cancelledTransitions().isEmpty()) { |
| 641 ASSERT(elementAnimations); | 638 ASSERT(elementAnimations); |
| 642 const TransitionMap& transitionMap = elementAnimations->cssAnimation s().m_transitions; | 639 const TransitionMap& transitionMap = elementAnimations->cssAnimation s().m_transitions; |
| 643 for (CSSPropertyID id : update->cancelledTransitions()) { | 640 for (CSSPropertyID id : update.cancelledTransitions()) { |
| 644 ASSERT(transitionMap.contains(id)); | 641 ASSERT(transitionMap.contains(id)); |
| 645 cancelledAnimations.add(transitionMap.get(id).animation.get()); | 642 cancelledAnimations.add(transitionMap.get(id).animation.get()); |
| 646 } | 643 } |
| 647 } | 644 } |
| 648 | 645 |
| 649 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, &newTransitions, &cancelledAnimations, KeyframeEffect::Transit ionPriority, timelineCurrentTime); | 646 activeInterpolationsForTransitions = AnimationStack::activeInterpolation s(animationStack, &newTransitions, &cancelledAnimations, KeyframeEffect::Transit ionPriority, timelineCurrentTime); |
| 650 } | 647 } |
| 651 | 648 |
| 652 // Properties being animated by animations don't get values from transitions applied. | 649 // Properties being animated by animations don't get values from transitions applied. |
| 653 if (!update->activeInterpolationsForAnimations().isEmpty() && !activeInterpo lationsForTransitions.isEmpty()) { | 650 if (!update.activeInterpolationsForAnimations().isEmpty() && !activeInterpol ationsForTransitions.isEmpty()) { |
| 654 for (const auto& entry : update->activeInterpolationsForAnimations()) | 651 for (const auto& entry : update.activeInterpolationsForAnimations()) |
| 655 activeInterpolationsForTransitions.remove(entry.key); | 652 activeInterpolationsForTransitions.remove(entry.key); |
| 656 } | 653 } |
| 657 update->adoptActiveInterpolationsForTransitions(activeInterpolationsForTrans itions); | 654 update.adoptActiveInterpolationsForTransitions(activeInterpolationsForTransi tions); |
| 658 } | 655 } |
| 659 | 656 |
| 660 EventTarget* CSSAnimations::AnimationEventDelegate::eventTarget() const | 657 EventTarget* CSSAnimations::AnimationEventDelegate::eventTarget() const |
| 661 { | 658 { |
| 662 return EventPath::eventTargetRespectingTargetRules(*m_animationTarget); | 659 return EventPath::eventTargetRespectingTargetRules(*m_animationTarget); |
| 663 } | 660 } |
| 664 | 661 |
| 665 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType listenerType, const AtomicString& eventName, double elapsedTime) | 662 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType listenerType, const AtomicString& eventName, double elapsedTime) |
| 666 { | 663 { |
| 667 if (m_animationTarget->document().hasListenerType(listenerType)) { | 664 if (m_animationTarget->document().hasListenerType(listenerType)) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 791 DEFINE_TRACE(CSSAnimations) | 788 DEFINE_TRACE(CSSAnimations) |
| 792 { | 789 { |
| 793 #if ENABLE(OILPAN) | 790 #if ENABLE(OILPAN) |
| 794 visitor->trace(m_transitions); | 791 visitor->trace(m_transitions); |
| 795 visitor->trace(m_pendingUpdate); | 792 visitor->trace(m_pendingUpdate); |
| 796 visitor->trace(m_animations); | 793 visitor->trace(m_animations); |
| 797 visitor->trace(m_previousActiveInterpolationsForAnimations); | 794 visitor->trace(m_previousActiveInterpolationsForAnimations); |
| 798 #endif | 795 #endif |
| 799 } | 796 } |
| 800 | 797 |
| 801 DEFINE_TRACE(CSSAnimationUpdate) | |
| 802 { | |
| 803 #if ENABLE(OILPAN) | |
| 804 visitor->trace(m_newTransitions); | |
| 805 visitor->trace(m_activeInterpolationsForAnimations); | |
| 806 visitor->trace(m_activeInterpolationsForTransitions); | |
| 807 visitor->trace(m_newAnimations); | |
| 808 visitor->trace(m_suppressedAnimations); | |
| 809 visitor->trace(m_animationsWithUpdates); | |
| 810 visitor->trace(m_animationsWithStyleUpdates); | |
| 811 #endif | |
| 812 } | |
| 813 | |
| 814 } // namespace blink | 798 } // namespace blink |
| OLD | NEW |