<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[190844] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/190844">190844</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2015-10-10 23:16:18 -0700 (Sat, 10 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Use references and more const in SVGPathUtilities
https://bugs.webkit.org/show_bug.cgi?id=150007
Reviewed by Zalan Bujtas.
SVGPathUtilities had lots of pointers whose non-nullness was asserted,
little const, and was very trigger-happy with stack allocations. Clean
that all up.
* svg/SVGAnimatedPath.cpp:
(WebCore::SVGAnimatedPathAnimator::constructFromString):
(WebCore::SVGAnimatedPathAnimator::resetAnimValToBaseVal):
(WebCore::SVGAnimatedPathAnimator::addAnimatedTypes):
(WebCore::SVGAnimatedPathAnimator::calculateAnimatedValue):
* svg/SVGPathByteStream.h:
(WebCore::SVGPathByteStream::begin):
(WebCore::SVGPathByteStream::end):
(WebCore::SVGPathByteStream::append):
* svg/SVGPathByteStreamSource.cpp:
(WebCore::SVGPathByteStreamSource::SVGPathByteStreamSource):
* svg/SVGPathByteStreamSource.h:
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::getTotalLength):
(WebCore::SVGPathElement::getPointAtLength):
(WebCore::SVGPathElement::getPathSegAtLength):
(WebCore::SVGPathElement::parseAttribute):
(WebCore::SVGPathElement::svgAttributeChanged):
(WebCore::SVGPathElement::pathByteStream):
(WebCore::SVGPathElement::lookupOrCreateDWrapper):
(WebCore::SVGPathElement::pathSegListChanged):
(WebCore::SVGPathElement::SVGPathElement): Deleted.
* svg/SVGPathElement.h:
* svg/SVGPathUtilities.cpp:
(WebCore::globalSVGPathBuilder):
(WebCore::globalSVGPathSegListBuilder):
(WebCore::globalSVGPathByteStreamBuilder):
(WebCore::globalSVGPathStringBuilder):
(WebCore::globalSVGPathTraversalStateBuilder):
(WebCore::globalSVGPathParser):
(WebCore::globalSVGPathBlender):
(WebCore::buildPathFromString):
(WebCore::buildSVGPathByteStreamFromSVGPathSegList):
(WebCore::appendSVGPathByteStreamFromSVGPathSeg):
(WebCore::buildPathFromByteStream):
(WebCore::buildSVGPathSegListFromByteStream):
(WebCore::buildStringFromByteStream):
(WebCore::buildStringFromSVGPathSegList):
(WebCore::buildSVGPathByteStreamFromString):
(WebCore::buildAnimatedSVGPathByteStream):
(WebCore::addToSVGPathByteStream):
(WebCore::getSVGPathSegAtLengthFromSVGPathByteStream):
(WebCore::getTotalLengthOfSVGPathByteStream):
(WebCore::getPointAtLengthOfSVGPathByteStream):
(WebCore::buildStringFromPath):
* svg/SVGPathUtilities.h:
* svg/properties/SVGAnimatedPathSegListPropertyTearOff.h:
(WebCore::SVGAnimatedPathSegListPropertyTearOff::animValDidChange):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoresvgSVGAnimatedPathcpp">trunk/Source/WebCore/svg/SVGAnimatedPath.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGPathByteStreamh">trunk/Source/WebCore/svg/SVGPathByteStream.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGPathByteStreamSourcecpp">trunk/Source/WebCore/svg/SVGPathByteStreamSource.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGPathByteStreamSourceh">trunk/Source/WebCore/svg/SVGPathByteStreamSource.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGPathElementcpp">trunk/Source/WebCore/svg/SVGPathElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGPathElementh">trunk/Source/WebCore/svg/SVGPathElement.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGPathUtilitiescpp">trunk/Source/WebCore/svg/SVGPathUtilities.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGPathUtilitiesh">trunk/Source/WebCore/svg/SVGPathUtilities.h</a></li>
<li><a href="#trunkSourceWebCoresvgpropertiesSVGAnimatedPathSegListPropertyTearOffh">trunk/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/ChangeLog        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -1,3 +1,63 @@
</span><ins>+2015-10-10 Simon Fraser <simon.fraser@apple.com>
+
+ Use references and more const in SVGPathUtilities
+ https://bugs.webkit.org/show_bug.cgi?id=150007
+
+ Reviewed by Zalan Bujtas.
+
+ SVGPathUtilities had lots of pointers whose non-nullness was asserted,
+ little const, and was very trigger-happy with stack allocations. Clean
+ that all up.
+
+ * svg/SVGAnimatedPath.cpp:
+ (WebCore::SVGAnimatedPathAnimator::constructFromString):
+ (WebCore::SVGAnimatedPathAnimator::resetAnimValToBaseVal):
+ (WebCore::SVGAnimatedPathAnimator::addAnimatedTypes):
+ (WebCore::SVGAnimatedPathAnimator::calculateAnimatedValue):
+ * svg/SVGPathByteStream.h:
+ (WebCore::SVGPathByteStream::begin):
+ (WebCore::SVGPathByteStream::end):
+ (WebCore::SVGPathByteStream::append):
+ * svg/SVGPathByteStreamSource.cpp:
+ (WebCore::SVGPathByteStreamSource::SVGPathByteStreamSource):
+ * svg/SVGPathByteStreamSource.h:
+ * svg/SVGPathElement.cpp:
+ (WebCore::SVGPathElement::getTotalLength):
+ (WebCore::SVGPathElement::getPointAtLength):
+ (WebCore::SVGPathElement::getPathSegAtLength):
+ (WebCore::SVGPathElement::parseAttribute):
+ (WebCore::SVGPathElement::svgAttributeChanged):
+ (WebCore::SVGPathElement::pathByteStream):
+ (WebCore::SVGPathElement::lookupOrCreateDWrapper):
+ (WebCore::SVGPathElement::pathSegListChanged):
+ (WebCore::SVGPathElement::SVGPathElement): Deleted.
+ * svg/SVGPathElement.h:
+ * svg/SVGPathUtilities.cpp:
+ (WebCore::globalSVGPathBuilder):
+ (WebCore::globalSVGPathSegListBuilder):
+ (WebCore::globalSVGPathByteStreamBuilder):
+ (WebCore::globalSVGPathStringBuilder):
+ (WebCore::globalSVGPathTraversalStateBuilder):
+ (WebCore::globalSVGPathParser):
+ (WebCore::globalSVGPathBlender):
+ (WebCore::buildPathFromString):
+ (WebCore::buildSVGPathByteStreamFromSVGPathSegList):
+ (WebCore::appendSVGPathByteStreamFromSVGPathSeg):
+ (WebCore::buildPathFromByteStream):
+ (WebCore::buildSVGPathSegListFromByteStream):
+ (WebCore::buildStringFromByteStream):
+ (WebCore::buildStringFromSVGPathSegList):
+ (WebCore::buildSVGPathByteStreamFromString):
+ (WebCore::buildAnimatedSVGPathByteStream):
+ (WebCore::addToSVGPathByteStream):
+ (WebCore::getSVGPathSegAtLengthFromSVGPathByteStream):
+ (WebCore::getTotalLengthOfSVGPathByteStream):
+ (WebCore::getPointAtLengthOfSVGPathByteStream):
+ (WebCore::buildStringFromPath):
+ * svg/SVGPathUtilities.h:
+ * svg/properties/SVGAnimatedPathSegListPropertyTearOff.h:
+ (WebCore::SVGAnimatedPathSegListPropertyTearOff::animValDidChange):
+
</ins><span class="cx"> 2015-10-10 Andreas Kling <akling@apple.com>
</span><span class="cx">
</span><span class="cx"> Reduce pointless malloc traffic in ElementRuleCollector.
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGAnimatedPathcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGAnimatedPath.cpp (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGAnimatedPath.cpp        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/SVGAnimatedPath.cpp        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx"> std::unique_ptr<SVGAnimatedType> SVGAnimatedPathAnimator::constructFromString(const String& string)
</span><span class="cx"> {
</span><span class="cx"> auto byteStream = std::make_unique<SVGPathByteStream>();
</span><del>- buildSVGPathByteStreamFromString(string, byteStream.get(), UnalteredParsing);
</del><ins>+ buildSVGPathByteStreamFromString(string, *byteStream, UnalteredParsing);
</ins><span class="cx"> return SVGAnimatedType::createPath(WTF::move(byteStream));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx"> SVGAnimatedPathSegListPropertyTearOff* property = castAnimatedPropertyToActualType<SVGAnimatedPathSegListPropertyTearOff>(animatedTypes[0].properties[0].get());
</span><span class="cx"> const SVGPathSegList& baseValue = property->currentBaseValue();
</span><span class="cx">
</span><del>- buildSVGPathByteStreamFromSVGPathSegList(baseValue, byteStream, UnalteredParsing);
</del><ins>+ buildSVGPathByteStreamFromSVGPathSegList(baseValue, *byteStream, UnalteredParsing);
</ins><span class="cx">
</span><span class="cx"> Vector<RefPtr<SVGAnimatedPathSegListPropertyTearOff>> result;
</span><span class="cx">
</span><span class="lines">@@ -104,7 +104,7 @@
</span><span class="cx"> unsigned fromPathSize = fromPath->size();
</span><span class="cx"> if (!fromPathSize || fromPathSize != toPath->size())
</span><span class="cx"> return;
</span><del>- addToSVGPathByteStream(toPath, fromPath);
</del><ins>+ addToSVGPathByteStream(*toPath, *fromPath);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void SVGAnimatedPathAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
</span><span class="lines">@@ -133,15 +133,15 @@
</span><span class="cx"> if (!m_animationElement->adjustFromToListValues<SVGPathByteStream>(*fromPath, *toPath, *animatedPath, percentage, false))
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- buildAnimatedSVGPathByteStream(fromPath, toPath, animatedPath, percentage);
</del><ins>+ buildAnimatedSVGPathByteStream(*fromPath, *toPath, *animatedPath, percentage);
</ins><span class="cx">
</span><span class="cx"> // Handle additive='sum'.
</span><span class="cx"> if (lastAnimatedPath)
</span><del>- addToSVGPathByteStream(animatedPath, lastAnimatedPath.get());
</del><ins>+ addToSVGPathByteStream(*animatedPath, *lastAnimatedPath);
</ins><span class="cx">
</span><span class="cx"> // Handle accumulate='sum'.
</span><span class="cx"> if (m_animationElement->isAccumulated() && repeatCount)
</span><del>- addToSVGPathByteStream(animatedPath, toAtEndOfDurationPath, repeatCount);
</del><ins>+ addToSVGPathByteStream(*animatedPath, *toAtEndOfDurationPath, repeatCount);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> float SVGAnimatedPathAnimator::calculateDistance(const String&, const String&)
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGPathByteStreamh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGPathByteStream.h (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGPathByteStream.h        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/SVGPathByteStream.h        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -55,10 +55,11 @@
</span><span class="cx"> return std::make_unique<SVGPathByteStream>(m_data);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- DataIterator begin() { return m_data.begin(); }
- DataIterator end() { return m_data.end(); }
</del><ins>+ DataIterator begin() const { return m_data.begin(); }
+ DataIterator end() const { return m_data.end(); }
+
</ins><span class="cx"> void append(unsigned char byte) { m_data.append(byte); }
</span><del>- void append(SVGPathByteStream& other)
</del><ins>+ void append(const SVGPathByteStream& other)
</ins><span class="cx"> {
</span><span class="cx"> for (auto stream : other)
</span><span class="cx"> append(stream);
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGPathByteStreamSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGPathByteStreamSource.cpp (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGPathByteStreamSource.cpp        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/SVGPathByteStreamSource.cpp        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -22,11 +22,10 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-SVGPathByteStreamSource::SVGPathByteStreamSource(SVGPathByteStream* stream)
</del><ins>+SVGPathByteStreamSource::SVGPathByteStreamSource(const SVGPathByteStream& stream)
</ins><span class="cx"> {
</span><del>- ASSERT(stream);
- m_streamCurrent = stream->begin();
- m_streamEnd = stream->end();
</del><ins>+ m_streamCurrent = stream.begin();
+ m_streamEnd = stream.end();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool SVGPathByteStreamSource::hasMoreData() const
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGPathByteStreamSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGPathByteStreamSource.h (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGPathByteStreamSource.h        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/SVGPathByteStreamSource.h        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx">
</span><span class="cx"> class SVGPathByteStreamSource : public SVGPathSource {
</span><span class="cx"> public:
</span><del>- explicit SVGPathByteStreamSource(SVGPathByteStream*);
</del><ins>+ explicit SVGPathByteStreamSource(const SVGPathByteStream&);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> virtual bool hasMoreData() const override;
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGPathElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGPathElement.cpp (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGPathElement.cpp        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/SVGPathElement.cpp        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -80,7 +80,6 @@
</span><span class="cx">
</span><span class="cx"> inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document& document)
</span><span class="cx"> : SVGGraphicsElement(tagName, document)
</span><del>- , m_pathByteStream(std::make_unique<SVGPathByteStream>())
</del><span class="cx"> , m_pathSegList(PathSegUnalteredRole)
</span><span class="cx"> , m_isAnimValObserved(false)
</span><span class="cx"> {
</span><span class="lines">@@ -93,21 +92,21 @@
</span><span class="cx"> return adoptRef(*new SVGPathElement(tagName, document));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-float SVGPathElement::getTotalLength()
</del><ins>+float SVGPathElement::getTotalLength() const
</ins><span class="cx"> {
</span><span class="cx"> float totalLength = 0;
</span><span class="cx"> getTotalLengthOfSVGPathByteStream(pathByteStream(), totalLength);
</span><span class="cx"> return totalLength;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SVGPoint SVGPathElement::getPointAtLength(float length)
</del><ins>+SVGPoint SVGPathElement::getPointAtLength(float length) const
</ins><span class="cx"> {
</span><span class="cx"> SVGPoint point;
</span><span class="cx"> getPointAtLengthOfSVGPathByteStream(pathByteStream(), length, point);
</span><span class="cx"> return point;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-unsigned SVGPathElement::getPathSegAtLength(float length)
</del><ins>+unsigned SVGPathElement::getPathSegAtLength(float length) const
</ins><span class="cx"> {
</span><span class="cx"> unsigned pathSeg = 0;
</span><span class="cx"> getSVGPathSegAtLengthFromSVGPathByteStream(pathByteStream(), length, pathSeg);
</span><span class="lines">@@ -224,7 +223,7 @@
</span><span class="cx"> void SVGPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
</span><span class="cx"> {
</span><span class="cx"> if (name == SVGNames::dAttr) {
</span><del>- if (!buildSVGPathByteStreamFromString(value, m_pathByteStream.get(), UnalteredParsing))
</del><ins>+ if (!buildSVGPathByteStreamFromString(value, m_pathByteStream, UnalteredParsing))
</ins><span class="cx"> document().accessSVGExtensions().reportError("Problem parsing d=\"" + value + "\"");
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -254,7 +253,7 @@
</span><span class="cx"> if (attrName == SVGNames::dAttr) {
</span><span class="cx"> if (m_pathSegList.shouldSynchronize && !SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo())->isAnimating()) {
</span><span class="cx"> SVGPathSegList newList(PathSegUnalteredRole);
</span><del>- buildSVGPathSegListFromByteStream(m_pathByteStream.get(), this, newList, UnalteredParsing);
</del><ins>+ buildSVGPathSegListFromByteStream(m_pathByteStream, *this, newList, UnalteredParsing);
</ins><span class="cx"> m_pathSegList.value = newList;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -293,12 +292,17 @@
</span><span class="cx"> invalidateMPathDependencies();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SVGPathByteStream* SVGPathElement::pathByteStream() const
</del><ins>+const SVGPathByteStream& SVGPathElement::pathByteStream() const
</ins><span class="cx"> {
</span><span class="cx"> SVGAnimatedProperty* property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo());
</span><span class="cx"> if (!property || !property->isAnimating())
</span><del>- return m_pathByteStream.get();
- return static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property)->animatedPathByteStream();
</del><ins>+ return m_pathByteStream;
+
+ SVGPathByteStream* animatedPathByteStream = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property)->animatedPathByteStream();
+ if (!animatedPathByteStream)
+ return m_pathByteStream;
+
+ return *animatedPathByteStream;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Ref<SVGAnimatedProperty> SVGPathElement::lookupOrCreateDWrapper(SVGElement* contextElement)
</span><span class="lines">@@ -310,7 +314,7 @@
</span><span class="cx"> return *property;
</span><span class="cx">
</span><span class="cx"> // Build initial SVGPathSegList.
</span><del>- buildSVGPathSegListFromByteStream(ownerType.m_pathByteStream.get(), &ownerType, ownerType.m_pathSegList.value, UnalteredParsing);
</del><ins>+ buildSVGPathSegListFromByteStream(ownerType.m_pathByteStream, ownerType, ownerType.m_pathSegList.value, UnalteredParsing);
</ins><span class="cx">
</span><span class="cx"> return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff, SVGPathSegList>
</span><span class="cx"> (&ownerType, dPropertyInfo(), ownerType.m_pathSegList.value);
</span><span class="lines">@@ -359,9 +363,9 @@
</span><span class="cx"> case PathSegUnalteredRole:
</span><span class="cx"> if (listModification == ListModificationAppend) {
</span><span class="cx"> ASSERT(!m_pathSegList.value.isEmpty());
</span><del>- appendSVGPathByteStreamFromSVGPathSeg(m_pathSegList.value.last().copyRef(), m_pathByteStream.get(), UnalteredParsing);
</del><ins>+ appendSVGPathByteStreamFromSVGPathSeg(m_pathSegList.value.last().copyRef(), m_pathByteStream, UnalteredParsing);
</ins><span class="cx"> } else
</span><del>- buildSVGPathByteStreamFromSVGPathSegList(m_pathSegList.value, m_pathByteStream.get(), UnalteredParsing);
</del><ins>+ buildSVGPathByteStreamFromSVGPathSegList(m_pathSegList.value, m_pathByteStream, UnalteredParsing);
</ins><span class="cx"> break;
</span><span class="cx"> case PathSegUndefinedRole:
</span><span class="cx"> return;
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGPathElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGPathElement.h (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGPathElement.h        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/SVGPathElement.h        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -57,9 +57,9 @@
</span><span class="cx"> public:
</span><span class="cx"> static Ref<SVGPathElement> create(const QualifiedName&, Document&);
</span><span class="cx">
</span><del>- float getTotalLength();
- SVGPoint getPointAtLength(float distance);
- unsigned getPathSegAtLength(float distance);
</del><ins>+ float getTotalLength() const;
+ SVGPoint getPointAtLength(float distance) const;
+ unsigned getPathSegAtLength(float distance) const;
</ins><span class="cx">
</span><span class="cx"> Ref<SVGPathSegClosePath> createSVGPathSegClosePath(SVGPathSegRole = PathSegUndefinedRole);
</span><span class="cx"> Ref<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y, SVGPathSegRole = PathSegUndefinedRole);
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx"> SVGPathSegListPropertyTearOff* normalizedPathSegList();
</span><span class="cx"> SVGPathSegListPropertyTearOff* animatedNormalizedPathSegList();
</span><span class="cx">
</span><del>- SVGPathByteStream* pathByteStream() const;
</del><ins>+ const SVGPathByteStream& pathByteStream() const;
</ins><span class="cx">
</span><span class="cx"> void pathSegListChanged(SVGPathSegRole, ListModification = ListModificationUnknown);
</span><span class="cx">
</span><span class="lines">@@ -124,7 +124,7 @@
</span><span class="cx"> void invalidateMPathDependencies();
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- std::unique_ptr<SVGPathByteStream> m_pathByteStream;
</del><ins>+ SVGPathByteStream m_pathByteStream;
</ins><span class="cx"> mutable SVGSynchronizableAnimatedProperty<SVGPathSegList> m_pathSegList;
</span><span class="cx"> bool m_isAnimValObserved;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGPathUtilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGPathUtilities.cpp (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGPathUtilities.cpp        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/SVGPathUtilities.cpp        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -37,76 +37,60 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-static SVGPathBuilder* globalSVGPathBuilder(Path& result)
</del><ins>+// FIXME: are all these globals warranted? Why not just make them on the stack?
+static SVGPathBuilder& globalSVGPathBuilder(Path& result)
</ins><span class="cx"> {
</span><del>- static SVGPathBuilder* s_builder = nullptr;
- if (!s_builder)
- s_builder = new SVGPathBuilder;
-
- s_builder->setCurrentPath(&result);
- return s_builder;
</del><ins>+ static NeverDestroyed<SVGPathBuilder> s_builder;
+ s_builder.get().setCurrentPath(&result);
+ return s_builder.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static SVGPathSegListBuilder* globalSVGPathSegListBuilder(SVGPathElement* element, SVGPathSegRole role, SVGPathSegList& result)
</del><ins>+static SVGPathSegListBuilder& globalSVGPathSegListBuilder(SVGPathElement& element, SVGPathSegRole role, SVGPathSegList& result)
</ins><span class="cx"> {
</span><del>- static SVGPathSegListBuilder* s_builder = nullptr;
- if (!s_builder)
- s_builder = new SVGPathSegListBuilder;
</del><ins>+ static NeverDestroyed<SVGPathSegListBuilder> s_builder;
</ins><span class="cx">
</span><del>- s_builder->setCurrentSVGPathElement(element);
- s_builder->setCurrentSVGPathSegList(result);
- s_builder->setCurrentSVGPathSegRole(role);
- return s_builder;
</del><ins>+ s_builder.get().setCurrentSVGPathElement(&element);
+ s_builder.get().setCurrentSVGPathSegList(result);
+ s_builder.get().setCurrentSVGPathSegRole(role);
+ return s_builder.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static SVGPathByteStreamBuilder* globalSVGPathByteStreamBuilder(SVGPathByteStream* result)
</del><ins>+static SVGPathByteStreamBuilder& globalSVGPathByteStreamBuilder(SVGPathByteStream& result)
</ins><span class="cx"> {
</span><del>- static SVGPathByteStreamBuilder* s_builder = nullptr;
- if (!s_builder)
- s_builder = new SVGPathByteStreamBuilder;
-
- s_builder->setCurrentByteStream(result);
- return s_builder;
</del><ins>+ static NeverDestroyed<SVGPathByteStreamBuilder> s_builder;
+ s_builder.get().setCurrentByteStream(&result);
+ return s_builder.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static SVGPathStringBuilder* globalSVGPathStringBuilder()
</del><ins>+static SVGPathStringBuilder& globalSVGPathStringBuilder()
</ins><span class="cx"> {
</span><del>- static SVGPathStringBuilder* s_builder = nullptr;
- if (!s_builder)
- s_builder = new SVGPathStringBuilder;
-
- return s_builder;
</del><ins>+ static NeverDestroyed<SVGPathStringBuilder> s_builder;
+ return s_builder.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static SVGPathTraversalStateBuilder* globalSVGPathTraversalStateBuilder(PathTraversalState& traversalState, float length)
</del><ins>+static SVGPathTraversalStateBuilder& globalSVGPathTraversalStateBuilder(PathTraversalState& traversalState, float length)
</ins><span class="cx"> {
</span><del>- static SVGPathTraversalStateBuilder* s_builder = nullptr;
- if (!s_builder)
- s_builder = new SVGPathTraversalStateBuilder;
</del><ins>+ static NeverDestroyed<SVGPathTraversalStateBuilder> s_parser;
</ins><span class="cx">
</span><del>- s_builder->setCurrentTraversalState(&traversalState);
- s_builder->setDesiredLength(length);
- return s_builder;
</del><ins>+ s_parser.get().setCurrentTraversalState(&traversalState);
+ s_parser.get().setDesiredLength(length);
+ return s_parser.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static SVGPathParser* globalSVGPathParser(SVGPathSource* source, SVGPathConsumer* consumer)
</del><ins>+// FIXME: why bother keeping a singleton around? Is it slow to allocate?
+static SVGPathParser& globalSVGPathParser(SVGPathSource& source, SVGPathConsumer& consumer)
</ins><span class="cx"> {
</span><del>- static SVGPathParser* s_parser = nullptr;
- if (!s_parser)
- s_parser = new SVGPathParser;
</del><ins>+ static NeverDestroyed<SVGPathParser> s_parser;
</ins><span class="cx">
</span><del>- s_parser->setCurrentSource(source);
- s_parser->setCurrentConsumer(consumer);
- return s_parser;
</del><ins>+ s_parser.get().setCurrentSource(&source);
+ s_parser.get().setCurrentConsumer(&consumer);
+ return s_parser.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static SVGPathBlender* globalSVGPathBlender()
</del><ins>+static SVGPathBlender& globalSVGPathBlender()
</ins><span class="cx"> {
</span><del>- static SVGPathBlender* s_blender = nullptr;
- if (!s_blender)
- s_blender = new SVGPathBlender;
-
- return s_blender;
</del><ins>+ static NeverDestroyed<SVGPathBlender> s_blender;
+ return s_blender.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool buildPathFromString(const String& d, Path& result)
</span><span class="lines">@@ -114,96 +98,91 @@
</span><span class="cx"> if (d.isEmpty())
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathBuilder* builder = globalSVGPathBuilder(result);
</del><ins>+ SVGPathBuilder& builder = globalSVGPathBuilder(result);
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathStringSource>(d);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(NormalizedParsing);
- parser->cleanup();
</del><ins>+ SVGPathStringSource source(d);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(NormalizedParsing);
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool buildSVGPathByteStreamFromSVGPathSegList(const SVGPathSegList& list, SVGPathByteStream* result, PathParsingMode parsingMode)
</del><ins>+bool buildSVGPathByteStreamFromSVGPathSegList(const SVGPathSegList& list, SVGPathByteStream& result, PathParsingMode parsingMode)
</ins><span class="cx"> {
</span><del>- ASSERT(result);
- result->clear();
</del><ins>+ result.clear();
</ins><span class="cx"> if (list.isEmpty())
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result);
</del><ins>+ SVGPathByteStreamBuilder& builder = globalSVGPathByteStreamBuilder(result);
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathSegListSource>(list);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(parsingMode);
- parser->cleanup();
</del><ins>+ SVGPathSegListSource source(list);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(parsingMode);
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool appendSVGPathByteStreamFromSVGPathSeg(RefPtr<SVGPathSeg>&& pathSeg, SVGPathByteStream* result, PathParsingMode parsingMode)
</del><ins>+bool appendSVGPathByteStreamFromSVGPathSeg(RefPtr<SVGPathSeg>&& pathSeg, SVGPathByteStream& result, PathParsingMode parsingMode)
</ins><span class="cx"> {
</span><del>- ASSERT(result);
</del><span class="cx"> // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists!
</span><span class="cx"> ASSERT(parsingMode == UnalteredParsing);
</span><span class="cx">
</span><span class="cx"> SVGPathSegList appendedItemList(PathSegUnalteredRole);
</span><span class="cx"> appendedItemList.append(WTF::move(pathSeg));
</span><del>- auto appendedByteStream = std::make_unique<SVGPathByteStream>();
</del><span class="cx">
</span><del>- SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(appendedByteStream.get());
- auto source = std::make_unique<SVGPathSegListSource>(appendedItemList);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(parsingMode, false);
- parser->cleanup();
</del><ins>+ SVGPathByteStream appendedByteStream;
+ SVGPathByteStreamBuilder& builder = globalSVGPathByteStreamBuilder(appendedByteStream);
+ SVGPathSegListSource source(appendedItemList);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(parsingMode, false);
+ parser.cleanup();
</ins><span class="cx">
</span><span class="cx"> if (ok)
</span><del>- result->append(*appendedByteStream);
</del><ins>+ result.append(appendedByteStream);
</ins><span class="cx">
</span><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool buildPathFromByteStream(SVGPathByteStream* stream, Path& result)
</del><ins>+bool buildPathFromByteStream(const SVGPathByteStream& stream, Path& result)
</ins><span class="cx"> {
</span><del>- ASSERT(stream);
- if (stream->isEmpty())
</del><ins>+ if (stream.isEmpty())
</ins><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathBuilder* builder = globalSVGPathBuilder(result);
</del><ins>+ SVGPathBuilder& builder = globalSVGPathBuilder(result);
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathByteStreamSource>(stream);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(NormalizedParsing);
- parser->cleanup();
</del><ins>+ SVGPathByteStreamSource source(stream);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(NormalizedParsing);
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool buildSVGPathSegListFromByteStream(SVGPathByteStream* stream, SVGPathElement* element, SVGPathSegList& result, PathParsingMode parsingMode)
</del><ins>+bool buildSVGPathSegListFromByteStream(const SVGPathByteStream& stream, SVGPathElement& element, SVGPathSegList& result, PathParsingMode parsingMode)
</ins><span class="cx"> {
</span><del>- ASSERT(stream);
- if (stream->isEmpty())
</del><ins>+ if (stream.isEmpty())
</ins><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder(element, parsingMode == NormalizedParsing ? PathSegNormalizedRole : PathSegUnalteredRole, result);
</del><ins>+ SVGPathSegListBuilder& builder = globalSVGPathSegListBuilder(element, parsingMode == NormalizedParsing ? PathSegNormalizedRole : PathSegUnalteredRole, result);
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathByteStreamSource>(stream);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(parsingMode);
- parser->cleanup();
</del><ins>+ SVGPathByteStreamSource source(stream);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(parsingMode);
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool buildStringFromByteStream(SVGPathByteStream* stream, String& result, PathParsingMode parsingMode)
</del><ins>+bool buildStringFromByteStream(const SVGPathByteStream& stream, String& result, PathParsingMode parsingMode)
</ins><span class="cx"> {
</span><del>- ASSERT(stream);
- if (stream->isEmpty())
</del><ins>+ if (stream.isEmpty())
</ins><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathStringBuilder* builder = globalSVGPathStringBuilder();
</del><ins>+ SVGPathStringBuilder& builder = globalSVGPathStringBuilder();
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathByteStreamSource>(stream);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(parsingMode);
- result = builder->result();
- parser->cleanup();
</del><ins>+ SVGPathByteStreamSource source(stream);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(parsingMode);
+ result = builder.result();
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -213,121 +192,113 @@
</span><span class="cx"> if (list.isEmpty())
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathStringBuilder* builder = globalSVGPathStringBuilder();
</del><ins>+ SVGPathStringBuilder& builder = globalSVGPathStringBuilder();
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathSegListSource>(list);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(parsingMode);
- result = builder->result();
- parser->cleanup();
</del><ins>+ SVGPathSegListSource source(list);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(parsingMode);
+ result = builder.result();
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool buildSVGPathByteStreamFromString(const String& d, SVGPathByteStream* result, PathParsingMode parsingMode)
</del><ins>+bool buildSVGPathByteStreamFromString(const String& d, SVGPathByteStream& result, PathParsingMode parsingMode)
</ins><span class="cx"> {
</span><del>- ASSERT(result);
- result->clear();
</del><ins>+ result.clear();
</ins><span class="cx"> if (d.isEmpty())
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result);
</del><ins>+ SVGPathByteStreamBuilder& builder = globalSVGPathByteStreamBuilder(result);
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathStringSource>(d);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(parsingMode);
- parser->cleanup();
</del><ins>+ SVGPathStringSource source(d);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(parsingMode);
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool buildAnimatedSVGPathByteStream(SVGPathByteStream* fromStream, SVGPathByteStream* toStream, SVGPathByteStream* result, float progress)
</del><ins>+bool buildAnimatedSVGPathByteStream(const SVGPathByteStream& fromStream, const SVGPathByteStream& toStream, SVGPathByteStream& result, float progress)
</ins><span class="cx"> {
</span><del>- ASSERT(fromStream);
- ASSERT(toStream);
- ASSERT(result);
- ASSERT(toStream != result);
-
- result->clear();
- if (toStream->isEmpty())
</del><ins>+ ASSERT(&toStream != &result);
+ result.clear();
+ if (toStream.isEmpty())
</ins><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result);
</del><ins>+ SVGPathByteStreamBuilder& builder = globalSVGPathByteStreamBuilder(result);
</ins><span class="cx">
</span><del>- auto fromSource = std::make_unique<SVGPathByteStreamSource>(fromStream);
- auto toSource = std::make_unique<SVGPathByteStreamSource>(toStream);
- SVGPathBlender* blender = globalSVGPathBlender();
- bool ok = blender->blendAnimatedPath(progress, fromSource.get(), toSource.get(), builder);
- blender->cleanup();
</del><ins>+ SVGPathByteStreamSource fromSource(fromStream);
+ SVGPathByteStreamSource toSource(toStream);
+ SVGPathBlender& blender = globalSVGPathBlender();
+ bool ok = blender.blendAnimatedPath(progress, &fromSource, &toSource, &builder);
+ blender.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool addToSVGPathByteStream(SVGPathByteStream* fromStream, SVGPathByteStream* byStream, unsigned repeatCount)
</del><ins>+bool addToSVGPathByteStream(SVGPathByteStream& streamToAppendTo, const SVGPathByteStream& byStream, unsigned repeatCount)
</ins><span class="cx"> {
</span><del>- ASSERT(fromStream);
- ASSERT(byStream);
- if (fromStream->isEmpty() || byStream->isEmpty())
</del><ins>+ // Why return when streamToAppendTo is empty? Don't we still need to append?
+ if (streamToAppendTo.isEmpty() || byStream.isEmpty())
</ins><span class="cx"> return true;
</span><span class="cx">
</span><del>- SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(fromStream);
</del><ins>+ // Is it OK to make the SVGPathByteStreamBuilder from a stream, and then clear that stream?
+ SVGPathByteStreamBuilder& builder = globalSVGPathByteStreamBuilder(streamToAppendTo);
</ins><span class="cx">
</span><del>- auto fromStreamCopy = fromStream->copy();
- fromStream->clear();
</del><ins>+ SVGPathByteStream fromStreamCopy = streamToAppendTo;
+ streamToAppendTo.clear();
</ins><span class="cx">
</span><del>- auto fromSource = std::make_unique<SVGPathByteStreamSource>(fromStreamCopy.get());
- auto bySource = std::make_unique<SVGPathByteStreamSource>(byStream);
- SVGPathBlender* blender = globalSVGPathBlender();
- bool ok = blender->addAnimatedPath(fromSource.get(), bySource.get(), builder, repeatCount);
- blender->cleanup();
</del><ins>+ SVGPathByteStreamSource fromSource(fromStreamCopy);
+ SVGPathByteStreamSource bySource(byStream);
+ SVGPathBlender& blender = globalSVGPathBlender();
+ bool ok = blender.addAnimatedPath(&fromSource, &bySource, &builder, repeatCount);
+ blender.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool getSVGPathSegAtLengthFromSVGPathByteStream(SVGPathByteStream* stream, float length, unsigned& pathSeg)
</del><ins>+bool getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream& stream, float length, unsigned& pathSeg)
</ins><span class="cx"> {
</span><del>- ASSERT(stream);
- if (stream->isEmpty())
</del><ins>+ if (stream.isEmpty())
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> PathTraversalState traversalState(PathTraversalState::Action::SegmentAtLength);
</span><del>- SVGPathTraversalStateBuilder* builder = globalSVGPathTraversalStateBuilder(traversalState, length);
</del><ins>+ SVGPathTraversalStateBuilder& builder = globalSVGPathTraversalStateBuilder(traversalState, length);
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathByteStreamSource>(stream);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(NormalizedParsing);
- pathSeg = builder->pathSegmentIndex();
- parser->cleanup();
</del><ins>+ SVGPathByteStreamSource source(stream);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(NormalizedParsing);
+ pathSeg = builder.pathSegmentIndex();
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool getTotalLengthOfSVGPathByteStream(SVGPathByteStream* stream, float& totalLength)
</del><ins>+bool getTotalLengthOfSVGPathByteStream(const SVGPathByteStream& stream, float& totalLength)
</ins><span class="cx"> {
</span><del>- ASSERT(stream);
- if (stream->isEmpty())
</del><ins>+ if (stream.isEmpty())
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> PathTraversalState traversalState(PathTraversalState::Action::TotalLength);
</span><del>- SVGPathTraversalStateBuilder* builder = globalSVGPathTraversalStateBuilder(traversalState, 0);
</del><ins>+ SVGPathTraversalStateBuilder& builder = globalSVGPathTraversalStateBuilder(traversalState, 0);
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathByteStreamSource>(stream);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(NormalizedParsing);
- totalLength = builder->totalLength();
- parser->cleanup();
</del><ins>+ SVGPathByteStreamSource source(stream);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(NormalizedParsing);
+ totalLength = builder.totalLength();
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool getPointAtLengthOfSVGPathByteStream(SVGPathByteStream* stream, float length, SVGPoint& point)
</del><ins>+bool getPointAtLengthOfSVGPathByteStream(const SVGPathByteStream& stream, float length, SVGPoint& point)
</ins><span class="cx"> {
</span><del>- ASSERT(stream);
- if (stream->isEmpty())
</del><ins>+ if (stream.isEmpty())
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> PathTraversalState traversalState(PathTraversalState::Action::VectorAtLength);
</span><del>- SVGPathTraversalStateBuilder* builder = globalSVGPathTraversalStateBuilder(traversalState, length);
</del><ins>+ SVGPathTraversalStateBuilder& builder = globalSVGPathTraversalStateBuilder(traversalState, length);
</ins><span class="cx">
</span><del>- auto source = std::make_unique<SVGPathByteStreamSource>(stream);
- SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
- bool ok = parser->parsePathDataFromSource(NormalizedParsing);
- point = builder->currentPoint();
- parser->cleanup();
</del><ins>+ SVGPathByteStreamSource source(stream);
+ SVGPathParser& parser = globalSVGPathParser(source, builder);
+ bool ok = parser.parsePathDataFromSource(NormalizedParsing);
+ point = builder.currentPoint();
+ parser.cleanup();
</ins><span class="cx"> return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -361,12 +332,12 @@
</span><span class="cx"> // Ideally we would have a SVGPathPlatformPathSource, but it's not possible to manually iterate
</span><span class="cx"> // a path, only apply a function to all path elements at once.
</span><span class="cx">
</span><del>- SVGPathStringBuilder* builder = globalSVGPathStringBuilder();
- path.apply([builder](const PathElement& pathElement) {
- pathIteratorForBuildingString(*builder, pathElement);
</del><ins>+ SVGPathStringBuilder& builder = globalSVGPathStringBuilder();
+ path.apply([&builder](const PathElement& pathElement) {
+ pathIteratorForBuildingString(builder, pathElement);
</ins><span class="cx"> });
</span><del>- string = builder->result();
- static_cast<SVGPathConsumer*>(builder)->cleanup();
</del><ins>+ string = builder.result();
+ static_cast<SVGPathConsumer&>(builder).cleanup(); // Wat?
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGPathUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGPathUtilities.h (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGPathUtilities.h        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/SVGPathUtilities.h        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -34,26 +34,26 @@
</span><span class="cx">
</span><span class="cx"> // String/SVGPathByteStream -> Path
</span><span class="cx"> bool buildPathFromString(const String&, Path&);
</span><del>-bool buildPathFromByteStream(SVGPathByteStream*, Path&);
</del><ins>+bool buildPathFromByteStream(const SVGPathByteStream&, Path&);
</ins><span class="cx">
</span><span class="cx"> // SVGPathSegList/String -> SVGPathByteStream
</span><del>-bool buildSVGPathByteStreamFromSVGPathSegList(const SVGPathSegList&, SVGPathByteStream*, PathParsingMode);
-bool appendSVGPathByteStreamFromSVGPathSeg(RefPtr<SVGPathSeg>&&, SVGPathByteStream*, PathParsingMode);
-bool buildSVGPathByteStreamFromString(const String&, SVGPathByteStream*, PathParsingMode);
</del><ins>+bool buildSVGPathByteStreamFromSVGPathSegList(const SVGPathSegList&, SVGPathByteStream& result, PathParsingMode);
+bool appendSVGPathByteStreamFromSVGPathSeg(RefPtr<SVGPathSeg>&&, SVGPathByteStream&, PathParsingMode);
+bool buildSVGPathByteStreamFromString(const String&, SVGPathByteStream&, PathParsingMode);
</ins><span class="cx">
</span><span class="cx"> // SVGPathByteStream/SVGPathSegList -> String
</span><del>-bool buildStringFromByteStream(SVGPathByteStream*, String&, PathParsingMode);
</del><ins>+bool buildStringFromByteStream(const SVGPathByteStream&, String&, PathParsingMode);
</ins><span class="cx"> bool buildStringFromSVGPathSegList(const SVGPathSegList&, String&, PathParsingMode);
</span><span class="cx">
</span><span class="cx"> // SVGPathByteStream -> SVGPathSegList
</span><del>-bool buildSVGPathSegListFromByteStream(SVGPathByteStream*, SVGPathElement*, SVGPathSegList&, PathParsingMode);
</del><ins>+bool buildSVGPathSegListFromByteStream(const SVGPathByteStream&, SVGPathElement&, SVGPathSegList&, PathParsingMode);
</ins><span class="cx">
</span><del>-bool buildAnimatedSVGPathByteStream(SVGPathByteStream*, SVGPathByteStream*, SVGPathByteStream*, float);
-bool addToSVGPathByteStream(SVGPathByteStream*, SVGPathByteStream*, unsigned repeatCount = 1);
</del><ins>+bool buildAnimatedSVGPathByteStream(const SVGPathByteStream& from, const SVGPathByteStream& to, SVGPathByteStream& result, float progress);
+bool addToSVGPathByteStream(SVGPathByteStream& streamToAppendTo, const SVGPathByteStream& from, unsigned repeatCount = 1);
</ins><span class="cx">
</span><del>-bool getSVGPathSegAtLengthFromSVGPathByteStream(SVGPathByteStream*, float length, unsigned& pathSeg);
-bool getTotalLengthOfSVGPathByteStream(SVGPathByteStream*, float& totalLength);
-bool getPointAtLengthOfSVGPathByteStream(SVGPathByteStream*, float length, SVGPoint&);
</del><ins>+bool getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream&, float length, unsigned& pathSeg);
+bool getTotalLengthOfSVGPathByteStream(const SVGPathByteStream&, float& totalLength);
+bool getPointAtLengthOfSVGPathByteStream(const SVGPathByteStream&, float length, SVGPoint&);
</ins><span class="cx">
</span><span class="cx"> // Path -> String
</span><span class="cx"> WEBCORE_EXPORT bool buildStringFromPath(const Path&, String&);
</span></span></pre></div>
<a id="trunkSourceWebCoresvgpropertiesSVGAnimatedPathSegListPropertyTearOffh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h (190843 => 190844)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h        2015-10-10 21:14:56 UTC (rev 190843)
+++ trunk/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h        2015-10-11 06:16:18 UTC (rev 190844)
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx"> if (pathElement->isAnimValObserved()) {
</span><span class="cx"> SVGPathSegList& animatedList = currentAnimatedValue();
</span><span class="cx"> animatedList.clear();
</span><del>- buildSVGPathSegListFromByteStream(m_animatedPathByteStream, pathElement, animatedList, UnalteredParsing);
</del><ins>+ buildSVGPathSegListFromByteStream(*m_animatedPathByteStream, *pathElement, animatedList, UnalteredParsing);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SVGAnimatedListPropertyTearOff<SVGPathSegList>::animValDidChange();
</span></span></pre>
</div>
</div>
</body>
</html>