Bug 1639376 - Implement unlink for nsXMLContentSink. r=peterv
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 04 Mar 2021 16:17:03 +0000
changeset 637015 a81fb37afb2bd7ce8b6d4b6272c505dbee4cf489
parent 637014 3c6cb17aa63aeb0f7c9a22e83be9095b871ad7bc
child 637016 c1486fd2c34c15e50ff9c11d62868024653b4605
push id15212
push userffxbld-merge
push dateMon, 22 Mar 2021 14:40:41 +0000
treeherdermozilla-beta@ad9bae9bb10c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1639376
milestone88.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 1639376 - Implement unlink for nsXMLContentSink. r=peterv Differential Revision: https://phabricator.services.mozilla.com/D107234
dom/xml/nsXMLContentSink.cpp
dom/xml/nsXMLContentSink.h
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -108,39 +108,40 @@ nsresult nsXMLContentSink::Init(Document
   }
 
   mState = eXMLContentSinkState_InProlog;
   mDocElement = nullptr;
 
   return NS_OK;
 }
 
+inline void ImplCycleCollectionTraverse(
+    nsCycleCollectionTraversalCallback& aCallback,
+    nsXMLContentSink::StackNode& aField, const char* aName,
+    uint32_t aFlags = 0) {
+  ImplCycleCollectionTraverse(aCallback, aField.mContent, aName, aFlags);
+}
+
+inline void ImplCycleCollectionUnlink(nsXMLContentSink::StackNode& aField) {
+  ImplCycleCollectionUnlink(aField.mContent);
+}
+
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXMLContentSink)
   NS_INTERFACE_MAP_ENTRY(nsIContentSink)
   NS_INTERFACE_MAP_ENTRY(nsIXMLContentSink)
   NS_INTERFACE_MAP_ENTRY(nsIExpatSink)
   NS_INTERFACE_MAP_ENTRY(nsITransformObserver)
 NS_INTERFACE_MAP_END_INHERITING(nsContentSink)
 
 NS_IMPL_ADDREF_INHERITED(nsXMLContentSink, nsContentSink)
 NS_IMPL_RELEASE_INHERITED(nsXMLContentSink, nsContentSink)
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsXMLContentSink)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLContentSink,
-                                                  nsContentSink)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCurrentHead)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocElement)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLastTextNode)
-  for (uint32_t i = 0, count = tmp->mContentStack.Length(); i < count; i++) {
-    const StackNode& node = tmp->mContentStack.ElementAt(i);
-    cb.NoteXPCOMChild(node.mContent);
-  }
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocumentChildren)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+NS_IMPL_CYCLE_COLLECTION_INHERITED(nsXMLContentSink, nsContentSink,
+                                   mCurrentHead, mDocElement, mLastTextNode,
+                                   mContentStack, mDocumentChildren)
 
 // nsIContentSink
 NS_IMETHODIMP
 nsXMLContentSink::WillParse(void) { return WillParseImpl(); }
 
 NS_IMETHODIMP
 nsXMLContentSink::WillBuildModel(nsDTDMode aDTDMode) {
   WillBuildModelImpl();
@@ -774,17 +775,17 @@ nsresult nsXMLContentSink::FlushText(boo
 
 nsIContent* nsXMLContentSink::GetCurrentContent() {
   if (mContentStack.Length() == 0) {
     return nullptr;
   }
   return GetCurrentStackNode()->mContent;
 }
 
-StackNode* nsXMLContentSink::GetCurrentStackNode() {
+nsXMLContentSink::StackNode* nsXMLContentSink::GetCurrentStackNode() {
   int32_t count = mContentStack.Length();
   return count != 0 ? &mContentStack[count - 1] : nullptr;
 }
 
 nsresult nsXMLContentSink::PushContent(nsIContent* aContent) {
   MOZ_ASSERT(aContent, "Null content being pushed!");
   StackNode* sn = mContentStack.AppendElement();
   NS_ENSURE_TRUE(sn, NS_ERROR_OUT_OF_MEMORY);
--- a/dom/xml/nsXMLContentSink.h
+++ b/dom/xml/nsXMLContentSink.h
@@ -32,36 +32,35 @@ class ProcessingInstruction;
 }  // namespace mozilla
 
 typedef enum {
   eXMLContentSinkState_InProlog,
   eXMLContentSinkState_InDocumentElement,
   eXMLContentSinkState_InEpilog
 } XMLContentSinkState;
 
-struct StackNode {
-  nsCOMPtr<nsIContent> mContent;
-  uint32_t mNumFlushed;
-};
-
 class nsXMLContentSink : public nsContentSink,
                          public nsIXMLContentSink,
                          public nsITransformObserver,
                          public nsIExpatSink {
  public:
+  struct StackNode {
+    nsCOMPtr<nsIContent> mContent;
+    uint32_t mNumFlushed;
+  };
+
   nsXMLContentSink();
 
   nsresult Init(mozilla::dom::Document* aDoc, nsIURI* aURL,
                 nsISupports* aContainer, nsIChannel* aChannel);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXMLContentSink,
-                                                     nsContentSink)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXMLContentSink, nsContentSink)
 
   NS_DECL_NSIEXPATSINK
 
   // nsIContentSink
   NS_IMETHOD WillParse(void) override;
   NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
   NS_IMETHOD DidBuildModel(bool aTerminated) override;
   NS_IMETHOD WillInterrupt(void) override;