Stop using deleteAllValues in SVG code
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2013 18:39:09 +0000 (18:39 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2013 18:39:09 +0000 (18:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121172

Reviewed by Antti Koivisto.

Use OwnPtr for values instead.

* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::~RenderSVGResourceClipper):
(WebCore::RenderSVGResourceClipper::removeAllClientsFromCache):
(WebCore::RenderSVGResourceClipper::removeClientFromCache):
(WebCore::RenderSVGResourceClipper::applyClippingToContext):
* rendering/svg/RenderSVGResourceClipper.h:
* rendering/svg/RenderSVGResourceFilter.cpp:
(WebCore::RenderSVGResourceFilter::~RenderSVGResourceFilter):
(WebCore::RenderSVGResourceFilter::removeAllClientsFromCache):
(WebCore::RenderSVGResourceFilter::removeClientFromCache):
(WebCore::RenderSVGResourceFilter::applyResource):
(WebCore::RenderSVGResourceFilter::postApplyResource):
(WebCore::RenderSVGResourceFilter::primitiveAttributeChanged):
* rendering/svg/RenderSVGResourceFilter.h:
* rendering/svg/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::~RenderSVGResourceMasker):
(WebCore::RenderSVGResourceMasker::removeAllClientsFromCache):
(WebCore::RenderSVGResourceMasker::removeClientFromCache):
(WebCore::RenderSVGResourceMasker::applyResource):
* rendering/svg/RenderSVGResourceMasker.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155547 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
Source/WebCore/rendering/svg/RenderSVGResourceClipper.h
Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp
Source/WebCore/rendering/svg/RenderSVGResourceFilter.h
Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp
Source/WebCore/rendering/svg/RenderSVGResourceMasker.h

index 7017d0e..c91521d 100644 (file)
@@ -1,3 +1,33 @@
+2013-09-11  Anders Carlsson  <andersca@apple.com>
+
+        Stop using deleteAllValues in SVG code
+        https://bugs.webkit.org/show_bug.cgi?id=121172
+
+        Reviewed by Antti Koivisto.
+
+        Use OwnPtr for values instead.
+
+        * rendering/svg/RenderSVGResourceClipper.cpp:
+        (WebCore::RenderSVGResourceClipper::~RenderSVGResourceClipper):
+        (WebCore::RenderSVGResourceClipper::removeAllClientsFromCache):
+        (WebCore::RenderSVGResourceClipper::removeClientFromCache):
+        (WebCore::RenderSVGResourceClipper::applyClippingToContext):
+        * rendering/svg/RenderSVGResourceClipper.h:
+        * rendering/svg/RenderSVGResourceFilter.cpp:
+        (WebCore::RenderSVGResourceFilter::~RenderSVGResourceFilter):
+        (WebCore::RenderSVGResourceFilter::removeAllClientsFromCache):
+        (WebCore::RenderSVGResourceFilter::removeClientFromCache):
+        (WebCore::RenderSVGResourceFilter::applyResource):
+        (WebCore::RenderSVGResourceFilter::postApplyResource):
+        (WebCore::RenderSVGResourceFilter::primitiveAttributeChanged):
+        * rendering/svg/RenderSVGResourceFilter.h:
+        * rendering/svg/RenderSVGResourceMasker.cpp:
+        (WebCore::RenderSVGResourceMasker::~RenderSVGResourceMasker):
+        (WebCore::RenderSVGResourceMasker::removeAllClientsFromCache):
+        (WebCore::RenderSVGResourceMasker::removeClientFromCache):
+        (WebCore::RenderSVGResourceMasker::applyResource):
+        * rendering/svg/RenderSVGResourceMasker.h:
+
 2013-09-10  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (143483): overflow:hidden doesn't quash big repaints from text-indent: -9999px
