mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Add support for table rows, columns, rowgroups and colgroups (#31341)
This adds support for table rows, columns, rowgroups and colgroups. There are few additions here: 1. The createion of fragments, which allows script queries and hit testing to work properly. These fragments are empty as all cells are still direct descendants of the table fragment. 2. Properly handling size information from tracks and track groups as well as frustrating rules about reordering rowgroups. 3. Painting a background seemlessly across track groups and groups. This is a thing that isn't done in legacy layout (nor WebKit)! Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
74c07db56c
commit
02ae1f448e
57 changed files with 4274 additions and 21000 deletions
|
@ -12,6 +12,8 @@
|
|||
mod construct;
|
||||
mod layout;
|
||||
|
||||
use std::ops::Range;
|
||||
|
||||
pub(crate) use construct::AnonymousTableContent;
|
||||
pub use construct::TableBuilder;
|
||||
use euclid::{Point2D, Size2D, UnknownUnit, Vector2D};
|
||||
|
@ -32,6 +34,19 @@ pub struct Table {
|
|||
#[serde(skip_serializing)]
|
||||
style: Arc<ComputedValues>,
|
||||
|
||||
/// The column groups for this table.
|
||||
pub column_groups: Vec<TableTrackGroup>,
|
||||
|
||||
/// The columns of this tabled defined by `<colgroup> | display: table-column-group`
|
||||
/// and `<col> | display: table-column` elements as well as `display: table-column`.
|
||||
pub columns: Vec<TableTrack>,
|
||||
|
||||
/// The rows groups for this table deinfed by `<tbody>`, `<thead>`, and `<tfoot>`.
|
||||
pub row_groups: Vec<TableTrackGroup>,
|
||||
|
||||
/// The rows of this tabled defined by `<tr>` or `display: table-row` elements.
|
||||
pub rows: Vec<TableTrack>,
|
||||
|
||||
/// The content of the slots of this table.
|
||||
pub slots: Vec<Vec<TableSlot>>,
|
||||
|
||||
|
@ -46,6 +61,10 @@ impl Table {
|
|||
pub(crate) fn new(style: Arc<ComputedValues>) -> Self {
|
||||
Self {
|
||||
style,
|
||||
column_groups: Vec::new(),
|
||||
columns: Vec::new(),
|
||||
row_groups: Vec::new(),
|
||||
rows: Vec::new(),
|
||||
slots: Vec::new(),
|
||||
size: TableSize::zero(),
|
||||
anonymous: false,
|
||||
|
@ -167,3 +186,52 @@ impl TableSlot {
|
|||
Self::Spanned(vec![offset])
|
||||
}
|
||||
}
|
||||
|
||||
/// A row or column of a table.
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct TableTrack {
|
||||
/// The [`BaseFragmentInfo`] of this cell.
|
||||
base_fragment_info: BaseFragmentInfo,
|
||||
|
||||
/// The style of this table column.
|
||||
#[serde(skip_serializing)]
|
||||
style: Arc<ComputedValues>,
|
||||
|
||||
/// The index of the table row or column group parent in the table's list of row or column
|
||||
/// groups.
|
||||
group_index: Option<usize>,
|
||||
|
||||
/// Whether or not this [`TableTrack`] was anonymous, for instance created due to
|
||||
/// a `span` attribute set on a parent `<colgroup>`.
|
||||
is_anonymous: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize)]
|
||||
pub enum TableTrackGroupType {
|
||||
HeaderGroup,
|
||||
FooterGroup,
|
||||
RowGroup,
|
||||
ColumnGroup,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct TableTrackGroup {
|
||||
/// The [`BaseFragmentInfo`] of this [`TableTrackGroup`].
|
||||
base_fragment_info: BaseFragmentInfo,
|
||||
|
||||
/// The style of this [`TableTrackGroup`].
|
||||
#[serde(skip_serializing)]
|
||||
style: Arc<ComputedValues>,
|
||||
|
||||
/// The type of this [`TableTrackGroup`].
|
||||
group_type: TableTrackGroupType,
|
||||
|
||||
/// The range of tracks in this [`TableTrackGroup`].
|
||||
track_range: Range<usize>,
|
||||
}
|
||||
|
||||
impl TableTrackGroup {
|
||||
pub(super) fn is_empty(&self) -> bool {
|
||||
self.track_range.is_empty()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue