Bug 1383868 part 1 - Add a new internal property for handling element specific style fixup. r?bz draft
authorXidorn Quan <me@upsuper.org>
Thu, 14 Sep 2017 19:57:14 +1000
changeset 664756 c0f8cdb8160354d355560ec177ce5c55dbcc55dc
parent 664755 f74e65da8b5d9cffe278e8bab7cb5ba5bc7aede8
child 664757 e10ed2219c8e6ee3b782a21b1f11cbf4069b32aa
push id79792
push userxquan@mozilla.com
push dateThu, 14 Sep 2017 10:03:54 +0000
reviewersbz
bugs1383868
milestone57.0a1
Bug 1383868 part 1 - Add a new internal property for handling element specific style fixup. r?bz MozReview-Commit-ID: 3xmtmm22A9J
layout/style/nsCSSPropList.h
layout/style/nsCSSProps.cpp
layout/style/nsCSSProps.h
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
servo/components/style/properties/longhand/box.mako.rs
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -320,16 +320,30 @@
 // 'float' is 'none'), margin properties, padding properties, border
 // properties, 'color', and background properties.  We also allow
 // 'text-shadow' (see above) and 'box-shadow' (which is like the
 // border properties).
 
 // Please keep these sorted by property name, ignoring any "-moz-",
 // "-webkit-" or "-x-" prefix.
 
+#ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL
+CSS_PROP_DISPLAY(
+    -moz-adjustment,
+    _moz_adjustment,
+    CSS_PROP_DOMPROP_PREFIXED(Adjustment),
+    CSS_PROPERTY_INTERNAL |
+        CSS_PROPERTY_PARSE_VALUE |
+        CSS_PROPERTY_ENABLED_IN_UA_SHEETS,
+    "",
+    VARIANT_HK,
+    kAdjustmentKTable,
+    CSS_PROP_NO_OFFSET,
+    eStyleAnimType_None)
+#endif // CSS_PROP_LIST_EXCLUDE_INTERNAL
 CSS_PROP_POSITION(
     align-content,
     align_content,
     AlignContent,
     CSS_PROPERTY_PARSE_FUNCTION,
     "",
     VARIANT_HK,
     kAutoCompletionAlignJustifyContent,
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -708,16 +708,21 @@ nsCSSProps::GetStringValue(nsCSSCounterD
   } else {
     static nsDependentCString sNullStr("");
     return sNullStr;
   }
 }
 
 /***************************************************************************/
 
