Add intrinsic size computation for inline formatting contexts

This commit is contained in:
Simon Sapin 2019-12-02 22:11:54 +01:00
parent 8fe37f3ed6
commit 9c5a595044
6 changed files with 188 additions and 46 deletions

View file

@ -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 {

View file

@ -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