diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-03-09 05:58:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-09 05:58:22 -0500 |
commit | 664efab4a33264c07d68013a0ac3585544556b72 (patch) | |
tree | e567cd393d789cfe69c5cff42fb91c1e68e3c730 | |
parent | 324e22db030ba73452dfc4ec455534fb144f585b (diff) | |
parent | afaa00a3447d33e531070c811dd23e5db46463db (diff) | |
download | servo-664efab4a33264c07d68013a0ac3585544556b72.tar.gz servo-664efab4a33264c07d68013a0ac3585544556b72.zip |
Auto merge of #20254 - servo:derive-all-the-things, r=emilio
Some random improvements to derived style code
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20254)
<!-- Reviewable:end -->
-rw-r--r-- | Cargo.lock | 60 | ||||
-rw-r--r-- | components/style/gecko/url.rs | 6 | ||||
-rw-r--r-- | components/style/properties/helpers/animated_properties.mako.rs | 4 | ||||
-rw-r--r-- | components/style/values/animated/mod.rs | 4 | ||||
-rw-r--r-- | components/style/values/computed/mod.rs | 1 | ||||
-rw-r--r-- | components/style/values/generics/basic_shape.rs | 5 | ||||
-rw-r--r-- | components/style/values/generics/grid.rs | 4 | ||||
-rw-r--r-- | components/style/values/generics/image.rs | 4 | ||||
-rw-r--r-- | components/style/values/generics/transform.rs | 2 | ||||
-rw-r--r-- | components/style/values/specified/mod.rs | 2 | ||||
-rw-r--r-- | components/style/values/specified/position.rs | 8 | ||||
-rw-r--r-- | components/style_derive/animate.rs | 102 | ||||
-rw-r--r-- | components/style_derive/to_css.rs | 8 |
13 files changed, 93 insertions, 117 deletions
diff --git a/Cargo.lock b/Cargo.lock index 28f9407074d..cbf5c1a7973 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,7 +94,7 @@ version = "0.28.0" source = "git+https://github.com/servo/rust-azure#29f0c063ad366b5364e06af26d3e9d1ee588e3b2" dependencies = [ "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "servo-freetype-sys 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "servo-skia 0.30000013.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -272,7 +272,7 @@ dependencies = [ "canvas_traits 0.0.1", "compositing 0.0.1", "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -289,7 +289,7 @@ name = "canvas_traits" version = "0.0.1" dependencies = [ "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", @@ -419,7 +419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "compositing" version = "0.0.1" dependencies = [ - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -452,7 +452,7 @@ dependencies = [ "compositing 0.0.1", "debugger 0.0.1", "devtools_traits 0.0.1", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gaol 0.0.1 (git+https://github.com/servo/gaol)", "gfx 0.0.1", "gfx_traits 0.0.1", @@ -859,7 +859,7 @@ dependencies = [ [[package]] name = "euclid" -version = "0.17.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1006,7 +1006,7 @@ dependencies = [ "core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "fontsan 0.4.0 (git+https://github.com/servo/fontsan)", "freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1390,7 +1390,7 @@ dependencies = [ "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "canvas_traits 0.0.1", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", @@ -1432,7 +1432,7 @@ version = "0.0.1" dependencies = [ "app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", @@ -1547,7 +1547,7 @@ dependencies = [ "devtools 0.0.1", "devtools_traits 0.0.1", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gaol 0.0.1 (git+https://github.com/servo/gaol)", "gfx 0.0.1", "gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1625,7 +1625,7 @@ version = "0.0.1" dependencies = [ "app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashglobe 0.1.0", "mozjs 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.19.0", @@ -2019,7 +2019,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2184,7 +2184,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2441,7 +2441,7 @@ dependencies = [ "dom_struct 0.0.1", "domobject_derive 0.0.1", "encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)", "half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2509,7 +2509,7 @@ dependencies = [ "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "canvas_traits 0.0.1", "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "html5ever 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2546,7 +2546,7 @@ dependencies = [ name = "script_tests" version = "0.0.1" dependencies = [ - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "script 0.0.1", "servo_url 0.0.1", @@ -2561,7 +2561,7 @@ dependencies = [ "canvas_traits 0.0.1", "cookie 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "devtools_traits 0.0.1", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2658,7 +2658,7 @@ dependencies = [ "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "compositing 0.0.1", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2725,7 +2725,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2786,7 +2786,7 @@ version = "0.0.1" dependencies = [ "android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2804,7 +2804,7 @@ name = "servo_geometry" version = "0.0.1" dependencies = [ "app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", "webrender_api 0.57.0 (git+https://github.com/servo/webrender)", @@ -2948,7 +2948,7 @@ dependencies = [ "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", "debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "fallible 0.0.1", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "hashglobe 0.1.0", @@ -3008,7 +3008,7 @@ dependencies = [ "app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3030,7 +3030,7 @@ dependencies = [ "app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", "selectors 0.19.0", @@ -3048,7 +3048,7 @@ dependencies = [ "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", "cstr 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "geckoservo 0.0.1", "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3450,7 +3450,7 @@ version = "0.0.1" dependencies = [ "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "cookie 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3480,7 +3480,7 @@ dependencies = [ "core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3507,7 +3507,7 @@ dependencies = [ "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3519,7 +3519,7 @@ name = "webvr" version = "0.0.1" dependencies = [ "canvas_traits 0.0.1", - "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", @@ -3767,7 +3767,7 @@ dependencies = [ "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" -"checksum euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5069a1354a7eecfdedc97e8e931b1fc455c4d06f5910380a3a049327ca7a0d0a" +"checksum euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "adfe67a9343519c1449d208da5998c6de582de698f7a39c4ac82ffba23d131a5" "checksum expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c470ccb972f2088549b023db8029ed9da9426f5affbf9b62efff7009ab8ed5b1" "checksum flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fac2277e84e5e858483756647a9d0aa8d9a2b7cba517fd84325a0aaa69a0909" "checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index e737b29926b..2642e174b01 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -121,7 +121,7 @@ impl MallocSizeOf for CssUrl { } /// A specified url() value for general usage. -#[derive(Clone, Debug, ToCss)] +#[derive(Clone, Debug, ToComputedValue, ToCss)] pub struct SpecifiedUrl { /// The specified url value. pub url: CssUrl, @@ -130,7 +130,6 @@ pub struct SpecifiedUrl { #[css(skip)] pub url_value: RefPtr<URLValue>, } -trivial_to_computed_value!(SpecifiedUrl); impl SpecifiedUrl { fn from_css_url(url: CssUrl) -> Self { @@ -177,7 +176,7 @@ impl MallocSizeOf for SpecifiedUrl { /// A specified url() value for image. /// /// This exists so that we can construct `ImageValue` and reuse it. -#[derive(Clone, Debug, ToCss)] +#[derive(Clone, Debug, ToComputedValue, ToCss)] pub struct SpecifiedImageUrl { /// The specified url value. pub url: CssUrl, @@ -186,7 +185,6 @@ pub struct SpecifiedImageUrl { #[css(skip)] pub image_value: RefPtr<ImageValue>, } -trivial_to_computed_value!(SpecifiedImageUrl); impl SpecifiedImageUrl { fn from_css_url(url: CssUrl) -> Self { diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 02fe6b2ba0e..570658c5301 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -78,7 +78,7 @@ pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool { /// a shorthand with at least one transitionable longhand component, or an unsupported property. // NB: This needs to be here because it needs all the longhands generated // beforehand. -#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] pub enum TransitionProperty { /// A shorthand. Shorthand(ShorthandId), @@ -89,8 +89,6 @@ pub enum TransitionProperty { Unsupported(CustomIdent), } -trivial_to_computed_value!(TransitionProperty); - impl TransitionProperty { /// Returns `all`. #[inline] diff --git a/components/style/values/animated/mod.rs b/components/style/values/animated/mod.rs index 04bab7375f1..ad81a4ecc4a 100644 --- a/components/style/values/animated/mod.rs +++ b/components/style/values/animated/mod.rs @@ -159,7 +159,7 @@ impl Animate for Au { impl<T> Animate for Size2D<T> where - T: Animate + Copy, + T: Animate, { #[inline] fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> { @@ -172,7 +172,7 @@ where impl<T> Animate for Point2D<T> where - T: Animate + Copy, + T: Animate, { #[inline] fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> { diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 1667f7ec8cf..ff16e328826 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -428,7 +428,6 @@ trivial_to_computed_value!(u8); trivial_to_computed_value!(u16); trivial_to_computed_value!(u32); trivial_to_computed_value!(Atom); -trivial_to_computed_value!(BorderStyle); trivial_to_computed_value!(CursorKind); #[cfg(feature = "servo")] trivial_to_computed_value!(Prefix); diff --git a/components/style/values/generics/basic_shape.rs b/components/style/values/generics/basic_shape.rs index e653508390f..ef9eac14ec7 100644 --- a/components/style/values/generics/basic_shape.rs +++ b/components/style/values/generics/basic_shape.rs @@ -18,7 +18,7 @@ pub type ClippingShape<BasicShape, Url> = ShapeSource<BasicShape, GeometryBox, U /// <https://drafts.fxtf.org/css-masking-1/#typedef-geometry-box> #[allow(missing_docs)] -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] pub enum GeometryBox { FillBox, StrokeBox, @@ -32,7 +32,7 @@ pub type FloatAreaShape<BasicShape, Image> = ShapeSource<BasicShape, ShapeBox, I /// https://drafts.csswg.org/css-shapes-1/#typedef-shape-box #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)] +#[derive(Animate, Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)] #[derive(ToComputedValue, ToCss)] pub enum ShapeBox { MarginBox, @@ -49,7 +49,6 @@ pub enum ShapeSource<BasicShape, ReferenceBox, ImageOrUrl> { ImageOrUrl(ImageOrUrl), Shape( BasicShape, - #[animation(constant)] Option<ReferenceBox>, ), #[animation(error)] diff --git a/components/style/values/generics/grid.rs b/components/style/values/generics/grid.rs index 2b519f1aa85..cc3256df7ab 100644 --- a/components/style/values/generics/grid.rs +++ b/components/style/values/generics/grid.rs @@ -566,7 +566,7 @@ impl<L: ToCss, I: ToCss> ToCss for TrackList<L, I> { /// /// `subgrid [ <line-names> | repeat(<positive-integer> | auto-fill, <line-names>+) ]+` /// Old spec: https://www.w3.org/TR/2015/WD-css-grid-1-20150917/#typedef-line-name-list -#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq)] +#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, ToComputedValue)] pub struct LineNameList { /// The optional `<line-name-list>` pub names: Box<[Box<[CustomIdent]>]>, @@ -574,8 +574,6 @@ pub struct LineNameList { pub fill_idx: Option<u32>, } -trivial_to_computed_value!(LineNameList); - impl Parse for LineNameList { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { input.expect_ident_matching("subgrid")?; diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs index 75751e39621..7f02fdec4f4 100644 --- a/components/style/values/generics/image.rs +++ b/components/style/values/generics/image.rs @@ -132,8 +132,8 @@ pub struct ColorStop<Color, LengthOrPercentage> { /// Specified values for a paint worklet. /// <https://drafts.css-houdini.org/css-paint-api/> -#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(MallocSizeOf))] +#[derive(Clone, Debug, PartialEq, ToComputedValue)] pub struct PaintWorklet { /// The name the worklet was registered with. pub name: Atom, @@ -143,8 +143,6 @@ pub struct PaintWorklet { pub arguments: Vec<Arc<custom_properties::SpecifiedValue>>, } -trivial_to_computed_value!(PaintWorklet); - impl ToCss for PaintWorklet { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index 816d8cc4cfd..1d96c9e9d84 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -298,7 +298,7 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage> }, } -#[derive(Animate, Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] /// A value of the `transform` property pub struct Transform<T>(#[css(if_empty = "none", iterable)] pub Vec<T>); diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 192c22a0a13..f0703699eaf 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -158,7 +158,7 @@ fn parse_number_with_clamping_mode<'i, 't>( #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Ord, Parse, PartialEq)] -#[derive(PartialOrd, ToCss)] +#[derive(PartialOrd, ToComputedValue, ToCss)] pub enum BorderStyle { None = -1, Solid = 6, diff --git a/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index 1f337560488..4a614aa1e03 100644 --- a/components/style/values/specified/position.rs +++ b/components/style/values/specified/position.rs @@ -509,7 +509,7 @@ impl From<GridAutoFlow> for u8 { } #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[derive(Clone, Debug, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)] /// https://drafts.csswg.org/css-grid/#named-grid-area pub struct TemplateAreas { /// `named area` containing for each template area @@ -614,10 +614,8 @@ impl Parse for TemplateAreas { } } -trivial_to_computed_value!(TemplateAreas); - /// Arc type for `Arc<TemplateAreas>` -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] pub struct TemplateAreasArc(#[ignore_malloc_size_of = "Arc"] pub Arc<TemplateAreas>); impl Parse for TemplateAreasArc { @@ -631,8 +629,6 @@ impl Parse for TemplateAreasArc { } } -trivial_to_computed_value!(TemplateAreasArc); - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] #[derive(Clone, Debug, PartialEq)] /// Not associated with any particular grid item, but can diff --git a/components/style_derive/animate.rs b/components/style_derive/animate.rs index f96469c079e..912f7dbc9f2 100644 --- a/components/style_derive/animate.rs +++ b/components/style_derive/animate.rs @@ -2,10 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use cg; +use cg::{self, WhereClause}; use quote::Tokens; use syn::{DeriveInput, Path}; -use synstructure; +use synstructure::{Structure, VariantInfo}; pub fn derive(input: DeriveInput) -> Tokens { let name = &input.ident; @@ -14,62 +14,18 @@ pub fn derive(input: DeriveInput) -> Tokens { cg::trait_parts(&input, &trait_path); let input_attrs = cg::parse_input_attrs::<AnimateInputAttrs>(&input); - let s = synstructure::Structure::new(&input); + let s = Structure::new(&input); let mut append_error_clause = s.variants().len() > 1; let mut match_body = s.variants().iter().fold(quote!(), |body, variant| { - let variant_attrs = cg::parse_variant_attrs::<AnimationVariantAttrs>(&variant.ast()); - if variant_attrs.error { - append_error_clause = true; - return body; - } - let (this_pattern, this_info) = cg::ref_pattern(&variant, "this"); - let (other_pattern, other_info) = cg::ref_pattern(&variant, "other"); - let (result_value, result_info) = cg::value(&variant, "result"); - let mut computations = quote!(); - let iter = result_info.iter().zip(this_info.iter().zip(&other_info)); - computations.append_all(iter.map(|(result, (this, other))| { - let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&result.ast()); - if field_attrs.constant { - if cg::is_parameterized(&result.ast().ty, &where_clause.params, None) { - cg::add_predicate( - &mut where_clause.inner, - cg::where_predicate( - result.ast().ty.clone(), - &parse_quote!(std::cmp::PartialEq), - None, - ), - ); - cg::add_predicate( - &mut where_clause.inner, - cg::where_predicate( - result.ast().ty.clone(), - &parse_quote!(std::clone::Clone), - None, - ), - ); - } - quote! { - if #this != #other { - return Err(()); - } - let #result = ::std::clone::Clone::clone(#this); - } - } else { - where_clause.add_trait_bound(&result.ast().ty); - quote! { - let #result = - ::values::animated::Animate::animate(#this, #other, procedure)?; - } + let arm = match derive_variant_arm(variant, &mut where_clause) { + Ok(arm) => arm, + Err(()) => { + append_error_clause = true; + return body; } - })); - quote! { - #body - (&#this_pattern, &#other_pattern) => { - #computations - Ok(#result_value) - } - } + }; + quote! { #body #arm } }); if append_error_clause { @@ -99,6 +55,44 @@ pub fn derive(input: DeriveInput) -> Tokens { } } +fn derive_variant_arm( + variant: &VariantInfo, + where_clause: &mut WhereClause, +) -> Result<Tokens, ()> { + let variant_attrs = cg::parse_variant_attrs::<AnimationVariantAttrs>(&variant.ast()); + if variant_attrs.error { + return Err(()); + } + let (this_pattern, this_info) = cg::ref_pattern(&variant, "this"); + let (other_pattern, other_info) = cg::ref_pattern(&variant, "other"); + let (result_value, result_info) = cg::value(&variant, "result"); + let mut computations = quote!(); + let iter = result_info.iter().zip(this_info.iter().zip(&other_info)); + computations.append_all(iter.map(|(result, (this, other))| { + let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&result.ast()); + if field_attrs.constant { + quote! { + if #this != #other { + return Err(()); + } + let #result = ::std::clone::Clone::clone(#this); + } + } else { + where_clause.add_trait_bound(&result.ast().ty); + quote! { + let #result = + ::values::animated::Animate::animate(#this, #other, procedure)?; + } + } + })); + Ok(quote! { + (&#this_pattern, &#other_pattern) => { + #computations + Ok(#result_value) + } + }) +} + #[darling(attributes(animate), default)] #[derive(Default, FromDeriveInput)] struct AnimateInputAttrs { diff --git a/components/style_derive/to_css.rs b/components/style_derive/to_css.rs index 1d3a2f2d230..4f8841810c1 100644 --- a/components/style_derive/to_css.rs +++ b/components/style_derive/to_css.rs @@ -5,16 +5,12 @@ use cg; use darling::util::Override; use quote::{ToTokens, Tokens}; -use syn::{self, Data, GenericParam, Path, WhereClause}; +use syn::{self, Data, Path, WhereClause}; use synstructure::{BindingInfo, Structure, VariantInfo}; pub fn derive(mut input: syn::DeriveInput) -> Tokens { let mut where_clause = input.generics.where_clause.take(); - for param in &input.generics.params { - let param = match *param { - GenericParam::Type(ref param) => param, - _ => continue, - }; + for param in input.generics.type_params() { cg::add_predicate( &mut where_clause, parse_quote!(#param: ::style_traits::ToCss), |