mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1253834 - add AllChildrenIterator::Get(), r=bz
This commit is contained in:
parent
69d1a23cae
commit
1cb1817bd3
@ -215,7 +215,7 @@ ExplicitChildIterator::Seek(nsIContent* aChildToFind)
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
ExplicitChildIterator::Get()
|
||||
ExplicitChildIterator::Get() const
|
||||
{
|
||||
MOZ_ASSERT(!mIsFirst);
|
||||
|
||||
@ -311,6 +311,38 @@ ExplicitChildIterator::GetPreviousChild()
|
||||
return mChild;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
AllChildrenIterator::Get() const
|
||||
{
|
||||
switch (mPhase) {
|
||||
case eAtBeforeKid: {
|
||||
nsIFrame* frame = mOriginalContent->GetPrimaryFrame();
|
||||
MOZ_ASSERT(frame, "No frame at eAtBeforeKid phase");
|
||||
nsIFrame* beforeFrame = nsLayoutUtils::GetBeforeFrame(frame);
|
||||
MOZ_ASSERT(beforeFrame, "No content before frame at eAtBeforeKid phase");
|
||||
return beforeFrame->GetContent();
|
||||
}
|
||||
|
||||
case eAtExplicitKids:
|
||||
return ExplicitChildIterator::Get();
|
||||
|
||||
case eAtAnonKids:
|
||||
return mAnonKids[mAnonKidsIdx];
|
||||
|
||||
case eAtAfterKid: {
|
||||
nsIFrame* frame = mOriginalContent->GetPrimaryFrame();
|
||||
MOZ_ASSERT(frame, "No frame at eAtAfterKid phase");
|
||||
nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(frame);
|
||||
MOZ_ASSERT(afterFrame, "No content before frame at eAtBeforeKid phase");
|
||||
return afterFrame->GetContent();
|
||||
}
|
||||
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AllChildrenIterator::Seek(nsIContent* aChildToFind)
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
// Returns the current target of this iterator (which might be an explicit
|
||||
// child of the node, fallback content of an insertion point or
|
||||
// a node distributed to an insertion point.
|
||||
nsIContent* Get();
|
||||
nsIContent* Get() const;
|
||||
|
||||
// The inverse of GetNextChild. Properly steps in and out of insertion
|
||||
// points.
|
||||
@ -170,12 +170,13 @@ protected:
|
||||
};
|
||||
|
||||
/**
|
||||
* AllChildrenIterator returns the children of a element including before /
|
||||
* after content and optionally XBL children. It assumes that no mutation of
|
||||
* the DOM or frame tree takes place during iteration, and will break horribly
|
||||
* if that is not true. The iterator can be initialized to start at the end by
|
||||
* providing false for aStartAtBeginning in order to start iterating in reverse
|
||||
* from the last child.
|
||||
* AllChildrenIterator traverses the children of an element including before /
|
||||
* after content and optionally XBL children. The iterator can be initialized
|
||||
* to start at the end by providing false for aStartAtBeginning in order to
|
||||
* start iterating in reverse from the last child.
|
||||
*
|
||||
* Note: it assumes that no mutation of the DOM or frame tree takes place during
|
||||
* iteration, and will break horribly if that is not true.
|
||||
*/
|
||||
class AllChildrenIterator : private FlattenedChildIterator
|
||||
{
|
||||
@ -199,6 +200,13 @@ public:
|
||||
~AllChildrenIterator() { MOZ_ASSERT(!mMutationGuard.Mutated(0)); }
|
||||
#endif
|
||||
|
||||
// Returns the current target the iterator is at, or null if the iterator
|
||||
// doesn't point to any child node (either eAtBegin or eAtEnd phase).
|
||||
nsIContent* Get() const;
|
||||
|
||||
// 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);
|
||||
|
||||
nsIContent* GetNextChild();
|
||||
|
Loading…
Reference in New Issue
Block a user