Bug 181137 - part 7: Get rid of nsIContentIterator interface r=smaug

Now, nobody requires nsIContentIterator interface.  So, we can get rid of it.

Unfortunately, there is no macro to keep the inherited class,
ContentSubtreeIterator, in the cycle collection to make it keep managing
ContentSubtreeIterator::mRange without nsISupports interface.  Therefore, this
patch moves it into ContentIteratorBase temporarily.  Anyway, the following
patch makes those classes not refcountable.  At that time, this issue will be
fixed.

Differential Revision: https://phabricator.services.mozilla.com/D15927

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-01-11 01:51:42 +00:00
parent a6ef59a998
commit f8844f0d9b
13 changed files with 55 additions and 176 deletions

View File

@ -68,18 +68,11 @@ static bool NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode,
nsContentUtils::ComparePoints(aEnd, beforeNode) > 0; nsContentUtils::ComparePoints(aEnd, beforeNode) > 0;
} }
NS_IMPL_CYCLE_COLLECTING_ADDREF(ContentIteratorBase)
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(ContentIteratorBase,
LastRelease())
NS_INTERFACE_MAP_BEGIN(ContentIteratorBase)
NS_INTERFACE_MAP_ENTRY(nsIContentIterator)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentIterator)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(ContentIteratorBase)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION(ContentIteratorBase, mCurNode, mFirst, mLast, NS_IMPL_CYCLE_COLLECTION(ContentIteratorBase, mCurNode, mFirst, mLast,
mCommonParent) mCommonParent, mRange)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(ContentIteratorBase, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(ContentIteratorBase, Release)
void ContentIteratorBase::LastRelease() { void ContentIteratorBase::LastRelease() {
mCurNode = nullptr; mCurNode = nullptr;
@ -637,32 +630,31 @@ nsINode* ContentIteratorBase::GetCurrentNode() {
* PostContentIterator * PostContentIterator
******************************************************/ ******************************************************/
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(PostContentIterator, NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(PostContentIterator)
ContentIteratorBase) NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE_WITH_LAST_RELEASE(PostContentIterator,
NS_IMPL_CYCLE_COLLECTION_INHERITED(PostContentIterator, ContentIteratorBase) LastRelease())
/****************************************************** /******************************************************
* PreContentIterator * PreContentIterator
******************************************************/ ******************************************************/
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(PreContentIterator, NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(PreContentIterator)
ContentIteratorBase) NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE_WITH_LAST_RELEASE(PreContentIterator,
NS_IMPL_CYCLE_COLLECTION_INHERITED(PreContentIterator, ContentIteratorBase) LastRelease())
/****************************************************** /******************************************************
* ContentSubtreeIterator * ContentSubtreeIterator
******************************************************/ ******************************************************/
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(ContentSubtreeIterator,
ContentIteratorBase)
NS_IMPL_CYCLE_COLLECTION_INHERITED(ContentSubtreeIterator, ContentIteratorBase,
mRange)
void ContentSubtreeIterator::LastRelease() { void ContentSubtreeIterator::LastRelease() {
mRange = nullptr; mRange = nullptr;
ContentIteratorBase::LastRelease(); ContentIteratorBase::LastRelease();
} }
NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(ContentSubtreeIterator)
NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE_WITH_LAST_RELEASE(
ContentSubtreeIterator, LastRelease())
/****************************************************** /******************************************************
* Init routines * Init routines
******************************************************/ ******************************************************/

View File

@ -11,7 +11,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsRange.h" #include "nsRange.h"
#include "nsTArray.h" #include "nsTArray.h"
@ -23,32 +22,37 @@ namespace mozilla {
* classes "final", compiler can avoid virtual calls if they are treated * classes "final", compiler can avoid virtual calls if they are treated
* by the users directly. * by the users directly.
*/ */
class ContentIteratorBase : public nsIContentIterator { class ContentIteratorBase {
protected:
nsCycleCollectingAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
public: public:
ContentIteratorBase() = delete; ContentIteratorBase() = delete;
ContentIteratorBase(const ContentIteratorBase&) = delete; ContentIteratorBase(const ContentIteratorBase&) = delete;
ContentIteratorBase& operator=(const ContentIteratorBase&) = delete; ContentIteratorBase& operator=(const ContentIteratorBase&) = delete;
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
NS_DECL_CYCLE_COLLECTION_CLASS(ContentIteratorBase) NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ContentIteratorBase)
virtual nsresult Init(nsINode* aRoot) override; virtual nsresult Init(nsINode* aRoot);
virtual nsresult Init(nsRange* aRange) override; virtual nsresult Init(nsRange* aRange);
virtual nsresult Init(nsINode* aStartContainer, uint32_t aStartOffset, virtual nsresult Init(nsINode* aStartContainer, uint32_t aStartOffset,
nsINode* aEndContainer, uint32_t aEndOffset) override; nsINode* aEndContainer, uint32_t aEndOffset);
virtual nsresult Init(const RawRangeBoundary& aStart, virtual nsresult Init(const RawRangeBoundary& aStart,
const RawRangeBoundary& aEnd) override; const RawRangeBoundary& aEnd);
virtual void First() override; virtual void First();
virtual void Last() override; virtual void Last();
virtual void Next() override; virtual void Next();
virtual void Prev() override; virtual void Prev();
virtual nsINode* GetCurrentNode() override; virtual nsINode* GetCurrentNode();
virtual bool IsDone() override; virtual bool IsDone();
virtual nsresult PositionAt(nsINode* aCurNode) override; virtual nsresult PositionAt(nsINode* aCurNode);
protected: protected:
explicit ContentIteratorBase(bool aPre); explicit ContentIteratorBase(bool aPre);
@ -88,6 +92,11 @@ class ContentIteratorBase : public nsIContentIterator {
nsCOMPtr<nsINode> mLast; nsCOMPtr<nsINode> mLast;
nsCOMPtr<nsINode> mCommonParent; nsCOMPtr<nsINode> mCommonParent;
// Used only by ContentSubtreeIterator class but we need to put this here
// for cycle collection because macros to implement classes in cycle
// collection do not support inherited classes without nsISupports interface.
RefPtr<nsRange> mRange;
bool mIsDone; bool mIsDone;
bool mPre; bool mPre;
}; };
@ -101,9 +110,8 @@ class PostContentIterator final : public ContentIteratorBase {
PostContentIterator(const PostContentIterator&) = delete; PostContentIterator(const PostContentIterator&) = delete;
PostContentIterator& operator=(const PostContentIterator&) = delete; PostContentIterator& operator=(const PostContentIterator&) = delete;
NS_DECL_ISUPPORTS_INHERITED NS_IMETHOD_(MozExternalRefCountType) AddRef() override;
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PostContentIterator, NS_IMETHOD_(MozExternalRefCountType) Release() override;
ContentIteratorBase)
protected: protected:
virtual ~PostContentIterator() = default; virtual ~PostContentIterator() = default;
@ -118,9 +126,8 @@ class PreContentIterator final : public ContentIteratorBase {
PreContentIterator(const PreContentIterator&) = delete; PreContentIterator(const PreContentIterator&) = delete;
PreContentIterator& operator=(const PreContentIterator&) = delete; PreContentIterator& operator=(const PreContentIterator&) = delete;
NS_DECL_ISUPPORTS_INHERITED NS_IMETHOD_(MozExternalRefCountType) AddRef() override;
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PreContentIterator, NS_IMETHOD_(MozExternalRefCountType) Release() override;
ContentIteratorBase)
protected: protected:
virtual ~PreContentIterator() = default; virtual ~PreContentIterator() = default;
@ -135,9 +142,8 @@ class ContentSubtreeIterator final : public ContentIteratorBase {
ContentSubtreeIterator(const ContentSubtreeIterator&) = delete; ContentSubtreeIterator(const ContentSubtreeIterator&) = delete;
ContentSubtreeIterator& operator=(const ContentSubtreeIterator&) = delete; ContentSubtreeIterator& operator=(const ContentSubtreeIterator&) = delete;
NS_DECL_ISUPPORTS_INHERITED NS_IMETHOD_(MozExternalRefCountType) AddRef() override;
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ContentSubtreeIterator, NS_IMETHOD_(MozExternalRefCountType) Release() override;
ContentIteratorBase)
virtual nsresult Init(nsINode* aRoot) override; virtual nsresult Init(nsINode* aRoot) override;
virtual nsresult Init(nsRange* aRange) override; virtual nsresult Init(nsRange* aRange) override;
@ -172,8 +178,6 @@ class ContentSubtreeIterator final : public ContentIteratorBase {
virtual void LastRelease() override; virtual void LastRelease() override;
RefPtr<nsRange> mRange;
AutoTArray<nsIContent*, 8> mEndNodes; AutoTArray<nsIContent*, 8> mEndNodes;
}; };

View File

@ -27,7 +27,6 @@
#include "nsIContentInlines.h" #include "nsIContentInlines.h"
#include "mozilla/dom/NodeInfo.h" #include "mozilla/dom/NodeInfo.h"
#include "mozilla/dom/DocumentTimeline.h" #include "mozilla/dom/DocumentTimeline.h"
#include "nsIContentIterator.h"
#include "nsFlexContainerFrame.h" #include "nsFlexContainerFrame.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsILinkHandler.h" #include "nsILinkHandler.h"

View File

@ -36,7 +36,6 @@
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/DocumentInlines.h"
#include "nsIDocumentEncoder.h" #include "nsIDocumentEncoder.h"
#include "nsIContentIterator.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsILinkHandler.h" #include "nsILinkHandler.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"

View File

@ -74,7 +74,6 @@ EXPORTS += [
'nsIAnimationObserver.h', 'nsIAnimationObserver.h',
'nsIContent.h', 'nsIContent.h',
'nsIContentInlines.h', 'nsIContentInlines.h',
'nsIContentIterator.h',
'nsIContentSerializer.h', 'nsIContentSerializer.h',
'nsIDocumentObserver.h', 'nsIDocumentObserver.h',
'nsIGlobalObject.h', 'nsIGlobalObject.h',

View File

@ -30,27 +30,6 @@
} \ } \
} }
#define NS_CONTENTITERATOR_CID \
{ /* {a6cf90e3-15b3-11d2-932e-00805f8add32}*/ \
0xa6cf90e3, 0x15b3, 0x11d2, { \
0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 \
} \
}
#define NS_PRECONTENTITERATOR_CID \
{ /* {80D7E247-D4B8-45d7-BB59-6F1DD56F384C} */ \
0x80d7e247, 0xd4b8, 0x45d7, { \
0xbb, 0x59, 0x6f, 0x1d, 0xd5, 0x6f, 0x38, 0x4c \
} \
}
#define NS_SUBTREEITERATOR_CID \
{ /* {a6cf90e5-15b3-11d2-932e-00805f8add32}*/ \
0xa6cf90e5, 0x15b3, 0x11d2, { \
0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 \
} \
}
// {09F689E0-B4DA-11d2-A68B-00104BDE6048} // {09F689E0-B4DA-11d2-A68B-00104BDE6048}
#define NS_EVENTLISTENERMANAGER_CID \ #define NS_EVENTLISTENERMANAGER_CID \
{ \ { \

View File

@ -98,7 +98,6 @@
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "GeckoProfiler.h" #include "GeckoProfiler.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "nsIContentIterator.h"
#include "nsIStyleSheetService.h" #include "nsIStyleSheetService.h"
#include "nsContentPermissionHelper.h" #include "nsContentPermissionHelper.h"
#include "nsCSSPseudoElements.h" // for CSSPseudoElementType #include "nsCSSPseudoElements.h" // for CSSPseudoElementType

View File

@ -1,86 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __nsIContentIterator_h___
#define __nsIContentIterator_h___
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "mozilla/RangeBoundary.h"
class nsINode;
class nsRange;
#define NS_ICONTENTITERATOR_IID \
{ \
0x2550078e, 0xae87, 0x4914, { \
0xb3, 0x04, 0xe4, 0xd1, 0x46, 0x19, 0x3d, 0x5f \
} \
}
class nsIContentIterator : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTITERATOR_IID)
/* Initializes an iterator for the subtree rooted by the node aRoot
*/
virtual nsresult Init(nsINode* aRoot) = 0;
/* Initializes an iterator for the subtree defined by the range aRange
Subclasses should make sure they implement both of these!
*/
virtual nsresult Init(nsRange* aRange) = 0;
/* Initializes an iterator for the subtree between
aStartContainer/aStartOffset and aEndContainer/aEndOffset
Callers should guarantee that the start point and end point are in
document order.
*/
virtual nsresult Init(nsINode* aStartContainer, uint32_t aStartOffset,
nsINode* aEndContainer, uint32_t aEndOffset) = 0;
/* Initializes an iterator for the subtree between aStart and aEnd.
Callers should guarantee that the start point and end point are in
document order.
*/
virtual nsresult Init(const mozilla::RawRangeBoundary& aStart,
const mozilla::RawRangeBoundary& aEnd) = 0;
/** First will reset the list.
*/
virtual void First() = 0;
/** Last will reset the list to the end.
*/
virtual void Last() = 0;
/** Next will advance the list.
*/
virtual void Next() = 0;
/** Prev will decrement the list.
*/
virtual void Prev() = 0;
/** CurrentItem will return the current item, or null if the list is empty
* @return the current node
*/
virtual nsINode* GetCurrentNode() = 0;
/** return if the collection is at the end. that is the beginning following a
* call to Prev and it is the end of the list following a call to next
* @return if the iterator is done.
*/
virtual bool IsDone() = 0;
/** PositionAt will position the iterator to the supplied node
*/
virtual nsresult PositionAt(nsINode* aCurNode) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentIterator, NS_ICONTENTITERATOR_IID)
#endif // __nsIContentIterator_h___

View File

@ -60,7 +60,6 @@
#include "nsIBaseWindow.h" #include "nsIBaseWindow.h"
#include "nsICategoryManager.h" #include "nsICategoryManager.h"
#include "nsIContentInlines.h" #include "nsIContentInlines.h"
#include "nsIContentIterator.h"
#include "nsIControllers.h" #include "nsIControllers.h"
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "nsIDOMEventListener.h" #include "nsIDOMEventListener.h"

View File

@ -10,7 +10,7 @@ webidl Range;
/** /**
* nsIScriptableContentIterator is designed to testing concrete classes of * nsIScriptableContentIterator is designed to testing concrete classes of
* nsIContentIterator. * ContentIteratorBase.
*/ */
[scriptable, builtinclass, uuid(9f25fb2a-265f-44f9-a122-62bbf443239e)] [scriptable, builtinclass, uuid(9f25fb2a-265f-44f9-a122-62bbf443239e)]
interface nsIScriptableContentIterator : nsISupports interface nsIScriptableContentIterator : nsISupports
@ -30,38 +30,38 @@ interface nsIScriptableContentIterator : nsISupports
* exception. * exception.
*/ */
// See nsIContentIterator::Init(nsINode*) // See ContentIteratorBase::Init(nsINode*)
void initWithRootNode(in nsIScriptableContentIterator_IteratorType aType, void initWithRootNode(in nsIScriptableContentIterator_IteratorType aType,
in Node aRoot); in Node aRoot);
// See nsIContentIterator::Init(nsRange*) // See ContentIteratorBase::Init(nsRange*)
void initWithRange(in nsIScriptableContentIterator_IteratorType aType, void initWithRange(in nsIScriptableContentIterator_IteratorType aType,
in Range aRange); in Range aRange);
// See nsIContentIterator::Init(nsINode*, uint32_t, nsINode*, uint32_t) // See ContentIteratorBase::Init(nsINode*, uint32_t, nsINode*, uint32_t)
void initWithPositions(in nsIScriptableContentIterator_IteratorType aType, void initWithPositions(in nsIScriptableContentIterator_IteratorType aType,
in Node aStartContainer, in unsigned long aStartOffset, in Node aStartContainer, in unsigned long aStartOffset,
in Node aEndContainer, in unsigned long aEndOffset); in Node aEndContainer, in unsigned long aEndOffset);
// See nsIContentIterator::First() // See ContentIteratorBase::First()
void first(); void first();
// See nsIContentIterator::Last() // See ContentIteratorBase::Last()
void last(); void last();
// See nsIContentIterator::Next() // See ContentIteratorBase::Next()
void next(); void next();
// See nsIContentIterator::Prev() // See ContentIteratorBase::Prev()
void prev(); void prev();
// See nsIContentIterator::GetCurrentNode() // See ContentIteratorBase::GetCurrentNode()
readonly attribute Node currentNode; readonly attribute Node currentNode;
// See nsIContentIterator::IsDone() // See ContentIteratorBase::IsDone()
readonly attribute bool isDone; readonly attribute bool isDone;
// See nsIContentIterator::PositionAt(nsINode*) // See ContentIteratorBase::PositionAt(nsINode*)
void positionAt(in Node aNode); void positionAt(in Node aNode);
}; };

