aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-01-23 13:55:01 +0100
committerGitHub <noreply@github.com>2024-01-23 12:55:01 +0000
commit54fb381a0a4c070bac75e9f602bf905fa101194d (patch)
tree1a40ea5debfe55b81df1c4b445475a1abc508bf4
parent890588945d2f0b9ad28d024d5a1ba2fb85542637 (diff)
downloadservo-54fb381a0a4c070bac75e9f602bf905fa101194d.tar.gz
servo-54fb381a0a4c070bac75e9f602bf905fa101194d.zip
layout: Convert layout internal display to inline for replaced elements (#31133)
Replaced elements should never be able to have a layout internal display, according to the specification. This change makes it so that the used value of replaced element's display is always inline, as the specification says.
-rw-r--r--components/layout_2020/dom_traversal.rs1
-rw-r--r--components/layout_2020/style_ext.rs18
-rw-r--r--components/layout_2020/table/construct.rs2
-rw-r--r--tests/wpt/meta/css/CSS2/tables/table-anonymous-objects-211.xht.ini2
-rw-r--r--tests/wpt/meta/css/css-tables/table-model-fixup-2.html.ini78
5 files changed, 22 insertions, 79 deletions
diff --git a/components/layout_2020/dom_traversal.rs b/components/layout_2020/dom_traversal.rs
index 47c1f4bff5a..ca8ec9037ad 100644
--- a/components/layout_2020/dom_traversal.rs
+++ b/components/layout_2020/dom_traversal.rs
@@ -172,6 +172,7 @@ fn traverse_element<'dom, Node>(
},
Display::GeneratingBox(display) => {
let contents = replaced.map_or(Contents::OfElement, Contents::Replaced);
+ let display = display.used_value_for_contents(&contents);
let box_slot = element.element_box_slot();
let info = NodeAndStyleInfo::new(element, style);
handler.handle_element(&info, display, contents, box_slot);
diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs
index b00551203b8..8df270589bd 100644
--- a/components/layout_2020/style_ext.rs
+++ b/components/layout_2020/style_ext.rs
@@ -21,6 +21,7 @@ use style::values::specified::{box_ as stylo, Overflow};
use style::Zero;
use webrender_api as wr;
+use crate::dom_traversal::Contents;
use crate::geom::{
LengthOrAuto, LengthPercentageOrAuto, LogicalSides, LogicalVec2, PhysicalSides, PhysicalSize,
};
@@ -52,6 +53,23 @@ impl DisplayGeneratingBox {
},
}
}
+
+ pub(crate) fn used_value_for_contents(&self, contents: &Contents) -> Self {
+ // From <https://www.w3.org/TR/css-display-3/#layout-specific-display>:
+ // > When the display property of a replaced element computes to one of
+ // > the layout-internal values, it is handled as having a used value of
+ // > inline.
+ if matches!(self, Self::LayoutInternal(_)) && contents.is_replaced() {
+ Self::OutsideInside {
+ outside: DisplayOutside::Inline,
+ inside: DisplayInside::Flow {
+ is_list_item: false,
+ },
+ }
+ } else {
+ *self
+ }
+ }
}
#[derive(Clone, Copy, Eq, PartialEq)]
diff --git a/components/layout_2020/table/construct.rs b/components/layout_2020/table/construct.rs
index 3dd0c01e977..bd183a2519d 100644
--- a/components/layout_2020/table/construct.rs
+++ b/components/layout_2020/table/construct.rs
@@ -679,7 +679,7 @@ where
)
},
Err(_replaced) => {
- panic!("We don't handle this yet.");
+ unreachable!("Replaced should not have a LayoutInternal display type.");
},
};
diff --git a/tests/wpt/meta/css/CSS2/tables/table-anonymous-objects-211.xht.ini b/tests/wpt/meta/css/CSS2/tables/table-anonymous-objects-211.xht.ini
index ffab45b50d2..b9705067946 100644
--- a/tests/wpt/meta/css/CSS2/tables/table-anonymous-objects-211.xht.ini
+++ b/tests/wpt/meta/css/CSS2/tables/table-anonymous-objects-211.xht.ini
@@ -1,2 +1,2 @@
[table-anonymous-objects-211.xht]
- expected: CRASH
+ expected: FAIL
diff --git a/tests/wpt/meta/css/css-tables/table-model-fixup-2.html.ini b/tests/wpt/meta/css/css-tables/table-model-fixup-2.html.ini
index 37c7bd47beb..e0fca6d7734 100644
--- a/tests/wpt/meta/css/css-tables/table-model-fixup-2.html.ini
+++ b/tests/wpt/meta/css/css-tables/table-model-fixup-2.html.ini
@@ -1,85 +1,9 @@
[table-model-fixup-2.html]
- expected: CRASH
- [Replaced elements inside a table cannot be table-row and are considered inline -- input elements (top)]
- expected: FAIL
-
- [Replaced elements inside a table cannot be table-row and are considered inline -- img elements (top)]
- expected: FAIL
-
[Replaced elements inside a table cannot be table-column and are considered inline -- input elements (width)]
expected: FAIL
- [Replaced elements inside a table cannot be table-column and are considered inline -- input elements (top)]
- expected: FAIL
-
- [Replaced elements inside a table cannot be table-column and are considered inline -- img elements (top)]
- expected: FAIL
-
[Replaced elements inside a table cannot be table-cell and are considered inline -- input elements (width)]
expected: FAIL
- [Replaced elements inside a table cannot be table-cell and are considered inline -- input elements (top)]
- expected: FAIL
-
- [Replaced elements inside a table cannot be table-cell and are considered inline -- img elements (top)]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-row and are considered inline -- input=text elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-row and are considered inline -- input=button elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-row and are considered inline -- input=file elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-row and are considered inline -- img elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-row-group and are considered inline -- input=text elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-row-group and are considered inline -- input=button elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-row-group and are considered inline -- input=file elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-row-group and are considered inline -- img elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-column and are considered inline inline -- input=text elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-column and are considered inline -- input=button elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-column and are considered inline -- input=file elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-column and are considered inline -- img elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-cell and are considered inline -- input=text elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-cell and are considered inline -- input=button elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-cell and are considered inline -- input=file elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-cell and are considered inline -- img elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-caption and are considered inline -- input=text elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-caption and are considered inline -- input=button elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-caption and are considered inline -- input=file elements]
- expected: FAIL
-
- [Replaced elements outside a table cannot be table-caption and are considered inline -- img elements]
+ [Replaced elements inside a table cannot be table-row and are considered inline -- input elements (width)]
expected: FAIL