mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
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:
parent
566f1ea600
commit
cf7b0e13b6
7 changed files with 59 additions and 9 deletions
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue