https://bugs.webkit.org/show_bug.cgi?id=123467
Reviewed by Anders Carlsson.
Manage SVGPathByteStream objects through std::unique_ptr. Constructors for the class are made public
so std::make_unique can be used with the class.
* svg/SVGAnimatedPath.cpp:
(WebCore::SVGAnimatedPathAnimator::constructFromString):
(WebCore::SVGAnimatedPathAnimator::startAnimValAnimation):
(WebCore::SVGAnimatedPathAnimator::calculateAnimatedValue):
* svg/SVGAnimatedType.cpp:
(WebCore::SVGAnimatedType::createPath):
* svg/SVGAnimatedType.h:
* svg/SVGPathByteStream.h:
(WebCore::SVGPathByteStream::SVGPathByteStream): Takes a const Data object that's then copied.
(WebCore::SVGPathByteStream::copy): Made const.
* svg/SVGPathByteStreamBuilder.cpp: Remove an unnecessary include.
* svg/SVGPathByteStreamBuilder.h: Ditto.
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::SVGPathElement):
* svg/SVGPathElement.h:
* svg/SVGPathUtilities.cpp:
(WebCore::appendSVGPathByteStreamFromSVGPathSeg):
(WebCore::addToSVGPathByteStream):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158359
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-10-31 Zan Dobersek <zdobersek@igalia.com>
+
+ Manage SVGPathByteStream through std::unique_ptr
+ https://bugs.webkit.org/show_bug.cgi?id=123467
+
+ Reviewed by Anders Carlsson.
+
+ Manage SVGPathByteStream objects through std::unique_ptr. Constructors for the class are made public
+ so std::make_unique can be used with the class.
+
+ * svg/SVGAnimatedPath.cpp:
+ (WebCore::SVGAnimatedPathAnimator::constructFromString):
+ (WebCore::SVGAnimatedPathAnimator::startAnimValAnimation):
+ (WebCore::SVGAnimatedPathAnimator::calculateAnimatedValue):
+ * svg/SVGAnimatedType.cpp:
+ (WebCore::SVGAnimatedType::createPath):
+ * svg/SVGAnimatedType.h:
+ * svg/SVGPathByteStream.h:
+ (WebCore::SVGPathByteStream::SVGPathByteStream): Takes a const Data object that's then copied.
+ (WebCore::SVGPathByteStream::copy): Made const.
+ * svg/SVGPathByteStreamBuilder.cpp: Remove an unnecessary include.
+ * svg/SVGPathByteStreamBuilder.h: Ditto.
+ * svg/SVGPathElement.cpp:
+ (WebCore::SVGPathElement::SVGPathElement):
+ * svg/SVGPathElement.h:
+ * svg/SVGPathUtilities.cpp:
+ (WebCore::appendSVGPathByteStreamFromSVGPathSeg):
+ (WebCore::addToSVGPathByteStream):
+
2013-10-31 Marcin Bychawski <m.bychawski@samsung.com>
Removing m_maxDeadCapacity condition in fast path in MemoryCache::prune().
PassOwnPtr<SVGAnimatedType> SVGAnimatedPathAnimator::constructFromString(const String& string)
{
- OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create();
+ auto byteStream = std::make_unique<SVGPathByteStream>();
buildSVGPathByteStreamFromString(string, byteStream.get(), UnalteredParsing);
- return SVGAnimatedType::createPath(byteStream.release());
+ return SVGAnimatedType::createPath(std::move(byteStream));
}
PassOwnPtr<SVGAnimatedType> SVGAnimatedPathAnimator::startAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
const SVGPathSegList& baseValue = property->currentBaseValue();
// Build initial path byte stream.
- OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create();
+ auto byteStream = std::make_unique<SVGPathByteStream>();
buildSVGPathByteStreamFromSVGPathSegList(baseValue, byteStream.get(), UnalteredParsing);
Vector<RefPtr<SVGAnimatedPathSegListPropertyTearOff>> result;
for (size_t i = 0; i < resultSize; ++i)
result[i]->animationStarted(byteStream.get(), &baseValue);
- return SVGAnimatedType::createPath(byteStream.release());
+ return SVGAnimatedType::createPath(std::move(byteStream));
}
void SVGAnimatedPathAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
SVGPathByteStream* toAtEndOfDurationPath = toAtEndOfDuration->path();
SVGPathByteStream* animatedPath = animated->path();
- OwnPtr<SVGPathByteStream> underlyingPath;
+ std::unique_ptr<SVGPathByteStream> underlyingPath;
bool isToAnimation = m_animationElement->animationMode() == ToAnimation;
if (isToAnimation) {
underlyingPath = animatedPath->copy();
}
// Cache the current animated value before the buildAnimatedSVGPathByteStream() clears animatedPath.
- OwnPtr<SVGPathByteStream> lastAnimatedPath;
+ std::unique_ptr<SVGPathByteStream> lastAnimatedPath;
if (!fromPath->size() || (m_animationElement->isAdditive() && !isToAnimation))
lastAnimatedPath = animatedPath->copy();
return animatedType.release();
}
-PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createPath(PassOwnPtr<SVGPathByteStream> path)
+PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createPath(std::unique_ptr<SVGPathByteStream> path)
{
ASSERT(path);
OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedPath));
- animatedType->m_data.path = path.leakPtr();
+ animatedType->m_data.path = path.release();
return animatedType.release();
}
static PassOwnPtr<SVGAnimatedType> createNumber(float*);
static PassOwnPtr<SVGAnimatedType> createNumberList(SVGNumberList*);
static PassOwnPtr<SVGAnimatedType> createNumberOptionalNumber(std::pair<float, float>*);
- static PassOwnPtr<SVGAnimatedType> createPath(PassOwnPtr<SVGPathByteStream>);
+ static PassOwnPtr<SVGAnimatedType> createPath(std::unique_ptr<SVGPathByteStream>);
static PassOwnPtr<SVGAnimatedType> createPointList(SVGPointList*);
static PassOwnPtr<SVGAnimatedType> createPreserveAspectRatio(SVGPreserveAspectRatio*);
static PassOwnPtr<SVGAnimatedType> createRect(FloatRect*);
#if ENABLE(SVG)
#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class SVGPathByteStream {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassOwnPtr<SVGPathByteStream> create()
- {
- return adoptPtr(new SVGPathByteStream);
- }
+ typedef Vector<unsigned char> Data;
+ typedef Data::const_iterator DataIterator;
- PassOwnPtr<SVGPathByteStream> copy()
+ SVGPathByteStream() { }
+ SVGPathByteStream(const Data& data) : m_data(data) { }
+
+ std::unique_ptr<SVGPathByteStream> copy() const
{
- return adoptPtr(new SVGPathByteStream(m_data));
+ return std::make_unique<SVGPathByteStream>(m_data);
}
- typedef Vector<unsigned char> Data;
- typedef Data::const_iterator DataIterator;
-
DataIterator begin() { return m_data.begin(); }
DataIterator end() { return m_data.end(); }
void append(unsigned char byte) { m_data.append(byte); }
void resize(unsigned) { }
private:
- SVGPathByteStream() { }
- SVGPathByteStream(Data& data)
- : m_data(data)
- {
- }
-
Data m_data;
};
#include "SVGPathParser.h"
#include "SVGPathSeg.h"
#include "SVGPathStringSource.h"
-#include <wtf/OwnPtr.h>
namespace WebCore {
#include "FloatPoint.h"
#include "SVGPathByteStream.h"
#include "SVGPathConsumer.h"
-#include <wtf/PassOwnPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document& document)
: SVGGraphicsElement(tagName, document)
- , m_pathByteStream(SVGPathByteStream::create())
+ , m_pathByteStream(std::make_unique<SVGPathByteStream>())
, m_pathSegList(PathSegUnalteredRole)
, m_isAnimValObserved(false)
{
void invalidateMPathDependencies();
private:
- OwnPtr<SVGPathByteStream> m_pathByteStream;
+ std::unique_ptr<SVGPathByteStream> m_pathByteStream;
mutable SVGSynchronizableAnimatedProperty<SVGPathSegList> m_pathSegList;
bool m_isAnimValObserved;
};
SVGPathSegList appendedItemList(PathSegUnalteredRole);
appendedItemList.append(pathSeg);
- OwnPtr<SVGPathByteStream> appendedByteStream = SVGPathByteStream::create();
+ auto appendedByteStream = std::make_unique<SVGPathByteStream>();
SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(appendedByteStream.get());
OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(appendedItemList);
SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(fromStream);
- OwnPtr<SVGPathByteStream> fromStreamCopy = fromStream->copy();
+ auto fromStreamCopy = fromStream->copy();
fromStream->clear();
OwnPtr<SVGPathByteStreamSource> fromSource = SVGPathByteStreamSource::create(fromStreamCopy.get());