mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
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:
parent
a6ef59a998
commit
f8844f0d9b
@ -68,18 +68,11 @@ static bool NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode,
|
||||
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,
|
||||
mCommonParent)
|
||||
mCommonParent, mRange)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(ContentIteratorBase, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(ContentIteratorBase, Release)
|
||||
|
||||
void ContentIteratorBase::LastRelease() {
|
||||
mCurNode = nullptr;
|
||||
@ -637,32 +630,31 @@ nsINode* ContentIteratorBase::GetCurrentNode() {
|
||||
* PostContentIterator
|
||||
******************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(PostContentIterator,
|
||||
ContentIteratorBase)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(PostContentIterator, ContentIteratorBase)
|
||||
NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(PostContentIterator)
|
||||
NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE_WITH_LAST_RELEASE(PostContentIterator,
|
||||
LastRelease())
|
||||
|
||||
/******************************************************
|
||||
* PreContentIterator
|
||||
******************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(PreContentIterator,
|
||||
ContentIteratorBase)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(PreContentIterator, ContentIteratorBase)
|
||||
NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(PreContentIterator)
|
||||
NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE_WITH_LAST_RELEASE(PreContentIterator,
|
||||
LastRelease())
|
||||
|
||||
/******************************************************
|
||||
* ContentSubtreeIterator
|
||||
******************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(ContentSubtreeIterator,
|
||||
ContentIteratorBase)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(ContentSubtreeIterator, ContentIteratorBase,
|
||||
mRange)
|
||||
|
||||
void ContentSubtreeIterator::LastRelease() {
|
||||
mRange = nullptr;
|
||||
ContentIteratorBase::LastRelease();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(ContentSubtreeIterator)
|
||||
NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE_WITH_LAST_RELEASE(
|
||||
ContentSubtreeIterator, LastRelease())
|
||||
|
||||
/******************************************************
|
||||
* Init routines
|
||||
******************************************************/
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
@ -23,32 +22,37 @@ namespace mozilla {
|
||||
* classes "final", compiler can avoid virtual calls if they are treated
|
||||
* by the users directly.
|
||||
*/
|
||||
class ContentIteratorBase : public nsIContentIterator {
|
||||
class ContentIteratorBase {
|
||||
protected:
|
||||
nsCycleCollectingAutoRefCnt mRefCnt;
|
||||
NS_DECL_OWNINGTHREAD
|
||||
|
||||
public:
|
||||
ContentIteratorBase() = delete;
|
||||
ContentIteratorBase(const ContentIteratorBase&) = delete;
|
||||
ContentIteratorBase& operator=(const ContentIteratorBase&) = delete;
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(ContentIteratorBase)
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ContentIteratorBase)
|
||||
|
||||
virtual nsresult Init(nsINode* aRoot) override;
|
||||
virtual nsresult Init(nsRange* aRange) override;
|
||||
virtual nsresult Init(nsINode* aRoot);
|
||||
virtual nsresult Init(nsRange* aRange);
|
||||
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,
|
||||
const RawRangeBoundary& aEnd) override;
|
||||
const RawRangeBoundary& aEnd);
|
||||
|
||||
virtual void First() override;
|
||||
virtual void Last() override;
|
||||
virtual void Next() override;
|
||||
virtual void Prev() override;
|
||||
virtual void First();
|
||||
virtual void Last();
|
||||
virtual void Next();
|
||||
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:
|
||||
explicit ContentIteratorBase(bool aPre);
|
||||
@ -88,6 +92,11 @@ class ContentIteratorBase : public nsIContentIterator {
|
||||
nsCOMPtr<nsINode> mLast;
|
||||
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 mPre;
|
||||
};
|
||||
@ -101,9 +110,8 @@ class PostContentIterator final : public ContentIteratorBase {
|
||||
PostContentIterator(const PostContentIterator&) = delete;
|
||||
PostContentIterator& operator=(const PostContentIterator&) = delete;
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PostContentIterator,
|
||||
ContentIteratorBase)
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef() override;
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release() override;
|
||||
|
||||
protected:
|
||||
virtual ~PostContentIterator() = default;
|
||||
@ -118,9 +126,8 @@ class PreContentIterator final : public ContentIteratorBase {
|
||||
PreContentIterator(const PreContentIterator&) = delete;
|
||||
PreContentIterator& operator=(const PreContentIterator&) = delete;
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PreContentIterator,
|
||||
ContentIteratorBase)
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef() override;
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release() override;
|
||||
|
||||
protected:
|
||||
virtual ~PreContentIterator() = default;
|
||||
@ -135,9 +142,8 @@ class ContentSubtreeIterator final : public ContentIteratorBase {
|
||||
ContentSubtreeIterator(const ContentSubtreeIterator&) = delete;
|
||||
ContentSubtreeIterator& operator=(const ContentSubtreeIterator&) = delete;
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ContentSubtreeIterator,
|
||||
ContentIteratorBase)
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef() override;
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release() override;
|
||||
|
||||
virtual nsresult Init(nsINode* aRoot) override;
|
||||
virtual nsresult Init(nsRange* aRange) override;
|
||||
@ -172,8 +178,6 @@ class ContentSubtreeIterator final : public ContentIteratorBase {
|
||||
|
||||
virtual void LastRelease() override;
|
||||
|
||||
RefPtr<nsRange> mRange;
|
||||
|
||||
AutoTArray<nsIContent*, 8> mEndNodes;
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "nsIContentInlines.h"
|
||||
#include "mozilla/dom/NodeInfo.h"
|
||||
#include "mozilla/dom/DocumentTimeline.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsFlexContainerFrame.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsILinkHandler.h"
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
@ -74,7 +74,6 @@ EXPORTS += [
|
||||
'nsIAnimationObserver.h',
|
||||
'nsIContent.h',
|
||||
'nsIContentInlines.h',
|
||||
'nsIContentIterator.h',
|
||||
'nsIContentSerializer.h',
|
||||
'nsIDocumentObserver.h',
|
||||
'nsIGlobalObject.h',
|
||||
|
@ -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}
|
||||
#define NS_EVENTLISTENERMANAGER_CID \
|
||||
{ \
|
||||
|
@ -98,7 +98,6 @@
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIStyleSheetService.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsCSSPseudoElements.h" // for CSSPseudoElementType
|
||||
|
@ -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___
|
@ -60,7 +60,6 @@
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
|
@ -10,7 +10,7 @@ webidl Range;
|
||||
|
||||
/**
|
||||
* nsIScriptableContentIterator is designed to testing concrete classes of
|
||||
* nsIContentIterator.
|
||||
* ContentIteratorBase.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(9f25fb2a-265f-44f9-a122-62bbf443239e)]
|
||||
interface nsIScriptableContentIterator : nsISupports
|
||||
@ -30,38 +30,38 @@ interface nsIScriptableContentIterator : nsISupports
|
||||
* exception.
|
||||
*/
|
||||
|
||||
// See nsIContentIterator::Init(nsINode*)
|
||||
// See ContentIteratorBase::Init(nsINode*)
|
||||
void initWithRootNode(in nsIScriptableContentIterator_IteratorType aType,
|
||||
in Node aRoot);
|
||||
|
||||
// See nsIContentIterator::Init(nsRange*)
|
||||
// See ContentIteratorBase::Init(nsRange*)
|
||||
void initWithRange(in nsIScriptableContentIterator_IteratorType aType,
|
||||
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,
|
||||
in Node aStartContainer, in unsigned long aStartOffset,
|
||||
in Node aEndContainer, in unsigned long aEndOffset);
|
||||
|
||||
// See nsIContentIterator::First()
|
||||
// See ContentIteratorBase::First()
|
||||
void first();
|
||||
|
||||
// See nsIContentIterator::Last()
|
||||
// See ContentIteratorBase::Last()
|
||||
void last();
|
||||
|
||||
// See nsIContentIterator::Next()
|
||||
// See ContentIteratorBase::Next()
|
||||
void next();
|
||||
|
||||
// See nsIContentIterator::Prev()
|
||||
// See ContentIteratorBase::Prev()
|
||||
void prev();
|
||||
|
||||
// See nsIContentIterator::GetCurrentNode()
|
||||
// See ContentIteratorBase::GetCurrentNode()
|
||||
readonly attribute Node currentNode;
|
||||
|
||||
// See nsIContentIterator::IsDone()
|
||||
// See ContentIteratorBase::IsDone()
|
||||
readonly attribute bool isDone;
|
||||
|
||||
// See nsIContentIterator::PositionAt(nsINode*)
|
||||
// See ContentIteratorBase::PositionAt(nsINode*)
|
||||
void positionAt(in Node aNode);
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "nsTableCellFrame.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include <algorithm>
|
||||
|
@ -35,9 +35,6 @@ using namespace mozilla::dom;
|
||||
// Yikes! Casting a char to unichar can fill with ones!
|
||||
#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_APOSTROPHE ((char16_t)0x27)
|
||||
#define CH_LEFT_SINGLE_QUOTE ((char16_t)0x2018)
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "mozilla/intl/WordBreaker.h"
|
||||
|
||||
class nsIContent;
|
||||
|
Loading…
Reference in New Issue
Block a user