Bug 1151243 part 2 - [css-grid] Add a eIsGridContainerCB flag for nsAbsoluteContainingBlock::Reflow to trigger Grid specific code (rather than checking GetType()). r=dholbert

This commit is contained in:
Mats Palmgren
2015-12-22 23:03:16 +01:00
parent 871c9ae3b7
commit 8a5b7625f3
4 changed files with 11 additions and 20 deletions

View File

@@ -118,16 +118,8 @@ nsAbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame,
{
nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
bool reflowAll = aReflowState.ShouldReflowAllKids();
// The 'width' check below is an optimization to avoid the virtual GetType()
// call in most cases. 'aContainingBlock' isn't used for grid items,
// each item has its own CB on a frame property instead.
// @see nsGridContainerFrame::ReflowChildren
const bool isGrid =
aContainingBlock.width == nsGridContainerFrame::VERY_LIKELY_A_GRID_CONTAINER &&
aDelegatingFrame->GetType() == nsGkAtoms::gridContainerFrame;
const bool reflowAll = aReflowState.ShouldReflowAllKids();
const bool isGrid = !!(aFlags & AbsPosReflowFlags::eIsGridContainerCB);
nsIFrame* kidFrame;
nsOverflowContinuationTracker tracker(aDelegatingFrame, true);
for (kidFrame = mAbsoluteFrames.FirstChild(); kidFrame; kidFrame = kidFrame->GetNextSibling()) {

View File

@@ -70,10 +70,11 @@ public:
nsIFrame* aOldFrame);
enum class AbsPosReflowFlags {
eConstrainHeight = 0x1,
eCBWidthChanged = 0x2,
eCBHeightChanged = 0x4,
eConstrainHeight = 0x1,
eCBWidthChanged = 0x2,
eCBHeightChanged = 0x4,
eCBWidthAndHeightChanged = eCBWidthChanged | eCBHeightChanged,
eIsGridContainerCB = 0x8,
};
/**

View File

@@ -3244,13 +3244,14 @@ nsGridContainerFrame::ReflowChildren(GridReflowState& aState,
}
*cb = itemCB.GetPhysicalRect(wm, gridCBPhysicalSize);
}
// This rect isn't used at all for layout so we use it to optimize
// away the virtual GetType() call in the callee in most cases.
// @see nsAbsoluteContainingBlock::Reflow
nsRect dummyRect(0, 0, VERY_LIKELY_A_GRID_CONTAINER, 0);
// We pass a dummy rect as CB because each child has its own CB rect.
// The eIsGridContainerCB flag tells nsAbsoluteContainingBlock::Reflow to
// use those instead.
nsRect dummyRect;
AbsPosReflowFlags flags =
AbsPosReflowFlags::eCBWidthAndHeightChanged; // XXX could be optimized
flags |= AbsPosReflowFlags::eConstrainHeight;
flags |= AbsPosReflowFlags::eIsGridContainerCB;
GetAbsoluteContainingBlock()->Reflow(this, pc, *aState.mReflowState,
aStatus, dummyRect, flags,
&aDesiredSize.mOverflowAreas);

View File

@@ -86,9 +86,6 @@ public:
StateBits mState;
};
// @see nsAbsoluteContainingBlock::Reflow about this magic number
static const nscoord VERY_LIKELY_A_GRID_CONTAINER = -123456789;
NS_DECLARE_FRAME_PROPERTY(GridItemContainingBlockRect, DeleteValue<nsRect>)
NS_DECLARE_FRAME_PROPERTY(GridColTrackSizes, DeleteValue<nsTArray<nscoord>>)