aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2024-05-21 13:08:08 +0200
committerGitHub <noreply@github.com>2024-05-21 11:08:08 +0000
commit5b13604bd8dbbd26275243d2882761b158291647 (patch)
treecd9eef3f8de266201ad288b9ac90ead217241a29
parent9d57c0de7758eb609306b8f11d93cead6c148786 (diff)
downloadservo-5b13604bd8dbbd26275243d2882761b158291647.tar.gz
servo-5b13604bd8dbbd26275243d2882761b158291647.zip
Implement 'empty-cells' for layout 2020 (#32331)
https://drafts.csswg.org/css-tables/#empty-cell-rendering Co-authored-by: Martin Robinson <mrobinson@igalia.com>
-rw-r--r--Cargo.lock26
-rw-r--r--components/layout_2020/display_list/mod.rs10
-rw-r--r--components/layout_2020/fragment_tree/base_fragment.rs3
-rw-r--r--components/layout_2020/table/layout.rs22
-rw-r--r--tests/wpt/meta/css/CSS2/tables/empty-cells-applies-to-014.xht.ini2
-rw-r--r--tests/wpt/meta/css/CSS2/tables/empty-cells-no-interpolation.html.ini87
-rw-r--r--tests/wpt/meta/css/css-tables/inheritance.html.ini6
-rw-r--r--tests/wpt/meta/css/css-tables/parsing/empty-cells-computed.html.ini6
-rw-r--r--tests/wpt/meta/css/css-tables/parsing/empty-cells-valid.html.ini6
-rw-r--r--tests/wpt/meta/css/cssom/serialize-values.html.ini9
-rw-r--r--tests/wpt/mozilla/meta/css/empty_cells_a.html.ini2
11 files changed, 46 insertions, 133 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 9debc09e09c..a5e5a6fc305 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1261,7 +1261,7 @@ dependencies = [
[[package]]
name = "derive_common"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"darling",
"proc-macro2",
@@ -3636,7 +3636,7 @@ dependencies = [
[[package]]
name = "malloc_size_of"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"accountable-refcell",
"app_units",
@@ -5241,7 +5241,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.24.0"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"bitflags 2.5.0",
"cssparser",
@@ -5529,7 +5529,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.2.0"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"nodrop",
"serde",
@@ -5539,7 +5539,7 @@ dependencies = [
[[package]]
name = "servo_atoms"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"string_cache",
"string_cache_codegen",
@@ -5737,7 +5737,7 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]]
name = "size_of_test"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"static_assertions",
]
@@ -5878,7 +5878,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "static_prefs"
version = "0.1.0"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
[[package]]
name = "strict-num"
@@ -5915,7 +5915,7 @@ dependencies = [
[[package]]
name = "style"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"app_units",
"arrayvec",
@@ -5974,7 +5974,7 @@ dependencies = [
[[package]]
name = "style_config"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"lazy_static",
]
@@ -5982,7 +5982,7 @@ dependencies = [
[[package]]
name = "style_derive"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"darling",
"derive_common",
@@ -6013,7 +6013,7 @@ dependencies = [
[[package]]
name = "style_traits"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"app_units",
"bitflags 2.5.0",
@@ -6376,7 +6376,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "to_shmem"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"cssparser",
"servo_arc",
@@ -6389,7 +6389,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.0.1"
-source = "git+https://github.com/servo/stylo?branch=2024-04-16#fde1b946c24db389f150752cc24c6496b1f537c5"
+source = "git+https://github.com/servo/stylo?branch=2024-04-16#ac65c5a27c1b9faf9e7bb5bbcb3a4837a810ef6b"
dependencies = [
"darling",
"derive_common",
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index 41236cdc413..22f5aeec337 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -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);
diff --git a/components/layout_2020/fragment_tree/base_fragment.rs b/components/layout_2020/fragment_tree/base_fragment.rs
index 3dbb530a4c6..d7081cd0403 100644
--- a/components/layout_2020/fragment_tree/base_fragment.rs
+++ b/components/layout_2020/fragment_tree/base_fragment.rs
@@ -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;
}
}
diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs
index 5ea7cd826ce..952a6fff74b 100644
--- a/components/layout_2020/table/layout.rs
+++ b/components/layout_2020/table/layout.rs
@@ -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,
diff --git a/tests/wpt/meta/css/CSS2/tables/empty-cells-applies-to-014.xht.ini b/tests/wpt/meta/css/CSS2/tables/empty-cells-applies-to-014.xht.ini
deleted file mode 100644
index 226f84cb5f5..00000000000
--- a/tests/wpt/meta/css/CSS2/tables/empty-cells-applies-to-014.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[empty-cells-applies-to-014.xht]
- expected: FAIL
diff --git a/tests/wpt/meta/css/CSS2/tables/empty-cells-no-interpolation.html.ini b/tests/wpt/meta/css/CSS2/tables/empty-cells-no-interpolation.html.ini
index 028cd5dd90e..fee26795217 100644
--- a/tests/wpt/meta/css/CSS2/tables/empty-cells-no-interpolation.html.ini
+++ b/tests/wpt/meta/css/CSS2/tables/empty-cells-no-interpolation.html.ini
@@ -8,60 +8,6 @@
[CSS Transitions: property <empty-cells> from [initial\] to [hide\] at (0.3) should be [initial\]]
expected: FAIL
- [CSS Transitions: property <empty-cells> from [initial\] to [hide\] at (0.5) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions: property <empty-cells> from [initial\] to [hide\] at (0.6) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions: property <empty-cells> from [initial\] to [hide\] at (1) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions: property <empty-cells> from [initial\] to [hide\] at (1.5) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition: all: property <empty-cells> from [initial\] to [hide\] at (-0.3) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition: all: property <empty-cells> from [initial\] to [hide\] at (0) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition: all: property <empty-cells> from [initial\] to [hide\] at (0.3) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition: all: property <empty-cells> from [initial\] to [hide\] at (0.5) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition: all: property <empty-cells> from [initial\] to [hide\] at (0.6) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition: all: property <empty-cells> from [initial\] to [hide\] at (1) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition: all: property <empty-cells> from [initial\] to [hide\] at (1.5) should be [hide\]]
- expected: FAIL
-
- [CSS Animations: property <empty-cells> from [initial\] to [hide\] at (-0.3) should be [initial\]]
- expected: FAIL
-
- [CSS Animations: property <empty-cells> from [initial\] to [hide\] at (0) should be [initial\]]
- expected: FAIL
-
- [CSS Animations: property <empty-cells> from [initial\] to [hide\] at (0.3) should be [initial\]]
- expected: FAIL
-
- [CSS Animations: property <empty-cells> from [initial\] to [hide\] at (0.5) should be [hide\]]
- expected: FAIL
-
- [CSS Animations: property <empty-cells> from [initial\] to [hide\] at (0.6) should be [hide\]]
- expected: FAIL
-
- [CSS Animations: property <empty-cells> from [initial\] to [hide\] at (1) should be [hide\]]
- expected: FAIL
-
- [CSS Animations: property <empty-cells> from [initial\] to [hide\] at (1.5) should be [hide\]]
- expected: FAIL
-
[Web Animations: property <empty-cells> from [initial\] to [hide\] at (-0.3) should be [initial\]]
expected: FAIL
@@ -83,15 +29,6 @@
[Web Animations: property <empty-cells> from [initial\] to [hide\] at (1.5) should be [hide\]]
expected: FAIL
- [CSS Transitions: property <empty-cells> from [initial\] to [hide\] at (-0.3) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions: property <empty-cells> from [initial\] to [hide\] at (0) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions: property <empty-cells> from [initial\] to [hide\] at (0.3) should be [hide\]]
- expected: FAIL
-
[CSS Transitions with transition-behavior:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (-0.3) should be [initial\]]
expected: FAIL
@@ -101,18 +38,6 @@
[CSS Transitions with transition-behavior:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (0.3) should be [initial\]]
expected: FAIL
- [CSS Transitions with transition-behavior:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (0.5) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition-behavior:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (0.6) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition-behavior:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (1) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition-behavior:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (1.5) should be [hide\]]
- expected: FAIL
-
[CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (-0.3) should be [initial\]]
expected: FAIL
@@ -121,15 +46,3 @@
[CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (0.3) should be [initial\]]
expected: FAIL
-
- [CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (0.5) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (0.6) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (1) should be [hide\]]
- expected: FAIL
-
- [CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <empty-cells> from [initial\] to [hide\] at (1.5) should be [hide\]]
- expected: FAIL
diff --git a/tests/wpt/meta/css/css-tables/inheritance.html.ini b/tests/wpt/meta/css/css-tables/inheritance.html.ini
index fda506bd73c..26943f34e40 100644
--- a/tests/wpt/meta/css/css-tables/inheritance.html.ini
+++ b/tests/wpt/meta/css/css-tables/inheritance.html.ini
@@ -8,12 +8,6 @@
[Property caption-side inherits]
expected: FAIL
- [Property empty-cells has initial value show]
- expected: FAIL
-
- [Property empty-cells inherits]
- expected: FAIL
-
[Property table-layout has initial value auto]
expected: FAIL
diff --git a/tests/wpt/meta/css/css-tables/parsing/empty-cells-computed.html.ini b/tests/wpt/meta/css/css-tables/parsing/empty-cells-computed.html.ini
deleted file mode 100644
index f1aad1c8bce..00000000000
--- a/tests/wpt/meta/css/css-tables/parsing/empty-cells-computed.html.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[empty-cells-computed.html]
- [Property empty-cells value 'show']
- expected: FAIL
-
- [Property empty-cells value 'hide']
- expected: FAIL
diff --git a/tests/wpt/meta/css/css-tables/parsing/empty-cells-valid.html.ini b/tests/wpt/meta/css/css-tables/parsing/empty-cells-valid.html.ini
deleted file mode 100644
index f784e99e4a5..00000000000
--- a/tests/wpt/meta/css/css-tables/parsing/empty-cells-valid.html.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[empty-cells-valid.html]
- [e.style['empty-cells'\] = "show" should set the property value]
- expected: FAIL
-
- [e.style['empty-cells'\] = "hide" should set the property value]
- expected: FAIL
diff --git a/tests/wpt/meta/css/cssom/serialize-values.html.ini b/tests/wpt/meta/css/cssom/serialize-values.html.ini
index 2110b7a1028..9cfeee8435b 100644
--- a/tests/wpt/meta/css/cssom/serialize-values.html.ini
+++ b/tests/wpt/meta/css/cssom/serialize-values.html.ini
@@ -101,15 +101,6 @@
[direction: inherit]
expected: FAIL
- [empty-cells: show]
- expected: FAIL
-
- [empty-cells: hide]
- expected: FAIL
-
- [empty-cells: inherit]
- expected: FAIL
-
[table-layout: auto]
expected: FAIL
diff --git a/tests/wpt/mozilla/meta/css/empty_cells_a.html.ini b/tests/wpt/mozilla/meta/css/empty_cells_a.html.ini
deleted file mode 100644
index c33581d6260..00000000000
--- a/tests/wpt/mozilla/meta/css/empty_cells_a.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[empty_cells_a.html]
- expected: FAIL