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