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

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

Issue 1262283002: Fix 50% flip handling of CSS Animations using CSS wide keywords (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 4 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
« no previous file with comments | « Source/core/animation/StringKeyframe.h ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/StringKeyframe.h" 6 #include "core/animation/StringKeyframe.h"
7 7
8 #include "core/animation/AngleSVGInterpolation.h" 8 #include "core/animation/AngleSVGInterpolation.h"
9 #include "core/animation/CSSValueInterpolationType.h" 9 #include "core/animation/CSSValueInterpolationType.h"
10 #include "core/animation/ColorStyleInterpolation.h" 10 #include "core/animation/ColorStyleInterpolation.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 break; 177 break;
178 } 178 }
179 applicableTypes->append(new CSSValueInterpolationType(property)); 179 applicableTypes->append(new CSSValueInterpolationType(property));
180 applicableTypesMap.add(property, applicableTypes); 180 applicableTypesMap.add(property, applicableTypes);
181 return applicableTypes; 181 return applicableTypes;
182 } 182 }
183 183
184 } // namespace 184 } // namespace
185 185
186 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram e::createLegacyStyleInterpolation(CSSPropertyID property, Keyframe::PropertySpec ificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const
187 {
188 CSSValue& fromCSSValue = *m_value.get();
189 CSSValue& toCSSValue = *toCSSPropertySpecificKeyframe(end).value();
190 if (DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(from CSSValue) || DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve (toCSSValue)) {
191 // FIXME: Handle these cases outside of DeferredLegacyStyleInterpolation .
192 return DeferredLegacyStyleInterpolation::create(&fromCSSValue, &toCSSVal ue, property);
193 }
194
195 // FIXME: Remove the use of AnimatableValues and Elements here.
196 ASSERT(element);
197 populateAnimatableValue(property, *element, baseStyle);
198 end.populateAnimatableValue(property, *element, baseStyle);
199 return LegacyStyleInterpolation::create(getAnimatableValue(), end.getAnimata bleValue(), property);
200 }
201
186 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram e::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpe cificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const 202 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram e::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpe cificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const
187 { 203 {
188 CSSPropertyID property = propertyHandle.cssProperty(); 204 CSSPropertyID property = propertyHandle.cssProperty();
189 const Vector<const InterpolationType*>* applicableTypes = applicableTypesFor Property(property); 205 const Vector<const InterpolationType*>* applicableTypes = applicableTypesFor Property(property);
190 if (applicableTypes) 206 if (applicableTypes)
191 return InvalidatableStyleInterpolation::create(*applicableTypes, *this, toCSSPropertySpecificKeyframe(end)); 207 return InvalidatableStyleInterpolation::create(*applicableTypes, *this, toCSSPropertySpecificKeyframe(end));
192 208
193 // TODO(alancutter): Remove the remainder of this function. 209 // TODO(alancutter): Remove the remainder of this function.
194 210
195 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe ct, and a template parameter specific converter. 211 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe ct, and a template parameter specific converter.
196 CSSValue* fromCSSValue = m_value.get(); 212 CSSValue* fromCSSValue = m_value.get();
197 CSSValue* toCSSValue = toCSSPropertySpecificKeyframe(end).value(); 213 CSSValue* toCSSValue = toCSSPropertySpecificKeyframe(end).value();
198 InterpolationRange range = RangeAll; 214 InterpolationRange range = RangeAll;
199 bool fallBackToLegacy = false;
200 215
201 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr ect. 216 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr ect.
202 bool forceDefaultInterpolation = false; 217 bool forceDefaultInterpolation = false;
203 218
204 // FIXME: Remove this check once neutral keyframes are implemented in String Keyframes. 219 // FIXME: Remove this check once neutral keyframes are implemented in String Keyframes.
205 if (!fromCSSValue || !toCSSValue) 220 if (!fromCSSValue || !toCSSValue)
206 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue , property); 221 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue , property);
207 222
208 ASSERT(fromCSSValue && toCSSValue); 223 ASSERT(fromCSSValue && toCSSValue);
209 224
210 if (!CSSPropertyMetadata::isInterpolableProperty(property)) { 225 if (!CSSPropertyMetadata::isInterpolableProperty(property)) {
211 if (fromCSSValue == toCSSValue) 226 if (fromCSSValue == toCSSValue)
212 return ConstantStyleInterpolation::create(fromCSSValue, property); 227 return ConstantStyleInterpolation::create(fromCSSValue, property);
213 228
214 return nullptr; 229 return nullptr;
215 } 230 }
216 231
232 if (fromCSSValue->isCSSWideKeyword() || toCSSValue->isCSSWideKeyword())
233 return createLegacyStyleInterpolation(property, end, element, baseStyle) ;
234
217 switch (property) { 235 switch (property) {
218 case CSSPropertyLineHeight: 236 case CSSPropertyLineHeight:
219 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl eInterpolation::canCreateFrom(*toCSSValue)) 237 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl eInterpolation::canCreateFrom(*toCSSValue))
220 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, RangeNonNegative); 238 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, RangeNonNegative);
221 239
222 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl eInterpolation::canCreateFrom(*toCSSValue)) 240 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl eInterpolation::canCreateFrom(*toCSSValue))
223 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, true, RangeNonNegative); 241 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, true, RangeNonNegative);
224 242
225 break; 243 break;
226 case CSSPropertyBorderBottomWidth: 244 case CSSPropertyBorderBottomWidth:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 case CSSPropertyWebkitTransformOriginX: 293 case CSSPropertyWebkitTransformOriginX:
276 case CSSPropertyWebkitTransformOriginY: 294 case CSSPropertyWebkitTransformOriginY:
277 case CSSPropertyWebkitTransformOriginZ: 295 case CSSPropertyWebkitTransformOriginZ:
278 case CSSPropertyX: 296 case CSSPropertyX:
279 case CSSPropertyY: 297 case CSSPropertyY:
280 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue, property) && LengthStyleInterpolation::canCreateFrom(*toCSSValue, property)) 298 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue, property) && LengthStyleInterpolation::canCreateFrom(*toCSSValue, property))
281 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, range); 299 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, range);
282 300
283 // FIXME: Handle keywords e.g. 'smaller', 'larger'. 301 // FIXME: Handle keywords e.g. 'smaller', 'larger'.
284 if (property == CSSPropertyFontSize) 302 if (property == CSSPropertyFontSize)
285 fallBackToLegacy = true; 303 return createLegacyStyleInterpolation(property, end, element, baseSt yle);
286 304
287 // FIXME: Handle keywords e.g. 'baseline', 'sub'. 305 // FIXME: Handle keywords e.g. 'baseline', 'sub'.
288 if (property == CSSPropertyBaselineShift) 306 if (property == CSSPropertyBaselineShift)
289 fallBackToLegacy = true; 307 return createLegacyStyleInterpolation(property, end, element, baseSt yle);
290 308
291 break; 309 break;
292 case CSSPropertyOrphans: 310 case CSSPropertyOrphans:
293 case CSSPropertyWidows: 311 case CSSPropertyWidows:
294 case CSSPropertyZIndex: 312 case CSSPropertyZIndex:
295 case CSSPropertyWebkitColumnCount: 313 case CSSPropertyWebkitColumnCount:
296 case CSSPropertyShapeImageThreshold: 314 case CSSPropertyShapeImageThreshold:
297 case CSSPropertyFillOpacity: 315 case CSSPropertyFillOpacity:
298 case CSSPropertyFloodOpacity: 316 case CSSPropertyFloodOpacity:
299 case CSSPropertyFontSizeAdjust: 317 case CSSPropertyFontSizeAdjust:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 case CSSPropertyTextDecorationColor: 350 case CSSPropertyTextDecorationColor:
333 case CSSPropertyWebkitColumnRuleColor: 351 case CSSPropertyWebkitColumnRuleColor:
334 case CSSPropertyWebkitTextStrokeColor: 352 case CSSPropertyWebkitTextStrokeColor:
335 { 353 {
336 RefPtrWillBeRawPtr<Interpolation> interpolation = ColorStyleInterpol ation::maybeCreateFromColor(*fromCSSValue, *toCSSValue, property); 354 RefPtrWillBeRawPtr<Interpolation> interpolation = ColorStyleInterpol ation::maybeCreateFromColor(*fromCSSValue, *toCSSValue, property);
337 if (interpolation) 355 if (interpolation)
338 return interpolation.release(); 356 return interpolation.release();
339 357
340 // Current color should use LegacyStyleInterpolation 358 // Current color should use LegacyStyleInterpolation
341 if (ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*from CSSValue, *toCSSValue)) 359 if (ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*from CSSValue, *toCSSValue))
342 fallBackToLegacy = true; 360 return createLegacyStyleInterpolation(property, end, element, ba seStyle);
343 361
344 break; 362 break;
345 } 363 }
346 364
347 case CSSPropertyBorderImageSource: 365 case CSSPropertyBorderImageSource:
348 case CSSPropertyListStyleImage: 366 case CSSPropertyListStyleImage:
349 case CSSPropertyWebkitMaskBoxImageSource: 367 case CSSPropertyWebkitMaskBoxImageSource:
350 if (fromCSSValue == toCSSValue) 368 if (fromCSSValue == toCSSValue)
351 return ConstantStyleInterpolation::create(fromCSSValue, property); 369 return ConstantStyleInterpolation::create(fromCSSValue, property);
352 370
(...skipping 13 matching lines...) Expand all
366 return LengthPairStyleInterpolation::create(*fromCSSValue, *toCSSVal ue, property, range); 384 return LengthPairStyleInterpolation::create(*fromCSSValue, *toCSSVal ue, property, range);
367 break; 385 break;
368 386
369 case CSSPropertyPerspectiveOrigin: 387 case CSSPropertyPerspectiveOrigin:
370 case CSSPropertyTransformOrigin: { 388 case CSSPropertyTransformOrigin: {
371 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation <LengthStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop erty, range); 389 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation <LengthStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop erty, range);
372 if (interpolation) 390 if (interpolation)
373 return interpolation.release(); 391 return interpolation.release();
374 392
375 // FIXME: Handle keywords: top, right, left, center, bottom 393 // FIXME: Handle keywords: top, right, left, center, bottom
376 fallBackToLegacy = true; 394 return createLegacyStyleInterpolation(property, end, element, baseStyle) ;
377
378 break;
379 } 395 }
380 396
381 case CSSPropertyBoxShadow: 397 case CSSPropertyBoxShadow:
382 case CSSPropertyTextShadow: { 398 case CSSPropertyTextShadow: {
383 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation <ShadowStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop erty); 399 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation <ShadowStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop erty);
384 if (interpolation) 400 if (interpolation)
385 return interpolation.release(); 401 return interpolation.release();
386 402
387 // FIXME: AnimatableShadow incorrectly animates between inset and non-in set values so it will never indicate it needs default interpolation 403 // FIXME: AnimatableShadow incorrectly animates between inset and non-in set values so it will never indicate it needs default interpolation
388 if (ShadowStyleInterpolation::usesDefaultStyleInterpolation(*fromCSSValu e, *toCSSValue)) { 404 if (ShadowStyleInterpolation::usesDefaultStyleInterpolation(*fromCSSValu e, *toCSSValue)) {
389 forceDefaultInterpolation = true; 405 forceDefaultInterpolation = true;
390 break; 406 break;
391 } 407 }
392 408
393 // FIXME: Handle interpolation from/to none, unspecified color values 409 // FIXME: Handle interpolation from/to none, unspecified color values
394 fallBackToLegacy = true; 410 return createLegacyStyleInterpolation(property, end, element, baseStyle) ;
395
396 break;
397
398 } 411 }
399 412
400 case CSSPropertyClip: { 413 case CSSPropertyClip: {
401 if (LengthBoxStyleInterpolation::usesDefaultInterpolation(*fromCSSValue, *toCSSValue)) { 414 if (LengthBoxStyleInterpolation::usesDefaultInterpolation(*fromCSSValue, *toCSSValue)) {
402 forceDefaultInterpolation = true; 415 forceDefaultInterpolation = true;
403 break; 416 break;
404 } 417 }
405 RefPtrWillBeRawPtr<Interpolation> interpolation = LengthBoxStyleInterpol ation::maybeCreateFrom(*fromCSSValue, *toCSSValue, property); 418 RefPtrWillBeRawPtr<Interpolation> interpolation = LengthBoxStyleInterpol ation::maybeCreateFrom(*fromCSSValue, *toCSSValue, property);
406 if (interpolation) 419 if (interpolation)
407 return interpolation.release(); 420 return interpolation.release();
(...skipping 18 matching lines...) Expand all
426 439
427 break; 440 break;
428 } 441 }
429 442
430 case CSSPropertyWebkitFilter: { 443 case CSSPropertyWebkitFilter: {
431 RefPtrWillBeRawPtr<Interpolation> interpolation = FilterStyleInterpolati on::maybeCreateList(*fromCSSValue, *toCSSValue, property); 444 RefPtrWillBeRawPtr<Interpolation> interpolation = FilterStyleInterpolati on::maybeCreateList(*fromCSSValue, *toCSSValue, property);
432 if (interpolation) 445 if (interpolation)
433 return interpolation.release(); 446 return interpolation.release();
434 447
435 // FIXME: Support drop shadow interpolation. 448 // FIXME: Support drop shadow interpolation.
436 fallBackToLegacy = true; 449 return createLegacyStyleInterpolation(property, end, element, baseStyle) ;
437 break; 450 break;
438 } 451 }
439 452
440 case CSSPropertyTranslate: { 453 case CSSPropertyTranslate: {
441 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation <LengthStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop erty, range); 454 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation <LengthStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop erty, range);
442 if (interpolation) 455 if (interpolation)
443 return interpolation.release(); 456 return interpolation.release();
444 457
445 // TODO(soonm): Legacy mode is used when from and to cssvaluelist length does not match. 458 // TODO(soonm): Legacy mode is used when from and to cssvaluelist length does not match.
446 fallBackToLegacy = true; 459 return createLegacyStyleInterpolation(property, end, element, baseStyle) ;
447 break; 460 break;
448 } 461 }
449 462
450 case CSSPropertyScale: { 463 case CSSPropertyScale: {
451 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation <DoubleStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop erty, range); 464 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation <DoubleStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop erty, range);
452 if (interpolation) 465 if (interpolation)
453 return interpolation.release(); 466 return interpolation.release();
454 467
455 // TODO(soonm): Legacy mode is used when from and to cssvaluelist length does not match. 468 // TODO(soonm): Legacy mode is used when from and to cssvaluelist length does not match.
456 fallBackToLegacy = true; 469 return createLegacyStyleInterpolation(property, end, element, baseStyle) ;
457 break; 470 break;
458 } 471 }
459 472
460 default: 473 default:
461 // Fall back to LegacyStyleInterpolation. 474 // Fall back to LegacyStyleInterpolation.
462 fallBackToLegacy = true; 475 return createLegacyStyleInterpolation(property, end, element, baseStyle) ;
463 break; 476 break;
464 } 477 }
465 478
466 if (fromCSSValue == toCSSValue) 479 if (fromCSSValue == toCSSValue)
467 return ConstantStyleInterpolation::create(fromCSSValue, property); 480 return ConstantStyleInterpolation::create(fromCSSValue, property);
468 481
469 if (forceDefaultInterpolation) 482 if (!forceDefaultInterpolation) {
470 return nullptr; 483 ASSERT(AnimatableValue::usesDefaultInterpolation(
471 484 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr operty, fromCSSValue).get(),
472 if (fromCSSValue->isCSSWideKeyword() || toCSSValue->isCSSWideKeyword()) 485 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr operty, toCSSValue).get()));
473 fallBackToLegacy = true;
474
475 if (fallBackToLegacy) {
476 if (DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve( *fromCSSValue) || DeferredLegacyStyleInterpolation::interpolationRequiresStyleRe solve(*toCSSValue)) {
477 // FIXME: Handle these cases outside of DeferredLegacyStyleInterpola tion.
478 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSV alue, property);
479 }
480
481 // FIXME: Remove the use of AnimatableValues and Elements here.
482 ASSERT(element);
483 populateAnimatableValue(property, *element, baseStyle);
484 end.populateAnimatableValue(property, *element, baseStyle);
485 return LegacyStyleInterpolation::create(getAnimatableValue(), end.getAni matableValue(), property);
486 } 486 }
487 487
488 ASSERT(AnimatableValue::usesDefaultInterpolation(
489 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, proper ty, fromCSSValue).get(),
490 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, proper ty, toCSSValue).get()));
491
492 return nullptr; 488 return nullptr;
493 489
494 } 490 }
495 491
496 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr opertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction > easing) const 492 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr opertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction > easing) const
497 { 493 {
498 return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, st atic_cast<CSSValue*>(0), EffectModel::CompositeAdd)); 494 return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, st atic_cast<CSSValue*>(0), EffectModel::CompositeAdd));
499 } 495 }
500 496
501 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr opertySpecificKeyframe::cloneWithOffset(double offset) const 497 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr opertySpecificKeyframe::cloneWithOffset(double offset) const
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase( )->cloneForAnimation(m_value); 600 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase( )->cloneForAnimation(m_value);
605 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()- >cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); 601 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()- >cloneForAnimation(toSVGPropertySpecificKeyframe(end).value());
606 602
607 if (!fromValue || !toValue) 603 if (!fromValue || !toValue)
608 return nullptr; 604 return nullptr;
609 605
610 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get( )); 606 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get( ));
611 } 607 }
612 608
613 } // namespace blink 609 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/StringKeyframe.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698