Bug 1037643 - Part 4 - Cycle collect HTMLImageElement/ResponsiveImageSelector r=mccr8
authorJohn Schoenick <jschoenick@mozilla.com>
Mon, 13 Oct 2014 13:36:01 -0700
changeset 212309 7e0376b11638ab7b75669de970233c97b9a1bb59
parent 212308 73a28e6fbe84fe18d5077d7018e5a6c3661183a9
child 212310 f81dc8f11838719ce4353a4ead078a4481668fbe
push id27704
push userkwierso@gmail.com
push dateSat, 25 Oct 2014 01:25:30 +0000
treeherdermozilla-central@e37231060eb4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1037643
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1037643 - Part 4 - Cycle collect HTMLImageElement/ResponsiveImageSelector r=mccr8
content/base/src/ResponsiveImageSelector.cpp
content/base/src/ResponsiveImageSelector.h
content/html/content/src/HTMLImageElement.cpp
content/html/content/src/HTMLImageElement.h
--- a/content/base/src/ResponsiveImageSelector.cpp
+++ b/content/base/src/ResponsiveImageSelector.cpp
@@ -17,17 +17,20 @@
 #include "nsRuleData.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_ISUPPORTS0(ResponsiveImageSelector);
+NS_IMPL_CYCLE_COLLECTION(ResponsiveImageSelector, mContent)
+
+NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(ResponsiveImageSelector, AddRef)
+NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(ResponsiveImageSelector, Release)
 
 static bool
 ParseInteger(const nsAString& aString, int32_t& aInt)
 {
   nsContentUtils::ParseHTMLIntegerResultFlags parseResult;
   aInt = nsContentUtils::ParseHTMLInteger(aString, &parseResult);
   return !(parseResult &
            ( nsContentUtils::eParseHTMLInteger_Error |
--- a/content/base/src/ResponsiveImageSelector.h
+++ b/content/base/src/ResponsiveImageSelector.h
@@ -4,30 +4,33 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_responsiveimageselector_h__
 #define mozilla_dom_responsiveimageselector_h__
 
 #include "nsISupports.h"
 #include "nsIContent.h"
 #include "nsString.h"
+#include "nsCycleCollectionParticipant.h"
 
 class nsMediaQuery;
 class nsCSSValue;
 
 namespace mozilla {
 namespace dom {
 
 class ResponsiveImageCandidate;
 
-class ResponsiveImageSelector : public nsISupports
+class ResponsiveImageSelector
 {
   friend class ResponsiveImageCandidate;
 public:
-  NS_DECL_ISUPPORTS
+  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ResponsiveImageSelector)
+  NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ResponsiveImageSelector)
+
   explicit ResponsiveImageSelector(nsIContent* aContent);
 
   // NOTE ABOUT CURRENT SELECTION
   //
   // The best candidate is selected lazily when GetSelectedImage*() is
   // called, or when SelectImage() is called explicitly. This result
   // is then cached until either invalidated by further Set*() calls,
   // or explicitly by replaced by SelectImage(aReselect = true).
--- a/content/html/content/src/HTMLImageElement.cpp
+++ b/content/html/content/src/HTMLImageElement.cpp
@@ -111,16 +111,19 @@ HTMLImageElement::~HTMLImageElement()
 {
   DestroyImageLoadingContent();
 }
 
 
 NS_IMPL_ADDREF_INHERITED(HTMLImageElement, Element)
 NS_IMPL_RELEASE_INHERITED(HTMLImageElement, Element)
 
+NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLImageElement,
+                                   nsGenericHTMLElement,
+                                   mResponsiveSelector)
 
 // QueryInterface implementation for HTMLImageElement
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLImageElement)
   NS_INTERFACE_TABLE_INHERITED(HTMLImageElement,
                                nsIDOMHTMLImageElement,
                                nsIImageLoadingContent,
                                imgIOnloadBlocker,
                                imgINotificationObserver)
--- a/content/html/content/src/HTMLImageElement.h
+++ b/content/html/content/src/HTMLImageElement.h
@@ -7,16 +7,17 @@
 #define mozilla_dom_HTMLImageElement_h
 
 #include "mozilla/Attributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsImageLoadingContent.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "imgRequestProxy.h"
 #include "Units.h"
+#include "nsCycleCollectionParticipant.h"
 
 // Only needed for IsPictureEnabled()
 #include "mozilla/dom/HTMLPictureElement.h"
 
 namespace mozilla {
 class EventChainPreVisitor;
 namespace dom {
 
@@ -32,16 +33,19 @@ public:
   explicit HTMLImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
 
   static already_AddRefed<HTMLImageElement>
     Image(const GlobalObject& aGlobal,
           const Optional<uint32_t>& aWidth,
           const Optional<uint32_t>& aHeight,
           ErrorResult& aError);
 
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLImageElement,
+                                           nsGenericHTMLElement)
+
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual bool Draggable() const MOZ_OVERRIDE;
 
   // nsIDOMHTMLImageElement
   NS_DECL_NSIDOMHTMLIMAGEELEMENT