aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2025-01-27 11:58:18 -0800
committerGitHub <noreply@github.com>2025-01-27 19:58:18 +0000
commit38847d4991b14752a20f6cac3649b90f6e1fdcff (patch)
tree2cdf6e817bd5a08dc8c595f919c2de7dbec26e56
parent3bcab362485bb48b1eabd83b7a2a03b1aaf178f8 (diff)
downloadservo-38847d4991b14752a20f6cac3649b90f6e1fdcff.tar.gz
servo-38847d4991b14752a20f6cac3649b90f6e1fdcff.zip
layout: Correctly resolve `currentcolor` on collapsed borders (#35163)
If a collapsed border has the `currentcolor` color, we were resolving it using the color of the table. Now we resolve it using the color of the box which owns the border that wins and becomes the collapsed border. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
-rw-r--r--components/layout_2020/display_list/mod.rs14
-rw-r--r--components/layout_2020/style_ext.rs29
-rw-r--r--tests/wpt/meta/css/CSS2/tables/border-conflict-element-001e.xht.ini2
3 files changed, 27 insertions, 18 deletions
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index 6fd9be1c8aa..cc352bfe86c 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -886,7 +886,7 @@ impl<'a> BuilderForBoxFragment<'a> {
fn build_border_side(&mut self, style_color: BorderStyleColor) -> wr::BorderSide {
wr::BorderSide {
- color: rgba(self.fragment.style.resolve_color(style_color.color)),
+ color: rgba(style_color.color),
style: match style_color.style {
BorderStyle::None => wr::BorderStyle::None,
BorderStyle::Solid => wr::BorderStyle::Solid,
@@ -986,7 +986,8 @@ impl<'a> BuilderForBoxFragment<'a> {
return;
}
- let style_color = BorderStyleColor::from_border(border);
+ let current_color = self.fragment.style.get_inherited_text().clone_color();
+ let style_color = BorderStyleColor::from_border(border, &current_color);
let details = wr::BorderDetails::Normal(wr::NormalBorder {
top: self.build_border_side(style_color.top),
right: self.build_border_side(style_color.right),
@@ -1095,7 +1096,8 @@ impl<'a> BuilderForBoxFragment<'a> {
}
fn build_outline(&mut self, builder: &mut DisplayListBuilder) {
- let outline = self.fragment.style.get_outline();
+ let style = &self.fragment.style;
+ let outline = style.get_outline();
let width = outline.outline_width.to_f32_px();
if width == 0.0 {
return;
@@ -1109,15 +1111,15 @@ impl<'a> BuilderForBoxFragment<'a> {
let outline_rect = self.border_rect.inflate(offset, offset);
let common = builder.common_properties(outline_rect, &self.fragment.style);
let widths = SideOffsets2D::new_all_same(width);
- let style = match outline.outline_style {
+ let border_style = match outline.outline_style {
// TODO: treating 'auto' as 'solid' is allowed by the spec,
// but we should do something better.
OutlineStyle::Auto => BorderStyle::Solid,
OutlineStyle::BorderStyle(s) => s,
};
let side = self.build_border_side(BorderStyleColor {
- style,
- color: outline.outline_color.clone(),
+ style: border_style,
+ color: style.resolve_color(outline.outline_color.clone()),
});
let details = wr::BorderDetails::Normal(wr::NormalBorder {
top: side,
diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs
index 027ce11564e..b103cf89e42 100644
--- a/components/layout_2020/style_ext.rs
+++ b/components/layout_2020/style_ext.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use app_units::Au;
+use style::color::AbsoluteColor;
use style::computed_values::direction::T as Direction;
use style::computed_values::mix_blend_mode::T as ComputedMixBlendMode;
use style::computed_values::position::T as ComputedPosition;
@@ -221,34 +222,41 @@ pub(crate) struct ContentBoxSizesAndPBMDeprecated {
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct BorderStyleColor {
pub style: BorderStyle,
- pub color: Color,
+ pub color: AbsoluteColor,
}
impl BorderStyleColor {
- pub(crate) fn new(style: BorderStyle, color: Color) -> Self {
+ pub(crate) fn new(style: BorderStyle, color: AbsoluteColor) -> Self {
Self { style, color }
}
- pub(crate) fn from_border(border: &Border) -> PhysicalSides<Self> {
+ pub(crate) fn from_border(
+ border: &Border,
+ current_color: &AbsoluteColor,
+ ) -> PhysicalSides<Self> {
+ let resolve = |color: &Color| color.resolve_to_absolute(current_color);
PhysicalSides::<Self>::new(
- Self::new(border.border_top_style, border.border_top_color.clone()),
- Self::new(border.border_right_style, border.border_right_color.clone()),
+ Self::new(border.border_top_style, resolve(&border.border_top_color)),
+ Self::new(
+ border.border_right_style,
+ resolve(&border.border_right_color),
+ ),
Self::new(
border.border_bottom_style,
- border.border_bottom_color.clone(),
+ resolve(&border.border_bottom_color),
),
- Self::new(border.border_left_style, border.border_left_color.clone()),
+ Self::new(border.border_left_style, resolve(&border.border_left_color)),
)
}
pub(crate) fn hidden() -> Self {
- Self::new(BorderStyle::Hidden, Color::TRANSPARENT_BLACK)
+ Self::new(BorderStyle::Hidden, AbsoluteColor::TRANSPARENT_BLACK)
}
}
impl Default for BorderStyleColor {
fn default() -> Self {
- Self::new(BorderStyle::None, Color::TRANSPARENT_BLACK)
+ Self::new(BorderStyle::None, AbsoluteColor::TRANSPARENT_BLACK)
}
}
@@ -440,8 +448,9 @@ impl ComputedValuesExt for ComputedValues {
&self,
containing_block_writing_mode: WritingMode,
) -> LogicalSides<BorderStyleColor> {
+ let current_color = self.get_inherited_text().clone_color();
LogicalSides::from_physical(
- &BorderStyleColor::from_border(self.get_border()),
+ &BorderStyleColor::from_border(self.get_border(), &current_color),
containing_block_writing_mode,
)
}
diff --git a/tests/wpt/meta/css/CSS2/tables/border-conflict-element-001e.xht.ini b/tests/wpt/meta/css/CSS2/tables/border-conflict-element-001e.xht.ini
deleted file mode 100644
index e1491b7dd3c..00000000000
--- a/tests/wpt/meta/css/CSS2/tables/border-conflict-element-001e.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[border-conflict-element-001e.xht]
- expected: FAIL