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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 keyframes[targetIndex]->setPropertyValue(property.cssProperty(),
keyframes[i]->cssPropertyValue(property.cssProperty())); | 130 keyframes[targetIndex]->setPropertyValue(property.cssProperty(),
keyframes[i]->cssPropertyValue(property.cssProperty())); |
131 } else { | 131 } else { |
132 targetIndex++; | 132 targetIndex++; |
133 keyframes[targetIndex] = keyframes[i]; | 133 keyframes[targetIndex] = keyframes[i]; |
134 } | 134 } |
135 } | 135 } |
136 if (!keyframes.isEmpty()) | 136 if (!keyframes.isEmpty()) |
137 keyframes.shrink(targetIndex + 1); | 137 keyframes.shrink(targetIndex + 1); |
138 | 138 |
139 // Add 0% and 100% keyframes if absent. | 139 // Add 0% and 100% keyframes if absent. |
140 RefPtrWillBeRawPtr<StringKeyframe> startKeyframe = keyframes.isEmpty() ? nul
lptr : keyframes[0]; | 140 RefPtr<StringKeyframe> startKeyframe = keyframes.isEmpty() ? nullptr : keyfr
ames[0]; |
141 if (!startKeyframe || keyframes[0]->offset() != 0) { | 141 if (!startKeyframe || keyframes[0]->offset() != 0) { |
142 startKeyframe = StringKeyframe::create(); | 142 startKeyframe = StringKeyframe::create(); |
143 startKeyframe->setOffset(0); | 143 startKeyframe->setOffset(0); |
144 startKeyframe->setEasing(defaultTimingFunction); | 144 startKeyframe->setEasing(defaultTimingFunction); |
145 keyframes.prepend(startKeyframe); | 145 keyframes.prepend(startKeyframe); |
146 } | 146 } |
147 RefPtrWillBeRawPtr<StringKeyframe> endKeyframe = keyframes[keyframes.size()
- 1]; | 147 RefPtr<StringKeyframe> endKeyframe = keyframes[keyframes.size() - 1]; |
148 if (endKeyframe->offset() != 1) { | 148 if (endKeyframe->offset() != 1) { |
149 endKeyframe = StringKeyframe::create(); | 149 endKeyframe = StringKeyframe::create(); |
150 endKeyframe->setOffset(1); | 150 endKeyframe->setOffset(1); |
151 endKeyframe->setEasing(defaultTimingFunction); | 151 endKeyframe->setEasing(defaultTimingFunction); |
152 keyframes.append(endKeyframe); | 152 keyframes.append(endKeyframe); |
153 } | 153 } |
154 ASSERT(keyframes.size() >= 2); | 154 ASSERT(keyframes.size() >= 2); |
155 ASSERT(!keyframes.first()->offset()); | 155 ASSERT(!keyframes.first()->offset()); |
156 ASSERT(keyframes.last()->offset() == 1); | 156 ASSERT(keyframes.last()->offset() == 1); |
157 | 157 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 const KeyframeVector& frames = oldEffect->getFrames(); | 427 const KeyframeVector& frames = oldEffect->getFrames(); |
428 | 428 |
429 AnimatableValueKeyframeVector newFrames; | 429 AnimatableValueKeyframeVector newFrames; |
430 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get())
); | 430 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get())
); |
431 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get())
); | 431 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get())
); |
432 newFrames.append(toAnimatableValueKeyframe(frames[2]->clone().get())
); | 432 newFrames.append(toAnimatableValueKeyframe(frames[2]->clone().get())
); |
433 newFrames[0]->clearPropertyValue(id); | 433 newFrames[0]->clearPropertyValue(id); |
434 newFrames[1]->clearPropertyValue(id); | 434 newFrames[1]->clearPropertyValue(id); |
435 | 435 |
436 InertEffect* inertAnimationForSampling = InertEffect::create(oldAnim
ation->model(), oldAnimation->specifiedTiming(), false, inheritedTime); | 436 InertEffect* inertAnimationForSampling = InertEffect::create(oldAnim
ation->model(), oldAnimation->specifiedTiming(), false, inheritedTime); |
437 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation
>>> sample = nullptr; | 437 OwnPtr<Vector<RefPtr<Interpolation>>> sample = nullptr; |
438 inertAnimationForSampling->sample(sample); | 438 inertAnimationForSampling->sample(sample); |
439 if (sample && sample->size() == 1) { | 439 if (sample && sample->size() == 1) { |
440 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sa
mple->at(0).get())->currentValue()); | 440 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sa
mple->at(0).get())->currentValue()); |
441 newFrames[1]->setPropertyValue(id, toLegacyStyleInterpolation(sa
mple->at(0).get())->currentValue()); | 441 newFrames[1]->setPropertyValue(id, toLegacyStyleInterpolation(sa
mple->at(0).get())->currentValue()); |
442 model = AnimatableValueKeyframeEffectModel::create(newFrames); | 442 model = AnimatableValueKeyframeEffectModel::create(newFrames); |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 KeyframeEffect* transition = KeyframeEffect::create(element, model, iner
tAnimation->specifiedTiming(), KeyframeEffect::TransitionPriority, eventDelegate
); | 446 KeyframeEffect* transition = KeyframeEffect::create(element, model, iner
tAnimation->specifiedTiming(), KeyframeEffect::TransitionPriority, eventDelegate
); |
447 transition->setName(inertAnimation->name()); | 447 transition->setName(inertAnimation->name()); |
448 Animation* animation = element->document().timeline().play(transition); | 448 Animation* animation = element->document().timeline().play(transition); |
449 // Set the current time as the start time for retargeted transitions | 449 // Set the current time as the start time for retargeted transitions |
450 if (retargetedCompositorTransitions.contains(id)) | 450 if (retargetedCompositorTransitions.contains(id)) |
451 animation->setStartTime(element->document().timeline().currentTime()
); | 451 animation->setStartTime(element->document().timeline().currentTime()
); |
452 animation->update(TimingUpdateOnDemand); | 452 animation->update(TimingUpdateOnDemand); |
453 runningTransition.animation = animation; | 453 runningTransition.animation = animation; |
454 m_transitions.set(id, runningTransition); | 454 m_transitions.set(id, runningTransition); |
455 ASSERT(id != CSSPropertyInvalid); | 455 ASSERT(id != CSSPropertyInvalid); |
456 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties",
UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); | 456 Platform::current()->histogramSparse("WebCore.Animation.CSSProperties",
UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); |
457 } | 457 } |
458 | |
459 clearPendingUpdate(); | 458 clearPendingUpdate(); |
460 } | 459 } |
461 | 460 |
462 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) | 461 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) |
463 { | 462 { |
464 RefPtrWillBeRawPtr<AnimatableValue> to = nullptr; | 463 RefPtr<AnimatableValue> to = nullptr; |
465 if (activeTransitions) { | 464 if (activeTransitions) { |
466 TransitionMap::const_iterator activeTransitionIter = activeTransitions->
find(id); | 465 TransitionMap::const_iterator activeTransitionIter = activeTransitions->
find(id); |
467 if (activeTransitionIter != activeTransitions->end()) { | 466 if (activeTransitionIter != activeTransitions->end()) { |
468 to = CSSAnimatableValueFactory::create(id, style); | 467 to = CSSAnimatableValueFactory::create(id, style); |
469 const AnimatableValue* activeTo = activeTransitionIter->value.to; | 468 const AnimatableValue* activeTo = activeTransitionIter->value.to; |
470 if (to->equals(activeTo)) | 469 if (to->equals(activeTo)) |
471 return; | 470 return; |
472 update.cancelTransition(id); | 471 update.cancelTransition(id); |
473 ASSERT(!element->elementAnimations() || !element->elementAnimations(
)->isAnimationStyleChange()); | 472 ASSERT(!element->elementAnimations() || !element->elementAnimations(
)->isAnimationStyleChange()); |
474 } | 473 } |
475 } | 474 } |
476 | 475 |
477 if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style)) | 476 if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style)) |
478 return; | 477 return; |
479 if (!to) | 478 if (!to) |
480 to = CSSAnimatableValueFactory::create(id, style); | 479 to = CSSAnimatableValueFactory::create(id, style); |
481 | 480 |
482 RefPtrWillBeRawPtr<AnimatableValue> from = CSSAnimatableValueFactory::create
(id, oldStyle); | 481 RefPtr<AnimatableValue> from = CSSAnimatableValueFactory::create(id, oldStyl
e); |
483 // If we have multiple transitions on the same property, we will use the | 482 // If we have multiple transitions on the same property, we will use the |
484 // last one since we iterate over them in order. | 483 // last one since we iterate over them in order. |
485 if (AnimatableValue::usesDefaultInterpolation(to.get(), from.get())) | 484 if (AnimatableValue::usesDefaultInterpolation(to.get(), from.get())) |
486 return; | 485 return; |
487 | 486 |
488 Timing timing = transitionData.convertToTiming(transitionIndex); | 487 Timing timing = transitionData.convertToTiming(transitionIndex); |
489 if (timing.startDelay + timing.iterationDuration <= 0) | 488 if (timing.startDelay + timing.iterationDuration <= 0) |
490 return; | 489 return; |
491 | 490 |
492 AnimatableValueKeyframeVector keyframes; | 491 AnimatableValueKeyframeVector keyframes; |
493 double startKeyframeOffset = 0; | 492 double startKeyframeOffset = 0; |
494 | 493 |
495 if (timing.startDelay > 0) { | 494 if (timing.startDelay > 0) { |
496 timing.iterationDuration += timing.startDelay; | 495 timing.iterationDuration += timing.startDelay; |
497 startKeyframeOffset = timing.startDelay / timing.iterationDuration; | 496 startKeyframeOffset = timing.startDelay / timing.iterationDuration; |
498 timing.startDelay = 0; | 497 timing.startDelay = 0; |
499 } | 498 } |
500 | 499 |
501 RefPtrWillBeRawPtr<AnimatableValueKeyframe> delayKeyframe = AnimatableValueK
eyframe::create(); | 500 RefPtr<AnimatableValueKeyframe> delayKeyframe = AnimatableValueKeyframe::cre
ate(); |
502 delayKeyframe->setPropertyValue(id, from.get()); | 501 delayKeyframe->setPropertyValue(id, from.get()); |
503 delayKeyframe->setOffset(0); | 502 delayKeyframe->setOffset(0); |
504 keyframes.append(delayKeyframe); | 503 keyframes.append(delayKeyframe); |
505 | 504 |
506 RefPtrWillBeRawPtr<AnimatableValueKeyframe> startKeyframe = AnimatableValueK
eyframe::create(); | 505 RefPtr<AnimatableValueKeyframe> startKeyframe = AnimatableValueKeyframe::cre
ate(); |
507 startKeyframe->setPropertyValue(id, from.get()); | 506 startKeyframe->setPropertyValue(id, from.get()); |
508 startKeyframe->setOffset(startKeyframeOffset); | 507 startKeyframe->setOffset(startKeyframeOffset); |
509 startKeyframe->setEasing(timing.timingFunction.release()); | 508 startKeyframe->setEasing(timing.timingFunction.release()); |
510 timing.timingFunction = LinearTimingFunction::shared(); | 509 timing.timingFunction = LinearTimingFunction::shared(); |
511 keyframes.append(startKeyframe); | 510 keyframes.append(startKeyframe); |
512 | 511 |
513 RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKey
frame::create(); | 512 RefPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKeyframe::creat
e(); |
514 endKeyframe->setPropertyValue(id, to.get()); | 513 endKeyframe->setPropertyValue(id, to.get()); |
515 endKeyframe->setOffset(1); | 514 endKeyframe->setOffset(1); |
516 keyframes.append(endKeyframe); | 515 keyframes.append(endKeyframe); |
517 | 516 |
518 AnimatableValueKeyframeEffectModel* model = AnimatableValueKeyframeEffectMod
el::create(keyframes); | 517 AnimatableValueKeyframeEffectModel* model = AnimatableValueKeyframeEffectMod
el::create(keyframes); |
519 update.startTransition(id, from.get(), to.get(), InertEffect::create(model,
timing, false, 0)); | 518 update.startTransition(id, from.get(), to.get(), InertEffect::create(model,
timing, false, 0)); |
520 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni
mationStyleChange()); | 519 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni
mationStyleChange()); |
521 } | 520 } |
522 | 521 |
523 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate& update, const
Element* animatingElement, const ComputedStyle& style) | 522 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate& update, const
Element* animatingElement, const ComputedStyle& style) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 entry.value->animation->cancel(); | 595 entry.value->animation->cancel(); |
597 entry.value->animation->update(TimingUpdateOnDemand); | 596 entry.value->animation->update(TimingUpdateOnDemand); |
598 } | 597 } |
599 | 598 |
600 for (const auto& entry : m_transitions) { | 599 for (const auto& entry : m_transitions) { |
601 entry.value.animation->cancel(); | 600 entry.value.animation->cancel(); |
602 entry.value.animation->update(TimingUpdateOnDemand); | 601 entry.value.animation->update(TimingUpdateOnDemand); |
603 } | 602 } |
604 | 603 |
605 m_animations.clear(); | 604 m_animations.clear(); |
| 605 m_transitions.clear(); |
606 clearPendingUpdate(); | 606 clearPendingUpdate(); |
607 } | 607 } |
608 | 608 |
609 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate& u
pdate, const Element* animatingElement, double timelineCurrentTime) | 609 void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate& u
pdate, const Element* animatingElement, double timelineCurrentTime) |
610 { | 610 { |
611 ElementAnimations* elementAnimations = animatingElement ? animatingElement->
elementAnimations() : nullptr; | 611 ElementAnimations* elementAnimations = animatingElement ? animatingElement->
elementAnimations() : nullptr; |
612 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def
aultStack() : nullptr; | 612 AnimationStack* animationStack = elementAnimations ? &elementAnimations->def
aultStack() : nullptr; |
613 | 613 |
614 if (update.newAnimations().isEmpty() && update.suppressedAnimations().isEmpt
y()) { | 614 if (update.newAnimations().isEmpty() && update.suppressedAnimations().isEmpt
y()) { |
615 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack:
:activeInterpolations(animationStack, 0, 0, KeyframeEffect::DefaultPriority, tim
elineCurrentTime)); | 615 ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack:
:activeInterpolations(animationStack, 0, 0, KeyframeEffect::DefaultPriority, tim
elineCurrentTime)); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 default: | 790 default: |
791 return true; | 791 return true; |
792 } | 792 } |
793 } | 793 } |
794 | 794 |
795 DEFINE_TRACE(CSSAnimations) | 795 DEFINE_TRACE(CSSAnimations) |
796 { | 796 { |
797 visitor->trace(m_transitions); | 797 visitor->trace(m_transitions); |
798 visitor->trace(m_pendingUpdate); | 798 visitor->trace(m_pendingUpdate); |
799 visitor->trace(m_animations); | 799 visitor->trace(m_animations); |
800 #if ENABLE(OILPAN) | |
801 visitor->trace(m_previousActiveInterpolationsForAnimations); | |
802 #endif | |
803 } | 800 } |
804 | 801 |
805 } // namespace blink | 802 } // namespace blink |
OLD | NEW |