From 55d0c600fad06ae3b9eec5fcf1e34f1914a4bc50 Mon Sep 17 00:00:00 2001 From: "cvshook%sicking.cc" Date: Wed, 25 Oct 2006 20:24:00 +0000 Subject: [PATCH] Kill nsGeneratedContentIterator and related classes and code since it's not used. r/sr=dbaron b=357957 --- content/base/public/nsContentCID.h | 8 - content/base/public/nsIContentIterator.h | 23 - content/base/src/Makefile.in | 1 - content/base/src/nsGeneratedIterator.cpp | 1242 ---------------------- layout/base/Makefile.in | 1 - layout/base/nsFrameContentIterator.cpp | 287 ----- layout/base/nsIPresShell.h | 18 +- layout/base/nsPresShell.cpp | 50 - layout/build/nsLayoutCID.h | 8 - layout/build/nsLayoutModule.cpp | 12 - layout/generic/nsHTMLParts.h | 7 - layout/generic/nsSelection.cpp | 45 +- 12 files changed, 4 insertions(+), 1698 deletions(-) delete mode 100644 content/base/src/nsGeneratedIterator.cpp delete mode 100644 layout/base/nsFrameContentIterator.cpp diff --git a/content/base/public/nsContentCID.h b/content/base/public/nsContentCID.h index 4e1729dc4a2d..7d95898e8a0e 100644 --- a/content/base/public/nsContentCID.h +++ b/content/base/public/nsContentCID.h @@ -163,14 +163,6 @@ {/* {80D7E247-D4B8-45d7-BB59-6F1DD56F384C} */ \ 0x80d7e247, 0xd4b8, 0x45d7, { 0xbb, 0x59, 0x6f, 0x1d, 0xd5, 0x6f, 0x38, 0x4c } } -#define NS_GENERATEDSUBTREEITERATOR_CID \ -{/* {9A45253B-EB8F-49f1-B925-E9EA90D3EB3A}*/ \ - 0x9a45253b, 0xeb8f, 0x49f1, { 0xb9, 0x25, 0xe9, 0xea, 0x90, 0xd3, 0xeb, 0x3a } } - -#define NS_GENERATEDCONTENTITERATOR_CID \ -{/* {A364930F-E353-49f1-AC69-91637EB8B757}*/ \ - 0xa364930f, 0xe353, 0x49f1, { 0xac, 0x69, 0x91, 0x63, 0x7e, 0xb8, 0xb7, 0x57 } } - #define NS_SUBTREEITERATOR_CID \ {/* {a6cf90e5-15b3-11d2-932e-00805f8add32}*/ \ 0xa6cf90e5, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } diff --git a/content/base/public/nsIContentIterator.h b/content/base/public/nsIContentIterator.h index a64dba25e47d..24cf794e63fe 100644 --- a/content/base/public/nsIContentIterator.h +++ b/content/base/public/nsIContentIterator.h @@ -47,12 +47,6 @@ class nsIDOMRange; {0xa6cf90e4, 0x15b3, 0x11d2, \ {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } -// {B4BC9F63-D9BA-11d3-9938-00108301233C} -#define NS_IGENERATEDCONTENTITERTOR_IID \ -{ 0xb4bc9f63, 0xd9ba, 0x11d3, \ -{ 0x99, 0x38, 0x0, 0x10, 0x83, 0x1, 0x23, 0x3c } } - - class nsIContentIterator : public nsISupports { public: @@ -100,22 +94,5 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentIterator, NS_ICONTENTITERTOR_IID) -class nsIPresShell; - -class nsIGeneratedContentIterator : public nsISupports { -public: - - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGENERATEDCONTENTITERTOR_IID) - - /* Initializes an iterator for the subtree rooted by the node aRoot - */ - virtual nsresult Init(nsIPresShell *aShell, nsIDOMRange* aRange) = 0; - - virtual nsresult Init(nsIPresShell *aShell, nsIContent* aContent) = 0; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsIGeneratedContentIterator, - NS_IGENERATEDCONTENTITERTOR_IID) - #endif // __nsIContentIterator_h___ diff --git a/content/base/src/Makefile.in b/content/base/src/Makefile.in index d998382939a5..9cce637372e6 100644 --- a/content/base/src/Makefile.in +++ b/content/base/src/Makefile.in @@ -115,7 +115,6 @@ CPPSRCS = \ nsDocumentFragment.cpp \ nsFrameLoader.cpp \ nsGenConImageContent.cpp \ - nsGeneratedIterator.cpp \ nsGenericDOMDataNode.cpp \ nsGenericDOMNodeList.cpp \ nsGenericElement.cpp \ diff --git a/content/base/src/nsGeneratedIterator.cpp b/content/base/src/nsGeneratedIterator.cpp deleted file mode 100644 index 467f4b980acb..000000000000 --- a/content/base/src/nsGeneratedIterator.cpp +++ /dev/null @@ -1,1242 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsISupports.h" -#include "nsIDOMNodeList.h" -#include "nsIContentIterator.h" -#include "nsRange.h" -#include "nsIContent.h" -#include "nsIDOMText.h" -#include "nsISupportsArray.h" -#include "nsCOMPtr.h" -#include "nsPresContext.h" -#include "nsIComponentManager.h" -#include "nsContentCID.h" -#include "nsIPresShell.h" - -#define DO_AFTER 1 -#define DO_BEFORE 1 - -/////////////////////////////////////////////////////////////////////////// -// GetNumChildren: returns the number of things inside aNode. -// -static PRUint32 -GetNumChildren(nsIDOMNode *aNode) -{ - PRUint32 numChildren = 0; - if (!aNode) - return 0; - - PRBool hasChildNodes; - aNode->HasChildNodes(&hasChildNodes); - if (hasChildNodes) - { - nsCOMPtrnodeList; - nsresult res = aNode->GetChildNodes(getter_AddRefs(nodeList)); - if (NS_SUCCEEDED(res) && nodeList) - nodeList->GetLength(&numChildren); - } - return numChildren; -} - -/////////////////////////////////////////////////////////////////////////// -// GetChildAt: returns the node at this position index in the parent -// -static nsCOMPtr -GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset) -{ - nsCOMPtr resultNode; - - if (!aParent) - return resultNode; - - PRBool hasChildNodes; - aParent->HasChildNodes(&hasChildNodes); - if (PR_TRUE==hasChildNodes) - { - nsCOMPtrnodeList; - nsresult res = aParent->GetChildNodes(getter_AddRefs(nodeList)); - if (NS_SUCCEEDED(res) && nodeList) - nodeList->Item(aOffset, getter_AddRefs(resultNode)); - } - - return resultNode; -} - - -/* - * A simple iterator class for traversing the generated content in "close tag" order - */ -class nsGeneratedContentIterator : public nsIContentIterator, - public nsIGeneratedContentIterator -{ -public: - NS_DECL_ISUPPORTS - - nsGeneratedContentIterator(); - virtual ~nsGeneratedContentIterator(); - - // nsIContentIterator interface methods ------------------------------ - - virtual nsresult Init(nsIContent* aRoot); - - virtual nsresult Init(nsIDOMRange* aRange); - - virtual void First(); - - virtual void Last(); - - virtual void Next(); - - virtual void Prev(); - - virtual nsIContent *GetCurrentNode(); - - virtual PRBool IsDone(); - - virtual nsresult PositionAt(nsIContent* aCurNode); - - // nsIEnumertor interface methods ------------------------------ - - //NS_IMETHOD CurrentItem(nsISupports **aItem); - - //nsIGeneratedContentIterator - virtual nsresult Init(nsIPresShell *aShell, nsIDOMRange* aRange); - virtual nsresult Init(nsIPresShell *aShell, nsIContent* aContent); - -protected: - - // Do these cause too much refcounting??? - nsCOMPtr GetDeepFirstChild(nsCOMPtr aRoot); - nsCOMPtr GetDeepLastChild(nsCOMPtr aRoot); - - nsIContent *GetNextSibling(nsIContent *aNode); - nsIContent *GetPrevSibling(nsIContent *aNode); - - nsIContent *NextNode(nsIContent *aNode); - nsIContent *PrevNode(nsIContent *aNode); - - void MakeEmpty(); - - nsCOMPtr mCurNode; - nsCOMPtr mFirst; - nsCOMPtr mLast; - nsCOMPtr mCommonParent; - - nsCOMPtr mFirstIter; - nsCOMPtr mLastIter; - nsCOMPtr mGenIter; - nsIPresShell::GeneratedContentType mIterType; - nsIPresShell::GeneratedContentType mFirstIterType; - nsIPresShell::GeneratedContentType mLastIterType; - nsCOMPtr mPresShell; - PRBool mIsDone; - -private: - - // no copy's or assigns FIX ME - nsGeneratedContentIterator(const nsGeneratedContentIterator&); - nsGeneratedContentIterator& operator=(const nsGeneratedContentIterator&); - -}; - - -/****************************************************** - * repository cruft - ******************************************************/ - -nsresult -NS_NewGenRegularIterator(nsIContentIterator ** aInstancePtrResult) -{ - nsGeneratedContentIterator * iter = new nsGeneratedContentIterator(); - if (!iter) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(*aInstancePtrResult = iter); - - return NS_OK; -} - - -/****************************************************** - * XPCOM cruft - ******************************************************/ - -NS_IMPL_ISUPPORTS2(nsGeneratedContentIterator, nsIGeneratedContentIterator, - nsIContentIterator) - - -/****************************************************** - * constructor/destructor - ******************************************************/ - -nsGeneratedContentIterator::nsGeneratedContentIterator() - : mIsDone(PR_FALSE) -{ -} - - -nsGeneratedContentIterator::~nsGeneratedContentIterator() -{ -} - - -/****************************************************** - * Init routines - ******************************************************/ - - -nsresult -nsGeneratedContentIterator::Init(nsIContent* aRoot) -{ - if (!aRoot) - return NS_ERROR_NULL_POINTER; - mIsDone = PR_FALSE; - nsCOMPtr root(aRoot); - mFirst = GetDeepFirstChild(root); - if (mGenIter)//we have generated - { - mFirstIter = mGenIter; - mFirstIterType = mIterType; - } - mLast = root; - mCommonParent = root; - mCurNode = mFirst; - return NS_OK; -} - -nsresult -nsGeneratedContentIterator::Init(nsIPresShell *aShell, nsIDOMRange* aRange) -{ - mPresShell = aShell; - return Init(aRange); -} - -nsresult -nsGeneratedContentIterator::Init(nsIPresShell *aShell, nsIContent* aContent) -{ - mPresShell = aShell; - return Init(aContent); -} - - -nsresult -nsGeneratedContentIterator::Init(nsIDOMRange* aRange) -{ - if (!aRange) - return NS_ERROR_NULL_POINTER; - - nsCOMPtr dN; - - nsCOMPtr startCon; - nsCOMPtr startDOM; - nsCOMPtr endCon; - nsCOMPtr endDOM; - PRInt32 startIndx; - PRInt32 endIndx; - - mIsDone = PR_FALSE; - - // get common content parent - if (NS_FAILED(aRange->GetCommonAncestorContainer(getter_AddRefs(dN))) || !dN) - return NS_ERROR_FAILURE; - mCommonParent = do_QueryInterface(dN); - - // get the start node and offset, convert to nsIContent - aRange->GetStartContainer(getter_AddRefs(startDOM)); - if (!startDOM) - return NS_ERROR_ILLEGAL_VALUE; - startCon = do_QueryInterface(startDOM); - if (!startCon) - return NS_ERROR_FAILURE; - - aRange->GetStartOffset(&startIndx); - - // get the end node and offset, convert to nsIContent - aRange->GetEndContainer(getter_AddRefs(endDOM)); - if (!endDOM) - return NS_ERROR_ILLEGAL_VALUE; - endCon = do_QueryInterface(endDOM); - if (!endCon) - return NS_ERROR_FAILURE; - - aRange->GetEndOffset(&endIndx); - - // find first node in range - nsIContent *cChild = startCon->GetChildAt(0); - - // short circuit when start node == end node - if (startDOM == endDOM) - { - if (!cChild) // no children, must be a text node or empty container - { - mFirst = startCon; - mLast = startCon; - mCurNode = startCon; - return NS_OK; - } - else - { - if (startIndx == endIndx) // collapsed range - { - MakeEmpty(); - return NS_OK; - } - } - } - - if (!cChild) // no children, must be a text node - { - mFirst = startCon; - } - else - { - cChild = startCon->GetChildAt(startIndx); - if (!cChild) // offset after last child, parent is first node - { - mFirst = startCon; - } - else - { - mFirst = GetDeepFirstChild(cChild); - if (mGenIter) - { - mFirstIter = mGenIter; - mFirstIterType = mIterType; - } - } - // Does that first node really intersect the range? - // the range could be collapsed, or the range could be - // 'degenerate', ie not collapsed but still containing - // no content. In this case, we want the iterator to - // be empty - - if (!nsRange::IsNodeIntersectsRange(mFirst, aRange)) - { - MakeEmpty(); - return NS_OK; - } - } - - // find last node in range - cChild = endCon->GetChildAt(0); - - if (!cChild) // no children, must be a text node - { - mLast = endCon; - } - else if (endIndx == 0) // before first child, parent is last node - { - mLast = endCon; - } - else - { - cChild = endCon->GetChildAt(--endIndx); - if (!cChild) // offset after last child, last child is last node - { - endIndx = (PRInt32)endCon->GetChildCount(); - cChild = endCon->GetChildAt(--endIndx); - if (!cChild) - { - NS_NOTREACHED("nsGeneratedContentIterator::nsGeneratedContentIterator"); - return NS_ERROR_FAILURE; - } - } - mLast = cChild; - } - - mCurNode = mFirst; - return NS_OK; -} - - -/****************************************************** - * Helper routines - ******************************************************/ - -void nsGeneratedContentIterator::MakeEmpty() -{ - nsCOMPtr noNode; - mCurNode = noNode; - mFirst = noNode; - mLast = noNode; - mCommonParent = noNode; - mIsDone = PR_TRUE; - mGenIter = 0; - mFirstIter = 0; - mIterType = nsIPresShell::Before; -} - -nsCOMPtr nsGeneratedContentIterator::GetDeepFirstChild(nsCOMPtr aRoot) -{ - nsCOMPtr deepFirstChild; - - if (aRoot) - { - nsCOMPtr cN = aRoot; - -#if DO_BEFORE - //CHECK FOR BEFORESTUFF - nsresult result = NS_ERROR_FAILURE; - if (mPresShell) - result = mPresShell->GetGeneratedContentIterator(cN,nsIPresShell::Before,getter_AddRefs(mGenIter)); - if (NS_SUCCEEDED(result) && mGenIter) - { //ok we have a generated iter all bets are off - mIterType = nsIPresShell::Before; - mGenIter->First(); - return cN; - } -#endif - - nsIContent *cChild; - while ((cChild = cN->GetChildAt(0))) - { - cN = cChild; - -#if DO_BEFORE - //CHECK FOR BEFORESTUFF - if (mPresShell) - result = mPresShell->GetGeneratedContentIterator(cN,nsIPresShell::Before,getter_AddRefs(mGenIter)); - if (NS_SUCCEEDED(result) && mGenIter) - { //ok we have a generated iter all bets are off - mIterType = nsIPresShell::Before; - mGenIter->First(); - return cN; - } -#endif - } - - deepFirstChild = cN; - } - - return deepFirstChild; -} - -nsCOMPtr nsGeneratedContentIterator::GetDeepLastChild(nsCOMPtr aRoot) -{ - nsCOMPtr deepFirstChild; - - if (aRoot) - { - nsCOMPtr cN = aRoot; - nsCOMPtr cChild; - -#if DO_AFTER - //CHECK FOR AFTER STUFF - nsresult result = NS_ERROR_FAILURE; - if (mPresShell) - result = mPresShell->GetGeneratedContentIterator(cN,nsIPresShell::After,getter_AddRefs(mGenIter)); - if (NS_SUCCEEDED(result) && mGenIter) - { //ok we have a generated iter all bets are off - mIterType = nsIPresShell::After; - mGenIter->First(); - return cN; - } -#endif - - PRUint32 numChildren = cN->GetChildCount(); - - while ( numChildren ) - { - cChild = cN->GetChildAt(--numChildren); - if (cChild) - { -#if DO_AFTER - //CHECK FOR AFTER STUFF - if (mPresShell) - result = mPresShell->GetGeneratedContentIterator(cChild,nsIPresShell::After,getter_AddRefs(mGenIter)); - if (NS_SUCCEEDED(result) && mGenIter) - { //ok we have a generated iter all bets are off - mGenIter->Last(); - mIterType = nsIPresShell::After; - return cChild; - } -#endif - numChildren = cChild->GetChildCount(); - cN = cChild; - } - else - { - break; - } - } - deepFirstChild = cN; - } - - return deepFirstChild; -} - -// Get the next sibling, or parents next sibling, or grandpa's next sibling... -nsIContent * -nsGeneratedContentIterator::GetNextSibling(nsIContent *aNode) -{ - if (!aNode) - return nsnull; - - nsIContent *parent = aNode->GetParent(); - if (!parent) - return nsnull; - - PRInt32 indx = parent->IndexOf(aNode); - - nsIContent *sib = parent->GetChildAt(++indx); - - if (!sib) - { -#if DO_AFTER - //CHECK FOR AFTERESTUFF - if (mPresShell) - mPresShell->GetGeneratedContentIterator(parent, nsIPresShell::After, - getter_AddRefs(mGenIter)); - if (mGenIter) - { //ok we have a generated iter all bets are off - mGenIter->First(); - mIterType = nsIPresShell::After; - - return parent; - } -#endif - if (parent != mCommonParent) - { - return GetNextSibling(parent); - } - else - { - sib = nsnull; - } - } - - return sib; -} - -// Get the prev sibling, or parents prev sibling, or grandpa's prev sibling... -nsIContent * -nsGeneratedContentIterator::GetPrevSibling(nsIContent *aNode) -{ - if (!aNode) - return nsnull; - - nsIContent *parent = aNode->GetParent(); - if (!parent) - return nsnull; - - PRInt32 indx = parent->IndexOf(aNode); - nsIContent *sib = nsnull; - - if (indx < 1 || !(sib = parent->GetChildAt(--indx))) - { -#if DO_BEFORE - //CHECK FOR BEFORESTUFF - if (mPresShell) - mPresShell->GetGeneratedContentIterator(parent, nsIPresShell::Before, - getter_AddRefs(mGenIter)); - if (mGenIter) - { //ok we have a generated iter all bets are off - mGenIter->Last(); - mIterType = nsIPresShell::Before; - return parent; - } - else -#endif - if (parent != mCommonParent) - { - return GetPrevSibling(parent); - } - else - { - sib = nsnull; - } - } - - return sib; -} - -nsIContent * -nsGeneratedContentIterator::NextNode(nsIContent *aNode) -{ - if (!aNode) - return nsnull; - - if (mGenIter) - { - if (mGenIter->IsDone()) - mGenIter = 0; - else { - mGenIter->Next(); - - return nsnull; - } - - if (nsIPresShell::After == mIterType)//answer is parent - { - //*ioNextNode = parent; leave it the same - return nsnull; - } - nsIContent *cN = aNode->GetChildAt(0); - if (cN) - { - return GetDeepFirstChild(cN); - } - } - - nsIContent *cN = aNode; - - // get next sibling if there is one - nsIContent *parent = cN->GetParent(); - if (!parent) - { - // a little noise to catch some iterator usage bugs. - NS_NOTREACHED("nsGeneratedContentIterator::NextNode() : no parent found"); - return nsnull; - } - - PRInt32 indx = parent->IndexOf(cN); - - nsIContent *cSibling = parent->GetChildAt(++indx); - if (cSibling) - { - // next node is siblings "deep left" child - return GetDeepFirstChild(cSibling); - } - - //CHECK FOR AFTERSTUFF - if (mGenIter)//we allready had an afteriter. it must be done! - { - mGenIter = 0; - } - else//check for after node. - { - if (mPresShell) - mPresShell->GetGeneratedContentIterator(parent, nsIPresShell::After, - getter_AddRefs(mGenIter)); - if (mGenIter) - { //ok we have a generated iter all bets are off - mGenIter->First(); - mIterType = nsIPresShell::After; - } - else - mGenIter = 0; - } - - // else it's the parent - return parent; -} - - -//THIS NEEDS TO USE A GENERATED SUBTREEITER HERE -nsIContent * -nsGeneratedContentIterator::PrevNode(nsIContent *aNode) -{ - PRUint32 numChildren = aNode->GetChildCount(); - - // if it has children then prev node is last child - if (numChildren > 0) - { - return aNode->GetChildAt(--numChildren); - } - - // else prev sibling is previous - return GetPrevSibling(aNode); -} - -/****************************************************** - * ContentIterator routines - ******************************************************/ - -void -nsGeneratedContentIterator::First() -{ - if (!mFirst) { - mIsDone = PR_TRUE; - - return; - } - - mIsDone = PR_FALSE; - - mCurNode = mFirst; - mGenIter = mFirstIter; - if (mGenIter)//set directionback to before... - mGenIter->First(); -} - - -void -nsGeneratedContentIterator::Last() -{ - if (!mLast) { - mIsDone = PR_TRUE; - - return; - } - - mIsDone = PR_FALSE; - - mGenIter = mLastIter; - mCurNode = mLast; -} - - -void -nsGeneratedContentIterator::Next() -{ - if (mIsDone || !mCurNode) - return; - - if (GetCurrentNode() == mLast) - { - mIsDone = PR_TRUE; - return; - } - - mCurNode = NextNode(mCurNode); -} - - -void -nsGeneratedContentIterator::Prev() -{ - if (mIsDone) - return; - if (!mCurNode) - return; - if (mCurNode == mFirst) - { - mIsDone = PR_TRUE; - return; - } - - mCurNode = PrevNode(mCurNode); -} - - -PRBool -nsGeneratedContentIterator::IsDone() -{ - return mIsDone; -} - - -nsresult -nsGeneratedContentIterator::PositionAt(nsIContent* aCurNode) -{ - // XXX need to confirm that aCurNode is within range - if (!aCurNode) - return NS_ERROR_NULL_POINTER; - mCurNode = aCurNode; - mIsDone = PR_FALSE; - return NS_OK; -} - - -nsIContent * -nsGeneratedContentIterator::GetCurrentNode() -{ - if (!mCurNode || mIsDone) { - return nsnull; - } - - if (mGenIter) { - return mGenIter->GetCurrentNode(); - } - - NS_ASSERTION(mCurNode, "Null current node in an iterator that's not done!"); - - return mCurNode; -} - - - - - -/*====================================================================================*/ -//SUBTREE ITERATOR -/*====================================================================================*/ -/****************************************************** - * nsGeneratedSubtreeIterator - ******************************************************/ - - -/* - * A simple iterator class for traversing the content in "top subtree" order - */ -class nsGeneratedSubtreeIterator : public nsGeneratedContentIterator -{ -public: - nsGeneratedSubtreeIterator() {}; - virtual ~nsGeneratedSubtreeIterator() {}; - - // nsContentIterator overrides ------------------------------ - - virtual nsresult Init(nsIContent* aRoot); - - virtual nsresult Init(nsIDOMRange* aRange); - - virtual void Next(); - - virtual void Prev(); - - virtual nsresult PositionAt(nsIContent* aCurNode); - - //nsIGeneratedContentIterator - virtual nsresult Init(nsIPresShell *aShell, nsIDOMRange* aRange); - virtual nsresult Init(nsIPresShell *aShell, nsIContent* aContent); -protected: - - nsresult GetTopAncestorInRange( nsCOMPtr aNode, - nsCOMPtr *outAnestor); - - // no copy's or assigns FIX ME - nsGeneratedSubtreeIterator(const nsGeneratedSubtreeIterator&); - nsGeneratedSubtreeIterator& operator=(const nsGeneratedSubtreeIterator&); - nsCOMPtr mRange; -}; - -nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult); - - - - -/****************************************************** - * repository cruft - ******************************************************/ - -nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult) -{ - nsGeneratedSubtreeIterator * iter = new nsGeneratedSubtreeIterator(); - if (!iter) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(*aInstancePtrResult = iter); - - return NS_OK; -} - - - -/****************************************************** - * Init routines - ******************************************************/ - - -nsresult -nsGeneratedSubtreeIterator::Init(nsIContent* aRoot) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -nsGeneratedSubtreeIterator::Init(nsIPresShell *aShell, nsIDOMRange* aRange) -{ - mPresShell = aShell; - return Init(aRange); -} - -nsresult -nsGeneratedSubtreeIterator::Init(nsIPresShell *aShell, nsIContent* aContent) -{ - mPresShell = aShell; - return Init(aContent); -} - -nsresult -nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange) -{ - if (!aRange) - return NS_ERROR_NULL_POINTER; - - mIsDone = PR_FALSE; - - mRange = aRange; - - // get the start node and offset, convert to nsIContent - nsCOMPtr commonParent; - nsCOMPtr startParent; - nsCOMPtr endParent; - nsCOMPtr cStartP; - nsCOMPtr cEndP; - nsCOMPtr cN; - nsCOMPtr firstCandidate; - nsCOMPtr lastCandidate; - nsCOMPtr dChild; - nsCOMPtr cChild; - PRInt32 indx, startIndx, endIndx; - PRInt32 numChildren; - - // get common content parent - if (NS_FAILED(aRange->GetCommonAncestorContainer(getter_AddRefs(commonParent))) || !commonParent) - return NS_ERROR_FAILURE; - mCommonParent = do_QueryInterface(commonParent); - - // get start content parent - if (NS_FAILED(aRange->GetStartContainer(getter_AddRefs(startParent))) || !startParent) - return NS_ERROR_FAILURE; - cStartP = do_QueryInterface(startParent); - aRange->GetStartOffset(&startIndx); - - // get end content parent - if (NS_FAILED(aRange->GetEndContainer(getter_AddRefs(endParent))) || !endParent) - return NS_ERROR_FAILURE; - cEndP = do_QueryInterface(endParent); - aRange->GetEndOffset(&endIndx); - - // short circuit when start node == end node - if (startParent == endParent) - { - cChild = cStartP->GetChildAt(0); - - if (!cChild) // no children, must be a text node or empty container - { - // all inside one text node - empty subtree iterator - MakeEmpty(); - return NS_OK; - } - else - { - if (startIndx == endIndx) // collapsed range - { - MakeEmpty(); - return NS_OK; - } - } - } - - // find first node in range - aRange->GetStartOffset(&indx); - numChildren = GetNumChildren(startParent); - - if (!numChildren) // no children, must be a text node - { - cN = cStartP; - } - else - { - dChild = GetChildAt(startParent, indx); - cChild = do_QueryInterface(dChild); - if (!cChild) // offset after last child - { - cN = cStartP; - } - else - { - firstCandidate = cChild; - } - } - - if (!firstCandidate) - { - // then firstCandidate is next node after cN - firstCandidate = GetNextSibling(cN); - - if (!firstCandidate) - { - MakeEmpty(); - return NS_OK; - } - } - if (mGenIter) - { - mFirstIter = mGenIter; - mFirstIterType = mIterType; - } - if (!mFirstIter) - { - firstCandidate = GetDeepFirstChild(firstCandidate); - if (mGenIter) - { - mFirstIter = mGenIter; - mFirstIterType = mIterType; - } - } - // confirm that this first possible contained node - // is indeed contained. Else we have a range that - // does not fully contain any node. - - PRBool nodeBefore(PR_FALSE), nodeAfter(PR_FALSE); - if (!mFirstIter && - NS_FAILED(nsRange::CompareNodeToRange(firstCandidate, aRange, - &nodeBefore, &nodeAfter))) - return NS_ERROR_FAILURE; - - if (nodeBefore || nodeAfter) - { - MakeEmpty(); - return NS_OK; - } - - // cool, we have the first node in the range. Now we walk - // up it's ancestors to find the most senior that is still - // in the range. That's the real first node. - if (NS_SUCCEEDED(GetTopAncestorInRange(firstCandidate, address_of(mFirst)))) - { - mFirstIter = 0;//ancestor has one no - mGenIter = 0; - } - else if (!mFirstIter) //something bad happened and its not generated content iterators fault - return NS_ERROR_FAILURE; - else - mFirst = firstCandidate;//setting last candidate to parent of generated content this is ok - - - - // now to find the last node - aRange->GetEndOffset(&indx); - numChildren = GetNumChildren(endParent); - - if (indx > numChildren) indx = numChildren; - if (!indx) - { - cN = cEndP; - } - else - { - if (!numChildren) // no children, must be a text node - { - cN = cEndP; - } - else - { - dChild = GetChildAt(endParent, --indx); - cChild = do_QueryInterface(dChild); - if (!cChild) // shouldn't happen - { - NS_ASSERTION(0,"tree traversal trouble in nsGeneratedSubtreeIterator::Init"); - return NS_ERROR_FAILURE; - } - else - { - lastCandidate = cChild; - } - } - } - - if (!lastCandidate) - { - // then lastCandidate is prev node before cN - lastCandidate = GetPrevSibling(cN); - - if (!lastCandidate) - { - MakeEmpty(); - return NS_OK; - } - } - if (mGenIter) - { - mLastIter = mGenIter; - mLastIterType = mIterType; - } - if (!mLastIter)//don't ever set last candidate to a generated node! - { - lastCandidate = GetDeepLastChild(lastCandidate); - if (mGenIter) - { - mLastIter = mGenIter; - mLastIterType = mIterType; - } - } - - // confirm that this first possible contained node - // is indeed contained. Else we have a range that - // does not fully contain any node. - - if (!mLastIter && - NS_FAILED(nsRange::CompareNodeToRange(lastCandidate, aRange, &nodeBefore, - &nodeAfter))) - return NS_ERROR_FAILURE; - - if (nodeBefore || nodeAfter) - { - MakeEmpty(); - return NS_OK; - } - - // cool, we have the last node in the range. Now we walk - // up it's ancestors to find the most senior that is still - // in the range. That's the real first node. - if (NS_SUCCEEDED(GetTopAncestorInRange(lastCandidate, address_of(mLast)))) - { - mLastIter = 0;//ancestor has one no - mGenIter = 0; - } - else if (!mLastIter) //something bad happened and its not generated content iterators fault - return NS_ERROR_FAILURE; - else - mLast = lastCandidate;//setting last candidate to parent of generated content this is ok - - mCurNode = mFirst; - mGenIter = mFirstIter; - mIterType = mFirstIterType ; - return NS_OK; -} - - -/**************************************************************** - * nsGeneratedSubtreeIterator overrides of ContentIterator routines - ****************************************************************/ - -void -nsGeneratedSubtreeIterator::Next() -{ - if (mIsDone) - return; - nsCOMPtr curnode; - nsCOMPtr nextNode; - if (mGenIter) - { - if (mGenIter->IsDone()) - { - mGenIter = 0; - - if (mIterType == nsIPresShell::After) - { - nextNode = GetNextSibling(mCurNode); - - if (!nextNode) - { - mIsDone = PR_TRUE; - - return; - } - } - else - { - nextNode = mCurNode->GetChildAt(0); - } - } - else { - mGenIter->Next(); - - return; - } - } - else - { - if (mCurNode == mLast) - { - mIsDone = PR_TRUE; - return; - } - nextNode = GetNextSibling(mCurNode); - - if (!nextNode) - { - mIsDone = PR_TRUE; - - return; - } - } - - if (!mGenIter) - nextNode = GetDeepFirstChild(nextNode); - if (NS_SUCCEEDED(GetTopAncestorInRange(nextNode, address_of(mCurNode)))) - { - mGenIter = 0; - } - else if (!mGenIter) //something bad happened and its not generated content iterators fault - return; - else - mCurNode = nextNode;//setting last candidate to parent of generated content this is ok -} - - -void -nsGeneratedSubtreeIterator::Prev() -{ -//notimplemented - NS_ERROR("Not implemented!"); -} - -nsresult -nsGeneratedSubtreeIterator::PositionAt(nsIContent* aCurNode) -{ - NS_ERROR("Not implemented!"); - - return NS_ERROR_NOT_IMPLEMENTED; -} - -/**************************************************************** - * nsGeneratedSubtreeIterator helper routines - ****************************************************************/ - -nsresult nsGeneratedSubtreeIterator::GetTopAncestorInRange( - nsCOMPtr aNode, - nsCOMPtr *outAnestor) -{ - if (!aNode) - return NS_ERROR_NULL_POINTER; - if (!outAnestor) - return NS_ERROR_NULL_POINTER; - - - // sanity check: aNode is itself in the range - PRBool nodeBefore, nodeAfter; - if (NS_FAILED(nsRange::CompareNodeToRange(aNode, mRange, &nodeBefore, - &nodeAfter))) - return NS_ERROR_FAILURE; - - if (nodeBefore || nodeAfter) - return NS_ERROR_FAILURE; - - nsCOMPtr parent; - while (aNode) - { - parent = aNode->GetParent(); - if (!parent) - return NS_ERROR_FAILURE; - if (NS_FAILED(nsRange::CompareNodeToRange(parent, mRange, &nodeBefore, - &nodeAfter))) - return NS_ERROR_FAILURE; - - if (nodeBefore || nodeAfter) - { - *outAnestor = aNode; - return NS_OK; - } - aNode = parent; - } - return NS_ERROR_FAILURE; -} - - - - - - diff --git a/layout/base/Makefile.in b/layout/base/Makefile.in index 3a36fda4c6f5..4efdd515a277 100644 --- a/layout/base/Makefile.in +++ b/layout/base/Makefile.in @@ -130,7 +130,6 @@ CPPSRCS = \ nsCounterManager.cpp \ nsDisplayList.cpp \ nsDocumentViewer.cpp \ - nsFrameContentIterator.cpp \ nsFrameManager.cpp \ nsFrameTraversal.cpp \ nsGenConList.cpp \ diff --git a/layout/base/nsFrameContentIterator.cpp b/layout/base/nsFrameContentIterator.cpp deleted file mode 100644 index 18419911c877..000000000000 --- a/layout/base/nsFrameContentIterator.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org Code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsCOMPtr.h" -#include "nsIContentIterator.h" -#include "nsPresContext.h" -#include "nsIFrame.h" -#include "nsIContent.h" -#include "nsIEnumerator.h" -#include "nsFrameList.h" - -class nsFrameContentIterator : public nsIContentIterator -{ -public: - nsFrameContentIterator(nsPresContext* aPresContext, nsIFrame* aFrame); - virtual ~nsFrameContentIterator(); - - // nsISupports - NS_DECL_ISUPPORTS - - // nsIContentIterator - virtual nsresult Init(nsIContent* aRoot); - virtual nsresult Init(nsIDOMRange* aRange); - - virtual void First(); - virtual void Last(); - virtual void Next(); - virtual void Prev(); - - virtual nsIContent *GetCurrentNode(); - virtual PRBool IsDone(); - virtual nsresult PositionAt(nsIContent* aCurNode); - -private: - nsCOMPtr mPresContext; - nsIFrame* mParentFrame; - nsIFrame* mCurrentChild; - PRBool mIsDone; -}; - -nsFrameContentIterator::nsFrameContentIterator(nsPresContext* aPresContext, - nsIFrame* aFrame) - : mPresContext(aPresContext), mParentFrame(aFrame), mIsDone(PR_FALSE) -{ - First(); -} - -NS_IMPL_ISUPPORTS1(nsFrameContentIterator, nsIContentIterator) - -nsFrameContentIterator::~nsFrameContentIterator() -{ -} - -nsresult -nsFrameContentIterator::Init(nsIContent* aRoot) -{ - return NS_ERROR_ALREADY_INITIALIZED; -} - -nsresult -nsFrameContentIterator::Init(nsIDOMRange* aRange) -{ - return NS_ERROR_ALREADY_INITIALIZED; -} - -void -nsFrameContentIterator::First() -{ - // Get the first child frame and make it the current node - mCurrentChild = mParentFrame->GetFirstChild(nsnull); - - mIsDone = !mCurrentChild; -} - - -static nsIFrame* -GetNextChildFrame(nsPresContext* aPresContext, nsIFrame* aFrame) -{ - NS_PRECONDITION(aFrame, "null pointer"); - - // Get the last-in-flow - aFrame = aFrame->GetLastInFlow(); - - // Get its next sibling - nsIFrame* nextSibling = aFrame->GetNextSibling(); - - // If there's no next sibling, then check if the parent frame - // has a next-in-flow and look there - if (!nextSibling) { - nsIFrame* parent = aFrame->GetParent()->GetNextInFlow(); - - if (parent) { - nextSibling = parent->GetFirstChild(nsnull); - } - } - - return nextSibling; -} - -void -nsFrameContentIterator::Last() -{ - // Starting with the first child walk and find the last child - mCurrentChild = nsnull; - nsIFrame* nextChild = mParentFrame->GetFirstChild(nsnull); - while (nextChild) { - mCurrentChild = nextChild; - nextChild = ::GetNextChildFrame(mPresContext, nextChild); - } - - mIsDone = !mCurrentChild; -} - -void -nsFrameContentIterator::Next() -{ - nsIFrame* nextChild = ::GetNextChildFrame(mPresContext, mCurrentChild); - - if (nextChild) { - // Advance to the next child - mCurrentChild = nextChild; - - // If we're at the end then the collection is at the end - mIsDone = (nsnull == ::GetNextChildFrame(mPresContext, mCurrentChild)); - - return; - } - - // No next frame, we're done. - mIsDone = PR_TRUE; -} - -static nsIFrame* -GetPrevChildFrame(nsPresContext* aPresContext, nsIFrame* aFrame) -{ - NS_PRECONDITION(aFrame, "null pointer"); - - // Get its previous sibling. Because we have a singly linked list we - // need to search from the first child - nsIFrame* parent = aFrame->GetParent(); - nsIFrame* prevSibling; - nsIFrame* firstChild = parent->GetFirstChild(nsnull); - - NS_ASSERTION(firstChild, "parent has no first child"); - nsFrameList frameList(firstChild); - prevSibling = frameList.GetPrevSiblingFor(aFrame); - - // If there's no previous sibling, then check if the parent frame - // has a prev-in-flow and look there - if (!prevSibling) { - parent = parent->GetPrevInFlow(); - - if (parent) { - firstChild = parent->GetFirstChild(nsnull); - frameList.SetFrames(firstChild); - prevSibling = frameList.LastChild(); - } - } - - // Get the first-in-flow - while (PR_TRUE) { - nsIFrame* prevInFlow = prevSibling->GetPrevInFlow(); - if (prevInFlow) { - prevSibling = prevInFlow; - } else { - break; - } - } - - return prevSibling; -} - -void -nsFrameContentIterator::Prev() -{ - nsIFrame* prevChild = ::GetPrevChildFrame(mPresContext, mCurrentChild); - - if (prevChild) { - // Make the previous child the current child - mCurrentChild = prevChild; - - // If we're at the beginning then the collection is at the end - mIsDone = (nsnull == ::GetPrevChildFrame(mPresContext, mCurrentChild)); - - return; - } - - // No previous frame, we're done. - mIsDone = PR_TRUE; -} - -nsIContent * -nsFrameContentIterator::GetCurrentNode() -{ - if (mCurrentChild && !mIsDone) { - return mCurrentChild->GetContent(); - } - - return nsnull; -} - -PRBool -nsFrameContentIterator::IsDone() -{ - return mIsDone; -} - -nsresult -nsFrameContentIterator::PositionAt(nsIContent* aCurNode) -{ - // Starting with the first child frame search for the child frame - // with the matching content object - nsIFrame* child = mParentFrame->GetFirstChild(nsnull); - while (child) { - if (child->GetContent() == aCurNode) { - break; - } - child = ::GetNextChildFrame(mPresContext, child); - } - - if (child) { - // Make it the current child - mCurrentChild = child; - mIsDone = PR_FALSE; - } - - return NS_OK; -} - -nsresult -NS_NewFrameContentIterator(nsPresContext* aPresContext, - nsIFrame* aFrame, - nsIContentIterator** aIterator) -{ - NS_ENSURE_ARG_POINTER(aIterator); - if (!aIterator) { - return NS_ERROR_NULL_POINTER; - } - NS_ENSURE_ARG_POINTER(aFrame); - if (!aFrame) { - return NS_ERROR_NULL_POINTER; - } - - // Make sure the frame corresponds to generated content - NS_ASSERTION(aFrame->GetStateBits() & NS_FRAME_GENERATED_CONTENT, "unexpected frame"); - - nsFrameContentIterator* it = new nsFrameContentIterator(aPresContext, aFrame); - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - return it->QueryInterface(NS_GET_IID(nsIContentIterator), (void **)aIterator); -} diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 2c2307e27288..2f0ef61bd486 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -100,9 +100,8 @@ typedef short SelectionType; // 0d8a87aa-3e6f-409f-a518-96fd8a29b423 #define NS_IPRESSHELL_IID \ -{ 0x0d8a87aa, 0x3e6f, 0x409f, \ - { 0xa5, 0x18, 0x96, 0xfd, 0x8a, 0x29, 0xb4, 0x23 } } - +{ 0x79433b66, 0xe8a4, 0x442f, \ + { 0x9c, 0x6e, 0x2f, 0xb2, 0x8d, 0x5e, 0x84, 0xd7 } } // Constants uses for ScrollFrameIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -549,19 +548,6 @@ public: */ NS_IMETHOD IsReflowLocked(PRBool* aIsLocked) = 0; - /** - * Returns a content iterator to iterate the generated content nodes. - * You must specify whether you want to iterate the "before" generated - * content or the "after" generated content. If there is no generated - * content of the specified type for the promary frame associated with - * with the content object then NULL is returned - */ - enum GeneratedContentType {Before, After}; - NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const = 0; - - /** * Store the nsIAnonymousContentCreator-generated anonymous * content that's associated with an element. The new anonymous content diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 82ce11557786..334f70c9057b 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1143,10 +1143,6 @@ public: NS_IMETHOD CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, PRBool aLeavingPage); - NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const; - NS_IMETHOD SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnonymousElements); NS_IMETHOD GetAnonymousContentFor(nsIContent* aContent, nsISupportsArray** aAnonymousElements); NS_IMETHOD ReleaseAnonymousContent(); @@ -4747,52 +4743,6 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa return NS_OK; } -NS_IMETHODIMP -PresShell::GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const -{ - nsresult rv = NS_OK; - - // Initialize OUT parameter - *aIterator = nsnull; - - // Get the primary frame associated with the content object - nsIFrame* primaryFrame = GetPrimaryFrameFor(aContent); - if (primaryFrame) { - // See whether it's a request for the before or after generated content - if (Before == aType) { - nsIFrame* beforeFrame = nsLayoutUtils::GetBeforeFrame(primaryFrame); - if (beforeFrame) { - // Create an iterator - rv = NS_NewFrameContentIterator(mPresContext, beforeFrame, aIterator); - } - - } else { - // Avoid finding the :after frame unless we need to (it's - // expensive). Instead probe for the existence of the pseudo-element - nsStyleContext *styleContext; - - styleContext = primaryFrame->GetStyleContext(); - if (nsLayoutUtils::HasPseudoStyle(aContent, styleContext, - nsCSSPseudoElements::after, - mPresContext)) { - nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(primaryFrame); - if (afterFrame) - { - NS_ASSERTION(afterFrame->IsGeneratedContentFrame(), - "can't find generated content frame"); - // Create an iterator - rv = NS_NewFrameContentIterator(mPresContext, afterFrame, aIterator); - } - } - } - } - - return rv; -} - - NS_IMETHODIMP PresShell::SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnonymousElements) { diff --git a/layout/build/nsLayoutCID.h b/layout/build/nsLayoutCID.h index f4786a7e76e5..3877543d6976 100644 --- a/layout/build/nsLayoutCID.h +++ b/layout/build/nsLayoutCID.h @@ -129,14 +129,6 @@ {/* {a6cf90e3-15b3-11d2-932e-00805f8add32}*/ \ 0xa6cf90e3, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } -#define NS_GENERATEDSUBTREEITERATOR_CID \ -{/* {9A45253B-EB8F-49f1-B925-E9EA90D3EB3A}*/ \ - 0x9a45253b, 0xeb8f, 0x49f1, { 0xb9, 0x25, 0xe9, 0xea, 0x90, 0xd3, 0xeb, 0x3a } } - -#define NS_GENERATEDCONTENTITERATOR_CID \ -{/* {A364930F-E353-49f1-AC69-91637EB8B757}*/ \ - 0xa364930f, 0xe353, 0x49f1, { 0xac, 0x69, 0x91, 0x63, 0x7e, 0xb8, 0xb7, 0x57 } } - #define NS_SUBTREEITERATOR_CID \ {/* {a6cf90e5-15b3-11d2-932e-00805f8add32}*/ \ 0xa6cf90e5, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index aab58d9bf172..997192e9c9fd 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -425,8 +425,6 @@ MAKE_CTOR(CreateRange, nsIDOMRange, NS_NewRan MAKE_CTOR(CreateRangeUtils, nsIRangeUtils, NS_NewRangeUtils) MAKE_CTOR(CreateContentIterator, nsIContentIterator, NS_NewContentIterator) MAKE_CTOR(CreatePreContentIterator, nsIContentIterator, NS_NewPreContentIterator) -MAKE_CTOR(CreateGeneratedContentIterator, nsIContentIterator, NS_NewGenRegularIterator) -MAKE_CTOR(CreateGeneratedSubtreeIterator, nsIContentIterator, NS_NewGenSubtreeIterator) MAKE_CTOR(CreateSubtreeIterator, nsIContentIterator, NS_NewContentSubtreeIterator) // CreateHTMLImgElement, see below // CreateHTMLOptionElement, see below @@ -941,16 +939,6 @@ static const nsModuleComponentInfo gComponents[] = { "@mozilla.org/content/pre-content-iterator;1", CreatePreContentIterator }, - { "Generated Content iterator", - NS_GENERATEDCONTENTITERATOR_CID, - "@mozilla.org/content/generated-content-iterator;1", - CreateGeneratedContentIterator }, - - { "Generated Subtree iterator", - NS_GENERATEDSUBTREEITERATOR_CID, - "@mozilla.org/content/generated-subtree-content-iterator;1", - CreateGeneratedSubtreeIterator }, - { "Subtree iterator", NS_SUBTREEITERATOR_CID, "@mozilla.org/content/subtree-content-iterator;1", diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h index 5a030cb60e4b..98e47f7ddc3d 100644 --- a/layout/generic/nsHTMLParts.h +++ b/layout/generic/nsHTMLParts.h @@ -73,13 +73,6 @@ class nsIChannel; // next-in-flows and are not private to blocks #define NS_BLOCK_FLAGS_MASK 0xF0F00000 -// Factory method for creating a content iterator for generated -// content -nsresult -NS_NewFrameContentIterator(nsPresContext* aPresContext, - nsIFrame* aFrame, - nsIContentIterator** aIterator); - // Factory methods for creating html layout objects // These are variations on AreaFrame with slightly different layout diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 33402bcd7d2a..9c5cc0961281 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -119,27 +119,8 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID); //#define DEBUG_TABLE 1 -// Selection's use of generated content iterators has been turned off -// temporarily since it bogs down selection in large documents. Using -// generated content iterators is slower because it must resolve the style -// for the content to find out if it has any before/after style, and it -// increases the number of calls to GetPrimaryFrame() which is very expensive. -// -// We can reduce the number of calls to GetPrimaryFrame() during selection -// by a good factor (maybe 2-3 times) if we just ignore the generated content -// and NOT hilite it when we cross it. -// -// #1 the output system doesn't handle it right now anyway so selecting -// has no REAL benefit to generated content. -// #2 there is no available way given to me by troy that can give back the -// necessary data without a frame to work from. -#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE -static NS_DEFINE_IID(kCGenContentIteratorCID, NS_GENERATEDCONTENTITERATOR_CID); -static NS_DEFINE_IID(kCGenSubtreeIteratorCID, NS_GENERATEDSUBTREEITERATOR_CID); -#else static NS_DEFINE_IID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kCSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); -#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #undef OLD_SELECTION #undef OLD_TABLE_SELECTION @@ -4961,15 +4942,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsresult result; if (!aInnerIter) return NS_ERROR_NULL_POINTER; -#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE - nsCOMPtr genericiter = do_QueryInterface(aInnerIter); - if (genericiter && aPresShell) - { - result = genericiter->Init(aPresShell,aContent); - } - else -#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE - result = aInnerIter->Init(aContent); + result = aInnerIter->Init(aContent); nsIFrame *frame; if (NS_SUCCEEDED(result)) { @@ -5052,33 +5025,19 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, nsIDOMRange *aRange, nsresult result; nsCOMPtr iter = do_CreateInstance( -#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE - kCGenSubtreeIteratorCID, -#else kCSubtreeIteratorCID, -#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE &result); if (NS_FAILED(result)) return result; nsCOMPtr inneriter = do_CreateInstance( -#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE - kCGenContentIteratorCID, -#else kCContentIteratorCID, -#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE &result); if ((NS_SUCCEEDED(result)) && iter && inneriter) { nsIPresShell *presShell = aPresContext->GetPresShell(); -#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE - nsCOMPtr genericiter = do_QueryInterface(iter); - if (genericiter && presShell) - result = genericiter->Init(presShell,aRange); - else -#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE - result = iter->Init(aRange); + result = iter->Init(aRange); // loop through the content iterator for each content node // for each text node: