mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Add support for text-decoration-color
This commit is contained in:
parent
107af9e769
commit
928bd0d1d2
2 changed files with 10 additions and 6 deletions
|
@ -128,7 +128,6 @@ impl Fragment {
|
||||||
common.hit_info = hit_info(&fragment.parent_style, fragment.tag, Cursor::Text);
|
common.hit_info = hit_info(&fragment.parent_style, fragment.tag, Cursor::Text);
|
||||||
|
|
||||||
let color = fragment.parent_style.clone_color();
|
let color = fragment.parent_style.clone_color();
|
||||||
|
|
||||||
let text_decorations = fragment
|
let text_decorations = fragment
|
||||||
.parent_style
|
.parent_style
|
||||||
.get_inherited_text()
|
.get_inherited_text()
|
||||||
|
@ -140,14 +139,14 @@ impl Fragment {
|
||||||
let mut rect = rect;
|
let mut rect = rect;
|
||||||
rect.origin.y = rect.origin.y + font_metrics.ascent - font_metrics.underline_offset;
|
rect.origin.y = rect.origin.y + font_metrics.ascent - font_metrics.underline_offset;
|
||||||
rect.size.height = font_metrics.underline_size;
|
rect.size.height = font_metrics.underline_size;
|
||||||
self.build_display_list_for_text_decoration(builder, &rect, color);
|
self.build_display_list_for_text_decoration(fragment, builder, &rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overline.
|
// Overline.
|
||||||
if text_decorations.overline {
|
if text_decorations.overline {
|
||||||
let mut rect = rect;
|
let mut rect = rect;
|
||||||
rect.size.height = font_metrics.underline_size;
|
rect.size.height = font_metrics.underline_size;
|
||||||
self.build_display_list_for_text_decoration(builder, &rect, color);
|
self.build_display_list_for_text_decoration(fragment, builder, &rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text.
|
// Text.
|
||||||
|
@ -166,24 +165,29 @@ impl Fragment {
|
||||||
rect.origin.y = rect.origin.y + font_metrics.ascent - font_metrics.strikeout_offset;
|
rect.origin.y = rect.origin.y + font_metrics.ascent - font_metrics.strikeout_offset;
|
||||||
// XXX(ferjm) This does not work on MacOS #942
|
// XXX(ferjm) This does not work on MacOS #942
|
||||||
rect.size.height = font_metrics.strikeout_size;
|
rect.size.height = font_metrics.strikeout_size;
|
||||||
self.build_display_list_for_text_decoration(builder, &rect, color);
|
self.build_display_list_for_text_decoration(fragment, builder, &rect, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_display_list_for_text_decoration(
|
fn build_display_list_for_text_decoration(
|
||||||
&self,
|
&self,
|
||||||
|
fragment: &TextFragment,
|
||||||
builder: &mut DisplayListBuilder,
|
builder: &mut DisplayListBuilder,
|
||||||
rect: &PhysicalRect<Length>,
|
rect: &PhysicalRect<Length>,
|
||||||
color: cssparser::RGBA,
|
color: cssparser::RGBA,
|
||||||
) {
|
) {
|
||||||
let rect = rect.to_webrender();
|
let rect = rect.to_webrender();
|
||||||
let wavy_line_thickness = (0.33 * rect.size.height).ceil();
|
let wavy_line_thickness = (0.33 * rect.size.height).ceil();
|
||||||
|
let text_decoration_color = fragment
|
||||||
|
.parent_style
|
||||||
|
.clone_text_decoration_color()
|
||||||
|
.to_rgba(color);
|
||||||
builder.wr.push_line(
|
builder.wr.push_line(
|
||||||
&builder.common_properties(rect),
|
&builder.common_properties(rect),
|
||||||
&rect,
|
&rect,
|
||||||
wavy_line_thickness,
|
wavy_line_thickness,
|
||||||
wr::LineOrientation::Horizontal,
|
wr::LineOrientation::Horizontal,
|
||||||
&rgba(color),
|
&rgba(text_decoration_color),
|
||||||
wr::LineStyle::Solid,
|
wr::LineStyle::Solid,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ ${helpers.predefined_type(
|
||||||
"text-decoration-color",
|
"text-decoration-color",
|
||||||
"Color",
|
"Color",
|
||||||
"computed_value::T::currentcolor()",
|
"computed_value::T::currentcolor()",
|
||||||
engines="gecko",
|
engines="gecko servo-2020",
|
||||||
initial_specified_value="specified::Color::currentcolor()",
|
initial_specified_value="specified::Color::currentcolor()",
|
||||||
animation_value_type="AnimatedColor",
|
animation_value_type="AnimatedColor",
|
||||||
ignored_when_colors_disabled=True,
|
ignored_when_colors_disabled=True,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue