OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 3 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 || from.left().type() != to.left().type()) | 190 || from.left().type() != to.left().type()) |
191 return to; | 191 return to; |
192 | 192 |
193 LengthBox result(blendFunc(anim, from.top(), to.top(), progress), | 193 LengthBox result(blendFunc(anim, from.top(), to.top(), progress), |
194 blendFunc(anim, from.right(), to.right(), progress), | 194 blendFunc(anim, from.right(), to.right(), progress), |
195 blendFunc(anim, from.bottom(), to.bottom(), progress), | 195 blendFunc(anim, from.bottom(), to.bottom(), progress), |
196 blendFunc(anim, from.left(), to.left(), progress)); | 196 blendFunc(anim, from.left(), to.left(), progress)); |
197 return result; | 197 return result; |
198 } | 198 } |
199 | 199 |
200 static inline SVGLength blendFunc(const AnimationBase*, const SVGLength& from, c
onst SVGLength& to, double progress) | 200 static inline PassRefPtr<SVGLength> blendFunc(const AnimationBase*, PassRefPtr<S
VGLength> from, PassRefPtr<SVGLength> to, double progress) |
201 { | 201 { |
202 return to.blend(from, narrowPrecisionToFloat(progress)); | 202 return to->blend(from, narrowPrecisionToFloat(progress)); |
203 } | 203 } |
204 | 204 |
205 static inline Vector<SVGLength> blendFunc(const AnimationBase*, const Vector<SVG
Length>& from, const Vector<SVGLength>& to, double progress) | 205 static inline PassRefPtr<SVGLengthList> blendFunc(const AnimationBase*, PassRefP
tr<SVGLengthList> passFrom, PassRefPtr<SVGLengthList> passTo, double progress) |
206 { | 206 { |
207 size_t fromLength = from.size(); | 207 RefPtr<SVGLengthList> from = passFrom; |
208 size_t toLength = to.size(); | 208 RefPtr<SVGLengthList> to = passTo; |
| 209 |
| 210 size_t fromLength = from->numberOfItems(); |
| 211 size_t toLength = to->numberOfItems(); |
209 if (!fromLength) | 212 if (!fromLength) |
210 return !progress ? from : to; | 213 return !progress ? from->clone() : to->clone(); |
211 if (!toLength) | 214 if (!toLength) |
212 return progress == 1 ? from : to; | 215 return progress == 1 ? from->clone() : to->clone(); |
213 | 216 |
214 size_t resultLength = fromLength; | 217 size_t resultLength = fromLength; |
215 if (fromLength != toLength) { | 218 if (fromLength != toLength) { |
216 if (!(fromLength % toLength)) | 219 if (!(fromLength % toLength)) |
217 resultLength = fromLength; | 220 resultLength = fromLength; |
218 else if (!(toLength % fromLength)) | 221 else if (!(toLength % fromLength)) |
219 resultLength = toLength; | 222 resultLength = toLength; |
220 else | 223 else |
221 resultLength = fromLength * toLength; | 224 resultLength = fromLength * toLength; |
222 } | 225 } |
223 Vector<SVGLength> result(resultLength); | 226 RefPtr<SVGLengthList> result = SVGLengthList::create(); |
224 for (size_t i = 0; i < resultLength; ++i) | 227 for (size_t i = 0; i < resultLength; ++i) |
225 result[i] = to[i % toLength].blend(from[i % fromLength], narrowPrecision
ToFloat(progress)); | 228 result->append(to->at(i % toLength)->blend(from->at(i % fromLength), nar
rowPrecisionToFloat(progress))); |
226 return result; | 229 return result; |
227 } | 230 } |
228 | 231 |
229 static inline PassRefPtr<StyleImage> crossfadeBlend(const AnimationBase*, StyleF
etchedImage* fromStyleImage, StyleFetchedImage* toStyleImage, double progress) | 232 static inline PassRefPtr<StyleImage> crossfadeBlend(const AnimationBase*, StyleF
etchedImage* fromStyleImage, StyleFetchedImage* toStyleImage, double progress) |
230 { | 233 { |
231 // If progress is at one of the extremes, we want getComputedStyle to show t
he image, | 234 // If progress is at one of the extremes, we want getComputedStyle to show t
he image, |
232 // not a completed cross-fade, so we hand back one of the existing images. | 235 // not a completed cross-fade, so we hand back one of the existing images. |
233 if (!progress) | 236 if (!progress) |
234 return fromStyleImage; | 237 return fromStyleImage; |
235 if (progress == 1) | 238 if (progress == 1) |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 toColor = Color(); | 895 toColor = Color(); |
893 (dst->*m_setter)(blendFunc(anim, fromColor, toColor, progress)); | 896 (dst->*m_setter)(blendFunc(anim, fromColor, toColor, progress)); |
894 } | 897 } |
895 | 898 |
896 private: | 899 private: |
897 const SVGPaint::SVGPaintType& (RenderStyle::*m_paintTypeGetter)() const; | 900 const SVGPaint::SVGPaintType& (RenderStyle::*m_paintTypeGetter)() const; |
898 Color (RenderStyle::*m_getter)() const; | 901 Color (RenderStyle::*m_getter)() const; |
899 void (RenderStyle::*m_setter)(const Color&); | 902 void (RenderStyle::*m_setter)(const Color&); |
900 }; | 903 }; |
901 | 904 |
| 905 template <typename T> |
| 906 class RefCountedSVGPropertyWrapper : public AnimationPropertyWrapperBase { |
| 907 public: |
| 908 RefCountedSVGPropertyWrapper(CSSPropertyID prop, PassRefPtr<T> (RenderStyle:
:*getter)() const, void (RenderStyle::*setter)(PassRefPtr<T>)) |
| 909 : AnimationPropertyWrapperBase(prop) |
| 910 , m_getter(getter) |
| 911 , m_setter(setter) |
| 912 { |
| 913 } |
| 914 |
| 915 virtual void blend(const AnimationBase* anim, RenderStyle* dst, const Render
Style* a, const RenderStyle* b, double progress) const |
| 916 { |
| 917 (dst->*m_setter)(blendFunc(anim, (a->*m_getter)(), (b->*m_getter)(), pro
gress)); |
| 918 } |
| 919 |
| 920 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const OVERRI
DE |
| 921 { |
| 922 if (a == b) |
| 923 return true; |
| 924 if (!a || !b) |
| 925 return false; |
| 926 RefPtr<T> aValue = (a->*this->m_getter)(); |
| 927 RefPtr<T> bValue = (b->*this->m_getter)(); |
| 928 if (aValue == bValue) |
| 929 return true; |
| 930 if (!aValue || !bValue) |
| 931 return false; |
| 932 return *aValue == *bValue; |
| 933 } |
| 934 |
| 935 protected: |
| 936 PassRefPtr<T> (RenderStyle::*m_getter)() const; |
| 937 void (RenderStyle::*m_setter)(PassRefPtr<T>); |
| 938 }; |
| 939 |
902 static void addShorthandProperties() | 940 static void addShorthandProperties() |
903 { | 941 { |
904 static const CSSPropertyID animatableShorthandProperties[] = { | 942 static const CSSPropertyID animatableShorthandProperties[] = { |
905 CSSPropertyBackground, // for background-color, background-position, bac
kground-image | 943 CSSPropertyBackground, // for background-color, background-position, bac
kground-image |
906 CSSPropertyBackgroundPosition, | 944 CSSPropertyBackgroundPosition, |
907 CSSPropertyFont, // for font-size, font-weight | 945 CSSPropertyFont, // for font-size, font-weight |
908 CSSPropertyWebkitMask, // for mask-position | 946 CSSPropertyWebkitMask, // for mask-position |
909 CSSPropertyWebkitMaskPosition, | 947 CSSPropertyWebkitMaskPosition, |
910 CSSPropertyBorderTop, CSSPropertyBorderRight, CSSPropertyBorderBottom, C
SSPropertyBorderLeft, | 948 CSSPropertyBorderTop, CSSPropertyBorderRight, CSSPropertyBorderBottom, C
SSPropertyBorderLeft, |
911 CSSPropertyBorderColor, | 949 CSSPropertyBorderColor, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1095 |
1058 gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyBoxShadow, &R
enderStyle::boxShadow, &RenderStyle::setBoxShadow)); | 1096 gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyBoxShadow, &R
enderStyle::boxShadow, &RenderStyle::setBoxShadow)); |
1059 gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyWebkitBoxShad
ow, &RenderStyle::boxShadow, &RenderStyle::setBoxShadow)); | 1097 gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyWebkitBoxShad
ow, &RenderStyle::boxShadow, &RenderStyle::setBoxShadow)); |
1060 gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyTextShadow, &
RenderStyle::textShadow, &RenderStyle::setTextShadow)); | 1098 gPropertyWrappers->append(new PropertyWrapperShadow(CSSPropertyTextShadow, &
RenderStyle::textShadow, &RenderStyle::setTextShadow)); |
1061 | 1099 |
1062 gPropertyWrappers->append(new PropertyWrapperSVGPaint(CSSPropertyFill, &Rend
erStyle::fillPaintType, &RenderStyle::fillPaintColor, &RenderStyle::setFillPaint
Color)); | 1100 gPropertyWrappers->append(new PropertyWrapperSVGPaint(CSSPropertyFill, &Rend
erStyle::fillPaintType, &RenderStyle::fillPaintColor, &RenderStyle::setFillPaint
Color)); |
1063 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFillOpacity,
&RenderStyle::fillOpacity, &RenderStyle::setFillOpacity)); | 1101 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFillOpacity,
&RenderStyle::fillOpacity, &RenderStyle::setFillOpacity)); |
1064 | 1102 |
1065 gPropertyWrappers->append(new PropertyWrapperSVGPaint(CSSPropertyStroke, &Re
nderStyle::strokePaintType, &RenderStyle::strokePaintColor, &RenderStyle::setStr
okePaintColor)); | 1103 gPropertyWrappers->append(new PropertyWrapperSVGPaint(CSSPropertyStroke, &Re
nderStyle::strokePaintType, &RenderStyle::strokePaintColor, &RenderStyle::setStr
okePaintColor)); |
1066 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyStrokeOpacit
y, &RenderStyle::strokeOpacity, &RenderStyle::setStrokeOpacity)); | 1104 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyStrokeOpacit
y, &RenderStyle::strokeOpacity, &RenderStyle::setStrokeOpacity)); |
1067 gPropertyWrappers->append(new PropertyWrapper<SVGLength>(CSSPropertyStrokeWi
dth, &RenderStyle::strokeWidth, &RenderStyle::setStrokeWidth)); | 1105 gPropertyWrappers->append(new RefCountedSVGPropertyWrapper<SVGLength>(CSSPro
pertyStrokeWidth, &RenderStyle::strokeWidth, &RenderStyle::setStrokeWidth)); |
1068 gPropertyWrappers->append(new PropertyWrapper< Vector<SVGLength> >(CSSProper
tyStrokeDasharray, &RenderStyle::strokeDashArray, &RenderStyle::setStrokeDashArr
ay)); | 1106 gPropertyWrappers->append(new RefCountedSVGPropertyWrapper<SVGLengthList>(CS
SPropertyStrokeDasharray, &RenderStyle::strokeDashArray, &RenderStyle::setStroke
DashArray)); |
1069 gPropertyWrappers->append(new PropertyWrapper<SVGLength>(CSSPropertyStrokeDa
shoffset, &RenderStyle::strokeDashOffset, &RenderStyle::setStrokeDashOffset)); | 1107 gPropertyWrappers->append(new RefCountedSVGPropertyWrapper<SVGLength>(CSSPro
pertyStrokeDashoffset, &RenderStyle::strokeDashOffset, &RenderStyle::setStrokeDa
shOffset)); |
1070 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyStrokeMiterl
imit, &RenderStyle::strokeMiterLimit, &RenderStyle::setStrokeMiterLimit)); | 1108 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyStrokeMiterl
imit, &RenderStyle::strokeMiterLimit, &RenderStyle::setStrokeMiterLimit)); |
1071 | 1109 |
1072 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFloodOpacity
, &RenderStyle::floodOpacity, &RenderStyle::setFloodOpacity)); | 1110 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFloodOpacity
, &RenderStyle::floodOpacity, &RenderStyle::setFloodOpacity)); |
1073 gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyFl
oodColor, &RenderStyle::floodColor, &RenderStyle::setFloodColor)); | 1111 gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyFl
oodColor, &RenderStyle::floodColor, &RenderStyle::setFloodColor)); |
1074 | 1112 |
1075 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyStopOpacity,
&RenderStyle::stopOpacity, &RenderStyle::setStopOpacity)); | 1113 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyStopOpacity,
&RenderStyle::stopOpacity, &RenderStyle::setStopOpacity)); |
1076 gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertySt
opColor, &RenderStyle::stopColor, &RenderStyle::setStopColor)); | 1114 gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertySt
opColor, &RenderStyle::stopColor, &RenderStyle::setStopColor)); |
1077 | 1115 |
1078 gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyLi
ghtingColor, &RenderStyle::lightingColor, &RenderStyle::setLightingColor)); | 1116 gPropertyWrappers->append(new PropertyWrapperMaybeInvalidColor(CSSPropertyLi
ghtingColor, &RenderStyle::lightingColor, &RenderStyle::setLightingColor)); |
1079 | 1117 |
1080 gPropertyWrappers->append(new PropertyWrapper<SVGLength>(CSSPropertyBaseline
Shift, &RenderStyle::baselineShiftValue, &RenderStyle::setBaselineShiftValue)); | 1118 gPropertyWrappers->append(new RefCountedSVGPropertyWrapper<SVGLength>(CSSPro
pertyBaselineShift, &RenderStyle::baselineShiftValue, &RenderStyle::setBaselineS
hiftValue)); |
1081 gPropertyWrappers->append(new PropertyWrapper<SVGLength>(CSSPropertyKerning,
&RenderStyle::kerning, &RenderStyle::setKerning)); | 1119 gPropertyWrappers->append(new RefCountedSVGPropertyWrapper<SVGLength>(CSSPro
pertyKerning, &RenderStyle::kerning, &RenderStyle::setKerning)); |
1082 | 1120 |
1083 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { | 1121 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { |
1084 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFlexGrow
, &RenderStyle::flexGrow, &RenderStyle::setFlexGrow)); | 1122 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFlexGrow
, &RenderStyle::flexGrow, &RenderStyle::setFlexGrow)); |
1085 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFlexShri
nk, &RenderStyle::flexShrink, &RenderStyle::setFlexShrink)); | 1123 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFlexShri
nk, &RenderStyle::flexShrink, &RenderStyle::setFlexShrink)); |
1086 gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyFlexBas
is, &RenderStyle::flexBasis, &RenderStyle::setFlexBasis)); | 1124 gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyFlexBas
is, &RenderStyle::flexBasis, &RenderStyle::setFlexBasis)); |
1087 } | 1125 } |
1088 | 1126 |
1089 // TODO: | 1127 // TODO: |
1090 // | 1128 // |
1091 // CSSPropertyVerticalAlign | 1129 // CSSPropertyVerticalAlign |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 } | 1197 } |
1160 | 1198 |
1161 int CSSPropertyAnimation::getNumProperties() | 1199 int CSSPropertyAnimation::getNumProperties() |
1162 { | 1200 { |
1163 ensurePropertyMap(); | 1201 ensurePropertyMap(); |
1164 | 1202 |
1165 return gPropertyWrappers->size(); | 1203 return gPropertyWrappers->size(); |
1166 } | 1204 } |
1167 | 1205 |
1168 } | 1206 } |
OLD | NEW |