From 1aa6725f9a15a36cacb4814f089d0dc957e073a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 11 Nov 2018 17:57:41 +0100 Subject: [PATCH] style: Move user-select outside of mako. This is the first step to unprefix user-select. This has no behavior change, it's just a nicer way to do the same thing which allows us to unship individual values more easily using parse(condition). Differential Revision: https://phabricator.services.mozilla.com/D11580 --- components/style/cbindgen.toml | 1 + components/style/properties/data.py | 1 + components/style/properties/gecko.mako.rs | 1 + .../style/properties/longhands/ui.mako.rs | 11 +++--- components/style/values/computed/mod.rs | 2 +- components/style/values/computed/ui.rs | 2 +- components/style/values/specified/mod.rs | 2 +- components/style/values/specified/ui.rs | 36 +++++++++++++++++++ 8 files changed, 47 insertions(+), 9 deletions(-) diff --git a/components/style/cbindgen.toml b/components/style/cbindgen.toml index 06c1730622a..d9efc9d9e18 100644 --- a/components/style/cbindgen.toml +++ b/components/style/cbindgen.toml @@ -53,5 +53,6 @@ include = [ "TimingFunction", "PathCommand", "UnicodeRange", + "UserSelect", ] item_types = ["enums", "structs", "typedefs"] diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 10f64484693..97e2f7f0d84 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -336,6 +336,7 @@ class Longhand(object): "TextEmphasisPosition", "TouchAction", "TransformStyle", + "UserSelect", "XSpan", "XTextZoom", "ZIndex", diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index b845d382623..2cc8cf2bcd3 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1429,6 +1429,7 @@ impl Clone for ${style_struct.gecko_struct_name} { "SVGWidth": impl_svg_length, "Transform": impl_transform, "TransformOrigin": impl_transform_origin, + "UserSelect": impl_simple, "url::UrlOrNone": impl_css_url, } diff --git a/components/style/properties/longhands/ui.mako.rs b/components/style/properties/longhands/ui.mako.rs index b8a188d896b..b73792104cb 100644 --- a/components/style/properties/longhands/ui.mako.rs +++ b/components/style/properties/longhands/ui.mako.rs @@ -31,16 +31,15 @@ ${helpers.single_keyword( spec="https://drafts.csswg.org/css-scrollbars-1/#scrollbar-width" )} -${helpers.single_keyword( +${helpers.predefined_type( "-moz-user-select", - "auto text none all element elements toggle tri-state -moz-all -moz-text", + "UserSelect", + "computed::UserSelect::Auto", products="gecko", - alias="-webkit-user-select", gecko_ffi_name="mUserSelect", - gecko_enum_prefix="StyleUserSelect", - gecko_strip_moz_prefix=False, - aliases="-moz-none=none", + alias="-webkit-user-select", animation_value_type="discrete", + needs_context=False, spec="https://drafts.csswg.org/css-ui-4/#propdef-user-select", )} diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index e24472a8068..b8484a291ab 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -84,7 +84,7 @@ pub use self::transform::{Rotate, Scale, Transform, TransformOperation}; pub use self::transform::{TransformOrigin, TransformStyle, Translate}; #[cfg(feature = "gecko")] pub use self::ui::CursorImage; -pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon}; +pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon, UserSelect}; pub use super::specified::{BorderStyle, TextDecorationLine}; pub use super::{Auto, Either, None_}; pub use app_units::Au; diff --git a/components/style/values/computed/ui.rs b/components/style/values/computed/ui.rs index 57990d84d79..7d4a5c6a1ce 100644 --- a/components/style/values/computed/ui.rs +++ b/components/style/values/computed/ui.rs @@ -10,7 +10,7 @@ use crate::values::computed::Number; use crate::values::generics::ui as generics; use crate::values::{Auto, Either}; -pub use crate::values::specified::ui::MozForceBrokenImageIcon; +pub use crate::values::specified::ui::{MozForceBrokenImageIcon, UserSelect}; /// auto | pub type ColorOrAuto = Either; diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 3b7a3d0e04e..bcca8ed8f49 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -82,7 +82,7 @@ pub use self::transform::{Rotate, Scale, Transform}; pub use self::transform::{TransformOrigin, TransformStyle, Translate}; #[cfg(feature = "gecko")] pub use self::ui::CursorImage; -pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon}; +pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon, UserSelect}; pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent; #[cfg(feature = "gecko")] diff --git a/components/style/values/specified/ui.rs b/components/style/values/specified/ui.rs index 5adfcaa7f70..f11aae73bc3 100644 --- a/components/style/values/specified/ui.rs +++ b/components/style/values/specified/ui.rs @@ -140,3 +140,39 @@ impl Parse for ScrollbarColor { }) } } + +/// The specified value for the `user-select` property. +/// +/// https://drafts.csswg.org/css-ui-4/#propdef-user-select +#[allow(missing_docs)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, +)] +#[repr(u8)] +pub enum UserSelect { + Auto, + Text, + #[parse(aliases = "-moz-none")] + None, + Element, + Elements, + All, + Toggle, + TriState, + /// Force selection of all children, unless an ancestor has `none` set. + /// + /// See bug 48096. + MozAll, + /// Like `text`, except that it won't get overridden by ancestors having + /// `all`. + MozText, +}