style: Move the from-font value from text-underline-offset to text-underline-position, as per recent spec changes, and fix interaction between position and offset.

Differential Revision: https://phabricator.services.mozilla.com/D59778
This commit is contained in:
Jonathan Kew 2020-02-03 14:38:28 +00:00 committed by Emilio Cobos Álvarez
parent 2910ca6197
commit df01cec675
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
4 changed files with 22 additions and 14 deletions

View file

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

View file

@ -27,7 +27,7 @@ pub use crate::values::specified::{TextDecorationSkipInk, TextTransform};
/// A computed value for the `initial-letter` property. /// A computed value for the `initial-letter` property.
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>; pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
/// Implements type for `text-underline-offset` and `text-decoration-thickness` properties /// Implements type for `text-decoration-thickness` property.
pub type TextDecorationLength = GenericTextDecorationLength<LengthPercentage>; pub type TextDecorationLength = GenericTextDecorationLength<LengthPercentage>;
/// A computed value for the `letter-spacing` property. /// A computed value for the `letter-spacing` property.

View file

@ -123,8 +123,8 @@ impl<N, L> LineHeight<N, L> {
} }
} }
/// Implements type for text-underline-offset and text-decoration-thickness /// Implements type for text-decoration-thickness
/// which take the grammar of auto | from-font | <length> | <percentage> /// which takes the grammar of auto | from-font | <length> | <percentage>
/// ///
/// https://drafts.csswg.org/css-text-decor-4/ /// https://drafts.csswg.org/css-text-decor-4/
#[repr(C, u8)] #[repr(C, u8)]

View file

@ -1029,7 +1029,7 @@ pub enum TextDecorationSkipInk {
None, None,
} }
/// Implements type for `text-underline-offset` and `text-decoration-thickness` properties /// Implements type for `text-decoration-thickness` property
pub type TextDecorationLength = GenericTextDecorationLength<LengthPercentage>; pub type TextDecorationLength = GenericTextDecorationLength<LengthPercentage>;
impl TextDecorationLength { impl TextDecorationLength {
@ -1048,21 +1048,23 @@ impl TextDecorationLength {
bitflags! { bitflags! {
#[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)]
#[value_info(other_values = "auto,under,left,right")] #[value_info(other_values = "auto,from-font,under,left,right")]
#[repr(C)] #[repr(C)]
/// Specified keyword values for the text-underline-position property. /// Specified keyword values for the text-underline-position property.
/// (Non-exclusive, but not all combinations are allowed: only `under` may occur /// (Non-exclusive, but not all combinations are allowed: the spec grammar gives
/// together with either `left` or `right`.) /// `auto | [ from-font | under ] || [ left | right ]`.)
/// https://drafts.csswg.org/css-text-decor-3/#text-underline-position-property /// https://drafts.csswg.org/css-text-decor-4/#text-underline-position-property
pub struct TextUnderlinePosition: u8 { pub struct TextUnderlinePosition: u8 {
/// Use automatic positioning below the alphabetic baseline. /// Use automatic positioning below the alphabetic baseline.
const AUTO = 0; const AUTO = 0;
/// Use underline position from the first available font.
const FROM_FONT = 1 << 0;
/// Below the glyph box. /// Below the glyph box.
const UNDER = 1 << 0; const UNDER = 1 << 1;
/// In vertical mode, place to the left of the text. /// In vertical mode, place to the left of the text.
const LEFT = 1 << 1; const LEFT = 1 << 2;
/// In vertical mode, place to the right of the text. /// In vertical mode, place to the right of the text.
const RIGHT = 1 << 2; const RIGHT = 1 << 3;
} }
} }
@ -1085,7 +1087,12 @@ impl Parse for TextUnderlinePosition {
"auto" if result.is_empty() => { "auto" if result.is_empty() => {
return Ok(result); return Ok(result);
}, },
"under" if !result.intersects(TextUnderlinePosition::UNDER) => { "from-font" if !result.intersects(TextUnderlinePosition::FROM_FONT |
TextUnderlinePosition::UNDER) => {
result.insert(TextUnderlinePosition::FROM_FONT);
},
"under" if !result.intersects(TextUnderlinePosition::FROM_FONT |
TextUnderlinePosition::UNDER) => {
result.insert(TextUnderlinePosition::UNDER); result.insert(TextUnderlinePosition::UNDER);
}, },
"left" if !result.intersects(TextUnderlinePosition::LEFT | "left" if !result.intersects(TextUnderlinePosition::LEFT |
@ -1131,6 +1138,7 @@ impl ToCss for TextUnderlinePosition {
}; };
} }
maybe_write!(FROM_FONT => "from-font");
maybe_write!(UNDER => "under"); maybe_write!(UNDER => "under");
maybe_write!(LEFT => "left"); maybe_write!(LEFT => "left");
maybe_write!(RIGHT => "right"); maybe_write!(RIGHT => "right");