mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
layout: Implement computation of table column widths (#31165)
* layout: Implement computation of table column widths This change implements the various steps of table column width computation, ignoring features that don't exist yet (such as separated borders, column elements, and colgroups). Co-authored-by: Oriol Brufau <obrufau@igalia.com> * Fix an issue with the assignment of column percent width * Respond to review comments --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
dc34eec4d4
commit
d68c7e7881
16 changed files with 707 additions and 121 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
//! <https://drafts.csswg.org/css-sizing/>
|
||||
|
||||
use std::ops::{Add, AddAssign};
|
||||
|
||||
use app_units::Au;
|
||||
use serde::Serialize;
|
||||
use style::logical_geometry::WritingMode;
|
||||
|
@ -14,7 +16,7 @@ use style::Zero;
|
|||
|
||||
use crate::style_ext::{Clamp, ComputedValuesExt};
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Serialize)]
|
||||
pub(crate) struct ContentSizes {
|
||||
pub min_content: Au,
|
||||
pub max_content: Au,
|
||||
|
@ -43,7 +45,11 @@ impl ContentSizes {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn add(&self, other: &Self) -> Self {
|
||||
pub fn max_assign(&mut self, other: Self) {
|
||||
*self = self.max(other);
|
||||
}
|
||||
|
||||
pub fn union(&self, other: &Self) -> Self {
|
||||
Self {
|
||||
min_content: self.min_content.max(other.min_content),
|
||||
max_content: self.max_content + other.max_content,
|
||||
|
@ -51,6 +57,23 @@ impl ContentSizes {
|
|||
}
|
||||
}
|
||||
|
||||
impl Add for ContentSizes {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Self) -> Self {
|
||||
Self {
|
||||
min_content: self.min_content + rhs.min_content,
|
||||
max_content: self.max_content + rhs.max_content,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign for ContentSizes {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
*self = self.add(rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl ContentSizes {
|
||||
/// <https://drafts.csswg.org/css2/visudet.html#shrink-to-fit-float>
|
||||
pub fn shrink_to_fit(&self, available_size: Au) -> Au {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue