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 ToTyped,
70)]
71pub struct GenericLetterSpacing<L>(pub L);
72pub type LetterSpacing = GenericLetterSpacing<LengthPercentage>;
74
75impl LetterSpacing {
76 #[inline]
78 pub fn normal() -> Self {
79 Self(LengthPercentage::zero())
80 }
81}
82
83impl ToCss for LetterSpacing {
84 fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
85 where
86 W: Write,
87 {
88 if self.0.is_zero() {
93 return dest.write_str("normal");
94 }
95 self.0.to_css(dest)
96 }
97}
98
99pub type WordSpacing = LengthPercentage;
101
102impl WordSpacing {
103 #[inline]
105 pub fn normal() -> Self {
106 LengthPercentage::zero()
107 }
108}
109
110#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue, ToTyped)]
112#[allow(missing_docs)]
113#[repr(C, u8)]
114pub enum TextEmphasisStyle {
115 Keyword {
117 #[css(skip_if = "TextEmphasisFillMode::is_filled")]
118 fill: TextEmphasisFillMode,
119 shape: TextEmphasisShapeKeyword,
120 },
121 None,
123 String(crate::OwnedStr),
125}