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>
This commit is contained in:
Oriol Brufau 2025-01-27 11:58:18 -08:00 committed by GitHub
parent 3bcab36248
commit 38847d4991
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 18 deletions

View file

@ -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,