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

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

Issue 983073002: Make font-size-adjust animatable. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Do not allow font-size-adjust to animate for none or 0 Created 5 years, 9 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
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 21 matching lines...) Expand all
32 #include "core/animation/css/CSSAnimations.h" 32 #include "core/animation/css/CSSAnimations.h"
33 33
34 #include "core/StylePropertyShorthand.h" 34 #include "core/StylePropertyShorthand.h"
35 #include "core/animation/AnimationPlayer.h" 35 #include "core/animation/AnimationPlayer.h"
36 #include "core/animation/AnimationTimeline.h" 36 #include "core/animation/AnimationTimeline.h"
37 #include "core/animation/CompositorAnimations.h" 37 #include "core/animation/CompositorAnimations.h"
38 #include "core/animation/DeferredLegacyStyleInterpolation.h" 38 #include "core/animation/DeferredLegacyStyleInterpolation.h"
39 #include "core/animation/ElementAnimations.h" 39 #include "core/animation/ElementAnimations.h"
40 #include "core/animation/Interpolation.h" 40 #include "core/animation/Interpolation.h"
41 #include "core/animation/KeyframeEffectModel.h" 41 #include "core/animation/KeyframeEffectModel.h"
42 #include "core/animation/animatable/AnimatableUnknown.h"
42 #include "core/animation/css/CSSAnimatableValueFactory.h" 43 #include "core/animation/css/CSSAnimatableValueFactory.h"
43 #include "core/animation/css/CSSPropertyEquality.h" 44 #include "core/animation/css/CSSPropertyEquality.h"
44 #include "core/css/CSSKeyframeRule.h" 45 #include "core/css/CSSKeyframeRule.h"
45 #include "core/css/CSSPropertyMetadata.h" 46 #include "core/css/CSSPropertyMetadata.h"
46 #include "core/css/CSSValueList.h" 47 #include "core/css/CSSValueList.h"
47 #include "core/css/resolver/CSSToStyleMap.h" 48 #include "core/css/resolver/CSSToStyleMap.h"
48 #include "core/css/resolver/StyleResolver.h" 49 #include "core/css/resolver/StyleResolver.h"
49 #include "core/dom/Element.h" 50 #include "core/dom/Element.h"
50 #include "core/dom/PseudoElement.h" 51 #include "core/dom/PseudoElement.h"
51 #include "core/dom/StyleEngine.h" 52 #include "core/dom/StyleEngine.h"
(...skipping 27 matching lines...) Expand all
79 case CSSPropertyWebkitTransformOriginY: 80 case CSSPropertyWebkitTransformOriginY:
80 case CSSPropertyWebkitTransformOriginZ: 81 case CSSPropertyWebkitTransformOriginZ:
81 case CSSPropertyWebkitTransformOrigin: 82 case CSSPropertyWebkitTransformOrigin:
82 return CSSPropertyTransformOrigin; 83 return CSSPropertyTransformOrigin;
83 default: 84 default:
84 break; 85 break;
85 } 86 }
86 return property; 87 return property;
87 } 88 }
88 89
90 static bool isValidValueForAnimation(const CSSPropertyID& property, const Animat ableValue& value)
dstockwell 2015/03/16 21:49:31 I do not think you need to make these changes to C
changseok 2015/03/17 07:12:58 I guess you assume '0' and 'none' should be interp
91 {
92 switch (property) {
93 case CSSPropertyFontSizeAdjust:
94 return !(value.isUnknown() && (toAnimatableUnknown(value).toCSSValueID() == CSSValueNone));
95 default:
96 break;
97 }
98 return true;
99 }
100
89 static PassRefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> createKeyframe Effect(StyleResolver* resolver, const Element* animatingElement, Element& elemen t, const LayoutStyle& style, LayoutStyle* parentStyle, 101 static PassRefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> createKeyframe Effect(StyleResolver* resolver, const Element* animatingElement, Element& elemen t, const LayoutStyle& style, LayoutStyle* parentStyle,
90 const AtomicString& name, TimingFunction* defaultTimingFunction) 102 const AtomicString& name, TimingFunction* defaultTimingFunction)
91 { 103 {
92 // When the animating element is null, use its parent for scoping purposes. 104 // When the animating element is null, use its parent for scoping purposes.
93 const Element* elementForScoping = animatingElement ? animatingElement : &el ement; 105 const Element* elementForScoping = animatingElement ? animatingElement : &el ement;
94 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen tForScoping, name); 106 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen tForScoping, name);
95 ASSERT(keyframesRule); 107 ASSERT(keyframesRule);
96 108
97 AnimatableValueKeyframeVector keyframes; 109 AnimatableValueKeyframeVector keyframes;
98 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe s = keyframesRule->keyframes(); 110 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe s = keyframesRule->keyframes();
99 111
100 // Construct and populate the style for each keyframe 112 // Construct and populate the style for each keyframe
101 PropertySet specifiedPropertiesForUseCounter; 113 PropertySet specifiedPropertiesForUseCounter;
114 PropertySet invalidValueProperties;
102 for (size_t i = 0; i < styleKeyframes.size(); ++i) { 115 for (size_t i = 0; i < styleKeyframes.size(); ++i) {
103 const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get(); 116 const StyleRuleKeyframe* styleKeyframe = styleKeyframes[i].get();
104 RefPtr<LayoutStyle> keyframeStyle = resolver->styleForKeyframe(element, style, parentStyle, styleKeyframe, name); 117 RefPtr<LayoutStyle> keyframeStyle = resolver->styleForKeyframe(element, style, parentStyle, styleKeyframe, name);
105 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKe yframe::create(); 118 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKe yframe::create();
106 const Vector<double>& offsets = styleKeyframe->keys(); 119 const Vector<double>& offsets = styleKeyframe->keys();
107 ASSERT(!offsets.isEmpty()); 120 ASSERT(!offsets.isEmpty());
108 keyframe->setOffset(offsets[0]); 121 keyframe->setOffset(offsets[0]);
109 keyframe->setEasing(defaultTimingFunction); 122 keyframe->setEasing(defaultTimingFunction);
110 const StylePropertySet& properties = styleKeyframe->properties(); 123 const StylePropertySet& properties = styleKeyframe->properties();
111 for (unsigned j = 0; j < properties.propertyCount(); j++) { 124 for (unsigned j = 0; j < properties.propertyCount(); j++) {
112 specifiedPropertiesForUseCounter.add(properties.propertyAt(j).id()); 125 specifiedPropertiesForUseCounter.add(properties.propertyAt(j).id());
113 CSSPropertyID property = propertyForAnimation(properties.propertyAt( j).id()); 126 CSSPropertyID property = propertyForAnimation(properties.propertyAt( j).id());
114 if (property == CSSPropertyWebkitAnimationTimingFunction || property == CSSPropertyAnimationTimingFunction) { 127 if (property == CSSPropertyWebkitAnimationTimingFunction || property == CSSPropertyAnimationTimingFunction) {
115 CSSValue* value = properties.propertyAt(j).value(); 128 CSSValue* value = properties.propertyAt(j).value();
116 RefPtr<TimingFunction> timingFunction; 129 RefPtr<TimingFunction> timingFunction;
117 if (value->isInheritedValue() && parentStyle->animations()) { 130 if (value->isInheritedValue() && parentStyle->animations()) {
118 timingFunction = parentStyle->animations()->timingFunctionLi st()[0]; 131 timingFunction = parentStyle->animations()->timingFunctionLi st()[0];
119 } else if (value->isValueList()) { 132 } else if (value->isValueList()) {
120 timingFunction = CSSToStyleMap::mapAnimationTimingFunction(t oCSSValueList(value)->item(0)); 133 timingFunction = CSSToStyleMap::mapAnimationTimingFunction(t oCSSValueList(value)->item(0));
121 } else { 134 } else {
122 ASSERT(value->isInheritedValue() || value->isInitialValue() || value->isUnsetValue()); 135 ASSERT(value->isInheritedValue() || value->isInitialValue() || value->isUnsetValue());
123 timingFunction = CSSTimingData::initialTimingFunction(); 136 timingFunction = CSSTimingData::initialTimingFunction();
124 } 137 }
125 keyframe->setEasing(timingFunction.release()); 138 keyframe->setEasing(timingFunction.release());
126 } else if (CSSPropertyMetadata::isAnimatableProperty(property)) { 139 } else if (CSSPropertyMetadata::isAnimatableProperty(property)) {
127 keyframe->setPropertyValue(property, CSSAnimatableValueFactory:: create(property, *keyframeStyle).get()); 140 keyframe->setPropertyValue(property, CSSAnimatableValueFactory:: create(property, *keyframeStyle));
141 if (!isValidValueForAnimation(property, *keyframe->propertyValue (property)))
142 invalidValueProperties.add(property);
128 } 143 }
129 } 144 }
130 keyframes.append(keyframe); 145 keyframes.append(keyframe);
131 // The last keyframe specified at a given offset is used. 146 // The last keyframe specified at a given offset is used.
132 for (size_t j = 1; j < offsets.size(); ++j) { 147 for (size_t j = 1; j < offsets.size(); ++j) {
133 keyframes.append(toAnimatableValueKeyframe(keyframe->cloneWithOffset (offsets[j]).get())); 148 keyframes.append(toAnimatableValueKeyframe(keyframe->cloneWithOffset (offsets[j]).get()));
134 } 149 }
135 } 150 }
136 151
137 for (CSSPropertyID property : specifiedPropertiesForUseCounter) { 152 for (CSSPropertyID property : specifiedPropertiesForUseCounter) {
138 ASSERT(property != CSSPropertyInvalid); 153 ASSERT(property != CSSPropertyInvalid);
139 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property)); 154 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property));
140 } 155 }
141 156
157 for (CSSPropertyID property : invalidValueProperties) {
158 for (const auto& keyframe : keyframes)
159 keyframe->clearPropertyValue(property);
160 }
161
142 // Merge duplicate keyframes. 162 // Merge duplicate keyframes.
143 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s); 163 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s);
144 size_t targetIndex = 0; 164 size_t targetIndex = 0;
145 for (size_t i = 1; i < keyframes.size(); i++) { 165 for (size_t i = 1; i < keyframes.size(); i++) {
146 if (keyframes[i]->offset() == keyframes[targetIndex]->offset()) { 166 if (keyframes[i]->offset() == keyframes[targetIndex]->offset()) {
147 for (CSSPropertyID property : keyframes[i]->properties()) 167 for (CSSPropertyID property : keyframes[i]->properties())
148 keyframes[targetIndex]->setPropertyValue(property, keyframes[i]- >propertyValue(property)); 168 keyframes[targetIndex]->setPropertyValue(property, keyframes[i]- >propertyValue(property));
149 } else { 169 } else {
150 targetIndex++; 170 targetIndex++;
151 keyframes[targetIndex] = keyframes[i]; 171 keyframes[targetIndex] = keyframes[i];
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 visitor->trace(m_activeInterpolationsForAnimations); 822 visitor->trace(m_activeInterpolationsForAnimations);
803 visitor->trace(m_activeInterpolationsForTransitions); 823 visitor->trace(m_activeInterpolationsForTransitions);
804 visitor->trace(m_newAnimations); 824 visitor->trace(m_newAnimations);
805 visitor->trace(m_suppressedAnimationPlayers); 825 visitor->trace(m_suppressedAnimationPlayers);
806 visitor->trace(m_animationsWithUpdates); 826 visitor->trace(m_animationsWithUpdates);
807 visitor->trace(m_animationsWithStyleUpdates); 827 visitor->trace(m_animationsWithStyleUpdates);
808 #endif 828 #endif
809 } 829 }
810 830
811 } // namespace blink 831 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698