Bug 1333482 part 1 - [css-ui] Introduce the 'appearance: auto | none' property. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Thu, 23 Mar 2017 23:13:17 +0100
changeset 349333 51cff1ed410ba17ae8b072128ffa1781652eb0e5
parent 349332 8bb800ab23a51e39e17045be457c44f8b2612c62
child 349334 cf701cfc024972be7bb703aace2b9d88e6f27115
push id31550
push usercbook@mozilla.com
push dateFri, 24 Mar 2017 13:22:27 +0000
treeherdermozilla-central@473e0b201761 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1333482
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1333482 part 1 - [css-ui] Introduce the 'appearance: auto | none' property. r=dholbert MozReview-Commit-ID: 3itCDTKuYQ9
gfx/src/nsThemeConstants.h
layout/style/nsCSSPropList.h
layout/style/nsCSSProps.cpp
layout/style/nsCSSProps.h
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
layout/style/nsComputedDOMStylePropertyList.h
layout/style/nsRuleNode.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/gfx/src/nsThemeConstants.h
+++ b/gfx/src/nsThemeConstants.h
@@ -9,16 +9,19 @@
 #define NS_THEME_BUTTON                                    1
 
 // A radio element within a radio group.
 #define NS_THEME_RADIO                                     2
 
 // A checkbox element. 
 #define NS_THEME_CHECKBOX                                  3
 
+// appearance:auto (only used in the style system, not in layout)
+#define NS_THEME_AUTO                                      4
+
 // A rectangular button that contains complex content
 // like images (e.g. HTML <button> elements)
 #define NS_THEME_BUTTON_BEVEL                              7
 
 // A themed focus outline (for outline:auto)
 #define NS_THEME_FOCUS_OUTLINE                             8
 
 // The toolbox that contains the toolbars.
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -458,17 +458,27 @@ CSS_PROP_DISPLAY(
     "",
     VARIANT_KEYWORD | VARIANT_TIMING_FUNCTION, // used by list parsing
     kTransitionTimingFunctionKTable,
     CSS_PROP_NO_OFFSET,
     eStyleAnimType_None)
 CSS_PROP_DISPLAY(
     -moz-appearance,
     _moz_appearance,
-    CSS_PROP_DOMPROP_PREFIXED(Appearance),
+    MozAppearance,
+    CSS_PROPERTY_PARSE_VALUE,
+    "",
+    VARIANT_HK,
+    kMozAppearanceKTable,
+    CSS_PROP_NO_OFFSET,
+    eStyleAnimType_Discrete)
+CSS_PROP_DISPLAY(
+    appearance,
+    appearance,
+    Appearance,
     CSS_PROPERTY_PARSE_VALUE,
     "",
     VARIANT_HK,
     kAppearanceKTable,
     CSS_PROP_NO_OFFSET,
     eStyleAnimType_Discrete)
 CSS_PROP_DISPLAY(
     backface-visibility,
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -739,16 +739,22 @@ const KTableEntry nsCSSProps::kAnimation
 
 const KTableEntry nsCSSProps::kAnimationPlayStateKTable[] = {
   { eCSSKeyword_running, NS_STYLE_ANIMATION_PLAY_STATE_RUNNING },
   { eCSSKeyword_paused, NS_STYLE_ANIMATION_PLAY_STATE_PAUSED },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kAppearanceKTable[] = {
+  { eCSSKeyword_auto,    NS_THEME_AUTO },
+  { eCSSKeyword_none,    NS_THEME_NONE },
+  { eCSSKeyword_UNKNOWN, -1 }
+};
+
+const KTableEntry nsCSSProps::kMozAppearanceKTable[] = {
   { eCSSKeyword_none,                   NS_THEME_NONE },
   { eCSSKeyword_button,                 NS_THEME_BUTTON },
   { eCSSKeyword_radio,                  NS_THEME_RADIO },
   { eCSSKeyword_checkbox,               NS_THEME_CHECKBOX },
   { eCSSKeyword_button_bevel,           NS_THEME_BUTTON_BEVEL },
   { eCSSKeyword_toolbox,                NS_THEME_TOOLBOX },
   { eCSSKeyword_toolbar,                NS_THEME_TOOLBAR },
   { eCSSKeyword_toolbarbutton,          NS_THEME_TOOLBARBUTTON },
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -691,16 +691,17 @@ public:
 
   // Keyword/Enum value tables
   static const KTableEntry kAnimationDirectionKTable[];
   static const KTableEntry kAnimationFillModeKTable[];
   static const KTableEntry kAnimationIterationCountKTable[];
   static const KTableEntry kAnimationPlayStateKTable[];
   static const KTableEntry kAnimationTimingFunctionKTable[];
   static const KTableEntry kAppearanceKTable[];
+  static const KTableEntry kMozAppearanceKTable[];
   static const KTableEntry kAzimuthKTable[];
   static const KTableEntry kBackfaceVisibilityKTable[];
   static const KTableEntry kTransformStyleKTable[];
   static const KTableEntry kImageLayerAttachmentKTable[];
   static const KTableEntry kBackgroundOriginKTable[];
   static const KTableEntry kMaskOriginKTable[];
   static const KTableEntry kImageLayerPositionKTable[];
   static const KTableEntry kImageLayerRepeatKTable[];
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -4356,16 +4356,24 @@ already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetAppearance()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetIdent(nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mAppearance,
                                                nsCSSProps::kAppearanceKTable));
   return val.forget();
 }
 
+already_AddRefed<CSSValue>
+nsComputedDOMStyle::DoGetMozAppearance()
+{
+  RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
+  val->SetIdent(nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mMozAppearance,
+                                               nsCSSProps::kMozAppearanceKTable));
+  return val.forget();
+}
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetBoxAlign()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetIdent(nsCSSProps::ValueToKeywordEnum(StyleXUL()->mBoxAlign,
                                                nsCSSProps::kBoxAlignKTable));
   return val.forget();
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -232,16 +232,17 @@ private:
   bool ShouldHonorMinSizeAutoInAxis(mozilla::PhysicalAxis aAxis);
 
   /* Properties queryable as CSSValues.
    * To avoid a name conflict with nsIDOM*CSS2Properties, these are all
    * DoGetXXX instead of GetXXX.
    */
 
   already_AddRefed<CSSValue> DoGetAppearance();
