Bug 1793826 Part 1 - Change nsFrameList::ExtractHead and ExtractTail to take nsIFrame* argument. r=emilio

This is a preparation to remove nsFrameList::FrameLinkEnumerator in the next
part.

FrameLinkEnumerator::Find() can be replaced with std::find/std::find_if.

Differential Revision: https://phabricator.services.mozilla.com/D158700
This commit is contained in:
Ting-Yu Lin
2022-10-06 00:19:41 +00:00
parent f5ac0b9d15
commit c1ba6068b9
6 changed files with 89 additions and 126 deletions

View File

@@ -11007,13 +11007,14 @@ nsIFrame* nsCSSFrameConstructor::ConstructInline(
ConstructFramesFromItemList(aState, aItem.mChildItems, newFrame,
/* aParentIsWrapperAnonBox = */ false, childList);
nsFrameList::FrameLinkEnumerator firstBlockEnumerator(childList);
if (!aItem.mIsAllInline) {
firstBlockEnumerator.Find(
[](nsIFrame* aFrame) { return aFrame->IsBlockOutside(); });
}
auto firstBlock = aItem.mIsAllInline
? childList.end()
: std::find_if(childList.begin(), childList.end(),
[](nsIFrame* aFrame) {
return aFrame->IsBlockOutside();
});
if (aItem.mIsAllInline || firstBlockEnumerator.AtEnd()) {
if (aItem.mIsAllInline || firstBlock == childList.end()) {
// This part is easy. We either already know we have no non-inline kids,
// or haven't found any when constructing actual frames (the latter can
// happen only if out-of-flows that we thought had no containing block
@@ -11029,7 +11030,7 @@ nsIFrame* nsCSSFrameConstructor::ConstructInline(
// has to be chopped into several pieces, as described above.
// Grab the first inline's kids
nsFrameList firstInlineKids = childList.ExtractHead(firstBlockEnumerator);
nsFrameList firstInlineKids = childList.ExtractHead(*firstBlock);
newFrame->SetInitialChildList(kPrincipalList, firstInlineKids);
aFrameList.AppendFrame(nullptr, newFrame);