From db0134e69725e4f4e625d4691b63eb05c04e9c27 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 9 May 2018 16:07:36 +1000 Subject: [PATCH] style: Rename pointing to inherited_ui. And also merge values::*::pointing into values::*::ui. Bug: 1460192 Reviewed-by: heycam MozReview-Commit-ID: FM4gWEszahB --- .../sugar/style_complex_color.rs | 2 +- components/style/properties/gecko.mako.rs | 13 +-- ...{pointing.mako.rs => inherited_ui.mako.rs} | 4 +- .../style/properties/properties.mako.rs | 2 +- components/style/values/computed/mod.rs | 8 +- components/style/values/computed/pointing.rs | 21 ----- components/style/values/computed/ui.rs | 14 +++ components/style/values/generics/mod.rs | 2 +- .../values/generics/{pointing.rs => ui.rs} | 2 +- components/style/values/specified/mod.rs | 8 +- components/style/values/specified/pointing.rs | 86 ------------------- components/style/values/specified/ui.rs | 75 ++++++++++++++++ 12 files changed, 103 insertions(+), 134 deletions(-) rename components/style/properties/longhand/{pointing.mako.rs => inherited_ui.mako.rs} (95%) delete mode 100644 components/style/values/computed/pointing.rs rename components/style/values/generics/{pointing.rs => ui.rs} (98%) delete mode 100644 components/style/values/specified/pointing.rs diff --git a/components/style/gecko_bindings/sugar/style_complex_color.rs b/components/style/gecko_bindings/sugar/style_complex_color.rs index 0d5a20944a8..0e06b4c50ba 100644 --- a/components/style/gecko_bindings/sugar/style_complex_color.rs +++ b/components/style/gecko_bindings/sugar/style_complex_color.rs @@ -7,7 +7,7 @@ use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor}; use gecko_bindings::structs::{nscolor, StyleComplexColor}; use values::computed::Color as ComputedColor; -use values::generics::pointing::CaretColor; +use values::generics::ui::CaretColor; impl From for StyleComplexColor { fn from(other: nscolor) -> Self { diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 4479d040564..c751bd843a2 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -4108,10 +4108,6 @@ fn static_assert() { unsafe { Gecko_SetListStyleImageImageValue(&mut self.gecko, url.image_value.get()); } - // We don't need to record this struct as uncacheable, like when setting - // background-image to a url() value, since only properties in reset structs - // are re-used from the applicable declaration cache, and the List struct - // is an inherited struct. } } } @@ -5266,7 +5262,7 @@ clip-path } -<%self:impl_trait style_struct_name="Pointing" +<%self:impl_trait style_struct_name="InheritedUI" skip_longhands="cursor caret-color"> pub fn set_cursor(&mut self, v: longhands::cursor::computed_value::T) { use style_traits::cursor::CursorKind; @@ -5326,11 +5322,6 @@ clip-path ); } - // We don't need to record this struct as uncacheable, like when setting - // background-image to a url() value, since only properties in reset structs - // are re-used from the applicable declaration cache, and the Pointing struct - // is an inherited struct. - match v.images[i].hotspot { Some((x, y)) => { self.gecko.mCursorImages[i].mHaveHotspot = true; @@ -5356,7 +5347,7 @@ clip-path } pub fn clone_cursor(&self) -> longhands::cursor::computed_value::T { - use values::computed::pointing::CursorImage; + use values::computed::ui::CursorImage; use style_traits::cursor::CursorKind; use values::specified::url::SpecifiedImageUrl; diff --git a/components/style/properties/longhand/pointing.mako.rs b/components/style/properties/longhand/inherited_ui.mako.rs similarity index 95% rename from components/style/properties/longhand/pointing.mako.rs rename to components/style/properties/longhand/inherited_ui.mako.rs index 6dbb71c59ae..3b516e2f1ce 100644 --- a/components/style/properties/longhand/pointing.mako.rs +++ b/components/style/properties/longhand/inherited_ui.mako.rs @@ -4,7 +4,7 @@ <%namespace name="helpers" file="/helpers.mako.rs" /> -<% data.new_style_struct("Pointing", inherited=True, gecko_name="UserInterface") %> +<% data.new_style_struct("InheritedUI", inherited=True, gecko_name="UserInterface") %> ${helpers.predefined_type("cursor", "Cursor", @@ -44,7 +44,7 @@ ${helpers.single_keyword("-moz-user-focus", ${helpers.predefined_type( "caret-color", "CaretColor", - "generics::pointing::CaretColor::Auto", + "generics::ui::CaretColor::Auto", spec="https://drafts.csswg.org/css-ui/#caret-color", animation_value_type="AnimatedCaretColor", ignored_when_colors_disabled=True, diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 5e3d8eaeaaf..8c5b9c74149 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -109,11 +109,11 @@ pub mod longhands { <%include file="/longhand/inherited_box.mako.rs" /> <%include file="/longhand/inherited_table.mako.rs" /> <%include file="/longhand/inherited_text.mako.rs" /> + <%include file="/longhand/inherited_ui.mako.rs" /> <%include file="/longhand/list.mako.rs" /> <%include file="/longhand/margin.mako.rs" /> <%include file="/longhand/outline.mako.rs" /> <%include file="/longhand/padding.mako.rs" /> - <%include file="/longhand/pointing.mako.rs" /> <%include file="/longhand/position.mako.rs" /> <%include file="/longhand/table.mako.rs" /> <%include file="/longhand/text.mako.rs" /> diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 4adf33253e8..16391ae5d86 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -67,9 +67,6 @@ pub use self::list::Quotes; pub use self::list::ListStyleType; pub use self::outline::OutlineStyle; pub use self::percentage::{Percentage, NonNegativePercentage}; -pub use self::pointing::{CaretColor, Cursor}; -#[cfg(feature = "gecko")] -pub use self::pointing::CursorImage; pub use self::position::{GridAutoFlow, GridTemplateAreas, Position, ZIndex}; pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind}; pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; @@ -80,7 +77,9 @@ pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle, TextOve pub use self::time::Time; pub use self::transform::{Rotate, Scale, TimingFunction, Transform, TransformOperation}; pub use self::transform::{TransformOrigin, TransformStyle, Translate}; -pub use self::ui::MozForceBrokenImageIcon; +pub use self::ui::{CaretColor, Cursor, MozForceBrokenImageIcon}; +#[cfg(feature = "gecko")] +pub use self::ui::CursorImage; #[cfg(feature = "gecko")] pub mod align; @@ -104,7 +103,6 @@ pub mod length; pub mod list; pub mod outline; pub mod percentage; -pub mod pointing; pub mod position; pub mod rect; pub mod svg; diff --git a/components/style/values/computed/pointing.rs b/components/style/values/computed/pointing.rs deleted file mode 100644 index a89db9104c3..00000000000 --- a/components/style/values/computed/pointing.rs +++ /dev/null @@ -1,21 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! Computed values for Pointing properties. -//! -//! https://drafts.csswg.org/css-ui/#pointing-keyboard - -use values::computed::Number; -use values::computed::color::Color; -use values::computed::url::ComputedImageUrl; -use values::generics::pointing as generics; - -/// A computed value for the `caret-color` property. -pub type CaretColor = generics::CaretColor; - -/// A computed value for the `cursor` property. -pub type Cursor = generics::Cursor; - -/// A computed value for item of `image cursors`. -pub type CursorImage = generics::CursorImage; diff --git a/components/style/values/computed/ui.rs b/components/style/values/computed/ui.rs index f3f3cdf4c99..1313a5e5dd9 100644 --- a/components/style/values/computed/ui.rs +++ b/components/style/values/computed/ui.rs @@ -4,4 +4,18 @@ //! Computed values for UI properties +use values::computed::Number; +use values::computed::color::Color; +use values::computed::url::ComputedImageUrl; +use values::generics::ui as generics; + pub use values::specified::ui::MozForceBrokenImageIcon; + +/// A computed value for the `caret-color` property. +pub type CaretColor = generics::CaretColor; + +/// A computed value for the `cursor` property. +pub type Cursor = generics::Cursor; + +/// A computed value for item of `image cursors`. +pub type CursorImage = generics::CursorImage; diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index 59d9748ea5b..c68ed91426a 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -26,13 +26,13 @@ pub mod font; pub mod gecko; pub mod grid; pub mod image; -pub mod pointing; pub mod position; pub mod rect; pub mod size; pub mod svg; pub mod text; pub mod transform; +pub mod ui; pub mod url; // https://drafts.csswg.org/css-counter-styles/#typedef-symbols-type diff --git a/components/style/values/generics/pointing.rs b/components/style/values/generics/ui.rs similarity index 98% rename from components/style/values/generics/pointing.rs rename to components/style/values/generics/ui.rs index 9d9ec031225..a52ee9fcf76 100644 --- a/components/style/values/generics/pointing.rs +++ b/components/style/values/generics/ui.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! Generic values for pointing properties. +//! Generic values for UI properties. use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 3f89dae0053..5b07d380c58 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -62,9 +62,6 @@ pub use self::list::ListStyleType; pub use self::outline::OutlineStyle; pub use self::rect::LengthOrNumberRect; pub use self::percentage::Percentage; -pub use self::pointing::{CaretColor, Cursor}; -#[cfg(feature = "gecko")] -pub use self::pointing::CursorImage; pub use self::position::{GridAutoFlow, GridTemplateAreas, Position}; pub use self::position::{PositionComponent, ZIndex}; pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind}; @@ -77,7 +74,9 @@ pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpa pub use self::time::Time; pub use self::transform::{Rotate, Scale, TimingFunction, Transform}; pub use self::transform::{TransformOrigin, TransformStyle, Translate}; -pub use self::ui::MozForceBrokenImageIcon; +pub use self::ui::{CaretColor, Cursor, MozForceBrokenImageIcon}; +#[cfg(feature = "gecko")] +pub use self::ui::CursorImage; pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent; #[cfg(feature = "gecko")] @@ -104,7 +103,6 @@ pub mod length; pub mod list; pub mod outline; pub mod percentage; -pub mod pointing; pub mod position; pub mod rect; pub mod source_size_list; diff --git a/components/style/values/specified/pointing.rs b/components/style/values/specified/pointing.rs deleted file mode 100644 index cf718a1fd9d..00000000000 --- a/components/style/values/specified/pointing.rs +++ /dev/null @@ -1,86 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! Specified values for Pointing properties. -//! -//! https://drafts.csswg.org/css-ui/#pointing-keyboard - -use cssparser::Parser; -use parser::{Parse, ParserContext}; -use style_traits::{ParseError, StyleParseErrorKind}; -use style_traits::cursor::CursorKind; -use values::generics::pointing as generics; -use values::specified::Number; -use values::specified::color::Color; -use values::specified::url::SpecifiedImageUrl; - -/// A specified value for the `caret-color` property. -pub type CaretColor = generics::CaretColor; - -impl Parse for CaretColor { - fn parse<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - if input.try(|i| i.expect_ident_matching("auto")).is_ok() { - return Ok(generics::CaretColor::Auto); - } - Ok(generics::CaretColor::Color(Color::parse(context, input)?)) - } -} - -/// A specified value for the `cursor` property. -pub type Cursor = generics::Cursor; - -/// A specified value for item of `image cursors`. -pub type CursorImage = generics::CursorImage; - -impl Parse for Cursor { - /// cursor: [ [ ]?]# [auto | default | ...] - fn parse<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - let mut images = vec![]; - loop { - match input.try(|input| CursorImage::parse(context, input)) { - Ok(image) => images.push(image), - Err(_) => break, - } - input.expect_comma()?; - } - Ok(Self { - images: images.into_boxed_slice(), - keyword: CursorKind::parse(context, input)?, - }) - } -} - -impl Parse for CursorKind { - fn parse<'i, 't>( - _context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - let location = input.current_source_location(); - let ident = input.expect_ident()?; - CursorKind::from_css_keyword(&ident).map_err(|_| { - location.new_custom_error(StyleParseErrorKind::UnspecifiedError) - }) - } -} - -impl Parse for CursorImage { - fn parse<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - Ok(Self { - url: SpecifiedImageUrl::parse(context, input)?, - hotspot: match input.try(|input| Number::parse(context, input)) { - Ok(number) => Some((number, Number::parse(context, input)?)), - Err(_) => None, - }, - }) - } -} diff --git a/components/style/values/specified/ui.rs b/components/style/values/specified/ui.rs index fc7ef048082..d42b1e4e257 100644 --- a/components/style/values/specified/ui.rs +++ b/components/style/values/specified/ui.rs @@ -8,6 +8,81 @@ use cssparser::Parser; use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; +use style_traits::cursor::CursorKind; +use values::generics::ui as generics; +use values::specified::Number; +use values::specified::color::Color; +use values::specified::url::SpecifiedImageUrl; + +/// A specified value for the `caret-color` property. +pub type CaretColor = generics::CaretColor; + +impl Parse for CaretColor { + fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + if input.try(|i| i.expect_ident_matching("auto")).is_ok() { + return Ok(generics::CaretColor::Auto); + } + Ok(generics::CaretColor::Color(Color::parse(context, input)?)) + } +} + +/// A specified value for the `cursor` property. +pub type Cursor = generics::Cursor; + +/// A specified value for item of `image cursors`. +pub type CursorImage = generics::CursorImage; + +impl Parse for Cursor { + /// cursor: [ [ ]?]# [auto | default | ...] + fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + let mut images = vec![]; + loop { + match input.try(|input| CursorImage::parse(context, input)) { + Ok(image) => images.push(image), + Err(_) => break, + } + input.expect_comma()?; + } + Ok(Self { + images: images.into_boxed_slice(), + keyword: CursorKind::parse(context, input)?, + }) + } +} + +impl Parse for CursorKind { + fn parse<'i, 't>( + _context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + let location = input.current_source_location(); + let ident = input.expect_ident()?; + CursorKind::from_css_keyword(&ident).map_err(|_| { + location.new_custom_error(StyleParseErrorKind::UnspecifiedError) + }) + } +} + +impl Parse for CursorImage { + fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + Ok(Self { + url: SpecifiedImageUrl::parse(context, input)?, + hotspot: match input.try(|input| Number::parse(context, input)) { + Ok(number) => Some((number, Number::parse(context, input)?)), + Err(_) => None, + }, + }) + } +} /// Specified value of `-moz-force-broken-image-icon` #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo,