Bug 1484306 Part 3 - Use nsFrameList::Split() to replace the usage of FindFirstBlock(). r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D3645
This commit is contained in:
Ting-Yu Lin 2018-08-17 10:56:25 -07:00
Родитель 4347d6785b
Коммит 4e52c71be9
1 изменённых файлов: 10 добавлений и 22 удалений

Просмотреть файл

@ -635,15 +635,6 @@ ParentIsWrapperAnonBox(nsIFrame* aParent)
// child then the block child is migrated upward until it lands in a block // child then the block child is migrated upward until it lands in a block
// parent (the inline frames containing block is where it will end up). // parent (the inline frames containing block is where it will end up).
// After this function returns, aLink is pointing to the first link at or
// after its starting position for which the next frame is a block. If there
// is no such link, it points to the end of the list.
static void
FindFirstBlock(nsFrameList::FrameLinkEnumerator& aLink)
{
aLink.Find([](nsIFrame* aFrame) { return !aFrame->IsInlineOutside(); });
}
inline void inline void
SetInitialSingleChild(nsContainerFrame* aParent, nsIFrame* aFrame) SetInitialSingleChild(nsContainerFrame* aParent, nsIFrame* aFrame)
{ {
@ -6218,10 +6209,9 @@ nsCSSFrameConstructor::AppendFramesToParent(nsFrameConstructorState& aStat
} }
// We want to put some of the frames into this inline frame. // We want to put some of the frames into this inline frame.
nsFrameList::FrameLinkEnumerator firstBlockEnumerator(aFrameList); nsFrameList inlineKids =
FindFirstBlock(firstBlockEnumerator); aFrameList.Split([](nsIFrame* f) { return !f->IsInlineOutside(); });
nsFrameList inlineKids = aFrameList.ExtractHead(firstBlockEnumerator);
if (!inlineKids.IsEmpty()) { if (!inlineKids.IsEmpty()) {
AppendFrames(aParentFrame, kPrincipalList, inlineKids); AppendFrames(aParentFrame, kPrincipalList, inlineKids);
} }
@ -10240,11 +10230,10 @@ nsCSSFrameConstructor::WrapFramesInFirstLineFrame(
nsFirstLineFrame* aLineFrame, nsFirstLineFrame* aLineFrame,
nsFrameItems& aFrameItems) nsFrameItems& aFrameItems)
{ {
// Find the part of aFrameItems that we want to put in the first-line // Extract any initial inline frames from aFrameItems so we can put them
nsFrameList::FrameLinkEnumerator link(aFrameItems); // in the first-line.
FindFirstBlock(link); nsFrameList firstLineChildren =
aFrameItems.Split([](nsIFrame* f) { return !f->IsInlineOutside(); });
nsFrameList firstLineChildren = aFrameItems.ExtractHead(link);
if (firstLineChildren.IsEmpty()) { if (firstLineChildren.IsEmpty()) {
// Nothing is supposed to go into the first-line; nothing to do // Nothing is supposed to go into the first-line; nothing to do
@ -11123,7 +11112,8 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState,
nsFrameList::FrameLinkEnumerator firstBlockEnumerator(childItems); nsFrameList::FrameLinkEnumerator firstBlockEnumerator(childItems);
if (!aItem.mIsAllInline) { if (!aItem.mIsAllInline) {
FindFirstBlock(firstBlockEnumerator); firstBlockEnumerator.Find(
[](nsIFrame* aFrame) { return !aFrame->IsInlineOutside(); });
} }
if (aItem.mIsAllInline || firstBlockEnumerator.AtEnd()) { if (aItem.mIsAllInline || firstBlockEnumerator.AtEnd()) {
@ -11212,10 +11202,8 @@ nsCSSFrameConstructor::CreateIBSiblings(nsFrameConstructorState& aState,
} }
if (aChildItems.NotEmpty()) { if (aChildItems.NotEmpty()) {
nsFrameList::FrameLinkEnumerator firstBlock(aChildItems); nsFrameList inlineKids =
FindFirstBlock(firstBlock); aChildItems.Split([](nsIFrame* f) { return !f->IsInlineOutside(); });
nsFrameList inlineKids = aChildItems.ExtractHead(firstBlock);
MoveChildrenTo(aInitialInline, inlineFrame, inlineKids); MoveChildrenTo(aInitialInline, inlineFrame, inlineKids);
} }