Bug 181137 - part 4: Make all users of PreContentIterator treat it directly rather than via nsIContentIterator r=smaug
☠☠ backed out by 5562d6967f3d ☠ ☠
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 10 Jan 2019 08:46:25 +0000
changeset 453215 b7ab59bf545e46eb2e677eaf1f68adc100cbebae
parent 453214 b6fc7a332db7a7a3e3fe89f311b3c44e49145ad6
child 453216 83bec02c21d965b6cd5eb0fc682a18ef6ac74b68
push id35349
push userbtara@mozilla.com
push dateThu, 10 Jan 2019 17:19:27 +0000
treeherdermozilla-central@a51746f37520 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs181137
milestone66.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 181137 - part 4: Make all users of PreContentIterator treat it directly rather than via nsIContentIterator r=smaug Now, all users of PreContentIterator can access it directly. This patch makes them use the concrete class directly. Differential Revision: https://phabricator.services.mozilla.com/D15922
dom/base/ContentIterator.cpp
dom/base/ScriptableContentIterator.cpp
dom/base/nsContentList.cpp
dom/base/nsIContentIterator.h
dom/base/nsRange.cpp
dom/events/ContentEventHandler.cpp
editor/spellchecker/nsFilteredContentIterator.cpp
editor/spellchecker/nsFilteredContentIterator.h
--- a/dom/base/ContentIterator.cpp
+++ b/dom/base/ContentIterator.cpp
@@ -14,21 +14,16 @@
 #include "nsIContent.h"
 #include "nsRange.h"
 
 already_AddRefed<nsIContentIterator> NS_NewContentIterator() {
   nsCOMPtr<nsIContentIterator> iter = new mozilla::PostContentIterator();
   return iter.forget();
 }
 
-already_AddRefed<nsIContentIterator> NS_NewPreContentIterator() {
-  nsCOMPtr<nsIContentIterator> iter = new mozilla::PreContentIterator();
-  return iter.forget();
-}
-
 namespace mozilla {
 
 ///////////////////////////////////////////////////////////////////////////
 // NodeIsInTraversalRange: returns true if content is visited during
 // the traversal of the range in the specified mode.
 //
 static bool NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode,
                                    const RawRangeBoundary& aStart,
--- a/dom/base/ScriptableContentIterator.cpp
+++ b/dom/base/ScriptableContentIterator.cpp
@@ -30,17 +30,17 @@ void ScriptableContentIterator::EnsureCo
     return;
   }
   switch (mIteratorType) {
     case POST_ORDER_ITERATOR:
     default:
       mContentIterator = NS_NewContentIterator();
       break;
     case PRE_ORDER_ITERATOR:
-      mContentIterator = NS_NewPreContentIterator();
+      mContentIterator = new PreContentIterator();
       break;
     case SUBTREE_ITERATOR:
       mContentIterator = new ContentSubtreeIterator();
       break;
   }
 }
 
 NS_IMETHODIMP
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -8,16 +8,17 @@
  * nsBaseContentList is a basic list of content nodes; nsContentList
  * is a commonly used NodeList implementation (used for
  * getElementsByTagName, some properties on HTMLDocument/Document, etc).
  */
 
 #include "nsContentList.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Document.h"
+#include "mozilla/ContentIterator.h"
 #include "mozilla/dom/Element.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsContentUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsGkAtoms.h"
 #include "mozilla/dom/HTMLCollectionBinding.h"
 #include "mozilla/dom/NodeListBinding.h"
 #include "mozilla/Likely.h"
@@ -25,17 +26,16 @@
 #include "jsfriendapi.h"
 #include <algorithm>
 #include "mozilla/dom/NodeInfoInlines.h"
 #include "mozilla/MruCache.h"
 
 #include "PLDHashTable.h"
 
 #ifdef DEBUG_CONTENT_LIST
