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

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

Issue 2682603004: Don't animate visibility keyframes that don't include "visible" (Closed)
Patch Set: git squash commit for _fixVisibilityMerge. Created 3 years, 10 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 | « third_party/WebKit/LayoutTests/animations/interpolation/visibility-interpolation.html ('k') | 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 // 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 "core/animation/CSSVisibilityInterpolationType.h" 5 #include "core/animation/CSSVisibilityInterpolationType.h"
6 6
7 #include "core/css/CSSPrimitiveValueMappings.h" 7 #include "core/css/CSSPrimitiveValueMappings.h"
8 #include "core/css/resolver/StyleResolverState.h" 8 #include "core/css/resolver/StyleResolverState.h"
9 #include "wtf/PtrUtil.h" 9 #include "wtf/PtrUtil.h"
10 #include <memory> 10 #include <memory>
(...skipping 12 matching lines...) Expand all
23 EVisibility visibility() const { 23 EVisibility visibility() const {
24 DCHECK(m_isSingle); 24 DCHECK(m_isSingle);
25 return m_start; 25 return m_start;
26 } 26 }
27 27
28 EVisibility visibility(double fraction) const { 28 EVisibility visibility(double fraction) const {
29 if (m_isSingle || fraction <= 0) 29 if (m_isSingle || fraction <= 0)
30 return m_start; 30 return m_start;
31 if (fraction >= 1) 31 if (fraction >= 1)
32 return m_end; 32 return m_end;
33 if (m_start == EVisibility::kVisible || m_end == EVisibility::kVisible) 33 if (m_start == EVisibility::kVisible || m_end == EVisibility::kVisible)
Eric Willigers 2017/02/16 00:29:47 Should this now be DCHECK(m_start == EVisibility::
alancutter (OOO until 2018) 2017/02/16 00:58:17 Good idea. Done.
34 return EVisibility::kVisible; 34 return EVisibility::kVisible;
35 return fraction < 0.5 ? m_start : m_end; 35 return fraction < 0.5 ? m_start : m_end;
36 } 36 }
37 37
38 DECLARE_NON_INTERPOLABLE_VALUE_TYPE(); 38 DECLARE_NON_INTERPOLABLE_VALUE_TYPE();
39 39
40 private: 40 private:
41 CSSVisibilityNonInterpolableValue(EVisibility start, EVisibility end) 41 CSSVisibilityNonInterpolableValue(EVisibility start, EVisibility end)
42 : m_start(start), m_end(end), m_isSingle(m_start == m_end) {} 42 : m_start(start), m_end(end), m_isSingle(m_start == m_end) {}
43 43
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 InterpolationValue 155 InterpolationValue
156 CSSVisibilityInterpolationType::maybeConvertStandardPropertyUnderlyingValue( 156 CSSVisibilityInterpolationType::maybeConvertStandardPropertyUnderlyingValue(
157 const ComputedStyle& style) const { 157 const ComputedStyle& style) const {
158 return createVisibilityValue(style.visibility()); 158 return createVisibilityValue(style.visibility());
159 } 159 }
160 160
161 PairwiseInterpolationValue CSSVisibilityInterpolationType::maybeMergeSingles( 161 PairwiseInterpolationValue CSSVisibilityInterpolationType::maybeMergeSingles(
162 InterpolationValue&& start, 162 InterpolationValue&& start,
163 InterpolationValue&& end) const { 163 InterpolationValue&& end) const {
164 return PairwiseInterpolationValue( 164 EVisibility startVisibility =
165 InterpolableNumber::create(0), InterpolableNumber::create(1), 165 toCSSVisibilityNonInterpolableValue(*start.nonInterpolableValue)
166 CSSVisibilityNonInterpolableValue::create( 166 .visibility();
167 toCSSVisibilityNonInterpolableValue(*start.nonInterpolableValue) 167 EVisibility endVisibility =
168 .visibility(), 168 toCSSVisibilityNonInterpolableValue(*end.nonInterpolableValue)
169 toCSSVisibilityNonInterpolableValue(*end.nonInterpolableValue) 169 .visibility();
170 .visibility())); 170 if (startVisibility != endVisibility &&
171 startVisibility != EVisibility::kVisible &&
172 endVisibility != EVisibility::kVisible) {
173 return nullptr;
174 }
175 return PairwiseInterpolationValue(InterpolableNumber::create(0),
176 InterpolableNumber::create(1),
177 CSSVisibilityNonInterpolableValue::create(
178 startVisibility, endVisibility));
171 } 179 }
172 180
173 void CSSVisibilityInterpolationType::composite( 181 void CSSVisibilityInterpolationType::composite(
174 UnderlyingValueOwner& underlyingValueOwner, 182 UnderlyingValueOwner& underlyingValueOwner,
175 double underlyingFraction, 183 double underlyingFraction,
176 const InterpolationValue& value, 184 const InterpolationValue& value,
177 double interpolationFraction) const { 185 double interpolationFraction) const {
178 underlyingValueOwner.set(*this, value); 186 underlyingValueOwner.set(*this, value);
179 } 187 }
180 188
181 void CSSVisibilityInterpolationType::applyStandardPropertyValue( 189 void CSSVisibilityInterpolationType::applyStandardPropertyValue(
182 const InterpolableValue& interpolableValue, 190 const InterpolableValue& interpolableValue,
183 const NonInterpolableValue* nonInterpolableValue, 191 const NonInterpolableValue* nonInterpolableValue,
184 StyleResolverState& state) const { 192 StyleResolverState& state) const {
185 // Visibility interpolation has been deferred to application time here due to 193 // Visibility interpolation has been deferred to application time here due to
186 // its non-linear behaviour. 194 // its non-linear behaviour.
187 double fraction = toInterpolableNumber(interpolableValue).value(); 195 double fraction = toInterpolableNumber(interpolableValue).value();
188 EVisibility visibility = 196 EVisibility visibility =
189 toCSSVisibilityNonInterpolableValue(nonInterpolableValue) 197 toCSSVisibilityNonInterpolableValue(nonInterpolableValue)
190 ->visibility(fraction); 198 ->visibility(fraction);
191 state.style()->setVisibility(visibility); 199 state.style()->setVisibility(visibility);
192 } 200 }
193 201
194 } // namespace blink 202 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/animations/interpolation/visibility-interpolation.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698