Bug 838688 - Optimize CollectFloats by doing an early return if this block doesn't have any floats. r=bzbarsky

This commit is contained in:
Mats Palmgren 2013-02-28 00:05:45 +01:00
Родитель 68ac87f2e4
Коммит 5aeae652ec
2 изменённых файлов: 31 добавлений и 5 удалений

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

@ -6895,8 +6895,8 @@ nsBlockFrame::ReflowBullet(nsIFrame* aBulletFrame,
// that are float containing blocks. Floats that or not children of 'this'
// are ignored (they are not added to aList).
void
nsBlockFrame::CollectFloats(nsIFrame* aFrame, nsFrameList& aList,
bool aCollectSiblings)
nsBlockFrame::DoCollectFloats(nsIFrame* aFrame, nsFrameList& aList,
bool aCollectSiblings)
{
while (aFrame) {
// Don't descend into float containing blocks.
@ -6934,8 +6934,8 @@ nsBlockFrame::CollectFloats(nsIFrame* aFrame, nsFrameList& aList,
// XXXmats nsInlineFrame's lazy reparenting depends on NOT doing that.
}
CollectFloats(aFrame->GetFirstPrincipalChild(), aList, true);
CollectFloats(aFrame->GetFirstChild(kOverflowList), aList, true);
DoCollectFloats(aFrame->GetFirstPrincipalChild(), aList, true);
DoCollectFloats(aFrame->GetFirstChild(kOverflowList), aList, true);
}
if (!aCollectSiblings)
break;

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

@ -478,6 +478,25 @@ protected:
*/
bool DrainOverflowLines();
/**
* @return false iff this block does not have a float on any child list.
* This function is O(1).
*/
bool MaybeHasFloats() const {
if (!mFloats.IsEmpty()) {
return true;
}
// XXX this could be replaced with HasPushedFloats() if we enforced
// removing the property when the frame list becomes empty.
nsFrameList* list = GetPushedFloats();
if (list && !list->IsEmpty()) {
return true;
}
// For the OverflowOutOfFlowsProperty I think we do enforce that, but it's
// a mix of out-of-flow frames, so that's why the method name has "Maybe".
return GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS;
}
/** grab pushed floats from this block's prevInFlow, and splice
* them into this block's mFloats list.
*/
@ -505,7 +524,14 @@ protected:
void RemoveFloat(nsIFrame* aFloat);
void CollectFloats(nsIFrame* aFrame, nsFrameList& aList,
bool aCollectFromSiblings);
bool aCollectFromSiblings) {
if (MaybeHasFloats()) {
DoCollectFloats(aFrame, aList, aCollectFromSiblings);
}
}
void DoCollectFloats(nsIFrame* aFrame, nsFrameList& aList,
bool aCollectFromSiblings);
// Remove a float, abs, rel positioned frame from the appropriate block's list
static void DoRemoveOutOfFlowFrame(nsIFrame* aFrame);