Add support for text-decoration-style

This commit is contained in:
Fernando Jiménez Moreno 2020-03-04 12:35:47 +01:00
parent 928bd0d1d2
commit 689b413bde
3 changed files with 22 additions and 3 deletions

View file

@ -4,6 +4,7 @@
use crate::geom::{PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize};
use style::computed_values::mix_blend_mode::T as ComputedMixBlendMode;
use style::computed_values::text_decoration_style::T as ComputedTextDecorationStyle;
use style::computed_values::transform_style::T as ComputedTransformStyle;
use style::values::computed::Filter as ComputedFilter;
use style::values::computed::Length;
@ -100,3 +101,16 @@ impl ToWebRender for PhysicalSides<Length> {
)
}
}
impl ToWebRender for ComputedTextDecorationStyle {
type Type = webrender_api::LineStyle;
fn to_webrender(&self) -> Self::Type {
match *self {
ComputedTextDecorationStyle::Solid => wr::LineStyle::Solid,
ComputedTextDecorationStyle::Dotted => wr::LineStyle::Dotted,
ComputedTextDecorationStyle::Dashed => wr::LineStyle::Dashed,
ComputedTextDecorationStyle::Wavy => wr::LineStyle::Wavy,
_ => wr::LineStyle::Solid,
}
}
}

View file

@ -13,9 +13,9 @@ use gfx::text::glyph::GlyphStore;
use mitochondria::OnceCell;
use net_traits::image_cache::UsePlaceholder;
use std::sync::Arc;
use style::computed_values::text_decoration_style::T as ComputedTextDecorationStyle;
use style::dom::OpaqueNode;
use style::properties::ComputedValues;
use style::values::computed::{BorderStyle, Length, LengthPercentage};
use style::values::specified::ui::CursorKind;
use webrender_api::{self as wr, units};
@ -182,14 +182,19 @@ impl Fragment {
.parent_style
.clone_text_decoration_color()
.to_rgba(color);
let text_decoration_style = fragment.parent_style.clone_text_decoration_style();
if text_decoration_style == ComputedTextDecorationStyle::MozNone {
return;
}
builder.wr.push_line(
&builder.common_properties(rect),
&rect,
wavy_line_thickness,
wr::LineOrientation::Horizontal,
&rgba(text_decoration_color),
wr::LineStyle::Solid,
text_decoration_style.to_webrender(),
);
// XXX(ferjm) support text-decoration-style: double
}
}

View file

@ -41,7 +41,7 @@ ${helpers.predefined_type(
${helpers.single_keyword(
"text-decoration-style",
"solid double dotted dashed wavy -moz-none",
engines="gecko",
engines="gecko servo-2020",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-style",
)}