Diff
Modified: trunk/Source/WebCore/ChangeLog (149660 => 149661)
--- trunk/Source/WebCore/ChangeLog 2013-05-07 04:15:05 UTC (rev 149660)
+++ trunk/Source/WebCore/ChangeLog 2013-05-07 04:31:35 UTC (rev 149661)
@@ -1,3 +1,41 @@
+2013-05-06 Darin Adler <[email protected]>
+
+ Use OwnPtr instead of deleteAllValues in KeyframeValueList
+ https://bugs.webkit.org/show_bug.cgi?id=115652
+
+ Reviewed by Simon Fraser.
+
+ Also made a few related style fixes in the functions touched.
+
+ * platform/graphics/GraphicsLayer.cpp:
+ (WebCore::KeyframeValueList::insert): Change argument type to PassOwnPtr
+ and update use of m_values since it has OwnPtr now instead of raw pointer.
+
+ * platform/graphics/GraphicsLayer.h: Move conditional includes to a
+ separate paragraph, removed an unneeded forward class declaration.
+ (WebCore::AnimationValue::AnimationValue): Marked this constructor explicit
+ and removed an unneeded if statement.
+ (WebCore::AnimationValue::clone): Changed to use adoptPtr and PassOwnPtr.
+ (WebCore::FloatAnimationValue::clone): Changed this to return a PassOwnPtr.
+ (WebCore::TransformAnimationValue::TransformAnimationValue): Marked explicit.
+ (WebCore::TransformAnimationValue::clone): Changed to use adoptPtr and PassOwnPtr.
+ (WebCore::FilterAnimationValue::FilterAnimationValue): Marked explicit.
+ (WebCore::FilterAnimationValue::clone): Changed to use adoptPtr and PassOwnPtr.
+ (WebCore::KeyframeValueList::KeyframeValueList): Marked explicit.
+ (WebCore::KeyframeValueList::~KeyframeValueList): Removed, since the default
+ destructor works without an explicit deleteAllValues call.
+ (WebCore::KeyframeValueList::at): Added call to get needed since the vector
+ contains OwnPtr now.
+ (WebCore::KeyframeValueList::insert): Changed to take PassOwnPtr and then
+ removed now-redundant comment saying "takes ownership of the pointer".
+ (WebCore::KeyframeValueList::m_values): Changed type to Vector<OwnPtr>.
+
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::startAnimation): Added adoptPtr next to the
+ all the places new was done before calling KeyframeValueList::insert. Also
+ simplified the booleans and #if in this function.
+ (WebCore::RenderLayerBacking::startTransition): Ditto.
+
2013-05-06 Ryosuke Niwa <[email protected]>
[Replaceable] attributes must be readonly
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (149660 => 149661)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2013-05-07 04:15:05 UTC (rev 149660)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2013-05-07 04:31:35 UTC (rev 149661)
@@ -53,10 +53,10 @@
return map;
}
-void KeyframeValueList::insert(const AnimationValue* value)
+void KeyframeValueList::insert(PassOwnPtr<const AnimationValue> value)
{
for (size_t i = 0; i < m_values.size(); ++i) {
- const AnimationValue* curValue = m_values[i];
+ const AnimationValue* curValue = m_values[i].get();
if (curValue->keyTime() == value->keyTime()) {
ASSERT_NOT_REACHED();
// insert after
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (149660 => 149661)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h 2013-05-07 04:15:05 UTC (rev 149660)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h 2013-05-07 04:31:35 UTC (rev 149661)
@@ -30,9 +30,6 @@
#include "Animation.h"
#include "Color.h"
-#if ENABLE(CSS_FILTERS)
-#include "FilterOperations.h"
-#endif
#include "FloatPoint.h"
#include "FloatPoint3D.h"
#include "FloatSize.h"
@@ -43,6 +40,10 @@
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#if ENABLE(CSS_FILTERS)
+#include "FilterOperations.h"
+#endif
+
enum LayerTreeAsTextBehaviorFlags {
LayerTreeAsTextBehaviorNormal = 0,
LayerTreeAsTextDebug = 1 << 0, // Dump extra debugging info like layer addresses.
@@ -55,7 +56,6 @@
namespace WebCore {
-class FloatPoint3D;
class FloatRect;
class GraphicsContext;
class GraphicsLayerFactory;
@@ -68,21 +68,21 @@
// Base class for animation values (also used for transitions). Here to
// represent values for properties being animated via the GraphicsLayer,
// without pulling in style-related data from outside of the platform directory.
+// FIXME: Should be moved to its own header file.
class AnimationValue {
WTF_MAKE_FAST_ALLOCATED;
public:
- AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0)
+ explicit AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0)
: m_keyTime(keyTime)
+ , m_timingFunction(timingFunction)
{
- if (timingFunction)
- m_timingFunction = timingFunction;
}
virtual ~AnimationValue() { }
float keyTime() const { return m_keyTime; }
const TimingFunction* timingFunction() const { return m_timingFunction.get(); }
- virtual AnimationValue* clone() const = 0;
+ virtual PassOwnPtr<AnimationValue> clone() const = 0;
private:
float m_keyTime;
@@ -90,6 +90,7 @@
};
// Used to store one float value of an animation.
+// FIXME: Should be moved to its own header file.
class FloatAnimationValue : public AnimationValue {
public:
FloatAnimationValue(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction = 0)
@@ -97,7 +98,7 @@
, m_value(value)
{
}
- virtual AnimationValue* clone() const { return new FloatAnimationValue(*this); }
+ virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new FloatAnimationValue(*this)); }
float value() const { return m_value; }
@@ -106,15 +107,16 @@
};
// Used to store one transform value in a keyframe list.
+// FIXME: Should be moved to its own header file.
class TransformAnimationValue : public AnimationValue {
public:
- TransformAnimationValue(float keyTime, const TransformOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0)
+ explicit TransformAnimationValue(float keyTime, const TransformOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0)
: AnimationValue(keyTime, timingFunction)
{
if (value)
m_value = *value;
}
- virtual AnimationValue* clone() const { return new TransformAnimationValue(*this); }
+ virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new TransformAnimationValue(*this)); }
const TransformOperations* value() const { return &m_value; }
@@ -124,15 +126,16 @@
#if ENABLE(CSS_FILTERS)
// Used to store one filter value in a keyframe list.
+// FIXME: Should be moved to its own header file.
class FilterAnimationValue : public AnimationValue {
public:
- FilterAnimationValue(float keyTime, const FilterOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0)
+ explicit FilterAnimationValue(float keyTime, const FilterOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0)
: AnimationValue(keyTime, timingFunction)
{
if (value)
m_value = *value;
}
- virtual AnimationValue* clone() const { return new FilterAnimationValue(*this); }
+ virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new FilterAnimationValue(*this)); }
const FilterOperations* value() const { return &m_value; }
@@ -141,12 +144,12 @@
};
#endif
-// Used to store a series of values in a keyframe list. Values will all be of the same type,
-// which can be inferred from the property.
+// Used to store a series of values in a keyframe list.
+// Values will all be of the same type, which can be inferred from the property.
+// FIXME: Should be moved to its own header file.
class KeyframeValueList {
public:
-
- KeyframeValueList(AnimatedPropertyID property)
+ explicit KeyframeValueList(AnimatedPropertyID property)
: m_property(property)
{
}
@@ -158,11 +161,6 @@
m_values.append(other.m_values[i]->clone());
}
- ~KeyframeValueList()
- {
- deleteAllValues(m_values);
- }
-
KeyframeValueList& operator=(const KeyframeValueList& other)
{
KeyframeValueList copy(other);
@@ -179,18 +177,16 @@
AnimatedPropertyID property() const { return m_property; }
size_t size() const { return m_values.size(); }
- const AnimationValue* at(size_t i) const { return m_values.at(i); }
+ const AnimationValue* at(size_t i) const { return m_values.at(i).get(); }
- // Insert, sorted by keyTime. Takes ownership of the pointer.
- void insert(const AnimationValue*);
+ // Insert, sorted by keyTime.
+ void insert(PassOwnPtr<const AnimationValue>);
protected:
- Vector<const AnimationValue*> m_values;
+ Vector<OwnPtr<const AnimationValue> > m_values;
AnimatedPropertyID m_property;
};
-
-
// GraphicsLayer is an abstraction for a rendering surface with backing store,
// which may have associated transformation and animations.
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (149660 => 149661)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2013-05-07 04:15:05 UTC (rev 149660)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2013-05-07 04:31:35 UTC (rev 149661)
@@ -2107,39 +2107,31 @@
bool isFirstOrLastKeyframe = key == 0 || key == 1;
if ((hasTransform && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyWebkitTransform))
- transformVector.insert(new TransformAnimationValue(key, &(keyframeStyle->transform()), tf));
+ transformVector.insert(adoptPtr(new TransformAnimationValue(key, &(keyframeStyle->transform()), tf)));
if ((hasOpacity && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyOpacity))
- opacityVector.insert(new FloatAnimationValue(key, keyframeStyle->opacity(), tf));
+ opacityVector.insert(adoptPtr(new FloatAnimationValue(key, keyframeStyle->opacity(), tf)));
#if ENABLE(CSS_FILTERS)
if ((hasFilter && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyWebkitFilter))
- filterVector.insert(new FilterAnimationValue(key, &(keyframeStyle->filter()), tf));
+ filterVector.insert(adoptPtr(new FilterAnimationValue(key, &(keyframeStyle->filter()), tf)));
#endif
}
- bool didAnimateTransform = false;
- bool didAnimateOpacity = false;
-#if ENABLE(CSS_FILTERS)
- bool didAnimateFilter = false;
-#endif
+ bool didAnimate = false;
if (hasTransform && m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer())->pixelSnappedBorderBoxRect().size(), anim, keyframes.animationName(), timeOffset))
- didAnimateTransform = true;
+ didAnimate = true;
if (hasOpacity && m_graphicsLayer->addAnimation(opacityVector, IntSize(), anim, keyframes.animationName(), timeOffset))
- didAnimateOpacity = true;
+ didAnimate = true;
#if ENABLE(CSS_FILTERS)
if (hasFilter && m_graphicsLayer->addAnimation(filterVector, IntSize(), anim, keyframes.animationName(), timeOffset))
- didAnimateFilter = true;
+ didAnimate = true;
#endif
-#if ENABLE(CSS_FILTERS)
- return didAnimateTransform || didAnimateOpacity || didAnimateFilter;
-#else
- return didAnimateTransform || didAnimateOpacity;
-#endif
+ return didAnimate;
}
void RenderLayerBacking::animationPaused(double timeOffset, const String& animationName)
@@ -2154,11 +2146,7 @@
bool RenderLayerBacking::startTransition(double timeOffset, CSSPropertyID property, const RenderStyle* fromStyle, const RenderStyle* toStyle)
{
- bool didAnimateOpacity = false;
- bool didAnimateTransform = false;
-#if ENABLE(CSS_FILTERS)
- bool didAnimateFilter = false;
-#endif
+ bool didAnimate = false;
ASSERT(property != CSSPropertyInvalid);
@@ -2166,13 +2154,13 @@
const Animation* opacityAnim = toStyle->transitionForProperty(CSSPropertyOpacity);
if (opacityAnim && !opacityAnim->isEmptyOrZeroDuration()) {
KeyframeValueList opacityVector(AnimatedPropertyOpacity);
- opacityVector.insert(new FloatAnimationValue(0, compositingOpacity(fromStyle->opacity())));
- opacityVector.insert(new FloatAnimationValue(1, compositingOpacity(toStyle->opacity())));
+ opacityVector.insert(adoptPtr(new FloatAnimationValue(0, compositingOpacity(fromStyle->opacity()))));
+ opacityVector.insert(adoptPtr(new FloatAnimationValue(1, compositingOpacity(toStyle->opacity()))));
// The boxSize param is only used for transform animations (which can only run on RenderBoxes), so we pass an empty size here.
if (m_graphicsLayer->addAnimation(opacityVector, IntSize(), opacityAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyOpacity), timeOffset)) {
// To ensure that the correct opacity is visible when the animation ends, also set the final opacity.
updateOpacity(toStyle);
- didAnimateOpacity = true;
+ didAnimate = true;
}
}
}
@@ -2181,12 +2169,12 @@
const Animation* transformAnim = toStyle->transitionForProperty(CSSPropertyWebkitTransform);
if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) {
KeyframeValueList transformVector(AnimatedPropertyWebkitTransform);
- transformVector.insert(new TransformAnimationValue(0, &fromStyle->transform()));
- transformVector.insert(new TransformAnimationValue(1, &toStyle->transform()));
+ transformVector.insert(adoptPtr(new TransformAnimationValue(0, &fromStyle->transform())));
+ transformVector.insert(adoptPtr(new TransformAnimationValue(1, &toStyle->transform())));
if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer())->pixelSnappedBorderBoxRect().size(), transformAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitTransform), timeOffset)) {
// To ensure that the correct transform is visible when the animation ends, also set the final transform.
updateTransform(toStyle);
- didAnimateTransform = true;
+ didAnimate = true;
}
}
}
@@ -2196,22 +2184,18 @@
const Animation* filterAnim = toStyle->transitionForProperty(CSSPropertyWebkitFilter);
if (filterAnim && !filterAnim->isEmptyOrZeroDuration()) {
KeyframeValueList filterVector(AnimatedPropertyWebkitFilter);
- filterVector.insert(new FilterAnimationValue(0, &fromStyle->filter()));
- filterVector.insert(new FilterAnimationValue(1, &toStyle->filter()));
+ filterVector.insert(adoptPtr(new FilterAnimationValue(0, &fromStyle->filter())));
+ filterVector.insert(adoptPtr(new FilterAnimationValue(1, &toStyle->filter())));
if (m_graphicsLayer->addAnimation(filterVector, IntSize(), filterAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitFilter), timeOffset)) {
// To ensure that the correct filter is visible when the animation ends, also set the final filter.
updateFilters(toStyle);
- didAnimateFilter = true;
+ didAnimate = true;
}
}
}
#endif
-#if ENABLE(CSS_FILTERS)
- return didAnimateOpacity || didAnimateTransform || didAnimateFilter;
-#else
- return didAnimateOpacity || didAnimateTransform;
-#endif
+ return didAnimate;
}
void RenderLayerBacking::transitionPaused(double timeOffset, CSSPropertyID property)
Modified: trunk/Source/WebKit2/ChangeLog (149660 => 149661)
--- trunk/Source/WebKit2/ChangeLog 2013-05-07 04:15:05 UTC (rev 149660)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-07 04:31:35 UTC (rev 149661)
@@ -1,3 +1,14 @@
+2013-05-06 Darin Adler <[email protected]>
+
+ Use OwnPtr instead of deleteAllValues in KeyframeValueList
+ https://bugs.webkit.org/show_bug.cgi?id=115652
+
+ Reviewed by Simon Fraser.
+
+ * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+ (CoreIPC::ArgumentCoder<GraphicsLayerAnimation>::decode): Added adoptPtr
+ next to new when calling KeyframeValueList::insert.
+
2013-05-06 Gyuyoung Kim <[email protected]>
Unreviewed, build fix on EFL port
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp (149660 => 149661)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp 2013-05-07 04:15:05 UTC (rev 149660)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp 2013-05-07 04:31:35 UTC (rev 149661)
@@ -733,14 +733,14 @@
float value;
if (!decoder.decode(value))
return false;
- keyframes.insert(new FloatAnimationValue(keyTime, value, timingFunction));
+ keyframes.insert(adoptPtr(new FloatAnimationValue(keyTime, value, timingFunction)));
break;
}
case AnimatedPropertyWebkitTransform: {
TransformOperations transform;
if (!decoder.decode(transform))
return false;
- keyframes.insert(new TransformAnimationValue(keyTime, &transform, timingFunction));
+ keyframes.insert(adoptPtr(new TransformAnimationValue(keyTime, &transform, timingFunction)));
break;
}
#if ENABLE(CSS_FILTERS)
@@ -748,7 +748,7 @@
FilterOperations filter;
if (!decoder.decode(filter))
return false;
- keyframes.insert(new FilterAnimationValue(keyTime, &filter, timingFunction));
+ keyframes.insert(adoptPtr(new FilterAnimationValue(keyTime, &filter, timingFunction)));
break;
}
#endif