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

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

Issue 2909543003: Use unnamed namespaces instead of static functions in CSSAnimations.cpp (Closed)
Patch Set: Created 3 years, 6 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "platform/animation/TimingFunction.h" 66 #include "platform/animation/TimingFunction.h"
67 #include "platform/wtf/HashSet.h" 67 #include "platform/wtf/HashSet.h"
68 #include "public/platform/Platform.h" 68 #include "public/platform/Platform.h"
69 69
70 namespace blink { 70 namespace blink {
71 71
72 using PropertySet = HashSet<CSSPropertyID>; 72 using PropertySet = HashSet<CSSPropertyID>;
73 73
74 namespace { 74 namespace {
75 75
76 static StringKeyframeEffectModel* CreateKeyframeEffectModel( 76 StringKeyframeEffectModel* CreateKeyframeEffectModel(
77 StyleResolver* resolver, 77 StyleResolver* resolver,
78 const Element* animating_element, 78 const Element* animating_element,
79 Element& element, 79 Element& element,
80 const ComputedStyle* style, 80 const ComputedStyle* style,
81 const ComputedStyle* parent_style, 81 const ComputedStyle* parent_style,
82 const AtomicString& name, 82 const AtomicString& name,
83 TimingFunction* default_timing_function, 83 TimingFunction* default_timing_function,
84 size_t animation_index) { 84 size_t animation_index) {
85 // When the animating element is null, use its parent for scoping purposes. 85 // When the animating element is null, use its parent for scoping purposes.
86 const Element* element_for_scoping = 86 const Element* element_for_scoping =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 bool CSSAnimations::IsTransitionAnimationForInspector( 204 bool CSSAnimations::IsTransitionAnimationForInspector(
205 const Animation& animation) const { 205 const Animation& animation) const {
206 for (const auto& it : transitions_) { 206 for (const auto& it : transitions_) {
207 if (it.value.animation->SequenceNumber() == animation.SequenceNumber()) 207 if (it.value.animation->SequenceNumber() == animation.SequenceNumber())
208 return true; 208 return true;
209 } 209 }
210 return false; 210 return false;
211 } 211 }
212 212
213 static const KeyframeEffectModelBase* GetKeyframeEffectModelBase( 213 namespace {
214
215 const KeyframeEffectModelBase* GetKeyframeEffectModelBase(
214 const AnimationEffectReadOnly* effect) { 216 const AnimationEffectReadOnly* effect) {
215 if (!effect) 217 if (!effect)
216 return nullptr; 218 return nullptr;
217 const EffectModel* model = nullptr; 219 const EffectModel* model = nullptr;
218 if (effect->IsKeyframeEffectReadOnly()) 220 if (effect->IsKeyframeEffectReadOnly())
219 model = ToKeyframeEffectReadOnly(effect)->Model(); 221 model = ToKeyframeEffectReadOnly(effect)->Model();
220 else if (effect->IsInertEffect()) 222 else if (effect->IsInertEffect())
221 model = ToInertEffect(effect)->Model(); 223 model = ToInertEffect(effect)->Model();
222 if (!model || !model->IsKeyframeEffectModel()) 224 if (!model || !model->IsKeyframeEffectModel())
223 return nullptr; 225 return nullptr;
224 return ToKeyframeEffectModelBase(model); 226 return ToKeyframeEffectModelBase(model);
225 } 227 }
226 228
229 } // namespace
230
227 void CSSAnimations::CalculateCompositorAnimationUpdate( 231 void CSSAnimations::CalculateCompositorAnimationUpdate(
228 CSSAnimationUpdate& update, 232 CSSAnimationUpdate& update,
229 const Element* animating_element, 233 const Element* animating_element,
230 Element& element, 234 Element& element,
231 const ComputedStyle& style, 235 const ComputedStyle& style,
232 const ComputedStyle* parent_style, 236 const ComputedStyle* parent_style,
233 bool was_viewport_resized) { 237 bool was_viewport_resized) {
234 ElementAnimations* element_animations = 238 ElementAnimations* element_animations =
235 animating_element ? animating_element->GetElementAnimations() : nullptr; 239 animating_element ? animating_element->GetElementAnimations() : nullptr;
236 240
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 for (const auto& entry : transitions_) { 946 for (const auto& entry : transitions_) {
943 entry.value.animation->cancel(); 947 entry.value.animation->cancel();
944 entry.value.animation->Update(kTimingUpdateOnDemand); 948 entry.value.animation->Update(kTimingUpdateOnDemand);
945 } 949 }
946 950
947 running_animations_.clear(); 951 running_animations_.clear();
948 transitions_.clear(); 952 transitions_.clear();
949 ClearPendingUpdate(); 953 ClearPendingUpdate();
950 } 954 }
951 955
952 static bool IsCustomPropertyHandle(const PropertyHandle& property) { 956 namespace {
957
958 bool IsCustomPropertyHandle(const PropertyHandle& property) {
953 return property.IsCSSCustomProperty(); 959 return property.IsCSSCustomProperty();
954 } 960 }
955 961
956 // TODO(alancutter): CSS properties and presentation attributes may have 962 // TODO(alancutter): CSS properties and presentation attributes may have
957 // identical effects. By grouping them in the same set we introduce a bug where 963 // identical effects. By grouping them in the same set we introduce a bug where
958 // arbitrary hash iteration will determine the order the apply in and thus which 964 // arbitrary hash iteration will determine the order the apply in and thus which
959 // one "wins". We should be more deliberate about the order of application in 965 // one "wins". We should be more deliberate about the order of application in
960 // the case of effect collisions. 966 // the case of effect collisions.
961 // Example: Both 'color' and 'svg-color' set the color on ComputedStyle but are 967 // Example: Both 'color' and 'svg-color' set the color on ComputedStyle but are
962 // considered distinct properties in the ActiveInterpolationsMap. 968 // considered distinct properties in the ActiveInterpolationsMap.
963 static bool IsStandardPropertyHandle(const PropertyHandle& property) { 969 bool IsStandardPropertyHandle(const PropertyHandle& property) {
964 return (property.IsCSSProperty() && !property.IsCSSCustomProperty()) || 970 return (property.IsCSSProperty() && !property.IsCSSCustomProperty()) ||
965 property.IsPresentationAttribute(); 971 property.IsPresentationAttribute();
966 } 972 }
967 973
968 static void AdoptActiveAnimationInterpolations( 974 void AdoptActiveAnimationInterpolations(
969 EffectStack* effect_stack, 975 EffectStack* effect_stack,
970 CSSAnimationUpdate& update, 976 CSSAnimationUpdate& update,
971 const HeapVector<Member<const InertEffect>>* new_animations, 977 const HeapVector<Member<const InertEffect>>* new_animations,
972 const HeapHashSet<Member<const Animation>>* suppressed_animations) { 978 const HeapHashSet<Member<const Animation>>* suppressed_animations) {
973 ActiveInterpolationsMap custom_interpolations( 979 ActiveInterpolationsMap custom_interpolations(
974 EffectStack::ActiveInterpolations( 980 EffectStack::ActiveInterpolations(
975 effect_stack, new_animations, suppressed_animations, 981 effect_stack, new_animations, suppressed_animations,
976 KeyframeEffectReadOnly::kDefaultPriority, IsCustomPropertyHandle)); 982 KeyframeEffectReadOnly::kDefaultPriority, IsCustomPropertyHandle));
977 update.AdoptActiveInterpolationsForCustomAnimations(custom_interpolations); 983 update.AdoptActiveInterpolationsForCustomAnimations(custom_interpolations);
978 984
979 ActiveInterpolationsMap standard_interpolations( 985 ActiveInterpolationsMap standard_interpolations(
980 EffectStack::ActiveInterpolations( 986 EffectStack::ActiveInterpolations(
981 effect_stack, new_animations, suppressed_animations, 987 effect_stack, new_animations, suppressed_animations,
982 KeyframeEffectReadOnly::kDefaultPriority, IsStandardPropertyHandle)); 988 KeyframeEffectReadOnly::kDefaultPriority, IsStandardPropertyHandle));
983 update.AdoptActiveInterpolationsForStandardAnimations( 989 update.AdoptActiveInterpolationsForStandardAnimations(
984 standard_interpolations); 990 standard_interpolations);
985 } 991 }
986 992
993 } // namespace
994
987 void CSSAnimations::CalculateAnimationActiveInterpolations( 995 void CSSAnimations::CalculateAnimationActiveInterpolations(
988 CSSAnimationUpdate& update, 996 CSSAnimationUpdate& update,
989 const Element* animating_element) { 997 const Element* animating_element) {
990 ElementAnimations* element_animations = 998 ElementAnimations* element_animations =
991 animating_element ? animating_element->GetElementAnimations() : nullptr; 999 animating_element ? animating_element->GetElementAnimations() : nullptr;
992 EffectStack* effect_stack = 1000 EffectStack* effect_stack =
993 element_animations ? &element_animations->GetEffectStack() : nullptr; 1001 element_animations ? &element_animations->GetEffectStack() : nullptr;
994 1002
995 if (update.NewAnimations().IsEmpty() && 1003 if (update.NewAnimations().IsEmpty() &&
996 update.SuppressedAnimations().IsEmpty()) { 1004 update.SuppressedAnimations().IsEmpty()) {
997 AdoptActiveAnimationInterpolations(effect_stack, update, nullptr, nullptr); 1005 AdoptActiveAnimationInterpolations(effect_stack, update, nullptr, nullptr);
998 return; 1006 return;
999 } 1007 }
1000 1008
1001 HeapVector<Member<const InertEffect>> new_effects; 1009 HeapVector<Member<const InertEffect>> new_effects;
1002 for (const auto& new_animation : update.NewAnimations()) 1010 for (const auto& new_animation : update.NewAnimations())
1003 new_effects.push_back(new_animation.effect); 1011 new_effects.push_back(new_animation.effect);
1004 1012
1005 // Animations with updates use a temporary InertEffect for the current frame. 1013 // Animations with updates use a temporary InertEffect for the current frame.
1006 for (const auto& updated_animation : update.AnimationsWithUpdates()) 1014 for (const auto& updated_animation : update.AnimationsWithUpdates())
1007 new_effects.push_back(updated_animation.effect); 1015 new_effects.push_back(updated_animation.effect);
1008 1016
1009 AdoptActiveAnimationInterpolations(effect_stack, update, &new_effects, 1017 AdoptActiveAnimationInterpolations(effect_stack, update, &new_effects,
1010 &update.SuppressedAnimations()); 1018 &update.SuppressedAnimations());
1011 } 1019 }
1012 1020
1013 static EffectStack::PropertyHandleFilter PropertyFilter( 1021 namespace {
1022
1023 EffectStack::PropertyHandleFilter PropertyFilter(
1014 CSSAnimations::PropertyPass property_pass) { 1024 CSSAnimations::PropertyPass property_pass) {
1015 if (property_pass == CSSAnimations::PropertyPass::kCustom) { 1025 if (property_pass == CSSAnimations::PropertyPass::kCustom) {
1016 return IsCustomPropertyHandle; 1026 return IsCustomPropertyHandle;
1017 } 1027 }
1018 DCHECK_EQ(property_pass, CSSAnimations::PropertyPass::kStandard); 1028 DCHECK_EQ(property_pass, CSSAnimations::PropertyPass::kStandard);
1019 return IsStandardPropertyHandle; 1029 return IsStandardPropertyHandle;
1020 } 1030 }
1021 1031
1032 } // namespace
1033
1022 void CSSAnimations::CalculateTransitionActiveInterpolations( 1034 void CSSAnimations::CalculateTransitionActiveInterpolations(
1023 CSSAnimationUpdate& update, 1035 CSSAnimationUpdate& update,
1024 PropertyPass property_pass, 1036 PropertyPass property_pass,
1025 const Element* animating_element) { 1037 const Element* animating_element) {
1026 ElementAnimations* element_animations = 1038 ElementAnimations* element_animations =
1027 animating_element ? animating_element->GetElementAnimations() : nullptr; 1039 animating_element ? animating_element->GetElementAnimations() : nullptr;
1028 EffectStack* effect_stack = 1040 EffectStack* effect_stack =
1029 element_animations ? &element_animations->GetEffectStack() : nullptr; 1041 element_animations ? &element_animations->GetEffectStack() : nullptr;
1030 1042
1031 ActiveInterpolationsMap active_interpolations_for_transitions; 1043 ActiveInterpolationsMap active_interpolations_for_transitions;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 IsCustomPropertyHandle); 1261 IsCustomPropertyHandle);
1250 } 1262 }
1251 1263
1252 DEFINE_TRACE(CSSAnimations) { 1264 DEFINE_TRACE(CSSAnimations) {
1253 visitor->Trace(transitions_); 1265 visitor->Trace(transitions_);
1254 visitor->Trace(pending_update_); 1266 visitor->Trace(pending_update_);
1255 visitor->Trace(running_animations_); 1267 visitor->Trace(running_animations_);
1256 } 1268 }
1257 1269
1258 } // namespace blink 1270 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698