зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1695390 - Move extremum lengths to the individual Size / MaxSize types. r=boris
This will prevent growing them when introducing fit-content(<length>). This can _almost_ be derived, if it wasn't because of the quirky stuff. I think the macro is probably good enough for now but let me know if you disagree. Differential Revision: https://phabricator.services.mozilla.com/D106713
This commit is contained in:
Родитель
2b35c2ae19
Коммит
c17b1c2e53
|
@ -1967,8 +1967,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"content",
|
||||
"inherit",
|
||||
|
@ -1988,8 +1986,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"content",
|
||||
"inherit",
|
||||
|
@ -3803,8 +3799,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"inherit",
|
||||
"initial",
|
||||
|
@ -6060,8 +6054,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"content",
|
||||
"inherit",
|
||||
|
@ -6081,8 +6073,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"content",
|
||||
"inherit",
|
||||
|
@ -7003,8 +6993,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"inherit",
|
||||
"initial",
|
||||
|
@ -7090,8 +7078,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"inherit",
|
||||
"initial",
|
||||
|
@ -8252,8 +8238,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"inherit",
|
||||
"initial",
|
||||
|
@ -8272,8 +8256,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"inherit",
|
||||
"initial",
|
||||
|
@ -8292,8 +8274,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"inherit",
|
||||
"initial",
|
||||
|
@ -8312,8 +8292,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"inherit",
|
||||
"initial",
|
||||
|
@ -10823,8 +10801,6 @@ exports.CSS_PROPERTIES = {
|
|||
"values": [
|
||||
"-moz-available",
|
||||
"-moz-fit-content",
|
||||
"-moz-max-content",
|
||||
"-moz-min-content",
|
||||
"auto",
|
||||
"inherit",
|
||||
"initial",
|
||||
|
|
|
@ -4298,9 +4298,6 @@ 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 &&
|
||||
|
@ -4312,10 +4309,6 @@ 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);
|
||||
|
@ -4331,10 +4324,6 @@ 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);
|
||||
|
@ -4342,11 +4331,9 @@ static bool GetPercentBSize(const LengthPercentage& aStyle, nsIFrame* aFrame,
|
|||
nscoord minh;
|
||||
if (GetAbsoluteCoord(minBSizeCoord, minh) ||
|
||||
GetPercentBSize(minBSizeCoord, f, aHorizontalAxis, minh)) {
|
||||
if (minh > h) h = minh;
|
||||
} else {
|
||||
NS_ASSERTION(minBSizeCoord.IsAuto() || minBSizeCoord.IsExtremumLength() ||
|
||||
minBSizeCoord.HasPercent(),
|
||||
"unknown min block-size unit");
|
||||
if (minh > h) {
|
||||
h = minh;
|
||||
}
|
||||
}
|
||||
|
||||
// If we're an abspos box, percentages in that case resolve against the
|
||||
|
@ -4497,7 +4484,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(StyleExtremumLength aStyle,
|
||||
static bool GetIntrinsicCoord(nsIFrame::ExtremumLength aStyle,
|
||||
gfxContext* aRenderingContext, nsIFrame* aFrame,
|
||||
Maybe<nscoord> aInlineSizeFromAspectRatio,
|
||||
eWidthProperty aProperty, nscoord& aResult) {
|
||||
|
@ -4505,19 +4492,19 @@ static bool GetIntrinsicCoord(StyleExtremumLength aStyle,
|
|||
aProperty == PROP_MIN_WIDTH,
|
||||
"unexpected property");
|
||||
|
||||
if (aStyle == StyleExtremumLength::MozAvailable) return false;
|
||||
if (aStyle == StyleExtremumLength::MozFitContent) {
|
||||
if (aStyle == nsIFrame::ExtremumLength::MozAvailable) return false;
|
||||
if (aStyle == nsIFrame::ExtremumLength::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 = StyleExtremumLength::MaxContent;
|
||||
aStyle = nsIFrame::ExtremumLength::MaxContent;
|
||||
else
|
||||
// constrain small 'width' or 'max-width' values up to min-content
|
||||
aStyle = StyleExtremumLength::MinContent;
|
||||
aStyle = nsIFrame::ExtremumLength::MinContent;
|
||||
}
|
||||
|
||||
NS_ASSERTION(aStyle == StyleExtremumLength::MinContent ||
|
||||
aStyle == StyleExtremumLength::MaxContent,
|
||||
NS_ASSERTION(aStyle == nsIFrame::ExtremumLength::MinContent ||
|
||||
aStyle == nsIFrame::ExtremumLength::MaxContent,
|
||||
"should have reduced everything remaining to one of these");
|
||||
|
||||
// If aFrame is a container for font size inflation, then shrink
|
||||
|
@ -4526,7 +4513,7 @@ static bool GetIntrinsicCoord(StyleExtremumLength aStyle,
|
|||
|
||||
if (aInlineSizeFromAspectRatio) {
|
||||
aResult = *aInlineSizeFromAspectRatio;
|
||||
} else if (aStyle == StyleExtremumLength::MaxContent) {
|
||||
} else if (aStyle == nsIFrame::ExtremumLength::MaxContent) {
|
||||
aResult = aFrame->GetPrefISize(aRenderingContext);
|
||||
} else {
|
||||
aResult = aFrame->GetMinISize(aRenderingContext);
|
||||
|
@ -4539,11 +4526,11 @@ static bool GetIntrinsicCoord(const SizeOrMaxSize& aStyle,
|
|||
gfxContext* aRenderingContext, nsIFrame* aFrame,
|
||||
Maybe<nscoord> aInlineSizeFromAspectRatio,
|
||||
eWidthProperty aProperty, nscoord& aResult) {
|
||||
if (!aStyle.IsExtremumLength()) {
|
||||
auto length = nsIFrame::ToExtremumLength(aStyle);
|
||||
if (!length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return GetIntrinsicCoord(aStyle.AsExtremumLength(), aRenderingContext, aFrame,
|
||||
return GetIntrinsicCoord(*length, aRenderingContext, aFrame,
|
||||
aInlineSizeFromAspectRatio, aProperty, aResult);
|
||||
}
|
||||
|
||||
|
@ -4709,7 +4696,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
|||
? styleMinISize
|
||||
: (horizontalAxis ? stylePos->mWidth : stylePos->mHeight);
|
||||
MOZ_ASSERT(!(aFlags & MIN_INTRINSIC_ISIZE) || styleISize.IsAuto() ||
|
||||
styleISize.IsExtremumLength(),
|
||||
nsIFrame::ToExtremumLength(styleISize),
|
||||
"should only use MIN_INTRINSIC_ISIZE for intrinsic values");
|
||||
StyleMaxSize styleMaxISize =
|
||||
horizontalAxis ? stylePos->mMaxWidth : stylePos->mMaxHeight;
|
||||
|
@ -4720,13 +4707,13 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
|||
|
||||
auto resetIfKeywords = [](StyleSize& aSize, StyleSize& aMinSize,
|
||||
StyleMaxSize& aMaxSize) {
|
||||
if (aSize.IsExtremumLength()) {
|
||||
if (!aSize.IsLengthPercentage()) {
|
||||
aSize = StyleSize::Auto();
|
||||
}
|
||||
if (aMinSize.IsExtremumLength()) {
|
||||
if (!aMinSize.IsLengthPercentage()) {
|
||||
aMinSize = StyleSize::Auto();
|
||||
}
|
||||
if (aMaxSize.IsExtremumLength()) {
|
||||
if (!aMaxSize.IsLengthPercentage()) {
|
||||
aMaxSize = StyleMaxSize::None();
|
||||
}
|
||||
};
|
||||
|
@ -4810,9 +4797,7 @@ 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.IsExtremumLength() &&
|
||||
(styleISize.AsExtremumLength() == StyleExtremumLength::MaxContent ||
|
||||
styleISize.AsExtremumLength() == StyleExtremumLength::MinContent)) {
|
||||
if (styleISize.IsMaxContent() || styleISize.IsMinContent()) {
|
||||
MOZ_ASSERT(isInlineAxis);
|
||||
// -moz-fit-content and -moz-available enumerated widths compute intrinsic
|
||||
// widths just like auto.
|
||||
|
@ -4971,11 +4956,14 @@ 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 && styleISize.IsExtremumLength() && ar &&
|
||||
if (isInlineAxis && ar && nsIFrame::ToExtremumLength(styleISize) &&
|
||||
aFrame->IsFrameOfType(nsIFrame::eSupportsAspectRatio) &&
|
||||
!inlineSizeFromAspectRatio) {
|
||||
// This 'B' in |styleBSize| means the block size of |aFrame|. We go into
|
||||
|
@ -5071,10 +5059,10 @@ nscoord nsLayoutUtils::MinSizeContributionForAxis(
|
|||
// -moz-available for intrinsic size in block axis. Therefore, we reset them
|
||||
// if needed.
|
||||
if (aAxis != ourInlineAxis) {
|
||||
if (size.IsExtremumLength()) {
|
||||
if (size.BehavesLikeInitialValueOnBlockAxis()) {
|
||||
size = StyleSize::Auto();
|
||||
}
|
||||
if (maxSize.IsExtremumLength()) {
|
||||
if (maxSize.BehavesLikeInitialValueOnBlockAxis()) {
|
||||
maxSize = StyleMaxSize::None();
|
||||
}
|
||||
}
|
||||
|
@ -5086,7 +5074,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.IsExtremumLength()) {
|
||||
if (aAxis != ourInlineAxis && size.BehavesLikeInitialValueOnBlockAxis()) {
|
||||
size = StyleSize::Auto();
|
||||
}
|
||||
|
||||
|
@ -5107,7 +5095,7 @@ nscoord nsLayoutUtils::MinSizeContributionForAxis(
|
|||
}
|
||||
} else if (GetAbsoluteCoord(size, minSize)) {
|
||||
fixedMinSize = &minSize;
|
||||
} else if (!size.IsExtremumLength()) {
|
||||
} else if (size.IsLengthPercentage()) {
|
||||
MOZ_ASSERT(size.HasPercent());
|
||||
minSize = 0;
|
||||
fixedMinSize = &minSize;
|
||||
|
|
|
@ -3373,27 +3373,19 @@ 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.IsAuto() || aCoord.IsExtremumLength()) {
|
||||
// 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()) {
|
||||
return false;
|
||||
}
|
||||
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();
|
||||
MOZ_ASSERT(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;
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
|
@ -3417,7 +3409,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 (BehavesLikeInitialValueOnBlockAxis(position->BSize(wm)) &&
|
||||
if (position->BSize(wm).BehavesLikeInitialValueOnBlockAxis() &&
|
||||
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.IsExtremumLength());
|
||||
return aSize.IsAuto() || (!aIsInline && !aSize.IsLengthPercentage());
|
||||
}
|
||||
|
||||
// Helper-macros to let us pick one of two expressions to evaluate
|
||||
|
@ -1346,8 +1346,7 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild(
|
|||
// value 'max-content'.
|
||||
styleFlexBaseSize.emplace(StyleSize::Auto());
|
||||
} else {
|
||||
styleFlexBaseSize.emplace(
|
||||
StyleSize::ExtremumLength(StyleExtremumLength::MaxContent));
|
||||
styleFlexBaseSize.emplace(StyleSize::MaxContent());
|
||||
}
|
||||
} else if (flexBasis.IsSize() && !flexBasis.IsAuto()) {
|
||||
// For all other non-'auto' flex-basis values, we just swap in the
|
||||
|
@ -4473,11 +4472,14 @@ 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.IsExtremumLength()) &&
|
||||
(bsize.IsAuto() || !bsize.IsLengthPercentage()) &&
|
||||
!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.IsExtremumLength());
|
||||
size.BehavesLikeInitialValueOnBlockAxis());
|
||||
// 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.IsExtremumLength());
|
||||
minSize.BehavesLikeInitialValueOnBlockAxis());
|
||||
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.IsExtremumLength()) {
|
||||
if (axis != ourInlineAxis && sizeStyle.BehavesLikeInitialValueOnBlockAxis()) {
|
||||
sizeStyle = StyleSize::Auto();
|
||||
}
|
||||
|
||||
|
@ -5405,8 +5405,9 @@ static nscoord MinSize(const GridItemInfo& aGridItem,
|
|||
// treat it as `auto`.
|
||||
const bool inInlineAxis = axis == ourInlineAxis;
|
||||
const bool isAuto =
|
||||
style.IsAuto() || (!inInlineAxis && style.IsExtremumLength());
|
||||
if ((inInlineAxis && style.IsExtremumLength()) ||
|
||||
style.IsAuto() ||
|
||||
(!inInlineAxis && style.BehavesLikeInitialValueOnBlockAxis());
|
||||
if ((inInlineAxis && nsIFrame::ToExtremumLength(style)) ||
|
||||
(isAuto && child->StyleDisplay()->mOverflowX == StyleOverflow::Visible)) {
|
||||
// Now calculate the "content size" part and return whichever is smaller.
|
||||
MOZ_ASSERT(isAuto || sz == NS_UNCONSTRAINEDSIZE);
|
||||
|
|
|
@ -2323,12 +2323,9 @@ already_AddRefed<ComputedStyle> nsIFrame::ComputeSelectionStyle(
|
|||
|
||||
template <typename SizeOrMaxSize>
|
||||
static inline bool IsIntrinsicKeyword(const SizeOrMaxSize& aSize) {
|
||||
if (!aSize.IsExtremumLength()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// All of the keywords except for '-moz-available' depend on intrinsic sizes.
|
||||
return aSize.AsExtremumLength() != StyleExtremumLength::MozAvailable;
|
||||
// All keywords other than auto/none/-moz-available depend on intrinsic sizes.
|
||||
return aSize.IsMaxContent() || aSize.IsMinContent() ||
|
||||
aSize.IsMozFitContent();
|
||||
}
|
||||
|
||||
bool nsIFrame::CanBeDynamicReflowRoot() const {
|
||||
|
@ -6433,7 +6430,7 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
|
|||
gfxContext* aRenderingContext, const WritingMode aWM,
|
||||
const LogicalSize& aContainingBlockSize,
|
||||
const LogicalSize& aContentEdgeToBoxSizing, nscoord aBoxSizingToMarginEdge,
|
||||
StyleExtremumLength aSize, ComputeSizeFlags aFlags) {
|
||||
ExtremumLength 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);
|
||||
|
@ -6441,20 +6438,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 == StyleExtremumLength::MozAvailable
|
||||
aSize == ExtremumLength::MozAvailable
|
||||
? Nothing()
|
||||
: ComputeInlineSizeFromAspectRatio(aWM, aContainingBlockSize,
|
||||
aContentEdgeToBoxSizing, aFlags);
|
||||
nscoord result;
|
||||
switch (aSize) {
|
||||
case StyleExtremumLength::MaxContent:
|
||||
case ExtremumLength::MaxContent:
|
||||
result = intrinsicSizeFromAspectRatio ? *intrinsicSizeFromAspectRatio
|
||||
: GetPrefISize(aRenderingContext);
|
||||
NS_ASSERTION(result >= 0, "inline-size less than zero");
|
||||
return {result, intrinsicSizeFromAspectRatio
|
||||
? AspectRatioUsage::ToComputeISize
|
||||
: AspectRatioUsage::None};
|
||||
case StyleExtremumLength::MinContent:
|
||||
case ExtremumLength::MinContent:
|
||||
result = intrinsicSizeFromAspectRatio ? *intrinsicSizeFromAspectRatio
|
||||
: GetMinISize(aRenderingContext);
|
||||
NS_ASSERTION(result >= 0, "inline-size less than zero");
|
||||
|
@ -6468,7 +6465,7 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
|
|||
return {result, intrinsicSizeFromAspectRatio
|
||||
? AspectRatioUsage::ToComputeISize
|
||||
: AspectRatioUsage::None};
|
||||
case StyleExtremumLength::MozFitContent: {
|
||||
case ExtremumLength::MozFitContent: {
|
||||
nscoord pref = NS_UNCONSTRAINEDSIZE;
|
||||
nscoord min = 0;
|
||||
if (intrinsicSizeFromAspectRatio) {
|
||||
|
@ -6490,7 +6487,7 @@ nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue(
|
|||
NS_ASSERTION(result >= 0, "inline-size less than zero");
|
||||
return {result};
|
||||
}
|
||||
case StyleExtremumLength::MozAvailable:
|
||||
case ExtremumLength::MozAvailable:
|
||||
return {aContainingBlockSize.ISize(aWM) -
|
||||
(aBoxSizingToMarginEdge + aContentEdgeToBoxSizing.ISize(aWM))};
|
||||
}
|
||||
|
|
|
@ -639,7 +639,6 @@ 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;
|
||||
|
@ -4767,6 +4766,29 @@ 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.
|
||||
|
@ -4779,7 +4801,7 @@ class nsIFrame : public nsQueryFrame {
|
|||
gfxContext* aRenderingContext, const mozilla::WritingMode aWM,
|
||||
const mozilla::LogicalSize& aContainingBlockSize,
|
||||
const mozilla::LogicalSize& aContentEdgeToBoxSizing,
|
||||
nscoord aBoxSizingToMarginEdge, StyleExtremumLength aSize,
|
||||
nscoord aBoxSizingToMarginEdge, ExtremumLength aSize,
|
||||
mozilla::ComputeSizeFlags aFlags);
|
||||
|
||||
/**
|
||||
|
@ -4798,16 +4820,17 @@ 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,
|
||||
aSize.AsExtremumLength(), aFlags);
|
||||
length.valueOr(ExtremumLength::MinContent),
|
||||
aFlags);
|
||||
}
|
||||
|
||||
DisplayItemDataArray* DisplayItemData() const {
|
||||
|
|
|
@ -120,16 +120,16 @@ static bool HaveSpecifiedSize(const nsStylePosition* aStylePosition) {
|
|||
|
||||
template <typename SizeOrMaxSize>
|
||||
static bool DependsOnIntrinsicSize(const SizeOrMaxSize& aMinOrMaxSize) {
|
||||
if (!aMinOrMaxSize.IsExtremumLength()) {
|
||||
auto length = nsIFrame::ToExtremumLength(aMinOrMaxSize);
|
||||
if (!length) {
|
||||
return false;
|
||||
}
|
||||
auto keyword = aMinOrMaxSize.AsExtremumLength();
|
||||
switch (keyword) {
|
||||
case StyleExtremumLength::MinContent:
|
||||
case StyleExtremumLength::MaxContent:
|
||||
case StyleExtremumLength::MozFitContent:
|
||||
switch (*length) {
|
||||
case nsIFrame::ExtremumLength::MinContent:
|
||||
case nsIFrame::ExtremumLength::MaxContent:
|
||||
case nsIFrame::ExtremumLength::MozFitContent:
|
||||
return true;
|
||||
case StyleExtremumLength::MozAvailable:
|
||||
case nsIFrame::ExtremumLength::MozAvailable:
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown sizing keyword?");
|
||||
|
|
|
@ -424,7 +424,6 @@ 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() || IsExtremumLength();
|
||||
return IsAuto() || !IsLengthPercentage();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool StyleMaxSize::BehavesLikeInitialValueOnBlockAxis() const {
|
||||
return IsNone() || IsExtremumLength();
|
||||
return IsNone() || !IsLengthPercentage();
|
||||
}
|
||||
|
||||
template <>
|
||||
|
|
|
@ -2234,16 +2234,16 @@ already_AddRefed<CSSValue> nsComputedDOMStyle::GetMarginWidthFor(
|
|||
return val.forget();
|
||||
}
|
||||
|
||||
void nsComputedDOMStyle::SetValueToExtremumLength(nsROCSSPrimitiveValue* aValue,
|
||||
StyleExtremumLength aSize) {
|
||||
static void SetValueToExtremumLength(nsROCSSPrimitiveValue* aValue,
|
||||
nsIFrame::ExtremumLength aSize) {
|
||||
switch (aSize) {
|
||||
case StyleExtremumLength::MaxContent:
|
||||
case nsIFrame::ExtremumLength::MaxContent:
|
||||
return aValue->SetString("max-content");
|
||||
case StyleExtremumLength::MinContent:
|
||||
case nsIFrame::ExtremumLength::MinContent:
|
||||
return aValue->SetString("min-content");
|
||||
case StyleExtremumLength::MozAvailable:
|
||||
case nsIFrame::ExtremumLength::MozAvailable:
|
||||
return aValue->SetString("-moz-available");
|
||||
case StyleExtremumLength::MozFitContent:
|
||||
case nsIFrame::ExtremumLength::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 (aSize.IsExtremumLength()) {
|
||||
return SetValueToExtremumLength(aValue, aSize.AsExtremumLength());
|
||||
if (auto length = nsIFrame::ToExtremumLength(aSize)) {
|
||||
return SetValueToExtremumLength(aValue, *length);
|
||||
}
|
||||
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 (aSize.IsExtremumLength()) {
|
||||
return SetValueToExtremumLength(aValue, aSize.AsExtremumLength());
|
||||
if (auto length = nsIFrame::ToExtremumLength(aSize)) {
|
||||
return SetValueToExtremumLength(aValue, *length);
|
||||
}
|
||||
MOZ_ASSERT(aSize.IsLengthPercentage());
|
||||
SetValueToLengthPercentage(aValue, aSize.AsLengthPercentage(), true);
|
||||
|
|
|
@ -60,7 +60,6 @@ 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:
|
||||
|
@ -295,9 +294,6 @@ 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,14 +831,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition {
|
|||
if (aCoord.IsLengthPercentage()) {
|
||||
return aCoord.AsLengthPercentage().HasPercent();
|
||||
}
|
||||
|
||||
if (!aCoord.IsExtremumLength()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto keyword = aCoord.AsExtremumLength();
|
||||
return keyword == mozilla::StyleExtremumLength::MozFitContent ||
|
||||
keyword == mozilla::StyleExtremumLength::MozAvailable;
|
||||
return aCoord.IsMozFitContent() || aCoord.IsMozAvailable();
|
||||
}
|
||||
|
||||
template <typename SizeOrMaxSize>
|
||||
|
|
|
@ -140,38 +140,36 @@ static CellISizeInfo GetISizeInfo(gfxContext* aRenderingContext,
|
|||
prefCoord = std::max(c, minCoord);
|
||||
} else if (iSize.ConvertsToPercentage()) {
|
||||
prefPercent = iSize.ToPercentage();
|
||||
} else if (iSize.IsExtremumLength() && aIsCell) {
|
||||
switch (iSize.AsExtremumLength()) {
|
||||
case StyleExtremumLength::MaxContent:
|
||||
} else if (aIsCell) {
|
||||
switch (iSize.tag) {
|
||||
case StyleSize::Tag::MaxContent:
|
||||
// 'inline-size' only affects pref isize, not min
|
||||
// isize, so don't change anything
|
||||
break;
|
||||
case StyleExtremumLength::MinContent:
|
||||
case StyleSize::Tag::MinContent:
|
||||
prefCoord = minCoord;
|
||||
break;
|
||||
case StyleExtremumLength::MozFitContent:
|
||||
case StyleExtremumLength::MozAvailable:
|
||||
case StyleSize::Tag::MozAvailable:
|
||||
case StyleSize::Tag::MozFitContent:
|
||||
case StyleSize::Tag::Auto:
|
||||
case StyleSize::Tag::LengthPercentage:
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected enumerated value");
|
||||
}
|
||||
}
|
||||
|
||||
StyleMaxSize maxISize = stylePos->MaxISize(aWM);
|
||||
if (maxISize.IsExtremumLength()) {
|
||||
if (!aIsCell ||
|
||||
maxISize.AsExtremumLength() == StyleExtremumLength::MozAvailable) {
|
||||
if (nsIFrame::ToExtremumLength(maxISize)) {
|
||||
if (!aIsCell || maxISize.IsMozAvailable()) {
|
||||
maxISize = StyleMaxSize::None();
|
||||
} else if (maxISize.AsExtremumLength() ==
|
||||
StyleExtremumLength::MozFitContent) {
|
||||
} else if (maxISize.IsMozFitContent()) {
|
||||
// for 'max-inline-size', '-moz-fit-content' is like 'max-content'
|
||||
maxISize = StyleMaxSize::ExtremumLength(StyleExtremumLength::MaxContent);
|
||||
maxISize = StyleMaxSize::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.IsExtremumLength()) {
|
||||
if (maxISize.ConvertsToLength() || nsIFrame::ToExtremumLength(maxISize)) {
|
||||
nscoord c = aFrame
|
||||
->ComputeISizeValue(aRenderingContext, aWM, zeroSize,
|
||||
zeroSize, 0, maxISize)
|
||||
|
@ -186,17 +184,16 @@ static CellISizeInfo GetISizeInfo(gfxContext* aRenderingContext,
|
|||
}
|
||||
|
||||
StyleSize minISize = stylePos->MinISize(aWM);
|
||||
if (minISize.IsExtremumLength()) {
|
||||
if (!aIsCell ||
|
||||
minISize.AsExtremumLength() == StyleExtremumLength::MozAvailable) {
|
||||
if (nsIFrame::ToExtremumLength(maxISize)) {
|
||||
if (!aIsCell || minISize.IsMozAvailable()) {
|
||||
minISize = StyleSize::LengthPercentage(LengthPercentage::Zero());
|
||||
} else if (minISize.AsExtremumLength() ==
|
||||
StyleExtremumLength::MozFitContent) {
|
||||
} else if (minISize.IsMozFitContent()) {
|
||||
// for 'min-inline-size', '-moz-fit-content' is like 'min-content'
|
||||
minISize = StyleSize::ExtremumLength(StyleExtremumLength::MinContent);
|
||||
minISize = StyleSize::MinContent();
|
||||
}
|
||||
}
|
||||
if (minISize.ConvertsToLength() || minISize.IsExtremumLength()) {
|
||||
|
||||
if (minISize.ConvertsToLength() || nsIFrame::ToExtremumLength(minISize)) {
|
||||
nscoord c = aFrame
|
||||
->ComputeISizeValue(aRenderingContext, aWM, zeroSize,
|
||||
zeroSize, 0, minISize)
|
||||
|
|
|
@ -73,10 +73,6 @@ 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;
|
||||
|
@ -85,12 +81,8 @@ nscoord FixedTableLayoutStrategy::GetMinISize(gfxContext* aRenderingContext) {
|
|||
cellMap->GetCellInfoAt(0, col, &originates, &colSpan);
|
||||
if (cellFrame) {
|
||||
styleISize = &cellFrame->StylePosition()->ISize(wm);
|
||||
if (styleISize->ConvertsToLength() ||
|
||||
(styleISize->IsExtremumLength() &&
|
||||
(styleISize->AsExtremumLength() ==
|
||||
StyleExtremumLength::MaxContent ||
|
||||
styleISize->AsExtremumLength() ==
|
||||
StyleExtremumLength::MinContent))) {
|
||||
if (styleISize->ConvertsToLength() || styleISize->IsMinContent() ||
|
||||
styleISize->IsMaxContent()) {
|
||||
nscoord cellISize = nsLayoutUtils::IntrinsicForContainer(
|
||||
aRenderingContext, cellFrame, IntrinsicISizeType::MinISize);
|
||||
if (colSpan > 1) {
|
||||
|
@ -216,11 +208,6 @@ 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;
|
||||
|
@ -230,12 +217,8 @@ void FixedTableLayoutStrategy::ComputeColumnISizes(
|
|||
if (cellFrame) {
|
||||
const nsStylePosition* cellStylePos = cellFrame->StylePosition();
|
||||
styleISize = &cellStylePos->ISize(wm);
|
||||
if (styleISize->ConvertsToLength() ||
|
||||
(styleISize->IsExtremumLength() &&
|
||||
(styleISize->AsExtremumLength() ==
|
||||
StyleExtremumLength::MaxContent ||
|
||||
styleISize->AsExtremumLength() ==
|
||||
StyleExtremumLength::MinContent))) {
|
||||
if (styleISize->ConvertsToLength() || styleISize->IsMaxContent() ||
|
||||
styleISize->IsMinContent()) {
|
||||
// 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,9 +3749,7 @@ 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.IsExtremumLength() &&
|
||||
iSize.AsExtremumLength() == StyleExtremumLength::MaxContent);
|
||||
return iSize.IsAuto() || iSize.IsMaxContent();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FRAME_DUMP
|
||||
|
|
|
@ -185,7 +185,10 @@ impl Size {
|
|||
GenericSize::Auto => false,
|
||||
GenericSize::LengthPercentage(ref lp) => lp.is_definitely_zero(),
|
||||
#[cfg(feature = "gecko")]
|
||||
GenericSize::ExtremumLength(..) => false,
|
||||
GenericSize::MinContent |
|
||||
GenericSize::MaxContent |
|
||||
GenericSize::MozFitContent |
|
||||
GenericSize::MozAvailable => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -495,37 +498,6 @@ 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, ExtremumLength, NonNegativeLength};
|
||||
pub use self::length::{CSSPixelLength, NonNegativeLength};
|
||||
pub use self::length::{Length, LengthOrNumber, LengthPercentage, NonNegativeLengthOrNumber};
|
||||
pub use self::length::{LengthOrAuto, LengthPercentageOrAuto, MaxSize, Size};
|
||||
pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto};
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
#[cfg(feature = "gecko")]
|
||||
use crate::values::computed::ExtremumLength;
|
||||
use crate::Zero;
|
||||
use cssparser::Parser;
|
||||
use style_traits::ParseError;
|
||||
|
@ -151,9 +150,14 @@ impl<LengthPercentage: Parse> Parse for LengthPercentageOrAuto<LengthPercentage>
|
|||
pub enum GenericSize<LengthPercent> {
|
||||
LengthPercentage(LengthPercent),
|
||||
Auto,
|
||||
#[cfg(feature = "gecko")]
|
||||
#[animation(error)]
|
||||
ExtremumLength(ExtremumLength),
|
||||
MaxContent,
|
||||
#[animation(error)]
|
||||
MinContent,
|
||||
#[animation(error)]
|
||||
MozFitContent,
|
||||
#[animation(error)]
|
||||
MozAvailable,
|
||||
}
|
||||
|
||||
pub use self::GenericSize as Size;
|
||||
|
@ -194,9 +198,16 @@ impl<LengthPercentage> Size<LengthPercentage> {
|
|||
pub enum GenericMaxSize<LengthPercent> {
|
||||
LengthPercentage(LengthPercent),
|
||||
None,
|
||||
#[cfg(feature = "gecko")]
|
||||
#[animation(error)]
|
||||
ExtremumLength(ExtremumLength),
|
||||
#[parse(aliases = "-moz-max-content")]
|
||||
MaxContent,
|
||||
#[animation(error)]
|
||||
#[parse(aliases = "-moz-min-content")]
|
||||
MinContent,
|
||||
#[animation(error)]
|
||||
MozFitContent,
|
||||
#[animation(error)]
|
||||
MozAvailable,
|
||||
}
|
||||
|
||||
pub use self::GenericMaxSize as MaxSize;
|
||||
|
|
|
@ -1217,6 +1217,27 @@ 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>(
|
||||
|
@ -1224,16 +1245,7 @@ impl Size {
|
|||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
#[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);
|
||||
}
|
||||
parse_size_non_length!(Size, input, "auto" => Auto);
|
||||
|
||||
let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?;
|
||||
Ok(GenericSize::LengthPercentage(length))
|
||||
|
@ -1265,16 +1277,7 @@ impl MaxSize {
|
|||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
#[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);
|
||||
}
|
||||
parse_size_non_length!(MaxSize, input, "none" => None);
|
||||
|
||||
let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?;
|
||||
Ok(GenericMaxSize::LengthPercentage(length))
|
||||
|
|
|
@ -91,7 +91,6 @@ include = [
|
|||
"DisplayMode",
|
||||
"PrefersColorScheme",
|
||||
"PrefersContrast",
|
||||
"ExtremumLength",
|
||||
"FillRule",
|
||||
"FontDisplay",
|
||||
"FontFaceSourceListComponent",
|
||||
|
|
Загрузка…
Ссылка в новой задаче