Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Unified Diff: Source/core/svg/properties/SVGPropertyTearOff.h

Issue 23995018: Fix lifetime handling of SVGPropertyTearOffs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix ownership Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/svg/properties/SVGPropertyTearOff.h
diff --git a/Source/core/svg/properties/SVGPropertyTearOff.h b/Source/core/svg/properties/SVGPropertyTearOff.h
index ac22ff81825a79580ff0c98db26add7dbe3f6970..0d3b45ce7b1e8a5863739e46441cd5cc21894a81 100644
--- a/Source/core/svg/properties/SVGPropertyTearOff.h
+++ b/Source/core/svg/properties/SVGPropertyTearOff.h
@@ -23,11 +23,17 @@
#include "core/svg/SVGElement.h"
#include "core/svg/properties/SVGAnimatedProperty.h"
#include "core/svg/properties/SVGProperty.h"
+#include "wtf/WeakPtr.h"
namespace WebCore {
+class SVGPropertyTearOffBase : public SVGProperty {
+public:
+ virtual void detachWrapper() = 0;
+};
+
template<typename PropertyType>
-class SVGPropertyTearOff : public SVGProperty {
+class SVGPropertyTearOff : public SVGPropertyTearOffBase {
public:
typedef SVGPropertyTearOff<PropertyType> Self;
@@ -71,11 +77,18 @@ public:
return m_contextElement.get();
}
- void detachWrapper()
+ void addChild(WeakPtr<SVGPropertyTearOffBase> child)
+ {
+ m_childTearOffs.append(child);
+ }
+
+ virtual void detachWrapper() OVERRIDE
{
if (m_valueIsCopy)
return;
+ detachChildren();
+
// Switch from a live value, to a non-live value.
// For example: <text x="50"/>
// var item = text.x.baseVal.getItem(0);
@@ -132,10 +145,20 @@ protected:
delete m_value;
}
+ void detachChildren()
+ {
+ for (Vector<WeakPtr<SVGPropertyTearOffBase> >::iterator iter = m_childTearOffs.begin(); iter != m_childTearOffs.end(); iter++) {
+ if (iter->get())
+ iter->get()->detachWrapper();
+ }
+ m_childTearOffs.clear();
+ }
+
RefPtr<SVGElement> m_contextElement;
SVGAnimatedProperty* m_animatedProperty;
SVGPropertyRole m_role;
PropertyType* m_value;
+ Vector<WeakPtr<SVGPropertyTearOffBase> > m_childTearOffs;
bool m_valueIsCopy : 1;
};
« no previous file with comments | « Source/core/svg/properties/SVGMatrixTearOff.h ('k') | Source/core/svg/properties/SVGStaticPropertyWithParentTearOff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698