+  already_AddRefed<CSSValue> DoGetMozAppearance();
 
   /* Box properties */
   already_AddRefed<CSSValue> DoGetBoxAlign();
   already_AddRefed<CSSValue> DoGetBoxDecorationBreak();
   already_AddRefed<CSSValue> DoGetBoxDirection();
   already_AddRefed<CSSValue> DoGetBoxFlex();
   already_AddRefed<CSSValue> DoGetBoxOrdinalGroup();
   already_AddRefed<CSSValue> DoGetBoxOrient();
--- a/layout/style/nsComputedDOMStylePropertyList.h
+++ b/layout/style/nsComputedDOMStylePropertyList.h
@@ -34,28 +34,29 @@
  * Properties commented out with // are not yet implemented            *
  * Properties commented out with //// are shorthands and not queryable *
 \* ******************************************************************* */
 
 /* ***************************** *\
  * Implementations of CSS styles *
 \* ***************************** */
 
-COMPUTED_STYLE_PROP(align_content,                   AlignContent)
+COMPUTED_STYLE_PROP(align_content,                 AlignContent)
 COMPUTED_STYLE_PROP(align_items,                   AlignItems)
 COMPUTED_STYLE_PROP(align_self,                    AlignSelf)
 //// COMPUTED_STYLE_PROP(animation,                Animation)
 COMPUTED_STYLE_PROP(animation_delay,               AnimationDelay)
 COMPUTED_STYLE_PROP(animation_direction,           AnimationDirection)
 COMPUTED_STYLE_PROP(animation_duration,            AnimationDuration)
 COMPUTED_STYLE_PROP(animation_fill_mode,           AnimationFillMode)
 COMPUTED_STYLE_PROP(animation_iteration_count,     AnimationIterationCount)
 COMPUTED_STYLE_PROP(animation_name,                AnimationName)
 COMPUTED_STYLE_PROP(animation_play_state,          AnimationPlayState)
 COMPUTED_STYLE_PROP(animation_timing_function,     AnimationTimingFunction)
+COMPUTED_STYLE_PROP(appearance,                    Appearance)
 COMPUTED_STYLE_PROP(backface_visibility,           BackfaceVisibility)
 //// COMPUTED_STYLE_PROP(background,               Background)
 COMPUTED_STYLE_PROP(background_attachment,         BackgroundAttachment)
 COMPUTED_STYLE_PROP(background_blend_mode,         BackgroundBlendMode)
 COMPUTED_STYLE_PROP(background_clip,               BackgroundClip)
 COMPUTED_STYLE_PROP(background_color,              BackgroundColor)
 COMPUTED_STYLE_PROP(background_image,              BackgroundImage)
 COMPUTED_STYLE_PROP(background_origin,             BackgroundOrigin)
