Backed out changeset be6d9849825d (bug 1695390) for wr failures in col-definite-max-size-001.html. CLOSED TREE

This commit is contained in:
Brindusan Cristian 2021-03-02 13:41:40 +02:00
Родитель 83661b9403
Коммит 82efbb80e1
21 изменённых файлов: 246 добавлений и 176 удалений

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

@ -1967,6 +1967,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"content",
"inherit",
@ -1986,6 +1988,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"content",
"inherit",
@ -3799,6 +3803,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"inherit",
"initial",
@ -6054,6 +6060,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"content",
"inherit",
@ -6073,6 +6081,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"content",
"inherit",
@ -6993,6 +7003,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"inherit",
"initial",
@ -7078,6 +7090,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"inherit",
"initial",
@ -8238,6 +8252,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"inherit",
"initial",
@ -8256,6 +8272,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"inherit",
"initial",
@ -8274,6 +8292,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"inherit",
"initial",
@ -8292,6 +8312,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"inherit",
"initial",
@ -10801,6 +10823,8 @@ exports.CSS_PROPERTIES = {
"values": [
"-moz-available",
"-moz-fit-content",
"-moz-max-content",
"-moz-min-content",
"auto",
"inherit",
"initial",

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

@ -4298,6 +4298,9 @@ static bool GetPercentBSize(const LengthPercentage& aStyle, nsIFrame* aFrame,
nscoord h;
if (!GetAbsoluteCoord(bSizeCoord, h) &&
!GetPercentBSize(bSizeCoord, f, aHorizontalAxis, h)) {
NS_ASSERTION(bSizeCoord.IsAuto() || bSizeCoord.IsExtremumLength() ||
bSizeCoord.HasPercent(),
"unknown block-size unit");
LayoutFrameType fType = f->Type();
if (fType != LayoutFrameType::Viewport &&
fType != LayoutFrameType::Canvas &&
@ -4309,6 +4312,10 @@ static bool GetPercentBSize(const LengthPercentage& aStyle, nsIFrame* aFrame,
// so I'll choose not to. -LDB
return false;
}
NS_ASSERTION(
bSizeCoord.IsAuto() || bSizeCoord.IsExtremumLength(),
"Unexpected block-size unit for viewport or canvas or page-content");
// For the viewport, canvas, and page-content kids, the percentage
// basis is just the parent block-size.
h = f->BSize(wm);
@ -4324,6 +4331,10 @@ static bool GetPercentBSize(const LengthPercentage& aStyle, nsIFrame* aFrame,
if (GetAbsoluteCoord(maxBSizeCoord, maxh) ||
GetPercentBSize(maxBSizeCoord, f, aHorizontalAxis, maxh)) {
if (maxh < h) h = maxh;
} else {
NS_ASSERTION(maxBSizeCoord.IsNone() || maxBSizeCoord.IsExtremumLength() ||
maxBSizeCoord.HasPercent(),
"unknown max block-size unit");
}
const auto& minBSizeCoord = pos->MinBSize(wm);
@ -4331,9 +4342,11 @@ static bool GetPercentBSize(const LengthPercentage& aStyle, nsIFrame* aFrame,
nscoord minh;
if (GetAbsoluteCoord(minBSizeCoord, minh) ||
GetPercentBSize(minBSizeCoord, f, aHorizontalAxis, minh)) {
if (minh > h) {
h = minh;
}
if (minh > h) h = minh;
} else {
NS_ASSERTION(minBSizeCoord.IsAuto() || minBSizeCoord.IsExtremumLength() ||
minBSizeCoord.HasPercent(),
"unknown min block-size unit");
}
// If we're an abspos box, percentages in that case resolve against the
@ -4484,7 +4497,7 @@ static nscoord GetDefiniteSizeTakenByBoxSizing(
// (-moz-fit-content for width, and -moz-available) have no effect on
// intrinsic widths.
enum eWidthProperty { PROP_WIDTH, PROP_MAX_WIDTH, PROP_MIN_WIDTH };
static bool GetIntrinsicCoord(nsIFrame::ExtremumLength aStyle,
static bool GetIntrinsicCoord(StyleExtremumLength aStyle,
gfxContext* aRenderingContext, nsIFrame* aFrame,
Maybe<nscoord> aInlineSizeFromAspectRatio,
eWidthProperty aProperty, nscoord& aResult) {
@ -4492,19 +4505,19 @@ static bool GetIntrinsicCoord(nsIFrame::ExtremumLength aStyle,
aProperty == PROP_MIN_WIDTH,
"unexpected property");
if (aStyle == nsIFrame::ExtremumLength::MozAvailable) return false;
if (aStyle == nsIFrame::ExtremumLength::MozFitContent) {
if (aStyle == StyleExtremumLength::MozAvailable) return false;
if (aStyle == StyleExtremumLength::MozFitContent) {
if (aProperty == PROP_WIDTH) return false; // handle like 'width: auto'
if (aProperty == PROP_MAX_WIDTH)
// constrain large 'width' values down to max-content
aStyle = nsIFrame::ExtremumLength::MaxContent;
aStyle = StyleExtremumLength::MaxContent;
else
// constrain small 'width' or 'max-width' values up to min-content
aStyle = nsIFrame::ExtremumLength::MinContent;
aStyle = StyleExtremumLength::MinContent;
}
NS_ASSERTION(aStyle == nsIFrame::ExtremumLength::MinContent ||
aStyle == nsIFrame::ExtremumLength::MaxContent,
NS_ASSERTION(aStyle == StyleExtremumLength::MinContent ||
aStyle == StyleExtremumLength::MaxContent,
"should have reduced everything remaining to one of these");
// If aFrame is a container for font size inflation, then shrink
@ -4513,7 +4526,7 @@ static bool GetIntrinsicCoord(nsIFrame::ExtremumLength aStyle,
if (aInlineSizeFromAspectRatio) {
aResult = *aInlineSizeFromAspectRatio;
} else if (aStyle == nsIFrame::ExtremumLength::MaxContent) {
} else if (aStyle == StyleExtremumLength::MaxContent) {
aResult = aFrame->GetPrefISize(aRenderingContext);
} else {
aResult = aFrame->GetMinISize(aRenderingContext);
@ -4526,11 +4539,11 @@ static bool GetIntrinsicCoord(const SizeOrMaxSize& aStyle,
gfxContext* aRenderingContext, nsIFrame* aFrame,
Maybe<nscoord> aInlineSizeFromAspectRatio,
eWidthProperty aProperty, nscoord& aResult) {
auto length = nsIFrame::ToExtremumLength(aStyle);
if (!length) {
if (!aStyle.IsExtremumLength()) {
return false;
}
return GetIntrinsicCoord(*length, aRenderingContext, aFrame,
return GetIntrinsicCoord(aStyle.AsExtremumLength(), aRenderingContext, aFrame,
aInlineSizeFromAspectRatio, aProperty, aResult);
}
@ -4696,7 +4709,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
? styleMinISize
: (horizontalAxis ? stylePos->mWidth : stylePos->mHeight);
MOZ_ASSERT(!(aFlags & MIN_INTRINSIC_ISIZE) || styleISize.IsAuto() ||
nsIFrame::ToExtremumLength(styleISize),
styleISize.IsExtremumLength(),
"should only use MIN_INTRINSIC_ISIZE for intrinsic values");
StyleMaxSize styleMaxISize =
horizontalAxis ? stylePos->mMaxWidth : stylePos->mMaxHeight;
@ -4707,13 +4720,13 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
auto resetIfKeywords = [](StyleSize& aSize, StyleSize& aMinSize,
StyleMaxSize& aMaxSize) {
if (!aSize.IsLengthPercentage()) {
if (aSize.IsExtremumLength()) {
aSize = StyleSize::Auto();
}
if (!aMinSize.IsLengthPercentage()) {
if (aMinSize.IsExtremumLength()) {
aMinSize = StyleSize::Auto();
}
if (!aMaxSize.IsLengthPercentage()) {
if (aMaxSize.IsExtremumLength()) {
aMaxSize = StyleMaxSize::None();
}
};
@ -4797,7 +4810,9 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
// don't even bother getting the frame's intrinsic width, because in
// this case GetAbsoluteCoord(styleISize, w) will always succeed, so
// we'll never need the intrinsic dimensions.
if (styleISize.IsMaxContent() || styleISize.IsMinContent()) {
if (styleISize.IsExtremumLength() &&
(styleISize.AsExtremumLength() == StyleExtremumLength::MaxContent ||
styleISize.AsExtremumLength() == StyleExtremumLength::MinContent)) {
MOZ_ASSERT(isInlineAxis);
// -moz-fit-content and -moz-available enumerated widths compute intrinsic
// widths just like auto.
@ -4956,14 +4971,11 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
// resolve the {min|max}-content size by the aspect-ratio and the block size.
// If |aAxis| is not the inline axis of |aFrame|, {min|max}-content should
// behaves as auto, so we don't need this.
//
// FIXME(emilio): For -moz-available it seems we shouldn't need this.
//
// https://github.com/w3c/csswg-drafts/issues/5032
// FIXME: Bug 1670151: Use GetAspectRatio() to cover replaced elements (and
// then we can drop the check of eSupportsAspectRatio).
const AspectRatio ar = stylePos->mAspectRatio.ToLayoutRatio();
if (isInlineAxis && ar && nsIFrame::ToExtremumLength(styleISize) &&
if (isInlineAxis && styleISize.IsExtremumLength() && ar &&
aFrame->IsFrameOfType(nsIFrame::eSupportsAspectRatio) &&
!inlineSizeFromAspectRatio) {
// This 'B' in |styleBSize| means the block size of |aFrame|. We go into
@ -5059,10 +5071,10 @@ nscoord nsLayoutUtils::MinSizeContributionForAxis(
// -moz-available for intrinsic size in block axis. Therefore, we reset them
// if needed.
if (aAxis != ourInlineAxis) {
if (size.BehavesLikeInitialValueOnBlockAxis()) {
if (size.IsExtremumLength()) {
size = StyleSize::Auto();
}
if (maxSize.BehavesLikeInitialValueOnBlockAxis()) {
if (maxSize.IsExtremumLength()) {
maxSize = StyleMaxSize::None();
}
}
@ -5074,7 +5086,7 @@ nscoord nsLayoutUtils::MinSizeContributionForAxis(
size = aAxis == eAxisHorizontal ? stylePos->mWidth : stylePos->mHeight;
// This is same as above: keywords should behaves as property's initial
// values in block axis.
if (aAxis != ourInlineAxis && size.BehavesLikeInitialValueOnBlockAxis()) {
if (aAxis != ourInlineAxis && size.IsExtremumLength()) {
size = StyleSize::Auto();
}
@ -5095,7 +5107,7 @@ nscoord nsLayoutUtils::MinSizeContributionForAxis(
}
} else if (GetAbsoluteCoord(size, minSize)) {
fixedMinSize = &minSize;
} else if (size.IsLengthPercentage()) {
} else if (!size.IsExtremumLength()) {
MOZ_ASSERT(size.HasPercent());
minSize = 0;
fixedMinSize = &minSize;

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

@ -3373,19 +3373,27 @@ static inline bool IsNonAutoNonZeroBSize(const StyleSize& aCoord) {
// return false here, so we treat them like 'auto' pending a real
// implementation. (See bug 1126420.)
//
// FIXME (bug 567039, bug 527285) This isn't correct for the 'fill' value,
// which should more likely (but not necessarily, depending on the available
// space) be returning true.
if (aCoord.BehavesLikeInitialValueOnBlockAxis()) {
// FIXME (bug 567039, bug 527285)
// This isn't correct for the 'fill' value, which should more
// likely (but not necessarily, depending on the available space)
// be returning true.
if (aCoord.IsAuto() || aCoord.IsExtremumLength()) {
return false;
}
MOZ_ASSERT(aCoord.IsLengthPercentage());
if (aCoord.IsLengthPercentage()) {
// If we evaluate the length/percent/calc at a percentage basis of
// both nscoord_MAX and 0, and it's zero both ways, then it's a zero
// length, percent, or combination thereof. Test > 0 so we clamp
// negative calc() results to 0.
return aCoord.AsLengthPercentage().Resolve(nscoord_MAX) > 0 ||
aCoord.AsLengthPercentage().Resolve(0) > 0;
}
MOZ_ASSERT(false, "unexpected unit for height or min-height");
return true;
}
static bool BehavesLikeInitialValueOnBlockAxis(const StyleSize& aCoord) {
return aCoord.IsAuto() || aCoord.IsExtremumLength();
}
/* virtual */
@ -3409,7 +3417,7 @@ bool nsBlockFrame::IsSelfEmpty() {
// FIXME: Handle the case that both inline and block sizes are auto.
// https://github.com/w3c/csswg-drafts/issues/5060.
// Note: block-size could be zero or auto/intrinsic keywords here.
if (position->BSize(wm).BehavesLikeInitialValueOnBlockAxis() &&
if (BehavesLikeInitialValueOnBlockAxis(position->BSize(wm)) &&
position->mAspectRatio.HasFiniteRatio()) {
return false;
}

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

@ -169,7 +169,7 @@ static nscoord AddChecked(nscoord aFirst, nscoord aSecond) {
// Bug 567039: We treat -moz-fit-content and -moz-available as property's
// initial value for now.
static inline bool IsAutoOrEnumOnBSize(const StyleSize& aSize, bool aIsInline) {
return aSize.IsAuto() || (!aIsInline && !aSize.IsLengthPercentage());
return aSize.IsAuto() || (!aIsInline && aSize.IsExtremumLength());
}
// Helper-macros to let us pick one of two expressions to evaluate
@ -1346,7 +1346,8 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild(
// value 'max-content'.
styleFlexBaseSize.emplace(StyleSize::Auto());
} else {
styleFlexBaseSize.emplace(StyleSize::MaxContent());
styleFlexBaseSize.emplace(
StyleSize::ExtremumLength(StyleExtremumLength::MaxContent));
}
} else if (flexBasis.IsSize() && !flexBasis.IsAuto()) {
// For all other non-'auto' flex-basis values, we just swap in the
@ -4472,14 +4473,11 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
// "block-end" set and have block-size:auto. (There are actually other cases,
// too -- e.g. if our parent is itself a block-dir flex container and we're
// flexible -- but we'll let our ancestors handle those sorts of cases.)
//
// TODO(emilio): the !bsize.IsLengthPercentage() preserves behavior, but it's
// too conservative. min/max-content don't really depend on the container.
WritingMode wm = aReflowInput.GetWritingMode();
const nsStylePosition* stylePos = StylePosition();
const auto& bsize = stylePos->BSize(wm);
if (bsize.HasPercent() || (StyleDisplay()->IsAbsolutelyPositionedStyle() &&
(bsize.IsAuto() || !bsize.IsLengthPercentage()) &&
(bsize.IsAuto() || bsize.IsExtremumLength()) &&
!stylePos->mOffset.GetBStart(wm).IsAuto() &&
!stylePos->mOffset.GetBEnd(wm).IsAuto())) {
AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);

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

@ -699,7 +699,7 @@ struct nsGridContainerFrame::GridItemInfo {
bool isAuto = size.IsAuto() ||
(isInlineAxis ==
aContainerWM.IsOrthogonalTo(mFrame->GetWritingMode()) &&
size.BehavesLikeInitialValueOnBlockAxis());
size.IsExtremumLength());
// NOTE: if we have a definite size then our automatic minimum size
// can't affect our size. Excluding these simplifies applying
// the clamping in the right cases later.
@ -715,7 +715,7 @@ struct nsGridContainerFrame::GridItemInfo {
isAuto = minSize.IsAuto() ||
(isInlineAxis ==
aContainerWM.IsOrthogonalTo(mFrame->GetWritingMode()) &&
minSize.BehavesLikeInitialValueOnBlockAxis());
minSize.IsExtremumLength());
return isAuto &&
mFrame->StyleDisplay()->mOverflowX == StyleOverflow::Visible;
}
@ -5366,7 +5366,7 @@ static nscoord MinSize(const GridItemInfo& aGridItem,
// FIXME: Bug 567039: moz-fit-content and -moz-available are not supported
// for block size dimension on sizing properties (e.g. height), so we
// treat it as `auto`.
if (axis != ourInlineAxis && sizeStyle.BehavesLikeInitialValueOnBlockAxis()) {
if (axis != ourInlineAxis && sizeStyle.IsExtremumLength()) {
sizeStyle = StyleSize::Auto();
}
@ -5405,9 +5405,8 @@ static nscoord MinSize(const GridItemInfo& aGridItem,
// treat it as `auto`.
const bool inInlineAxis = axis == ourInlineAxis;
const bool isAuto =
style.IsAuto() ||
(!inInlineAxis && style.BehavesLikeInitialValueOnBlockAxis());
if ((inInlineAxis && nsIFrame::ToExtremumLength(style)) ||
style.IsAuto() || (!inInlineAxis && style.IsExtremumLength());
if ((inInlineAxis && style.IsExtremumLength()) ||
(isAuto && child->StyleDisplay()->mOverflowX == StyleOverflow::Visible)) {
// Now calculate the "content size" part and return whichever is smaller.
MOZ_ASSERT(isAuto || sz == NS_UNCONSTRAINEDSIZE);

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

@ -2323,9 +2323,12 @@ already_AddRefed<ComputedStyle> nsIFrame::ComputeSelectionStyle(
template <typename SizeOrMaxSize>
static inline bool IsIntrinsicKeyword(const SizeOrMaxSize& aSize) {
// All keywords other than auto/none/-moz-available depend on intrinsic sizes.
return aSize.IsMaxContent() || aSize.IsMinContent() ||
aSize.IsMozFitContent();
if (!aSize.IsExtremumLength()) {
return false;
}
// All of the keywords except for '-moz-available' depend on intrinsic sizes.
return aSize.AsExtremumLength() != StyleExtremumLength::MozAvailable;
}
bool nsIFrame::CanBeDynamicReflowRoot() const {
@ -6430,7 +6433,7 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
gfxContext* aRenderingContext, const WritingMode aWM,
const LogicalSize& aContainingBlockSize,
const LogicalSize& aContentEdgeToBoxSizing, nscoord aBoxSizingToMarginEdge,
ExtremumLength aSize, ComputeSizeFlags aFlags) {
StyleExtremumLength aSize, ComputeSizeFlags aFlags) {
// If 'this' is a container for font size inflation, then shrink
// wrapping inside of it should not apply font size inflation.
AutoMaybeDisableFontInflation an(this);
@ -6438,20 +6441,20 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
// min-content and max-content size by the aspect-ratio and the block size.
// https://github.com/w3c/csswg-drafts/issues/5032
Maybe<nscoord> intrinsicSizeFromAspectRatio =
aSize == ExtremumLength::MozAvailable
aSize == StyleExtremumLength::MozAvailable
? Nothing()
: ComputeInlineSizeFromAspectRatio(aWM, aContainingBlockSize,
aContentEdgeToBoxSizing, aFlags);
nscoord result;
switch (aSize) {
case ExtremumLength::MaxContent:
case StyleExtremumLength::MaxContent:
result = intrinsicSizeFromAspectRatio ? *intrinsicSizeFromAspectRatio
: GetPrefISize(aRenderingContext);
NS_ASSERTION(result >= 0, "inline-size less than zero");
return {result, intrinsicSizeFromAspectRatio
? AspectRatioUsage::ToComputeISize
: AspectRatioUsage::None};
case ExtremumLength::MinContent:
case StyleExtremumLength::MinContent:
result = intrinsicSizeFromAspectRatio ? *intrinsicSizeFromAspectRatio
: GetMinISize(aRenderingContext);
NS_ASSERTION(result >= 0, "inline-size less than zero");
@ -6465,7 +6468,7 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
return {result, intrinsicSizeFromAspectRatio
? AspectRatioUsage::ToComputeISize
: AspectRatioUsage::None};
case ExtremumLength::MozFitContent: {
case StyleExtremumLength::MozFitContent: {
nscoord pref = NS_UNCONSTRAINEDSIZE;
nscoord min = 0;
if (intrinsicSizeFromAspectRatio) {
@ -6487,7 +6490,7 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
NS_ASSERTION(result >= 0, "inline-size less than zero");
return {result};
}
case ExtremumLength::MozAvailable:
case StyleExtremumLength::MozAvailable:
return {aContainingBlockSize.ISize(aWM) -
(aBoxSizingToMarginEdge + aContentEdgeToBoxSizing.ISize(aWM))};
}

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

@ -639,6 +639,7 @@ class nsIFrame : public nsQueryFrame {
using ReflowOutput = mozilla::ReflowOutput;
using Visibility = mozilla::Visibility;
using LengthPercentage = mozilla::LengthPercentage;
using StyleExtremumLength = mozilla::StyleExtremumLength;
typedef mozilla::ComputedStyle ComputedStyle;
typedef mozilla::FrameProperties FrameProperties;
@ -4766,29 +4767,6 @@ class nsIFrame : public nsQueryFrame {
return false;
}
enum class ExtremumLength {
MinContent,
MaxContent,
MozAvailable,
MozFitContent,
};
template <typename SizeOrMaxSize>
static Maybe<ExtremumLength> ToExtremumLength(const SizeOrMaxSize& aSize) {
switch (aSize.tag) {
case SizeOrMaxSize::Tag::MinContent:
return mozilla::Some(ExtremumLength::MinContent);
case SizeOrMaxSize::Tag::MaxContent:
return mozilla::Some(ExtremumLength::MaxContent);
case SizeOrMaxSize::Tag::MozAvailable:
return mozilla::Some(ExtremumLength::MozAvailable);
case SizeOrMaxSize::Tag::MozFitContent:
return mozilla::Some(ExtremumLength::MozFitContent);
default:
return mozilla::Nothing();
}
}
/**
* Helper function - computes the content-box inline size for aSize, which is
* a more complex version to resolve a StyleExtremumLength.
@ -4801,7 +4779,7 @@ class nsIFrame : public nsQueryFrame {
gfxContext* aRenderingContext, const mozilla::WritingMode aWM,
const mozilla::LogicalSize& aContainingBlockSize,
const mozilla::LogicalSize& aContentEdgeToBoxSizing,
nscoord aBoxSizingToMarginEdge, ExtremumLength aSize,
nscoord aBoxSizingToMarginEdge, StyleExtremumLength aSize,
mozilla::ComputeSizeFlags aFlags);
/**
@ -4820,17 +4798,16 @@ class nsIFrame : public nsQueryFrame {
const mozilla::LogicalSize& aContentEdgeToBoxSizing,
nscoord aBoxSizingToMarginEdge, const SizeOrMaxSize& aSize,
mozilla::ComputeSizeFlags aFlags = {}) {
MOZ_ASSERT(aSize.IsExtremumLength() || aSize.IsLengthPercentage(),
"This doesn't handle auto / none");
if (aSize.IsLengthPercentage()) {
return {ComputeISizeValue(aWM, aContainingBlockSize,
aContentEdgeToBoxSizing,
aSize.AsLengthPercentage())};
}
auto length = ToExtremumLength(aSize);
MOZ_ASSERT(length, "This doesn't handle none / auto");
return ComputeISizeValue(aRenderingContext, aWM, aContainingBlockSize,
aContentEdgeToBoxSizing, aBoxSizingToMarginEdge,
length.valueOr(ExtremumLength::MinContent),
aFlags);
aSize.AsExtremumLength(), aFlags);
}
DisplayItemDataArray* DisplayItemData() const {

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

@ -120,16 +120,16 @@ static bool HaveSpecifiedSize(const nsStylePosition* aStylePosition) {
template <typename SizeOrMaxSize>
static bool DependsOnIntrinsicSize(const SizeOrMaxSize& aMinOrMaxSize) {
auto length = nsIFrame::ToExtremumLength(aMinOrMaxSize);
if (!length) {
if (!aMinOrMaxSize.IsExtremumLength()) {
return false;
}
switch (*length) {
case nsIFrame::ExtremumLength::MinContent:
case nsIFrame::ExtremumLength::MaxContent:
case nsIFrame::ExtremumLength::MozFitContent:
auto keyword = aMinOrMaxSize.AsExtremumLength();
switch (keyword) {
case StyleExtremumLength::MinContent:
case StyleExtremumLength::MaxContent:
case StyleExtremumLength::MozFitContent:
return true;
case nsIFrame::ExtremumLength::MozAvailable:
case StyleExtremumLength::MozAvailable:
return false;
}
MOZ_ASSERT_UNREACHABLE("Unknown sizing keyword?");

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

@ -424,6 +424,7 @@ cbindgen-types = [
{ gecko = "StyleDisplay", servo = "crate::values::specified::Display" },
{ gecko = "StyleDisplayMode", servo = "crate::gecko::media_features::DisplayMode" },
{ gecko = "StylePrefersColorScheme", servo = "crate::gecko::media_features::PrefersColorScheme" },
{ gecko = "StyleExtremumLength", servo = "crate::values::computed::length::ExtremumLength" },
{ gecko = "StyleFillRule", servo = "crate::values::generics::basic_shape::FillRule" },
{ gecko = "StyleFontDisplay", servo = "crate::font_face::FontDisplay" },
{ gecko = "StyleFontFaceSourceListComponent", servo = "crate::font_face::FontFaceSourceListComponent" },

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

@ -810,12 +810,12 @@ inline bool StyleFlexBasis::IsAuto() const {
template <>
inline bool StyleSize::BehavesLikeInitialValueOnBlockAxis() const {
return IsAuto() || !IsLengthPercentage();
return IsAuto() || IsExtremumLength();
}
template <>
inline bool StyleMaxSize::BehavesLikeInitialValueOnBlockAxis() const {
return IsNone() || !IsLengthPercentage();
return IsNone() || IsExtremumLength();
}
template <>

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

@ -2234,16 +2234,16 @@ already_AddRefed<CSSValue> nsComputedDOMStyle::GetMarginWidthFor(
return val.forget();
}
static void SetValueToExtremumLength(nsROCSSPrimitiveValue* aValue,
nsIFrame::ExtremumLength aSize) {
void nsComputedDOMStyle::SetValueToExtremumLength(nsROCSSPrimitiveValue* aValue,
StyleExtremumLength aSize) {
switch (aSize) {
case nsIFrame::ExtremumLength::MaxContent:
case StyleExtremumLength::MaxContent:
return aValue->SetString("max-content");
case nsIFrame::ExtremumLength::MinContent:
case StyleExtremumLength::MinContent:
return aValue->SetString("min-content");
case nsIFrame::ExtremumLength::MozAvailable:
case StyleExtremumLength::MozAvailable:
return aValue->SetString("-moz-available");
case nsIFrame::ExtremumLength::MozFitContent:
case StyleExtremumLength::MozFitContent:
return aValue->SetString("-moz-fit-content");
}
MOZ_ASSERT_UNREACHABLE("Unknown extremum length?");
@ -2254,8 +2254,8 @@ void nsComputedDOMStyle::SetValueToSize(nsROCSSPrimitiveValue* aValue,
if (aSize.IsAuto()) {
return aValue->SetString("auto");
}
if (auto length = nsIFrame::ToExtremumLength(aSize)) {
return SetValueToExtremumLength(aValue, *length);
if (aSize.IsExtremumLength()) {
return SetValueToExtremumLength(aValue, aSize.AsExtremumLength());
}
MOZ_ASSERT(aSize.IsLengthPercentage());
SetValueToLengthPercentage(aValue, aSize.AsLengthPercentage(), true);
@ -2266,8 +2266,8 @@ void nsComputedDOMStyle::SetValueToMaxSize(nsROCSSPrimitiveValue* aValue,
if (aSize.IsNone()) {
return aValue->SetString("none");
}
if (auto length = nsIFrame::ToExtremumLength(aSize)) {
return SetValueToExtremumLength(aValue, *length);
if (aSize.IsExtremumLength()) {
return SetValueToExtremumLength(aValue, aSize.AsExtremumLength());
}
MOZ_ASSERT(aSize.IsLengthPercentage());
SetValueToLengthPercentage(aValue, aSize.AsLengthPercentage(), true);

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

@ -60,6 +60,7 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
using Document = mozilla::dom::Document;
using LengthPercentage = mozilla::LengthPercentage;
using LengthPercentageOrAuto = mozilla::LengthPercentageOrAuto;
using StyleExtremumLength = mozilla::StyleExtremumLength;
using ComputedStyle = mozilla::ComputedStyle;
public:
@ -294,6 +295,9 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
void SetValueToMaxSize(nsROCSSPrimitiveValue* aValue,
const mozilla::StyleMaxSize&);
void SetValueToExtremumLength(nsROCSSPrimitiveValue* aValue,
StyleExtremumLength);
bool GetCBContentWidth(nscoord& aWidth);
bool GetCBContentHeight(nscoord& aHeight);
bool GetCBPaddingRectWidth(nscoord& aWidth);

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

@ -831,7 +831,14 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition {
if (aCoord.IsLengthPercentage()) {
return aCoord.AsLengthPercentage().HasPercent();
}
return aCoord.IsMozFitContent() || aCoord.IsMozAvailable();
if (!aCoord.IsExtremumLength()) {
return false;
}
auto keyword = aCoord.AsExtremumLength();
return keyword == mozilla::StyleExtremumLength::MozFitContent ||
keyword == mozilla::StyleExtremumLength::MozAvailable;
}
template <typename SizeOrMaxSize>

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

@ -140,36 +140,38 @@ static CellISizeInfo GetISizeInfo(gfxContext* aRenderingContext,
prefCoord = std::max(c, minCoord);
} else if (iSize.ConvertsToPercentage()) {
prefPercent = iSize.ToPercentage();
} else if (aIsCell) {
switch (iSize.tag) {
case StyleSize::Tag::MaxContent:
} else if (iSize.IsExtremumLength() && aIsCell) {
switch (iSize.AsExtremumLength()) {
case StyleExtremumLength::MaxContent:
// 'inline-size' only affects pref isize, not min
// isize, so don't change anything
break;
case StyleSize::Tag::MinContent:
case StyleExtremumLength::MinContent:
prefCoord = minCoord;
break;
case StyleSize::Tag::MozAvailable:
case StyleSize::Tag::MozFitContent:
case StyleSize::Tag::Auto:
case StyleSize::Tag::LengthPercentage:
case StyleExtremumLength::MozFitContent:
case StyleExtremumLength::MozAvailable:
break;
default:
MOZ_ASSERT_UNREACHABLE("unexpected enumerated value");
}
}
StyleMaxSize maxISize = stylePos->MaxISize(aWM);
if (nsIFrame::ToExtremumLength(maxISize)) {
if (!aIsCell || maxISize.IsMozAvailable()) {
if (maxISize.IsExtremumLength()) {
if (!aIsCell ||
maxISize.AsExtremumLength() == StyleExtremumLength::MozAvailable) {
maxISize = StyleMaxSize::None();
} else if (maxISize.IsMozFitContent()) {
} else if (maxISize.AsExtremumLength() ==
StyleExtremumLength::MozFitContent) {
// for 'max-inline-size', '-moz-fit-content' is like 'max-content'
maxISize = StyleMaxSize::MaxContent();
maxISize = StyleMaxSize::ExtremumLength(StyleExtremumLength::MaxContent);
}
}
// XXX To really implement 'max-inline-size' well, we'd need to store
// it separately on the columns.
const LogicalSize zeroSize(aWM);
if (maxISize.ConvertsToLength() || !maxISize.IsNone()) {
if (maxISize.ConvertsToLength() || maxISize.IsExtremumLength()) {
nscoord c = aFrame
->ComputeISizeValue(aRenderingContext, aWM, zeroSize,
zeroSize, 0, maxISize)
@ -184,16 +186,17 @@ static CellISizeInfo GetISizeInfo(gfxContext* aRenderingContext,
}
StyleSize minISize = stylePos->MinISize(aWM);
if (nsIFrame::ToExtremumLength(maxISize)) {
if (!aIsCell || minISize.IsMozAvailable()) {
if (minISize.IsExtremumLength()) {
if (!aIsCell ||
minISize.AsExtremumLength() == StyleExtremumLength::MozAvailable) {
minISize = StyleSize::LengthPercentage(LengthPercentage::Zero());
} else if (minISize.IsMozFitContent()) {
} else if (minISize.AsExtremumLength() ==
StyleExtremumLength::MozFitContent) {
// for 'min-inline-size', '-moz-fit-content' is like 'min-content'
minISize = StyleSize::MinContent();
minISize = StyleSize::ExtremumLength(StyleExtremumLength::MinContent);
}
}
if (minISize.ConvertsToLength() || !minISize.IsAuto()) {
if (minISize.ConvertsToLength() || minISize.IsExtremumLength()) {
nscoord c = aFrame
->ComputeISizeValue(aRenderingContext, aWM, zeroSize,
zeroSize, 0, minISize)

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

@ -73,6 +73,10 @@ nscoord FixedTableLayoutStrategy::GetMinISize(gfxContext* aRenderingContext) {
} else if (styleISize->ConvertsToPercentage()) {
// do nothing
} else {
NS_ASSERTION(styleISize->IsAuto() || styleISize->IsExtremumLength() ||
styleISize->HasLengthAndPercentage(),
"bad inline size");
// The 'table-layout: fixed' algorithm considers only cells in the
// first row.
bool originates;
@ -81,8 +85,12 @@ nscoord FixedTableLayoutStrategy::GetMinISize(gfxContext* aRenderingContext) {
cellMap->GetCellInfoAt(0, col, &originates, &colSpan);
if (cellFrame) {
styleISize = &cellFrame->StylePosition()->ISize(wm);
if (styleISize->ConvertsToLength() || styleISize->IsMinContent() ||
styleISize->IsMaxContent()) {
if (styleISize->ConvertsToLength() ||
(styleISize->IsExtremumLength() &&
(styleISize->AsExtremumLength() ==
StyleExtremumLength::MaxContent ||
styleISize->AsExtremumLength() ==
StyleExtremumLength::MinContent))) {
nscoord cellISize = nsLayoutUtils::IntrinsicForContainer(
aRenderingContext, cellFrame, IntrinsicISizeType::MinISize);
if (colSpan > 1) {
@ -208,6 +216,11 @@ void FixedTableLayoutStrategy::ComputeColumnISizes(
colFrame->AddPrefPercent(pct);
pctTotal += pct;
} else {
NS_ASSERTION(styleISize->IsAuto() || styleISize->IsExtremumLength() ||
(styleISize->IsLengthPercentage() &&
!styleISize->ConvertsToLength()),
"bad inline size");
// The 'table-layout: fixed' algorithm considers only cells in the
// first row.
bool originates;
@ -217,8 +230,12 @@ void FixedTableLayoutStrategy::ComputeColumnISizes(
if (cellFrame) {
const nsStylePosition* cellStylePos = cellFrame->StylePosition();
styleISize = &cellStylePos->ISize(wm);
if (styleISize->ConvertsToLength() || styleISize->IsMaxContent() ||
styleISize->IsMinContent()) {
if (styleISize->ConvertsToLength() ||
(styleISize->IsExtremumLength() &&
(styleISize->AsExtremumLength() ==
StyleExtremumLength::MaxContent ||
styleISize->AsExtremumLength() ==
StyleExtremumLength::MinContent))) {
// XXX This should use real percentage padding
// Note that the difference between MinISize and PrefISize
// shouldn't matter for any of these values of styleISize; use

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

@ -3749,7 +3749,9 @@ bool nsTableFrame::IsAutoLayout() {
// auto-layout (at least as long as
// FixedTableLayoutStrategy::GetPrefISize returns nscoord_MAX)
const auto& iSize = StylePosition()->ISize(GetWritingMode());
return iSize.IsAuto() || iSize.IsMaxContent();
return iSize.IsAuto() ||
(iSize.IsExtremumLength() &&
iSize.AsExtremumLength() == StyleExtremumLength::MaxContent);
}
#ifdef DEBUG_FRAME_DUMP

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

@ -185,10 +185,7 @@ impl Size {
GenericSize::Auto => false,
GenericSize::LengthPercentage(ref lp) => lp.is_definitely_zero(),
#[cfg(feature = "gecko")]
GenericSize::MinContent |
GenericSize::MaxContent |
GenericSize::MozFitContent |
GenericSize::MozAvailable => false
GenericSize::ExtremumLength(..) => false,
}
}
}
@ -498,6 +495,37 @@ pub type NonNegativeLengthPercentageOrNormal =
/// Either a non-negative `<length>` or a `<number>`.
pub type NonNegativeLengthOrNumber = GenericLengthOrNumber<NonNegativeLength, NonNegativeNumber>;
/// A type for possible values for min- and max- flavors of width, height,
/// block-size, and inline-size.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(
Clone,
Copy,
Debug,
Eq,
FromPrimitive,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(u8)]
pub enum ExtremumLength {
#[parse(aliases = "-moz-max-content")]
MaxContent,
#[parse(aliases = "-moz-min-content")]
MinContent,
MozFitContent,
MozAvailable,
}
/// A computed value for `min-width`, `min-height`, `width` or `height` property.
pub type Size = GenericSize<NonNegativeLengthPercentage>;

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

@ -61,7 +61,7 @@ pub use self::font::{FontVariantAlternates, FontWeight};
pub use self::font::{FontVariantEastAsian, FontVariationSettings};
pub use self::font::{MathDepth, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::image::{Gradient, Image, LineDirection, MozImageRect};
pub use self::length::{CSSPixelLength, NonNegativeLength};
pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength};
pub use self::length::{Length, LengthOrNumber, LengthPercentage, NonNegativeLengthOrNumber};
pub use self::length::{LengthOrAuto, LengthPercentageOrAuto, MaxSize, Size};
pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto};

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

@ -6,6 +6,7 @@
use crate::parser::{Parse, ParserContext};
#[cfg(feature = "gecko")]
use crate::values::computed::ExtremumLength;
use crate::Zero;
use cssparser::Parser;
use style_traits::ParseError;
@ -150,14 +151,9 @@ impl<LengthPercentage: Parse> Parse for LengthPercentageOrAuto<LengthPercentage>
pub enum GenericSize<LengthPercent> {
LengthPercentage(LengthPercent),
Auto,
#[cfg(feature = "gecko")]
#[animation(error)]
MaxContent,
#[animation(error)]
MinContent,
#[animation(error)]
MozFitContent,
#[animation(error)]
MozAvailable,
ExtremumLength(ExtremumLength),
}
pub use self::GenericSize as Size;
@ -198,16 +194,9 @@ impl<LengthPercentage> Size<LengthPercentage> {
pub enum GenericMaxSize<LengthPercent> {
LengthPercentage(LengthPercent),
None,
#[cfg(feature = "gecko")]
#[animation(error)]
#[parse(aliases = "-moz-max-content")]
MaxContent,
#[animation(error)]
#[parse(aliases = "-moz-min-content")]
MinContent,
#[animation(error)]
MozFitContent,
#[animation(error)]
MozAvailable,
ExtremumLength(ExtremumLength),
}
pub use self::GenericMaxSize as MaxSize;

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

@ -1217,27 +1217,6 @@ impl Parse for Size {
}
}
macro_rules! parse_size_non_length {
($size:ident, $input:expr, $auto_or_none:expr => $auto_or_none_ident:ident) => {{
let size = $input.try_parse(|input| {
Ok(try_match_ident_ignore_ascii_case! { input,
#[cfg(feature = "gecko")]
"min-content" | "-moz-min-content" => $size::MinContent,
#[cfg(feature = "gecko")]
"max-content" | "-moz-max-content" => $size::MaxContent,
#[cfg(feature = "gecko")]
"-moz-fit-content" => $size::MozFitContent,
#[cfg(feature = "gecko")]
"-moz-available" => $size::MozAvailable,
$auto_or_none => $size::$auto_or_none_ident,
})
});
if size.is_ok() {
return size;
}
}};
}
impl Size {
/// Parses, with quirks.
pub fn parse_quirky<'i, 't>(
@ -1245,7 +1224,16 @@ impl Size {
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
parse_size_non_length!(Size, input, "auto" => Auto);
#[cfg(feature = "gecko")]
{
if let Ok(l) = input.try_parse(computed::ExtremumLength::parse) {
return Ok(GenericSize::ExtremumLength(l));
}
}
if input.try_parse(|i| i.expect_ident_matching("auto")).is_ok() {
return Ok(GenericSize::Auto);
}
let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?;
Ok(GenericSize::LengthPercentage(length))
@ -1277,7 +1265,16 @@ impl MaxSize {
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
parse_size_non_length!(MaxSize, input, "none" => None);
#[cfg(feature = "gecko")]
{
if let Ok(l) = input.try_parse(computed::ExtremumLength::parse) {
return Ok(GenericMaxSize::ExtremumLength(l));
}
}
if input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
return Ok(GenericMaxSize::None);
}
let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?;
Ok(GenericMaxSize::LengthPercentage(length))

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

@ -91,6 +91,7 @@ include = [
"DisplayMode",
"PrefersColorScheme",
"PrefersContrast",
"ExtremumLength",
"FillRule",
"FontDisplay",
"FontFaceSourceListComponent",