From 0d49bfddd3271d9a54fe2f9f94bac35c73020d6a Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Tue, 2 Apr 2013 15:17:40 -0400 Subject: [PATCH] Bug 855597: Make SVGTransform not inherit nsISupports r=longsonr --- content/svg/content/src/DOMSVGTransform.cpp | 16 ++-------------- content/svg/content/src/DOMSVGTransform.h | 19 +++---------------- .../svg/content/src/DOMSVGTransformList.cpp | 10 +++++----- dom/bindings/Bindings.conf | 1 + 4 files changed, 11 insertions(+), 35 deletions(-) diff --git a/content/svg/content/src/DOMSVGTransform.cpp b/content/svg/content/src/DOMSVGTransform.cpp index b7a8dbe700f6..fda47db20f20 100644 --- a/content/svg/content/src/DOMSVGTransform.cpp +++ b/content/svg/content/src/DOMSVGTransform.cpp @@ -20,7 +20,6 @@ using namespace dom; static nsSVGAttrTearoffTable sSVGMatrixTearoffTable; //---------------------------------------------------------------------- -// nsISupports methods: // We could use NS_IMPL_CYCLE_COLLECTION_1, except that in Unlink() we need to // clear our list's weak ref to us to be safe. (The other option would be to @@ -43,19 +42,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGTransform) -NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER -NS_IMPL_CYCLE_COLLECTION_TRACE_END - -NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGTransform) -NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGTransform) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGTransform) - NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_MAP_ENTRY(mozilla::DOMSVGTransform) - NS_INTERFACE_MAP_ENTRY(nsISupports) -NS_INTERFACE_MAP_END - +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMSVGTransform, AddRef) +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMSVGTransform, Release) JSObject* DOMSVGTransform::WrapObject(JSContext* aCx, JSObject* aScope) diff --git a/content/svg/content/src/DOMSVGTransform.h b/content/svg/content/src/DOMSVGTransform.h index a77394fe54c3..46666e301b44 100644 --- a/content/svg/content/src/DOMSVGTransform.h +++ b/content/svg/content/src/DOMSVGTransform.h @@ -20,15 +20,6 @@ class nsSVGElement; struct gfxMatrix; -// We make DOMSVGTransform a pseudo-interface to allow us to QI to it in order -// to check that the objects that scripts pass in are our our *native* transform -// objects. -// -// {0A799862-9469-41FE-B4CD-2019E65D8DA6} -#define MOZILLA_DOMSVGTRANSFORM_IID \ - { 0x0A799862, 0x9469, 0x41FE, \ - { 0xB4, 0xCD, 0x20, 0x19, 0xE6, 0x5D, 0x8D, 0xA6 } } - #define MOZ_SVG_LIST_INDEX_BIT_COUNT 31 // supports > 2 billion list items namespace mozilla { @@ -40,13 +31,11 @@ class SVGMatrix; /** * DOM wrapper for an SVG transform. See DOMSVGLength.h. */ -class DOMSVGTransform MOZ_FINAL : public nsISupports, - public nsWrapperCache +class DOMSVGTransform MOZ_FINAL : public nsWrapperCache { public: - NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGTRANSFORM_IID) - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGTransform) + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMSVGTransform) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMSVGTransform) /** * Generic ctor for DOMSVGTransform objects that are created for an attribute. @@ -194,8 +183,6 @@ private: nsAutoPtr mTransform; }; -NS_DEFINE_STATIC_IID_ACCESSOR(DOMSVGTransform, MOZILLA_DOMSVGTRANSFORM_IID) - nsAttrValue DOMSVGTransform::NotifyElementWillChange() { diff --git a/content/svg/content/src/DOMSVGTransformList.cpp b/content/svg/content/src/DOMSVGTransformList.cpp index dce27074b5da..9baf4218530b 100644 --- a/content/svg/content/src/DOMSVGTransformList.cpp +++ b/content/svg/content/src/DOMSVGTransformList.cpp @@ -161,7 +161,7 @@ DOMSVGTransformList::Initialize(DOMSVGTransform& newItem, ErrorResult& error) // clone of newItem, it would actually insert newItem. To prevent that from // happening we have to do the clone here, if necessary. - nsCOMPtr domItem = &newItem; + nsRefPtr domItem = &newItem; if (domItem->HasOwner()) { domItem = newItem.Clone(); } @@ -201,7 +201,7 @@ DOMSVGTransformList::InsertItemBefore(DOMSVGTransform& newItem, return nullptr; } - nsCOMPtr domItem = &newItem; + nsRefPtr domItem = &newItem; if (newItem.HasOwner()) { domItem = newItem.Clone(); // must do this before changing anything! } @@ -248,7 +248,7 @@ DOMSVGTransformList::ReplaceItem(DOMSVGTransform& newItem, return nullptr; } - nsCOMPtr domItem = &newItem; + nsRefPtr domItem = &newItem; if (newItem.HasOwner()) { domItem = newItem.Clone(); // must do this before changing anything! } @@ -299,7 +299,7 @@ DOMSVGTransformList::RemoveItem(uint32_t index, ErrorResult& error) // Notify the DOM item of removal *before* modifying the lists so that the // DOM item can copy its *old* value: mItems[index]->RemovingFromList(); - nsCOMPtr result = mItems[index]; + nsRefPtr result = mItems[index]; InternalList().RemoveItem(index); mItems.RemoveElementAt(index); @@ -316,7 +316,7 @@ DOMSVGTransformList::RemoveItem(uint32_t index, ErrorResult& error) already_AddRefed DOMSVGTransformList::CreateSVGTransformFromMatrix(dom::SVGMatrix& matrix) { - nsCOMPtr result = new DOMSVGTransform(matrix.Matrix()); + nsRefPtr result = new DOMSVGTransform(matrix.Matrix()); return result.forget(); } diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index f66068b4aaf5..787fee472fc0 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -909,6 +909,7 @@ DOMInterfaces = { 'SVGTransform': { 'nativeType': 'mozilla::DOMSVGTransform', 'headerFile': 'DOMSVGTransform.h', + 'nativeOwnership': 'refcounted', 'resultNotAddRefed': [ 'matrix' ] },