@@ -269,17 +270,17 @@ COMPUTED_STYLE_PROP(word_break,         
 COMPUTED_STYLE_PROP(word_spacing,                  WordSpacing)
 COMPUTED_STYLE_PROP(writing_mode,                  WritingMode)
 COMPUTED_STYLE_PROP(z_index,                       ZIndex)
 
 /* ******************************* *\
  * Implementations of -moz- styles *
 \* ******************************* */
 
-COMPUTED_STYLE_PROP(_moz_appearance,               Appearance)
+COMPUTED_STYLE_PROP(_moz_appearance,               MozAppearance)
 COMPUTED_STYLE_PROP(_moz_binding,                  Binding)
 COMPUTED_STYLE_PROP(_moz_border_bottom_colors,     BorderBottomColors)
 COMPUTED_STYLE_PROP(_moz_border_left_colors,       BorderLeftColors)
 COMPUTED_STYLE_PROP(_moz_border_right_colors,      BorderRightColors)
 COMPUTED_STYLE_PROP(_moz_border_top_colors,        BorderTopColors)
 COMPUTED_STYLE_PROP(_moz_box_align,                BoxAlign)
 COMPUTED_STYLE_PROP(_moz_box_direction,            BoxDirection)
 COMPUTED_STYLE_PROP(_moz_box_flex,                 BoxFlex)
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -6166,22 +6166,29 @@ nsRuleNode::ComputeDisplayData(void* aSt
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parentDisplay->mTopLayer, NS_STYLE_TOP_LAYER_NONE);
 
   // Backup original display value for calculation of a hypothetical
   // box (CSS2 10.6.4/10.6.5), in addition to getting our style data right later.
   // See ReflowInput::CalculateHypotheticalBox
   display->mOriginalDisplay = display->mDisplay;
 
-  // appearance: enum, inherit, initial
+  // -moz-appearance: enum, inherit, initial
+  SetValue(*aRuleData->ValueForMozAppearance(),
+           display->mMozAppearance, conditions,
+           SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
+           parentDisplay->mMozAppearance,
+           NS_THEME_NONE);
+
+  // appearance: auto | none
   SetValue(*aRuleData->ValueForAppearance(),
            display->mAppearance, conditions,
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parentDisplay->mAppearance,
-           NS_THEME_NONE);
+           NS_THEME_AUTO);
 
   // binding: url, none, inherit
   const nsCSSValue* bindingValue = aRuleData->ValueForBinding();
   if (eCSSUnit_URL == bindingValue->GetUnit()) {
     mozilla::css::URLValue* url = bindingValue->GetURLStructValue();
     NS_ASSERTION(url, "What's going on here?");
     display->mBinding.Set(url);
   }
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3255,17 +3255,18 @@ StyleAnimation::operator==(const StyleAn
 
 // --------------------
 // nsStyleDisplay
 //
 nsStyleDisplay::nsStyleDisplay(const nsPresContext* aContext)
   : mDisplay(StyleDisplay::Inline)
   , mOriginalDisplay(StyleDisplay::Inline)
   , mContain(NS_STYLE_CONTAIN_NONE)
-  , mAppearance(NS_THEME_NONE)
+  , mMozAppearance(NS_THEME_NONE)
+  , mAppearance(NS_THEME_AUTO)
   , mPosition(NS_STYLE_POSITION_STATIC)
   , mFloat(StyleFloat::None)
   , mOriginalFloat(StyleFloat::None)
   , mBreakType(StyleClear::None)
   , mBreakInside(NS_STYLE_PAGE_BREAK_AUTO)
   , mBreakBefore(false)
   , mBreakAfter(false)
   , mOverflowX(NS_STYLE_OVERFLOW_VISIBLE)
@@ -3317,16 +3318,17 @@ nsStyleDisplay::nsStyleDisplay(const nsP
   mAnimations[0].SetInitialValues();
 }
 
 nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
   : mBinding(aSource.mBinding)
   , mDisplay(aSource.mDisplay)
   , mOriginalDisplay(aSource.mOriginalDisplay)
   , mContain(aSource.mContain)
+  , mMozAppearance(aSource.mMozAppearance)
   , mAppearance(aSource.mAppearance)
   , mPosition(aSource.mPosition)
   , mFloat(aSource.mFloat)
   , mOriginalFloat(aSource.mOriginalFloat)
   , mBreakType(aSource.mBreakType)
   , mBreakInside(aSource.mBreakInside)
   , mBreakBefore(aSource.mBreakBefore)
   , mBreakAfter(aSource.mBreakAfter)
@@ -3432,20 +3434,20 @@ nsStyleDisplay::CalcDifference(const nsS
    * as used when the overflow css property changes,
    * nsChangeHint_ReconstructFrame, PropagateScrollToViewport will be called.
    *
    * The scroll-behavior css property is not expected to change often (the
    * CSSOM-View DOM methods are likely to be used in those cases); however,
    * if this does become common perhaps a faster-path might be worth while.
    */
 
-  if ((mAppearance == NS_THEME_TEXTFIELD &&
-       aNewData.mAppearance != NS_THEME_TEXTFIELD) ||
-      (mAppearance != NS_THEME_TEXTFIELD &&
-       aNewData.mAppearance == NS_THEME_TEXTFIELD)) {
+  if ((mMozAppearance == NS_THEME_TEXTFIELD &&
+       aNewData.mMozAppearance != NS_THEME_TEXTFIELD) ||
+      (mMozAppearance != NS_THEME_TEXTFIELD &&
+       aNewData.mMozAppearance == NS_THEME_TEXTFIELD)) {
     // This is for <input type=number> where we allow authors to specify a
     // |-moz-appearance:textfield| to get a control without a spinner. (The
     // spinner is present for |-moz-appearance:number-input| but also other
     // values such as 'none'.) We need to reframe since we want to use
     // nsTextControlFrame instead of nsNumberControlFrame if the author
     // specifies 'textfield'.
     return nsChangeHint_ReconstructFrame;
   }
@@ -3464,16 +3466,17 @@ nsStyleDisplay::CalcDifference(const nsS
   }
 
   // XXX the following is conservative, for now: changing float breaking shouldn't
   // necessarily require a repaint, reflow should suffice.
   if (mBreakType != aNewData.mBreakType
       || mBreakInside != aNewData.mBreakInside
       || mBreakBefore != aNewData.mBreakBefore
       || mBreakAfter != aNewData.mBreakAfter
+      || mMozAppearance != aNewData.mMozAppearance
       || mAppearance != aNewData.mAppearance
       || mOrient != aNewData.mOrient
       || mOverflowClipBox != aNewData.mOverflowClipBox) {
     hint |= nsChangeHint_AllReflowHints |
             nsChangeHint_RepaintFrame;
   }
 
   if (mIsolation != aNewData.mIsolation) {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -22,16 +22,17 @@
 #include "mozilla/UniquePtr.h"
 #include "nsColor.h"
 #include "nsCoord.h"
 #include "nsMargin.h"
 #include "nsFont.h"
 #include "nsStyleAutoArray.h"
 #include "nsStyleCoord.h"
 #include "nsStyleConsts.h"
+#include "nsThemeConstants.h"
 #include "nsChangeHint.h"
 #include "nsPresContext.h"
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsCSSValue.h"
 #include "imgRequestProxy.h"
 #include "Orientation.h"
@@ -2655,17 +2656,30 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   BindingHolder mBinding;                  // [reset]
   mozilla::StyleDisplay mDisplay;          // [reset] see nsStyleConsts.h StyleDisplay
   mozilla::StyleDisplay mOriginalDisplay;  // [reset] saved mDisplay for
                                            //         position:absolute/fixed
                                            //         and float:left/right;
                                            //         otherwise equal to
                                            //         mDisplay
   uint8_t mContain;             // [reset] see nsStyleConsts.h NS_STYLE_CONTAIN_*
+//private:  XXX not yet
+  friend class nsComputedDOMStyle;
+  friend class nsRuleNode;
+  uint8_t mMozAppearance;       // [reset]
   uint8_t mAppearance;          // [reset]
+public:
+  MOZ_MUST_USE uint8_t UsedAppearance() const {
+    if (mAppearance == NS_THEME_NONE) {
+      return NS_THEME_NONE;
+    }
+    MOZ_ASSERT(mAppearance == NS_THEME_AUTO);
+    return mMozAppearance; // use the -moz-appearance value
+  }
+
   uint8_t mPosition;            // [reset] see nsStyleConsts.h
 
   // [reset] See StyleFloat in nsStyleConsts.h.
   mozilla::StyleFloat mFloat;
   // [reset] Save mFloat for position:absolute/fixed; otherwise equal to mFloat.
   mozilla::StyleFloat mOriginalFloat;
 
   mozilla::StyleClear mBreakType;  // [reset]