Title: [158359] trunk/Source/WebCore
Revision
158359
Author
[email protected]
Date
2013-10-31 08:29:28 -0700 (Thu, 31 Oct 2013)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158358 => 158359)


--- trunk/Source/WebCore/ChangeLog	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/ChangeLog	2013-10-31 15:29:28 UTC (rev 158359)
@@ -1,3 +1,32 @@
+2013-10-31  Zan Dobersek  <[email protected]>
+
+        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  <[email protected]>
 
         Removing m_maxDeadCapacity condition in fast path in MemoryCache::prune().

Modified: trunk/Source/WebCore/svg/SVGAnimatedPath.cpp (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGAnimatedPath.cpp	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGAnimatedPath.cpp	2013-10-31 15:29:28 UTC (rev 158359)
@@ -35,9 +35,9 @@
 
 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)
@@ -47,7 +47,7 @@
     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;
@@ -62,7 +62,7 @@
     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)
@@ -112,7 +112,7 @@
     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();
@@ -120,7 +120,7 @@
     }
 
     // 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();
 

Modified: trunk/Source/WebCore/svg/SVGAnimatedType.cpp (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGAnimatedType.cpp	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.cpp	2013-10-31 15:29:28 UTC (rev 158359)
@@ -180,11 +180,11 @@
     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();
 }
 

Modified: trunk/Source/WebCore/svg/SVGAnimatedType.h (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGAnimatedType.h	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.h	2013-10-31 15:29:28 UTC (rev 158359)
@@ -52,7 +52,7 @@
     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*);

Modified: trunk/Source/WebCore/svg/SVGPathByteStream.h (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGPathByteStream.h	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGPathByteStream.h	2013-10-31 15:29:28 UTC (rev 158359)
@@ -22,7 +22,6 @@
 
 #if ENABLE(SVG)
 #include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -46,19 +45,17 @@
 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); }
@@ -75,12 +72,6 @@
     void resize(unsigned) { }
 
 private:
-    SVGPathByteStream() { }
-    SVGPathByteStream(Data& data)
-        : m_data(data)
-    {
-    }
-
     Data m_data;
 };
 

Modified: trunk/Source/WebCore/svg/SVGPathByteStreamBuilder.cpp (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGPathByteStreamBuilder.cpp	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGPathByteStreamBuilder.cpp	2013-10-31 15:29:28 UTC (rev 158359)
@@ -25,7 +25,6 @@
 #include "SVGPathParser.h"
 #include "SVGPathSeg.h"
 #include "SVGPathStringSource.h"
-#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 

Modified: trunk/Source/WebCore/svg/SVGPathByteStreamBuilder.h (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGPathByteStreamBuilder.h	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGPathByteStreamBuilder.h	2013-10-31 15:29:28 UTC (rev 158359)
@@ -24,7 +24,6 @@
 #include "FloatPoint.h"
 #include "SVGPathByteStream.h"
 #include "SVGPathConsumer.h"
-#include <wtf/PassOwnPtr.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {

Modified: trunk/Source/WebCore/svg/SVGPathElement.cpp (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGPathElement.cpp	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGPathElement.cpp	2013-10-31 15:29:28 UTC (rev 158359)
@@ -84,7 +84,7 @@
 
 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)
 {

Modified: trunk/Source/WebCore/svg/SVGPathElement.h (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGPathElement.h	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGPathElement.h	2013-10-31 15:29:28 UTC (rev 158359)
@@ -126,7 +126,7 @@
     void invalidateMPathDependencies();
 
 private:
-    OwnPtr<SVGPathByteStream> m_pathByteStream;
+    std::unique_ptr<SVGPathByteStream> m_pathByteStream;
     mutable SVGSynchronizableAnimatedProperty<SVGPathSegList> m_pathSegList;
     bool m_isAnimValObserved;
 };

Modified: trunk/Source/WebCore/svg/SVGPathUtilities.cpp (158358 => 158359)


--- trunk/Source/WebCore/svg/SVGPathUtilities.cpp	2013-10-31 15:29:17 UTC (rev 158358)
+++ trunk/Source/WebCore/svg/SVGPathUtilities.cpp	2013-10-31 15:29:28 UTC (rev 158359)
@@ -148,7 +148,7 @@
 
     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);
@@ -270,7 +270,7 @@
 
     SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(fromStream);
 
-    OwnPtr<SVGPathByteStream> fromStreamCopy = fromStream->copy();
+    auto fromStreamCopy = fromStream->copy();
     fromStream->clear();
 
     OwnPtr<SVGPathByteStreamSource> fromSource = SVGPathByteStreamSource::create(fromStreamCopy.get());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to