mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #25033 - servo:intrinsic, r=nox
Add support for inline-block and for computing min/max-content
This commit is contained in:
commit
e70397d90a
19 changed files with 823 additions and 272 deletions
|
@ -170,6 +170,12 @@ impl LengthPercentage {
|
|||
self.length
|
||||
}
|
||||
|
||||
/// Returns the percentage component of this `calc()`
|
||||
#[inline]
|
||||
pub fn percentage_component(&self) -> Percentage {
|
||||
Percentage(self.clamping_mode.clamp(self.percentage.0))
|
||||
}
|
||||
|
||||
/// Return the percentage value as CSSFloat.
|
||||
#[inline]
|
||||
pub fn percentage(&self) -> CSSFloat {
|
||||
|
@ -186,6 +192,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> {
|
||||
|
|
|
@ -64,6 +64,12 @@ impl Zero for Percentage {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::ops::AddAssign for Percentage {
|
||||
fn add_assign(&mut self, other: Self) {
|
||||
self.0 += other.0
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Percentage {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
|
|
@ -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