| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen
tForScoping, name); | 72 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen
tForScoping, name); |
| 73 ASSERT(keyframesRule); | 73 ASSERT(keyframesRule); |
| 74 | 74 |
| 75 StringKeyframeVector keyframes; | 75 StringKeyframeVector keyframes; |
| 76 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe
s = keyframesRule->keyframes(); | 76 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe
s = keyframesRule->keyframes(); |
| 77 | 77 |
| 78 // Construct and populate the style for each keyframe | 78 // Construct and populate the style for each keyframe |
| 79 PropertySet specifiedPropertiesForUseCounter; | 79 PropertySet specifiedPropertiesForUseCounter; |
| 80 for (size_t i = 0; i < styleKeyframes.size(); ++i) { | 80 for (size_t i = 0; i < styleKeyframes.size(); ++i) { |
| 81 const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get(); | 81 const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get(); |
| 82 RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create(); | 82 RefPtr<StringKeyframe> keyframe = StringKeyframe::create(); |
| 83 const Vector<double>& offsets = styleKeyframe->keys(); | 83 const Vector<double>& offsets = styleKeyframe->keys(); |
| 84 ASSERT(!offsets.isEmpty()); | 84 ASSERT(!offsets.isEmpty()); |
| 85 keyframe->setOffset(offsets[0]); | 85 keyframe->setOffset(offsets[0]); |
| 86 keyframe->setEasing(defaultTimingFunction); | 86 keyframe->setEasing(defaultTimingFunction); |
| 87 const StylePropertySet& properties = styleKeyframe->properties(); | 87 const StylePropertySet& properties = styleKeyframe->properties(); |
| 88 for (unsigned j = 0; j < properties.propertyCount(); j++) { | 88 for (unsigned j = 0; j < properties.propertyCount(); j++) { |
| 89 CSSPropertyID property = properties.propertyAt(j).id(); | 89 CSSPropertyID property = properties.propertyAt(j).id(); |
| 90 specifiedPropertiesForUseCounter.add(property); | 90 specifiedPropertiesForUseCounter.add(property); |
| 91 if (property == CSSPropertyAnimationTimingFunction) { | 91 if (property == CSSPropertyAnimationTimingFunction) { |
| 92 CSSValue* value = properties.propertyAt(j).value(); | 92 CSSValue* value = properties.propertyAt(j).value(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 keyframes[targetIndex]->setPropertyValue(property.cssProperty(),
keyframes[i]->cssPropertyValue(property.cssProperty())); | 125 keyframes[targetIndex]->setPropertyValue(property.cssProperty(),
keyframes[i]->cssPropertyValue(property.cssProperty())); |
| 126 } else { | 126 } else { |
| 127 targetIndex++; | 127 targetIndex++; |
| 128 keyframes[targetIndex] = keyframes[i]; | 128 keyframes[targetIndex] = keyframes[i]; |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 if (!keyframes.isEmpty()) | 131 if (!keyframes.isEmpty()) |
| 132 keyframes.shrink(targetIndex + 1); | 132 keyframes.shrink(targetIndex + 1); |
| 133 | 133 |
| 134 // Add 0% and 100% keyframes if absent. | 134 // Add 0% and 100% keyframes if absent. |
| 135 RefPtrWillBeRawPtr<StringKeyframe> startKeyframe = keyframes.isEmpty() ? nul
lptr : keyframes[0]; | 135 RefPtr<StringKeyframe> startKeyframe = keyframes.isEmpty() ? nullptr : keyfr
ames[0]; |
| 136 if (!startKeyframe || keyframes[0]->offset() != 0) { | 136 if (!startKeyframe || keyframes[0]->offset() != 0) { |
| 137 startKeyframe = StringKeyframe::create(); | 137 startKeyframe = StringKeyframe::create(); |
| 138 startKeyframe->setOffset(0); | 138 startKeyframe->setOffset(0); |
| 139 startKeyframe->setEasing(defaultTimingFunction); | 139 startKeyframe->setEasing(defaultTimingFunction); |
| 140 keyframes.prepend(startKeyframe); | 140 keyframes.prepend(startKeyframe); |
| 141 } | 141 } |
| 142 RefPtrWillBeRawPtr<StringKeyframe> endKeyframe = keyframes[keyframes.size()
- 1]; | 142 RefPtr<StringKeyframe> endKeyframe = keyframes[keyframes.size() - 1]; |
| 143 if (endKeyframe->offset() != 1) { | 143 if (endKeyframe->offset() != 1) { |
| 144 endKeyframe = StringKeyframe::create(); | 144 endKeyframe = StringKeyframe::create(); |
| 145 endKeyframe->setOffset(1); | 145 endKeyframe->setOffset(1); |
| 146 endKeyframe->setEasing(defaultTimingFunction); | 146 endKeyframe->setEasing(defaultTimingFunction); |
| 147 keyframes.append(endKeyframe); | 147 keyframes.append(endKeyframe); |
| 148 } | 148 } |
| 149 ASSERT(keyframes.size() >= 2); | 149 ASSERT(keyframes.size() >= 2); |
| 150 ASSERT(!keyframes.first()->offset()); | 150 ASSERT(!keyframes.first()->offset()); |
| 151 ASSERT(keyframes.last()->offset() == 1); | 151 ASSERT(keyframes.last()->offset() == 1); |
| 152 | 152 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 RefPtrWillBeRawPtr<Animation> animation = element->document().timeline()
.play(transition.get()); | 441 RefPtrWillBeRawPtr<Animation> animation = element->document().timeline()
.play(transition.get()); |
| 442 // Set the current time as the start time for retargeted transitions | 442 // Set the current time as the start time for retargeted transitions |
| 443 if (retargetedCompositorTransitions.contains(id)) | 443 if (retargetedCompositorTransitions.contains(id)) |
| 444 animation->setStartTime(element->document().timeline().currentTime()
); | 444 animation->setStartTime(element->document().timeline().currentTime()
); |
| 445 animation->update(TimingUpdateOnDemand); | 445 animation->update(TimingUpdateOnDemand); |
| 446 runningTransition.animation = animation; | 446 runningTransition.animation = animation; |
| 447 m_transitions.set(id, runningTransition); | 447 m_transitions.set(id, runningTransition); |
| 448 ASSERT(id != CSSPropertyInvalid); | 448 ASSERT(id != CSSPropertyInvalid); |
| 449 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties",
UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); | 449 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties",
UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); |
| 450 } | 450 } |
| 451 | |
| 452 clearPendingUpdate(); | 451 clearPendingUpdate(); |
| 453 } | 452 } |
| 454 | 453 |
| 455 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) |
| 456 { | 455 { |
| 457 RefPtrWillBeRawPtr<AnimatableValue> to = nullptr; | 456 RefPtr<AnimatableValue> to = nullptr; |
| 458 if (activeTransitions) { | 457 if (activeTransitions) { |
| 459 TransitionMap::const_iterator activeTransitionIter = activeTransitions->
find(id); | 458 TransitionMap::const_iterator activeTransitionIter = activeTransitions->
find(id); |
| 460 if (activeTransitionIter != activeTransitions->end()) { | 459 if (activeTransitionIter != activeTransitions->end()) { |
| 461 to = CSSAnimatableValueFactory::create(id, style); | 460 to = CSSAnimatableValueFactory::create(id, style); |
| 462 const AnimatableValue* activeTo = activeTransitionIter->value.to; | 461 const AnimatableValue* activeTo = activeTransitionIter->value.to; |
| 463 if (to->equals(activeTo)) | 462 if (to->equals(activeTo)) |
| 464 return; | 463 return; |
| 465 update.cancelTransition(id); | 464 update.cancelTransition(id); |
| 466 ASSERT(!element->elementAnimations() || !element->elementAnimations(
)->isAnimationStyleChange()); | 465 ASSERT(!element->elementAnimations() || !element->elementAnimations(
)->isAnimationStyleChange()); |
| 467 } | 466 } |
| 468 } | 467 } |
| 469 | 468 |
| 470 if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style)) | 469 if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style)) |
| 471 return; | 470 return; |
| 472 if (!to) | 471 if (!to) |
| 473 to = CSSAnimatableValueFactory::create(id, style); | 472 to = CSSAnimatableValueFactory::create(id, style); |
| 474 | 473 |
| 475 RefPtrWillBeRawPtr<AnimatableValue> from = CSSAnimatableValueFactory::create
(id, oldStyle); | 474 RefPtr<AnimatableValue> from = CSSAnimatableValueFactory::create(id, oldStyl
e); |
| 476 // If we have multiple transitions on the same property, we will use the | 475 // If we have multiple transitions on the same property, we will use the |
| 477 // last one since we iterate over them in order. | 476 // last one since we iterate over them in order. |
| 478 if (AnimatableValue::usesDefaultInterpolation(to.get(), from.get())) | 477 if (AnimatableValue::usesDefaultInterpolation(to.get(), from.get())) |
| 479 return; | 478 return; |
| 480 | 479 |
| 481 Timing timing = transitionData.convertToTiming(transitionIndex); | 480 Timing timing = transitionData.convertToTiming(transitionIndex); |
| 482 if (timing.startDelay + timing.iterationDuration <= 0) | 481 if (timing.startDelay + timing.iterationDuration <= 0) |
| 483 return; | 482 return; |
| 484 | 483 |
| 485 AnimatableValueKeyframeVector keyframes; | 484 AnimatableValueKeyframeVector keyframes; |
| 486 double startKeyframeOffset = 0; | 485 double startKeyframeOffset = 0; |
| 487 | 486 |
| 488 if (timing.startDelay > 0) { | 487 if (timing.startDelay > 0) { |
| 489 timing.iterationDuration += timing.startDelay; | 488 timing.iterationDuration += timing.startDelay; |
| 490 startKeyframeOffset = timing.startDelay / timing.iterationDuration; | 489 startKeyframeOffset = timing.startDelay / timing.iterationDuration; |
| 491 timing.startDelay = 0; | 490 timing.startDelay = 0; |
| 492 } | 491 } |
| 493 | 492 |
| 494 RefPtrWillBeRawPtr<AnimatableValueKeyframe> delayKeyframe = AnimatableValueK
eyframe::create(); | 493 RefPtr<AnimatableValueKeyframe> delayKeyframe = AnimatableValueKeyframe::cre
ate(); |
| 495 delayKeyframe->setPropertyValue(id, from.get()); | 494 delayKeyframe->setPropertyValue(id, from.get()); |
| 496 delayKeyframe->setOffset(0); | 495 delayKeyframe->setOffset(0); |
| 497 keyframes.append(delayKeyframe); | 496 keyframes.append(delayKeyframe); |
| 498 | 497 |
| 499 RefPtrWillBeRawPtr<AnimatableValueKeyframe> startKeyframe = AnimatableValueK
eyframe::create(); | 498 RefPtr<AnimatableValueKeyframe> startKeyframe = AnimatableValueKeyframe::cre
ate(); |
| 500 startKeyframe->setPropertyValue(id, from.get()); | 499 startKeyframe->setPropertyValue(id, from.get()); |
| 501 startKeyframe->setOffset(startKeyframeOffset); | 500 startKeyframe->setOffset(startKeyframeOffset); |
| 502 startKeyframe->setEasing(timing.timingFunction.release()); | 501 startKeyframe->setEasing(timing.timingFunction.release()); |
| 503 timing.timingFunction = LinearTimingFunction::shared(); | 502 timing.timingFunction = LinearTimingFunction::shared(); |
| 504 keyframes.append(startKeyframe); | 503 keyframes.append(startKeyframe); |
| 505 | 504 |
| 506 RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKey
frame::create(); | 505 RefPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKeyframe::creat
e(); |
| 507 endKeyframe->setPropertyValue(id, to.get()); | 506 endKeyframe->setPropertyValue(id, to.get()); |
| 508 endKeyframe->setOffset(1); | 507 endKeyframe->setOffset(1); |
| 509 keyframes.append(endKeyframe); | 508 keyframes.append(endKeyframe); |
| 510 | 509 |
| 511 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> model = AnimatableVal
ueKeyframeEffectModel::create(keyframes); | 510 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> model = AnimatableVal
ueKeyframeEffectModel::create(keyframes); |
| 512 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)); |
| 513 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni
mationStyleChange()); | 512 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni
mationStyleChange()); |
| 514 } | 513 } |
| 515 | 514 |
| 516 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate& update, const
Element* animatingElement, const ComputedStyle& style) | 515 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate& update, const
Element* animatingElement, const ComputedStyle& style) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 entry.value->animation->cancel(); | 588 entry.value->animation->cancel(); |
| 590 entry.value->animation->update(TimingUpdateOnDemand); | 589 entry.value->animation->update(TimingUpdateOnDemand); |
| 591 } | 590 } |
| 592 | 591 |
| 593 for (const auto& entry : m_transitions) { | 592 for (const auto& entry : m_transitions) { |
| 594 entry.value.animation->cancel(); | 593 entry.value.animation->cancel(); |
| 595 entry.value.animation->update(TimingUpdateOnDemand); | 594 entry.value.animation->update(TimingUpdateOnDemand); |
| 596 } | 595 } |
| 597 | 596 |
| 598 m_animations.clear(); | 597 m_animations.clear(); |
| 598 m_transitions.clear(); |
| 599 clearPendingUpdate(); | 599 clearPendingUpdate(); |
| 600 } | 600 } |
| 601 | 601 |
| 602 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate& u
pdate, const Element* animatingElement, double timelineCurrentTime) | 602 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate& u
pdate, const Element* animatingElement, double timelineCurrentTime) |
| 603 { | 603 { |
| 604 ElementAnimations* elementAnimations = animatingElement ? animatingElement->
elementAnimations() : nullptr; | 604 ElementAnimations* elementAnimations = animatingElement ? animatingElement->
elementAnimations() : nullptr; |
| 605 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def
aultStack() : nullptr; | 605 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def
aultStack() : nullptr; |
| 606 | 606 |
| 607 if (update.newAnimations().isEmpty() && update.suppressedAnimations().isEmpt
y()) { | 607 if (update.newAnimations().isEmpty() && update.suppressedAnimations().isEmpt
y()) { |
| 608 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack:
:activeInterpolations(animationStack, 0, 0, KeyframeEffect::DefaultPriority, tim
elineCurrentTime)); | 608 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack:
:activeInterpolations(animationStack, 0, 0, KeyframeEffect::DefaultPriority, tim
elineCurrentTime)); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 { | 789 { |
| 790 #if ENABLE(OILPAN) | 790 #if ENABLE(OILPAN) |
| 791 visitor->trace(m_transitions); | 791 visitor->trace(m_transitions); |
| 792 visitor->trace(m_pendingUpdate); | 792 visitor->trace(m_pendingUpdate); |
| 793 visitor->trace(m_animations); | 793 visitor->trace(m_animations); |
| 794 visitor->trace(m_previousActiveInterpolationsForAnimations); | 794 visitor->trace(m_previousActiveInterpolationsForAnimations); |
| 795 #endif | 795 #endif |
| 796 } | 796 } |
| 797 | 797 |
| 798 } // namespace blink | 798 } // namespace blink |
| OLD | NEW |