style/values/computed/
text.rs1use crate::values::computed::length::{Length, LengthPercentage};
8use crate::values::generics::text::{
9 GenericHyphenateLimitChars, GenericInitialLetter, GenericTextDecorationLength,
10 GenericTextDecorationTrim, GenericTextIndent,
11};
12use crate::values::generics::NumberOrAuto;
13use crate::values::specified::text as specified;
14use crate::values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword};
15use crate::values::{CSSFloat, CSSInteger};
16use crate::Zero;
17use std::fmt::{self, Write};
18use style_traits::{CssWriter, ToCss};
19
20pub use crate::values::specified::text::{
21 HyphenateCharacter, LineBreak, MozControlCharacterVisibility, OverflowWrap, RubyPosition,
22 TextAlignLast, TextAutospace, TextDecorationLine, TextDecorationSkipInk, TextEmphasisPosition,
23 TextJustify, TextOverflow, TextTransform, TextUnderlinePosition, WordBreak,
24};
25
26pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
28
29pub type TextDecorationLength = GenericTextDecorationLength<LengthPercentage>;
31
32pub type TextDecorationTrim = GenericTextDecorationTrim<Length>;
34
35pub type TextAlign = specified::TextAlignKeyword;
37
38pub type TextIndent = GenericTextIndent<LengthPercentage>;
40
41pub type HyphenateLimitChars = GenericHyphenateLimitChars<CSSInteger>;
43
44impl HyphenateLimitChars {
45 #[inline]
47 pub fn auto() -> Self {
48 Self {
49 total_word_length: NumberOrAuto::Auto,
50 pre_hyphen_length: NumberOrAuto::Auto,
51 post_hyphen_length: NumberOrAuto::Auto,
52 }
53 }
54}
55
56#[repr(transparent)]
58#[derive(
59 Animate,
60 Clone,
61 ComputeSquaredDistance,
62 Copy,
63 Debug,
64 MallocSizeOf,
65 PartialEq,
66 ToAnimatedValue,
67 ToAnimatedZero,
68 ToResolvedValue,
69)]
70pub struct GenericLetterSpacing<L>(pub L);
71pub type LetterSpacing = GenericLetterSpacing<LengthPercentage>;
73
74impl LetterSpacing {
75 #[inline]
77 pub fn normal() -> Self {
78 Self(LengthPercentage::zero())
79 }
80}
81
82impl ToCss for LetterSpacing {
83 fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
84 where
85 W: Write,
86 {
87 if self.0.is_zero() {
92 return dest.write_str("normal");
93 }
94 self.0.to_css(dest)
95 }
96}
97
98pub type WordSpacing = LengthPercentage;
100
101impl WordSpacing {
102 #[inline]
104 pub fn normal() -> Self {
105 LengthPercentage::zero()
106 }
107}
108
109#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
111#[allow(missing_docs)]
112#[repr(C, u8)]
113pub enum TextEmphasisStyle {
114 Keyword {
116 #[css(skip_if = "TextEmphasisFillMode::is_filled")]
117 fill: TextEmphasisFillMode,
118 shape: TextEmphasisShapeKeyword,
119 },
120 None,
122 String(crate::OwnedStr),
124}