index 1471003..57e94bd 100644 (file)
@@ -60,20 +60,12 @@ RenderSVGResourceClipper::RenderSVGResourceClipper(SVGClipPathElement* node)
 
 RenderSVGResourceClipper::~RenderSVGResourceClipper()
 {
-    if (m_clipper.isEmpty())
-        return;
-
-    deleteAllValues(m_clipper);
-    m_clipper.clear();
 }
 
 void RenderSVGResourceClipper::removeAllClientsFromCache(bool markForInvalidation)
 {
     m_clipBoundaries = FloatRect();
-    if (!m_clipper.isEmpty()) {
-        deleteAllValues(m_clipper);
-        m_clipper.clear();
-    }
+    m_clipper.clear();
 
     markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation);
 }
@@ -81,8 +73,7 @@ void RenderSVGResourceClipper::removeAllClientsFromCache(bool markForInvalidatio
 void RenderSVGResourceClipper::removeClientFromCache(RenderObject* client, bool markForInvalidation)
 {
     ASSERT(client);
-    if (m_clipper.contains(client))
-        delete m_clipper.take(client);
+    m_clipper.remove(client);
 
     markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
 }
@@ -156,7 +147,7 @@ bool RenderSVGResourceClipper::applyClippingToContext(RenderObject* object, cons
 {
     bool missingClipperData = !m_clipper.contains(object);
     if (missingClipperData)
-        m_clipper.set(object, new ClipperData);
+        m_clipper.set(object, createOwned<ClipperData>().release());
 
     bool shouldCreateClipData = false;
     AffineTransform animatedLocalTransform = toSVGClipPathElement(element())->animatedLocalTransform();
index 2277ba4..aab3c29 100644 (file)
@@ -71,7 +71,7 @@ private:
     void calculateClipContentRepaintRect();
 
     FloatRect m_clipBoundaries;
-    HashMap<RenderObject*, ClipperData*> m_clipper;
+    HashMap<RenderObject*, OwnPtr<ClipperData>> m_clipper;
 };
 
 }
index 08d732c..b5b0376 100644 (file)
@@ -65,19 +65,11 @@ RenderSVGResourceFilter::RenderSVGResourceFilter(SVGFilterElement* node)
 
 RenderSVGResourceFilter::~RenderSVGResourceFilter()
 {
-    if (m_filter.isEmpty())
-        return;
-
-    deleteAllValues(m_filter);
-    m_filter.clear();
 }
 
 void RenderSVGResourceFilter::removeAllClientsFromCache(bool markForInvalidation)
 {
-    if (!m_filter.isEmpty()) {
-        deleteAllValues(m_filter);
-        m_filter.clear();
-    }
+    m_filter.clear();
 
     markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation);
 }
@@ -90,7 +82,7 @@ void RenderSVGResourceFilter::removeClientFromCache(RenderObject* client, bool m
         if (filterData->savedContext)
             filterData->state = FilterData::MarkedForRemoval;
         else
-            delete m_filter.take(client);
+            m_filter.remove(client);
     }
 
     markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
@@ -155,7 +147,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*,
         return false; // Already built, or we're in a cycle, or we're marked for removal. Regardless, just do nothing more now.
     }
 
-    OwnPtr<FilterData> filterData(adoptPtr(new FilterData));
+    auto filterData = createOwned<FilterData>();
     FloatRect targetBoundingBox = object->objectBoundingBox();
 
     SVGFilterElement* filterElement = toSVGFilterElement(element());
@@ -224,7 +216,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*,
     if (filterData->drawingRegion.isEmpty()) {
         ASSERT(!m_filter.contains(object));
         filterData->savedContext = context;
-        m_filter.set(object, filterData.leakPtr());
+        m_filter.set(object, filterData.release());
         return false;
     }
 
@@ -238,7 +230,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*,
     if (!SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, sourceGraphic, ColorSpaceLinearRGB, renderingMode)) {
         ASSERT(!m_filter.contains(object));
         filterData->savedContext = context;
-        m_filter.set(object, filterData.leakPtr());
+        m_filter.set(object, filterData.release());
         return false;
     }
     