+const KTableEntry nsCSSProps::kAdjustmentKTable[] = {
+  { eCSSKeyword_none, StyleAdjustment::None },
+  { eCSSKeyword_UNKNOWN, -1 }
+};
+
 const KTableEntry nsCSSProps::kAnimationDirectionKTable[] = {
   { eCSSKeyword_normal, static_cast<uint32_t>(dom::PlaybackDirection::Normal) },
   { eCSSKeyword_reverse, static_cast<uint32_t>(dom::PlaybackDirection::Reverse) },
   { eCSSKeyword_alternate, static_cast<uint32_t>(dom::PlaybackDirection::Alternate) },
   { eCSSKeyword_alternate_reverse, static_cast<uint32_t>(dom::PlaybackDirection::Alternate_reverse) },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -684,16 +684,17 @@ public:
 #define CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(it_, prop_, enabledstate_)   \
   for (const nsCSSPropertyID *it_ = nsCSSProps::SubpropertyEntryFor(prop_), \
                             es_ = (nsCSSPropertyID)((enabledstate_) |       \
                                                   CSSEnabledState(0));    \
        *it_ != eCSSProperty_UNKNOWN; ++it_)                               \
     if (nsCSSProps::IsEnabled(*it_, (mozilla::CSSEnabledState) es_))
 
   // Keyword/Enum value tables
+  static const KTableEntry kAdjustmentKTable[];
   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 kAzimuthKTable[];
   static const KTableEntry kBackfaceVisibilityKTable[];
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -11,16 +11,22 @@
 #include "gfxRect.h"
 #include "nsFont.h"
 #include "X11UndefineNone.h"
 
 // XXX fold this into nsStyleContext and group by nsStyleXXX struct
 
 namespace mozilla {
 
+// -moz-adjustment
+enum class StyleAdjustment : uint8_t {
+  // No special adjustment applied.
+  None,
+};
+
 // Basic shapes
 enum class StyleBasicShapeType : uint8_t {
   Polygon,
   Circle,
   Ellipse,
   Inset,
 };
 
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3391,16 +3391,17 @@ StyleAnimation::operator==(const StyleAn
 }
 
 // --------------------
 // nsStyleDisplay
 //
 nsStyleDisplay::nsStyleDisplay(const nsPresContext* aContext)
   : mDisplay(StyleDisplay::Inline)
   , mOriginalDisplay(StyleDisplay::Inline)
+  , mAdjustment(StyleAdjustment::None)
   , mContain(NS_STYLE_CONTAIN_NONE)
   , mAppearance(NS_THEME_NONE)
   , mPosition(NS_STYLE_POSITION_STATIC)
   , mFloat(StyleFloat::None)
   , mOriginalFloat(StyleFloat::None)
   , mBreakType(StyleClear::None)
   , mBreakInside(NS_STYLE_PAGE_BREAK_AUTO)
   , mBreakBefore(false)
@@ -3453,16 +3454,17 @@ nsStyleDisplay::nsStyleDisplay(const nsP
   mTransitions[0].SetInitialValues();
   mAnimations[0].SetInitialValues();
 }
 
 nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
   : mBinding(aSource.mBinding)
   , mDisplay(aSource.mDisplay)
   , mOriginalDisplay(aSource.mOriginalDisplay)
+  , mAdjustment(aSource.mAdjustment)
   , mContain(aSource.mContain)
   , mAppearance(aSource.mAppearance)
   , mPosition(aSource.mPosition)
   , mFloat(aSource.mFloat)
   , mOriginalFloat(aSource.mOriginalFloat)
   , mBreakType(aSource.mBreakType)
   , mBreakInside(aSource.mBreakInside)
   , mBreakBefore(aSource.mBreakBefore)
@@ -3544,16 +3546,17 @@ nsStyleDisplay::~nsStyleDisplay()
 nsChangeHint
 nsStyleDisplay::CalcDifference(const nsStyleDisplay& aNewData) const
 {
   nsChangeHint hint = nsChangeHint(0);
 
   if (!DefinitelyEqualURIsAndPrincipal(mBinding.ForceGet(), aNewData.mBinding.ForceGet())
       || mPosition != aNewData.mPosition
       || mDisplay != aNewData.mDisplay
+      || mAdjustment != aNewData.mAdjustment
       || mContain != aNewData.mContain
       || (mFloat == StyleFloat::None) != (aNewData.mFloat == StyleFloat::None)
       || mScrollBehavior != aNewData.mScrollBehavior
       || mScrollSnapTypeX != aNewData.mScrollSnapTypeX
       || mScrollSnapTypeY != aNewData.mScrollSnapTypeY
       || mScrollSnapPointsX != aNewData.mScrollSnapPointsX
       || mScrollSnapPointsY != aNewData.mScrollSnapPointsY
       || mScrollSnapDestination != aNewData.mScrollSnapDestination
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2691,16 +2691,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   // mBinding->mOriginPrincipal.
   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
+  mozilla::StyleAdjustment mAdjustment;    // [reset]
   uint8_t mContain;             // [reset] see nsStyleConsts.h NS_STYLE_CONTAIN_*
   uint8_t mAppearance;          // [reset]
   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;
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -195,16 +195,22 @@
 </%helpers:longhand>
 
 ${helpers.single_keyword("-moz-top-layer", "none top",
                          gecko_constant_prefix="NS_STYLE_TOP_LAYER",
                          gecko_ffi_name="mTopLayer", need_clone=True,
                          products="gecko", animation_value_type="none", internal=True,
                          spec="Internal (not web-exposed)")}
 
+${helpers.single_keyword("-moz-adjustment", "none",
+                         gecko_enum_prefix="StyleAdjustment",
+                         gecko_ffi_name="mAdjustment", need_clone=True,
+                         products="gecko", animation_value_type="none", internal=True,
+                         spec="Internal (not web-exposed)")}
+
 ${helpers.single_keyword("position", "static absolute relative fixed sticky",
                          animation_value_type="discrete",
                          flags="CREATES_STACKING_CONTEXT ABSPOS_CB",
                          spec="https://drafts.csswg.org/css-position/#position-property")}
 
 <%helpers:single_keyword_computed name="float"
                                   values="none left right"
                                   // https://drafts.csswg.org/css-logical-props/#float-clear