From 875d23afcbc9472f2146f7d5e7332bc9ea489289 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Tue, 22 Jul 2014 08:24:35 -0700 Subject: [PATCH] Bug 984711 part 6: Add back special handling for min-width:auto in nsHTMLReflowState & getComputedStyle. (no review; just an unbitrotted backout) This reverts changeset 1eae876d6c3a from bug 848539. --- layout/generic/nsHTMLReflowState.cpp | 12 ++++++++++-- layout/style/nsComputedDOMStyle.cpp | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index a1d6cc41da9..d22d63beff6 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -2597,8 +2597,16 @@ nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth, { // Handle "min-width: auto" if (eStyleUnit_Auto == mStylePosition->mMinWidth.GetUnit()) { - // XXXdholbert For flex items, this needs to behave like -moz-min-content. - ComputedMinWidth() = 0; + nsFlexContainerFrame* flexContainerFrame = GetFlexContainer(frame); + if (flexContainerFrame && flexContainerFrame->IsHorizontal()) { + ComputedMinWidth() = + ComputeWidthValue(aContainingBlockWidth, + mStylePosition->mBoxSizing, + nsStyleCoord(NS_STYLE_WIDTH_MIN_CONTENT, + eStyleUnit_Enumerated)); + } else { + ComputedMinWidth() = 0; + } } else { ComputedMinWidth() = ComputeWidthValue(aContainingBlockWidth, mStylePosition->mBoxSizing, diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 6d9e4bb7b36..d4c5f7a4112 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -14,6 +14,8 @@ #include "nsError.h" #include "nsDOMString.h" #include "nsIDOMCSSPrimitiveValue.h" +#include "nsIFrame.h" +#include "nsIFrameInlines.h" #include "nsStyleContext.h" #include "nsIScrollableFrame.h" #include "nsContentUtils.h" @@ -22,6 +24,7 @@ #include "nsDOMCSSRect.h" #include "nsDOMCSSRGBColor.h" #include "nsDOMCSSValueList.h" +#include "nsFlexContainerFrame.h" #include "nsGkAtoms.h" #include "nsHTMLReflowState.h" #include "nsStyleUtil.h" @@ -4126,12 +4129,20 @@ nsComputedDOMStyle::DoGetMinWidth() nsStyleCoord minWidth = StylePosition()->mMinWidth; if (eStyleUnit_Auto == minWidth.GetUnit()) { - // In non-flexbox contexts, "min-width: auto" means "min-width: 0". - // XXXdholbert For flex items, we should set |minWidth| to the - // -moz-min-content keyword, instead of 0. + // "min-width: auto" means "0", unless we're a flex item in a horizontal + // flex container, in which case it means "min-content" minWidth.SetCoordValue(0); - } + if (mOuterFrame && mOuterFrame->IsFlexItem()) { + nsIFrame* flexContainer = mOuterFrame->GetParent(); + MOZ_ASSERT(flexContainer && + flexContainer->GetType() == nsGkAtoms::flexContainerFrame, + "IsFlexItem() lied...?"); + if (static_cast(flexContainer)->IsHorizontal()) { + minWidth.SetIntValue(NS_STYLE_WIDTH_MIN_CONTENT, eStyleUnit_Enumerated); + } + } + } SetValueToCoord(val, minWidth, true, &nsComputedDOMStyle::GetCBContentWidth, nsCSSProps::kWidthKTable);