Bug 1481781 - Add check for non-Copy specified value to ensure specified_is_copy always returns the right result. r=emilio
authorXidorn Quan <me@upsuper.org>
Wed, 08 Aug 2018 12:07:34 +0000
changeset 485627 4fabd8dc76ee44dc52d0c99e7680b7906a50a374
parent 485626 e1f77f6bc93fbbcb20dbcbce31885cc431785000
child 485628 9edf32fc60f3361c7b4ce89e62a64b98ce8ed337
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1481781
milestone63.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 1481781 - Add check for non-Copy specified value to ensure specified_is_copy always returns the right result. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D2931
servo/components/style/properties/data.py
servo/components/style/properties/longhands/box.mako.rs
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/properties/data.py
+++ b/servo/components/style/properties/data.py
@@ -285,48 +285,61 @@ class Longhand(object):
     def specified_is_copy(self):
         if self.is_vector or self.boxed:
             return False
         if self.predefined_type:
             return self.predefined_type in {
                 "AlignContent",
                 "AlignItems",
                 "AlignSelf",
+                "Appearance",
                 "BackgroundRepeat",
                 "BorderImageRepeat",
                 "BorderStyle",
+                "Clear",
                 "ColumnCount",
                 "Contain",
+                "Display",
+                "Float",
+                "FontSizeAdjust",
+                "FontStretch",
+                "FontStyle",
                 "FontStyleAdjust",
                 "FontSynthesis",
                 "FontWeight",
+                "GreaterThanOrEqualToOneNumber",
                 "GridAutoFlow",
                 "InitialLetter",
                 "Integer",
                 "JustifyContent",
                 "JustifyItems",
                 "JustifySelf",
                 "MozForceBrokenImageIcon",
                 "MozScriptLevel",
                 "MozScriptMinSize",
                 "MozScriptSizeMultiplier",
                 "NonNegativeNumber",
                 "Opacity",
                 "OutlineStyle",
+                "OverflowClipBox",
                 "OverscrollBehavior",
                 "Percentage",
+                "SVGOpacity",
                 "SVGPaintOrder",
                 "ScrollSnapType",
+                "TextAlign",
                 "TextDecorationLine",
                 "TouchAction",
                 "TransformStyle",
                 "XSpan",
                 "XTextZoom",
                 "ZIndex",
             }
+        if self.name == "overflow-y":
+            return True
         return bool(self.keyword)
 
     def animated_type(self):
         assert self.animatable
         computed = "<{} as ToComputedValue>::ComputedValue".format(self.base_type())
         if self.is_animatable_with_computed_value:
             return computed
         return "<{} as ToAnimatedValue>::AnimatedValue".format(computed)
--- a/servo/components/style/properties/longhands/box.mako.rs
+++ b/servo/components/style/properties/longhands/box.mako.rs
@@ -443,17 +443,17 @@
     extra_prefixes=transform_extra_prefixes,
     flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
     animation_value_type="AnimatedPerspective",
     servo_restyle_damage = "reflow_out_of_flow",
 )}
 
 ${helpers.predefined_type(
     "perspective-origin",
-    "position::Position",
+    "Position",
     "computed::position::Position::center()",
     boxed=True,
     extra_prefixes=transform_extra_prefixes,
     spec="https://drafts.csswg.org/css-transforms-2/#perspective-origin-property",
     flags="GETCS_NEEDS_LAYOUT_FLUSH",
     animation_value_type="ComputedValue",
     servo_restyle_damage="reflow_out_of_flow"
 )}
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -300,16 +300,31 @@ impl Clone for PropertyDeclaration {
                 ptr::write(
                     &mut out as *mut _ as *mut CopyVariants,
                     *(self as *const _ as *const CopyVariants),
                 );
                 return out;
             }
         }
 
+        // This function ensures that all properties not handled above
+        // do not have a specified value implements Copy. If you hit
+        // compile error here, you may want to add the type name into
+        // Longhand.specified_is_copy in data.py.
+        fn _static_assert_others_are_not_copy() {
+            struct Helper<T>(T);
+            trait AssertCopy { fn assert() {} }
+            trait AssertNotCopy { fn assert() {} }
+            impl<T: Copy> AssertCopy for Helper<T> {}
+            % for ty in set(x["type"] for x in others):
+            impl AssertNotCopy for Helper<${ty}> {}
+            Helper::<${ty}>::assert();
+            % endfor
+        }
+
         match *self {
             ${" |\n".join("{}(..)".format(v["name"]) for v in copy)} => {
                 unsafe { debug_unreachable!() }
             }
             % for ty, vs in groupby(others, key=lambda x: x["type"]):
             <%
                 vs = list(vs)
             %>