From 862b7d124902b3054805b90146c0bbd701e124d7 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Thu, 16 Jul 2020 22:04:24 +0000 Subject: [PATCH] style: Make `appearance: button` behave like auto on various elements. Differential Revision: https://phabricator.services.mozilla.com/D83434 --- components/style/properties/data.py | 1 + .../style/properties/longhands/box.mako.rs | 19 ++++++++++++++ components/style/values/computed/box.rs | 4 +-- components/style/values/computed/mod.rs | 2 +- components/style/values/specified/box.rs | 25 +++++++++++++++++++ components/style/values/specified/mod.rs | 2 +- 6 files changed, 49 insertions(+), 4 deletions(-) diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 718b4771663..b68d40e402f 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -334,6 +334,7 @@ class Longhand(object): "BackgroundRepeat", "BorderImageRepeat", "BorderStyle", + "ButtonAppearance", "Clear", "ColumnCount", "Contain", diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs index ca93fd916ea..32a541481e2 100644 --- a/components/style/properties/longhands/box.mako.rs +++ b/components/style/properties/longhands/box.mako.rs @@ -639,6 +639,25 @@ ${helpers.predefined_type( gecko_ffi_name="mDefaultAppearance", )} +// A UA-sheet only property that controls the effect of `appearance: button` +// on the element: `-moz-button-appearance: allow` means the element is rendered +// with button appearance, and `-moz-button-appearance: disallow` is treated +// like `appearance: auto`. +// +// https://github.com/w3c/csswg-drafts/issues/5174 proposes to simplify `button` +// to mean `auto` unconditionally, at which point this property can be removed. +${helpers.predefined_type( + "-moz-button-appearance", + "ButtonAppearance", + "computed::ButtonAppearance::Allow", + engines="gecko", + animation_value_type="none", + needs_context=False, + spec="Internal (not web-exposed)", + enabled_in="ua", + gecko_ffi_name="mButtonAppearance", +)} + ${helpers.single_keyword( "-moz-orient", "inline block horizontal vertical", diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index d5adeb206a6..8054a9bda58 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -12,8 +12,8 @@ use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign; use crate::values::specified::box_ as specified; pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin}; -pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat}; -pub use crate::values::specified::box_::{Contain, Display, Overflow}; +pub use crate::values::specified::box_::{ButtonAppearance, Clear as SpecifiedClear}; +pub use crate::values::specified::box_::{Float as SpecifiedFloat, Contain, Display, Overflow}; pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox, OverscrollBehavior}; pub use crate::values::specified::box_::{ ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType, diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index aa13ff89d7c..95fb405e4ba 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -43,7 +43,7 @@ pub use self::border::{BorderCornerRadius, BorderRadius, BorderSpacing}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderImageSlice, BorderImageWidth}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain}; -pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float}; +pub use self::box_::{Appearance, BreakBetween, BreakWithin, ButtonAppearance, Clear, Float}; pub use self::box_::{Display, Overflow, OverflowAnchor, TransitionProperty}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize}; pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType}; diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index ef53c7b4cfd..84de346b1f6 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -1842,6 +1842,31 @@ pub enum Appearance { Count, } +/// The effect of `appearance: button` on an element. +#[derive( + Clone, + Copy, + Debug, + Eq, + Hash, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToCss, + ToComputedValue, + ToResolvedValue, + ToShmem, +)] +#[repr(u8)] +pub enum ButtonAppearance { + /// `appearance: button` means the element is rendered with button + /// appearance. + Allow, + /// `appearance: button` is treated like `appearance: auto`. + Disallow, +} + /// A kind of break between two boxes. /// /// https://drafts.csswg.org/css-break/#break-between diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 8ddca48d599..8de81acf8ff 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -37,7 +37,7 @@ pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display}; -pub use self::box_::{Appearance, BreakBetween, BreakWithin}; +pub use self::box_::{Appearance, BreakBetween, BreakWithin, ButtonAppearance}; pub use self::box_::{Clear, Float, Overflow, OverflowAnchor}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize}; pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType};