mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 09:15:35 +00:00
Bug 1568501 - Search from the end of the line rather than the start, like this code did before bug 1566945. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D39268 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
868643a218
commit
2af9d08603
@ -5475,8 +5475,12 @@ void nsBlockFrame::AddFrames(nsFrameList& aFrameList, nsIFrame* aPrevSibling,
|
|||||||
frames = &overflowLines->mFrames;
|
frames = &overflowLines->mFrames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FIXME: Should this IndexOf search from the end?
|
|
||||||
prevSiblingIndex = prevSibLine->IndexOf(aPrevSibling);
|
nsLineList::iterator nextLine = prevSibLine.next();
|
||||||
|
nsIFrame* lastFrameInLine = nextLine == lineList->end()
|
||||||
|
? frames->LastChild()
|
||||||
|
: nextLine->mFirstChild->GetPrevSibling();
|
||||||
|
prevSiblingIndex = prevSibLine->RIndexOf(aPrevSibling, lastFrameInLine);
|
||||||
MOZ_ASSERT(prevSiblingIndex >= 0,
|
MOZ_ASSERT(prevSiblingIndex >= 0,
|
||||||
"aPrevSibling must be in aPrevSiblingLine");
|
"aPrevSibling must be in aPrevSiblingLine");
|
||||||
} else {
|
} else {
|
||||||
|
@ -302,6 +302,20 @@ int32_t nsLineBox::IndexOf(nsIFrame* aFrame) const {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t nsLineBox::RIndexOf(nsIFrame* aFrame,
|
||||||
|
nsIFrame* aLastFrameInLine) const {
|
||||||
|
nsIFrame* frame = aLastFrameInLine;
|
||||||
|
for (int32_t i = GetChildCount() - 1; i >= 0; --i) {
|
||||||
|
MOZ_ASSERT(i != 0 || frame == mFirstChild,
|
||||||
|
"caller provided incorrect last frame");
|
||||||
|
if (frame == aFrame) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
frame = frame->GetPrevSibling();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
bool nsLineBox::IsEmpty() const {
|
bool nsLineBox::IsEmpty() const {
|
||||||
if (IsBlock()) return mFirstChild->IsEmpty();
|
if (IsBlock()) return mFirstChild->IsEmpty();
|
||||||
|
|
||||||
|
@ -525,8 +525,14 @@ class nsLineBox final : public nsLineLink {
|
|||||||
|
|
||||||
void AddSizeOfExcludingThis(nsWindowSizes& aSizes) const;
|
void AddSizeOfExcludingThis(nsWindowSizes& aSizes) const;
|
||||||
|
|
||||||
|
// Find the index of aFrame within the line, starting search at the start.
|
||||||
int32_t IndexOf(nsIFrame* aFrame) const;
|
int32_t IndexOf(nsIFrame* aFrame) const;
|
||||||
|
|
||||||
|
// Find the index of aFrame within the line, starting search at the end.
|
||||||
|
// (Produces the same result as IndexOf, but with different performance
|
||||||
|
// characteristics.) The caller must provide the last frame in the line.
|
||||||
|
int32_t RIndexOf(nsIFrame* aFrame, nsIFrame* aLastFrameInLine) const;
|
||||||
|
|
||||||
bool Contains(nsIFrame* aFrame) const {
|
bool Contains(nsIFrame* aFrame) const {
|
||||||
return MOZ_UNLIKELY(mFlags.mHasHashedFrames) ? mFrames->Contains(aFrame)
|
return MOZ_UNLIKELY(mFlags.mHasHashedFrames) ? mFrames->Contains(aFrame)
|
||||||
: IndexOf(aFrame) >= 0;
|
: IndexOf(aFrame) >= 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user