Bug 855464: Optimize nsBlockReflowState::ClearFloats better, given that nsBlockFrame::WidthToClearPastFloats is somewhat expensive. r=dholbert

This fixes a performance issue that showed up in a profile of the b2g
contacts app (though it's not clear what percentage of the time it was
given the difficulty of understanding output of 'perf').
This commit is contained in:
L. David Baron 2013-03-31 00:50:29 -07:00
parent ab382b9891
commit 8c6ca20f7d

View File

@ -945,7 +945,11 @@ nsBlockReflowState::ClearFloats(nscoord aY, uint8_t aBreakType,
aY, aBreakType);
mFloatManager->List(stdout);
#endif
if (!mFloatManager->HasAnyFloats()) {
return aY;
}
nscoord newY = aY;
if (aBreakType != NS_STYLE_CLEAR_NONE) {
@ -955,11 +959,16 @@ nsBlockReflowState::ClearFloats(nscoord aY, uint8_t aBreakType,
if (aReplacedBlock) {
for (;;) {
nsFlowAreaRect floatAvailableSpace = GetFloatAvailableSpace(newY);
if (!floatAvailableSpace.mHasFloats) {
// If there aren't any floats here, then we always fit.
// We check this before calling WidthToClearPastFloats, which is
// somewhat expensive.
break;
}
nsBlockFrame::ReplacedElementWidthToClear replacedWidth =
nsBlockFrame::WidthToClearPastFloats(*this, floatAvailableSpace.mRect,
aReplacedBlock);
if (!floatAvailableSpace.mHasFloats ||
std::max(floatAvailableSpace.mRect.x - mContentArea.x,
if (std::max(floatAvailableSpace.mRect.x - mContentArea.x,
replacedWidth.marginLeft) +
replacedWidth.borderBoxWidth +
std::max(mContentArea.XMost() - floatAvailableSpace.mRect.XMost(),