summaryrefslogtreecommitdiff
path: root/dom/base/ChildIterator.h
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/ChildIterator.h')
-rw-r--r--dom/base/ChildIterator.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/dom/base/ChildIterator.h b/dom/base/ChildIterator.h
index ec6dfa61de..78acdc1466 100644
--- a/dom/base/ChildIterator.h
+++ b/dom/base/ChildIterator.h
@@ -58,13 +58,13 @@ public:
// found. This version can take shortcuts that the two-argument version
// can't, so can be faster (and in fact can be O(1) instead of O(N) in many
// cases).
- bool Seek(nsIContent* aChildToFind);
+ bool Seek(const nsIContent* aChildToFind);
// Looks for aChildToFind respecting insertion points until aChildToFind is found.
// or aBound is found. If aBound is nullptr then the seek is unbounded. Returns
// whether aChildToFind was found as an explicit child prior to encountering
// aBound.
- bool Seek(nsIContent* aChildToFind, nsIContent* aBound)
+ bool Seek(const nsIContent* aChildToFind, nsIContent* aBound)
{
// It would be nice to assert that we find aChildToFind, but bz thinks that
// we might not find aChildToFind when called from ContentInserted
@@ -131,19 +131,29 @@ class FlattenedChildIterator : public ExplicitChildIterator
public:
explicit FlattenedChildIterator(const nsIContent* aParent,
bool aStartAtBeginning = true)
- : ExplicitChildIterator(aParent, aStartAtBeginning), mXBLInvolved(false)
+ : ExplicitChildIterator(aParent, aStartAtBeginning)
+ , mXBLInvolved(false)
+ , mOriginalContent(aParent)
{
Init(false);
}
FlattenedChildIterator(FlattenedChildIterator&& aOther)
- : ExplicitChildIterator(Move(aOther)), mXBLInvolved(aOther.mXBLInvolved) {}
+ : ExplicitChildIterator(Move(aOther))
+ , mXBLInvolved(aOther.mXBLInvolved)
+ , mOriginalContent(aOther.mOriginalContent)
+ {}
FlattenedChildIterator(const FlattenedChildIterator& aOther)
- : ExplicitChildIterator(aOther), mXBLInvolved(aOther.mXBLInvolved) {}
+ : ExplicitChildIterator(aOther)
+ , mXBLInvolved(aOther.mXBLInvolved)
+ , mOriginalContent(aOther.mOriginalContent)
+ {}
bool XBLInvolved() { return mXBLInvolved; }
+ const nsIContent* Parent() const { return mOriginalContent; }
+
protected:
/**
* This constructor is a hack to help AllChildrenIterator which sometimes
@@ -151,7 +161,9 @@ protected:
*/
FlattenedChildIterator(const nsIContent* aParent, uint32_t aFlags,
bool aStartAtBeginning = true)
- : ExplicitChildIterator(aParent, aStartAtBeginning), mXBLInvolved(false)
+ : ExplicitChildIterator(aParent, aStartAtBeginning)
+ , mXBLInvolved(false)
+ , mOriginalContent(aParent)
{
bool ignoreXBL = aFlags & nsIContent::eAllButXBL;
Init(ignoreXBL);
@@ -162,6 +174,8 @@ protected:
// For certain optimizations, nsCSSFrameConstructor needs to know if the
// child list of the element that we're iterating matches its .childNodes.
bool mXBLInvolved;
+
+ const nsIContent* mOriginalContent;
};
/**
@@ -179,12 +193,11 @@ public:
AllChildrenIterator(const nsIContent* aNode, uint32_t aFlags,
bool aStartAtBeginning = true) :
FlattenedChildIterator(aNode, aFlags, aStartAtBeginning),
- mOriginalContent(aNode), mAnonKidsIdx(aStartAtBeginning ? UINT32_MAX : 0),
+ mAnonKidsIdx(aStartAtBeginning ? UINT32_MAX : 0),
mFlags(aFlags), mPhase(aStartAtBeginning ? eAtBegin : eAtEnd) { }
AllChildrenIterator(AllChildrenIterator&& aOther)
: FlattenedChildIterator(Move(aOther)),
- mOriginalContent(aOther.mOriginalContent),
mAnonKids(Move(aOther.mAnonKids)), mAnonKidsIdx(aOther.mAnonKidsIdx),
mFlags(aOther.mFlags), mPhase(aOther.mPhase)
#ifdef DEBUG
@@ -203,11 +216,10 @@ public:
// Seeks the given node in children of a parent element, starting from
// the current iterator's position, and sets the iterator at the given child
// node if it was found.
- bool Seek(nsIContent* aChildToFind);
+ bool Seek(const nsIContent* aChildToFind);
nsIContent* GetNextChild();
nsIContent* GetPreviousChild();
- const nsIContent* Parent() const { return mOriginalContent; }
enum IteratorPhase
{
@@ -225,8 +237,6 @@ private:
void AppendNativeAnonymousChildren();
void AppendNativeAnonymousChildrenFromFrame(nsIFrame* aFrame);
- const nsIContent* mOriginalContent;
-
// mAnonKids is an array of native anonymous children, mAnonKidsIdx is index
// in the array. If mAnonKidsIdx < mAnonKids.Length() and mPhase is
// eAtAnonKids then the iterator points at a child at mAnonKidsIdx index. If