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

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

Issue 23537049: Merge 157801 "Fix lifetime handling of SVGPropertyTearOffs." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1599/
Patch Set: 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
===================================================================
--- Source/core/svg/properties/SVGPropertyTearOff.h (revision 157841)
+++ Source/core/svg/properties/SVGPropertyTearOff.h (working copy)
@@ -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 @@
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 @@
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;
};
Property changes on: Source/core/svg/properties/SVGPropertyTearOff.h
___________________________________________________________________
Modified: svn:eol-style
- native
+ LF
« 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