Commit 909ece73 authored by andersca@apple.com's avatar 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:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155547 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e7508bc8
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> 2013-09-10 Simon Fraser <simon.fraser@apple.com>
REGRESSION (143483): overflow:hidden doesn't quash big repaints from text-indent: -9999px REGRESSION (143483): overflow:hidden doesn't quash big repaints from text-indent: -9999px
...@@ -60,20 +60,12 @@ RenderSVGResourceClipper::RenderSVGResourceClipper(SVGClipPathElement* node) ...@@ -60,20 +60,12 @@ RenderSVGResourceClipper::RenderSVGResourceClipper(SVGClipPathElement* node)
RenderSVGResourceClipper::~RenderSVGResourceClipper() RenderSVGResourceClipper::~RenderSVGResourceClipper()
{ {
if (m_clipper.isEmpty())
return;
deleteAllValues(m_clipper);
m_clipper.clear();
} }
void RenderSVGResourceClipper::removeAllClientsFromCache(bool markForInvalidation) void RenderSVGResourceClipper::removeAllClientsFromCache(bool markForInvalidation)
{ {
m_clipBoundaries = FloatRect(); m_clipBoundaries = FloatRect();
if (!m_clipper.isEmpty()) { m_clipper.clear();
deleteAllValues(m_clipper);
m_clipper.clear();
}
markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation); markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation);
} }
...@@ -81,8 +73,7 @@ void RenderSVGResourceClipper::removeAllClientsFromCache(bool markForInvalidatio ...@@ -81,8 +73,7 @@ void RenderSVGResourceClipper::removeAllClientsFromCache(bool markForInvalidatio
void RenderSVGResourceClipper::removeClientFromCache(RenderObject* client, bool markForInvalidation) void RenderSVGResourceClipper::removeClientFromCache(RenderObject* client, bool markForInvalidation)
{ {
ASSERT(client); ASSERT(client);
if (m_clipper.contains(client)) m_clipper.remove(client);
delete m_clipper.take(client);
markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation); markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
} }
...@@ -156,7 +147,7 @@ bool RenderSVGResourceClipper::applyClippingToContext(RenderObject* object, cons ...@@ -156,7 +147,7 @@ bool RenderSVGResourceClipper::applyClippingToContext(RenderObject* object, cons
{ {
bool missingClipperData = !m_clipper.contains(object); bool missingClipperData = !m_clipper.contains(object);
if (missingClipperData) if (missingClipperData)
m_clipper.set(object, new ClipperData); m_clipper.set(object, createOwned<ClipperData>().release());
bool shouldCreateClipData = false; bool shouldCreateClipData = false;
AffineTransform animatedLocalTransform = toSVGClipPathElement(element())->animatedLocalTransform(); AffineTransform animatedLocalTransform = toSVGClipPathElement(element())->animatedLocalTransform();
......
...@@ -71,7 +71,7 @@ private: ...@@ -71,7 +71,7 @@ private:
void calculateClipContentRepaintRect(); void calculateClipContentRepaintRect();
FloatRect m_clipBoundaries; FloatRect m_clipBoundaries;
HashMap<RenderObject*, ClipperData*> m_clipper; HashMap<RenderObject*, OwnPtr<ClipperData>> m_clipper;
}; };
} }
......
...@@ -65,19 +65,11 @@ RenderSVGResourceFilter::RenderSVGResourceFilter(SVGFilterElement* node) ...@@ -65,19 +65,11 @@ RenderSVGResourceFilter::RenderSVGResourceFilter(SVGFilterElement* node)
RenderSVGResourceFilter::~RenderSVGResourceFilter() RenderSVGResourceFilter::~RenderSVGResourceFilter()
{ {
if (m_filter.isEmpty())
return;
deleteAllValues(m_filter);
m_filter.clear();
} }
void RenderSVGResourceFilter::removeAllClientsFromCache(bool markForInvalidation) void RenderSVGResourceFilter::removeAllClientsFromCache(bool markForInvalidation)
{ {
if (!m_filter.isEmpty()) { m_filter.clear();
deleteAllValues(m_filter);
m_filter.clear();
}
markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation); markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation);
} }
...@@ -90,7 +82,7 @@ void RenderSVGResourceFilter::removeClientFromCache(RenderObject* client, bool m ...@@ -90,7 +82,7 @@ void RenderSVGResourceFilter::removeClientFromCache(RenderObject* client, bool m
if (filterData->savedContext) if (filterData->savedContext)
filterData->state = FilterData::MarkedForRemoval; filterData->state = FilterData::MarkedForRemoval;
else else
delete m_filter.take(client); m_filter.remove(client);
} }
markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation); markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
...@@ -155,7 +147,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*, ...@@ -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. 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(); FloatRect targetBoundingBox = object->objectBoundingBox();
SVGFilterElement* filterElement = toSVGFilterElement(element()); SVGFilterElement* filterElement = toSVGFilterElement(element());
...@@ -224,7 +216,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*, ...@@ -224,7 +216,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*,
if (filterData->drawingRegion.isEmpty()) { if (filterData->drawingRegion.isEmpty()) {
ASSERT(!m_filter.contains(object)); ASSERT(!m_filter.contains(object));
filterData->savedContext = context; filterData->savedContext = context;
m_filter.set(object, filterData.leakPtr()); m_filter.set(object, filterData.release());
return false; return false;
} }
...@@ -238,7 +230,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*, ...@@ -238,7 +230,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*,
if (!SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, sourceGraphic, ColorSpaceLinearRGB, renderingMode)) { if (!SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, sourceGraphic, ColorSpaceLinearRGB, renderingMode)) {
ASSERT(!m_filter.contains(object)); ASSERT(!m_filter.contains(object));
filterData->savedContext = context; filterData->savedContext = context;
m_filter.set(object, filterData.leakPtr()); m_filter.set(object, filterData.release());
return false; return false;
} }
...@@ -254,7 +246,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*, ...@@ -254,7 +246,7 @@ bool RenderSVGResourceFilter::applyResource(RenderObject* object, RenderStyle*,
context = sourceGraphicContext; context = sourceGraphicContext;
ASSERT(!m_filter.contains(object)); ASSERT(!m_filter.contains(object));
m_filter.set(object, filterData.leakPtr()); m_filter.set(object, filterData.release());
return true; return true;
} }
...@@ -271,7 +263,7 @@ void RenderSVGResourceFilter::postApplyResource(RenderObject* object, GraphicsCo ...@@ -271,7 +263,7 @@ void RenderSVGResourceFilter::postApplyResource(RenderObject* object, GraphicsCo
switch (filterData->state) { switch (filterData->state) {
case FilterData::MarkedForRemoval: case FilterData::MarkedForRemoval:
delete m_filter.take(object); m_filter.remove(object);
return; return;
case FilterData::CycleDetected: case FilterData::CycleDetected:
...@@ -338,12 +330,10 @@ FloatRect RenderSVGResourceFilter::resourceBoundingBox(RenderObject* object) ...@@ -338,12 +330,10 @@ FloatRect RenderSVGResourceFilter::resourceBoundingBox(RenderObject* object)
void RenderSVGResourceFilter::primitiveAttributeChanged(RenderObject* object, const QualifiedName& attribute) 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()); SVGFilterPrimitiveStandardAttributes* primitve = static_cast<SVGFilterPrimitiveStandardAttributes*>(object->node());
for (; it != end; ++it) { for (auto it = m_filter.begin(), end = m_filter.end(); it != end; ++it) {
FilterData* filterData = it->value; const auto &filterData = it->value;
if (filterData->state != FilterData::Built) if (filterData->state != FilterData::Built)
continue; continue;
......
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
private: private:
bool fitsInMaximumImageSize(const FloatSize&, FloatSize&); bool fitsInMaximumImageSize(const FloatSize&, FloatSize&);
HashMap<RenderObject*, FilterData*> m_filter; HashMap<RenderObject*, OwnPtr<FilterData>> m_filter;
}; };
inline RenderSVGResourceFilter* toRenderSVGFilter(RenderObject* object) inline RenderSVGResourceFilter* toRenderSVGFilter(RenderObject* object)
......
...@@ -48,20 +48,12 @@ RenderSVGResourceMasker::RenderSVGResourceMasker(SVGMaskElement* node) ...@@ -48,20 +48,12 @@ RenderSVGResourceMasker::RenderSVGResourceMasker(SVGMaskElement* node)
RenderSVGResourceMasker::~RenderSVGResourceMasker() RenderSVGResourceMasker::~RenderSVGResourceMasker()
{ {
if (m_masker.isEmpty())
return;
deleteAllValues(m_masker);
m_masker.clear();
} }
void RenderSVGResourceMasker::removeAllClientsFromCache(bool markForInvalidation) void RenderSVGResourceMasker::removeAllClientsFromCache(bool markForInvalidation)
{ {
m_maskContentBoundaries = FloatRect(); m_maskContentBoundaries = FloatRect();
if (!m_masker.isEmpty()) { m_masker.clear();
deleteAllValues(m_masker);
m_masker.clear();
}
markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation); markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation);
} }
...@@ -69,9 +61,7 @@ void RenderSVGResourceMasker::removeAllClientsFromCache(bool markForInvalidation ...@@ -69,9 +61,7 @@ void RenderSVGResourceMasker::removeAllClientsFromCache(bool markForInvalidation
void RenderSVGResourceMasker::removeClientFromCache(RenderObject* client, bool markForInvalidation) void RenderSVGResourceMasker::removeClientFromCache(RenderObject* client, bool markForInvalidation)
{ {
ASSERT(client); ASSERT(client);
m_masker.remove(client);
if (m_masker.contains(client))
delete m_masker.take(client);
markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation); markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
} }
...@@ -84,7 +74,7 @@ bool RenderSVGResourceMasker::applyResource(RenderObject* object, RenderStyle*, ...@@ -84,7 +74,7 @@ bool RenderSVGResourceMasker::applyResource(RenderObject* object, RenderStyle*,
bool missingMaskerData = !m_masker.contains(object); bool missingMaskerData = !m_masker.contains(object);
if (missingMaskerData) if (missingMaskerData)
m_masker.set(object, new MaskerData); m_masker.set(object, createOwned<MaskerData>().release());
MaskerData* maskerData = m_masker.get(object); MaskerData* maskerData = m_masker.get(object);
......
...@@ -61,7 +61,7 @@ private: ...@@ -61,7 +61,7 @@ private:
void calculateMaskContentRepaintRect(); void calculateMaskContentRepaintRect();
FloatRect m_maskContentBoundaries; FloatRect m_maskContentBoundaries;
HashMap<RenderObject*, MaskerData*> m_masker; HashMap<RenderObject*, OwnPtr<MaskerData>> m_masker;
}; };
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment