mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +01:00
Implement 'empty-cells' for layout 2020 (#32331)
https://drafts.csswg.org/css-tables/#empty-cell-rendering Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
9d57c0de77
commit
5b13604bd8
11 changed files with 46 additions and 133 deletions
|
@ -32,7 +32,7 @@ use crate::context::LayoutContext;
|
|||
use crate::display_list::conversions::ToWebRender;
|
||||
use crate::display_list::stacking_context::StackingContextSection;
|
||||
use crate::fragment_tree::{
|
||||
BackgroundMode, BoxFragment, Fragment, FragmentTree, Tag, TextFragment,
|
||||
BackgroundMode, BoxFragment, Fragment, FragmentFlags, FragmentTree, Tag, TextFragment,
|
||||
};
|
||||
use crate::geom::{LogicalRect, PhysicalPoint, PhysicalRect};
|
||||
use crate::replaced::IntrinsicSizes;
|
||||
|
@ -631,6 +631,14 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
self.build_outline(builder);
|
||||
} else {
|
||||
self.build_hit_test(builder);
|
||||
if self
|
||||
.fragment
|
||||
.base
|
||||
.flags
|
||||
.contains(FragmentFlags::DO_NOT_PAINT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
self.build_background(builder);
|
||||
self.build_box_shadow(builder);
|
||||
self.build_border(builder);
|
||||
|
|
|
@ -94,6 +94,9 @@ bitflags! {
|
|||
/// Whether or not this Fragment was created to contain a list item marker
|
||||
/// with a used value of `list-style-position: outside`.
|
||||
const IS_OUTSIDE_LIST_ITEM_MARKER = 0b00001000;
|
||||
/// Avoid painting the fragment, this is used for empty table cells when 'empty-cells' is 'hide'.
|
||||
/// This flag doesn't avoid hit-testing.
|
||||
const DO_NOT_PAINT = 0b00010000;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use servo_arc::Arc;
|
|||
use style::computed_values::border_collapse::T as BorderCollapse;
|
||||
use style::logical_geometry::WritingMode;
|
||||
use style::properties::longhands::box_sizing::computed_value::T as BoxSizing;
|
||||
use style::properties::longhands::empty_cells::computed_value::T as EmptyCells;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{
|
||||
CSSPixelLength, Length, LengthPercentage as ComputedLengthPercentage, Percentage,
|
||||
|
@ -60,6 +61,15 @@ impl CellLayout {
|
|||
fn is_empty(&self) -> bool {
|
||||
self.layout.fragments.is_empty()
|
||||
}
|
||||
|
||||
/// Whether the cell is considered empty for the purpose of the 'empty-cells' property.
|
||||
fn is_empty_for_empty_cells(&self) -> bool {
|
||||
!self
|
||||
.layout
|
||||
.fragments
|
||||
.iter()
|
||||
.any(|fragment| !matches!(fragment, Fragment::AbsoluteOrFixedPositioned(_)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Information stored during the layout of rows.
|
||||
|
@ -1616,6 +1626,7 @@ impl<'a> TableLayout<'a> {
|
|||
row_relative_cell_rect,
|
||||
row_baseline,
|
||||
positioning_context,
|
||||
&self.table.style,
|
||||
);
|
||||
let column = self.table.columns.get(column_index);
|
||||
let column_group = column
|
||||
|
@ -2142,6 +2153,7 @@ impl TableSlotCell {
|
|||
cell_rect: LogicalRect<Au>,
|
||||
cell_baseline: Au,
|
||||
positioning_context: &mut PositioningContext,
|
||||
table_style: &ComputedValues,
|
||||
) -> BoxFragment {
|
||||
// This must be scoped to this function because it conflicts with euclid's Zero.
|
||||
use style::Zero as StyleZero;
|
||||
|
@ -2162,6 +2174,14 @@ impl TableSlotCell {
|
|||
},
|
||||
};
|
||||
|
||||
let mut base_fragment_info = self.base_fragment_info;
|
||||
if self.style.get_inherited_table().empty_cells == EmptyCells::Hide &&
|
||||
table_style.get_inherited_table().border_collapse != BorderCollapse::Collapse &&
|
||||
layout.is_empty_for_empty_cells()
|
||||
{
|
||||
base_fragment_info.flags.insert(FragmentFlags::DO_NOT_PAINT);
|
||||
}
|
||||
|
||||
// Create an `AnonymousFragment` to move the cell contents to the cell baseline.
|
||||
let mut vertical_align_fragment_rect = cell_content_rect.clone();
|
||||
vertical_align_fragment_rect.start_corner = LogicalVec2 {
|
||||
|
@ -2190,7 +2210,7 @@ impl TableSlotCell {
|
|||
positioning_context.append(layout.positioning_context);
|
||||
|
||||
BoxFragment::new(
|
||||
self.base_fragment_info,
|
||||
base_fragment_info,
|
||||
self.style.clone(),
|
||||
vec![Fragment::Positioning(vertical_align_fragment)],
|
||||
cell_content_rect,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue