зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1165982 - part 1 - provide fallible initialization of nsDOMIterator from an nsRange; r=ehsan
This commit is contained in:
Родитель
309d57da39
Коммит
a587185972
|
@ -66,14 +66,6 @@ nsAutoSelectionReset::Abort()
|
|||
* some helper classes for iterating the dom tree
|
||||
*****************************************************************************/
|
||||
|
||||
nsDOMIterator::nsDOMIterator(nsRange& aRange)
|
||||
{
|
||||
MOZ_ASSERT(aRange.GetStartParent(), "Invalid range");
|
||||
mIter = NS_NewContentIterator();
|
||||
DebugOnly<nsresult> res = mIter->Init(&aRange);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(res));
|
||||
}
|
||||
|
||||
nsDOMIterator::nsDOMIterator(nsINode& aNode)
|
||||
{
|
||||
mIter = NS_NewContentIterator();
|
||||
|
@ -81,6 +73,13 @@ nsDOMIterator::nsDOMIterator(nsINode& aNode)
|
|||
MOZ_ASSERT(NS_SUCCEEDED(res));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMIterator::Init(nsRange& aRange)
|
||||
{
|
||||
mIter = NS_NewContentIterator();
|
||||
return mIter->Init(&aRange);
|
||||
}
|
||||
|
||||
nsDOMIterator::nsDOMIterator()
|
||||
{
|
||||
}
|
||||
|
@ -103,11 +102,15 @@ nsDOMIterator::AppendList(const nsBoolDomIterFunctor& functor,
|
|||
}
|
||||
}
|
||||
|
||||
nsDOMSubtreeIterator::nsDOMSubtreeIterator(nsRange& aRange)
|
||||
nsDOMSubtreeIterator::nsDOMSubtreeIterator()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMSubtreeIterator::Init(nsRange& aRange)
|
||||
{
|
||||
mIter = NS_NewContentSubtreeIterator();
|
||||
DebugOnly<nsresult> res = mIter->Init(&aRange);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(res));
|
||||
return mIter->Init(&aRange);
|
||||
}
|
||||
|
||||
nsDOMSubtreeIterator::~nsDOMSubtreeIterator()
|
||||
|
|
|
@ -173,24 +173,26 @@ class nsBoolDomIterFunctor
|
|||
class MOZ_STACK_CLASS nsDOMIterator
|
||||
{
|
||||
public:
|
||||
explicit nsDOMIterator(nsRange& aRange);
|
||||
nsDOMIterator();
|
||||
|
||||
explicit nsDOMIterator(nsINode& aNode);
|
||||
virtual ~nsDOMIterator();
|
||||
|
||||
nsresult Init(nsRange& aRange);
|
||||
|
||||
void AppendList(const nsBoolDomIterFunctor& functor,
|
||||
nsTArray<mozilla::dom::OwningNonNull<nsINode>>& arrayOfNodes) const;
|
||||
protected:
|
||||
nsCOMPtr<nsIContentIterator> mIter;
|
||||
|
||||
// For nsDOMSubtreeIterator
|
||||
nsDOMIterator();
|
||||
};
|
||||
|
||||
class MOZ_STACK_CLASS nsDOMSubtreeIterator : public nsDOMIterator
|
||||
{
|
||||
public:
|
||||
explicit nsDOMSubtreeIterator(nsRange& aRange);
|
||||
nsDOMSubtreeIterator();
|
||||
virtual ~nsDOMSubtreeIterator();
|
||||
|
||||
nsresult Init(nsRange& aRange);
|
||||
};
|
||||
|
||||
class nsTrivialFunctor : public nsBoolDomIterFunctor
|
||||
|
|
|
@ -2151,7 +2151,9 @@ nsHTMLEditor::CreateListOfNodesToPaste(DocumentFragment& aFragment,
|
|||
|
||||
// Now use a subtree iterator over the range to create a list of nodes
|
||||
nsTrivialFunctor functor;
|
||||
nsDOMSubtreeIterator iter(*docFragRange);
|
||||
nsDOMSubtreeIterator iter;
|
||||
rv = iter.Init(*docFragRange);
|
||||
NS_ENSURE_SUCCESS(rv, );
|
||||
iter.AppendList(functor, outNodeList);
|
||||
}
|
||||
|
||||
|
|
|
@ -2403,7 +2403,9 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
|||
// Build a list of nodes in the range
|
||||
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
|
||||
nsTrivialFunctor functor;
|
||||
nsDOMSubtreeIterator iter(*range);
|
||||
nsDOMSubtreeIterator iter;
|
||||
nsresult res = iter.Init(*range);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
iter.AppendList(functor, arrayOfNodes);
|
||||
|
||||
// Now that we have the list, delete non-table elements
|
||||
|
@ -5783,7 +5785,9 @@ nsHTMLEditRules::GetNodesForOperation(nsTArray<nsRefPtr<nsRange>>& aArrayOfRange
|
|||
}
|
||||
// Gather up a list of all the nodes
|
||||
for (auto& range : aArrayOfRanges) {
|
||||
nsDOMSubtreeIterator iter(*range);
|
||||
nsDOMSubtreeIterator iter;
|
||||
nsresult res = iter.Init(*range);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (aOutArrayOfNodes.Length() == 0) {
|
||||
iter.AppendList(nsTrivialFunctor(), aOutArrayOfNodes);
|
||||
} else {
|
||||
|
@ -7291,7 +7295,9 @@ nsHTMLEditRules::AdjustSpecialBreaks()
|
|||
// Gather list of empty nodes
|
||||
nsTArray<OwningNonNull<nsINode>> nodeArray;
|
||||
nsEmptyEditableFunctor functor(mHTMLEditor);
|
||||
nsDOMIterator iter(*mDocChangeRange);
|
||||
nsDOMIterator iter;
|
||||
nsresult res = iter.Init(*mDocChangeRange);
|
||||
NS_ENSURE_SUCCESS(res, );
|
||||
iter.AppendList(functor, nodeArray);
|
||||
|
||||
// Put moz-br's into these empty li's and td's
|
||||
|
|
Загрузка…
Ссылка в новой задаче