Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the fit-content() sizing function #153

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions style/values/computed/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,77 +176,6 @@ impl NonNegativeLengthPercentageOrAuto {
computed_length_percentage_or_auto!(NonNegativeLengthPercentage);
}

#[cfg(feature = "servo")]
impl MaxSize {
/// Convert the computed value into used value.
#[inline]
pub fn to_used_value(&self, percentage_basis: Au) -> Option<Au> {
match *self {
Self::None | Self::MinContent | Self::MaxContent | Self::FitContent | Self::Stretch => {
None
},
Self::LengthPercentage(ref lp) => Some(lp.to_used_value(percentage_basis)),
Self::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
}
}

/// Convert the computed value into used value if there is enough information.
#[inline]
pub fn maybe_to_used_value(&self, percentage_basis: Option<Au>) -> Option<Au> {
match *self {
Self::None | Self::MinContent | Self::MaxContent | Self::FitContent | Self::Stretch => {
None
},
Self::LengthPercentage(ref lp) => lp.maybe_to_used_value(percentage_basis),
Self::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
}
}
}

impl Size {
/// Convert the computed value into used value.
#[inline]
#[cfg(feature = "servo")]
pub fn to_used_value(&self, percentage_basis: Au) -> Option<Au> {
match *self {
Self::Auto | Self::MinContent | Self::MaxContent | Self::FitContent | Self::Stretch => {
None
},
Self::LengthPercentage(ref lp) => Some(lp.to_used_value(percentage_basis)),
Self::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
}
}

/// Convert the computed value into used value if there is enough information.
#[inline]
#[cfg(feature = "servo")]
pub fn maybe_to_used_value(&self, percentage_basis: Option<Au>) -> Option<Au> {
match *self {
Self::Auto | Self::MinContent | Self::MaxContent | Self::FitContent | Self::Stretch => {
None
},
Self::LengthPercentage(ref lp) => lp.maybe_to_used_value(percentage_basis),
Self::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
}
}

/// Returns true if the computed value is absolute 0 or 0%.
#[inline]
pub fn is_definitely_zero(&self) -> bool {
match *self {
Self::Auto => false,
Self::LengthPercentage(ref lp) => lp.is_definitely_zero(),
Self::MinContent |
Self::MaxContent |
Self::FitContent |
Self::Stretch |
Self::AnchorSizeFunction(_) => false,
#[cfg(feature = "gecko")]
Self::MozAvailable | Self::WebkitFillAvailable | Self::FitContentFunction(_) => false,
}
}
}

/// The computed `<length>` value.
#[derive(
Animate,
Expand Down
2 changes: 0 additions & 2 deletions style/values/generics/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ pub enum GenericSize<LengthPercent> {
WebkitFillAvailable,
#[animation(error)]
Stretch,
#[cfg(feature = "gecko")]
#[animation(error)]
#[css(function = "fit-content")]
FitContentFunction(LengthPercent),
Expand Down Expand Up @@ -246,7 +245,6 @@ pub enum GenericMaxSize<LengthPercent> {
WebkitFillAvailable,
#[animation(error)]
Stretch,
#[cfg(feature = "gecko")]
#[animation(error)]
#[css(function = "fit-content")]
FitContentFunction(LengthPercent),
Expand Down
4 changes: 0 additions & 4 deletions style/values/specified/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2050,12 +2050,10 @@ fn is_stretch_enabled() -> bool {
static_prefs::pref!("layout.css.stretch-size-keyword.enabled")
}

#[cfg(feature = "gecko")]
fn is_fit_content_function_enabled() -> bool {
static_prefs::pref!("layout.css.fit-content-function.enabled")
}

#[cfg(feature = "gecko")]
macro_rules! parse_fit_content_function {
($size:ident, $input:expr, $context:expr, $allow_quirks:expr) => {
if is_fit_content_function_enabled() {
Expand All @@ -2079,7 +2077,6 @@ impl Size {
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
parse_size_non_length!(Size, input, "auto" => Auto);
#[cfg(feature = "gecko")]
parse_fit_content_function!(Size, input, context, allow_quirks);

if let Ok(length) =
Expand Down Expand Up @@ -2119,7 +2116,6 @@ impl MaxSize {
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
parse_size_non_length!(MaxSize, input, "none" => None);
#[cfg(feature = "gecko")]
parse_fit_content_function!(MaxSize, input, context, allow_quirks);

if let Ok(length) =
Expand Down
3 changes: 3 additions & 0 deletions stylo_static_prefs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ macro_rules! pref {
("layout.css.basic-shape-xywh.enabled") => {
true
};
("layout.css.fit-content-function.enabled") => {
true
};
("layout.css.relative-color-syntax.enabled") => {
true
};
Expand Down