mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1247364 - add AllChildrenIterator::Seek, r=bz
This commit is contained in:
parent
e7ddbfc7cb
commit
64ca196ec5
@ -190,7 +190,7 @@ FlattenedChildIterator::Init(bool aIgnoreXBL)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ExplicitChildIterator::Seek(nsIContent* aChildToFind)
|
||||
{
|
||||
if (aChildToFind->GetParent() == mParent &&
|
||||
@ -204,14 +204,14 @@ ExplicitChildIterator::Seek(nsIContent* aChildToFind)
|
||||
mShadowIterator = nullptr;
|
||||
mDefaultChild = nullptr;
|
||||
mIsFirst = false;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Can we add more fast paths here based on whether the parent of aChildToFind
|
||||
// is a shadow insertion point or content insertion point?
|
||||
|
||||
// Slow path: just walk all our kids.
|
||||
Seek(aChildToFind, nullptr);
|
||||
return Seek(aChildToFind, nullptr);
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
@ -311,6 +311,37 @@ ExplicitChildIterator::GetPreviousChild()
|
||||
return mChild;
|
||||
}
|
||||
|
||||
bool
|
||||
AllChildrenIterator::Seek(nsIContent* aChildToFind)
|
||||
{
|
||||
if (mPhase == eNeedBeforeKid) {
|
||||
mPhase = eNeedExplicitKids;
|
||||
nsIFrame* frame = mOriginalContent->GetPrimaryFrame();
|
||||
if (frame) {
|
||||
nsIFrame* beforeFrame = nsLayoutUtils::GetBeforeFrame(frame);
|
||||
if (beforeFrame) {
|
||||
if (beforeFrame->GetContent() == aChildToFind) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mPhase == eNeedExplicitKids) {
|
||||
if (ExplicitChildIterator::Seek(aChildToFind)) {
|
||||
return true;
|
||||
}
|
||||
mPhase = eNeedAnonKids;
|
||||
}
|
||||
|
||||
nsIContent* child = nullptr;
|
||||
do {
|
||||
child = GetNextChild();
|
||||
} while (child && child != aChildToFind);
|
||||
|
||||
return child == aChildToFind;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
AllChildrenIterator::GetNextChild()
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ 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).
|
||||
void Seek(nsIContent* aChildToFind);
|
||||
bool Seek(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
|
||||
@ -199,6 +199,8 @@ public:
|
||||
~AllChildrenIterator() { MOZ_ASSERT(!mMutationGuard.Mutated(0)); }
|
||||
#endif
|
||||
|
||||
bool Seek(nsIContent* aChildToFind);
|
||||
|
||||
nsIContent* GetNextChild();
|
||||
nsIContent* Parent() const { return mOriginalContent; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user