-#include "nsIContentIterator.h"
 #define ASSERT_IN_SYNC AssertInSync()
 #else
 #define ASSERT_IN_SYNC PR_BEGIN_MACRO PR_END_MACRO
 #endif
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
@@ -885,43 +885,43 @@ void nsContentList::AssertInSync() {
   }
 
   // XXX This code will need to change if nsContentLists can ever match
   // elements that are outside of the document element.
   nsIContent* root = mRootNode->IsDocument()
                          ? mRootNode->AsDocument()->GetRootElement()
                          : mRootNode->AsContent();
 
-  nsCOMPtr<nsIContentIterator> iter;
+  RefPtr<PreContentIterator> preOrderIter;
   if (mDeep) {
-    iter = NS_NewPreContentIterator();
-    iter->Init(root);
-    iter->First();
+    preOrderIter = new PreContentIterator();
+    preOrderIter->Init(root);
+    preOrderIter->First();
   }
 
   uint32_t cnt = 0, index = 0;
   while (true) {
     if (cnt == mElements.Length() && mState == LIST_LAZY) {
       break;
     }
 
     nsIContent* cur =
-        mDeep ? iter->GetCurrentNode() : mRootNode->GetChildAt(index++);
+        mDeep ? preOrderIter->GetCurrentNode() : mRootNode->GetChildAt(index++);
     if (!cur) {
       break;
     }
 
     if (cur->IsElement() && Match(cur->AsElement())) {
       NS_ASSERTION(cnt < mElements.Length() && mElements[cnt] == cur,
                    "Elements is out of sync");
       ++cnt;
     }
 
     if (mDeep) {
-      iter->Next();
+      preOrderIter->Next();
     }
   }
 
   NS_ASSERTION(cnt == mElements.Length(), "Too few elements");
 }
 #endif
 
 //-----------------------------------------------------
--- a/dom/base/nsIContentIterator.h
+++ b/dom/base/nsIContentIterator.h
@@ -79,11 +79,10 @@ class nsIContentIterator : public nsISup
   /** PositionAt will position the iterator to the supplied node
    */
   virtual nsresult PositionAt(nsINode* aCurNode) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentIterator, NS_ICONTENTITERATOR_IID)
 
 already_AddRefed<nsIContentIterator> NS_NewContentIterator();