@@ -254,7 +246,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*,
     context = sourceGraphicContext;
 
     ASSERT(!m_filter.contains(object));
-    m_filter.set(object, filterData.leakPtr());
+    m_filter.set(object, filterData.release());
 
     return true;
 }
@@ -271,7 +263,7 @@ void RenderSVGResourceFilter::postApplyResource(RenderObject* object, GraphicsCo
 
     switch (filterData->state) {
     case FilterData::MarkedForRemoval:
-        delete m_filter.take(object);
+        m_filter.remove(object);
         return;
 
     case FilterData::CycleDetected:
@@ -338,12 +330,10 @@ FloatRect RenderSVGResourceFilter::resourceBoundingBox(RenderObject* object)
 
 void RenderSVGResourceFilter::primitiveAttributeChanged(RenderObject* object, const QualifiedName& attribute)
 {
-    HashMap<RenderObject*, FilterData*>::iterator it = m_filter.begin();
-    HashMap<RenderObject*, FilterData*>::iterator end = m_filter.end();
     SVGFilterPrimitiveStandardAttributes* primitve = static_cast<SVGFilterPrimitiveStandardAttributes*>(object->node());
 
-    for (; it != end; ++it) {
-        FilterData* filterData = it->value;
+    for (auto it = m_filter.begin(), end = m_filter.end(); it != end; ++it) {
+        const auto &filterData = it->value;
         if (filterData->state != FilterData::Built)
             continue;
 
index 97b9304..09fbe2a 100644 (file)
@@ -93,7 +93,7 @@ public:
 private:
     bool fitsInMaximumImageSize(const FloatSize&, FloatSize&);
 
-    HashMap<RenderObject*, FilterData*> m_filter;
+    HashMap<RenderObject*, OwnPtr<FilterData>> m_filter;
 };
 
 inline RenderSVGResourceFilter* toRenderSVGFilter(RenderObject* object)
index dc10283..20ffbd0 100644 (file)
@@ -48,20 +48,12 @@ RenderSVGResourceMasker::RenderSVGResourceMasker(SVGMaskElement* node)
 
 RenderSVGResourceMasker::~RenderSVGResourceMasker()
 {
-    if (m_masker.isEmpty())
-        return;
-
-    deleteAllValues(m_masker);
-    m_masker.clear();
 }
 
 void RenderSVGResourceMasker::removeAllClientsFromCache(bool markForInvalidation)
 {
     m_maskContentBoundaries = FloatRect();
-    if (!m_masker.isEmpty()) {
-        deleteAllValues(m_masker);
-        m_masker.clear();
-    }
+    m_masker.clear();
 
     markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation);
 }
@@ -69,9 +61,7 @@ void RenderSVGResourceMasker::removeAllClientsFromCache(bool markForInvalidation
 void RenderSVGResourceMasker::removeClientFromCache(RenderObject* client, bool markForInvalidation)
 {
     ASSERT(client);
-
-    if (m_masker.contains(client))
-        delete m_masker.take(client);
+    m_masker.remove(client);
 
     markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
 }
@@ -84,7 +74,7 @@ bool RenderSVGResourceMasker::applyResource(RenderObject* object, RenderStyle*,
 
     bool missingMaskerData = !m_masker.contains(object);
     if (missingMaskerData)
-        m_masker.set(object, new MaskerData);
+        m_masker.set(object, createOwned<MaskerData>().release());
 
     MaskerData* maskerData = m_masker.get(object);
 
index a88bb2f..1331c51 100644 (file)
@@ -61,7 +61,7 @@ private:
     void calculateMaskContentRepaintRect();
 
     FloatRect m_maskContentBoundaries;
-    HashMap<RenderObject*, MaskerData*> m_masker;
+    HashMap<RenderObject*, OwnPtr<MaskerData>> m_masker;
 };
 
 }