Bug 1485044: Remove useless StyleDisplay conversion. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 21 Aug 2018 17:34:21 +0200
changeset 432762 ab61273bea17b941baca4f3f85b6ca0362d56e22
parent 432761 e3e6a4d867a447d7c56827a491e6e2330838082b
child 432788 e5ac55ad643d95424b8891446a3743b53bcf6bfe
push id106865
push useremilio@crisal.io
push dateWed, 22 Aug 2018 09:26:28 +0000
treeherdermozilla-inbound@ab61273bea17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1485044
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 1485044: Remove useless StyleDisplay conversion. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D3896
Cargo.lock
servo/components/style/properties/longhands/box.mako.rs
servo/components/style/values/specified/box.rs
servo/ports/geckolib/Cargo.toml
servo/ports/geckolib/glue.rs
servo/ports/geckolib/lib.rs
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -827,16 +827,17 @@ version = "0.0.1"
 dependencies = [
  "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "malloc_size_of 0.0.1",
  "nsstring 0.1.0",
+ "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "selectors 0.19.0",
  "servo_arc 0.1.1",
  "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "style 0.0.1",
  "style_traits 0.0.1",
 ]
 
--- a/servo/components/style/properties/longhands/box.mako.rs
+++ b/servo/components/style/properties/longhands/box.mako.rs
@@ -18,34 +18,16 @@
     initial_specified_value="specified::Display::inline()",
     animation_value_type="discrete",
     flags="APPLIES_TO_PLACEHOLDER",
     spec="https://drafts.csswg.org/css-display/#propdef-display",
     servo_restyle_damage="rebuild_and_reflow",
     needs_context=product == "gecko"
 )}
 
-// FIXME(emilio): Listing all the display values here is very unfortunate, we should teach C++ to use the
-// Rust enum directly, or generate the conversions to `StyleDisplay`.
-${helpers.gecko_keyword_conversion(
-    Keyword('display', """
-        inline block inline-block
-        table inline-table table-row-group table-header-group table-footer-group
-        table-row table-column-group table-column table-cell table-caption
-        list-item none flex inline-flex grid inline-grid ruby ruby-base ruby-base-container
-        ruby-text ruby-text-container contents flow-root -webkit-box
-        -webkit-inline-box -moz-box -moz-inline-box -moz-grid -moz-inline-grid
-        -moz-grid-group -moz-grid-line -moz-stack -moz-inline-stack -moz-deck
-        -moz-popup -moz-groupbox
-    """,
-    gecko_enum_prefix='StyleDisplay',
-    gecko_strip_moz_prefix=False),
-    type="::values::specified::Display"
-)}
-
 ${helpers.single_keyword(
     "-moz-top-layer",
     "none top",
     gecko_constant_prefix="NS_STYLE_TOP_LAYER",
     gecko_ffi_name="mTopLayer",
     products="gecko",
     animation_value_type="none",
     enabled_in="ua",
--- a/servo/components/style/values/specified/box.rs
+++ b/servo/components/style/values/specified/box.rs
@@ -52,18 +52,18 @@ fn moz_box_display_values_enabled(contex
 ///
 /// If you change it, make sure to take a look at the
 /// FrameConstructionDataByDisplay stuff (both the XUL and non-XUL version), and
 /// ensure it's still correct!
 ///
 /// Also, when you change this from Gecko you may need to regenerate the
 /// C++-side bindings (see components/style/cbindgen.toml).
 #[allow(missing_docs)]
-#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq,
-         SpecifiedValueInfo, ToComputedValue, ToCss)]
+#[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, MallocSizeOf, Parse,
+         PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
 #[repr(u8)]
 pub enum Display {
     None = 0,
     Block,
     #[cfg(feature = "gecko")]
     FlowRoot,
     Inline,
--- a/servo/ports/geckolib/Cargo.toml
+++ b/servo/ports/geckolib/Cargo.toml
@@ -16,14 +16,15 @@ gecko_debug = ["style/gecko_debug"]
 [dependencies]
 atomic_refcell = "0.1"
 cssparser = "0.24.0"
 cstr = "0.1.2"
 libc = "0.2"
 log = {version = "0.4", features = ["release_max_level_info"]}
 malloc_size_of = {path = "../../components/malloc_size_of"}
 nsstring = {path = "../../support/gecko/nsstring"}
+num-traits = "0.2"
 parking_lot = "0.6"
 selectors = {path = "../../components/selectors"}
 servo_arc = {path = "../../components/servo_arc"}
 smallvec = "0.6"
 style = {path = "../../components/style", features = ["gecko"]}
 style_traits = {path = "../../components/style_traits"}
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -3957,29 +3957,31 @@ pub unsafe extern "C" fn Servo_Declarati
 
 #[no_mangle]
 #[allow(unreachable_code)]
 pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(
     declarations: RawServoDeclarationBlockBorrowed,
     property: nsCSSPropertyID,
     value: i32
 ) {
+    use num_traits::FromPrimitive;
     use style::properties::{PropertyDeclaration, LonghandId};
     use style::properties::longhands;
     use style::values::specified::BorderStyle;
+    use style::values::specified::Display;
     use style::values::specified::{Clear, Float};
     use style::values::generics::font::FontStyle;
 
     let long = get_longhand_from_id!(property);
     let value = value as u32;
 
     let prop = match_wrap_declared! { long,
         MozUserModify => longhands::_moz_user_modify::SpecifiedValue::from_gecko_keyword(value),
         Direction => longhands::direction::SpecifiedValue::from_gecko_keyword(value),
-        Display => longhands::display::SpecifiedValue::from_gecko_keyword(value),
+        Display => Display::from_u32(value).unwrap(),
         Float => {
             const LEFT: u32 = structs::StyleFloat::Left as u32;
             const RIGHT: u32 = structs::StyleFloat::Right as u32;
             const NONE: u32 = structs::StyleFloat::None as u32;
             match value {
                 LEFT => Float::Left,
                 RIGHT => Float::Right,
                 NONE => Float::None,
--- a/servo/ports/geckolib/lib.rs
+++ b/servo/ports/geckolib/lib.rs
@@ -4,16 +4,17 @@
 
 
 extern crate cssparser;
 #[macro_use] extern crate cstr;
 extern crate libc;
 #[macro_use] extern crate log;
 extern crate malloc_size_of;
 extern crate nsstring;
+extern crate num_traits;
 extern crate selectors;
 extern crate servo_arc;
 extern crate smallvec;
 #[macro_use] extern crate style;
 extern crate style_traits;
 
 mod error_reporter;
 #[allow(non_snake_case)]