mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implement "outer min/max-content" (based on a given min/max-content)
https://dbaron.org/css/intrinsic/#outer-intrinsic
This commit is contained in:
parent
aa925a5984
commit
8fe37f3ed6
3 changed files with 80 additions and 1 deletions
|
@ -186,6 +186,16 @@ impl LengthPercentage {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the length component if this could be represented as a
|
||||
/// non-calc length.
|
||||
pub fn as_length(&self) -> Option<Length> {
|
||||
if !self.has_percentage {
|
||||
Some(self.length_component())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the percentage component if this could be represented as a
|
||||
/// non-calc percentage.
|
||||
pub fn as_percentage(&self) -> Option<Percentage> {
|
||||
|
|
|
@ -92,7 +92,7 @@ where
|
|||
}
|
||||
|
||||
/// Maps the length of this value.
|
||||
pub fn map(&self, f: impl FnOnce(LengthPercentage) -> LengthPercentage) -> Self {
|
||||
pub fn map<T>(&self, f: impl FnOnce(LengthPercentage) -> T) -> LengthPercentageOrAuto<T> {
|
||||
match self {
|
||||
LengthPercentageOrAuto::LengthPercentage(l) => {
|
||||
LengthPercentageOrAuto::LengthPercentage(f(l.clone()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue