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

Side by Side Diff: Source/core/animation/AnimatableValue.h

Issue 26247003: Web Animations CSS: Support animation of background-position and background-image (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review changes Created 7 years, 2 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 /* 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 bool isClipPathOperation() const { return type() == TypeClipPathOperation; } 54 bool isClipPathOperation() const { return type() == TypeClipPathOperation; }
55 bool isColor() const { return type() == TypeColor; } 55 bool isColor() const { return type() == TypeColor; }
56 bool isDouble() const { return type() == TypeDouble; } 56 bool isDouble() const { return type() == TypeDouble; }
57 bool isImage() const { return type() == TypeImage; } 57 bool isImage() const { return type() == TypeImage; }
58 bool isLength() const { return type() == TypeLength; } 58 bool isLength() const { return type() == TypeLength; }
59 bool isLengthBox() const { return type() == TypeLengthBox; } 59 bool isLengthBox() const { return type() == TypeLengthBox; }
60 bool isLengthSize() const { return type() == TypeLengthSize; } 60 bool isLengthSize() const { return type() == TypeLengthSize; }
61 bool isNeutral() const { return type() == TypeNeutral; } 61 bool isNeutral() const { return type() == TypeNeutral; }
62 bool isRepeatable() const { return type() == TypeRepeatable; }
62 bool isSVGLength() const { return type() == TypeSVGLength; } 63 bool isSVGLength() const { return type() == TypeSVGLength; }
63 bool isShapeValue() const { return type() == TypeShapeValue; } 64 bool isShapeValue() const { return type() == TypeShapeValue; }
64 bool isSVGPaint() const { return type() == TypeSVGPaint; } 65 bool isSVGPaint() const { return type() == TypeSVGPaint; }
65 bool isTransform() const { return type() == TypeTransform; } 66 bool isTransform() const { return type() == TypeTransform; }
66 bool isUnknown() const { return type() == TypeUnknown; } 67 bool isUnknown() const { return type() == TypeUnknown; }
67 bool isVisibility() const { return type() == TypeVisibility; } 68 bool isVisibility() const { return type() == TypeVisibility; }
68 69
70 bool isSameType(const AnimatableValue* value) const
71 {
72 ASSERT(value);
73 return value->type() == type();
74 }
75
69 protected: 76 protected:
70 enum AnimatableType { 77 enum AnimatableType {
71 TypeClipPathOperation, 78 TypeClipPathOperation,
72 TypeColor, 79 TypeColor,
73 TypeDouble, 80 TypeDouble,
74 TypeImage, 81 TypeImage,
75 TypeLength, 82 TypeLength,
76 TypeLengthBox, 83 TypeLengthBox,
77 TypeLengthSize, 84 TypeLengthSize,
78 TypeNeutral, 85 TypeNeutral,
86 TypeRepeatable,
79 TypeSVGLength, 87 TypeSVGLength,
80 TypeShapeValue, 88 TypeShapeValue,
81 TypeSVGPaint, 89 TypeSVGPaint,
82 TypeTransform, 90 TypeTransform,
83 TypeUnknown, 91 TypeUnknown,
84 TypeVisibility, 92 TypeVisibility,
85 }; 93 };
86 94
87 bool isSameType(const AnimatableValue* value) const
88 {
89 ASSERT(value);
90 return value->type() == type();
91 }
92
93 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do uble fraction) const = 0; 95 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do uble fraction) const = 0;
94 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f raction < 0.5) ? left : right); } 96 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f raction < 0.5) ? left : right); }
95 97
96 // For noncommutative values read A->addWith(B) to mean the value A with B c omposed onto it. 98 // For noncommutative values read A->addWith(B) to mean the value A with B c omposed onto it.
97 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const; 99 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const;
98 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef t, const AnimatableValue* right) { return takeConstRef(right); } 100 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef t, const AnimatableValue* right) { return takeConstRef(right); }
99 101
100 template <class T> 102 template <class T>
101 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con st_cast<T*>(value)); } 103 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con st_cast<T*>(value)); }
102 104
103 private: 105 private:
104 virtual AnimatableType type() const = 0; 106 virtual AnimatableType type() const = 0;
105 // Implementations can assume that the object being compared has the same ty pe as the object this is called on 107 // Implementations can assume that the object being compared has the same ty pe as the object this is called on
106 virtual bool equalTo(const AnimatableValue*) const = 0; 108 virtual bool equalTo(const AnimatableValue*) const = 0;
107 }; 109 };
108 110
109 } // namespace WebCore 111 } // namespace WebCore
110 112
111 #endif // AnimatableValue_h 113 #endif // AnimatableValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698