mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #14740 - glasserc:extremum-length, r=Manishearth
Add support for keyword values for min-width and max-width This is a follow-up to #14432 which got closed and can no longer be re-opened. This PR aims to add support for keyword-values max-content, min-content, fit-content, and fill-available to the properties that use them, namely min-width, min-height, max-width, and max-height. It's still untested because I still haven't figured out how to do that. I guess I should write or find some web page that uses these properties. Refs #13821. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #13821 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14740) <!-- Reviewable:end -->
This commit is contained in:
commit
26de7c6bc4
9 changed files with 349 additions and 17 deletions
|
@ -635,6 +635,8 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
|||
"LengthOrPercentageOrAuto": impl_style_coord,
|
||||
"LengthOrPercentageOrNone": impl_style_coord,
|
||||
"LengthOrNone": impl_style_coord,
|
||||
"MaxLength": impl_style_coord,
|
||||
"MinLength": impl_style_coord,
|
||||
"Number": impl_simple,
|
||||
"Opacity": impl_simple,
|
||||
"CSSColor": impl_color,
|
||||
|
|
|
@ -33,6 +33,7 @@ use values::Either;
|
|||
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||
use values::computed::{BorderRadiusSize, ClipRect, LengthOrNone};
|
||||
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
|
||||
use values::computed::{MaxLength, MinLength};
|
||||
use values::computed::position::{HorizontalPosition, Position, VerticalPosition};
|
||||
use values::computed::ToComputedValue;
|
||||
use values::specified::Angle as SpecifiedAngle;
|
||||
|
@ -630,6 +631,34 @@ impl Interpolate for LengthOrPercentageOrNone {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
|
||||
impl Interpolate for MinLength {
|
||||
#[inline]
|
||||
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
|
||||
match (*self, *other) {
|
||||
(MinLength::LengthOrPercentage(ref this),
|
||||
MinLength::LengthOrPercentage(ref other)) => {
|
||||
this.interpolate(other, progress).map(MinLength::LengthOrPercentage)
|
||||
}
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
|
||||
impl Interpolate for MaxLength {
|
||||
#[inline]
|
||||
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
|
||||
match (*self, *other) {
|
||||
(MaxLength::LengthOrPercentage(ref this),
|
||||
MaxLength::LengthOrPercentage(ref other)) => {
|
||||
this.interpolate(other, progress).map(MaxLength::LengthOrPercentage)
|
||||
}
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-number
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-length
|
||||
impl Interpolate for LineHeight {
|
||||
|
|
|
@ -218,23 +218,40 @@ ${helpers.predefined_type("flex-basis",
|
|||
spec=spec % size,
|
||||
animatable=True, logical = logical)}
|
||||
|
||||
// min-width, min-height, min-block-size, min-inline-size
|
||||
${helpers.predefined_type("min-%s" % size,
|
||||
"LengthOrPercentage",
|
||||
"computed::LengthOrPercentage::Length(Au(0))",
|
||||
"parse_non_negative",
|
||||
needs_context=False,
|
||||
spec=spec % ("min-%s" % size),
|
||||
animatable=True, logical = logical)}
|
||||
% if product == "gecko":
|
||||
// min-width, min-height, min-block-size, min-inline-size
|
||||
${helpers.predefined_type("min-%s" % size,
|
||||
"MinLength",
|
||||
"computed::MinLength::LengthOrPercentage(" +
|
||||
"computed::LengthOrPercentage::Length(Au(0)))",
|
||||
spec=spec % ("min-%s" % size),
|
||||
animatable=True, logical = logical)}
|
||||
% else:
|
||||
${helpers.predefined_type("min-%s" % size,
|
||||
"LengthOrPercentage",
|
||||
"computed::LengthOrPercentage::Length(Au(0))",
|
||||
"parse_non_negative",
|
||||
needs_context=False,
|
||||
spec=spec % ("min-%s" % size),
|
||||
animatable=True, logical = logical)}
|
||||
% endif
|
||||
|
||||
// max-width, max-height, max-block-size, max-inline-size
|
||||
${helpers.predefined_type("max-%s" % size,
|
||||
"LengthOrPercentageOrNone",
|
||||
"computed::LengthOrPercentageOrNone::None",
|
||||
"parse_non_negative",
|
||||
needs_context=False,
|
||||
spec=spec % ("max-%s" % size),
|
||||
animatable=True, logical = logical)}
|
||||
% if product == "gecko":
|
||||
${helpers.predefined_type("max-%s" % size,
|
||||
"MaxLength",
|
||||
"computed::MaxLength::None",
|
||||
spec=spec % ("max-%s" % size),
|
||||
animatable=True, logical = logical)}
|
||||
% else:
|
||||
${helpers.predefined_type("max-%s" % size,
|
||||
"LengthOrPercentageOrNone",
|
||||
"computed::LengthOrPercentageOrNone::None",
|
||||
"parse_non_negative",
|
||||
needs_context=False,
|
||||
spec=spec % ("max-%s" % size),
|
||||
animatable=True, logical = logical)}
|
||||
% endif
|
||||
% endfor
|
||||
|
||||
${helpers.single_keyword("box-sizing",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue