diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 3ce5891bb73..5ec5e6d414f 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -4709,22 +4709,22 @@ fn static_assert() { pub fn set_text_emphasis_style(&mut self, v: values::computed::TextEmphasisStyle) { use values::computed::TextEmphasisStyle; - use values::specified::text::{FillMode, ShapeKeyword}; + use values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword}; self.clear_text_emphasis_style_if_string(); let (te, s) = match v { TextEmphasisStyle::None => (structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE, ""), TextEmphasisStyle::Keyword(ref keyword) => { let fill = match keyword.fill { - FillMode::Filled => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_FILLED, - FillMode::Open => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN, + TextEmphasisFillMode::Filled => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_FILLED, + TextEmphasisFillMode::Open => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN, }; let shape = match keyword.shape { - ShapeKeyword::Dot => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT, - ShapeKeyword::Circle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE, - ShapeKeyword::DoubleCircle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE, - ShapeKeyword::Triangle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE, - ShapeKeyword::Sesame => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME, + TextEmphasisShapeKeyword::Dot => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT, + TextEmphasisShapeKeyword::Circle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE, + TextEmphasisShapeKeyword::DoubleCircle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE, + TextEmphasisShapeKeyword::Triangle => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE, + TextEmphasisShapeKeyword::Sesame => structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME, }; (shape | fill, keyword.shape.char(keyword.fill)) @@ -4752,8 +4752,8 @@ fn static_assert() { pub fn clone_text_emphasis_style(&self) -> values::computed::TextEmphasisStyle { use values::computed::TextEmphasisStyle; - use values::specified::text::{FillMode, ShapeKeyword}; - use values::computed::text::{KeywordValue}; + use values::computed::text::TextEmphasisKeywordValue; + use values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword}; if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE as u8 { return TextEmphasisStyle::None; @@ -4766,19 +4766,19 @@ fn static_assert() { let fill = self.gecko.mTextEmphasisStyle & structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN as u8 == 0; - let fill = if fill { FillMode::Filled } else { FillMode::Open }; + let fill = if fill { TextEmphasisFillMode::Filled } else { TextEmphasisFillMode::Open }; let shape = match self.gecko.mTextEmphasisStyle as u32 & !structs::NS_STYLE_TEXT_EMPHASIS_STYLE_OPEN { - structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT => ShapeKeyword::Dot, - structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE => ShapeKeyword::Circle, - structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE => ShapeKeyword::DoubleCircle, - structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE => ShapeKeyword::Triangle, - structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME => ShapeKeyword::Sesame, + structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOT => TextEmphasisShapeKeyword::Dot, + structs::NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE => TextEmphasisShapeKeyword::Circle, + structs::NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE => TextEmphasisShapeKeyword::DoubleCircle, + structs::NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE => TextEmphasisShapeKeyword::Triangle, + structs::NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME => TextEmphasisShapeKeyword::Sesame, _ => panic!("Unexpected value in style struct for text-emphasis-style property") }; - TextEmphasisStyle::Keyword(KeywordValue { fill, shape }) + TextEmphasisStyle::Keyword(TextEmphasisKeywordValue { fill, shape }) } ${impl_non_negative_length('_webkit_text_stroke_width', diff --git a/components/style/properties/shorthand/inherited_text.mako.rs b/components/style/properties/shorthand/inherited_text.mako.rs index 71359384697..95850f5c043 100644 --- a/components/style/properties/shorthand/inherited_text.mako.rs +++ b/components/style/properties/shorthand/inherited_text.mako.rs @@ -33,7 +33,7 @@ if color.is_some() || style.is_some() { Ok(expanded! { text_emphasis_color: unwrap_or_initial!(text_emphasis_color, color), - text_emphasis_style: unwrap_or_initial!(text_emphasis_style, style), // TODO: what? + text_emphasis_style: unwrap_or_initial!(text_emphasis_style, style), }) } else { Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 335a28d647e..a24ebc5073c 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -75,7 +75,7 @@ pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; pub use self::svg::MozContextProperties; pub use self::table::XSpan; pub use self::text::{InitialLetter, LetterSpacing, LineHeight, MozTabSize}; -pub use self::text::{TextAlign, TextOverflow, WordSpacing, TextEmphasisStyle}; +pub use self::text::{TextAlign, TextEmphasisStyle, TextOverflow, WordSpacing}; pub use self::time::Time; pub use self::transform::{Rotate, Scale, TimingFunction, Transform, TransformOperation}; pub use self::transform::{TransformOrigin, TransformStyle, Translate}; diff --git a/components/style/values/computed/text.rs b/components/style/values/computed/text.rs index 2238a5d6804..bbef98ae4bd 100644 --- a/components/style/values/computed/text.rs +++ b/components/style/values/computed/text.rs @@ -15,7 +15,7 @@ use values::generics::text::InitialLetter as GenericInitialLetter; use values::generics::text::LineHeight as GenericLineHeight; use values::generics::text::MozTabSize as GenericMozTabSize; use values::generics::text::Spacing; -use values::specified::text::{TextOverflowSide, TextDecorationLine, FillMode, ShapeKeyword}; +use values::specified::text::{TextDecorationLine, TextEmphasisFillMode, TextEmphasisShapeKeyword, TextOverflowSide}; pub use values::specified::TextAlignKeyword as TextAlign; @@ -156,18 +156,18 @@ pub type MozTabSize = GenericMozTabSize; #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub enum TextEmphasisStyle { /// Keyword value for the text-emphasis-style property (`filled` `open`) - Keyword(KeywordValue), + Keyword(TextEmphasisKeywordValue), /// `none` None, - /// String (will be used only first character) for the text-emphasis-style property + /// String (will be used only first grapheme cluster) for the text-emphasis-style property String(String), } /// Keyword value for the text-emphasis-style property #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] -pub struct KeywordValue { +pub struct TextEmphasisKeywordValue { /// fill for the text-emphasis-style property - pub fill: FillMode, + pub fill: TextEmphasisFillMode, /// shape for the text-emphasis-style property - pub shape: ShapeKeyword, + pub shape: TextEmphasisShapeKeyword, } diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs index 31e30ada2f9..fcb15650110 100644 --- a/components/style/values/specified/text.rs +++ b/components/style/values/specified/text.rs @@ -12,8 +12,8 @@ use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use unicode_segmentation::UnicodeSegmentation; use values::computed::{Context, ToComputedValue}; -use values::computed::text::KeywordValue as ComputedKeywordValue; use values::computed::text::LineHeight as ComputedLineHeight; +use values::computed::text::TextEmphasisKeywordValue as ComputedTextEmphasisKeywordValue; use values::computed::text::TextEmphasisStyle as ComputedTextEmphasisStyle; use values::computed::text::TextOverflow as ComputedTextOverflow; use values::generics::text::InitialLetter as GenericInitialLetter; @@ -522,37 +522,37 @@ impl ToComputedValue for TextAlign { #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub enum TextEmphasisStyle { /// - Keyword(KeywordValue), + Keyword(TextEmphasisKeywordValue), /// `none` None, - /// String (will be used only first character) for the text-emphasis-style property + /// String (will be used only first grapheme cluster) for the text-emphasis-style property String(String), } /// Keyword value for the text-emphasis-style property #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] -pub enum KeywordValue { +pub enum TextEmphasisKeywordValue { /// - Fill(FillMode), + Fill(TextEmphasisFillMode), /// - Shape(ShapeKeyword), + Shape(TextEmphasisShapeKeyword), /// - FillAndShape(FillMode, ShapeKeyword), + FillAndShape(TextEmphasisFillMode, TextEmphasisShapeKeyword), } -impl KeywordValue { - fn fill(&self) -> Option { +impl TextEmphasisKeywordValue { + fn fill(&self) -> Option { match *self { - KeywordValue::Fill(fill) | - KeywordValue::FillAndShape(fill, _) => Some(fill), + TextEmphasisKeywordValue::Fill(fill) | + TextEmphasisKeywordValue::FillAndShape(fill, _) => Some(fill), _ => None, } } - fn shape(&self) -> Option { + fn shape(&self) -> Option { match *self { - KeywordValue::Shape(shape) | - KeywordValue::FillAndShape(_, shape) => Some(shape), + TextEmphasisKeywordValue::Shape(shape) | + TextEmphasisKeywordValue::FillAndShape(_, shape) => Some(shape), _ => None, } } @@ -560,7 +560,7 @@ impl KeywordValue { /// Fill mode for the text-emphasis-style property #[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, ToCss)] -pub enum FillMode { +pub enum TextEmphasisFillMode { /// `filled` Filled, /// `open` @@ -569,7 +569,7 @@ pub enum FillMode { /// Shape keyword for the text-emphasis-style property #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)] -pub enum ShapeKeyword { +pub enum TextEmphasisShapeKeyword { /// `dot` Dot, /// `circle` @@ -582,16 +582,16 @@ pub enum ShapeKeyword { Sesame, } -impl ShapeKeyword { +impl TextEmphasisShapeKeyword { /// converts fill mode to a unicode char - pub fn char(&self, fill: FillMode) -> &str { - let fill = fill == FillMode::Filled; + pub fn char(&self, fill: TextEmphasisFillMode) -> &str { + let fill = fill == TextEmphasisFillMode::Filled; match *self { - ShapeKeyword::Dot => if fill { "\u{2022}" } else { "\u{25e6}" }, - ShapeKeyword::Circle => if fill { "\u{25cf}" } else { "\u{25cb}" }, - ShapeKeyword::DoubleCircle => if fill { "\u{25c9}" } else { "\u{25ce}" }, - ShapeKeyword::Triangle => if fill { "\u{25b2}" } else { "\u{25b3}" }, - ShapeKeyword::Sesame => if fill { "\u{fe45}" } else { "\u{fe46}" }, + TextEmphasisShapeKeyword::Dot => if fill { "\u{2022}" } else { "\u{25e6}" }, + TextEmphasisShapeKeyword::Circle => if fill { "\u{25cf}" } else { "\u{25cb}" }, + TextEmphasisShapeKeyword::DoubleCircle => if fill { "\u{25c9}" } else { "\u{25ce}" }, + TextEmphasisShapeKeyword::Triangle => if fill { "\u{25b2}" } else { "\u{25b3}" }, + TextEmphasisShapeKeyword::Sesame => if fill { "\u{fe45}" } else { "\u{fe46}" }, } } } @@ -605,12 +605,12 @@ impl ToComputedValue for TextEmphasisStyle { TextEmphasisStyle::Keyword(ref keyword) => { let default_shape = if context.style().get_inheritedbox() .clone_writing_mode() == SpecifiedWritingMode::HorizontalTb { - ShapeKeyword::Circle + TextEmphasisShapeKeyword::Circle } else { - ShapeKeyword::Sesame + TextEmphasisShapeKeyword::Sesame }; - ComputedTextEmphasisStyle::Keyword(ComputedKeywordValue { - fill: keyword.fill().unwrap_or(FillMode::Filled), + ComputedTextEmphasisStyle::Keyword(ComputedTextEmphasisKeywordValue { + fill: keyword.fill().unwrap_or(TextEmphasisFillMode::Filled), shape: keyword.shape().unwrap_or(default_shape), }) }, @@ -627,7 +627,7 @@ impl ToComputedValue for TextEmphasisStyle { fn from_computed_value(computed: &Self::ComputedValue) -> Self { match *computed { ComputedTextEmphasisStyle::Keyword(ref keyword) => - TextEmphasisStyle::Keyword(KeywordValue::FillAndShape(keyword.fill, keyword.shape)), + TextEmphasisStyle::Keyword(TextEmphasisKeywordValue::FillAndShape(keyword.fill, keyword.shape)), ComputedTextEmphasisStyle::None => TextEmphasisStyle::None, ComputedTextEmphasisStyle::String(ref string) => TextEmphasisStyle::String(string.clone()) } @@ -649,17 +649,17 @@ impl Parse for TextEmphasisStyle { } // Handle a pair of keywords - let mut shape = input.try(ShapeKeyword::parse).ok(); - let fill = input.try(FillMode::parse).ok(); + let mut shape = input.try(TextEmphasisShapeKeyword::parse).ok(); + let fill = input.try(TextEmphasisFillMode::parse).ok(); if shape.is_none() { - shape = input.try(ShapeKeyword::parse).ok(); + shape = input.try(TextEmphasisShapeKeyword::parse).ok(); } // At least one of shape or fill must be handled let keyword_value = match (fill, shape) { - (Some(fill), Some(shape)) => KeywordValue::FillAndShape(fill, shape), - (Some(fill), None) => KeywordValue::Fill(fill), - (None, Some(shape)) => KeywordValue::Shape(shape), + (Some(fill), Some(shape)) => TextEmphasisKeywordValue::FillAndShape(fill, shape), + (Some(fill), None) => TextEmphasisKeywordValue::Fill(fill), + (None, Some(shape)) => TextEmphasisKeywordValue::Shape(shape), _ => return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)), }; Ok(TextEmphasisStyle::Keyword(keyword_value))