-already_AddRefed<nsIContentIterator> NS_NewPreContentIterator();
 
 #endif  // __nsIContentIterator_h___
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -3054,33 +3054,33 @@ static bool ExcludeIfNextToNonSelectable
 void nsRange::ExcludeNonSelectableNodes(nsTArray<RefPtr<nsRange>>* aOutRanges) {
   MOZ_ASSERT(mIsPositioned);
   MOZ_ASSERT(mEnd.Container());
   MOZ_ASSERT(mStart.Container());
 
   nsRange* range = this;
   RefPtr<nsRange> newRange;
   while (range) {
-    nsCOMPtr<nsIContentIterator> iter = NS_NewPreContentIterator();
-    nsresult rv = iter->Init(range);
+    RefPtr<PreContentIterator> preOrderIter = new PreContentIterator();
+    nsresult rv = preOrderIter->Init(range);
     if (NS_FAILED(rv)) {
       return;
     }
 
     bool added = false;
     bool seenSelectable = false;
     // |firstNonSelectableContent| is the first node in a consecutive sequence
     // of non-IsSelectable nodes.  When we find a selectable node after such
     // a sequence we'll end the last nsRange, create a new one and restart
     // the outer loop.
     nsIContent* firstNonSelectableContent = nullptr;
     while (true) {
       ErrorResult err;
-      nsINode* node = iter->GetCurrentNode();
-      iter->Next();
+      nsINode* node = preOrderIter->GetCurrentNode();
+      preOrderIter->Next();
       bool selectable = true;
       nsIContent* content =
           node && node->IsContent() ? node->AsContent() : nullptr;
       if (content) {
         if (firstNonSelectableContent &&
             ExcludeIfNextToNonSelectable(content)) {
           // Ignorable whitespace next to a sequence of non-selectable nodes
           // counts as non-selectable (bug 1216001).
@@ -3096,17 +3096,17 @@ void nsRange::ExcludeNonSelectableNodes(
           }
         }
       }
 
       if (!selectable) {
         if (!firstNonSelectableContent) {
           firstNonSelectableContent = content;
         }
-        if (iter->IsDone() && seenSelectable) {
+        if (preOrderIter->IsDone() && seenSelectable) {
           // The tail end of the initial range is non-selectable - truncate the
           // current range before the first non-selectable node.
           range->SetEndBefore(*firstNonSelectableContent, err);
         }
       } else if (firstNonSelectableContent) {
         if (range == this && !seenSelectable) {
           // This is the initial range and all its nodes until now are
           // non-selectable so just trim them from the start.
@@ -3152,17 +3152,17 @@ void nsRange::ExcludeNonSelectableNodes(
         }
       } else {
         seenSelectable = true;
         if (!added) {
           added = true;
           aOutRanges->AppendElement(range);
         }
       }
-      if (iter->IsDone()) {
+      if (preOrderIter->IsDone()) {
         return;
       }
     }
   }
 }
 
 struct InnerTextAccumulator {
   explicit InnerTextAccumulator(mozilla::dom::DOMString& aValue)
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -1,30 +1,31 @@
 /* -*- 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/. */
 
 #include "ContentEventHandler.h"
+
+#include "mozilla/ContentIterator.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLUnknownElement.h"
 #include "mozilla/dom/Selection.h"
 #include "nsCaret.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nsCopySupport.h"
 #include "nsElementTable.h"
 #include "nsFocusManager.h"
 #include "nsFontMetrics.h"
 #include "nsFrameSelection.h"
-#include "nsIContentIterator.h"
 #include "nsIPresShell.h"
 #include "nsIFrame.h"
 #include "nsIObjectFrame.h"
 #include "nsLayoutUtils.h"
 #include "nsPresContext.h"
 #include "nsQueryObject.h"
 #include "nsRange.h"
 #include "nsTextFragment.h"
@@ -725,23 +726,24 @@ nsresult ContentEventHandler::GenerateFl
   if (startNode == endNode && startNode->IsText()) {
     nsIContent* content = startNode->AsContent();
     AppendSubString(aString, content, aRawRange.StartOffset(),
                     aRawRange.EndOffset() - aRawRange.StartOffset());
     ConvertToNativeNewlines(aString);
     return NS_OK;
   }
 
-  nsCOMPtr<nsIContentIterator> iter = NS_NewPreContentIterator();
-  nsresult rv = iter->Init(aRawRange.Start().AsRaw(), aRawRange.End().AsRaw());
+  RefPtr<PreContentIterator> preOrderIter = new PreContentIterator();
+  nsresult rv =
+      preOrderIter->Init(aRawRange.Start().AsRaw(), aRawRange.End().AsRaw());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  for (; !iter->IsDone(); iter->Next()) {
-    nsINode* node = iter->GetCurrentNode();
+  for (; !preOrderIter->IsDone(); preOrderIter->Next()) {
+    nsINode* node = preOrderIter->GetCurrentNode();
     if (NS_WARN_IF(!node)) {
       break;
     }
     if (!node->IsContent()) {
       continue;
     }
     nsIContent* content = node->AsContent();
 
@@ -885,23 +887,24 @@ nsresult ContentEventHandler::GenerateFl
   nsINode* startNode = aRawRange.GetStartContainer();
   nsINode* endNode = aRawRange.GetEndContainer();
   if (NS_WARN_IF(!startNode) || NS_WARN_IF(!endNode)) {
     return NS_ERROR_FAILURE;
   }
 
   // baseOffset is the flattened offset of each content node.
   int32_t baseOffset = 0;
-  nsCOMPtr<nsIContentIterator> iter = NS_NewPreContentIterator();
-  nsresult rv = iter->Init(aRawRange.Start().AsRaw(), aRawRange.End().AsRaw());
+  RefPtr<PreContentIterator> preOrderIter = new PreContentIterator();
+  nsresult rv =
+      preOrderIter->Init(aRawRange.Start().AsRaw(), aRawRange.End().AsRaw());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  for (; !iter->IsDone(); iter->Next()) {
-    nsINode* node = iter->GetCurrentNode();
+  for (; !preOrderIter->IsDone(); preOrderIter->Next()) {
+    nsINode* node = preOrderIter->GetCurrentNode();
     if (NS_WARN_IF(!node)) {
       break;
     }
     if (!node->IsContent()) {
       continue;
     }
     nsIContent* content = node->AsContent();
 
@@ -1010,27 +1013,27 @@ nsresult ContentEventHandler::SetRawRang
   // Special case like <br contenteditable>
   if (!mRootContent->HasChildren()) {
     nsresult rv = aRawRange->CollapseTo(RawRangeBoundary(mRootContent, 0));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
-  nsCOMPtr<nsIContentIterator> iter = NS_NewPreContentIterator();
-  nsresult rv = iter->Init(mRootContent);
+  RefPtr<PreContentIterator> preOrderIter = new PreContentIterator();
+  nsresult rv = preOrderIter->Init(mRootContent);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   uint32_t offset = 0;
   uint32_t endOffset = aOffset + aLength;
   bool startSet = false;
-  for (; !iter->IsDone(); iter->Next()) {
-    nsINode* node = iter->GetCurrentNode();
+  for (; !preOrderIter->IsDone(); preOrderIter->Next()) {
+    nsINode* node = preOrderIter->GetCurrentNode();
     if (NS_WARN_IF(!node)) {
       break;
     }
     // FYI: mRootContent shouldn't cause any text. So, we can skip it simply.
     if (node == mRootContent || !node->IsContent()) {
       continue;
     }
     nsIContent* content = node->AsContent();
@@ -1442,23 +1445,24 @@ void ContentEventHandler::EnsureNonEmpty
   aRect.height = std::max(1, aRect.height);
   aRect.width = std::max(1, aRect.width);
 }
 
 ContentEventHandler::FrameAndNodeOffset
 ContentEventHandler::GetFirstFrameInRangeForTextRect(
     const RawRange& aRawRange) {
   NodePosition nodePosition;
-  nsCOMPtr<nsIContentIterator> iter = NS_NewPreContentIterator();
-  nsresult rv = iter->Init(aRawRange.Start().AsRaw(), aRawRange.End().AsRaw());
+  RefPtr<PreContentIterator> preOrderIter = new PreContentIterator();
+  nsresult rv =
+      preOrderIter->Init(aRawRange.Start().AsRaw(), aRawRange.End().AsRaw());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return FrameAndNodeOffset();
   }
-  for (; !iter->IsDone(); iter->Next()) {
-    nsINode* node = iter->GetCurrentNode();
+  for (; !preOrderIter->IsDone(); preOrderIter->Next()) {
+    nsINode* node = preOrderIter->GetCurrentNode();
     if (NS_WARN_IF(!node)) {
       break;
     }
 
     if (!node->IsContent()) {
       continue;
     }
 
@@ -1490,18 +1494,19 @@ ContentEventHandler::GetFirstFrameInRang
   GetFrameForTextRect(nodePosition.Container(), nodePosition.Offset(), true,
                       &firstFrame);
   return FrameAndNodeOffset(firstFrame, nodePosition.Offset());
 }
 
 ContentEventHandler::FrameAndNodeOffset
 ContentEventHandler::GetLastFrameInRangeForTextRect(const RawRange& aRawRange) {
   NodePosition nodePosition;
-  nsCOMPtr<nsIContentIterator> iter = NS_NewPreContentIterator();
-  nsresult rv = iter->Init(aRawRange.Start().AsRaw(), aRawRange.End().AsRaw());
+  RefPtr<PreContentIterator> preOrderIter = new PreContentIterator();
+  nsresult rv =
+      preOrderIter->Init(aRawRange.Start().AsRaw(), aRawRange.End().AsRaw());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return FrameAndNodeOffset();
   }
 
   const RangeBoundary& endPoint = aRawRange.End();
   MOZ_ASSERT(endPoint.IsSet());
   // If the end point is start of a text node or specified by its parent and
   // index, the node shouldn't be included into the range.  For example,
@@ -1528,18 +1533,18 @@ ContentEventHandler::GetLastFrameInRange
     if (endPoint.IsStartOfContainer() &&
         aRawRange.GetStartContainer() != endPoint.Container()) {
       nextNodeOfRangeEnd = endPoint.Container();
     }
   } else if (endPoint.IsSetAndValid()) {
     nextNodeOfRangeEnd = endPoint.GetChildAtOffset();
   }
 
-  for (iter->Last(); !iter->IsDone(); iter->Prev()) {
-    nsINode* node = iter->GetCurrentNode();
+  for (preOrderIter->Last(); !preOrderIter->IsDone(); preOrderIter->Prev()) {
+    nsINode* node = preOrderIter->GetCurrentNode();
     if (NS_WARN_IF(!node)) {
       break;
     }
 
     if (!node->IsContent() || node == nextNodeOfRangeEnd) {
       continue;
     }
 
@@ -2650,17 +2655,17 @@ nsresult ContentEventHandler::OnQueryDOM
 
   if (aStartPosition == aEndPosition) {
     *aLength = 0;
     return NS_OK;
   }
 
   // Don't create ContentIterator instance until it's really necessary since
   // destroying without initializing causes unexpected NS_ASSERTION() call.
-  nsCOMPtr<nsIContentIterator> iter;
+  RefPtr<PreContentIterator> preOrderIter;
 
   // Working with ContentIterator, we may need to adjust the end position for
   // including it forcibly.
   NodePosition endPosition(aEndPosition);
 
   // This may be called for retrieving the text of removed nodes.  Even in this
   // case, the node thinks it's still in the tree because UnbindFromTree() will
   // be called after here.  However, the node was already removed from the
@@ -2674,18 +2679,18 @@ nsresult ContentEventHandler::OnQueryDOM
     MOZ_ASSERT(aStartPosition.Container() == endPosition.Container(),
                "At removing the node, start and end node should be same");
     MOZ_ASSERT(aStartPosition.Offset() == 0,
                "When the node is being removed, the start offset should be 0");
     MOZ_ASSERT(
         static_cast<uint32_t>(endPosition.Offset()) ==
             endPosition.Container()->GetChildCount(),
         "When the node is being removed, the end offset should be child count");
-    iter = NS_NewPreContentIterator();
-    nsresult rv = iter->Init(aStartPosition.Container());
+    preOrderIter = new PreContentIterator();
+    nsresult rv = preOrderIter->Init(aStartPosition.Container());
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   } else {
     RawRange prevRawRange;
     nsresult rv = prevRawRange.SetStart(aStartPosition.AsRaw());
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
@@ -2719,45 +2724,47 @@ nsresult ContentEventHandler::OnQueryDOM
     }
 
     if (endPosition.IsSetAndValid()) {
       // Offset is within node's length; set end of range to that offset
       rv = prevRawRange.SetEnd(endPosition.AsRaw());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
-      iter = NS_NewPreContentIterator();
-      rv = iter->Init(prevRawRange.Start().AsRaw(), prevRawRange.End().AsRaw());
+      preOrderIter = new PreContentIterator();
+      rv = preOrderIter->Init(prevRawRange.Start().AsRaw(),
+                              prevRawRange.End().AsRaw());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else if (endPosition.Container() != aRootContent) {
       // Offset is past node's length; set end of range to end of node
       rv = prevRawRange.SetEndAfter(endPosition.Container());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
-      iter = NS_NewPreContentIterator();
-      rv = iter->Init(prevRawRange.Start().AsRaw(), prevRawRange.End().AsRaw());
+      preOrderIter = new PreContentIterator();
+      rv = preOrderIter->Init(prevRawRange.Start().AsRaw(),
+                              prevRawRange.End().AsRaw());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else {
       // Offset is past the root node; set end of range to end of root node
-      iter = NS_NewPreContentIterator();
-      rv = iter->Init(aRootContent);
+      preOrderIter = new PreContentIterator();
+      rv = preOrderIter->Init(aRootContent);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
   }
 
   *aLength = 0;
-  for (; !iter->IsDone(); iter->Next()) {
-    nsINode* node = iter->GetCurrentNode();
+  for (; !preOrderIter->IsDone(); preOrderIter->Next()) {
+    nsINode* node = preOrderIter->GetCurrentNode();
     if (NS_WARN_IF(!node)) {
       break;
     }
     if (!node->IsContent()) {
       continue;
     }
     nsIContent* content = node->AsContent();
 
--- a/editor/spellchecker/nsFilteredContentIterator.cpp
+++ b/editor/spellchecker/nsFilteredContentIterator.cpp
@@ -1,36 +1,38 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+#include "nsFilteredContentIterator.h"
+
+#include "mozilla/ContentIterator.h"
+#include "mozilla/Move.h"
 #include "mozilla/mozalloc.h"
-#include "mozilla/Move.h"
+
 #include "nsComponentManagerUtils.h"
 #include "nsComposeTxtSrvFilter.h"
 #include "nsContentUtils.h"
 #include "nsDebug.h"
 #include "nsError.h"
-#include "nsFilteredContentIterator.h"
 #include "nsAtom.h"
 #include "nsIContent.h"
-#include "nsIContentIterator.h"
 #include "nsINode.h"
 #include "nsISupportsBase.h"
 #include "nsISupportsUtils.h"
 #include "nsRange.h"
 
 using namespace mozilla;
 
 //------------------------------------------------------------
 nsFilteredContentIterator::nsFilteredContentIterator(
     UniquePtr<nsComposeTxtSrvFilter> aFilter)
     : mIterator(NS_NewContentIterator()),
-      mPreIterator(NS_NewPreContentIterator()),
+      mPreIterator(new PreContentIterator()),
       mFilter(std::move(aFilter)),
       mDidSkip(false),
       mIsOutOfRange(false),
       mDirection(eDirNotSet) {}
 
 //------------------------------------------------------------
 nsFilteredContentIterator::~nsFilteredContentIterator() {}
 
--- a/editor/spellchecker/nsFilteredContentIterator.h
+++ b/editor/spellchecker/nsFilteredContentIterator.h
@@ -3,19 +3,19 @@
  * 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 nsFilteredContentIterator_h__
 #define nsFilteredContentIterator_h__
 
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsIContentIterator.h"
 #include "nsISupportsImpl.h"
 #include "nscore.h"
+#include "mozilla/ContentIterator.h"
 #include "mozilla/UniquePtr.h"
 
 class nsAtom;
 class nsComposeTxtSrvFilter;
 class nsINode;
 class nsRange;
 
 class nsFilteredContentIterator final : public nsIContentIterator {
@@ -60,17 +60,17 @@ class nsFilteredContentIterator final : 
   // enum to give us the direction
   typedef enum { eDirNotSet, eForward, eBackward } eDirectionType;
   nsresult AdvanceNode(nsINode* aNode, nsINode*& aNewNode, eDirectionType aDir);
   void CheckAdvNode(nsINode* aNode, bool& aDidSkip, eDirectionType aDir);
   nsresult SwitchDirections(bool aChangeToForward);
 
   nsCOMPtr<nsIContentIterator> mCurrentIterator;
   nsCOMPtr<nsIContentIterator> mIterator;
-  nsCOMPtr<nsIContentIterator> mPreIterator;
+  RefPtr<mozilla::PreContentIterator> mPreIterator;
 
   RefPtr<nsAtom> mBlockQuoteAtom;
   RefPtr<nsAtom> mScriptAtom;
   RefPtr<nsAtom> mTextAreaAtom;
   RefPtr<nsAtom> mSelectAreaAtom;
   RefPtr<nsAtom> mMapAtom;
 
   mozilla::UniquePtr<nsComposeTxtSrvFilter> mFilter;