View File

@ -29,7 +29,6 @@
#include "nsTableCellFrame.h" #include "nsTableCellFrame.h"
#include "nsIScrollableFrame.h" #include "nsIScrollableFrame.h"
#include "nsCCUncollectableMarker.h" #include "nsCCUncollectableMarker.h"
#include "nsIContentIterator.h"
#include "nsIDocumentEncoder.h" #include "nsIDocumentEncoder.h"
#include "nsTextFragment.h" #include "nsTextFragment.h"
#include <algorithm> #include <algorithm>

View File

@ -35,9 +35,6 @@ using namespace mozilla::dom;
// Yikes! Casting a char to unichar can fill with ones! // Yikes! Casting a char to unichar can fill with ones!
#define CHAR_TO_UNICHAR(c) ((char16_t)(unsigned char)c) #define CHAR_TO_UNICHAR(c) ((char16_t)(unsigned char)c)
static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
static NS_DEFINE_CID(kCPreContentIteratorCID, NS_PRECONTENTITERATOR_CID);
#define CH_QUOTE ((char16_t)0x22) #define CH_QUOTE ((char16_t)0x22)
#define CH_APOSTROPHE ((char16_t)0x27) #define CH_APOSTROPHE ((char16_t)0x27)
#define CH_LEFT_SINGLE_QUOTE ((char16_t)0x2018) #define CH_LEFT_SINGLE_QUOTE ((char16_t)0x2018)

View File

@ -12,7 +12,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsINode.h" #include "nsINode.h"
#include "nsIContentIterator.h"
#include "mozilla/intl/WordBreaker.h" #include "mozilla/intl/WordBreaker.h"
class nsIContent; class nsIContent;