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

Side by Side Diff: Source/core/animation/InvalidatableStyleInterpolation.cpp

Issue 1329843002: Support per property CSS Animation stacks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix TODO Created 5 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/animation/InvalidatableStyleInterpolation.h" 6 #include "core/animation/InvalidatableStyleInterpolation.h"
7 7
8 #include "core/animation/StringKeyframe.h" 8 #include "core/animation/StringKeyframe.h"
9 #include "core/css/resolver/StyleResolverState.h" 9 #include "core/css/resolver/StyleResolverState.h"
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void InvalidatableStyleInterpolation::setFlagIfInheritUsed(StyleResolverState& s tate) const 113 void InvalidatableStyleInterpolation::setFlagIfInheritUsed(StyleResolverState& s tate) const
114 { 114 {
115 if (!state.parentStyle()) 115 if (!state.parentStyle())
116 return; 116 return;
117 if ((m_startKeyframe->value() && m_startKeyframe->value()->isInheritedValue( )) 117 if ((m_startKeyframe->value() && m_startKeyframe->value()->isInheritedValue( ))
118 || (m_endKeyframe->value() && m_endKeyframe->value()->isInheritedValue() )) { 118 || (m_endKeyframe->value() && m_endKeyframe->value()->isInheritedValue() )) {
119 state.parentStyle()->setHasExplicitlyInheritedProperties(); 119 state.parentStyle()->setHasExplicitlyInheritedProperties();
120 } 120 }
121 } 121 }
122 122
123 void InvalidatableStyleInterpolation::apply(StyleResolverState& state) const 123 void InvalidatableStyleInterpolation::applyStack(const ActiveInterpolations& int erpolations, StyleResolverState& state)
124 { 124 {
125 OwnPtr<InterpolationValue> underlyingValue = dependsOnUnderlyingValue() ? ma ybeConvertUnderlyingValue(state) : nullptr; 125 ASSERT(interpolations.size() > 0);
126 ensureValidInterpolation(state, underlyingValue.get()); 126 size_t startingIndex = 0;
127 if (!m_cachedValue) 127
128 return; 128 // Compute the underlying value to composite onto.
129 const InterpolableValue* appliedInterpolableValue = &m_cachedValue->interpol ableValue(); 129 OwnPtr<InterpolationValue> underlyingValueOwner = nullptr;
dstockwell 2015/09/07 03:11:37 Let's see if we can encapsulate this ownptr/rawptr
alancutter (OOO until 2018) 2015/09/07 03:36:46 Done.
130 if (underlyingValue && m_cachedValue->type() == underlyingValue->type()) { 130 InterpolationValue* underlyingValue = nullptr;
131 double underlyingFraction = m_cachedConversion->interpolateUnderlyingFra ction(m_startKeyframe->underlyingFraction(), m_endKeyframe->underlyingFraction() , m_currentFraction); 131 const InvalidatableStyleInterpolation& firstInterpolation = toInvalidatableS tyleInterpolation(*interpolations.at(startingIndex));
132 underlyingValue->interpolableValue().scaleAndAdd(underlyingFraction, m_c achedValue->interpolableValue()); 132 if (firstInterpolation.dependsOnUnderlyingValue()) {
133 appliedInterpolableValue = &underlyingValue->interpolableValue(); 133 underlyingValueOwner = firstInterpolation.maybeConvertUnderlyingValue(st ate);
134 underlyingValue = underlyingValueOwner.get();
135 } else {
136 firstInterpolation.ensureValidInterpolation(state, nullptr);
dstockwell 2015/09/07 03:11:37 Should ensureValidInterpolation just return the m_
alancutter (OOO until 2018) 2015/09/07 03:36:46 Good idea, done.
137 // Fast path for replace interpolations that are the last to apply.
138 if (interpolations.size() == 1) {
139 const InterpolationValue* firstValue = firstInterpolation.m_cachedVa lue.get();
140 if (firstValue) {
141 firstInterpolation.setFlagIfInheritUsed(state);
142 firstValue->type().apply(firstValue->interpolableValue(), firstV alue->nonInterpolableValue(), state);
143 }
144 return;
145 }
146 underlyingValue = firstInterpolation.m_cachedValue.get();
147 startingIndex++;
134 } 148 }
135 m_cachedValue->type().apply(*appliedInterpolableValue, m_cachedValue->nonInt erpolableValue(), state); 149
136 setFlagIfInheritUsed(state); 150 // Composite interpolations onto the underlying value.
151 bool shouldApply = false;
152 for (size_t i = startingIndex; i < interpolations.size(); i++) {
153 const InvalidatableStyleInterpolation& currentInterpolation = toInvalida tableStyleInterpolation(*interpolations.at(i));
154 ASSERT(currentInterpolation.dependsOnUnderlyingValue());
155 currentInterpolation.ensureValidInterpolation(state, underlyingValue);
156 const InterpolationValue* currentValue = currentInterpolation.m_cachedVa lue.get();
157 if (!currentValue)
158 continue;
159 shouldApply = true;
160 currentInterpolation.setFlagIfInheritUsed(state);
161 if (!underlyingValue || underlyingValue->type() != currentValue->type()) {
162 // We keep track of the current value as the new underlying value bu t do not mutate it, instead perform copy on write.
163 underlyingValue = const_cast<InterpolationValue*>(currentValue);
164 underlyingValueOwner.clear();
165 } else {
166 double underlyingFraction = currentInterpolation.m_cachedConversion- >interpolateUnderlyingFraction(
167 currentInterpolation.m_startKeyframe->underlyingFraction(),
168 currentInterpolation.m_endKeyframe->underlyingFraction(),
169 currentInterpolation.m_currentFraction);
170 if (!underlyingValueOwner) {
171 underlyingValueOwner = underlyingValue->clone();
172 underlyingValue = underlyingValueOwner.get();
173 }
174 underlyingValue->interpolableValue().scaleAndAdd(underlyingFraction, currentInterpolation.m_cachedValue->interpolableValue());
175 }
176 }
177
178 if (shouldApply && underlyingValue) {
179 underlyingValue->type().apply(underlyingValue->interpolableValue(), unde rlyingValue->nonInterpolableValue(), state);
180 }
137 } 181 }
138 182
139 } // namespace blink 183 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698