diff --git a/Cargo.lock b/Cargo.lock index 49f256a2d5bb..47c8d2ff5f4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -832,6 +832,7 @@ dependencies = [ "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", diff --git a/servo/components/style/properties/longhands/box.mako.rs b/servo/components/style/properties/longhands/box.mako.rs index 06742d45e689..dcc292273017 100644 --- a/servo/components/style/properties/longhands/box.mako.rs +++ b/servo/components/style/properties/longhands/box.mako.rs @@ -23,24 +23,6 @@ ${helpers.predefined_type( 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", diff --git a/servo/components/style/values/specified/box.rs b/servo/components/style/values/specified/box.rs index 6b474689df37..9554d76890c2 100644 --- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -57,8 +57,8 @@ fn moz_box_display_values_enabled(context: &ParserContext) -> bool { /// 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 { diff --git a/servo/ports/geckolib/Cargo.toml b/servo/ports/geckolib/Cargo.toml index de2adda4707b..9aa4ba7e03cf 100644 --- a/servo/ports/geckolib/Cargo.toml +++ b/servo/ports/geckolib/Cargo.toml @@ -21,6 +21,7 @@ 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"} diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index be8eae810e68..e6fd51c53d39 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -3962,9 +3962,11 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue( 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; @@ -3974,7 +3976,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue( 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; diff --git a/servo/ports/geckolib/lib.rs b/servo/ports/geckolib/lib.rs index 79150f62bf75..467b20b191dc 100644 --- a/servo/ports/geckolib/lib.rs +++ b/servo/ports/geckolib/lib.rs @@ -9,6 +9,7 @@ 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;