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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 // applyMatchedProperties system. | 638 // applyMatchedProperties system. |
639 if (state.update.ActiveInterpolationsForAnimations().Contains(property) || | 639 if (state.update.ActiveInterpolationsForAnimations().Contains(property) || |
640 (state.animating_element->GetElementAnimations() && | 640 (state.animating_element->GetElementAnimations() && |
641 state.animating_element->GetElementAnimations() | 641 state.animating_element->GetElementAnimations() |
642 ->CssAnimations() | 642 ->CssAnimations() |
643 .previous_active_interpolations_for_animations_.Contains( | 643 .previous_active_interpolations_for_animations_.Contains( |
644 property))) { | 644 property))) { |
645 return; | 645 return; |
646 } | 646 } |
647 | 647 |
648 RefPtr<AnimatableValue> to = nullptr; | |
649 const RunningTransition* interrupted_transition = nullptr; | 648 const RunningTransition* interrupted_transition = nullptr; |
650 if (state.active_transitions) { | 649 if (state.active_transitions) { |
651 TransitionMap::const_iterator active_transition_iter = | 650 TransitionMap::const_iterator active_transition_iter = |
652 state.active_transitions->find(property); | 651 state.active_transitions->find(property); |
653 if (active_transition_iter != state.active_transitions->end()) { | 652 if (active_transition_iter != state.active_transitions->end()) { |
654 const RunningTransition* running_transition = | 653 const RunningTransition* running_transition = |
655 &active_transition_iter->value; | 654 &active_transition_iter->value; |
656 to = CSSAnimatableValueFactory::Create(property, state.style); | 655 if (CSSPropertyEquality::PropertiesEqual(property, state.style, |
657 const AnimatableValue* active_to = running_transition->to.Get(); | 656 *running_transition->to)) { |
658 if (to->Equals(active_to)) | |
659 return; | 657 return; |
658 } | |
660 state.update.CancelTransition(property); | 659 state.update.CancelTransition(property); |
661 DCHECK(!state.animating_element->GetElementAnimations() || | 660 DCHECK(!state.animating_element->GetElementAnimations() || |
662 !state.animating_element->GetElementAnimations() | 661 !state.animating_element->GetElementAnimations() |
663 ->IsAnimationStyleChange()); | 662 ->IsAnimationStyleChange()); |
664 | 663 |
665 if (to->Equals( | 664 if (CSSPropertyEquality::PropertiesEqual( |
666 running_transition->reversing_adjusted_start_value.Get())) { | 665 property, state.style, |
666 *running_transition->reversing_adjusted_start_value)) { | |
667 interrupted_transition = running_transition; | 667 interrupted_transition = running_transition; |
668 } | 668 } |
669 } | 669 } |
670 } | 670 } |
671 | 671 |
672 const PropertyRegistry* registry = | 672 const PropertyRegistry* registry = |
673 state.animating_element->GetDocument().GetPropertyRegistry(); | 673 state.animating_element->GetDocument().GetPropertyRegistry(); |
674 | |
675 if (property.IsCSSCustomProperty()) { | 674 if (property.IsCSSCustomProperty()) { |
676 if (!registry || !registry->Registration(property.CustomPropertyName()) || | 675 if (!registry || !registry->Registration(property.CustomPropertyName())) { |
677 CSSPropertyEquality::RegisteredCustomPropertiesEqual( | |
678 property.CustomPropertyName(), state.old_style, state.style)) { | |
679 return; | 676 return; |
680 } | 677 } |
681 } else if (CSSPropertyEquality::PropertiesEqual( | 678 } |
682 property.CssProperty(), state.old_style, state.style)) { | 679 |
680 if (CSSPropertyEquality::PropertiesEqual(property, state.old_style, | |
681 state.style)) { | |
683 return; | 682 return; |
684 } | 683 } |
685 | 684 |
686 if (!to) | |
687 to = CSSAnimatableValueFactory::Create(property, state.style); | |
688 RefPtr<AnimatableValue> from = | |
689 CSSAnimatableValueFactory::Create(property, state.old_style); | |
690 | |
691 CSSInterpolationTypesMap map(registry); | 685 CSSInterpolationTypesMap map(registry); |
692 InterpolationEnvironment old_environment(map, state.old_style); | 686 InterpolationEnvironment old_environment(map, state.old_style); |
693 InterpolationEnvironment new_environment(map, state.style); | 687 InterpolationEnvironment new_environment(map, state.style); |
694 InterpolationValue start = nullptr; | 688 InterpolationValue start = nullptr; |
695 InterpolationValue end = nullptr; | 689 InterpolationValue end = nullptr; |
696 const InterpolationType* transition_type = nullptr; | 690 const InterpolationType* transition_type = nullptr; |
697 for (const auto& interpolation_type : map.Get(property)) { | 691 for (const auto& interpolation_type : map.Get(property)) { |
698 start = interpolation_type->MaybeConvertUnderlyingValue(old_environment); | 692 start = interpolation_type->MaybeConvertUnderlyingValue(old_environment); |
699 if (!start) { | 693 if (!start) { |
700 continue; | 694 continue; |
(...skipping 22 matching lines...) Expand all Loading... | |
723 if (timing.start_delay + timing.iteration_duration <= 0) { | 717 if (timing.start_delay + timing.iteration_duration <= 0) { |
724 // We may have started a transition in a prior CSSTransitionData update, | 718 // We may have started a transition in a prior CSSTransitionData update, |
725 // this CSSTransitionData update needs to override them. | 719 // this CSSTransitionData update needs to override them. |
726 // TODO(alancutter): Just iterate over the CSSTransitionDatas in reverse and | 720 // TODO(alancutter): Just iterate over the CSSTransitionDatas in reverse and |
727 // skip any properties that have already been visited so we don't need to | 721 // skip any properties that have already been visited so we don't need to |
728 // "undo" work like this. | 722 // "undo" work like this. |
729 state.update.UnstartTransition(property); | 723 state.update.UnstartTransition(property); |
730 return; | 724 return; |
731 } | 725 } |
732 | 726 |
733 AnimatableValue* reversing_adjusted_start_value = from.Get(); | 727 const ComputedStyle* reversing_adjusted_start_value = &state.old_style; |
734 double reversing_shortening_factor = 1; | 728 double reversing_shortening_factor = 1; |
735 if (interrupted_transition) { | 729 if (interrupted_transition) { |
736 const double interrupted_progress = | 730 const double interrupted_progress = |
737 interrupted_transition->animation->effect()->Progress(); | 731 interrupted_transition->animation->effect()->Progress(); |
738 if (!std::isnan(interrupted_progress)) { | 732 if (!std::isnan(interrupted_progress)) { |
739 reversing_adjusted_start_value = interrupted_transition->to.Get(); | 733 reversing_adjusted_start_value = interrupted_transition->to.Get(); |
740 reversing_shortening_factor = | 734 reversing_shortening_factor = |
741 clampTo((interrupted_progress * | 735 clampTo((interrupted_progress * |
742 interrupted_transition->reversing_shortening_factor) + | 736 interrupted_transition->reversing_shortening_factor) + |
743 (1 - interrupted_transition->reversing_shortening_factor), | 737 (1 - interrupted_transition->reversing_shortening_factor), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 | 772 |
779 RefPtr<TransitionKeyframe> end_keyframe = | 773 RefPtr<TransitionKeyframe> end_keyframe = |
780 TransitionKeyframe::Create(property); | 774 TransitionKeyframe::Create(property); |
781 end_keyframe->SetValue(TypedInterpolationValue::Create( | 775 end_keyframe->SetValue(TypedInterpolationValue::Create( |
782 *transition_type, end.interpolable_value->Clone(), | 776 *transition_type, end.interpolable_value->Clone(), |
783 end.non_interpolable_value)); | 777 end.non_interpolable_value)); |
784 end_keyframe->SetOffset(1); | 778 end_keyframe->SetOffset(1); |
785 keyframes.push_back(end_keyframe); | 779 keyframes.push_back(end_keyframe); |
786 | 780 |
787 if (CompositorAnimations::IsCompositableProperty(property.CssProperty())) { | 781 if (CompositorAnimations::IsCompositableProperty(property.CssProperty())) { |
782 RefPtr<AnimatableValue> from = | |
783 CSSAnimatableValueFactory::Create(property, state.old_style); | |
784 RefPtr<AnimatableValue> to = | |
785 CSSAnimatableValueFactory::Create(property, state.style); | |
788 delay_keyframe->SetCompositorValue(from); | 786 delay_keyframe->SetCompositorValue(from); |
789 start_keyframe->SetCompositorValue(from); | 787 start_keyframe->SetCompositorValue(from); |
790 end_keyframe->SetCompositorValue(to); | 788 end_keyframe->SetCompositorValue(to); |
791 } | 789 } |
792 | 790 |
793 TransitionKeyframeEffectModel* model = | 791 TransitionKeyframeEffectModel* model = |
794 TransitionKeyframeEffectModel::Create(keyframes); | 792 TransitionKeyframeEffectModel::Create(keyframes); |
795 state.update.StartTransition(property, from.Get(), to.Get(), | 793 if (!state.cloned_style) { |
794 state.cloned_style = ComputedStyle::Clone(state.style); | |
Eric Willigers
2017/05/24 05:43:58
Why is safe to not always overwrite?
alancutter (OOO until 2018)
2017/05/24 06:34:44
This cloned style is shared between transitions th
| |
795 } | |
796 state.update.StartTransition(property, &state.old_style, state.cloned_style, | |
796 reversing_adjusted_start_value, | 797 reversing_adjusted_start_value, |
797 reversing_shortening_factor, | 798 reversing_shortening_factor, |
798 *InertEffect::Create(model, timing, false, 0)); | 799 *InertEffect::Create(model, timing, false, 0)); |
799 DCHECK(!state.animating_element->GetElementAnimations() || | 800 DCHECK(!state.animating_element->GetElementAnimations() || |
800 !state.animating_element->GetElementAnimations() | 801 !state.animating_element->GetElementAnimations() |
801 ->IsAnimationStyleChange()); | 802 ->IsAnimationStyleChange()); |
802 } | 803 } |
803 | 804 |
804 void CSSAnimations::CalculateTransitionUpdateForCustomProperty( | 805 void CSSAnimations::CalculateTransitionUpdateForCustomProperty( |
805 TransitionUpdateState& state, | 806 TransitionUpdateState& state, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 | 870 |
870 const bool animation_style_recalc = | 871 const bool animation_style_recalc = |
871 element_animations && element_animations->IsAnimationStyleChange(); | 872 element_animations && element_animations->IsAnimationStyleChange(); |
872 | 873 |
873 HashSet<PropertyHandle> listed_properties; | 874 HashSet<PropertyHandle> listed_properties; |
874 bool any_transition_had_transition_all = false; | 875 bool any_transition_had_transition_all = false; |
875 const LayoutObject* layout_object = animating_element->GetLayoutObject(); | 876 const LayoutObject* layout_object = animating_element->GetLayoutObject(); |
876 if (!animation_style_recalc && style.Display() != EDisplay::kNone && | 877 if (!animation_style_recalc && style.Display() != EDisplay::kNone && |
877 layout_object && layout_object->Style() && transition_data) { | 878 layout_object && layout_object->Style() && transition_data) { |
878 TransitionUpdateState state = { | 879 TransitionUpdateState state = { |
879 update, animating_element, *layout_object->Style(), | 880 update, animating_element, *layout_object->Style(), style, |
880 style, active_transitions, listed_properties, | 881 nullptr, active_transitions, listed_properties, *transition_data}; |
Eric Willigers
2017/05/24 05:43:58
Why the spaces?
alancutter (OOO until 2018)
2017/05/24 06:34:44
This is what git cl format does.
| |
881 *transition_data}; | |
882 | 882 |
883 for (size_t transition_index = 0; | 883 for (size_t transition_index = 0; |
884 transition_index < transition_data->PropertyList().size(); | 884 transition_index < transition_data->PropertyList().size(); |
885 ++transition_index) { | 885 ++transition_index) { |
886 const CSSTransitionData::TransitionProperty& transition_property = | 886 const CSSTransitionData::TransitionProperty& transition_property = |
887 transition_data->PropertyList()[transition_index]; | 887 transition_data->PropertyList()[transition_index]; |
888 if (transition_property.unresolved_property == CSSPropertyAll) { | 888 if (transition_property.unresolved_property == CSSPropertyAll) { |
889 any_transition_had_transition_all = true; | 889 any_transition_had_transition_all = true; |
890 } | 890 } |
891 if (property_pass == PropertyPass::kCustom) { | 891 if (property_pass == PropertyPass::kCustom) { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1230 IsCustomPropertyHandle); | 1230 IsCustomPropertyHandle); |
1231 } | 1231 } |
1232 | 1232 |
1233 DEFINE_TRACE(CSSAnimations) { | 1233 DEFINE_TRACE(CSSAnimations) { |
1234 visitor->Trace(transitions_); | 1234 visitor->Trace(transitions_); |
1235 visitor->Trace(pending_update_); | 1235 visitor->Trace(pending_update_); |
1236 visitor->Trace(running_animations_); | 1236 visitor->Trace(running_animations_); |
1237 } | 1237 } |
1238 | 1238 |
1239 } // namespace blink | 1239 } // namespace blink |
OLD | NEW |