mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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:
parent
3bcab36248
commit
38847d4991
3 changed files with 27 additions and 18 deletions
|
@ -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, ¤t_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,
|
||||
|
|
|
@ -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(), ¤t_color),
|
||||
containing_block_writing_mode,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[border-conflict-element-001e.xht]
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue