From c427cf64a8c13b13ce39fecf9db71672df622038 Mon Sep 17 00:00:00 2001 From: JustOff Date: Thu, 14 Mar 2019 19:40:42 +0200 Subject: Handle the special case of a flex frame being the absolute containing block correctly from the CSS align code --- layout/generic/nsAbsoluteContainingBlock.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'layout/generic') diff --git a/layout/generic/nsAbsoluteContainingBlock.cpp b/layout/generic/nsAbsoluteContainingBlock.cpp index 7c48aae92..e3c847d01 100644 --- a/layout/generic/nsAbsoluteContainingBlock.cpp +++ b/layout/generic/nsAbsoluteContainingBlock.cpp @@ -409,14 +409,30 @@ OffsetToAlignedStaticPos(const ReflowInput& aKidReflowInput, ? GetOrthogonalAxis(aAbsPosCBAxis) : aAbsPosCBAxis); + const bool placeholderContainerIsContainingBlock = + aPlaceholderContainer == aKidReflowInput.mCBReflowInput->mFrame; + nsIAtom* parentType = aPlaceholderContainer->GetType(); LogicalSize alignAreaSize(pcWM); if (parentType == nsGkAtoms::flexContainerFrame) { - // The alignment container is the flex container's content box: - alignAreaSize = aPlaceholderContainer->GetLogicalSize(pcWM); - LogicalMargin pcBorderPadding = - aPlaceholderContainer->GetLogicalUsedBorderAndPadding(pcWM); - alignAreaSize -= pcBorderPadding.Size(pcWM); + // We store the frame rect in FinishAndStoreOverflow, which runs _after_ + // reflowing the absolute frames, so handle the special case of the frame + // being the actual containing block here, by getting the size from + // aAbsPosCBSize. + // + // The alignment container is the flex container's content box. + if (placeholderContainerIsContainingBlock) { + alignAreaSize = aAbsPosCBSize.ConvertTo(pcWM, aAbsPosCBWM); + // aAbsPosCBSize is the padding-box, so substract the padding to get the + // content box. + alignAreaSize -= + aPlaceholderContainer->GetLogicalUsedPadding(pcWM).Size(pcWM); + } else { + alignAreaSize = aPlaceholderContainer->GetLogicalSize(pcWM); + LogicalMargin pcBorderPadding = + aPlaceholderContainer->GetLogicalUsedBorderAndPadding(pcWM); + alignAreaSize -= pcBorderPadding.Size(pcWM); + } } else if (parentType == nsGkAtoms::gridContainerFrame) { // This abspos elem's parent is a grid container. Per CSS Grid 10.1 & 10.2: // - If the grid container *also* generates the abspos containing block (a @@ -424,7 +440,7 @@ OffsetToAlignedStaticPos(const ReflowInput& aKidReflowInput, // the alignment container, too. (And its size is aAbsPosCBSize.) // - Otherwise, we use the grid's padding box as the alignment container. // https://drafts.csswg.org/css-grid/#static-position - if (aPlaceholderContainer == aKidReflowInput.mCBReflowInput->mFrame) { + if (placeholderContainerIsContainingBlock) { // The alignment container is the grid area that we're using as the // absolute containing block. alignAreaSize = aAbsPosCBSize.ConvertTo(pcWM, aAbsPosCBWM); -- cgit v1.2.3