style: adding from-font support to text-underline-offset and text-decoration-thickness.

Differential Revision: https://phabricator.services.mozilla.com/D41476
This commit is contained in:
Charlie Marlow 2019-08-13 17:43:25 +00:00 committed by Emilio Cobos Álvarez
parent 566f1ea600
commit cf7b0e13b6
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
7 changed files with 59 additions and 9 deletions

View file

@ -382,8 +382,8 @@ ${helpers.single_keyword(
// text underline offset
${helpers.predefined_type(
"text-underline-offset",
"LengthOrAuto",
"computed::LengthOrAuto::auto()",
"TextDecorationLength",
"generics::text::GenericTextDecorationLength::Auto",
engines="gecko",
animation_value_type="ComputedValue",
gecko_pref="layout.css.text-underline-offset.enabled",

View file

@ -71,10 +71,10 @@ ${helpers.predefined_type(
${helpers.predefined_type(
"text-decoration-thickness",
"LengthOrAuto",
"computed::LengthOrAuto::auto()",
"TextDecorationLength",
"generics::text::GenericTextDecorationLength::Auto",
engines="gecko",
initial_specified_value="specified::LengthOrAuto::auto()",
initial_specified_value="generics::text::GenericTextDecorationLength::Auto",
animation_value_type="ComputedValue",
gecko_pref="layout.css.text-decoration-thickness.enabled",
spec="https://drafts.csswg.org/css-text-decor-4/#text-decoration-width-property"

View file

@ -76,7 +76,7 @@ pub use self::svg::MozContextProperties;
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
pub use self::table::XSpan;
pub use self::text::TextDecorationSkipInk;
pub use self::text::{TextDecorationLength, TextDecorationSkipInk};
pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight};
pub use self::text::{OverflowWrap, TextOverflow, WordBreak, WordSpacing};
pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle};

View file

@ -10,7 +10,7 @@ use crate::values::computed::length::{Length, LengthPercentage};
use crate::values::computed::{Context, NonNegativeLength, NonNegativeNumber, ToComputedValue};
use crate::values::generics::text::InitialLetter as GenericInitialLetter;
use crate::values::generics::text::LineHeight as GenericLineHeight;
use crate::values::generics::text::Spacing;
use crate::values::generics::text::{Spacing, GenericTextDecorationLength};
use crate::values::specified::text::{self as specified, TextOverflowSide};
use crate::values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword};
use crate::values::{CSSFloat, CSSInteger};
@ -26,6 +26,9 @@ pub use crate::values::specified::{TextDecorationSkipInk, TextTransform};
/// A computed value for the `initial-letter` property.
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
/// Implements type for `text-underline-offset` and `text-decoration-thickness` properties
pub type TextDecorationLength = GenericTextDecorationLength<Length>;
/// A computed value for the `letter-spacing` property.
#[repr(transparent)]
#[derive(

View file

@ -122,3 +122,33 @@ impl<N, L> LineHeight<N, L> {
LineHeight::Normal
}
}
/// Implements type for text-underline-offset and text-decoration-thickness
/// which take the grammar of auto | from-font | <length>
///
/// https://drafts.csswg.org/css-text-decor-4/
#[repr(C, u8)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(
Animate,
Clone,
Copy,
ComputeSquaredDistance,
ToAnimatedZero,
Debug,
Eq,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[allow(missing_docs)]
pub enum GenericTextDecorationLength<L> {
Length(L),
Auto,
FromFont,
}

View file

@ -82,7 +82,7 @@ pub use self::table::XSpan;
pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight, TextAlign};
pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak};
pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing};
pub use self::text::{TextDecorationSkipInk, TextTransform};
pub use self::text::{TextDecorationLength, TextDecorationSkipInk, TextTransform};
pub use self::time::Time;
pub use self::transform::{Rotate, Scale, Transform};
pub use self::transform::{TransformOrigin, TransformStyle, Translate};

View file

@ -12,7 +12,7 @@ use crate::values::computed::text::TextOverflow as ComputedTextOverflow;
use crate::values::computed::{Context, ToComputedValue};
use crate::values::generics::text::InitialLetter as GenericInitialLetter;
use crate::values::generics::text::LineHeight as GenericLineHeight;
use crate::values::generics::text::Spacing;
use crate::values::generics::text::{Spacing, GenericTextDecorationLength};
use crate::values::specified::length::NonNegativeLengthPercentage;
use crate::values::specified::length::{FontRelativeLength, Length};
use crate::values::specified::length::{LengthPercentage, NoCalcLength};
@ -1039,3 +1039,20 @@ pub enum TextDecorationSkipInk {
Auto,
None,
}
/// Implements type for `text-underline-offset` and `text-decoration-thickness` properties
pub type TextDecorationLength = GenericTextDecorationLength<Length>;
impl TextDecorationLength {
/// `Auto` value.
#[inline]
pub fn auto() -> Self {
GenericTextDecorationLength::Auto
}
/// Whether this is the `Auto` value.
#[inline]
pub fn is_auto(&self) -> bool {
matches!(*self, GenericTextDecorationLength::Auto)
}
}