diff options
175 files changed, 1459 insertions, 1419 deletions
diff --git a/Cargo.lock b/Cargo.lock index 97f3f869cb8..19dae1aa9b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -137,14 +137,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "azure" -version = "0.36.0" -source = "git+https://github.com/servo/rust-azure#ca9cc643808f6f63576c5c2cd098e973406cc7f3" +version = "0.36.1" +source = "git+https://github.com/servo/rust-azure#37a57b3d862bcf345d1413c7ebb534ff69daab3b" dependencies = [ "cmake 0.1.40 (git+https://github.com/alexcrichton/cmake-rs)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "servo-freetype-sys 4.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "servo-skia 0.30000021.1 (registry+https://github.com/rust-lang/crates.io-index)", + "servo-skia 0.30000022.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -391,20 +391,20 @@ dependencies = [ name = "canvas" version = "0.0.1" dependencies = [ - "azure 0.36.0 (git+https://github.com/servo/rust-azure)", + "azure 0.36.1 (git+https://github.com/servo/rust-azure)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "canvas_traits 0.0.1", "cssparser 0.25.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "offscreen_gl_context 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", + "offscreen_gl_context 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "pixels 0.0.1", - "raqote 0.5.6-alpha.0 (git+https://github.com/jrmuizel/raqote)", + "raqote 0.6.1-alpha.0 (git+https://github.com/jrmuizel/raqote)", "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "servo_config 0.0.1", "webrender 0.60.0 (git+https://github.com/servo/webrender)", @@ -417,7 +417,7 @@ name = "canvas_traits" version = "0.0.1" dependencies = [ "cssparser 0.25.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -596,7 +596,7 @@ version = "0.0.1" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "embedder_traits 0.0.1", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -638,7 +638,7 @@ dependencies = [ "debugger 0.0.1", "devtools_traits 0.0.1", "embedder_traits 0.0.1", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gaol 0.2.0 (git+https://github.com/servo/gaol)", "gfx 0.0.1", "gfx_traits 0.0.1", @@ -1191,6 +1191,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "euclid" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1261,7 +1269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "font-kit" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1270,13 +1278,13 @@ dependencies = [ "core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon_path 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lyon_path 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "servo-fontconfig 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1399,7 +1407,7 @@ dependencies = [ "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "fontsan 0.4.0 (git+https://github.com/servo/fontsan)", "freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2277,13 +2285,14 @@ dependencies = [ "canvas_traits 0.0.1", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "embedder_traits 0.0.1", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", "html5ever 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", @@ -2330,7 +2339,7 @@ dependencies = [ "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "embedder_traits 0.0.1", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", @@ -2373,7 +2382,7 @@ name = "layout_thread_2020" version = "0.0.1" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "layout_2020 0.0.1", @@ -2394,7 +2403,7 @@ name = "layout_traits" version = "0.0.1" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "metrics 0.0.1", @@ -2492,7 +2501,7 @@ dependencies = [ "devtools_traits 0.0.1", "embedder_traits 0.0.1", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gaol 0.2.0 (git+https://github.com/servo/gaol)", "gfx 0.0.1", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2506,7 +2515,7 @@ dependencies = [ "msg 0.0.1", "net 0.0.1", "net_traits 0.0.1", - "offscreen_gl_context 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", + "offscreen_gl_context 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "profile 0.0.1", "profile_traits 0.0.1", "script 0.0.1", @@ -2588,20 +2597,20 @@ dependencies = [ [[package]] name = "lyon_geom" -version = "0.12.6" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lyon_path" -version = "0.12.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lyon_geom 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lyon_geom 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2637,7 +2646,7 @@ dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "hashglobe 0.1.0", "hyper 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2700,7 +2709,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "media" version = "0.0.1" dependencies = [ - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3141,12 +3150,12 @@ dependencies = [ [[package]] name = "offscreen_gl_context" -version = "0.22.4" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3303,6 +3312,27 @@ dependencies = [ ] [[package]] +name = "peek-poke" +version = "0.2.0" +source = "git+https://github.com/servo/webrender#964a2eb8d9ed25cfffe6dd446cfa21a37eefe9c7" +dependencies = [ + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "peek-poke-derive 0.2.0 (git+https://github.com/servo/webrender)", +] + +[[package]] +name = "peek-poke-derive" +version = "0.2.0" +source = "git+https://github.com/servo/webrender#964a2eb8d9ed25cfffe6dd446cfa21a37eefe9c7" +dependencies = [ + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "peeking_take_while" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3360,7 +3390,7 @@ dependencies = [ name = "pixels" version = "0.0.1" dependencies = [ - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3373,11 +3403,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "plane-split" -version = "0.13.7" +version = "0.14.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.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3605,12 +3635,12 @@ dependencies = [ [[package]] name = "raqote" -version = "0.5.6-alpha.0" -source = "git+https://github.com/jrmuizel/raqote#40dd11e85e4800061c4f31223199949804d3f8da" +version = "0.6.1-alpha.0" +source = "git+https://github.com/jrmuizel/raqote#4b9ae1986e3211d788dacc0a58ce4d5734dbdb44" dependencies = [ - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", - "font-kit 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lyon_geom 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "font-kit 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lyon_geom 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "png 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "sw-composite 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "typed-arena 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3812,7 +3842,7 @@ dependencies = [ "embedder_traits 0.0.1", "encoding_rs 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)", "enum-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "headers 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3892,7 +3922,7 @@ dependencies = [ "canvas_traits 0.0.1", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "html5ever 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3932,7 +3962,7 @@ dependencies = [ name = "script_tests" version = "0.0.1" dependencies = [ - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "keyboard-types 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "script 0.0.1", "servo_url 0.0.1", @@ -3948,7 +3978,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "devtools_traits 0.0.1", "embedder_traits 0.0.1", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4053,7 +4083,7 @@ dependencies = [ "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", "clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4251,12 +4281,12 @@ dependencies = [ [[package]] name = "servo-skia" -version = "0.30000021.1" +version = "0.30000022.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.40 (git+https://github.com/alexcrichton/cmake-rs)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "expat-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4301,7 +4331,7 @@ dependencies = [ "dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "embedder_traits 0.0.1", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4331,7 +4361,7 @@ name = "servo_geometry" version = "0.0.1" dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "style_traits 0.0.1", @@ -4597,7 +4627,7 @@ dependencies = [ "cssparser 0.25.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "fallible 0.0.1", "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "hashglobe 0.1.0", @@ -4663,7 +4693,7 @@ dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.21.0", @@ -4685,7 +4715,7 @@ dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5331,7 +5361,7 @@ dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "cookie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5354,7 +5384,7 @@ dependencies = [ [[package]] name = "webrender" version = "0.60.0" -source = "git+https://github.com/servo/webrender#2afa0c3ba85d2f6b219a1349268d1250760ebd64" +source = "git+https://github.com/servo/webrender#964a2eb8d9ed25cfffe6dd446cfa21a37eefe9c7" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5366,7 +5396,7 @@ dependencies = [ "core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "cstr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5376,7 +5406,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "plane-split 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", + "plane-split 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5395,18 +5425,18 @@ dependencies = [ [[package]] name = "webrender_api" version = "0.60.0" -source = "git+https://github.com/servo/webrender#2afa0c3ba85d2f6b219a1349268d1250760ebd64" +source = "git+https://github.com/servo/webrender#964a2eb8d9ed25cfffe6dd446cfa21a37eefe9c7" dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "peek-poke 0.2.0 (git+https://github.com/servo/webrender)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5417,7 +5447,7 @@ dependencies = [ [[package]] name = "webrender_build" version = "0.0.1" -source = "git+https://github.com/servo/webrender#2afa0c3ba85d2f6b219a1349268d1250760ebd64" +source = "git+https://github.com/servo/webrender#964a2eb8d9ed25cfffe6dd446cfa21a37eefe9c7" dependencies = [ "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5426,7 +5456,7 @@ dependencies = [ name = "webrender_traits" version = "0.0.1" dependencies = [ - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "webrender 0.60.0 (git+https://github.com/servo/webrender)", "webrender_api 0.60.0 (git+https://github.com/servo/webrender)", ] @@ -5437,7 +5467,7 @@ version = "0.0.1" dependencies = [ "canvas_traits 0.0.1", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5462,9 +5492,9 @@ dependencies = [ [[package]] name = "webxr" version = "0.0.1" -source = "git+https://github.com/servo/webxr#b5a4b93fcfb2b03ee264a8f95bbaa1500ff0a087" +source = "git+https://github.com/servo/webxr#43a54f4cbe0ed3037e5e2bf34769241a5bd3da60" dependencies = [ - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5474,9 +5504,9 @@ dependencies = [ [[package]] name = "webxr-api" version = "0.0.1" -source = "git+https://github.com/servo/webxr#b5a4b93fcfb2b03ee264a8f95bbaa1500ff0a087" +source = "git+https://github.com/servo/webxr#43a54f4cbe0ed3037e5e2bf34769241a5bd3da60" dependencies = [ - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5570,10 +5600,10 @@ dependencies = [ [[package]] name = "wr_malloc_size_of" version = "0.0.1" -source = "git+https://github.com/servo/webrender#2afa0c3ba85d2f6b219a1349268d1250760ebd64" +source = "git+https://github.com/servo/webrender#964a2eb8d9ed25cfffe6dd446cfa21a37eefe9c7" dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5688,7 +5718,7 @@ dependencies = [ "checksum atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb2dcb6e6d35f20276943cc04bb98e538b348d525a04ac79c10021561d202f21" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum azure 0.36.0 (git+https://github.com/servo/rust-azure)" = "<none>" +"checksum azure 0.36.1 (git+https://github.com/servo/rust-azure)" = "<none>" "checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" @@ -5776,6 +5806,7 @@ dependencies = [ "checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7a4719a544a67ed3fc33784c2bd2c6581663dfe83b719a6ae05c6dabc3b51c73" +"checksum euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4786521fec183792e755bf32cd0188e4e7628c6d0fcfd51426435b9081a106" "checksum euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdcb84c18ea5037a1c5a23039b4ff29403abce2e0d6b1daa11cf0bde2b30be15" "checksum expat-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" @@ -5784,7 +5815,7 @@ dependencies = [ "checksum flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fac2277e84e5e858483756647a9d0aa8d9a2b7cba517fd84325a0aaa69a0909" "checksum float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -"checksum font-kit 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da53acd00b0af3dbb578bdfa92d0acee09c7e4e4f4dfb4b9cb7d7bc57f135270" +"checksum font-kit 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b7ff8d2a0a660875d01689807925a45c5843bf90a1ef97ec52ef86ab0cafba" "checksum fontsan 0.4.0 (git+https://github.com/servo/fontsan)" = "<none>" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -5886,8 +5917,8 @@ dependencies = [ "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum lyon_geom 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0638070e85f0e8b5da3909d8c5c0a66785b18da96a1e8dc30acb0aea9770529a" -"checksum lyon_path 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e9dc8e0746b7cca11960b602f7fe037bb067746a01eab4aa502fed1494544843" +"checksum lyon_geom 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "69589b8844c0b3745cc031a35b62bc33b0fb9e5ba7613756d802c52861dcdb4c" +"checksum lyon_path 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bcb57ac24a5428539e2c7c0592766d5933c937d703f430990c669c00de96862" "checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" @@ -5928,7 +5959,7 @@ dependencies = [ "checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d" "checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" "checksum objc_id 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4730aa1c64d722db45f7ccc4113a3e2c465d018de6db4d3e7dfe031e8c8a297" -"checksum offscreen_gl_context 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)" = "154c923c8bf54299672a5121836a929395d763778525ce752c00b61249fe9cab" +"checksum offscreen_gl_context 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b6b1df447af7a71721bfc33697b364831d59c0c8668dae0e570a7993ca84bc8" "checksum opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51ecbcb821e1bd256d456fe858aaa7f380b63863eab2eb86eee1bd9f33dd6682" "checksum openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6c24d3508b4fb6da175c10baac54c578b33f09c89ae90c6fe9788b3b4768efdc" "checksum openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)" = "912f301a749394e1025d9dcddef6106ddee9252620e6d0a0e5f8d0681de9b129" @@ -5945,6 +5976,8 @@ dependencies = [ "checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" +"checksum peek-poke 0.2.0 (git+https://github.com/servo/webrender)" = "<none>" +"checksum peek-poke-derive 0.2.0 (git+https://github.com/servo/webrender)" = "<none>" "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356" "checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" @@ -5953,7 +5986,7 @@ dependencies = [ "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum plane-split 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9760bb0546502fcfae6d2d1d638fac6b9272027a3efae34060218152d0ce8387" +"checksum plane-split 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91821c7436aefc1b912552d494232efcaf9810c0189918749532be1e9dbace59" "checksum png 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9adebf7fb91ccf5eac9da1a8e00e83cb8ae882c3e8d8e4ad59da73cb8c82a2c9" "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" @@ -5973,7 +6006,7 @@ dependencies = [ "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -"checksum raqote 0.5.6-alpha.0 (git+https://github.com/jrmuizel/raqote)" = "<none>" +"checksum raqote 0.6.1-alpha.0 (git+https://github.com/jrmuizel/raqote)" = "<none>" "checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4" "checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" @@ -6015,7 +6048,7 @@ dependencies = [ "checksum servo-media-streams 0.1.0 (git+https://github.com/servo/media)" = "<none>" "checksum servo-media-traits 0.1.0 (git+https://github.com/servo/media)" = "<none>" "checksum servo-media-webrtc 0.1.0 (git+https://github.com/servo/media)" = "<none>" -"checksum servo-skia 0.30000021.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0a65022054874fc1f38dc45e19192accbae775784c3ff05c3875bcc176c19" +"checksum servo-skia 0.30000022.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2df44d1fcd25d158fc5430a588daaa4aec88df6306ddf2a079f99dfd52672102" "checksum servo_media_derive 0.1.0 (git+https://github.com/servo/media)" = "<none>" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index 93875f32242..dbc3b2a7200 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -21,14 +21,14 @@ azure = {git = "https://github.com/servo/rust-azure", optional = true} byteorder = "1" canvas_traits = {path = "../canvas_traits"} cssparser = "0.25" -euclid = "0.19" +euclid = "0.20" fnv = "1.0" gleam = "0.6.7" half = "1" ipc-channel = "0.11" log = "0.4" num-traits = "0.2" -offscreen_gl_context = {version = "0.22", features = ["serde", "osmesa"]} +offscreen_gl_context = {version = "0.23", features = ["serde", "osmesa"]} raqote = {git = "https://github.com/jrmuizel/raqote", optional = true} pixels = {path = "../pixels"} serde_bytes = "0.10" diff --git a/components/canvas/azure_backend.rs b/components/canvas/azure_backend.rs index 102cddd0565..57e53e6ab7e 100644 --- a/components/canvas/azure_backend.rs +++ b/components/canvas/azure_backend.rs @@ -16,7 +16,7 @@ use azure::azure_hl::{CapStyle, JoinStyle}; use azure::azure_hl::{LinearGradientPattern, RadialGradientPattern}; use canvas_traits::canvas::*; use cssparser::RGBA; -use euclid::{Point2D, Rect, Size2D, Transform2D, Vector2D}; +use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D}; pub struct AzureBackend; diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index 4a55529066c..43e48bc8a65 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -5,7 +5,7 @@ use crate::canvas_paint_thread::AntialiasMode; use canvas_traits::canvas::*; use cssparser::RGBA; -use euclid::{Point2D, Rect, Size2D, Transform2D, Vector2D}; +use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D}; use ipc_channel::ipc::{IpcSender, IpcSharedMemory}; use num_traits::ToPrimitive; #[allow(unused_imports)] @@ -13,6 +13,7 @@ use std::marker::PhantomData; use std::mem; use std::sync::Arc; use webrender::api::DirtyRect; +use webrender_api::units::RectExt; /// The canvas data stores a state machine for the current status of /// the path data and any relevant transformations that are @@ -123,12 +124,12 @@ struct PathBuilderRef<'a> { impl<'a> PathBuilderRef<'a> { fn line_to(&self, pt: &Point2D<f32>) { - let pt = self.transform.transform_point(pt); + let pt = self.transform.transform_point(*pt); self.builder.line_to(pt); } fn move_to(&self, pt: &Point2D<f32>) { - let pt = self.transform.transform_point(pt); + let pt = self.transform.transform_point(*pt); self.builder.move_to(pt); } @@ -142,32 +143,30 @@ impl<'a> PathBuilderRef<'a> { ), Point2D::new(rect.origin.x, rect.origin.y + rect.size.height), ); - self.builder.move_to(self.transform.transform_point(&first)); - self.builder - .line_to(self.transform.transform_point(&second)); - self.builder.line_to(self.transform.transform_point(&third)); - self.builder - .line_to(self.transform.transform_point(&fourth)); + self.builder.move_to(self.transform.transform_point(first)); + self.builder.line_to(self.transform.transform_point(second)); + self.builder.line_to(self.transform.transform_point(third)); + self.builder.line_to(self.transform.transform_point(fourth)); self.builder.close(); } fn quadratic_curve_to(&self, cp: &Point2D<f32>, endpoint: &Point2D<f32>) { self.builder.quadratic_curve_to( - &self.transform.transform_point(cp), - &self.transform.transform_point(endpoint), + &self.transform.transform_point(*cp), + &self.transform.transform_point(*endpoint), ) } fn bezier_curve_to(&self, cp1: &Point2D<f32>, cp2: &Point2D<f32>, endpoint: &Point2D<f32>) { self.builder.bezier_curve_to( - &self.transform.transform_point(cp1), - &self.transform.transform_point(cp2), - &self.transform.transform_point(endpoint), + &self.transform.transform_point(*cp1), + &self.transform.transform_point(*cp2), + &self.transform.transform_point(*endpoint), ) } fn arc(&self, center: &Point2D<f32>, radius: f32, start_angle: f32, end_angle: f32, ccw: bool) { - let center = self.transform.transform_point(center); + let center = self.transform.transform_point(*center); self.builder .arc(center, radius, start_angle, end_angle, ccw); } @@ -182,7 +181,7 @@ impl<'a> PathBuilderRef<'a> { end_angle: f32, ccw: bool, ) { - let center = self.transform.transform_point(center); + let center = self.transform.transform_point(*center); self.builder.ellipse( center, radius_x, @@ -200,7 +199,7 @@ impl<'a> PathBuilderRef<'a> { None => return None, }; let current_point = self.builder.get_current_point(); - Some(inverse.transform_point(&Point2D::new(current_point.x, current_point.y))) + Some(inverse.transform_point(Point2D::new(current_point.x, current_point.y))) } } @@ -1033,7 +1032,7 @@ impl<'a> CanvasData<'a> { ); let matrix = Transform2D::identity() .pre_translate(-source_rect.origin.to_vector().cast()) - .pre_mul(&self.state.transform); + .pre_transform(&self.state.transform); draw_target.set_transform(&matrix); draw_target } diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index f026311f2ee..e324c213d6e 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -4,7 +4,7 @@ use crate::canvas_data::*; use canvas_traits::canvas::*; -use euclid::Size2D; +use euclid::default::Size2D; use ipc_channel::ipc::{self, IpcSender}; use std::borrow::ToOwned; use std::collections::HashMap; diff --git a/components/canvas/gl_context.rs b/components/canvas/gl_context.rs index 84c907af617..e1e45f40a60 100644 --- a/components/canvas/gl_context.rs +++ b/components/canvas/gl_context.rs @@ -6,7 +6,7 @@ use super::webgl_thread::{GLState, WebGLImpl}; use canvas_traits::webgl::{ GLContextAttributes, GLLimits, WebGLCommand, WebGLCommandBacktrace, WebGLVersion, }; -use euclid::Size2D; +use euclid::default::Size2D; use gleam::gl; use offscreen_gl_context::{ ColorAttachmentType, DrawBuffer, GLContext, GLContextAttributes as RawGLContextAttributes, diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 482ee4090c8..e33203226c8 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -10,7 +10,7 @@ use crate::canvas_data::{ use crate::canvas_paint_thread::AntialiasMode; use canvas_traits::canvas::*; use cssparser::RGBA; -use euclid::{Point2D, Rect, Size2D, Transform2D, Vector2D}; +use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D}; use std::marker::PhantomData; pub struct RaqoteBackend; diff --git a/components/canvas/webgl_mode/inprocess.rs b/components/canvas/webgl_mode/inprocess.rs index 8584289b904..76d468390db 100644 --- a/components/canvas/webgl_mode/inprocess.rs +++ b/components/canvas/webgl_mode/inprocess.rs @@ -8,7 +8,7 @@ use canvas_traits::webgl::webgl_channel; use canvas_traits::webgl::DOMToTextureCommand; use canvas_traits::webgl::{WebGLChan, WebGLContextId, WebGLMsg, WebGLPipeline, WebGLReceiver}; use canvas_traits::webgl::{WebGLSender, WebVRCommand, WebVRRenderHandler}; -use euclid::Size2D; +use euclid::default::Size2D; use fnv::FnvHashMap; use gleam::gl; use servo_config::pref; diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index b275e62bc7a..ce73b03cf09 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -5,7 +5,7 @@ use super::gl_context::{map_attrs_to_script_attrs, GLContextFactory, GLContextWrapper}; use byteorder::{ByteOrder, NativeEndian, WriteBytesExt}; use canvas_traits::webgl::*; -use euclid::Size2D; +use euclid::default::Size2D; use fnv::FnvHashMap; use gleam::gl; use half::f16; diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index 52388be8863..b8b34b7c960 100644 --- a/components/canvas_traits/Cargo.toml +++ b/components/canvas_traits/Cargo.toml @@ -15,7 +15,7 @@ webgl_backtrace = [] [dependencies] cssparser = "0.25" -euclid = "0.19" +euclid = "0.20" ipc-channel = "0.11" gleam = "0.6.7" lazy_static = "1" diff --git a/components/canvas_traits/canvas.rs b/components/canvas_traits/canvas.rs index 7f3d0ef20ca..ff7e65722e3 100644 --- a/components/canvas_traits/canvas.rs +++ b/components/canvas_traits/canvas.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use euclid::{Point2D, Rect, Size2D, Transform2D}; +use euclid::default::{Point2D, Rect, Size2D, Transform2D}; use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSender, IpcSharedMemory}; use serde_bytes::ByteBuf; use std::default::Default; diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index 6ac103f629f..b33f5eae1be 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use euclid::{Rect, Size2D}; +use euclid::default::{Rect, Size2D}; use gleam::gl; use gleam::gl::GLsync; use gleam::gl::GLuint; diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 2d5fa600376..fb98050d022 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -18,7 +18,7 @@ gl = ["gleam", "pixels"] [dependencies] crossbeam-channel = "0.3" embedder_traits = {path = "../embedder_traits"} -euclid = "0.19" +euclid = "0.20" gfx_traits = {path = "../gfx_traits"} gleam = {version = "0.6", optional = true} image = "0.21" diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 4f42867ae67..98de79cc3f8 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -14,7 +14,7 @@ use crate::CompositionPipeline; use crate::SendableFrameTree; use crossbeam_channel::Sender; use embedder_traits::Cursor; -use euclid::{TypedPoint2D, TypedScale, TypedVector2D}; +use euclid::{Point2D, Scale, Vector2D}; use gfx_traits::Epoch; #[cfg(feature = "gl")] use image::{DynamicImage, ImageFormat}; @@ -115,7 +115,7 @@ pub struct IOCompositor<Window: WindowMethods + ?Sized> { pipeline_details: HashMap<PipelineId, PipelineDetails>, /// The scene scale, to allow for zooming and high-resolution painting. - scale: TypedScale<f32, LayerPixel, DevicePixel>, + scale: Scale<f32, LayerPixel, DevicePixel>, /// "Mobile-style" zoom that does not reflow the page. viewport_zoom: PinchZoomFactor, @@ -125,7 +125,7 @@ pub struct IOCompositor<Window: WindowMethods + ?Sized> { max_viewport_zoom: Option<PinchZoomFactor>, /// "Desktop-style" zoom that resizes the viewport to fit the window. - page_zoom: TypedScale<f32, CSSPixel, DeviceIndependentPixel>, + page_zoom: Scale<f32, CSSPixel, DeviceIndependentPixel>, /// The type of composition to perform composite_target: CompositeTarget, @@ -296,14 +296,14 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { port: state.receiver, root_pipeline: None, pipeline_details: HashMap::new(), - scale: TypedScale::new(1.0), + scale: Scale::new(1.0), composition_request: CompositionRequest::NoCompositingNecessary, touch_handler: TouchHandler::new(), pending_scroll_zoom_events: Vec::new(), waiting_for_results_of_scroll: false, composite_target, shutdown_state: ShutdownState::NotShuttingDown, - page_zoom: TypedScale::new(1.0), + page_zoom: Scale::new(1.0), viewport_zoom: PinchZoomFactor::new(1.0), min_viewport_zoom: None, max_viewport_zoom: None, @@ -741,7 +741,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { let dppx = self.page_zoom * self.hidpi_factor(); let scaled_point = (point / dppx).to_untyped(); - let world_cursor = webrender_api::units::WorldPoint::from_untyped(&scaled_point); + let world_cursor = webrender_api::units::WorldPoint::from_untyped(scaled_point); self.webrender_api.hit_test( self.webrender_document, None, @@ -845,15 +845,15 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { fn on_touch_move(&mut self, identifier: TouchId, point: DevicePoint) { match self.touch_handler.on_touch_move(identifier, point) { TouchAction::Scroll(delta) => self.on_scroll_window_event( - ScrollLocation::Delta(LayoutVector2D::from_untyped(&delta.to_untyped())), + ScrollLocation::Delta(LayoutVector2D::from_untyped(delta.to_untyped())), point.cast(), ), TouchAction::Zoom(magnification, scroll_delta) => { - let cursor = TypedPoint2D::new(-1, -1); // Make sure this hits the base layer. + let cursor = Point2D::new(-1, -1); // Make sure this hits the base layer. self.pending_scroll_zoom_events.push(ScrollZoomEvent { magnification: magnification, scroll_location: ScrollLocation::Delta(LayoutVector2D::from_untyped( - &scroll_delta.to_untyped(), + scroll_delta.to_untyped(), )), cursor: cursor, event_count: 1, @@ -942,7 +942,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { *last_combined_event = Some(ScrollZoomEvent { magnification: scroll_event.magnification, scroll_location: ScrollLocation::Delta(LayoutVector2D::from_untyped( - &this_delta.to_untyped(), + this_delta.to_untyped(), )), cursor: this_cursor, event_count: 1, @@ -954,11 +954,9 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { // nasty-looking "pops". To mitigate this, during a fling we average // deltas instead of summing them. if let ScrollLocation::Delta(delta) = last_combined_event.scroll_location { - let old_event_count = - TypedScale::new(last_combined_event.event_count as f32); + let old_event_count = Scale::new(last_combined_event.event_count as f32); last_combined_event.event_count += 1; - let new_event_count = - TypedScale::new(last_combined_event.event_count as f32); + let new_event_count = Scale::new(last_combined_event.event_count as f32); last_combined_event.scroll_location = ScrollLocation::Delta( (delta * old_event_count + this_delta) / new_event_count, ); @@ -971,17 +969,16 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { if let Some(combined_event) = last_combined_event { let scroll_location = match combined_event.scroll_location { ScrollLocation::Delta(delta) => { - let scaled_delta = (TypedVector2D::from_untyped(&delta.to_untyped()) / - self.scale) - .to_untyped(); - let calculated_delta = LayoutVector2D::from_untyped(&scaled_delta); + let scaled_delta = + (Vector2D::from_untyped(delta.to_untyped()) / self.scale).to_untyped(); + let calculated_delta = LayoutVector2D::from_untyped(scaled_delta); ScrollLocation::Delta(calculated_delta) }, // Leave ScrollLocation unchanged if it is Start or End location. sl @ ScrollLocation::Start | sl @ ScrollLocation::End => sl, }; let cursor = (combined_event.cursor.to_f32() / self.scale).to_untyped(); - let cursor = webrender_api::units::WorldPoint::from_untyped(&cursor); + let cursor = webrender_api::units::WorldPoint::from_untyped(cursor); let mut txn = webrender_api::Transaction::new(); txn.scroll(scroll_location, cursor); if combined_event.magnification != 1.0 { @@ -1063,34 +1060,34 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { } } - fn hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { + fn hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> { match self.device_pixels_per_px { - Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px), + Some(device_pixels_per_px) => Scale::new(device_pixels_per_px), None => match self.output_file { - Some(_) => TypedScale::new(1.0), + Some(_) => Scale::new(1.0), None => self.embedder_coordinates.hidpi_factor, }, } } - fn device_pixels_per_page_px(&self) -> TypedScale<f32, CSSPixel, DevicePixel> { + fn device_pixels_per_page_px(&self) -> Scale<f32, CSSPixel, DevicePixel> { self.page_zoom * self.hidpi_factor() } fn update_zoom_transform(&mut self) { let scale = self.device_pixels_per_page_px(); - self.scale = TypedScale::new(scale.get()); + self.scale = Scale::new(scale.get()); } pub fn on_zoom_reset_window_event(&mut self) { - self.page_zoom = TypedScale::new(1.0); + self.page_zoom = Scale::new(1.0); self.update_zoom_transform(); self.send_window_size(WindowSizeType::Resize); self.update_page_zoom_for_webrender(); } pub fn on_zoom_window_event(&mut self, magnification: f32) { - self.page_zoom = TypedScale::new( + self.page_zoom = Scale::new( (self.page_zoom.get() * magnification) .max(MIN_ZOOM) .min(MAX_ZOOM), @@ -1113,8 +1110,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { pub fn on_pinch_zoom_window_event(&mut self, magnification: f32) { self.pending_scroll_zoom_events.push(ScrollZoomEvent { magnification: magnification, - scroll_location: ScrollLocation::Delta(TypedVector2D::zero()), // TODO: Scroll to keep the center in view? - cursor: TypedPoint2D::new(-1, -1), // Make sure this hits the base layer. + scroll_location: ScrollLocation::Delta(Vector2D::zero()), // TODO: Scroll to keep the center in view? + cursor: Point2D::new(-1, -1), // Make sure this hits the base layer. event_count: 1, }); } @@ -1127,7 +1124,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { { let scroll_state = ScrollState { scroll_id: scroll_layer_state.id, - scroll_offset: scroll_layer_state.scroll_offset.to_untyped(), + scroll_offset: scroll_layer_state.scroll_offset, }; scroll_states_per_pipeline @@ -1243,12 +1240,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { &mut self, target: CompositeTarget, ) -> Result<Option<Image>, UnableToComposite> { - let width = self.embedder_coordinates.framebuffer.to_u32().width_typed(); - let height = self - .embedder_coordinates - .framebuffer - .to_u32() - .height_typed(); + let size = self.embedder_coordinates.framebuffer.to_u32(); self.window.prepare_for_composite(); self.webrender.update(); @@ -1279,8 +1271,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { #[cfg(feature = "gl")] CompositeTarget::WindowAndPng | CompositeTarget::PngFile => gl::initialize_png( &*self.window.gl(), - FramebufferUintLength::new(width.get()), - FramebufferUintLength::new(height.get()), + FramebufferUintLength::new(size.width), + FramebufferUintLength::new(size.height), ), #[cfg(not(feature = "gl"))] _ => (), @@ -1293,9 +1285,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { || { debug!("compositor: compositing"); - let size = DeviceIntSize::from_untyped( - &self.embedder_coordinates.framebuffer.to_untyped(), - ); + let size = + DeviceIntSize::from_untyped(self.embedder_coordinates.framebuffer.to_untyped()); // Paint the scene. // TODO(gw): Take notice of any errors the renderer returns! @@ -1346,8 +1337,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { let img = gl::draw_img( &*self.window.gl(), rt_info, - FramebufferUintLength::new(width.get()), - FramebufferUintLength::new(height.get()), + FramebufferUintLength::new(size.width), + FramebufferUintLength::new(size.height), ); Some(Image { width: img.width(), @@ -1370,8 +1361,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> { let img = gl::draw_img( gl, rt_info, - FramebufferUintLength::new(width.get()), - FramebufferUintLength::new(height.get()), + FramebufferUintLength::new(size.width), + FramebufferUintLength::new(size.height), ); let dynamic_image = DynamicImage::ImageRgb8(img); if let Err(e) = dynamic_image.write_to(&mut file, ImageFormat::PNG) diff --git a/components/compositing/touch.rs b/components/compositing/touch.rs index 44aa3ff1ad7..24082054b51 100644 --- a/components/compositing/touch.rs +++ b/components/compositing/touch.rs @@ -3,8 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use self::TouchState::*; -use euclid::TypedScale; -use euclid::{TypedPoint2D, TypedVector2D}; +use euclid::{Point2D, Scale, Vector2D}; use script_traits::{EventResult, TouchId}; use style_traits::DevicePixel; @@ -19,11 +18,11 @@ pub struct TouchHandler { #[derive(Clone, Copy, Debug)] pub struct TouchPoint { pub id: TouchId, - pub point: TypedPoint2D<f32, DevicePixel>, + pub point: Point2D<f32, DevicePixel>, } impl TouchPoint { - pub fn new(id: TouchId, point: TypedPoint2D<f32, DevicePixel>) -> Self { + pub fn new(id: TouchId, point: Point2D<f32, DevicePixel>) -> Self { TouchPoint { id: id, point: point, @@ -60,9 +59,9 @@ pub enum TouchAction { /// Simulate a mouse click. Click, /// Scroll by the provided offset. - Scroll(TypedVector2D<f32, DevicePixel>), + Scroll(Vector2D<f32, DevicePixel>), /// Zoom by a magnification factor and scroll by the provided offset. - Zoom(f32, TypedVector2D<f32, DevicePixel>), + Zoom(f32, Vector2D<f32, DevicePixel>), /// Send a JavaScript event to content. DispatchEvent, /// Don't do anything. @@ -77,7 +76,7 @@ impl TouchHandler { } } - pub fn on_touch_down(&mut self, id: TouchId, point: TypedPoint2D<f32, DevicePixel>) { + pub fn on_touch_down(&mut self, id: TouchId, point: Point2D<f32, DevicePixel>) { let point = TouchPoint::new(id, point); self.active_touch_points.push(point); @@ -90,11 +89,7 @@ impl TouchHandler { }; } - pub fn on_touch_move( - &mut self, - id: TouchId, - point: TypedPoint2D<f32, DevicePixel>, - ) -> TouchAction { + pub fn on_touch_move(&mut self, id: TouchId, point: Point2D<f32, DevicePixel>) -> TouchAction { let idx = match self.active_touch_points.iter_mut().position(|t| t.id == id) { Some(i) => i, None => { @@ -128,7 +123,7 @@ impl TouchHandler { let (d1, c1) = self.pinch_distance_and_center(); let magnification = d1 / d0; - let scroll_delta = c1 - c0 * TypedScale::new(magnification); + let scroll_delta = c1 - c0 * Scale::new(magnification); TouchAction::Zoom(magnification, scroll_delta) }, @@ -145,11 +140,7 @@ impl TouchHandler { action } - pub fn on_touch_up( - &mut self, - id: TouchId, - _point: TypedPoint2D<f32, DevicePixel>, - ) -> TouchAction { + pub fn on_touch_up(&mut self, id: TouchId, _point: Point2D<f32, DevicePixel>) -> TouchAction { match self.active_touch_points.iter().position(|t| t.id == id) { Some(i) => { self.active_touch_points.swap_remove(i); @@ -182,7 +173,7 @@ impl TouchHandler { } } - pub fn on_touch_cancel(&mut self, id: TouchId, _point: TypedPoint2D<f32, DevicePixel>) { + pub fn on_touch_cancel(&mut self, id: TouchId, _point: Point2D<f32, DevicePixel>) { match self.active_touch_points.iter().position(|t| t.id == id) { Some(i) => { self.active_touch_points.swap_remove(i); @@ -225,7 +216,7 @@ impl TouchHandler { self.active_touch_points.len() } - fn pinch_distance_and_center(&self) -> (f32, TypedPoint2D<f32, DevicePixel>) { + fn pinch_distance_and_center(&self) -> (f32, Point2D<f32, DevicePixel>) { debug_assert_eq!(self.touch_count(), 2); let p0 = self.active_touch_points[0].point; let p1 = self.active_touch_points[1].point; diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index d668b03979e..7e5b1530931 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -5,7 +5,7 @@ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. use embedder_traits::EventLoopWaker; -use euclid::TypedScale; +use euclid::Scale; #[cfg(feature = "gl")] use gleam::gl; use keyboard_types::KeyboardEvent; @@ -183,7 +183,7 @@ pub trait EmbedderMethods { #[derive(Clone, Copy, Debug)] pub struct EmbedderCoordinates { /// The pixel density of the display. - pub hidpi_factor: TypedScale<f32, DeviceIndependentPixel, DevicePixel>, + pub hidpi_factor: Scale<f32, DeviceIndependentPixel, DevicePixel>, /// Size of the screen. pub screen: DeviceIntSize, /// Size of the available screen space (screen without toolbars and docks). diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index 4698bfe9a35..568d2acb92b 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -14,7 +14,7 @@ name = "servo_config" path = "lib.rs" [dependencies] -euclid = "0.19" +euclid = "0.20" embedder_traits = { path = "../embedder_traits" } getopts = "0.2.11" lazy_static = "1" diff --git a/components/config/opts.rs b/components/config/opts.rs index 49fa0fee344..ffc557c0a46 100644 --- a/components/config/opts.rs +++ b/components/config/opts.rs @@ -6,7 +6,7 @@ //! from command line arguments. use crate::prefs::{self, PrefValue}; -use euclid::TypedSize2D; +use euclid::Size2D; use getopts::Options; use servo_geometry::DeviceIndependentPixel; use servo_url::ServoUrl; @@ -135,7 +135,7 @@ pub struct Opts { pub webdriver_port: Option<u16>, /// The initial requested size of the window. - pub initial_window_size: TypedSize2D<u32, DeviceIndependentPixel>, + pub initial_window_size: Size2D<u32, DeviceIndependentPixel>, /// An optional string allowing the user agent to be set for testing. pub user_agent: Cow<'static, str>, @@ -576,7 +576,7 @@ pub fn default_opts() -> Opts { debugger_port: None, devtools_port: None, webdriver_port: None, - initial_window_size: TypedSize2D::new(1024, 740), + initial_window_size: Size2D::new(1024, 740), user_agent: default_user_agent_string(DEFAULT_USER_AGENT).into(), multiprocess: false, random_pipeline_closure_probability: None, @@ -954,9 +954,9 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult { }) }) .collect(); - TypedSize2D::new(res[0], res[1]) + Size2D::new(res[0], res[1]) }, - None => TypedSize2D::new(1024, 740), + None => Size2D::new(1024, 740), }; if opt_match.opt_present("M") { diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index f5270aa2d90..835211f9c20 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -26,7 +26,7 @@ compositing = {path = "../compositing"} crossbeam-channel = "0.3" debugger = {path = "../debugger"} devtools_traits = {path = "../devtools_traits"} -euclid = "0.19" +euclid = "0.20" embedder_traits = { path = "../embedder_traits" } gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} diff --git a/components/constellation/browsingcontext.rs b/components/constellation/browsingcontext.rs index e63d0701258..d90cb79cadd 100644 --- a/components/constellation/browsingcontext.rs +++ b/components/constellation/browsingcontext.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::pipeline::Pipeline; -use euclid::TypedSize2D; +use euclid::Size2D; use msg::constellation_msg::{ BrowsingContextGroupId, BrowsingContextId, PipelineId, TopLevelBrowsingContextId, }; @@ -46,7 +46,7 @@ pub struct BrowsingContext { pub top_level_id: TopLevelBrowsingContextId, /// The size of the frame. - pub size: TypedSize2D<f32, CSSPixel>, + pub size: Size2D<f32, CSSPixel>, /// Whether this browsing context is in private browsing mode. pub is_private: bool, @@ -76,7 +76,7 @@ impl BrowsingContext { top_level_id: TopLevelBrowsingContextId, pipeline_id: PipelineId, parent_pipeline_id: Option<PipelineId>, - size: TypedSize2D<f32, CSSPixel>, + size: Size2D<f32, CSSPixel>, is_private: bool, is_visible: bool, ) -> BrowsingContext { diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 9e14e38f645..9a4d8b3e93f 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -113,7 +113,7 @@ use compositing::SendableFrameTree; use crossbeam_channel::{unbounded, Receiver, Sender}; use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg}; use embedder_traits::{Cursor, EmbedderMsg, EmbedderProxy}; -use euclid::{Size2D, TypedScale, TypedSize2D}; +use euclid::{default::Size2D as UntypedSize2D, Scale, Size2D}; use gfx::font_cache_thread::FontCacheThread; use gfx_traits::Epoch; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; @@ -644,7 +644,7 @@ where /// Create a new constellation thread. pub fn start( state: InitialConstellationState, - initial_window_size: TypedSize2D<u32, DeviceIndependentPixel>, + initial_window_size: Size2D<u32, DeviceIndependentPixel>, device_pixels_per_px: Option<f32>, random_pipeline_closure_probability: Option<f32>, random_pipeline_closure_seed: Option<usize>, @@ -738,8 +738,8 @@ where time_profiler_chan: state.time_profiler_chan, mem_profiler_chan: state.mem_profiler_chan, window_size: WindowSizeData { - initial_viewport: initial_window_size.to_f32() * TypedScale::new(1.0), - device_pixel_ratio: TypedScale::new(device_pixels_per_px.unwrap_or(1.0)), + initial_viewport: initial_window_size.to_f32() * Scale::new(1.0), + device_pixel_ratio: Scale::new(device_pixels_per_px.unwrap_or(1.0)), }, phantom: PhantomData, webdriver: WebDriverData::new(), @@ -903,7 +903,7 @@ where top_level_browsing_context_id: TopLevelBrowsingContextId, parent_pipeline_id: Option<PipelineId>, opener: Option<BrowsingContextId>, - initial_window_size: TypedSize2D<f32, CSSPixel>, + initial_window_size: Size2D<f32, CSSPixel>, // TODO: we have to provide ownership of the LoadData // here, because it will be send on an ipc channel, // and ipc channels take onership of their data. @@ -1078,7 +1078,7 @@ where top_level_id: TopLevelBrowsingContextId, pipeline_id: PipelineId, parent_pipeline_id: Option<PipelineId>, - size: TypedSize2D<f32, CSSPixel>, + size: Size2D<f32, CSSPixel>, is_private: bool, is_visible: bool, ) { @@ -3341,7 +3341,7 @@ where fn handle_create_canvas_paint_thread_msg( &mut self, - size: Size2D<u64>, + size: UntypedSize2D<u64>, response_sender: IpcSender<(IpcSender<CanvasMsg>, CanvasId)>, ) { let webrender_api = self.webrender_api_sender.clone(); @@ -4015,7 +4015,7 @@ where // If the rectangle for this pipeline is zero sized, it will // never be painted. In this case, don't query the layout // thread as it won't contribute to the final output image. - if browsing_context.size == TypedSize2D::zero() { + if browsing_context.size == Size2D::zero() { continue; } diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index 36e6284ab1a..d2c006d368c 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -11,7 +11,7 @@ use compositing::CompositionPipeline; use compositing::CompositorProxy; use crossbeam_channel::Sender; use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg}; -use euclid::{TypedScale, TypedSize2D}; +use euclid::{Scale, Size2D}; use gfx::font_cache_thread::FontCacheThread; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; @@ -158,10 +158,10 @@ pub struct InitialPipelineState { pub mem_profiler_chan: profile_mem::ProfilerChan, /// Information about the initial window size. - pub window_size: TypedSize2D<f32, CSSPixel>, + pub window_size: Size2D<f32, CSSPixel>, /// Information about the device pixel ratio. - pub device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + pub device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, /// The event loop to run in, if applicable. pub event_loop: Option<Rc<EventLoop>>, diff --git a/components/geometry/Cargo.toml b/components/geometry/Cargo.toml index 407fbe81e78..387f17a1e55 100644 --- a/components/geometry/Cargo.toml +++ b/components/geometry/Cargo.toml @@ -12,7 +12,7 @@ path = "lib.rs" [dependencies] app_units = "0.7" -euclid = "0.19" +euclid = "0.20" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = "0.1" style_traits = { path = "../style_traits" } diff --git a/components/geometry/lib.rs b/components/geometry/lib.rs index 155551ee3d9..fd579b7f9bd 100644 --- a/components/geometry/lib.rs +++ b/components/geometry/lib.rs @@ -6,7 +6,10 @@ extern crate malloc_size_of_derive; use app_units::{Au, MAX_AU, MIN_AU}; -use euclid::{Length, Point2D, Rect, Size2D}; +use euclid::{ + default::{Point2D, Rect, Size2D}, + Length, +}; use std::f32; use webrender_api::units::{FramebufferPixel, LayoutPoint, LayoutRect, LayoutSize}; diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index 8d2dbd33ad9..ba751a45e0d 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -16,7 +16,7 @@ doctest = false [dependencies] app_units = "0.7" bitflags = "1.0" -euclid = "0.19" +euclid = "0.20" fnv = "1.0" fontsan = {git = "https://github.com/servo/fontsan"} gfx_traits = {path = "../gfx_traits"} diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 35ce19621ac..3dd5ac9f244 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -12,7 +12,7 @@ use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; use crate::text::shaping::ShaperMethods; use crate::text::Shaper; use app_units::Au; -use euclid::{Point2D, Rect, Size2D}; +use euclid::default::{Point2D, Rect, Size2D}; use ordered_float::NotNan; use servo_atoms::Atom; use smallvec::SmallVec; diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 82d002e61f4..99595eb47c8 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; #[cfg(any(target_feature = "sse2", target_feature = "neon"))] use packed_simd::u32x4; use range::{self, EachIndex, Range, RangeIndex}; diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index ce8ce628f08..9599dd61a12 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -10,7 +10,7 @@ use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; use crate::text::shaping::ShaperMethods; use crate::text::util::{fixed_to_float, float_to_fixed, is_bidi_control}; use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; // Eventually we would like the shaper to be pluggable, as many operating systems have their own // shapers. For now, however, HarfBuzz is a hard dependency. use harfbuzz_sys::hb_blob_t; diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index a6623516129..1f6027eab24 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -19,13 +19,14 @@ bitflags = "1.0" canvas_traits = {path = "../canvas_traits"} crossbeam-channel = "0.3" embedder_traits = {path = "../embedder_traits"} -euclid = "0.19" +euclid = "0.20" fnv = "1.0" fxhash = "0.2" gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} html5ever = "0.23" ipc-channel = "0.11" +lazy_static = "1" libc = "0.2" log = "0.4" malloc_size_of = { path = "../malloc_size_of" } diff --git a/components/layout/block.rs b/components/layout/block.rs index 24128ca2ae7..1f4eb92ea51 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -50,7 +50,7 @@ use crate::model::{ use crate::sequential; use crate::traversal::PreorderFlowTraversal; use app_units::{Au, MAX_AU}; -use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; +use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D}; use gfx_traits::print_tree::PrintTree; use serde::{Serialize, Serializer}; use servo_geometry::MaxRect; @@ -2610,7 +2610,7 @@ impl Flow for BlockFlow { .relative_containing_block_mode, CoordinateSystem::Own, ) - .translate(&stacking_context_position.to_vector()), + .translate(stacking_context_position.to_vector()), ); } diff --git a/components/layout/display_list/background.rs b/components/layout/display_list/background.rs index c6fa1691e46..9d05cef9054 100644 --- a/components/layout/display_list/background.rs +++ b/components/layout/display_list/background.rs @@ -4,7 +4,7 @@ use crate::display_list::border; use app_units::Au; -use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; +use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D}; use style::computed_values::background_attachment::single_value::T as BackgroundAttachment; use style::computed_values::background_clip::single_value::T as BackgroundClip; use style::computed_values::background_origin::single_value::T as BackgroundOrigin; diff --git a/components/layout/display_list/border.rs b/components/layout/display_list/border.rs index fff18fcf6c0..4970b2a34de 100644 --- a/components/layout/display_list/border.rs +++ b/components/layout/display_list/border.rs @@ -4,7 +4,8 @@ use crate::display_list::ToLayout; use app_units::Au; -use euclid::{Rect, SideOffsets2D, Size2D}; +use euclid::default::{Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D as UntypedSize2D}; +use euclid::{SideOffsets2D, Size2D}; use style::computed_values::border_image_outset::T as BorderImageOutset; use style::properties::style_structs::Border; use style::values::computed::NumberOrPercentage; @@ -23,7 +24,10 @@ use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF, NormalBorder} /// > Percentages: Refer to corresponding dimension of the border box. /// /// [1]: https://drafts.csswg.org/css-backgrounds-3/#border-radius -fn corner_radius(radius: BorderCornerRadius, containing_size: Size2D<Au>) -> Size2D<Au> { +fn corner_radius( + radius: BorderCornerRadius, + containing_size: UntypedSize2D<Au>, +) -> UntypedSize2D<Au> { let w = radius.0.width().to_used_value(containing_size.width); let h = radius.0.height().to_used_value(containing_size.height); Size2D::new(w, h) @@ -105,7 +109,7 @@ pub fn radii(abs_bounds: Rect<Au>, border_style: &Border) -> BorderRadius { /// the inner radii need to be smaller depending on the line width. /// /// This is used to determine clipping areas. -pub fn inner_radii(mut radii: BorderRadius, offsets: SideOffsets2D<Au>) -> BorderRadius { +pub fn inner_radii(mut radii: BorderRadius, offsets: UntypedSideOffsets2D<Au>) -> BorderRadius { fn inner_length(x: f32, offset: Au) -> f32 { 0.0_f32.max(x - offset.to_f32_px()) } @@ -144,7 +148,10 @@ fn side_image_outset(outset: NonNegativeLengthOrNumber, border_width: Au) -> Au } /// Compute the additional border-image area. -pub fn image_outset(outset: BorderImageOutset, border: SideOffsets2D<Au>) -> SideOffsets2D<Au> { +pub fn image_outset( + outset: BorderImageOutset, + border: UntypedSideOffsets2D<Au>, +) -> UntypedSideOffsets2D<Au> { SideOffsets2D::new( side_image_outset(outset.0, border.top), side_image_outset(outset.1, border.right), @@ -168,7 +175,7 @@ fn side_image_width( pub fn image_width( width: &BorderImageWidth, border: LayoutSideOffsets, - border_area: Size2D<Au>, + border_area: UntypedSize2D<Au>, ) -> LayoutSideOffsets { LayoutSideOffsets::new( side_image_width(width.0, border.top, border_area.height), @@ -185,15 +192,14 @@ fn resolve_percentage(value: NonNegative<NumberOrPercentage>, length: i32) -> i3 } } -pub fn image_slice( +pub fn image_slice<U>( border_image_slice: &StyleRect<NonNegative<NumberOrPercentage>>, - width: i32, - height: i32, -) -> SideOffsets2D<i32> { + size: Size2D<i32, U>, +) -> SideOffsets2D<i32, U> { SideOffsets2D::new( - resolve_percentage(border_image_slice.0, height), - resolve_percentage(border_image_slice.1, width), - resolve_percentage(border_image_slice.2, height), - resolve_percentage(border_image_slice.3, width), + resolve_percentage(border_image_slice.0, size.height), + resolve_percentage(border_image_slice.1, size.width), + resolve_percentage(border_image_slice.2, size.height), + resolve_percentage(border_image_slice.3, size.width), ) } diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index e6ead2505ca..cba26fe05a4 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -32,7 +32,10 @@ use crate::table_cell::CollapsedBordersForCell; use app_units::{Au, AU_PER_PX}; use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg}; use embedder_traits::Cursor; -use euclid::{rect, Point2D, Rect, SideOffsets2D, Size2D, TypedRect, TypedSize2D}; +use euclid::{ + default::{Point2D, Rect, SideOffsets2D as UntypedSideOffsets2D, Size2D}, + rect, SideOffsets2D, +}; use fnv::FnvHashMap; use gfx::text::glyph::ByteIndex; use gfx::text::TextRun; @@ -874,7 +877,7 @@ impl Fragment { ) -> Option<WebRenderImageInfo> { let device_pixel_ratio = state.layout_context.style_context.device_pixel_ratio(); let size_in_px = - TypedSize2D::new(size_in_au.width.to_f32_px(), size_in_au.height.to_f32_px()); + euclid::Size2D::new(size_in_au.width.to_f32_px(), size_in_au.height.to_f32_px()); // TODO: less copying. let name = paint_worklet.name.clone(); @@ -1169,7 +1172,7 @@ impl Fragment { base: BaseDisplayItem, bounds: Rect<Au>, image: &Image, - border_width: SideOffsets2D<Au>, + border_width: UntypedSideOffsets2D<Au>, ) -> Option<()> { let border_style_struct = style.get_border(); let border_image_outset = @@ -1238,11 +1241,13 @@ impl Fragment { _ => return None, }; + // FIXME(emilio): WR expects device pixels here... somehow? + let size = euclid::Size2D::new(width as i32, height as i32); let details = BorderDetails::NinePatch(NinePatchBorder { source, width: width as i32, height: height as i32, - slice: border::image_slice(border_image_slice, width as i32, height as i32), + slice: border::image_slice(border_image_slice, size), fill: border_image_fill, repeat_horizontal: border_image_repeat.0.to_layout(), repeat_vertical: border_image_repeat.1.to_layout(), @@ -1660,7 +1665,7 @@ impl Fragment { // of this fragment's background but behind its content. This ensures that any // hit tests inside the content box but not on actual content target the current // scrollable ancestor. - let content_size = TypedRect::new(stacking_relative_border_box.origin, content_size); + let content_size = Rect::new(stacking_relative_border_box.origin, content_size); let base = state.create_base_display_item_with_clipping_and_scrolling( content_size, self.node, @@ -1810,10 +1815,9 @@ impl Fragment { // XXXjdm: This sleight-of-hand to convert LayoutRect -> Size2D<CSSPixel> // looks bogus. - let size = Size2D::new(bounds.size.width, bounds.size.height); state.iframe_sizes.push(IFrameSize { id: browsing_context_id, - size: TypedSize2D::from_untyped(&size), + size: euclid::Size2D::new(bounds.size.width, bounds.size.height), }); state.add_display_item(item); @@ -1926,13 +1930,13 @@ impl Fragment { // First, compute the offset of our border box (including relative positioning) // from our flow origin, since that is what `BaseFlow::overflow` is relative to. let border_box_offset = border_box - .translate(&-base_flow.stacking_relative_position) + .translate(-base_flow.stacking_relative_position) .origin; // Then, using that, compute our overflow region relative to our border box. let overflow = base_flow .overflow .paint - .translate(&-border_box_offset.to_vector()); + .translate(-border_box_offset.to_vector()); // Create the filter pipeline. let effects = self.style().get_effects(); @@ -2269,7 +2273,7 @@ impl BlockFlow { .fragment .perspective_matrix(&border_box) .unwrap_or(LayoutTransform::identity()); - let transform = transform.pre_mul(&perspective).inverse(); + let transform = transform.pre_transform(&perspective).inverse(); let origin = border_box.origin; let transform_clip = |clip: Rect<Au>| { @@ -3016,7 +3020,7 @@ trait ToF32Px { fn to_f32_px(&self) -> Self::Output; } -impl ToF32Px for TypedRect<Au> { +impl ToF32Px for Rect<Au> { type Output = LayoutRect; fn to_f32_px(&self) -> LayoutRect { LayoutRect::from_untyped(&servo_geometry::au_rect_to_f32_rect(*self)) diff --git a/components/layout/display_list/conversions.rs b/components/layout/display_list/conversions.rs index 4624b5f8dd0..2759c5f65ac 100644 --- a/components/layout/display_list/conversions.rs +++ b/components/layout/display_list/conversions.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use app_units::Au; -use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D}; +use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D}; use style::computed_values::image_rendering::T as ImageRendering; use style::computed_values::mix_blend_mode::T as MixBlendMode; use style::computed_values::transform_style::T as TransformStyle; diff --git a/components/layout/display_list/gradient.rs b/components/layout/display_list/gradient.rs index ab56b1d6c9c..3d7730e4fe6 100644 --- a/components/layout/display_list/gradient.rs +++ b/components/layout/display_list/gradient.rs @@ -4,7 +4,7 @@ use crate::display_list::ToLayout; use app_units::Au; -use euclid::{Point2D, Size2D, Vector2D}; +use euclid::default::{Point2D, Size2D, Vector2D}; use style::properties::ComputedValues; use style::values::computed::image::{EndingShape, LineDirection}; use style::values::computed::{Angle, GradientItem, LengthPercentage, Percentage, Position}; diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs index b6674d972fe..de7e49d306e 100644 --- a/components/layout/display_list/items.rs +++ b/components/layout/display_list/items.rs @@ -24,7 +24,7 @@ use std::f32; use std::fmt; use style::computed_values::_servo_top_layer::T as InTopLayer; use webrender_api as wr; -use webrender_api::units::{LayoutPoint, LayoutRect, LayoutSize, LayoutTransform}; +use webrender_api::units::{LayoutPixel, LayoutPoint, LayoutRect, LayoutSize, LayoutTransform}; use webrender_api::{BorderRadius, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion}; use webrender_api::{ExternalScrollId, FilterOp, GlyphInstance, GradientStop, ImageKey}; use webrender_api::{MixBlendMode, ScrollSensitivity, Shadow, SpatialId}; @@ -343,7 +343,7 @@ impl fmt::Debug for StackingContext { #[derive(Clone, Debug, PartialEq, Serialize)] pub struct StickyFrameData { - pub margins: SideOffsets2D<Option<f32>>, + pub margins: SideOffsets2D<Option<f32>, LayoutPixel>, pub vertical_offset_bounds: StickyOffsetBounds, pub horizontal_offset_bounds: StickyOffsetBounds, } @@ -792,4 +792,4 @@ impl WebRenderImageInfo { } /// The type of the scroll offset list. This is only populated if WebRender is in use. -pub type ScrollOffsetMap = HashMap<ExternalScrollId, Vector2D<f32>>; +pub type ScrollOffsetMap = HashMap<ExternalScrollId, Vector2D<f32, LayoutPixel>>; diff --git a/components/layout/display_list/webrender_helpers.rs b/components/layout/display_list/webrender_helpers.rs index 6bdb1bfcfdc..37232dda832 100644 --- a/components/layout/display_list/webrender_helpers.rs +++ b/components/layout/display_list/webrender_helpers.rs @@ -189,7 +189,7 @@ impl WebRenderDisplayItemConverter for DisplayItem { ), (Some(t), None) => (t, ReferenceFrameKind::Transform), (Some(t), Some(p)) => ( - t.pre_mul(&p), + t.pre_transform(&p), ReferenceFrameKind::Perspective { scrolling_relative_to: None, }, diff --git a/components/layout/flex.rs b/components/layout/flex.rs index e6aa2f7b2c8..8d2f7b98fe1 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -17,7 +17,7 @@ use crate::model::{self, AdjoiningMargins, CollapsibleMargins}; use crate::model::{IntrinsicISizes, MaybeAuto, SizeConstraint}; use crate::traversal::PreorderFlowTraversal; use app_units::{Au, MAX_AU}; -use euclid::Point2D; +use euclid::default::Point2D; use std::cmp::{max, min}; use std::ops::Range; use style::computed_values::align_content::T as AlignContent; diff --git a/components/layout/flow.rs b/components/layout/flow.rs index d7ab73cd8d3..2d6e449766e 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -44,7 +44,7 @@ use crate::table_row::TableRowFlow; use crate::table_rowgroup::TableRowGroupFlow; use crate::table_wrapper::TableWrapperFlow; use app_units::Au; -use euclid::{Point2D, Rect, Size2D, Vector2D}; +use euclid::default::{Point2D, Rect, Size2D, Vector2D}; use gfx_traits::print_tree::PrintTree; use gfx_traits::StackingContextId; use num_traits::cast::FromPrimitive; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 879e2af2f64..f663dad744d 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -22,7 +22,7 @@ use crate::wrapper::ThreadSafeLayoutNodeHelpers; use crate::ServoArc; use app_units::Au; use canvas_traits::canvas::{CanvasId, CanvasMsg}; -use euclid::{Point2D, Rect, Size2D, Vector2D}; +use euclid::default::{Point2D, Rect, Size2D, Vector2D}; use gfx::text::glyph::ByteIndex; use gfx::text::text_run::{TextRun, TextRunSlice}; use gfx_traits::StackingContextId; @@ -2671,8 +2671,12 @@ impl Fragment { // this. let relative_position = self.relative_position(relative_containing_block_size); border_box - .translate_by_size(&relative_position.to_physical(self.style.writing_mode)) - .translate(&stacking_relative_flow_origin) + .translate( + relative_position + .to_physical(self.style.writing_mode) + .to_vector(), + ) + .translate(*stacking_relative_flow_origin) } /// Given the stacking-context-relative border box, returns the stacking-context-relative @@ -2789,8 +2793,11 @@ impl Fragment { // FIXME(pcwalton): I'm not a fan of the way this makes us crawl though so many styles all // the time. Can't we handle relative positioning by just adjusting `border_box`? let relative_position = self.relative_position(relative_containing_block_size); - border_box = - border_box.translate_by_size(&relative_position.to_physical(self.style.writing_mode)); + border_box = border_box.translate( + relative_position + .to_physical(self.style.writing_mode) + .to_vector(), + ); let mut overflow = Overflow::from_rect(&border_box); // Box shadows cause us to draw outside our border box. @@ -2803,7 +2810,7 @@ impl Fragment { Au::from(box_shadow.base.blur) * BLUR_INFLATION_FACTOR; overflow.paint = overflow .paint - .union(&border_box.translate(&offset).inflate(inflation, inflation)) + .union(&border_box.translate(offset).inflate(inflation, inflation)) } // Outlines cause us to draw outside our border box. @@ -3172,7 +3179,11 @@ impl Fragment { -transform_origin_z, ); - Some(pre_transform.pre_mul(&transform).pre_mul(&post_transform)) + Some( + pre_transform + .pre_transform(&transform) + .pre_transform(&post_transform), + ) } /// Returns the 4D matrix representing this fragment's perspective. @@ -3210,8 +3221,8 @@ impl Fragment { Some( pre_transform - .pre_mul(&perspective_matrix) - .pre_mul(&post_transform), + .pre_transform(&perspective_matrix) + .pre_transform(&post_transform), ) }, Perspective::None => None, @@ -3378,8 +3389,8 @@ impl Overflow { } pub fn translate(&mut self, by: &Vector2D<Au>) { - self.scroll = self.scroll.translate(by); - self.paint = self.paint.translate(by); + self.scroll = self.scroll.translate(*by); + self.paint = self.paint.translate(*by); } } diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index 737dc3e84b8..683bb316897 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -25,6 +25,23 @@ use style::properties::ComputedValues; use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage; use style::values::generics::counters::ContentItem; +use style::values::specified::list::{QuotePair, Quotes}; + +lazy_static! { + static ref INITIAL_QUOTES: style::ArcSlice<QuotePair> = style::ArcSlice::from_iter_leaked( + vec![ + QuotePair { + opening: "\u{201c}".to_owned().into(), + closing: "\u{201d}".to_owned().into(), + }, + QuotePair { + opening: "\u{2018}".to_owned().into(), + closing: "\u{2019}".to_owned().into(), + }, + ] + .into_iter() + ); +} // Decimal styles per CSS-COUNTER-STYLES § 6.1: static DECIMAL: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; @@ -326,14 +343,17 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> { } fn quote(&self, style: &ComputedValues, close: bool) -> String { - let quotes = &style.get_list().quotes; - if quotes.0.is_empty() { + let quotes = match style.get_list().quotes { + Quotes::Auto => &*INITIAL_QUOTES, + Quotes::QuoteList(ref list) => &list.0, + }; + if quotes.is_empty() { return String::new(); } - let pair = if self.traversal.quote as usize >= quotes.0.len() { - quotes.0.last().unwrap() + let pair = if self.traversal.quote as usize >= quotes.len() { + quotes.last().unwrap() } else { - "es.0[self.traversal.quote as usize] + "es[self.traversal.quote as usize] }; if close { pair.closing.to_string() diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 152108dc912..1c43ba13586 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -21,7 +21,7 @@ use crate::text; use crate::traversal::PreorderFlowTraversal; use crate::ServoArc; use app_units::{Au, MIN_AU}; -use euclid::{Point2D, Rect, Size2D}; +use euclid::default::{Point2D, Rect, Size2D}; use gfx::font::FontMetrics; use gfx_traits::print_tree::PrintTree; use range::{Range, RangeIndex}; @@ -1977,7 +1977,7 @@ impl Flow for InlineFlow { relative_containing_block_mode, CoordinateSystem::Own, ) - .translate(&stacking_context_position.to_vector()), + .translate(stacking_context_position.to_vector()), ) } } diff --git a/components/layout/lib.rs b/components/layout/lib.rs index f8afdc79190..fdf3971fc3f 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -9,6 +9,8 @@ extern crate bitflags; #[macro_use] extern crate html5ever; #[macro_use] +extern crate lazy_static; +#[macro_use] extern crate log; #[macro_use] extern crate range; diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index 3416ff444b3..c3e17fdfdc3 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -20,7 +20,7 @@ use crate::fragment::{ use crate::generated_content; use crate::inline::InlineFlow; use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; use style::computed_values::list_style_type::T as ListStyleType; use style::computed_values::position::T as Position; use style::logical_geometry::LogicalSize; @@ -280,7 +280,7 @@ impl Flow for ListItemFlow { .relative_containing_block_mode, CoordinateSystem::Own, ) - .translate(&stacking_context_position.to_vector()), + .translate(stacking_context_position.to_vector()), ); } } diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index d49e5f1d79f..8890c08e189 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -12,7 +12,7 @@ use crate::flow::{Flow, FlowClass, FragmentationContext, GetBaseFlow, OpaqueFlow use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::ServoArc; use app_units::Au; -use euclid::{Point2D, Vector2D}; +use euclid::default::{Point2D, Vector2D}; use gfx_traits::print_tree::PrintTree; use std::cmp::{max, min}; use std::fmt; diff --git a/components/layout/query.rs b/components/layout/query.rs index 789056753d5..8dfd1bab795 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -15,7 +15,7 @@ use crate::opaque_node::OpaqueNodeMethods; use crate::sequential; use crate::wrapper::LayoutNodeLayoutData; use app_units::Au; -use euclid::{Point2D, Rect, Size2D, Vector2D}; +use euclid::default::{Point2D, Rect, Size2D, Vector2D}; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use script_layout_interface::rpc::TextIndexResponse; diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs index 16dd3b8d4da..8a113f39bb0 100644 --- a/components/layout/sequential.rs +++ b/components/layout/sequential.rs @@ -15,7 +15,7 @@ use crate::incremental::RelayoutMode; use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList}; use crate::traversal::{InorderFlowTraversal, PostorderFlowTraversal, PreorderFlowTraversal}; use app_units::Au; -use euclid::{Point2D, Rect, Size2D, Vector2D}; +use euclid::default::{Point2D, Rect, Size2D, Vector2D}; use servo_config::opts; use style::servo::restyle_damage::ServoRestyleDamage; use webrender_api::units::LayoutPoint; @@ -125,7 +125,7 @@ pub fn iterate_through_flow_tree_fragment_border_boxes( .as_block() .stacking_relative_border_box(CoordinateSystem::Own); if let Some(matrix) = kid.as_block().fragment.transform_matrix(&relative_position) { - let transform_matrix = matrix.transform_point2d(&LayoutPoint::zero()).unwrap(); + let transform_matrix = matrix.transform_point2d(LayoutPoint::zero()).unwrap(); stacking_context_position = stacking_context_position + Vector2D::new( Au::from_f32_px(transform_matrix.x), diff --git a/components/layout/table.rs b/components/layout/table.rs index 9f6219f0980..190f6693256 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -24,7 +24,7 @@ use crate::table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, Collapsed use crate::table_row::{TableRowFlow, TableRowSizeData}; use crate::table_wrapper::TableLayout; use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; use gfx_traits::print_tree::PrintTree; use std::{cmp, fmt}; use style::computed_values::{border_collapse, border_spacing, table_layout}; diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index 3d44190f986..470a1c2f489 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -12,7 +12,7 @@ use crate::display_list::{ use crate::flow::{Flow, FlowClass, OpaqueFlow}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; use gfx_traits::print_tree::PrintTree; use std::fmt; use style::logical_geometry::LogicalSize; diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index ec79f9f4540..89d83702f0e 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -15,7 +15,7 @@ use crate::layout_debug; use crate::table::InternalTable; use crate::table_row::{CollapsedBorder, CollapsedBorderProvenance}; use app_units::Au; -use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; +use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D}; use gfx_traits::print_tree::PrintTree; use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode; use std::fmt; diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index c07ad56f95a..b318dd95efd 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -10,7 +10,7 @@ use crate::flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::layout_debug; use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; use std::fmt; use style::logical_geometry::LogicalSize; use style::properties::ComputedValues; diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 824da31edad..ffaf720467b 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -18,7 +18,7 @@ use crate::layout_debug; use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt}; use crate::table_cell::{CollapsedBordersForCell, TableCellFlow}; use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; use gfx_traits::print_tree::PrintTree; use serde::{Serialize, Serializer}; use std::cmp::max; diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 814cbe0d2d2..fd984fa4291 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -14,7 +14,7 @@ use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::layout_debug; use crate::table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow}; use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; use gfx_traits::print_tree::PrintTree; use serde::{Serialize, Serializer}; use std::fmt; diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 65ecc07d3ab..d2eac788c60 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -24,7 +24,7 @@ use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::model::MaybeAuto; use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize}; use app_units::Au; -use euclid::Point2D; +use euclid::default::Point2D; use gfx_traits::print_tree::PrintTree; use std::cmp::{max, min}; use std::fmt; diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index e0e91c0d449..dc3f06ce6ce 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -15,7 +15,7 @@ app_units = "0.7" atomic_refcell = "0.1" crossbeam-channel = "0.3" embedder_traits = {path = "../embedder_traits"} -euclid = "0.19" +euclid = "0.20" fnv = "1.0" fxhash = "0.2" gfx = {path = "../gfx"} diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 1d8448c6e74..2febabce08b 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -28,7 +28,7 @@ use crate::dom_wrapper::{ServoLayoutDocument, ServoLayoutElement, ServoLayoutNod use app_units::Au; use crossbeam_channel::{unbounded, Receiver, Sender}; use embedder_traits::resources::{self, Resource}; -use euclid::{Point2D, Rect, Size2D, TypedScale, TypedSize2D}; +use euclid::{default::Size2D as UntypedSize2D, Point2D, Rect, Scale, Size2D}; use fnv::FnvHashMap; use fxhash::{FxHashMap, FxHashSet}; use gfx::font; @@ -216,7 +216,7 @@ pub struct LayoutThread { /// The size of the viewport. This may be different from the size of the screen due to viewport /// constraints. - viewport_size: Size2D<Au>, + viewport_size: UntypedSize2D<Au>, /// A mutex to allow for fast, read-only RPC of layout's internal data /// structures, while still letting the LayoutThread modify them. @@ -246,7 +246,7 @@ pub struct LayoutThread { layout_query_waiting_time: Histogram, /// The sizes of all iframes encountered during the last layout operation. - last_iframe_sizes: RefCell<HashMap<BrowsingContextId, TypedSize2D<f32, CSSPixel>>>, + last_iframe_sizes: RefCell<HashMap<BrowsingContextId, Size2D<f32, CSSPixel>>>, /// Flag that indicates if LayoutThread is busy handling a request. busy: Arc<AtomicBool>, @@ -255,7 +255,7 @@ pub struct LayoutThread { load_webfonts_synchronously: bool, /// The initial request size of the window - initial_window_size: TypedSize2D<u32, DeviceIndependentPixel>, + initial_window_size: Size2D<u32, DeviceIndependentPixel>, /// The ratio of device pixels per px at the default scale. /// If unspecified, will use the platform default setting. @@ -312,7 +312,7 @@ impl LayoutThreadFactory for LayoutThread { paint_time_metrics: PaintTimeMetrics, busy: Arc<AtomicBool>, load_webfonts_synchronously: bool, - initial_window_size: TypedSize2D<u32, DeviceIndependentPixel>, + initial_window_size: Size2D<u32, DeviceIndependentPixel>, device_pixels_per_px: Option<f32>, dump_display_list: bool, dump_display_list_json: bool, @@ -535,7 +535,7 @@ impl LayoutThread { paint_time_metrics: PaintTimeMetrics, busy: Arc<AtomicBool>, load_webfonts_synchronously: bool, - initial_window_size: TypedSize2D<u32, DeviceIndependentPixel>, + initial_window_size: Size2D<u32, DeviceIndependentPixel>, device_pixels_per_px: Option<f32>, dump_display_list: bool, dump_display_list_json: bool, @@ -550,8 +550,8 @@ impl LayoutThread { // but it will be set correctly when the initial reflow takes place. let device = Device::new( MediaType::screen(), - initial_window_size.to_f32() * TypedScale::new(1.0), - TypedScale::new(device_pixels_per_px.unwrap_or(1.0)), + initial_window_size.to_f32() * Scale::new(1.0), + Scale::new(device_pixels_per_px.unwrap_or(1.0)), ); // Create the channel on which new animations can be sent. @@ -833,7 +833,7 @@ impl LayoutThread { let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y); let mut txn = webrender_api::Transaction::new(); txn.scroll_node_with_id( - webrender_api::units::LayoutPoint::from_untyped(&point), + webrender_api::units::LayoutPoint::from_untyped(point), state.scroll_id, webrender_api::ScrollClamping::ToContentBounds, ); @@ -1249,7 +1249,7 @@ impl LayoutThread { epoch.next(); self.epoch.set(epoch); - let viewport_size = webrender_api::units::LayoutSize::from_untyped(&viewport_size); + let viewport_size = webrender_api::units::LayoutSize::from_untyped(viewport_size); // Observe notifications about rendered frames if needed right before // sending the display list to WebRender in order to set time related @@ -1671,8 +1671,7 @@ impl LayoutThread { // particular pipeline, so we need to tell WebRender about that. flags.insert(webrender_api::HitTestFlags::POINT_RELATIVE_TO_PIPELINE_VIEWPORT); - let client_point = - webrender_api::units::WorldPoint::from_untyped(&client_point); + let client_point = webrender_api::units::WorldPoint::from_untyped(client_point); let results = self.webrender_api.hit_test( self.webrender_document, Some(self.id.to_webrender()), @@ -2134,8 +2133,8 @@ impl RegisteredSpeculativePainter for RegisteredPainterImpl { impl Painter for RegisteredPainterImpl { fn draw_a_paint_image( &self, - size: TypedSize2D<f32, CSSPixel>, - device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + size: Size2D<f32, CSSPixel>, + device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, properties: Vec<(Atom, String)>, arguments: Vec<String>, ) -> Result<DrawAPaintImageResult, PaintWorkletError> { diff --git a/components/layout_thread_2020/Cargo.toml b/components/layout_thread_2020/Cargo.toml index 157d1085711..8711cec2638 100644 --- a/components/layout_thread_2020/Cargo.toml +++ b/components/layout_thread_2020/Cargo.toml @@ -12,7 +12,7 @@ path = "lib.rs" [dependencies] crossbeam-channel = "0.3" -euclid = "0.19" +euclid = "0.20" gfx = {path = "../gfx"} ipc-channel = "0.11" layout = {path = "../layout_2020", package = "layout_2020"} diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index d101ccac107..b5bbe316dcc 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crossbeam_channel::{Receiver, Sender}; -use euclid::TypedSize2D; +use euclid::Size2D; use gfx::font_cache_thread::FontCacheThread; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use metrics::PaintTimeMetrics; @@ -44,7 +44,7 @@ impl layout_traits::LayoutThreadFactory for LayoutThread { paint_time_metrics: PaintTimeMetrics, busy: Arc<AtomicBool>, load_webfonts_synchronously: bool, - initial_window_size: TypedSize2D<u32, DeviceIndependentPixel>, + initial_window_size: Size2D<u32, DeviceIndependentPixel>, device_pixels_per_px: Option<f32>, dump_display_list: bool, dump_display_list_json: bool, diff --git a/components/layout_traits/Cargo.toml b/components/layout_traits/Cargo.toml index 500f59e05e6..eeed0c26c8a 100644 --- a/components/layout_traits/Cargo.toml +++ b/components/layout_traits/Cargo.toml @@ -12,7 +12,7 @@ path = "lib.rs" [dependencies] crossbeam-channel = "0.3" -euclid = "0.19" +euclid = "0.20" gfx = {path = "../gfx"} ipc-channel = "0.11" metrics = {path = "../metrics"} diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index b0526a4b915..a37e8943125 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -10,7 +10,7 @@ // that these modules won't have to depend on layout. use crossbeam_channel::{Receiver, Sender}; -use euclid::TypedSize2D; +use euclid::Size2D; use gfx::font_cache_thread::FontCacheThread; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use metrics::PaintTimeMetrics; @@ -49,7 +49,7 @@ pub trait LayoutThreadFactory { paint_time_metrics: PaintTimeMetrics, busy: Arc<AtomicBool>, load_webfonts_synchronously: bool, - initial_window_size: TypedSize2D<u32, DeviceIndependentPixel>, + initial_window_size: Size2D<u32, DeviceIndependentPixel>, device_pixels_per_px: Option<f32>, dump_display_list: bool, dump_display_list_json: bool, diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index 271461ad9c5..3de67f45abb 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -27,7 +27,7 @@ servo = [ app_units = "0.7" crossbeam-channel = { version = "0.3", optional = true } cssparser = "0.25" -euclid = "0.19" +euclid = "0.20" hashglobe = { path = "../hashglobe" } hyper = { version = "0.12", optional = true } hyper_serde = { version = "0.11", optional = true } diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index 2be7f565a76..d7e0a6fdf16 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -625,25 +625,25 @@ impl<T: MallocSizeOf, Unit> MallocSizeOf for euclid::Length<T, Unit> { } } -impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::TypedScale<T, Src, Dst> { +impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Scale<T, Src, Dst> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.0.size_of(ops) } } -impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedPoint2D<T, U> { +impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Point2D<T, U> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.x.size_of(ops) + self.y.size_of(ops) } } -impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedRect<T, U> { +impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Rect<T, U> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.origin.size_of(ops) + self.size.size_of(ops) } } -impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedSideOffsets2D<T, U> { +impl<T: MallocSizeOf, U> MallocSizeOf for euclid::SideOffsets2D<T, U> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.top.size_of(ops) + self.right.size_of(ops) + @@ -652,13 +652,13 @@ impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedSideOffsets2D<T, U> { } } -impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedSize2D<T, U> { +impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Size2D<T, U> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.width.size_of(ops) + self.height.size_of(ops) } } -impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::TypedTransform2D<T, Src, Dst> { +impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Transform2D<T, Src, Dst> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.m11.size_of(ops) + self.m12.size_of(ops) + @@ -669,7 +669,7 @@ impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::TypedTransform2D<T, Src } } -impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::TypedTransform3D<T, Src, Dst> { +impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Transform3D<T, Src, Dst> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.m11.size_of(ops) + self.m12.size_of(ops) + @@ -690,7 +690,7 @@ impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::TypedTransform3D<T, Src } } -impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedVector2D<T, U> { +impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Vector2D<T, U> { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.x.size_of(ops) + self.y.size_of(ops) } diff --git a/components/media/Cargo.toml b/components/media/Cargo.toml index 254b4246f7e..58adf721bc1 100644 --- a/components/media/Cargo.toml +++ b/components/media/Cargo.toml @@ -11,7 +11,7 @@ name = "media" path = "lib.rs" [dependencies] -euclid = "0.19" +euclid = "0.20" fnv = "1.0" ipc-channel = "0.11" lazy_static = "1" diff --git a/components/media/lib.rs b/components/media/lib.rs index 7c339693da2..86f403faa2b 100644 --- a/components/media/lib.rs +++ b/components/media/lib.rs @@ -17,7 +17,7 @@ mod media_thread; pub use crate::media_channel::glplayer_channel; use crate::media_channel::{GLPlayerChan, GLPlayerPipeline, GLPlayerReceiver, GLPlayerSender}; use crate::media_thread::GLPlayerThread; -use euclid::Size2D; +use euclid::default::Size2D; use servo_media::player::context::{GlApi, GlContext, NativeDisplay, PlayerGLContext}; use std::sync::{Arc, Mutex}; use webrender_traits::{WebrenderExternalImageApi, WebrenderExternalImageRegistry}; diff --git a/components/pixels/Cargo.toml b/components/pixels/Cargo.toml index 0d5c9161b26..1b9f4d97002 100644 --- a/components/pixels/Cargo.toml +++ b/components/pixels/Cargo.toml @@ -11,7 +11,7 @@ name = "pixels" path = "lib.rs" [dependencies] -euclid = "0.19" +euclid = "0.20" malloc_size_of = {path = "../malloc_size_of"} malloc_size_of_derive = "0.1" serde = {version = "1", features = ["derive"]} diff --git a/components/pixels/lib.rs b/components/pixels/lib.rs index 155a53b4b4b..68b22abb11d 100644 --- a/components/pixels/lib.rs +++ b/components/pixels/lib.rs @@ -5,7 +5,7 @@ #[macro_use] extern crate serde; -use euclid::{Point2D, Rect, Size2D}; +use euclid::default::{Point2D, Rect, Size2D}; use malloc_size_of_derive::MallocSizeOf; use std::borrow::Cow; diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 902a4031947..cb03c00b873 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -50,7 +50,7 @@ domobject_derive = {path = "../domobject_derive"} embedder_traits = {path = "../embedder_traits"} encoding_rs = "0.8" enum-iterator = "0.2.0" -euclid = "0.19.7" +euclid = "0.20" fnv = "1.0" gleam = "0.6" headers = "0.2" diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 7f4fad813e5..bad7ebaa4bb 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -55,11 +55,8 @@ use crossbeam_channel::{Receiver, Sender}; use cssparser::RGBA; use devtools_traits::{CSSError, TimelineMarkerType, WorkerId}; use encoding_rs::{Decoder, Encoding}; +use euclid::default::{Point2D, Rect, Rotation3D, Transform2D, Transform3D}; use euclid::Length as EuclidLength; -use euclid::{ - Point2D, Rect, RigidTransform3D, Rotation3D, Transform2D, Transform3D, TypedRect, - TypedRigidTransform3D, TypedScale, TypedSize2D, Vector2D, -}; use html5ever::buffer_queue::BufferQueue; use html5ever::{LocalName, Namespace, Prefix, QualName}; use http::header::HeaderMap; @@ -510,8 +507,8 @@ unsafe_no_jsmanaged_fields!(ResourceFetchTiming); unsafe_no_jsmanaged_fields!(Timespec); unsafe_no_jsmanaged_fields!(HTMLMediaElementFetchContext); unsafe_no_jsmanaged_fields!(Rotation3D<f64>, Transform2D<f32>, Transform3D<f64>); -unsafe_no_jsmanaged_fields!(Point2D<f32>, Vector2D<f32>, Rect<Au>); -unsafe_no_jsmanaged_fields!(Rect<f32>, RigidTransform3D<f64>); +unsafe_no_jsmanaged_fields!(Point2D<f32>, Rect<Au>); +unsafe_no_jsmanaged_fields!(Rect<f32>); unsafe_no_jsmanaged_fields!(CascadeData); unsafe_no_jsmanaged_fields!(WindowGLContext); @@ -605,14 +602,28 @@ where } } -unsafe impl<T, U> JSTraceable for TypedScale<f32, T, U> { +unsafe impl<U> JSTraceable for euclid::Vector2D<f32, U> { + #[inline] + unsafe fn trace(&self, _trc: *mut JSTracer) { + // Do nothing + } +} + +unsafe impl<T, U> JSTraceable for euclid::Scale<f32, T, U> { + #[inline] + unsafe fn trace(&self, _trc: *mut JSTracer) { + // Do nothing + } +} + +unsafe impl<T, U> JSTraceable for euclid::RigidTransform3D<f32, T, U> { #[inline] unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing } } -unsafe impl<T, U> JSTraceable for TypedRigidTransform3D<f32, T, U> { +unsafe impl<T, U> JSTraceable for euclid::RigidTransform3D<f64, T, U> { #[inline] unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing @@ -626,28 +637,28 @@ unsafe impl<T> JSTraceable for EuclidLength<u64, T> { } } -unsafe impl<U> JSTraceable for TypedSize2D<i32, U> { +unsafe impl<U> JSTraceable for euclid::Size2D<i32, U> { #[inline] unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing } } -unsafe impl<U> JSTraceable for TypedSize2D<f32, U> { +unsafe impl<U> JSTraceable for euclid::Size2D<f32, U> { #[inline] unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing } } -unsafe impl<U> JSTraceable for TypedSize2D<u32, U> { +unsafe impl<U> JSTraceable for euclid::Size2D<u32, U> { #[inline] unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing } } -unsafe impl<U> JSTraceable for TypedRect<i32, U> { +unsafe impl<U> JSTraceable for euclid::Rect<i32, U> { #[inline] unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing diff --git a/components/script/dom/canvaspattern.rs b/components/script/dom/canvaspattern.rs index a60a92988ac..bce7cd24c54 100644 --- a/components/script/dom/canvaspattern.rs +++ b/components/script/dom/canvaspattern.rs @@ -9,7 +9,7 @@ use crate::dom::canvasgradient::ToFillOrStrokeStyle; use crate::dom::globalscope::GlobalScope; use canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle}; use dom_struct::dom_struct; -use euclid::Size2D; +use euclid::default::Size2D; // https://html.spec.whatwg.org/multipage/#canvaspattern #[dom_struct] diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 039ff1039f9..2a8f14295c0 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -32,7 +32,10 @@ use canvas_traits::canvas::{RadialGradientStyle, RepetitionStyle}; use cssparser::Color as CSSColor; use cssparser::{Parser, ParserInput, RGBA}; use dom_struct::dom_struct; -use euclid::{vec2, Point2D, Rect, Size2D, Transform2D}; +use euclid::{ + default::{Point2D, Rect, Size2D, Transform2D}, + vec2, +}; use ipc_channel::ipc::{self, IpcSender}; use net_traits::image_cache::CanRequestImages; use net_traits::image_cache::ImageCache; @@ -1223,7 +1226,7 @@ impl CanvasState { let (sin, cos) = (angle.sin(), angle.cos()); let transform = self.state.borrow().transform; - self.state.borrow_mut().transform = transform.pre_mul(&Transform2D::row_major( + self.state.borrow_mut().transform = transform.pre_transform(&Transform2D::row_major( cos as f32, sin as f32, -sin as f32, @@ -1258,7 +1261,7 @@ impl CanvasState { } let transform = self.state.borrow().transform; - self.state.borrow_mut().transform = transform.pre_mul(&Transform2D::row_major( + self.state.borrow_mut().transform = transform.pre_transform(&Transform2D::row_major( a as f32, b as f32, c as f32, d as f32, e as f32, f as f32, )); self.update_transform() diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 5b17c8ea004..d7e77ef9243 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -113,7 +113,7 @@ use devtools_traits::ScriptToDevtoolsControlMsg; use dom_struct::dom_struct; use embedder_traits::EmbedderMsg; use encoding_rs::{Encoding, UTF_8}; -use euclid::Point2D; +use euclid::default::Point2D; use html5ever::{LocalName, Namespace, QualName}; use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcSender}; diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs index 8a29d16d013..9b57dd32bf6 100644 --- a/components/script/dom/documentorshadowroot.rs +++ b/components/script/dom/documentorshadowroot.rs @@ -13,7 +13,7 @@ use crate::dom::htmlmetaelement::HTMLMetaElement; use crate::dom::node::{self, Node, VecPreOrderInsertionHelper}; use crate::dom::window::Window; use crate::stylesheet_set::StylesheetSetRef; -use euclid::Point2D; +use euclid::default::Point2D; use js::jsapi::JS_GetRuntime; use script_layout_interface::message::{NodesFromPointQueryType, QueryMsg}; use script_traits::UntrustedNodeAddress; diff --git a/components/script/dom/dommatrix.rs b/components/script/dom/dommatrix.rs index 03e152a2f2c..c9cc366e8ec 100644 --- a/components/script/dom/dommatrix.rs +++ b/components/script/dom/dommatrix.rs @@ -18,7 +18,7 @@ use crate::dom::dommatrixreadonly::{ use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use dom_struct::dom_struct; -use euclid::Transform3D; +use euclid::default::Transform3D; use js::rust::CustomAutoRooterGuard; use js::typedarray::{Float32Array, Float64Array}; diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index 7e9b2e716f4..cde3dbc4031 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -20,7 +20,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use cssparser::{Parser, ParserInput}; use dom_struct::dom_struct; -use euclid::{Angle, Transform3D}; +use euclid::{default::Transform3D, Angle}; use js::jsapi::{JSContext, JSObject}; use js::rust::CustomAutoRooterGuard; use js::typedarray::CreateWith; @@ -180,7 +180,7 @@ impl DOMMatrixReadOnly { dommatrixinit_to_matrix(&other).map(|(is2D, other_matrix)| { // Step 2. let mut matrix = self.matrix.borrow_mut(); - *matrix = other_matrix.post_mul(&matrix); + *matrix = other_matrix.post_transform(&matrix); // Step 3. if !is2D { self.is2D.set(false); @@ -195,7 +195,7 @@ impl DOMMatrixReadOnly { dommatrixinit_to_matrix(&other).map(|(is2D, other_matrix)| { // Step 2. let mut matrix = self.matrix.borrow_mut(); - *matrix = other_matrix.pre_mul(&matrix); + *matrix = other_matrix.pre_transform(&matrix); // Step 3. if !is2D { self.is2D.set(false); @@ -209,7 +209,7 @@ impl DOMMatrixReadOnly { // Step 1. let translation = Transform3D::create_translation(tx, ty, tz); let mut matrix = self.matrix.borrow_mut(); - *matrix = translation.post_mul(&matrix); + *matrix = translation.post_transform(&matrix); // Step 2. if tz != 0.0 { self.is2D.set(false); @@ -235,7 +235,7 @@ impl DOMMatrixReadOnly { { let scale3D = Transform3D::create_scale(scaleX, scaleY, scaleZ); let mut matrix = self.matrix.borrow_mut(); - *matrix = scale3D.post_mul(&matrix); + *matrix = scale3D.post_transform(&matrix); } // Step 4. originX = -originX; @@ -258,7 +258,7 @@ impl DOMMatrixReadOnly { { let scale3D = Transform3D::create_scale(scale, scale, scale); let mut matrix = self.matrix.borrow_mut(); - *matrix = scale3D.post_mul(&matrix); + *matrix = scale3D.post_transform(&matrix); } // Step 3. self.translate_self(-originX, -originY, -originZ); @@ -291,7 +291,7 @@ impl DOMMatrixReadOnly { let rotation = Transform3D::create_rotation(0.0, 0.0, -1.0, Angle::radians(rotZ.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_mul(&matrix); + *matrix = rotation.post_transform(&matrix); } if rotY != 0.0 { // Step 6. @@ -299,7 +299,7 @@ impl DOMMatrixReadOnly { let rotation = Transform3D::create_rotation(0.0, -1.0, 0.0, Angle::radians(rotY.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_mul(&matrix); + *matrix = rotation.post_transform(&matrix); } if rotX != 0.0 { // Step 7. @@ -307,7 +307,7 @@ impl DOMMatrixReadOnly { let rotation = Transform3D::create_rotation(-1.0, 0.0, 0.0, Angle::radians(rotX.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_mul(&matrix); + *matrix = rotation.post_transform(&matrix); } // Step 8 in DOMMatrix.RotateSelf } @@ -321,7 +321,7 @@ impl DOMMatrixReadOnly { // Beware: pass negated value until https://github.com/servo/euclid/issues/354 let rotation = Transform3D::create_rotation(0.0, 0.0, -1.0, rotZ); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_mul(&matrix); + *matrix = rotation.post_transform(&matrix); } // Step 2 in DOMMatrix.RotateFromVectorSelf } @@ -338,7 +338,7 @@ impl DOMMatrixReadOnly { Angle::radians(angle.to_radians()), ); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_mul(&matrix); + *matrix = rotation.post_transform(&matrix); // Step 2. if x != 0.0 || y != 0.0 { self.is2D.set(false); @@ -351,7 +351,7 @@ impl DOMMatrixReadOnly { // Step 1. let skew = Transform3D::create_skew(Angle::radians(sx.to_radians()), Angle::radians(0.0)); let mut matrix = self.matrix.borrow_mut(); - *matrix = skew.post_mul(&matrix); + *matrix = skew.post_transform(&matrix); // Step 2 in DOMMatrix.SkewXSelf } @@ -360,7 +360,7 @@ impl DOMMatrixReadOnly { // Step 1. let skew = Transform3D::create_skew(Angle::radians(0.0), Angle::radians(sy.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = skew.post_mul(&matrix); + *matrix = skew.post_transform(&matrix); // Step 2 in DOMMatrix.SkewYSelf } @@ -629,7 +629,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { let flip = Transform3D::row_major( -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, ); - let matrix = flip.post_mul(&self.matrix.borrow()); + let matrix = flip.post_transform(&self.matrix.borrow()); DOMMatrix::new(&self.global(), is2D, matrix) } @@ -639,7 +639,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { let flip = Transform3D::row_major( 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, ); - let matrix = flip.post_mul(&self.matrix.borrow()); + let matrix = flip.post_transform(&self.matrix.borrow()); DOMMatrix::new(&self.global(), is2D, matrix) } diff --git a/components/script/dom/fakexrdevice.rs b/components/script/dom/fakexrdevice.rs index c5e1d16eaff..239eb415478 100644 --- a/components/script/dom/fakexrdevice.rs +++ b/components/script/dom/fakexrdevice.rs @@ -11,8 +11,8 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; -use euclid::{TypedPoint2D, TypedRect, TypedSize2D}; -use euclid::{TypedRigidTransform3D, TypedRotation3D, TypedTransform3D, TypedVector3D}; +use euclid::{Point2D, Rect, Size2D}; +use euclid::{RigidTransform3D, Rotation3D, Transform3D, Vector3D}; use ipc_channel::ipc::IpcSender; use webxr_api::{MockDeviceMsg, View, Views}; @@ -67,23 +67,23 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<Views> { let mut proj_r = [0.; 16]; let v: Vec<_> = left.projectionMatrix.iter().map(|x| **x).collect(); proj_l.copy_from_slice(&v); - let proj_l = TypedTransform3D::from_array(proj_l); + let proj_l = Transform3D::from_array(proj_l); let v: Vec<_> = right.projectionMatrix.iter().map(|x| **x).collect(); proj_r.copy_from_slice(&v); - let proj_r = TypedTransform3D::from_array(proj_r); + let proj_r = Transform3D::from_array(proj_r); // spec defines offsets as origins, but mock API expects the inverse transform let offset_l = get_origin(&left.viewOffset)?.inverse(); let offset_r = get_origin(&right.viewOffset)?.inverse(); - let size_l = TypedSize2D::new(views[0].resolution.width, views[0].resolution.height); - let size_r = TypedSize2D::new(views[1].resolution.width, views[1].resolution.height); + let size_l = Size2D::new(views[0].resolution.width, views[0].resolution.height); + let size_r = Size2D::new(views[1].resolution.width, views[1].resolution.height); - let origin_l = TypedPoint2D::new(0, 0); - let origin_r = TypedPoint2D::new(size_l.width, 0); + let origin_l = Point2D::new(0, 0); + let origin_r = Point2D::new(size_l.width, 0); - let viewport_l = TypedRect::new(origin_l, size_l); - let viewport_r = TypedRect::new(origin_r, size_r); + let viewport_l = Rect::new(origin_l, size_l); + let viewport_r = Rect::new(origin_r, size_r); let left = View { projection: proj_l, @@ -100,23 +100,23 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<Views> { pub fn get_origin<T, U>( origin: &FakeXRRigidTransformInit, -) -> Fallible<TypedRigidTransform3D<f32, T, U>> { +) -> Fallible<RigidTransform3D<f32, T, U>> { if origin.position.len() != 3 || origin.orientation.len() != 4 { return Err(Error::Type("Incorrectly sized array".into())); } - let p = TypedVector3D::new( + let p = Vector3D::new( *origin.position[0], *origin.position[1], *origin.position[2], ); - let o = TypedRotation3D::unit_quaternion( + let o = Rotation3D::unit_quaternion( *origin.orientation[0], *origin.orientation[1], *origin.orientation[2], *origin.orientation[3], ); - Ok(TypedRigidTransform3D::new(o, p)) + Ok(RigidTransform3D::new(o, p)) } impl FakeXRDeviceMethods for FakeXRDevice { diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 2cbd4ed1e37..65e47911c0d 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -18,7 +18,7 @@ use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; use crate::dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use euclid::Point2D; +use euclid::default::Point2D; use html5ever::{LocalName, Prefix}; use std::default::Default; use std::f32; diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index ecf3a36c28e..6376e9d9a64 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -32,7 +32,7 @@ use base64; use canvas_traits::canvas::{CanvasId, CanvasMsg, FromScriptMsg}; use canvas_traits::webgl::{GLContextAttributes, WebGLVersion}; use dom_struct::dom_struct; -use euclid::{Rect, Size2D}; +use euclid::default::{Rect, Size2D}; use html5ever::{LocalName, Prefix}; use image::png::PNGEncoder; use image::ColorType; diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 58ddd48c8c9..fbeaf14cdf4 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -28,7 +28,7 @@ use crate::dom::windowproxy::WindowProxy; use crate::script_thread::ScriptThread; use crate::task_source::TaskSource; use dom_struct::dom_struct; -use euclid::TypedSize2D; +use euclid::Size2D; use html5ever::{LocalName, Prefix}; use ipc_channel::ipc; use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId}; @@ -202,10 +202,7 @@ impl HTMLIFrameElement { window_size: WindowSizeData { initial_viewport: { let rect = self.upcast::<Node>().bounding_content_box_or_zero(); - TypedSize2D::new( - rect.size.width.to_f32_px(), - rect.size.height.to_f32_px(), - ) + Size2D::new(rect.size.width.to_f32_px(), rect.size.height.to_f32_px()) }, device_pixel_ratio: window.device_pixel_ratio(), }, diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 8eaa9c2b552..ef363813a5d 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -65,7 +65,7 @@ use crate::script_thread::ScriptThread; use crate::task_source::TaskSource; use dom_struct::dom_struct; use embedder_traits::resources::{self, Resource as EmbedderResource}; -use euclid::Size2D; +use euclid::default::Size2D; use headers::{ContentLength, ContentRange, HeaderMapExt}; use html5ever::{LocalName, Prefix}; use http::header::{self, HeaderMap, HeaderValue}; diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index 29c15f665a4..460c827ab1a 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -9,7 +9,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; -use euclid::{Rect, Size2D}; +use euclid::default::{Rect, Size2D}; use ipc_channel::ipc::IpcSharedMemory; use js::jsapi::{Heap, JSContext, JSObject}; use js::rust::Runtime; diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs index 7a54a20925b..6656eac90fe 100644 --- a/components/script/dom/mouseevent.rs +++ b/components/script/dom/mouseevent.rs @@ -15,7 +15,7 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::uievent::UIEvent; use crate::dom::window::Window; use dom_struct::dom_struct; -use euclid::Point2D; +use euclid::default::Point2D; use servo_config::pref; use std::cell::Cell; use std::default::Default; diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 8165d0c4eef..75172c70717 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -64,7 +64,7 @@ use crate::script_thread::ScriptThread; use app_units::Au; use devtools_traits::NodeInfo; use dom_struct::dom_struct; -use euclid::{Point2D, Rect, Size2D, Vector2D}; +use euclid::default::{Point2D, Rect, Size2D, Vector2D}; use html5ever::{Namespace, Prefix, QualName}; use js::jsapi::{JSContext, JSObject, JSRuntime}; use libc::{self, c_void, uintptr_t}; @@ -778,7 +778,7 @@ impl Node { pub fn scroll_offset(&self) -> Vector2D<f32> { let document = self.owner_doc(); let window = document.window(); - window.scroll_offset_query(self) + window.scroll_offset_query(self).to_untyped() } // https://dom.spec.whatwg.org/#dom-childnode-before diff --git a/components/script/dom/offscreencanvas.rs b/components/script/dom/offscreencanvas.rs index 5086287dbb3..2087c47c91f 100644 --- a/components/script/dom/offscreencanvas.rs +++ b/components/script/dom/offscreencanvas.rs @@ -16,7 +16,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::htmlcanvaselement::HTMLCanvasElement; use crate::dom::offscreencanvasrenderingcontext2d::OffscreenCanvasRenderingContext2D; use dom_struct::dom_struct; -use euclid::Size2D; +use euclid::default::Size2D; use js::jsapi::JSContext; use js::rust::HandleValue; use ref_filter_map; diff --git a/components/script/dom/offscreencanvasrenderingcontext2d.rs b/components/script/dom/offscreencanvasrenderingcontext2d.rs index 502600a9145..461af3b882f 100644 --- a/components/script/dom/offscreencanvasrenderingcontext2d.rs +++ b/components/script/dom/offscreencanvasrenderingcontext2d.rs @@ -24,7 +24,7 @@ use crate::dom::htmlcanvaselement::HTMLCanvasElement; use crate::dom::imagedata::ImageData; use crate::dom::offscreencanvas::OffscreenCanvas; use dom_struct::dom_struct; -use euclid::Size2D; +use euclid::default::Size2D; #[dom_struct] pub struct OffscreenCanvasRenderingContext2D { diff --git a/components/script/dom/paintrenderingcontext2d.rs b/components/script/dom/paintrenderingcontext2d.rs index 9bf7cc38eb4..1bbb52d05fe 100644 --- a/components/script/dom/paintrenderingcontext2d.rs +++ b/components/script/dom/paintrenderingcontext2d.rs @@ -25,9 +25,7 @@ use canvas_traits::canvas::CanvasImageData; use canvas_traits::canvas::CanvasMsg; use canvas_traits::canvas::FromLayoutMsg; use dom_struct::dom_struct; -use euclid::Size2D; -use euclid::TypedScale; -use euclid::TypedSize2D; +use euclid::{Scale, Size2D}; use ipc_channel::ipc::IpcSender; use servo_url::ServoUrl; use std::cell::Cell; @@ -37,7 +35,7 @@ use style_traits::DevicePixel; #[dom_struct] pub struct PaintRenderingContext2D { context: CanvasRenderingContext2D, - device_pixel_ratio: Cell<TypedScale<f32, CSSPixel, DevicePixel>>, + device_pixel_ratio: Cell<Scale<f32, CSSPixel, DevicePixel>>, } impl PaintRenderingContext2D { @@ -45,7 +43,7 @@ impl PaintRenderingContext2D { let size = Size2D::zero(); PaintRenderingContext2D { context: CanvasRenderingContext2D::new_inherited(global.upcast(), None, size), - device_pixel_ratio: Cell::new(TypedScale::new(1.0)), + device_pixel_ratio: Cell::new(Scale::new(1.0)), } } @@ -71,8 +69,8 @@ impl PaintRenderingContext2D { pub fn set_bitmap_dimensions( &self, - size: TypedSize2D<f32, CSSPixel>, - device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + size: Size2D<f32, CSSPixel>, + device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, ) { let size = size * device_pixel_ratio; self.device_pixel_ratio.set(device_pixel_ratio); diff --git a/components/script/dom/paintsize.rs b/components/script/dom/paintsize.rs index eb460c5f12d..7f7fa61346b 100644 --- a/components/script/dom/paintsize.rs +++ b/components/script/dom/paintsize.rs @@ -10,7 +10,7 @@ use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::root::DomRoot; use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; use dom_struct::dom_struct; -use euclid::TypedSize2D; +use euclid::Size2D; use style_traits::CSSPixel; #[dom_struct] @@ -21,7 +21,7 @@ pub struct PaintSize { } impl PaintSize { - fn new_inherited(size: TypedSize2D<f32, CSSPixel>) -> PaintSize { + fn new_inherited(size: Size2D<f32, CSSPixel>) -> PaintSize { PaintSize { reflector: Reflector::new(), width: Finite::wrap(size.width as f64), @@ -31,7 +31,7 @@ impl PaintSize { pub fn new( global: &PaintWorkletGlobalScope, - size: TypedSize2D<f32, CSSPixel>, + size: Size2D<f32, CSSPixel>, ) -> DomRoot<PaintSize> { reflect_dom_object( Box::new(PaintSize::new_inherited(size)), diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index 7791456294d..2cd6ae19846 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -25,8 +25,8 @@ use crate::dom::workletglobalscope::WorkletGlobalScopeInit; use crate::dom::workletglobalscope::WorkletTask; use crossbeam_channel::{unbounded, Sender}; use dom_struct::dom_struct; -use euclid::TypedScale; -use euclid::TypedSize2D; +use euclid::Scale; +use euclid::Size2D; use js::jsapi::HandleValueArray; use js::jsapi::Heap; use js::jsapi::IsCallable; @@ -81,9 +81,9 @@ pub struct PaintWorkletGlobalScope { /// The most recent name the worklet was called with cached_name: DomRefCell<Atom>, /// The most recent size the worklet was drawn at - cached_size: Cell<TypedSize2D<f32, CSSPixel>>, + cached_size: Cell<Size2D<f32, CSSPixel>>, /// The most recent device pixel ratio the worklet was drawn at - cached_device_pixel_ratio: Cell<TypedScale<f32, CSSPixel, DevicePixel>>, + cached_device_pixel_ratio: Cell<Scale<f32, CSSPixel, DevicePixel>>, /// The most recent properties the worklet was drawn at cached_properties: DomRefCell<Vec<(Atom, String)>>, /// The most recent arguments the worklet was drawn at @@ -116,8 +116,8 @@ impl PaintWorkletGlobalScope { paint_definitions: Default::default(), paint_class_instances: Default::default(), cached_name: DomRefCell::new(Atom::from("")), - cached_size: Cell::new(TypedSize2D::zero()), - cached_device_pixel_ratio: Cell::new(TypedScale::new(1.0)), + cached_size: Cell::new(Size2D::zero()), + cached_device_pixel_ratio: Cell::new(Scale::new(1.0)), cached_properties: Default::default(), cached_arguments: Default::default(), cached_result: DomRefCell::new(DrawAPaintImageResult { @@ -211,13 +211,13 @@ impl PaintWorkletGlobalScope { fn draw_a_paint_image( &self, name: &Atom, - size_in_px: TypedSize2D<f32, CSSPixel>, - device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + size_in_px: Size2D<f32, CSSPixel>, + device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, properties: &StylePropertyMapReadOnly, arguments: &[String], ) -> DrawAPaintImageResult { let size_in_dpx = size_in_px * device_pixel_ratio; - let size_in_dpx = TypedSize2D::new( + let size_in_dpx = Size2D::new( size_in_dpx.width.abs() as u32, size_in_dpx.height.abs() as u32, ); @@ -240,9 +240,9 @@ impl PaintWorkletGlobalScope { fn invoke_a_paint_callback( &self, name: &Atom, - size_in_px: TypedSize2D<f32, CSSPixel>, - size_in_dpx: TypedSize2D<u32, DevicePixel>, - device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + size_in_px: Size2D<f32, CSSPixel>, + size_in_dpx: Size2D<u32, DevicePixel>, + device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, properties: &StylePropertyMapReadOnly, arguments: &[String], ) -> DrawAPaintImageResult { @@ -383,7 +383,7 @@ impl PaintWorkletGlobalScope { // https://drafts.csswg.org/css-images-4/#invalid-image fn invalid_image( &self, - size: TypedSize2D<u32, DevicePixel>, + size: Size2D<u32, DevicePixel>, missing_image_urls: Vec<ServoUrl>, ) -> DrawAPaintImageResult { debug!("Returning an invalid image."); @@ -420,8 +420,8 @@ impl PaintWorkletGlobalScope { impl Painter for WorkletPainter { fn draw_a_paint_image( &self, - size: TypedSize2D<f32, CSSPixel>, - device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + size: Size2D<f32, CSSPixel>, + device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, properties: Vec<(Atom, String)>, arguments: Vec<String>, ) -> Result<DrawAPaintImageResult, PaintWorkletError> { @@ -458,8 +458,8 @@ impl PaintWorkletGlobalScope { pub enum PaintWorkletTask { DrawAPaintImage( Atom, - TypedSize2D<f32, CSSPixel>, - TypedScale<f32, CSSPixel, DevicePixel>, + Size2D<f32, CSSPixel>, + Scale<f32, CSSPixel, DevicePixel>, Vec<(Atom, String)>, Vec<String>, Sender<DrawAPaintImageResult>, diff --git a/components/script/dom/screen.rs b/components/script/dom/screen.rs index ff90224d53a..cf5d6785405 100644 --- a/components/script/dom/screen.rs +++ b/components/script/dom/screen.rs @@ -12,7 +12,7 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; use crate::dom::window::Window; use dom_struct::dom_struct; -use euclid::TypedSize2D; +use euclid::Size2D; use profile_traits::ipc; use script_traits::ScriptMsg; use style_traits::CSSPixel; @@ -40,7 +40,7 @@ impl Screen { ) } - fn screen_size(&self) -> TypedSize2D<u32, CSSPixel> { + fn screen_size(&self) -> Size2D<u32, CSSPixel> { let (send, recv) = ipc::channel::<DeviceIntSize>(self.global().time_profiler_chan().clone()).unwrap(); self.window @@ -49,11 +49,11 @@ impl Screen { .send(ScriptMsg::GetScreenSize(send)) .unwrap(); let dpr = self.window.device_pixel_ratio(); - let screen = recv.recv().unwrap_or(TypedSize2D::zero()); + let screen = recv.recv().unwrap_or(Size2D::zero()); (screen.to_f32() / dpr).to_u32() } - fn screen_avail_size(&self) -> TypedSize2D<u32, CSSPixel> { + fn screen_avail_size(&self) -> Size2D<u32, CSSPixel> { let (send, recv) = ipc::channel::<DeviceIntSize>(self.global().time_profiler_chan().clone()).unwrap(); self.window @@ -62,7 +62,7 @@ impl Screen { .send(ScriptMsg::GetScreenAvailSize(send)) .unwrap(); let dpr = self.window.device_pixel_ratio(); - let screen = recv.recv().unwrap_or(TypedSize2D::zero()); + let screen = recv.recv().unwrap_or(Size2D::zero()); (screen.to_f32() / dpr).to_u32() } } diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index 98056104848..3b068caafca 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -32,7 +32,7 @@ use crate::dom::window::Window; /// https://www.khronos.org/registry/webgl/specs/latest/2.0/webgl.idl use canvas_traits::webgl::{GLContextAttributes, WebGLVersion}; use dom_struct::dom_struct; -use euclid::Size2D; +use euclid::default::Size2D; use js::jsapi::{JSContext, JSObject}; use js::jsval::JSVal; use js::rust::CustomAutoRooterGuard; diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 6e249a38ed0..21927e6bf44 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -59,7 +59,7 @@ use canvas_traits::webgl::{ YAxisTreatment, }; use dom_struct::dom_struct; -use euclid::{Point2D, Rect, Size2D}; +use euclid::default::{Point2D, Rect, Size2D}; use ipc_channel::ipc::{self, IpcSharedMemory}; use js::jsapi::{JSContext, JSObject, Type}; use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, UInt32Value}; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 31d66963327..4d1ea5e80d4 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -74,7 +74,8 @@ use cssparser::{Parser, ParserInput, SourceLocation}; use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; use dom_struct::dom_struct; use embedder_traits::EmbedderMsg; -use euclid::{Point2D, Rect, Size2D, TypedPoint2D, TypedScale, TypedSize2D, Vector2D}; +use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect}; +use euclid::{Point2D, Rect, Scale, Size2D, Vector2D}; use ipc_channel::ipc::{channel, IpcSender}; use ipc_channel::router::ROUTER; use js::jsapi::JSAutoRealm; @@ -131,7 +132,7 @@ use style::str::HTML_SPACE_CHARACTERS; use style::stylesheets::CssRuleType; use style_traits::{CSSPixel, DevicePixel, ParsingMode}; use url::Position; -use webrender_api::units::{DeviceIntPoint, DeviceIntSize}; +use webrender_api::units::{DeviceIntPoint, DeviceIntSize, LayoutPixel}; use webrender_api::{DocumentId, ExternalScrollId, RenderApiSender}; use webvr_traits::WebVRMsg; @@ -229,7 +230,7 @@ pub struct Window { /// An enlarged rectangle around the page contents visible in the viewport, used /// to prevent creating display list items for content that is far away from the viewport. - page_clip_rect: Cell<Rect<Au>>, + page_clip_rect: Cell<UntypedRect<Au>>, /// Flag to suppress reflows. The first reflow will come either with /// RefreshTick or with FirstLoad. Until those first reflows, we want to @@ -246,12 +247,12 @@ pub struct Window { /// The current state of the window object current_state: Cell<WindowState>, - current_viewport: Cell<Rect<Au>>, + current_viewport: Cell<UntypedRect<Au>>, error_reporter: CSSErrorReporter, /// A list of scroll offsets for each scrollable element. - scroll_offsets: DomRefCell<HashMap<OpaqueNode, Vector2D<f32>>>, + scroll_offsets: DomRefCell<HashMap<OpaqueNode, Vector2D<f32, LayoutPixel>>>, /// All the MediaQueryLists we need to update media_query_lists: DOMTracker<MediaQueryList>, @@ -423,11 +424,11 @@ impl Window { /// Sets a new list of scroll offsets. /// /// This is called when layout gives us new ones and WebRender is in use. - pub fn set_scroll_offsets(&self, offsets: HashMap<OpaqueNode, Vector2D<f32>>) { + pub fn set_scroll_offsets(&self, offsets: HashMap<OpaqueNode, Vector2D<f32, LayoutPixel>>) { *self.scroll_offsets.borrow_mut() = offsets } - pub fn current_viewport(&self) -> Rect<Au> { + pub fn current_viewport(&self) -> UntypedRect<Au> { self.current_viewport.clone().get() } @@ -1093,7 +1094,7 @@ impl WindowMethods for Window { // Step 1 //TODO determine if this operation is allowed let dpr = self.device_pixel_ratio(); - let size = TypedSize2D::new(width, height).to_f32() * dpr; + let size = Size2D::new(width, height).to_f32() * dpr; self.send_to_embedder(EmbedderMsg::ResizeTo(size.to_i32())); } @@ -1112,7 +1113,7 @@ impl WindowMethods for Window { // Step 1 //TODO determine if this operation is allowed let dpr = self.device_pixel_ratio(); - let point = TypedPoint2D::new(x, y).to_f32() * dpr; + let point = Point2D::new(x, y).to_f32() * dpr; let msg = EmbedderMsg::MoveTo(point.to_i32()); self.send_to_embedder(msg); } @@ -1377,18 +1378,16 @@ impl Window { self.current_viewport.set(new_viewport) } - pub fn device_pixel_ratio(&self) -> TypedScale<f32, CSSPixel, DevicePixel> { + pub fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel> { self.window_size.get().device_pixel_ratio } - fn client_window(&self) -> (TypedSize2D<u32, CSSPixel>, TypedPoint2D<i32, CSSPixel>) { + fn client_window(&self) -> (Size2D<u32, CSSPixel>, Point2D<i32, CSSPixel>) { let timer_profile_chan = self.global().time_profiler_chan().clone(); let (send, recv) = ProfiledIpc::channel::<(DeviceIntSize, DeviceIntPoint)>(timer_profile_chan).unwrap(); self.send_to_constellation(ScriptMsg::GetClientWindow(send)); - let (size, point) = recv - .recv() - .unwrap_or((TypedSize2D::zero(), TypedPoint2D::zero())); + let (size, point) = recv.recv().unwrap_or((Size2D::zero(), Point2D::zero())); let dpr = self.device_pixel_ratio(); ( (size.to_f32() / dpr).to_u32(), @@ -1626,7 +1625,7 @@ impl Window { &*self.layout_rpc } - pub fn content_box_query(&self, node: &Node) -> Option<Rect<Au>> { + pub fn content_box_query(&self, node: &Node) -> Option<UntypedRect<Au>> { if !self.layout_reflow(QueryMsg::ContentBoxQuery(node.to_opaque())) { return None; } @@ -1634,7 +1633,7 @@ impl Window { rect } - pub fn content_boxes_query(&self, node: &Node) -> Vec<Rect<Au>> { + pub fn content_boxes_query(&self, node: &Node) -> Vec<UntypedRect<Au>> { if !self.layout_reflow(QueryMsg::ContentBoxesQuery(node.to_opaque())) { return vec![]; } @@ -1642,21 +1641,21 @@ impl Window { rects } - pub fn client_rect_query(&self, node: &Node) -> Rect<i32> { + pub fn client_rect_query(&self, node: &Node) -> UntypedRect<i32> { if !self.layout_reflow(QueryMsg::NodeGeometryQuery(node.to_opaque())) { return Rect::zero(); } self.layout_rpc.node_geometry().client_rect } - pub fn scroll_area_query(&self, node: &Node) -> Rect<i32> { + pub fn scroll_area_query(&self, node: &Node) -> UntypedRect<i32> { if !self.layout_reflow(QueryMsg::NodeScrollGeometryQuery(node.to_opaque())) { return Rect::zero(); } self.layout_rpc.node_scroll_area().client_rect } - pub fn scroll_offset_query(&self, node: &Node) -> Vector2D<f32> { + pub fn scroll_offset_query(&self, node: &Node) -> Vector2D<f32, LayoutPixel> { if let Some(scroll_offset) = self.scroll_offsets.borrow().get(&node.to_opaque()) { return *scroll_offset; } @@ -1702,7 +1701,7 @@ impl Window { } #[allow(unsafe_code)] - pub fn offset_parent_query(&self, node: &Node) -> (Option<DomRoot<Element>>, Rect<Au>) { + pub fn offset_parent_query(&self, node: &Node) -> (Option<DomRoot<Element>>, UntypedRect<Au>) { if !self.layout_reflow(QueryMsg::OffsetParentQuery(node.to_opaque())) { return (None, Rect::zero()); } @@ -1726,7 +1725,11 @@ impl Window { self.layout_rpc.style().0 } - pub fn text_index_query(&self, node: &Node, point_in_node: Point2D<f32>) -> TextIndexResponse { + pub fn text_index_query( + &self, + node: &Node, + point_in_node: UntypedPoint2D<f32>, + ) -> TextIndexResponse { if !self.layout_reflow(QueryMsg::TextIndexQuery(node.to_opaque(), point_in_node)) { return TextIndexResponse(None); } @@ -1891,7 +1894,7 @@ impl Window { event } - pub fn set_page_clip_rect_with_new_viewport(&self, viewport: Rect<f32>) -> bool { + pub fn set_page_clip_rect_with_new_viewport(&self, viewport: UntypedRect<f32>) -> bool { let rect = f32_rect_to_au_rect(viewport.clone()); self.current_viewport.set(rect); // We use a clipping rectangle that is five times the size of the of the viewport, @@ -2184,8 +2187,8 @@ impl Window { } } -fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool { - let clip_rect = Rect::new( +fn should_move_clip_rect(clip_rect: UntypedRect<Au>, new_viewport: UntypedRect<f32>) -> bool { + let clip_rect = UntypedRect::new( Point2D::new( clip_rect.origin.x.to_f32_px(), clip_rect.origin.y.to_f32_px(), diff --git a/components/script/dom/xrframe.rs b/components/script/dom/xrframe.rs index 8c3bf737ec1..29572c02300 100644 --- a/components/script/dom/xrframe.rs +++ b/components/script/dom/xrframe.rs @@ -95,7 +95,7 @@ impl XRFrameMethods for XRFrame { } let space = space.get_pose(&self.data); let relative_to = relative_to.get_pose(&self.data); - let pose = relative_to.inverse().pre_mul(&space); + let pose = relative_to.inverse().pre_transform(&space); Ok(Some(XRPose::new(&self.global(), pose))) } } diff --git a/components/script/dom/xrreferencespace.rs b/components/script/dom/xrreferencespace.rs index f07ea8e7658..829fdfc02fa 100644 --- a/components/script/dom/xrreferencespace.rs +++ b/components/script/dom/xrreferencespace.rs @@ -13,7 +13,7 @@ use crate::dom::xrrigidtransform::XRRigidTransform; use crate::dom::xrsession::{cast_transform, ApiPose, ApiRigidTransform, ApiViewerPose, XRSession}; use crate::dom::xrspace::XRSpace; use dom_struct::dom_struct; -use euclid::{TypedRigidTransform3D, TypedVector3D}; +use euclid::{RigidTransform3D, Vector3D}; use webxr_api::Frame; #[dom_struct] @@ -64,7 +64,7 @@ impl XRReferenceSpace { impl XRReferenceSpaceMethods for XRReferenceSpace { /// https://immersive-web.github.io/webxr/#dom-xrreferencespace-getoffsetreferencespace fn GetOffsetReferenceSpace(&self, new: &XRRigidTransform) -> DomRoot<Self> { - let offset = new.transform().pre_mul(&self.offset.transform()); + let offset = new.transform().pre_transform(&self.offset.transform()); let offset = XRRigidTransform::new(&self.global(), offset); Self::new_offset( &self.global(), @@ -92,7 +92,7 @@ impl XRReferenceSpace { // = offset.inverse() * get_unoffset_viewer_pose(space) let offset = self.offset.transform(); let inverse = offset.inverse(); - inverse.pre_mul(&pose) + inverse.pre_transform(&pose) } /// Gets pose of the viewer with respect to this space @@ -120,13 +120,13 @@ impl XRReferenceSpace { // = Translate(2) * viewer_pose // assume approximate user height of 2 meters - let floor_to_eye: ApiRigidTransform = TypedVector3D::new(0., 2., 0.).into(); - floor_to_eye.pre_mul(&viewer_pose) + let floor_to_eye: ApiRigidTransform = Vector3D::new(0., 2., 0.).into(); + floor_to_eye.pre_transform(&viewer_pose) }, XRReferenceSpaceType::Viewer => { // This reference space follows the viewer around, so the viewer is // always at an identity transform with respect to it - TypedRigidTransform3D::identity() + RigidTransform3D::identity() }, _ => unimplemented!(), } @@ -142,7 +142,7 @@ impl XRReferenceSpace { // This may change, see https://github.com/immersive-web/webxr/issues/567 let offset = self.offset.transform(); - offset.post_mul(&pose) + offset.post_transform(&pose) } /// Gets pose represented by this space @@ -153,14 +153,14 @@ impl XRReferenceSpace { XRReferenceSpaceType::Local => { // The eye-level pose is basically whatever the headset pose was at t=0, which // for most devices is (0, 0, 0) - TypedRigidTransform3D::identity() + RigidTransform3D::identity() }, XRReferenceSpaceType::Local_floor => { // XXXManishearth support getting floor info from stage parameters // Assume approximate height of 2m // the floor-level space is 2m below the eye-level space, which is (0, 0, 0) - TypedVector3D::new(0., -2., 0.).into() + Vector3D::new(0., -2., 0.).into() }, XRReferenceSpaceType::Viewer => cast_transform(base_pose.transform), _ => unimplemented!(), diff --git a/components/script/dom/xrrigidtransform.rs b/components/script/dom/xrrigidtransform.rs index ca73121d931..887b54f688c 100644 --- a/components/script/dom/xrrigidtransform.rs +++ b/components/script/dom/xrrigidtransform.rs @@ -16,7 +16,7 @@ use crate::dom::vrframedata::create_typed_array; use crate::dom::window::Window; use crate::dom::xrsession::ApiRigidTransform; use dom_struct::dom_struct; -use euclid::{TypedRigidTransform3D, TypedRotation3D, TypedVector3D}; +use euclid::{RigidTransform3D, Rotation3D, Vector3D}; use js::jsapi::{Heap, JSContext, JSObject}; use std::ptr::NonNull; @@ -53,7 +53,7 @@ impl XRRigidTransform { } pub fn identity(window: &GlobalScope) -> DomRoot<XRRigidTransform> { - let transform = TypedRigidTransform3D::identity(); + let transform = RigidTransform3D::identity(); XRRigidTransform::new(window, transform) } @@ -70,8 +70,8 @@ impl XRRigidTransform { ))); } - let translate = TypedVector3D::new(position.x as f32, position.y as f32, position.z as f32); - let rotate = TypedRotation3D::unit_quaternion( + let translate = Vector3D::new(position.x as f32, position.y as f32, position.z as f32); + let rotate = Rotation3D::unit_quaternion( orientation.x as f32, orientation.y as f32, orientation.z as f32, @@ -83,7 +83,7 @@ impl XRRigidTransform { // value for each element. This is preferable to checking for zero. return Err(Error::InvalidState); } - let transform = TypedRigidTransform3D::new(rotate, translate); + let transform = RigidTransform3D::new(rotate, translate); Ok(XRRigidTransform::new(&window.global(), transform)) } } diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index 0ea8a0e0e46..9542486f3ae 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -38,7 +38,7 @@ use crate::dom::xrspace::XRSpace; use crate::dom::xrwebgllayer::XRWebGLLayer; use crate::task_source::TaskSource; use dom_struct::dom_struct; -use euclid::TypedRigidTransform3D; +use euclid::RigidTransform3D; use ipc_channel::ipc::IpcSender; use ipc_channel::router::ROUTER; use profile_traits::ipc; @@ -403,15 +403,15 @@ impl XRSessionMethods for XRSession { #[derive(Clone, Copy, Debug)] pub struct ApiSpace; // The pose of an object in native-space. Should never be exposed. -pub type ApiPose = TypedRigidTransform3D<f32, ApiSpace, webxr_api::Native>; +pub type ApiPose = RigidTransform3D<f32, ApiSpace, webxr_api::Native>; // The pose of the viewer in some api-space. -pub type ApiViewerPose = TypedRigidTransform3D<f32, webxr_api::Viewer, ApiSpace>; +pub type ApiViewerPose = RigidTransform3D<f32, webxr_api::Viewer, ApiSpace>; // A transform between objects in some API-space -pub type ApiRigidTransform = TypedRigidTransform3D<f32, ApiSpace, ApiSpace>; +pub type ApiRigidTransform = RigidTransform3D<f32, ApiSpace, ApiSpace>; #[allow(unsafe_code)] pub fn cast_transform<T, U, V, W>( - transform: TypedRigidTransform3D<f32, T, U>, -) -> TypedRigidTransform3D<f32, V, W> { + transform: RigidTransform3D<f32, T, U>, +) -> RigidTransform3D<f32, V, W> { unsafe { mem::transmute(transform) } } diff --git a/components/script/dom/xrtest.rs b/components/script/dom/xrtest.rs index 81949addf02..c8f45b75b4f 100644 --- a/components/script/dom/xrtest.rs +++ b/components/script/dom/xrtest.rs @@ -20,7 +20,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::task_source::TaskSource; use dom_struct::dom_struct; -use euclid::TypedRigidTransform3D; +use euclid::RigidTransform3D; use ipc_channel::ipc::IpcSender; use ipc_channel::router::ROUTER; use profile_traits::ipc; @@ -103,7 +103,7 @@ impl XRTestMethods for XRTest { }, } } else { - TypedRigidTransform3D::identity() + RigidTransform3D::identity() }; let floor_origin = if let Some(ref o) = init.floorOrigin { @@ -115,7 +115,7 @@ impl XRTestMethods for XRTest { }, } } else { - TypedRigidTransform3D::identity() + RigidTransform3D::identity() }; let views = match get_views(&init.views) { diff --git a/components/script/dom/xrview.rs b/components/script/dom/xrview.rs index 5ff8d397bd6..807217945a6 100644 --- a/components/script/dom/xrview.rs +++ b/components/script/dom/xrview.rs @@ -53,7 +53,7 @@ impl XRView { // from the viewer space to the eye space. We invert it to get the pose of the eye in the viewer space. let offset = view.transform.inverse(); - let transform = pose.pre_mul(&offset); + let transform = pose.pre_transform(&offset); let transform = XRRigidTransform::new(global, cast_transform(transform)); let ret = reflect_dom_object( diff --git a/components/script/dom/xrviewport.rs b/components/script/dom/xrviewport.rs index f0b013a317e..80b8c27fbaa 100644 --- a/components/script/dom/xrviewport.rs +++ b/components/script/dom/xrviewport.rs @@ -8,24 +8,24 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; -use euclid::TypedRect; +use euclid::Rect; use webxr_api::Viewport; #[dom_struct] pub struct XRViewport { reflector_: Reflector, - viewport: TypedRect<i32, Viewport>, + viewport: Rect<i32, Viewport>, } impl XRViewport { - fn new_inherited(viewport: TypedRect<i32, Viewport>) -> XRViewport { + fn new_inherited(viewport: Rect<i32, Viewport>) -> XRViewport { XRViewport { reflector_: Reflector::new(), viewport, } } - pub fn new(global: &GlobalScope, viewport: TypedRect<i32, Viewport>) -> DomRoot<XRViewport> { + pub fn new(global: &GlobalScope, viewport: Rect<i32, Viewport>) -> DomRoot<XRViewport> { reflect_dom_object( Box::new(XRViewport::new_inherited(viewport)), global, diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 07626cc80bd..8193c9b7ace 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -94,7 +94,8 @@ use devtools_traits::CSSError; use devtools_traits::{DevtoolScriptControlMsg, DevtoolsPageInfo}; use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; use embedder_traits::EmbedderMsg; -use euclid::{Point2D, Rect, Vector2D}; +use euclid::default::{Point2D, Rect}; +use euclid::Vector2D; use headers::ReferrerPolicy as ReferrerPolicyHeader; use headers::{HeaderMapExt, LastModified}; use hyper_serde::Serde; @@ -161,6 +162,7 @@ use style::thread_state::{self, ThreadState}; use time::{at_utc, get_time, precise_time_ns, Timespec}; use url::percent_encoding::percent_decode; use url::Position; +use webrender_api::units::LayoutPixel; use webrender_api::{DocumentId, RenderApiSender}; use webvr_traits::{WebVREvent, WebVRMsg}; @@ -2230,7 +2232,7 @@ impl ScriptThread { fn handle_set_scroll_state( &self, id: PipelineId, - scroll_states: &[(UntrustedNodeAddress, Vector2D<f32>)], + scroll_states: &[(UntrustedNodeAddress, Vector2D<f32, LayoutPixel>)], ) { let window = match { self.documents.borrow().find_window(id) } { Some(window) => window, diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 03b61875b3b..3871b7a6ef5 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -29,7 +29,7 @@ use crate::dom::window::Window; use crate::dom::xmlserializer::XMLSerializer; use crate::script_thread::Documents; use cookie::Cookie; -use euclid::{Point2D, Rect, Size2D}; +use euclid::default::{Point2D, Rect, Size2D}; use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcSender}; use js::jsapi::JSContext; diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index 91ef929ec28..88eaddfa6c5 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -16,7 +16,7 @@ atomic_refcell = "0.1" canvas_traits = {path = "../canvas_traits"} cssparser = "0.25" crossbeam-channel = "0.3" -euclid = "0.19" +euclid = "0.20" gfx_traits = {path = "../gfx_traits"} html5ever = "0.23" ipc-channel = "0.11" diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index 2c2c2229ba0..c6d9710541f 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -6,7 +6,7 @@ use crate::rpc::LayoutRPC; use crate::{OpaqueStyleAndLayoutData, PendingImage, TrustedNodeAddress}; use app_units::Au; use crossbeam_channel::{Receiver, Sender}; -use euclid::{Point2D, Rect}; +use euclid::default::{Point2D, Rect}; use gfx_traits::Epoch; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use metrics::PaintTimeMetrics; diff --git a/components/script_layout_interface/rpc.rs b/components/script_layout_interface/rpc.rs index f77b7e63836..95d25082ed8 100644 --- a/components/script_layout_interface/rpc.rs +++ b/components/script_layout_interface/rpc.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use app_units::Au; -use euclid::Rect; +use euclid::default::Rect; use script_traits::UntrustedNodeAddress; use servo_arc::Arc; use style::properties::ComputedValues; diff --git a/components/script_traits/Cargo.toml b/components/script_traits/Cargo.toml index 5cc35639ae0..61e1dda7410 100644 --- a/components/script_traits/Cargo.toml +++ b/components/script_traits/Cargo.toml @@ -17,7 +17,7 @@ cookie = "0.11" crossbeam-channel = "0.3" devtools_traits = {path = "../devtools_traits"} embedder_traits = {path = "../embedder_traits"} -euclid = "0.19" +euclid = "0.20" gfx_traits = {path = "../gfx_traits"} http = "0.1" hyper = "0.12" diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 518bea585e6..19c8a41e8c5 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -25,7 +25,10 @@ use canvas_traits::webgl::WebGLPipeline; use crossbeam_channel::{Receiver, RecvTimeoutError, Sender}; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; use embedder_traits::Cursor; -use euclid::{Length, Point2D, Rect, TypedScale, TypedSize2D, Vector2D}; +use euclid::{ + default::{Point2D, Rect}, + Length, Scale, Size2D, Vector2D, +}; use gfx_traits::Epoch; use http::HeaderMap; use hyper::Method; @@ -58,7 +61,7 @@ use std::sync::Arc; use std::time::Duration; use style_traits::CSSPixel; use style_traits::SpeculativePainter; -use webrender_api::units::{DeviceIntSize, DevicePixel}; +use webrender_api::units::{DeviceIntSize, DevicePixel, LayoutPixel}; use webrender_api::{DocumentId, ExternalScrollId, ImageKey, RenderApiSender}; use webvr_traits::{WebVREvent, WebVRMsg}; @@ -295,7 +298,10 @@ pub enum ConstellationControlMsg { /// Notifies script of the viewport. Viewport(PipelineId, Rect<f32>), /// Notifies script of a new set of scroll offsets. - SetScrollState(PipelineId, Vec<(UntrustedNodeAddress, Vector2D<f32>)>), + SetScrollState( + PipelineId, + Vec<(UntrustedNodeAddress, Vector2D<f32, LayoutPixel>)>, + ), /// Requests that the script thread immediately send the constellation the title of a pipeline. GetTitle(PipelineId), /// Notifies script thread of a change to one of its document's activity @@ -753,7 +759,7 @@ pub struct ScrollState { /// The ID of the scroll root. pub scroll_id: ExternalScrollId, /// The scrolling offset of this stacking context. - pub scroll_offset: Vector2D<f32>, + pub scroll_offset: Vector2D<f32, LayoutPixel>, } /// Data about the window size. @@ -761,10 +767,10 @@ pub struct ScrollState { pub struct WindowSizeData { /// The size of the initial layout viewport, before parsing an /// <http://www.w3.org/TR/css-device-adapt/#initial-viewport> - pub initial_viewport: TypedSize2D<f32, CSSPixel>, + pub initial_viewport: Size2D<f32, CSSPixel>, /// The resolution of the window in dppx, not including any "pinch zoom" factor. - pub device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + pub device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, } /// The type of window size change. @@ -953,8 +959,8 @@ pub trait Painter: SpeculativePainter { /// <https://drafts.css-houdini.org/css-paint-api/#draw-a-paint-image> fn draw_a_paint_image( &self, - size: TypedSize2D<f32, CSSPixel>, - zoom: TypedScale<f32, CSSPixel, DevicePixel>, + size: Size2D<f32, CSSPixel>, + zoom: Scale<f32, CSSPixel, DevicePixel>, properties: Vec<(Atom, String)>, arguments: Vec<String>, ) -> Result<DrawAPaintImageResult, PaintWorkletError>; diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index 200604cbbf5..c3ee8d75205 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -14,7 +14,8 @@ use crate::WorkerScriptLoadOrigin; use canvas_traits::canvas::{CanvasId, CanvasMsg}; use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; use embedder_traits::EmbedderMsg; -use euclid::{Size2D, TypedSize2D}; +use euclid::default::Size2D as UntypedSize2D; +use euclid::Size2D; use gfx_traits::Epoch; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId}; @@ -35,7 +36,7 @@ pub struct IFrameSize { /// The child browsing context for this iframe. pub id: BrowsingContextId, /// The size of the iframe. - pub size: TypedSize2D<f32, CSSPixel>, + pub size: Size2D<f32, CSSPixel>, } /// An iframe sizing operation. @@ -126,7 +127,10 @@ pub enum ScriptMsg { ChangeRunningAnimationsState(AnimationState), /// Requests that a new 2D canvas thread be created. (This is done in the constellation because /// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.) - CreateCanvasPaintThread(Size2D<u64>, IpcSender<(IpcSender<CanvasMsg>, CanvasId)>), + CreateCanvasPaintThread( + UntypedSize2D<u64>, + IpcSender<(IpcSender<CanvasMsg>, CanvasId)>, + ), /// Notifies the constellation that this frame has received focus. Focus, /// Get the top-level browsing context info for a given browsing context. diff --git a/components/script_traits/webdriver_msg.rs b/components/script_traits/webdriver_msg.rs index db7fc65d042..2d15172fe30 100644 --- a/components/script_traits/webdriver_msg.rs +++ b/components/script_traits/webdriver_msg.rs @@ -5,7 +5,7 @@ #![allow(missing_docs)] use cookie::Cookie; -use euclid::Rect; +use euclid::default::Rect; use hyper_serde::Serde; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::BrowsingContextId; diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 77a297d67d1..cc158af843f 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -50,7 +50,7 @@ devtools = {path = "../devtools"} devtools_traits = {path = "../devtools_traits"} embedder_traits = {path = "../embedder_traits"} env_logger = "0.6" -euclid = "0.19" +euclid = "0.20" gfx = {path = "../gfx"} gleam = "0.6" ipc-channel = "0.11" @@ -60,7 +60,7 @@ layout_thread_2020 = {path = "../layout_thread_2020", optional = true} log = "0.4" media = {path = "../media"} msg = {path = "../msg"} -offscreen_gl_context = "0.22" +offscreen_gl_context = "0.23" net = {path = "../net"} net_traits = {path = "../net_traits"} profile = {path = "../profile"} diff --git a/components/servo/lib.rs b/components/servo/lib.rs index ac1cd492a12..a64972bc1a7 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -84,7 +84,7 @@ use constellation::{FromCompositorLogger, FromScriptLogger}; use crossbeam_channel::{unbounded, Sender}; use embedder_traits::{EmbedderMsg, EmbedderProxy, EmbedderReceiver, EventLoopWaker}; use env_logger::Builder as EnvLoggerBuilder; -use euclid::TypedSize2D; +use euclid::Size2D; #[cfg(all( not(target_os = "windows"), not(target_os = "ios"), @@ -326,8 +326,8 @@ where // Cast from `DeviceIndependentPixel` to `DevicePixel` let device_pixel_ratio = coordinates.hidpi_factor.get(); - let window_size = TypedSize2D::from_untyped( - &(opts.initial_window_size.to_f32() / device_pixel_ratio) + let window_size = Size2D::from_untyped( + (opts.initial_window_size.to_f32() / device_pixel_ratio) .to_i32() .to_untyped(), ); diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index c0c01204037..d276c5fbc6c 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -16,8 +16,7 @@ path = "lib.rs" doctest = false [features] -gecko = ["style_traits/gecko", "fallible/known_system_malloc"] -use_bindgen = ["bindgen", "regex", "toml"] +gecko = ["style_traits/gecko", "fallible/known_system_malloc", "bindgen", "regex", "toml"] servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever", "cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union", "servo_url", "string_cache", "crossbeam-channel", "to_shmem/servo", "servo_arc/servo"] @@ -37,7 +36,7 @@ crossbeam-channel = { version = "0.3", optional = true } derive_more = "0.13" new_debug_unreachable = "1.0" encoding_rs = {version = "0.8", optional = true} -euclid = "0.19" +euclid = "0.20" fallible = { path = "../fallible" } fxhash = "0.2" hashglobe = { path = "../hashglobe" } diff --git a/components/style/build.rs b/components/style/build.rs index 9997d0e660b..0ff8434fa1d 100644 --- a/components/style/build.rs +++ b/components/style/build.rs @@ -4,13 +4,13 @@ #[macro_use] extern crate lazy_static; -#[cfg(feature = "bindgen")] +#[cfg(feature = "gecko")] extern crate bindgen; -#[cfg(feature = "bindgen")] +#[cfg(feature = "gecko")] extern crate log; -#[cfg(feature = "bindgen")] +#[cfg(feature = "gecko")] extern crate regex; -#[cfg(feature = "bindgen")] +#[cfg(feature = "gecko")] extern crate toml; extern crate walkdir; diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index e51ba6bfa3f..86d2098d063 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -2,458 +2,406 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -mod common { - use std::env; - use std::path::PathBuf; - - lazy_static! { - pub static ref OUTDIR_PATH: PathBuf = - PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("gecko"); - } +use super::PYTHON; +use bindgen::{Builder, CodegenConfig}; +use regex::Regex; +use std::cmp; +use std::collections::HashSet; +use std::env; +use std::fs::{self, File}; +use std::io::{Read, Write}; +use std::path::{Path, PathBuf}; +use std::process::{exit, Command}; +use std::slice; +use std::sync::Mutex; +use std::time::SystemTime; +use toml; +use toml::value::Table; + +lazy_static! { + static ref OUTDIR_PATH: PathBuf = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("gecko"); } -#[cfg(feature = "bindgen")] -mod bindings { - use super::super::PYTHON; - use super::common::*; - use bindgen::{Builder, CodegenConfig}; - use regex::Regex; - use std::cmp; - use std::collections::HashSet; - use std::env; - use std::fs::{self, File}; - use std::io::{Read, Write}; - use std::path::{Path, PathBuf}; - use std::process::{exit, Command}; - use std::slice; - use std::sync::Mutex; - use std::time::SystemTime; - use toml; - use toml::value::Table; - - const STRUCTS_FILE: &'static str = "structs.rs"; - - fn read_config(path: &PathBuf) -> Table { - println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); - update_last_modified(&path); - - let mut contents = String::new(); - File::open(path) - .expect("Failed to open config file") - .read_to_string(&mut contents) - .expect("Failed to read config file"); - match toml::from_str::<Table>(&contents) { - Ok(result) => result, - Err(e) => panic!("Failed to parse config file: {}", e), - } - } - - lazy_static! { - static ref CONFIG: Table = { - // Load Gecko's binding generator config from the source tree. - let path = PathBuf::from(env::var_os("MOZ_SRC").unwrap()) - .join("layout/style/ServoBindings.toml"); - read_config(&path) - }; - static ref BUILD_CONFIG: Table = { - // Load build-specific config overrides. - let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap()) - .join("layout/style/bindgen.toml"); - read_config(&path) - }; - static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap(); - static ref DISTDIR_PATH: PathBuf = { - let path = PathBuf::from(env::var_os("MOZ_DIST").unwrap()); - if !path.is_absolute() || !path.is_dir() { - panic!("MOZ_DIST must be an absolute directory, was: {}", path.display()); - } - path - }; - static ref SEARCH_PATHS: Vec<PathBuf> = vec![ - DISTDIR_PATH.join("include"), - DISTDIR_PATH.join("include/nspr"), - ]; - static ref ADDED_PATHS: Mutex<HashSet<PathBuf>> = Mutex::new(HashSet::new()); - static ref LAST_MODIFIED: Mutex<SystemTime> = - Mutex::new(get_modified_time(&env::current_exe().unwrap()) - .expect("Failed to get modified time of executable")); - } +const STRUCTS_FILE: &'static str = "structs.rs"; - fn get_modified_time(file: &Path) -> Option<SystemTime> { - file.metadata().and_then(|m| m.modified()).ok() - } +fn read_config(path: &PathBuf) -> Table { + println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); + update_last_modified(&path); - fn update_last_modified(file: &Path) { - let modified = get_modified_time(file).expect("Couldn't get file modification time"); - let mut last_modified = LAST_MODIFIED.lock().unwrap(); - *last_modified = cmp::max(modified, *last_modified); + let mut contents = String::new(); + File::open(path) + .expect("Failed to open config file") + .read_to_string(&mut contents) + .expect("Failed to read config file"); + match toml::from_str::<Table>(&contents) { + Ok(result) => result, + Err(e) => panic!("Failed to parse config file: {}", e), } +} - fn search_include(name: &str) -> Option<PathBuf> { - for path in SEARCH_PATHS.iter() { - let file = path.join(name); - if file.is_file() { - update_last_modified(&file); - return Some(file); - } +lazy_static! { + static ref CONFIG: Table = { + // Load Gecko's binding generator config from the source tree. + let path = PathBuf::from(env::var_os("MOZ_SRC").unwrap()) + .join("layout/style/ServoBindings.toml"); + read_config(&path) + }; + static ref BUILD_CONFIG: Table = { + // Load build-specific config overrides. + let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap()) + .join("layout/style/bindgen.toml"); + read_config(&path) + }; + static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap(); + static ref DISTDIR_PATH: PathBuf = { + let path = PathBuf::from(env::var_os("MOZ_DIST").unwrap()); + if !path.is_absolute() || !path.is_dir() { + panic!("MOZ_DIST must be an absolute directory, was: {}", path.display()); } - None - } + path + }; + static ref SEARCH_PATHS: Vec<PathBuf> = vec![ + DISTDIR_PATH.join("include"), + DISTDIR_PATH.join("include/nspr"), + ]; + static ref ADDED_PATHS: Mutex<HashSet<PathBuf>> = Mutex::new(HashSet::new()); + static ref LAST_MODIFIED: Mutex<SystemTime> = + Mutex::new(get_modified_time(&env::current_exe().unwrap()) + .expect("Failed to get modified time of executable")); +} - fn add_headers_recursively(path: PathBuf, added_paths: &mut HashSet<PathBuf>) { - if added_paths.contains(&path) { - return; - } - let mut file = File::open(&path).unwrap(); - let mut content = String::new(); - file.read_to_string(&mut content).unwrap(); - added_paths.insert(path); - // Find all includes and add them recursively - for cap in INCLUDE_RE.captures_iter(&content) { - if let Some(path) = search_include(cap.get(1).unwrap().as_str()) { - add_headers_recursively(path, added_paths); - } +fn get_modified_time(file: &Path) -> Option<SystemTime> { + file.metadata().and_then(|m| m.modified()).ok() +} + +fn update_last_modified(file: &Path) { + let modified = get_modified_time(file).expect("Couldn't get file modification time"); + let mut last_modified = LAST_MODIFIED.lock().unwrap(); + *last_modified = cmp::max(modified, *last_modified); +} + +fn search_include(name: &str) -> Option<PathBuf> { + for path in SEARCH_PATHS.iter() { + let file = path.join(name); + if file.is_file() { + update_last_modified(&file); + return Some(file); } } + None +} - fn add_include(name: &str) -> String { - let mut added_paths = ADDED_PATHS.lock().unwrap(); - let file = search_include(name).expect("Include not found!"); - let result = String::from(file.to_str().unwrap()); - add_headers_recursively(file, &mut *added_paths); - result +fn add_headers_recursively(path: PathBuf, added_paths: &mut HashSet<PathBuf>) { + if added_paths.contains(&path) { + return; } - - trait BuilderExt { - fn get_initial_builder() -> Builder; - fn include<T: Into<String>>(self, file: T) -> Builder; + let mut file = File::open(&path).unwrap(); + let mut content = String::new(); + file.read_to_string(&mut content).unwrap(); + added_paths.insert(path); + // Find all includes and add them recursively + for cap in INCLUDE_RE.captures_iter(&content) { + if let Some(path) = search_include(cap.get(1).unwrap().as_str()) { + add_headers_recursively(path, added_paths); + } } +} - impl BuilderExt for Builder { - fn get_initial_builder() -> Builder { - use bindgen::RustTarget; - - // Disable rust unions, because we replace some types inside of - // them. - let mut builder = Builder::default() - .rust_target(RustTarget::Stable_1_25) - .disable_untagged_union(); - - let rustfmt_path = env::var_os("RUSTFMT") - // This can be replaced with - // > .filter(|p| !p.is_empty()).map(PathBuf::from) - // once we can use 1.27+. - .and_then(|p| { - if p.is_empty() { - None - } else { - Some(PathBuf::from(p)) - } - }); - if let Some(path) = rustfmt_path { - builder = builder.with_rustfmt(path); - } +fn add_include(name: &str) -> String { + let mut added_paths = ADDED_PATHS.lock().unwrap(); + let file = search_include(name).expect("Include not found!"); + let result = String::from(file.to_str().unwrap()); + add_headers_recursively(file, &mut *added_paths); + result +} - for dir in SEARCH_PATHS.iter() { - builder = builder.clang_arg("-I").clang_arg(dir.to_str().unwrap()); - } +trait BuilderExt { + fn get_initial_builder() -> Builder; + fn include<T: Into<String>>(self, file: T) -> Builder; +} - builder = builder.include(add_include("mozilla-config.h")); +impl BuilderExt for Builder { + fn get_initial_builder() -> Builder { + use bindgen::RustTarget; + + // Disable rust unions, because we replace some types inside of + // them. + let mut builder = Builder::default() + .rust_target(RustTarget::Stable_1_25) + .disable_untagged_union(); + + let rustfmt_path = env::var_os("RUSTFMT") + // This can be replaced with + // > .filter(|p| !p.is_empty()).map(PathBuf::from) + // once we can use 1.27+. + .and_then(|p| { + if p.is_empty() { + None + } else { + Some(PathBuf::from(p)) + } + }); + if let Some(path) = rustfmt_path { + builder = builder.with_rustfmt(path); + } - if env::var("CARGO_FEATURE_GECKO_DEBUG").is_ok() { - builder = builder.clang_arg("-DDEBUG=1").clang_arg("-DJS_DEBUG=1"); - } + for dir in SEARCH_PATHS.iter() { + builder = builder.clang_arg("-I").clang_arg(dir.to_str().unwrap()); + } - let build_config = BUILD_CONFIG["build"] - .as_table() - .expect("Malformed config file"); - let extra_bindgen_flags = build_config["args"].as_array().unwrap().as_slice(); - for item in extra_bindgen_flags.iter() { - builder = builder.clang_arg(item.as_str().expect("Expect string in list")); - } + builder = builder.include(add_include("mozilla-config.h")); - builder + if env::var("CARGO_FEATURE_GECKO_DEBUG").is_ok() { + builder = builder.clang_arg("-DDEBUG=1").clang_arg("-DJS_DEBUG=1"); } - fn include<T: Into<String>>(self, file: T) -> Builder { - self.clang_arg("-include").clang_arg(file) + + let build_config = BUILD_CONFIG["build"] + .as_table() + .expect("Malformed config file"); + let extra_bindgen_flags = build_config["args"].as_array().unwrap().as_slice(); + for item in extra_bindgen_flags.iter() { + builder = builder.clang_arg(item.as_str().expect("Expect string in list")); } - } - struct Fixup { - pat: String, - rep: String, + builder + } + fn include<T: Into<String>>(self, file: T) -> Builder { + self.clang_arg("-include").clang_arg(file) } +} - fn write_binding_file(builder: Builder, file: &str, fixups: &[Fixup]) { - let out_file = OUTDIR_PATH.join(file); - if let Some(modified) = get_modified_time(&out_file) { - // Don't generate the file if nothing it depends on was modified. - let last_modified = LAST_MODIFIED.lock().unwrap(); - if *last_modified <= modified { - return; - } - } - let command_line_opts = builder.command_line_flags(); - let result = builder.generate(); - let mut result = match result { - Ok(bindings) => bindings.to_string(), - Err(_) => { - panic!( - "Failed to generate bindings, flags: {:?}", - command_line_opts - ); - }, - }; - - for fixup in fixups.iter() { - result = Regex::new(&fixup.pat) - .unwrap() - .replace_all(&result, &*fixup.rep) - .into_owned() - .into(); +struct Fixup { + pat: String, + rep: String, +} + +fn write_binding_file(builder: Builder, file: &str, fixups: &[Fixup]) { + let out_file = OUTDIR_PATH.join(file); + if let Some(modified) = get_modified_time(&out_file) { + // Don't generate the file if nothing it depends on was modified. + let last_modified = LAST_MODIFIED.lock().unwrap(); + if *last_modified <= modified { + return; } - let bytes = result.into_bytes(); - File::create(&out_file) - .unwrap() - .write_all(&bytes) - .expect("Unable to write output"); } + let command_line_opts = builder.command_line_flags(); + let result = builder.generate(); + let mut result = match result { + Ok(bindings) => bindings.to_string(), + Err(_) => { + panic!( + "Failed to generate bindings, flags: {:?}", + command_line_opts + ); + }, + }; - struct BuilderWithConfig<'a> { - builder: Builder, - config: &'a Table, - used_keys: HashSet<&'static str>, + for fixup in fixups.iter() { + result = Regex::new(&fixup.pat) + .unwrap() + .replace_all(&result, &*fixup.rep) + .into_owned() + .into(); } - impl<'a> BuilderWithConfig<'a> { - fn new(builder: Builder, config: &'a Table) -> Self { - BuilderWithConfig { - builder, - config, - used_keys: HashSet::new(), - } - } + let bytes = result.into_bytes(); + File::create(&out_file) + .unwrap() + .write_all(&bytes) + .expect("Unable to write output"); +} - fn handle_list<F>(self, key: &'static str, func: F) -> BuilderWithConfig<'a> - where - F: FnOnce(Builder, slice::Iter<'a, toml::Value>) -> Builder, - { - let mut builder = self.builder; - let config = self.config; - let mut used_keys = self.used_keys; - if let Some(list) = config.get(key) { - used_keys.insert(key); - builder = func(builder, list.as_array().unwrap().as_slice().iter()); - } - BuilderWithConfig { - builder, - config, - used_keys, - } - } - fn handle_items<F>(self, key: &'static str, mut func: F) -> BuilderWithConfig<'a> - where - F: FnMut(Builder, &'a toml::Value) -> Builder, - { - self.handle_list(key, |b, iter| iter.fold(b, |b, item| func(b, item))) - } - fn handle_str_items<F>(self, key: &'static str, mut func: F) -> BuilderWithConfig<'a> - where - F: FnMut(Builder, &'a str) -> Builder, - { - self.handle_items(key, |b, item| func(b, item.as_str().unwrap())) - } - fn handle_table_items<F>(self, key: &'static str, mut func: F) -> BuilderWithConfig<'a> - where - F: FnMut(Builder, &'a Table) -> Builder, - { - self.handle_items(key, |b, item| func(b, item.as_table().unwrap())) - } - fn handle_common(self, fixups: &mut Vec<Fixup>) -> BuilderWithConfig<'a> { - self.handle_str_items("headers", |b, item| b.header(add_include(item))) - .handle_str_items("raw-lines", |b, item| b.raw_line(item)) - .handle_str_items("hide-types", |b, item| b.blacklist_type(item)) - .handle_table_items("fixups", |builder, item| { - fixups.push(Fixup { - pat: item["pat"].as_str().unwrap().into(), - rep: item["rep"].as_str().unwrap().into(), - }); - builder - }) +struct BuilderWithConfig<'a> { + builder: Builder, + config: &'a Table, + used_keys: HashSet<&'static str>, +} +impl<'a> BuilderWithConfig<'a> { + fn new(builder: Builder, config: &'a Table) -> Self { + BuilderWithConfig { + builder, + config, + used_keys: HashSet::new(), } + } - fn get_builder(self) -> Builder { - for key in self.config.keys() { - if !self.used_keys.contains(key.as_str()) { - panic!(format!("Unknown key: {}", key)); - } - } - self.builder + fn handle_list<F>(self, key: &'static str, func: F) -> BuilderWithConfig<'a> + where + F: FnOnce(Builder, slice::Iter<'a, toml::Value>) -> Builder, + { + let mut builder = self.builder; + let config = self.config; + let mut used_keys = self.used_keys; + if let Some(list) = config.get(key) { + used_keys.insert(key); + builder = func(builder, list.as_array().unwrap().as_slice().iter()); + } + BuilderWithConfig { + builder, + config, + used_keys, } } - - fn generate_structs() { - let builder = Builder::get_initial_builder() - .enable_cxx_namespaces() - .with_codegen_config( - CodegenConfig::TYPES | CodegenConfig::VARS | CodegenConfig::FUNCTIONS, - ); - let mut fixups = vec![]; - let builder = BuilderWithConfig::new(builder, CONFIG["structs"].as_table().unwrap()) - .handle_common(&mut fixups) - .handle_str_items("whitelist-functions", |b, item| b.whitelist_function(item)) - .handle_str_items("bitfield-enums", |b, item| b.bitfield_enum(item)) - .handle_str_items("rusty-enums", |b, item| b.rustified_enum(item)) - .handle_str_items("whitelist-vars", |b, item| b.whitelist_var(item)) - .handle_str_items("whitelist-types", |b, item| b.whitelist_type(item)) - .handle_str_items("opaque-types", |b, item| b.opaque_type(item)) - .handle_table_items("cbindgen-types", |b, item| { - let gecko = item["gecko"].as_str().unwrap(); - let servo = item["servo"].as_str().unwrap(); - b.blacklist_type(format!("mozilla::{}", gecko)) - .module_raw_line("root::mozilla", format!("pub use {} as {};", servo, gecko)) - }) - .handle_table_items("mapped-generic-types", |builder, item| { - let generic = item["generic"].as_bool().unwrap(); - let gecko = item["gecko"].as_str().unwrap(); - let servo = item["servo"].as_str().unwrap(); - let gecko_name = gecko.rsplit("::").next().unwrap(); - let gecko = gecko - .split("::") - .map(|s| format!("\\s*{}\\s*", s)) - .collect::<Vec<_>>() - .join("::"); - + fn handle_items<F>(self, key: &'static str, mut func: F) -> BuilderWithConfig<'a> + where + F: FnMut(Builder, &'a toml::Value) -> Builder, + { + self.handle_list(key, |b, iter| iter.fold(b, |b, item| func(b, item))) + } + fn handle_str_items<F>(self, key: &'static str, mut func: F) -> BuilderWithConfig<'a> + where + F: FnMut(Builder, &'a str) -> Builder, + { + self.handle_items(key, |b, item| func(b, item.as_str().unwrap())) + } + fn handle_table_items<F>(self, key: &'static str, mut func: F) -> BuilderWithConfig<'a> + where + F: FnMut(Builder, &'a Table) -> Builder, + { + self.handle_items(key, |b, item| func(b, item.as_table().unwrap())) + } + fn handle_common(self, fixups: &mut Vec<Fixup>) -> BuilderWithConfig<'a> { + self.handle_str_items("headers", |b, item| b.header(add_include(item))) + .handle_str_items("raw-lines", |b, item| b.raw_line(item)) + .handle_str_items("hide-types", |b, item| b.blacklist_type(item)) + .handle_table_items("fixups", |builder, item| { fixups.push(Fixup { - pat: format!("\\broot\\s*::\\s*{}\\b", gecko), - rep: format!("::gecko_bindings::structs::{}", gecko_name), + pat: item["pat"].as_str().unwrap().into(), + rep: item["rep"].as_str().unwrap().into(), }); - builder.blacklist_type(gecko).raw_line(format!( - "pub type {0}{2} = {1}{2};", - gecko_name, - servo, - if generic { "<T>" } else { "" } - )) + builder }) - .get_builder(); - write_binding_file(builder, STRUCTS_FILE, &fixups); } - fn setup_logging() -> bool { - struct BuildLogger { - file: Option<Mutex<fs::File>>, - filter: String, + fn get_builder(self) -> Builder { + for key in self.config.keys() { + if !self.used_keys.contains(key.as_str()) { + panic!(format!("Unknown key: {}", key)); + } } + self.builder + } +} - impl log::Log for BuildLogger { - fn enabled(&self, meta: &log::Metadata) -> bool { - self.file.is_some() && meta.target().contains(&self.filter) - } +fn generate_structs() { + let builder = Builder::get_initial_builder() + .enable_cxx_namespaces() + .with_codegen_config(CodegenConfig::TYPES | CodegenConfig::VARS | CodegenConfig::FUNCTIONS); + let mut fixups = vec![]; + let builder = BuilderWithConfig::new(builder, CONFIG["structs"].as_table().unwrap()) + .handle_common(&mut fixups) + .handle_str_items("whitelist-functions", |b, item| b.whitelist_function(item)) + .handle_str_items("bitfield-enums", |b, item| b.bitfield_enum(item)) + .handle_str_items("rusty-enums", |b, item| b.rustified_enum(item)) + .handle_str_items("whitelist-vars", |b, item| b.whitelist_var(item)) + .handle_str_items("whitelist-types", |b, item| b.whitelist_type(item)) + .handle_str_items("opaque-types", |b, item| b.opaque_type(item)) + .handle_table_items("cbindgen-types", |b, item| { + let gecko = item["gecko"].as_str().unwrap(); + let servo = item["servo"].as_str().unwrap(); + b.blacklist_type(format!("mozilla::{}", gecko)) + .module_raw_line("root::mozilla", format!("pub use {} as {};", servo, gecko)) + }) + .handle_table_items("mapped-generic-types", |builder, item| { + let generic = item["generic"].as_bool().unwrap(); + let gecko = item["gecko"].as_str().unwrap(); + let servo = item["servo"].as_str().unwrap(); + let gecko_name = gecko.rsplit("::").next().unwrap(); + let gecko = gecko + .split("::") + .map(|s| format!("\\s*{}\\s*", s)) + .collect::<Vec<_>>() + .join("::"); + + fixups.push(Fixup { + pat: format!("\\broot\\s*::\\s*{}\\b", gecko), + rep: format!("::gecko_bindings::structs::{}", gecko_name), + }); + builder.blacklist_type(gecko).raw_line(format!( + "pub type {0}{2} = {1}{2};", + gecko_name, + servo, + if generic { "<T>" } else { "" } + )) + }) + .get_builder(); + write_binding_file(builder, STRUCTS_FILE, &fixups); +} - fn log(&self, record: &log::Record) { - if !self.enabled(record.metadata()) { - return; - } +fn setup_logging() -> bool { + struct BuildLogger { + file: Option<Mutex<fs::File>>, + filter: String, + } - let mut file = self.file.as_ref().unwrap().lock().unwrap(); - let _ = writeln!( - file, - "{} - {} - {} @ {}:{}", - record.level(), - record.target(), - record.args(), - record.file().unwrap_or("<unknown>"), - record.line().unwrap_or(0) - ); - } + impl log::Log for BuildLogger { + fn enabled(&self, meta: &log::Metadata) -> bool { + self.file.is_some() && meta.target().contains(&self.filter) + } - fn flush(&self) { - if let Some(ref file) = self.file { - file.lock().unwrap().flush().unwrap(); - } + fn log(&self, record: &log::Record) { + if !self.enabled(record.metadata()) { + return; } - } - if let Some(path) = env::var_os("STYLO_BUILD_LOG") { - log::set_max_level(log::LevelFilter::Debug); - log::set_boxed_logger(Box::new(BuildLogger { - file: fs::File::create(path).ok().map(Mutex::new), - filter: env::var("STYLO_BUILD_FILTER") - .ok() - .unwrap_or_else(|| "bindgen".to_owned()), - })) - .expect("Failed to set logger."); - - true - } else { - false + let mut file = self.file.as_ref().unwrap().lock().unwrap(); + let _ = writeln!( + file, + "{} - {} - {} @ {}:{}", + record.level(), + record.target(), + record.args(), + record.file().unwrap_or("<unknown>"), + record.line().unwrap_or(0) + ); } - } - fn generate_atoms() { - let script = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()) - .join("gecko") - .join("regen_atoms.py"); - println!("cargo:rerun-if-changed={}", script.display()); - let status = Command::new(&*PYTHON) - .arg(&script) - .arg(DISTDIR_PATH.as_os_str()) - .arg(OUTDIR_PATH.as_os_str()) - .status() - .unwrap(); - if !status.success() { - exit(1); + fn flush(&self) { + if let Some(ref file) = self.file { + file.lock().unwrap().flush().unwrap(); + } } } - pub fn generate() { - setup_logging(); - generate_structs(); - generate_atoms(); - - for path in ADDED_PATHS.lock().unwrap().iter() { - println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); - } + if let Some(path) = env::var_os("STYLO_BUILD_LOG") { + log::set_max_level(log::LevelFilter::Debug); + log::set_boxed_logger(Box::new(BuildLogger { + file: fs::File::create(path).ok().map(Mutex::new), + filter: env::var("STYLO_BUILD_FILTER") + .ok() + .unwrap_or_else(|| "bindgen".to_owned()), + })) + .expect("Failed to set logger."); + + true + } else { + false } } -#[cfg(not(feature = "bindgen"))] -mod bindings { - use super::common::*; - use std::path::{Path, PathBuf}; - use std::{env, fs, io}; - - /// Copy contents of one directory into another. - /// It currently only does a shallow copy. - fn copy_dir<P, Q, F>(from: P, to: Q, callback: F) -> io::Result<()> - where - P: AsRef<Path>, - Q: AsRef<Path>, - F: Fn(&Path), - { - let to = to.as_ref(); - for entry in from.as_ref().read_dir()? { - let entry = entry?; - let path = entry.path(); - callback(&path); - fs::copy(&path, to.join(entry.file_name()))?; - } - Ok(()) - } - - pub fn generate() { - let dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("gecko/generated"); - println!("cargo:rerun-if-changed={}", dir.display()); - copy_dir(&dir, &*OUTDIR_PATH, |path| { - println!("cargo:rerun-if-changed={}", path.display()); - }) - .expect("Fail to copy generated files to out dir"); +fn generate_atoms() { + let script = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()) + .join("gecko") + .join("regen_atoms.py"); + println!("cargo:rerun-if-changed={}", script.display()); + let status = Command::new(&*PYTHON) + .arg(&script) + .arg(DISTDIR_PATH.as_os_str()) + .arg(OUTDIR_PATH.as_os_str()) + .status() + .unwrap(); + if !status.success() { + exit(1); } } pub fn generate() { - use self::common::*; - use std::fs; println!("cargo:rerun-if-changed=build_gecko.rs"); fs::create_dir_all(&*OUTDIR_PATH).unwrap(); - bindings::generate(); + setup_logging(); + generate_structs(); + generate_atoms(); + + for path in ADDED_PATHS.lock().unwrap().iter() { + println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); + } } diff --git a/components/style/context.rs b/components/style/context.rs index 6d93b973b22..0c7d9744117 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -31,8 +31,8 @@ use crate::traversal_flags::TraversalFlags; use app_units::Au; #[cfg(feature = "servo")] use crossbeam_channel::Sender; -use euclid::Size2D; -use euclid::TypedScale; +use euclid::default::Size2D; +use euclid::Scale; use fxhash::FxHashMap; #[cfg(feature = "servo")] use parking_lot::RwLock; @@ -195,7 +195,7 @@ impl<'a> SharedStyleContext<'a> { } /// The device pixel ratio - pub fn device_pixel_ratio(&self) -> TypedScale<f32, CSSPixel, DevicePixel> { + pub fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel> { self.stylist.device().device_pixel_ratio() } diff --git a/components/style/gecko/media_features.rs b/components/style/gecko/media_features.rs index 4b94571c8ef..a80c486a6c3 100644 --- a/components/style/gecko/media_features.rs +++ b/components/style/gecko/media_features.rs @@ -14,7 +14,7 @@ use crate::values::computed::CSSPixelLength; use crate::values::computed::Resolution; use crate::Atom; use app_units::Au; -use euclid::Size2D; +use euclid::default::Size2D; fn viewport_size(device: &Device) -> Size2D<Au> { if let Some(pc) = device.pres_context() { diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 459d58121ac..556470569db 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -16,8 +16,8 @@ use crate::values::{CustomIdent, KeyframesName}; use app_units::Au; use app_units::AU_PER_PX; use cssparser::RGBA; -use euclid::Size2D; -use euclid::TypedScale; +use euclid::default::Size2D; +use euclid::Scale; use servo_arc::Arc; use std::fmt; use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering}; @@ -247,20 +247,20 @@ impl Device { } /// Returns the device pixel ratio. - pub fn device_pixel_ratio(&self) -> TypedScale<f32, CSSPixel, DevicePixel> { + pub fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel> { let pc = match self.pres_context() { Some(pc) => pc, - None => return TypedScale::new(1.), + None => return Scale::new(1.), }; let override_dppx = pc.mOverrideDPPX; if override_dppx > 0.0 { - return TypedScale::new(override_dppx); + return Scale::new(override_dppx); } let au_per_dpx = pc.mCurAppUnitsPerDevPixel as f32; let au_per_px = AU_PER_PX as f32; - TypedScale::new(au_per_px / au_per_dpx) + Scale::new(au_per_px / au_per_dpx) } /// Returns whether document colors are enabled. diff --git a/components/style/gecko_bindings/sugar/refptr.rs b/components/style/gecko_bindings/sugar/refptr.rs index a141aef4e8b..e27b4a28c40 100644 --- a/components/style/gecko_bindings/sugar/refptr.rs +++ b/components/style/gecko_bindings/sugar/refptr.rs @@ -304,6 +304,11 @@ impl_threadsafe_refcount!( bindings::Gecko_ReleaseURLExtraDataArbitraryThread ); impl_threadsafe_refcount!( + structs::nsIReferrerInfo, + bindings::Gecko_AddRefnsIReferrerInfoArbitraryThread, + bindings::Gecko_ReleasensIReferrerInfoArbitraryThread +); +impl_threadsafe_refcount!( structs::nsIURI, bindings::Gecko_AddRefnsIURIArbitraryThread, bindings::Gecko_ReleasensIURIArbitraryThread diff --git a/components/style/logical_geometry.rs b/components/style/logical_geometry.rs index dc6bae55461..3817c12dcf0 100644 --- a/components/style/logical_geometry.rs +++ b/components/style/logical_geometry.rs @@ -5,8 +5,8 @@ //! Geometry in flow-relative space. use crate::properties::style_structs; +use euclid::default::{Point2D, Rect, SideOffsets2D, Size2D}; use euclid::num::Zero; -use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; use std::cmp::{max, min}; use std::fmt::{self, Debug, Error, Formatter}; use std::ops::{Add, Sub}; diff --git a/components/style/matching.rs b/components/style/matching.rs index dfc5685098c..958ec00f1d9 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -240,16 +240,31 @@ trait PrivateMatchMethods: TElement { let new_box_style = new_style.get_box(); let new_style_specifies_animations = new_box_style.specifies_animations(); - let old_style = match old_style { - Some(old) => old, - None => return new_style_specifies_animations, - }; - let has_animations = self.has_css_animations(); if !new_style_specifies_animations && !has_animations { return false; } + let old_style = match old_style { + Some(old) => old, + // If we have no old style but have animations, we may be a + // pseudo-element which was re-created without style changes. + // + // This can happen when we reframe the pseudo-element without + // restyling it (due to content insertion on a flex container or + // such, for example). See bug 1564366. + // + // FIXME(emilio): The really right fix for this is keeping the + // pseudo-element itself around on reframes, but that's a bit + // harder. If we do that we can probably remove quite a lot of the + // EffectSet complexity though, since right now it's stored on the + // parent element for pseudo-elements given we need to keep it + // around... + None => { + return new_style_specifies_animations || new_style.is_pseudo_style(); + }, + }; + let old_box_style = old_style.get_box(); let keyframes_could_have_changed = context diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs index 1e362fb1bc4..3d64dde7e2c 100644 --- a/components/style/properties/cascade.rs +++ b/components/style/properties/cascade.rs @@ -153,7 +153,7 @@ where // longhands are only allowed if they have our // restriction flag set. if let PropertyDeclarationId::Longhand(id) = declaration.id() { - if !id.flags().contains(restriction) { + if !id.flags().contains(restriction) && cascade_level.origin() != Origin::UserAgent { return None; } } diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 0c9321d004c..dd501fb8fc2 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -175,6 +175,7 @@ class Longhand(object): predefined_type=None, servo_pref=None, gecko_pref=None, enabled_in="content", need_index=False, gecko_ffi_name=None, + has_effect_on_gecko_scrollbars=None, allowed_in_keyframe_block=True, cast_type='u8', logical=False, logical_group=None, alias=None, extra_prefixes=None, boxed=False, flags=None, allowed_in_page_rule=False, allow_quirks="No", @@ -192,6 +193,14 @@ class Longhand(object): self.style_struct = style_struct self.servo_pref = servo_pref self.gecko_pref = gecko_pref + self.has_effect_on_gecko_scrollbars = has_effect_on_gecko_scrollbars + assert ( + has_effect_on_gecko_scrollbars in [None, False, True] and + not style_struct.inherited or + (gecko_pref is None) == (has_effect_on_gecko_scrollbars is None)), ( + "Property " + name + ": has_effect_on_gecko_scrollbars must be " + + "specified, and must have a value of True or False, iff a " + + "property is inherited and is behind a Gecko pref") # For enabled_in, the setup is as follows: # It needs to be one of the four values: ["", "ua", "chrome", "content"] # * "chrome" implies "ua", and implies that they're explicitly @@ -208,6 +217,7 @@ class Longhand(object): self.logical_group = logical_group if self.logical: assert logical_group, "Property " + name + " must have a logical group" + self.alias = parse_property_aliases(alias) self.extra_prefixes = parse_property_aliases(extra_prefixes) self.boxed = arg_to_bool(boxed) @@ -532,8 +542,10 @@ class PropertiesData(object): self.current_style_struct = None self.longhands = [] self.longhands_by_name = {} + self.longhands_by_logical_group = {} self.longhand_aliases = [] self.shorthands = [] + self.shorthands_by_name = {} self.shorthand_aliases = [] def new_style_struct(self, *args, **kwargs): @@ -563,6 +575,8 @@ class PropertiesData(object): self.current_style_struct.longhands.append(longhand) self.longhands.append(longhand) self.longhands_by_name[name] = longhand + if longhand.logical_group: + self.longhands_by_logical_group.setdefault(longhand.logical_group, []).append(longhand) return longhand @@ -577,6 +591,7 @@ class PropertiesData(object): shorthand.alias = list(map(lambda xp: Alias(xp[0], shorthand, xp[1]), shorthand.alias)) self.shorthand_aliases += shorthand.alias self.shorthands.append(shorthand) + self.shorthands_by_name[name] = shorthand return shorthand def shorthands_except_all(self): @@ -584,3 +599,172 @@ class PropertiesData(object): def all_aliases(self): return self.longhand_aliases + self.shorthand_aliases + + +def _add_logical_props(data, props): + groups = set() + for prop in props: + if prop not in data.longhands_by_name: + assert data.product == "servo" + continue + prop = data.longhands_by_name[prop] + if prop.logical_group: + groups.add(prop.logical_group) + for group in groups: + for prop in data.longhands_by_logical_group[group]: + props.add(prop.name) + + +# These are probably Gecko bugs and should be supported per spec. +def _remove_common_first_line_and_first_letter_properties(props, product): + if product == "gecko": + props.remove("-moz-tab-size") + props.remove("hyphens") + props.remove("line-break") + props.remove("text-align-last") + props.remove("text-emphasis-position") + props.remove("text-emphasis-style") + props.remove("text-emphasis-color") + props.remove("text-decoration-skip-ink") + props.remove("text-decoration-thickness") + props.remove("text-underline-offset") + + props.remove("overflow-wrap") + props.remove("text-align") + props.remove("text-justify") + props.remove("white-space") + props.remove("word-break") + props.remove("text-indent") + + +class PropertyRestrictions: + @staticmethod + def logical_group(data, group): + return map(lambda p: p.name, data.longhands_by_logical_group[group]) + + @staticmethod + def shorthand(data, shorthand): + return map(lambda p: p.name, data.shorthands_by_name[shorthand].sub_properties) + + @staticmethod + def spec(data, spec_path): + return map(lambda p: p.name, filter(lambda p: spec_path in p.spec, data.longhands)) + + # https://drafts.csswg.org/css-pseudo/#first-letter-styling + @staticmethod + def first_letter(data): + props = set([ + "color", + "float", + "initial-letter", + + # Kinda like css-fonts? + "-moz-osx-font-smoothing", + + # Kinda like css-text? + "-webkit-text-stroke-width", + "-webkit-text-fill-color", + "-webkit-text-stroke-color", + "vertical-align", + "line-height", + + # Kinda like css-backgrounds? + "background-blend-mode", + ] + PropertyRestrictions.shorthand(data, "padding") + + PropertyRestrictions.shorthand(data, "margin") + + PropertyRestrictions.spec(data, "css-fonts") + + PropertyRestrictions.spec(data, "css-backgrounds") + + PropertyRestrictions.spec(data, "css-text") + + PropertyRestrictions.spec(data, "css-shapes") + + PropertyRestrictions.spec(data, "css-text-decor")) + + _add_logical_props(data, props) + + _remove_common_first_line_and_first_letter_properties(props, data.product) + return props + + # https://drafts.csswg.org/css-pseudo/#first-line-styling + @staticmethod + def first_line(data): + props = set([ + # Per spec. + "color", + + # Kinda like css-fonts? + "-moz-osx-font-smoothing", + + # Kinda like css-text? + "-webkit-text-stroke-width", + "-webkit-text-fill-color", + "-webkit-text-stroke-color", + "vertical-align", + "line-height", + + # Kinda like css-backgrounds? + "background-blend-mode", + ] + PropertyRestrictions.spec(data, "css-fonts") + + PropertyRestrictions.spec(data, "css-backgrounds") + + PropertyRestrictions.spec(data, "css-text") + + PropertyRestrictions.spec(data, "css-text-decor")) + + # These are probably Gecko bugs and should be supported per spec. + for prop in PropertyRestrictions.shorthand(data, "border"): + props.remove(prop) + for prop in PropertyRestrictions.shorthand(data, "border-radius"): + props.remove(prop) + props.remove("box-shadow") + + _remove_common_first_line_and_first_letter_properties(props, data.product) + return props + + # https://drafts.csswg.org/css-pseudo/#placeholder + # + # The spec says that placeholder and first-line have the same restrictions, + # but that's not true in Gecko and we also allow a handful other properties + # for ::placeholder. + @staticmethod + def placeholder(data): + props = PropertyRestrictions.first_line(data) + props.add("opacity") + props.add("white-space") + props.add("text-overflow") + props.add("text-align") + props.add("text-justify") + return props + + # https://drafts.csswg.org/css-pseudo/#marker-pseudo + @staticmethod + def marker(data): + return set([ + "color", + "text-combine-upright", + "unicode-bidi", + "direction", + "content", + "-moz-osx-font-smoothing", + ] + PropertyRestrictions.spec(data, "css-fonts")) + + # https://www.w3.org/TR/webvtt1/#the-cue-pseudo-element + @staticmethod + def cue(data): + return set([ + "color", + "opacity", + "visibility", + "text-shadow", + "white-space", + "text-combine-upright", + "ruby-position", + + # XXX Should these really apply to cue? + "font-synthesis", + "-moz-osx-font-smoothing", + + # FIXME(emilio): background-blend-mode should be part of the + # background shorthand, and get reset, per + # https://drafts.fxtf.org/compositing/#background-blend-mode + "background-blend-mode", + ] + PropertyRestrictions.shorthand(data, "text-decoration") + + PropertyRestrictions.shorthand(data, "background") + + PropertyRestrictions.shorthand(data, "outline") + + PropertyRestrictions.shorthand(data, "font")) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index ec29b82f2df..afef80aa800 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -118,8 +118,13 @@ impl ComputedValues { } #[inline] + pub fn is_pseudo_style(&self) -> bool { + self.0.mPseudoType != PseudoStyleType::NotPseudo + } + + #[inline] pub fn pseudo(&self) -> Option<PseudoElement> { - if self.0.mPseudoType == PseudoStyleType::NotPseudo { + if !self.is_pseudo_style() { return None; } PseudoElement::from_pseudo_type(self.0.mPseudoType) diff --git a/components/style/properties/longhands/background.mako.rs b/components/style/properties/longhands/background.mako.rs index cc416bc3af0..7422c4b474a 100644 --- a/components/style/properties/longhands/background.mako.rs +++ b/components/style/properties/longhands/background.mako.rs @@ -15,8 +15,7 @@ ${helpers.predefined_type( animation_value_type="AnimatedColor", ignored_when_colors_disabled=True, allow_quirks="Yes", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER \ - CAN_ANIMATE_ON_COMPOSITOR", + flags="CAN_ANIMATE_ON_COMPOSITOR", )} ${helpers.predefined_type( @@ -28,7 +27,6 @@ ${helpers.predefined_type( vector="True", animation_value_type="discrete", ignored_when_colors_disabled="True", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", )} % for (axis, direction, initial) in [("x", "Horizontal", "left"), ("y", "Vertical", "top")]: @@ -41,7 +39,6 @@ ${helpers.predefined_type( animation_value_type="ComputedValue", vector=True, vector_animation_type="repeatable_list", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", )} % endfor @@ -53,7 +50,6 @@ ${helpers.predefined_type( animation_value_type="discrete", vector=True, spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", )} ${helpers.single_keyword( @@ -63,7 +59,6 @@ ${helpers.single_keyword( gecko_enum_prefix="StyleImageLayerAttachment", spec="https://drafts.csswg.org/css-backgrounds/#the-background-attachment", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", )} ${helpers.single_keyword( @@ -75,7 +70,6 @@ ${helpers.single_keyword( gecko_inexhaustive=True, spec="https://drafts.csswg.org/css-backgrounds/#the-background-clip", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", )} ${helpers.single_keyword( @@ -86,7 +80,6 @@ ${helpers.single_keyword( gecko_inexhaustive=True, spec="https://drafts.csswg.org/css-backgrounds/#the-background-origin", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER" )} ${helpers.predefined_type( @@ -98,7 +91,6 @@ ${helpers.predefined_type( vector=True, vector_animation_type="repeatable_list", animation_value_type="BackgroundSizeList", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", extra_prefixes="webkit")} // https://drafts.fxtf.org/compositing/#background-blend-mode @@ -110,5 +102,4 @@ ${helpers.single_keyword( gecko_constant_prefix="NS_STYLE_BLEND", vector=True, products="gecko", animation_value_type="discrete", spec="https://drafts.fxtf.org/compositing/#background-blend-mode", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", )} diff --git a/components/style/properties/longhands/border.mako.rs b/components/style/properties/longhands/border.mako.rs index 66544a44858..87de168d534 100644 --- a/components/style/properties/longhands/border.mako.rs +++ b/components/style/properties/longhands/border.mako.rs @@ -29,7 +29,6 @@ logical=is_logical, logical_group="border-color", allow_quirks="No" if is_logical else "Yes", - flags="APPLIES_TO_FIRST_LETTER", ignored_when_colors_disabled=True, )} @@ -38,7 +37,6 @@ "specified::BorderStyle::None", alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-style"), spec=maybe_logical_spec(side, "style"), - flags="APPLIES_TO_FIRST_LETTER", animation_value_type="discrete" if not is_logical else "none", logical=is_logical, logical_group="border-style", @@ -55,7 +53,7 @@ animation_value_type="NonNegativeLength", logical=is_logical, logical_group="border-width", - flags="APPLIES_TO_FIRST_LETTER GETCS_NEEDS_LAYOUT_FLUSH", + flags="GETCS_NEEDS_LAYOUT_FLUSH", allow_quirks="No" if is_logical else "Yes", servo_restyle_damage="reflow rebuild_and_reflow_inline" )} @@ -78,7 +76,6 @@ extra_prefixes=prefixes, spec=maybe_logical_spec(corner, "radius"), boxed=True, - flags="APPLIES_TO_FIRST_LETTER", animation_value_type="BorderCornerRadius", logical_group="border-radius", logical=is_logical, @@ -112,7 +109,6 @@ ${helpers.predefined_type( spec="https://drafts.csswg.org/css-backgrounds/#the-background-image", vector=False, animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER", boxed=product == "servo", ignored_when_colors_disabled=True )} @@ -124,7 +120,6 @@ ${helpers.predefined_type( initial_specified_value="generics::rect::Rect::all(specified::NonNegativeLengthOrNumber::zero())", spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset", animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER", boxed=True, )} @@ -135,7 +130,6 @@ ${helpers.predefined_type( initial_specified_value="specified::BorderImageRepeat::stretch()", animation_value_type="discrete", spec="https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat", - flags="APPLIES_TO_FIRST_LETTER", )} ${helpers.predefined_type( @@ -145,7 +139,6 @@ ${helpers.predefined_type( initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())", spec="https://drafts.csswg.org/css-backgrounds/#border-image-width", animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER", boxed=True, )} @@ -156,6 +149,5 @@ ${helpers.predefined_type( initial_specified_value="specified::BorderImageSlice::hundred_percent()", spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice", animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER", boxed=True, )} diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs index 0a15047038a..133960d0379 100644 --- a/components/style/properties/longhands/box.mako.rs +++ b/components/style/properties/longhands/box.mako.rs @@ -9,15 +9,12 @@ inherited=False, gecko_name="Display") %> -// We allow "display" to apply to placeholders because we need to make the -// placeholder pseudo-element an inline-block in the UA stylesheet in Gecko. ${helpers.predefined_type( "display", "Display", "computed::Display::inline()", 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" @@ -62,7 +59,6 @@ ${helpers.predefined_type( spec="https://drafts.csswg.org/css-box/#propdef-float", animation_value_type="discrete", needs_context=False, - flags="APPLIES_TO_FIRST_LETTER", servo_restyle_damage="rebuild_and_reflow", gecko_ffi_name="mFloat", )} @@ -83,7 +79,6 @@ ${helpers.predefined_type( "VerticalAlign", "computed::VerticalAlign::baseline()", animation_value_type="ComputedValue", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align", servo_restyle_damage = "reflow", )} @@ -103,7 +98,6 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box", products="gecko", enabled_in="ua", needs_context=False, - flags="APPLIES_TO_PLACEHOLDER", gecko_pref="layout.css.overflow-clip-box.enabled", animation_value_type="discrete", spec="Internal, may be standardized in the future: \ @@ -111,9 +105,6 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box", )} % endfor -// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`. -// -// We allow it to apply to placeholders for UA sheets, which set it !important. % for (axis, logical) in ALL_AXES: <% full_name = "overflow-{}".format(axis) %> ${helpers.predefined_type( @@ -123,7 +114,6 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box", logical_group="overflow", logical=logical, animation_value_type="discrete", - flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-overflow-3/#propdef-{}".format(full_name), needs_context=False, servo_restyle_damage = "reflow", @@ -477,10 +467,6 @@ ${helpers.predefined_type( // CSS Basic User Interface Module Level 3 // http://dev.w3.org/csswg/css-ui -// -// This is APPLIES_TO_PLACEHOLDER so we can override, in the UA sheet, the -// 'resize' property we'd inherit from textarea otherwise. Basically, just -// makes the UA rules easier to write. ${helpers.predefined_type( "resize", "Resize", @@ -489,7 +475,6 @@ ${helpers.predefined_type( animation_value_type="discrete", needs_context=False, gecko_ffi_name="mResize", - flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-ui/#propdef-resize", )} @@ -616,11 +601,12 @@ ${helpers.predefined_type( spec="https://drafts.csswg.org/css-will-change/#will-change", )} +// The spec issue for the parse_method: https://github.com/w3c/csswg-drafts/issues/4102. ${helpers.predefined_type( "shape-image-threshold", "Opacity", "0.0", + parse_method="parse_number", products="gecko", animation_value_type="ComputedValue", - flags="APPLIES_TO_FIRST_LETTER", spec="https://drafts.csswg.org/css-shapes/#shape-image-threshold-property", )} @@ -630,7 +616,6 @@ ${helpers.predefined_type( "computed::NonNegativeLengthPercentage::zero()", products="gecko", animation_value_type="NonNegativeLengthPercentage", - flags="APPLIES_TO_FIRST_LETTER", spec="https://drafts.csswg.org/css-shapes/#shape-margin-property", )} @@ -640,7 +625,6 @@ ${helpers.predefined_type( "generics::basic_shape::ShapeSource::None", products="gecko", animation_value_type="basic_shape::FloatAreaShape", - flags="APPLIES_TO_FIRST_LETTER", spec="https://drafts.csswg.org/css-shapes/#shape-outside-property", )} diff --git a/components/style/properties/longhands/counters.mako.rs b/components/style/properties/longhands/counters.mako.rs index fce23f3a1ea..f8971315603 100644 --- a/components/style/properties/longhands/counters.mako.rs +++ b/components/style/properties/longhands/counters.mako.rs @@ -13,7 +13,6 @@ ${helpers.predefined_type( initial_specified_value="specified::Content::normal()", animation_value_type="discrete", spec="https://drafts.csswg.org/css-content/#propdef-content", - flags="APPLIES_TO_MARKER", servo_restyle_damage="rebuild_and_reflow", )} diff --git a/components/style/properties/longhands/effects.mako.rs b/components/style/properties/longhands/effects.mako.rs index ac2b92cbe52..01b5abfd41f 100644 --- a/components/style/properties/longhands/effects.mako.rs +++ b/components/style/properties/longhands/effects.mako.rs @@ -12,9 +12,8 @@ ${helpers.predefined_type( "Opacity", "1.0", animation_value_type="ComputedValue", - flags="APPLIES_TO_CUE CREATES_STACKING_CONTEXT APPLIES_TO_PLACEHOLDER \ - CAN_ANIMATE_ON_COMPOSITOR", - spec="https://drafts.csswg.org/css-color/#opacity", + flags="CREATES_STACKING_CONTEXT CAN_ANIMATE_ON_COMPOSITOR", + spec="https://drafts.csswg.org/css-color/#transparency", servo_restyle_damage = "reflow_out_of_flow", )} @@ -28,7 +27,6 @@ ${helpers.predefined_type( vector_animation_type="with_zero", extra_prefixes="webkit", ignored_when_colors_disabled=True, - flags="APPLIES_TO_FIRST_LETTER", spec="https://drafts.csswg.org/css-backgrounds/#box-shadow", )} diff --git a/components/style/properties/longhands/font.mako.rs b/components/style/properties/longhands/font.mako.rs index 02a4fd03c7d..18b3328a536 100644 --- a/components/style/properties/longhands/font.mako.rs +++ b/components/style/properties/longhands/font.mako.rs @@ -12,7 +12,6 @@ ${helpers.predefined_type( "FontFamily", initial_value="computed::FontFamily::serif()", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-family", servo_restyle_damage="rebuild_and_reflow", )} @@ -23,7 +22,6 @@ ${helpers.predefined_type( initial_value="computed::FontStyle::normal()", initial_specified_value="specified::FontStyle::normal()", animation_value_type="FontStyle", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-style", servo_restyle_damage="rebuild_and_reflow", )} @@ -42,7 +40,6 @@ ${helpers.single_keyword_system( gecko_ffi_name="mFont.variantCaps", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps", custom_consts=font_variant_caps_custom_consts, - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", animation_value_type="discrete", servo_restyle_damage="rebuild_and_reflow", )} @@ -53,7 +50,6 @@ ${helpers.predefined_type( initial_value="computed::FontWeight::normal()", initial_specified_value="specified::FontWeight::normal()", animation_value_type="Number", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight", servo_restyle_damage="rebuild_and_reflow", )} @@ -65,7 +61,6 @@ ${helpers.predefined_type( initial_specified_value="specified::FontSize::medium()", animation_value_type="NonNegativeLength", allow_quirks="Yes", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-size", servo_restyle_damage="rebuild_and_reflow", )} @@ -77,7 +72,6 @@ ${helpers.predefined_type( initial_value="computed::FontSizeAdjust::none()", initial_specified_value="specified::FontSizeAdjust::none()", animation_value_type="ComputedValue", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-size-adjust", )} @@ -87,7 +81,6 @@ ${helpers.predefined_type( products="gecko", initial_value="specified::FontSynthesis::get_initial_value()", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis", )} @@ -97,7 +90,6 @@ ${helpers.predefined_type( initial_value="computed::FontStretch::hundred()", initial_specified_value="specified::FontStretch::normal()", animation_value_type="Percentage", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-stretch", servo_restyle_damage="rebuild_and_reflow", )} @@ -109,7 +101,6 @@ ${helpers.single_keyword_system( gecko_ffi_name="mFont.kerning", gecko_constant_prefix="NS_FONT_KERNING", spec="https://drafts.csswg.org/css-fonts/#propdef-font-kerning", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", animation_value_type="discrete", )} @@ -120,7 +111,6 @@ ${helpers.predefined_type( initial_value="computed::FontVariantAlternates::get_initial_value()", initial_specified_value="specified::FontVariantAlternates::get_initial_specified_value()", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-alternates", )} @@ -131,7 +121,6 @@ ${helpers.predefined_type( initial_value="computed::FontVariantEastAsian::empty()", initial_specified_value="specified::FontVariantEastAsian::empty()", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian", )} @@ -142,7 +131,6 @@ ${helpers.predefined_type( initial_value="computed::FontVariantLigatures::empty()", initial_specified_value="specified::FontVariantLigatures::empty()", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures", )} @@ -153,7 +141,6 @@ ${helpers.predefined_type( initial_value="computed::FontVariantNumeric::empty()", initial_specified_value="specified::FontVariantNumeric::empty()", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric", )} @@ -164,7 +151,6 @@ ${helpers.single_keyword_system( gecko_ffi_name="mFont.variantPosition", gecko_constant_prefix="NS_FONT_VARIANT_POSITION", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", animation_value_type="discrete", )} @@ -176,27 +162,19 @@ ${helpers.predefined_type( initial_specified_value="specified::FontFeatureSettings::normal()", extra_prefixes="moz:layout.css.prefixes.font-features", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings", )} -<% -# This spec link is too long to fit elsewhere -variation_spec = """\ -https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-the-font-variation-settings-property\ -""" -%> - ${helpers.predefined_type( "font-variation-settings", "FontVariationSettings", products="gecko", gecko_pref="layout.css.font-variations.enabled", + has_effect_on_gecko_scrollbars=False, initial_value="computed::FontVariationSettings::normal()", initial_specified_value="specified::FontVariationSettings::normal()", animation_value_type="ComputedValue", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", - spec="${variation_spec}", + spec="https://drafts.csswg.org/css-fonts-4/#propdef-font-variation-settings" )} ${helpers.predefined_type( @@ -207,7 +185,6 @@ ${helpers.predefined_type( initial_specified_value="specified::FontLanguageOverride::normal()", animation_value_type="discrete", extra_prefixes="moz:layout.css.prefixes.font-features", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-language-override", )} @@ -216,10 +193,10 @@ ${helpers.single_keyword_system( "auto none", products="gecko", gecko_pref="layout.css.font-variations.enabled", + has_effect_on_gecko_scrollbars=False, gecko_ffi_name="mFont.opticalSizing", gecko_constant_prefix="NS_FONT_OPTICAL_SIZING", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", spec="https://www.w3.org/TR/css-fonts-4/#font-optical-sizing-def", )} @@ -513,9 +490,9 @@ ${helpers.single_keyword( gecko_constant_prefix="NS_FONT_SMOOTHING", gecko_ffi_name="mFont.smoothing", gecko_pref="layout.css.osx-font-smoothing.enabled", + has_effect_on_gecko_scrollbars=False, products="gecko", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth)", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", animation_value_type="discrete", )} diff --git a/components/style/properties/longhands/inherited_box.mako.rs b/components/style/properties/longhands/inherited_box.mako.rs index 94ed265defa..0e3799f6c46 100644 --- a/components/style/properties/longhands/inherited_box.mako.rs +++ b/components/style/properties/longhands/inherited_box.mako.rs @@ -14,7 +14,6 @@ ${helpers.single_keyword( gecko_ffi_name="mVisible", animation_value_type="ComputedValue", spec="https://drafts.csswg.org/css-box/#propdef-visibility", - flags="APPLIES_TO_CUE", )} // CSS Writing Modes Level 3 @@ -38,7 +37,6 @@ ${helpers.single_keyword( animation_value_type="none", spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction", needs_conversion=True, - flags="APPLIES_TO_MARKER", servo_restyle_damage="rebuild_and_reflow", )} diff --git a/components/style/properties/longhands/inherited_svg.mako.rs b/components/style/properties/longhands/inherited_svg.mako.rs index c3e16ee475f..5becde6d258 100644 --- a/components/style/properties/longhands/inherited_svg.mako.rs +++ b/components/style/properties/longhands/inherited_svg.mako.rs @@ -11,6 +11,15 @@ // Section 10 - Text ${helpers.single_keyword( + "dominant-baseline", + """auto ideographic alphabetic hanging mathematical central middle + text-after-edge text-before-edge""", + products="gecko", + animation_value_type="discrete", + spec="https://www.w3.org/TR/css-inline-3/#propdef-dominant-baseline", +)} + +${helpers.single_keyword( "text-anchor", "start middle end", products="gecko", @@ -52,7 +61,7 @@ ${helpers.predefined_type( "Default::default()", products="gecko", animation_value_type="ComputedValue", - spec="https://www.w3.org/TR/SVG11/painting.html#FillOpacityProperty", + spec="https://svgwg.org/svg2-draft/painting.html#FillOpacity", )} ${helpers.predefined_type( @@ -123,7 +132,7 @@ ${helpers.predefined_type( "Default::default()", products="gecko", animation_value_type="ComputedValue", - spec="https://www.w3.org/TR/SVG11/painting.html#StrokeOpacityProperty", + spec="https://svgwg.org/svg2-draft/painting.html#StrokeOpacity", )} ${helpers.predefined_type( diff --git a/components/style/properties/longhands/inherited_text.mako.rs b/components/style/properties/longhands/inherited_text.mako.rs index c81e8392f94..07f2bb3f9c2 100644 --- a/components/style/properties/longhands/inherited_text.mako.rs +++ b/components/style/properties/longhands/inherited_text.mako.rs @@ -11,7 +11,6 @@ ${helpers.predefined_type( "ColorPropertyValue", "::cssparser::RGBA::new(0, 0, 0, 255)", animation_value_type="AnimatedRGBA", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER APPLIES_TO_MARKER", ignored_when_colors_disabled="True", spec="https://drafts.csswg.org/css-color/#color", )} @@ -21,8 +20,7 @@ ${helpers.predefined_type( "LineHeight", "computed::LineHeight::normal()", animation_value_type="LineHeight", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE \ - APPLIES_TO_PLACEHOLDER GETCS_NEEDS_LAYOUT_FLUSH", + flags="GETCS_NEEDS_LAYOUT_FLUSH", spec="https://drafts.csswg.org/css2/visudet.html#propdef-line-height", servo_restyle_damage="reflow" )} @@ -34,7 +32,6 @@ ${helpers.predefined_type( "TextTransform", "computed::TextTransform::none()", animation_value_type="discrete", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text/#propdef-text-transform", servo_restyle_damage="rebuild_and_reflow", )} @@ -102,7 +99,7 @@ ${helpers.predefined_type( gecko_enum_prefix="StyleTextJustify" animation_value_type="discrete" gecko_pref="layout.css.text-justify.enabled" - flags="APPLIES_TO_PLACEHOLDER", + has_effect_on_gecko_scrollbars="False" spec="https://drafts.csswg.org/css-text/#propdef-text-justify" servo_restyle_damage="rebuild_and_reflow" > @@ -148,7 +145,6 @@ ${helpers.predefined_type( "TextAlign", "computed::TextAlign::Start", animation_value_type="discrete", - flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text/#propdef-text-align", servo_restyle_damage = "reflow", )} @@ -158,7 +154,6 @@ ${helpers.predefined_type( "LetterSpacing", "computed::LetterSpacing::normal()", animation_value_type="ComputedValue", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing", servo_restyle_damage="rebuild_and_reflow", )} @@ -168,7 +163,6 @@ ${helpers.predefined_type( "WordSpacing", "computed::WordSpacing::zero()", animation_value_type="ComputedValue", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text/#propdef-word-spacing", servo_restyle_damage="rebuild_and_reflow", )} @@ -180,8 +174,6 @@ ${helpers.predefined_type( gecko_enum_prefix="StyleWhiteSpace" needs_conversion="True" animation_value_type="discrete" - // Only allowed for UA sheets, which set it !important. - flags="APPLIES_TO_CUE APPLIES_TO_PLACEHOLDER" spec="https://drafts.csswg.org/css-text/#propdef-white-space" servo_restyle_damage="rebuild_and_reflow" > @@ -229,7 +221,6 @@ ${helpers.predefined_type( animation_value_type="AnimatedTextShadowList", ignored_when_colors_disabled=True, simple_vector_bindings=True, - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text-decor-3/#text-shadow-property", )} @@ -293,7 +284,6 @@ ${helpers.predefined_type( products="gecko", animation_value_type="AnimatedColor", ignored_when_colors_disabled=True, - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color", )} @@ -305,7 +295,6 @@ ${helpers.predefined_type( products="gecko", animation_value_type="AnimatedColor", ignored_when_colors_disabled=True, - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color", )} @@ -316,7 +305,6 @@ ${helpers.predefined_type( initial_specified_value="specified::BorderSideWidth::zero()", computed_type="crate::values::computed::NonNegativeLength", products="gecko", - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width", animation_value_type="discrete", )} @@ -337,7 +325,6 @@ ${helpers.single_keyword( products="gecko", animation_value_type="discrete", spec="https://drafts.csswg.org/css-ruby/#ruby-position-property", - flags="APPLIES_TO_CUE", )} // CSS Writing Modes Module Level 3 @@ -349,7 +336,6 @@ ${helpers.single_keyword( products="gecko", animation_value_type="discrete", spec="https://drafts.csswg.org/css-writing-modes-3/#text-combine-upright", - flags="APPLIES_TO_CUE APPLIES_TO_MARKER", )} // SVG 1.1: Section 11 - Painting: Filling, Stroking and Marker Symbols @@ -382,6 +368,7 @@ ${helpers.predefined_type( products="gecko", animation_value_type="ComputedValue", gecko_pref="layout.css.text-underline-offset.enabled", + has_effect_on_gecko_scrollbars=False, spec="https://drafts.csswg.org/css-text-decor-4/#underline-offset", )} @@ -394,5 +381,6 @@ ${helpers.predefined_type( needs_context=False, animation_value_type="discrete", gecko_pref="layout.css.text-decoration-skip-ink.enabled", + has_effect_on_gecko_scrollbars=False, spec="https://drafts.csswg.org/css-text-decor-4/#text-decoration-skip-ink-property", )} diff --git a/components/style/properties/longhands/inherited_ui.mako.rs b/components/style/properties/longhands/inherited_ui.mako.rs index 07264372995..477bda6839d 100644 --- a/components/style/properties/longhands/inherited_ui.mako.rs +++ b/components/style/properties/longhands/inherited_ui.mako.rs @@ -23,7 +23,6 @@ ${helpers.single_keyword( "auto none", animation_value_type="discrete", extra_gecko_values="visiblepainted visiblefill visiblestroke visible painted fill stroke all", - flags="APPLIES_TO_PLACEHOLDER", spec="https://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty", )} @@ -74,6 +73,10 @@ ${helpers.predefined_type( "Default::default()", spec="https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color", gecko_pref="layout.css.scrollbar-color.enabled", + # Surprisingly, yes the computed value of scrollbar-color has no effect on + # Gecko scrollbar elements, since the value only matters on the scrollable + # element itself. + has_effect_on_gecko_scrollbars=False, animation_value_type="ScrollbarColor", boxed=True, ignored_when_colors_disabled=True, diff --git a/components/style/properties/longhands/margin.mako.rs b/components/style/properties/longhands/margin.mako.rs index c3289c34b7c..db98f8778f4 100644 --- a/components/style/properties/longhands/margin.mako.rs +++ b/components/style/properties/longhands/margin.mako.rs @@ -22,7 +22,7 @@ logical=side[1], logical_group="margin", spec=spec, - flags="APPLIES_TO_FIRST_LETTER GETCS_NEEDS_LAYOUT_FLUSH", + flags="GETCS_NEEDS_LAYOUT_FLUSH", allowed_in_page_rule=True, servo_restyle_damage="reflow" )} @@ -38,7 +38,6 @@ logical=side[1], logical_group="scroll-margin", spec="https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin-%s" % side[0], - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE", animation_value_type="ComputedValue", )} % endfor diff --git a/components/style/properties/longhands/outline.mako.rs b/components/style/properties/longhands/outline.mako.rs index ec765e631b8..8d0d326180b 100644 --- a/components/style/properties/longhands/outline.mako.rs +++ b/components/style/properties/longhands/outline.mako.rs @@ -18,7 +18,6 @@ ${helpers.predefined_type( animation_value_type="AnimatedColor", ignored_when_colors_disabled=True, spec="https://drafts.csswg.org/css-ui/#propdef-outline-color", - flags="APPLIES_TO_CUE", )} ${helpers.predefined_type( @@ -28,7 +27,6 @@ ${helpers.predefined_type( initial_specified_value="specified::OutlineStyle::none()", animation_value_type="discrete", spec="https://drafts.csswg.org/css-ui/#propdef-outline-style", - flags="APPLIES_TO_CUE", )} ${helpers.predefined_type( @@ -39,7 +37,6 @@ ${helpers.predefined_type( computed_type="crate::values::computed::NonNegativeLength", animation_value_type="NonNegativeLength", spec="https://drafts.csswg.org/css-ui/#propdef-outline-width", - flags="APPLIES_TO_CUE", )} // The -moz-outline-radius-* properties are non-standard and not on a standards track. diff --git a/components/style/properties/longhands/padding.mako.rs b/components/style/properties/longhands/padding.mako.rs index 6142bbf901e..5f00b0b2546 100644 --- a/components/style/properties/longhands/padding.mako.rs +++ b/components/style/properties/longhands/padding.mako.rs @@ -6,8 +6,6 @@ <% from data import ALL_SIDES, maybe_moz_logical_alias %> <% data.new_style_struct("Padding", inherited=False) %> -// APPLIES_TO_PLACEHOLDER so we can set it in UA stylesheets. But we use a -// !important value there, so pages can't set it. % for side in ALL_SIDES: <% spec = "https://drafts.csswg.org/css-box/#propdef-padding-%s" % side[0] @@ -23,7 +21,7 @@ logical=side[1], logical_group="padding", spec=spec, - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_PLACEHOLDER GETCS_NEEDS_LAYOUT_FLUSH", + flags="GETCS_NEEDS_LAYOUT_FLUSH", allow_quirks="No" if side[1] else "Yes", servo_restyle_damage="reflow rebuild_and_reflow_inline" )} diff --git a/components/style/properties/longhands/svg.mako.rs b/components/style/properties/longhands/svg.mako.rs index 9f0e0db9fbc..5480a6d5fdc 100644 --- a/components/style/properties/longhands/svg.mako.rs +++ b/components/style/properties/longhands/svg.mako.rs @@ -7,15 +7,6 @@ <% data.new_style_struct("SVG", inherited=False, gecko_name="SVGReset") %> ${helpers.single_keyword( - "dominant-baseline", - """auto use-script no-change reset-size ideographic alphabetic hanging - mathematical central middle text-after-edge text-before-edge""", - products="gecko", - animation_value_type="discrete", - spec="https://www.w3.org/TR/SVG11/text.html#DominantBaselineProperty", -)} - -${helpers.single_keyword( "vector-effect", "none non-scaling-stroke", products="gecko", @@ -40,7 +31,7 @@ ${helpers.predefined_type( "1.0", products="gecko", animation_value_type="ComputedValue", - spec="https://www.w3.org/TR/SVGTiny12/painting.html#propdef-stop-opacity", + spec="https://svgwg.org/svg2-draft/pservers.html#StopOpacityProperty", )} // Section 15 - Filter Effects @@ -60,7 +51,7 @@ ${helpers.predefined_type( "1.0", products="gecko", animation_value_type="ComputedValue", - spec="https://www.w3.org/TR/SVG/filters.html#FloodOpacityProperty", + spec="https://drafts.fxtf.org/filter-effects/#FloodOpacityProperty", )} ${helpers.predefined_type( diff --git a/components/style/properties/longhands/text.mako.rs b/components/style/properties/longhands/text.mako.rs index 44adc21766d..06db3307238 100644 --- a/components/style/properties/longhands/text.mako.rs +++ b/components/style/properties/longhands/text.mako.rs @@ -13,7 +13,6 @@ ${helpers.predefined_type( "computed::TextOverflow::get_initial_value()", animation_value_type="discrete", boxed=True, - flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow", servo_restyle_damage="rebuild_and_reflow", )} @@ -23,7 +22,6 @@ ${helpers.single_keyword( "normal embed isolate bidi-override isolate-override plaintext", animation_value_type="none", spec="https://drafts.csswg.org/css-writing-modes/#propdef-unicode-bidi", - flags="APPLIES_TO_MARKER", servo_restyle_damage="rebuild_and_reflow", )} @@ -33,7 +31,6 @@ ${helpers.predefined_type( "specified::TextDecorationLine::none()", initial_specified_value="specified::TextDecorationLine::none()", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line", servo_restyle_damage="rebuild_and_reflow", )} @@ -43,7 +40,6 @@ ${helpers.single_keyword( "solid double dotted dashed wavy -moz-none", products="gecko", animation_value_type="discrete", - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-style", )} @@ -55,7 +51,6 @@ ${helpers.predefined_type( products="gecko", animation_value_type="AnimatedColor", ignored_when_colors_disabled=True, - flags="APPLIES_TO_CUE APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-color", )} @@ -66,17 +61,16 @@ ${helpers.predefined_type( initial_specified_value="specified::InitialLetter::normal()", animation_value_type="discrete", products="gecko", - flags="APPLIES_TO_FIRST_LETTER", gecko_pref="layout.css.initial-letter.enabled", spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials", )} ${helpers.predefined_type( - "text-decoration-width", + "text-decoration-thickness", "LengthOrAuto", "computed::LengthOrAuto::auto()", products="gecko", animation_value_type="ComputedValue", - gecko_pref="layout.css.text-decoration-width.enabled", + gecko_pref="layout.css.text-decoration-thickness.enabled", spec="https://drafts.csswg.org/css-text-decor-4/#text-decoration-width-property" )} diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 6382ae8b250..e00e3c7cb79 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -53,7 +53,7 @@ pub use self::cascade::*; <%! from collections import defaultdict - from data import Method, Keyword, to_rust_ident, to_camel_case, SYSTEM_FONT_LONGHANDS + from data import Method, PropertyRestrictions, Keyword, to_rust_ident, to_camel_case, SYSTEM_FONT_LONGHANDS import os.path %> @@ -812,6 +812,22 @@ impl LonghandIdSet { &IGNORED_WHEN_COLORS_DISABLED } + /// Returns the set of properties that are declared as having no effect on + /// Gecko <scrollbar> elements or their descendant scrollbar parts. + #[cfg(debug_assertions)] + #[cfg(feature = "gecko")] + #[inline] + pub fn has_no_effect_on_gecko_scrollbars() -> &'static Self { + // data.py asserts that has_no_effect_on_gecko_scrollbars is True or + // False for properties that are inherited and Gecko pref controlled, + // and is None for all other properties. + ${static_longhand_id_set( + "HAS_NO_EFFECT_ON_SCROLLBARS", + lambda p: p.has_effect_on_gecko_scrollbars is False + )} + &HAS_NO_EFFECT_ON_SCROLLBARS + } + /// Iterate over the current longhand id set. pub fn iter(&self) -> LonghandIdSetIterator { LonghandIdSetIterator { longhands: self, cur: 0, } @@ -987,6 +1003,28 @@ bitflags! { if logical_count * 2 != len(props): raise RuntimeError("Logical group {} has ".format(group) + "unbalanced logical / physical properties") + + FIRST_LINE_RESTRICTIONS = PropertyRestrictions.first_line(data) + FIRST_LETTER_RESTRICTIONS = PropertyRestrictions.first_letter(data) + MARKER_RESTRICTIONS = PropertyRestrictions.marker(data) + PLACEHOLDER_RESTRICTIONS = PropertyRestrictions.placeholder(data) + CUE_RESTRICTIONS = PropertyRestrictions.cue(data) + + def restriction_flags(property): + name = property.name + flags = [] + if name in FIRST_LINE_RESTRICTIONS: + flags.append("APPLIES_TO_FIRST_LINE") + if name in FIRST_LETTER_RESTRICTIONS: + flags.append("APPLIES_TO_FIRST_LETTER") + if name in PLACEHOLDER_RESTRICTIONS: + flags.append("APPLIES_TO_PLACEHOLDER") + if name in MARKER_RESTRICTIONS: + flags.append("APPLIES_TO_MARKER") + if name in CUE_RESTRICTIONS: + flags.append("APPLIES_TO_CUE") + return flags + %> /// A group for properties which may override each other @@ -1190,7 +1228,7 @@ impl LonghandId { // constant expression support. const FLAGS: [u16; ${len(data.longhands)}] = [ % for property in data.longhands: - % for flag in property.flags: + % for flag in property.flags + restriction_flags(property): PropertyFlags::${flag}.bits | % endfor 0, diff --git a/components/style/properties/shorthands/background.mako.rs b/components/style/properties/shorthands/background.mako.rs index af98342bfe6..7986201e423 100644 --- a/components/style/properties/shorthands/background.mako.rs +++ b/components/style/properties/shorthands/background.mako.rs @@ -15,7 +15,7 @@ use crate::properties::longhands::background_clip; use crate::properties::longhands::background_clip::single_value::computed_value::T as Clip; use crate::properties::longhands::background_origin::single_value::computed_value::T as Origin; - use crate::values::specified::{Color, Position, PositionComponent}; + use crate::values::specified::{AllowQuirks, Color, Position, PositionComponent}; use crate::parser::Parse; // FIXME(emilio): Should be the same type! @@ -64,7 +64,9 @@ } } if position.is_none() { - if let Ok(value) = input.try(|input| Position::parse(context, input)) { + if let Ok(value) = input.try(|input| { + Position::parse_three_value_quirky(context, input, AllowQuirks::No) + }) { position = Some(value); // Parse background size, if applicable. @@ -211,7 +213,7 @@ let mut any = false; input.parse_comma_separated(|input| { - let value = Position::parse_quirky(context, input, AllowQuirks::Yes)?; + let value = Position::parse_three_value_quirky(context, input, AllowQuirks::Yes)?; position_x.push(value.horizontal); position_y.push(value.vertical); any = true; diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs index b3c99cf875a..df7bf93b8ac 100644 --- a/components/style/servo/media_queries.rs +++ b/components/style/servo/media_queries.rs @@ -15,7 +15,8 @@ use crate::values::computed::CSSPixelLength; use crate::values::KeyframesName; use app_units::Au; use cssparser::RGBA; -use euclid::{Size2D, TypedScale, TypedSize2D}; +use euclid::default::Size2D as UntypedSize2D; +use euclid::{Scale, Size2D}; use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering}; use style_traits::viewport::ViewportConstraints; use style_traits::{CSSPixel, DevicePixel}; @@ -29,9 +30,9 @@ pub struct Device { /// The current media type used by de device. media_type: MediaType, /// The current viewport size, in CSS pixels. - viewport_size: TypedSize2D<f32, CSSPixel>, + viewport_size: Size2D<f32, CSSPixel>, /// The current device pixel ratio, from CSS pixels to device pixels. - device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, /// The font size of the root element /// This is set when computing the style of the root @@ -59,8 +60,8 @@ impl Device { /// Trivially construct a new `Device`. pub fn new( media_type: MediaType, - viewport_size: TypedSize2D<f32, CSSPixel>, - device_pixel_ratio: TypedScale<f32, CSSPixel, DevicePixel>, + viewport_size: Size2D<f32, CSSPixel>, + device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, ) -> Device { Device { media_type, @@ -121,7 +122,7 @@ impl Device { /// Returns the viewport size of the current device in app units, needed, /// among other things, to resolve viewport units. #[inline] - pub fn au_viewport_size(&self) -> Size2D<Au> { + pub fn au_viewport_size(&self) -> UntypedSize2D<Au> { Size2D::new( Au::from_f32_px(self.viewport_size.width), Au::from_f32_px(self.viewport_size.height), @@ -129,7 +130,7 @@ impl Device { } /// Like the above, but records that we've used viewport units. - pub fn au_viewport_size_for_viewport_unit_resolution(&self) -> Size2D<Au> { + pub fn au_viewport_size_for_viewport_unit_resolution(&self) -> UntypedSize2D<Au> { self.used_viewport_units.store(true, Ordering::Relaxed); self.au_viewport_size() } @@ -140,7 +141,7 @@ impl Device { } /// Returns the device pixel ratio. - pub fn device_pixel_ratio(&self) -> TypedScale<f32, CSSPixel, DevicePixel> { + pub fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel> { self.device_pixel_ratio } diff --git a/components/style/stylesheets/mod.rs b/components/style/stylesheets/mod.rs index 5853ff5f3a5..b74413866f5 100644 --- a/components/style/stylesheets/mod.rs +++ b/components/style/stylesheets/mod.rs @@ -181,18 +181,29 @@ impl UrlExtraData { #[cfg(feature = "gecko")] impl fmt::Debug for UrlExtraData { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - struct DebugURI(*mut structs::nsIURI); - impl fmt::Debug for DebugURI { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - use nsstring::nsCString; - let mut spec = nsCString::new(); - unsafe { - bindings::Gecko_nsIURI_Debug(self.0, &mut spec); + macro_rules! define_debug_struct { + ($struct_name:ident, $gecko_class:ident, $debug_fn:ident) => { + struct $struct_name(*mut structs::$gecko_class); + impl fmt::Debug for $struct_name { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + use nsstring::nsCString; + let mut spec = nsCString::new(); + unsafe { + bindings::$debug_fn(self.0, &mut spec); + } + spec.fmt(formatter) + } } - spec.fmt(formatter) - } + }; } + define_debug_struct!(DebugURI, nsIURI, Gecko_nsIURI_Debug); + define_debug_struct!( + DebugReferrerInfo, + nsIReferrerInfo, + Gecko_nsIReferrerInfo_Debug + ); + formatter .debug_struct("URLExtraData") .field("is_chrome", &self.is_chrome()) @@ -202,7 +213,11 @@ impl fmt::Debug for UrlExtraData { ) .field( "referrer", - &DebugURI(self.as_ref().mReferrer.raw::<structs::nsIURI>()), + &DebugReferrerInfo( + self.as_ref() + .mReferrerInfo + .raw::<structs::nsIReferrerInfo>(), + ), ) .finish() } diff --git a/components/style/stylesheets/viewport_rule.rs b/components/style/stylesheets/viewport_rule.rs index e845930bfbd..8cc858f7a7f 100644 --- a/components/style/stylesheets/viewport_rule.rs +++ b/components/style/stylesheets/viewport_rule.rs @@ -25,7 +25,7 @@ use crate::values::specified::{NonNegativeLengthPercentageOrAuto, ViewportPercen use app_units::Au; use cssparser::CowRcStr; use cssparser::{parse_important, AtRuleParser, DeclarationListParser, DeclarationParser, Parser}; -use euclid::TypedSize2D; +use euclid::Size2D; use selectors::parser::SelectorParseErrorKind; use std::borrow::Cow; use std::cell::RefCell; @@ -832,7 +832,7 @@ impl MaybeNew for ViewportConstraints { }); Some(ViewportConstraints { - size: TypedSize2D::new(width.to_f32_px(), height.to_f32_px()), + size: Size2D::new(width.to_f32_px(), height.to_f32_px()), // TODO: compute a zoom factor for 'auto' as suggested by DEVICE-ADAPT § 10. initial_zoom: PinchZoomFactor::new(initial_zoom.unwrap_or(1.)), diff --git a/components/style/values/computed/list.rs b/components/style/values/computed/list.rs index bdcf62ba2f8..2ae3776041b 100644 --- a/components/style/values/computed/list.rs +++ b/components/style/values/computed/list.rs @@ -7,28 +7,12 @@ #[cfg(feature = "gecko")] pub use crate::values::specified::list::ListStyleType; pub use crate::values::specified::list::MozListReversed; -pub use crate::values::specified::list::{QuotePair, Quotes}; - -lazy_static! { - static ref INITIAL_QUOTES: crate::ArcSlice<QuotePair> = crate::ArcSlice::from_iter_leaked( - vec![ - QuotePair { - opening: "\u{201c}".to_owned().into(), - closing: "\u{201d}".to_owned().into(), - }, - QuotePair { - opening: "\u{2018}".to_owned().into(), - closing: "\u{2019}".to_owned().into(), - }, - ] - .into_iter() - ); -} +pub use crate::values::specified::list::Quotes; impl Quotes { /// Initial value for `quotes`. #[inline] pub fn get_initial_value() -> Quotes { - Quotes(INITIAL_QUOTES.clone()) + Quotes::Auto } } diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index cea768abeff..7cfe0de6d8d 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -23,7 +23,7 @@ use crate::rule_cache::RuleCacheConditions; use crate::Atom; #[cfg(feature = "servo")] use crate::Prefix; -use euclid::Size2D; +use euclid::default::Size2D; use std::cell::RefCell; use std::cmp; use std::f32; @@ -64,7 +64,7 @@ pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageO #[cfg(feature = "gecko")] pub use self::list::ListStyleType; pub use self::list::MozListReversed; -pub use self::list::{QuotePair, Quotes}; +pub use self::list::Quotes; pub use self::motion::{OffsetPath, OffsetRotate}; pub use self::outline::OutlineStyle; pub use self::percentage::{NonNegativePercentage, Percentage}; diff --git a/components/style/values/computed/transform.rs b/components/style/values/computed/transform.rs index 9104a43ae5b..46c471b7e2e 100644 --- a/components/style/values/computed/transform.rs +++ b/components/style/values/computed/transform.rs @@ -10,7 +10,7 @@ use crate::values::animated::ToAnimatedZero; use crate::values::computed::{Angle, Integer, Length, LengthPercentage, Number, Percentage}; use crate::values::generics::transform as generic; use crate::Zero; -use euclid::{Transform3D, Vector3D}; +use euclid::default::{Transform3D, Vector3D}; pub use crate::values::generics::transform::TransformStyle; diff --git a/components/style/values/distance.rs b/components/style/values/distance.rs index d3b4c7dfaad..a1872366c2a 100644 --- a/components/style/values/distance.rs +++ b/components/style/values/distance.rs @@ -5,7 +5,7 @@ //! Machinery to compute distances between animatable values. use app_units::Au; -use euclid::Size2D; +use euclid::default::Size2D; use std::iter::Sum; use std::ops::Add; diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index f6fd800247a..8dbbdfcd168 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -12,7 +12,8 @@ use crate::values::specified::length::LengthPercentage as SpecifiedLengthPercent use crate::values::{computed, CSSFloat}; use crate::Zero; use app_units::Au; -use euclid::{self, Rect, Transform3D}; +use euclid; +use euclid::default::{Rect, Transform3D}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; @@ -562,7 +563,7 @@ impl<T: ToMatrix> Transform<T> { for operation in &*self.0 { let matrix = operation.to_3d_matrix(reference_box)?; contain_3d |= operation.is_3d(); - transform = transform.pre_mul(&matrix); + transform = transform.pre_transform(&matrix); } Ok((transform, contain_3d)) diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 5bb01955956..6ae374685b8 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -22,7 +22,7 @@ use crate::values::CSSFloat; use crate::Zero; use app_units::Au; use cssparser::{Parser, Token}; -use euclid::Size2D; +use euclid::default::Size2D; use std::cmp; use std::ops::{Add, Mul}; use style_traits::values::specified::AllowedNumericType; diff --git a/components/style/values/specified/list.rs b/components/style/values/specified/list.rs index 0519053b902..3946d78652e 100644 --- a/components/style/values/specified/list.rs +++ b/components/style/values/specified/list.rs @@ -104,7 +104,7 @@ pub struct QuotePair { pub closing: crate::OwnedStr, } -/// Specified and computed `quotes` property. +/// List of quote pairs for the specified/computed value of `quotes` property. #[derive( Clone, Debug, @@ -117,23 +117,53 @@ pub struct QuotePair { ToResolvedValue, ToShmem, )] -#[repr(C)] -pub struct Quotes( +#[repr(transparent)] +pub struct QuoteList( #[css(iterable, if_empty = "none")] #[ignore_malloc_size_of = "Arc"] pub crate::ArcSlice<QuotePair>, ); +/// Specified and computed `quotes` property: `auto`, `none`, or a list +/// of characters. +/// +/// cbindgen:derive-tagged-enum-copy-constructor=true +#[derive( + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] +#[repr(C)] +pub enum Quotes { + /// list of quote pairs + QuoteList(QuoteList), + /// auto (use lang-dependent quote marks) + Auto, +} + impl Parse for Quotes { fn parse<'i, 't>( _: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Quotes, ParseError<'i>> { if input + .try(|input| input.expect_ident_matching("auto")) + .is_ok() + { + return Ok(Quotes::Auto); + } + + if input .try(|input| input.expect_ident_matching("none")) .is_ok() { - return Ok(Self::default()); + return Ok(Quotes::QuoteList(QuoteList::default())); } let mut quotes = Vec::new(); @@ -150,7 +180,9 @@ impl Parse for Quotes { } if !quotes.is_empty() { - Ok(Quotes(crate::ArcSlice::from_iter(quotes.into_iter()))) + Ok(Quotes::QuoteList(QuoteList(crate::ArcSlice::from_iter( + quotes.into_iter(), + )))) } else { Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) } diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 14439d2eea0..c8cce337381 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -65,7 +65,7 @@ pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageO #[cfg(feature = "gecko")] pub use self::list::ListStyleType; pub use self::list::MozListReversed; -pub use self::list::{QuotePair, Quotes}; +pub use self::list::Quotes; pub use self::motion::{OffsetPath, OffsetRotate}; pub use self::outline::OutlineStyle; pub use self::percentage::Percentage; @@ -402,18 +402,45 @@ impl Parse for NonNegativeNumberOrPercentage { } } -#[allow(missing_docs)] +/// The value of Opacity is <alpha-value>, which is "<number> | <percentage>". +/// However, we serialize the specified value as number, so it's ok to store +/// the Opacity as Number. #[derive( Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, SpecifiedValueInfo, ToCss, ToShmem, )] pub struct Opacity(Number); +impl Opacity { + /// Parse number value only. + #[inline] + pub fn parse_number<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result<Self, ParseError<'i>> { + Number::parse(context, input).map(Opacity) + } +} + impl Parse for Opacity { + /// Opacity accepts <number> | <percentage>, so we parse it as NumberOrPercentage, + /// and then convert into an Number if it's a Percentage. + /// https://drafts.csswg.org/cssom/#serializing-css-values fn parse<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - Number::parse(context, input).map(Opacity) + let number = match NumberOrPercentage::parse(context, input)? { + NumberOrPercentage::Percentage(p) => Number { + value: p.get(), + calc_clamping_mode: if p.is_calc() { + Some(AllowedNumericType::All) + } else { + None + }, + }, + NumberOrPercentage::Number(n) => n, + }; + Ok(Opacity(number)) } } diff --git a/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index 85516790c4f..4e6a71ec2ca 100644 --- a/components/style/values/specified/position.rs +++ b/components/style/values/specified/position.rs @@ -94,13 +94,17 @@ impl Parse for Position { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - Self::parse_quirky(context, input, AllowQuirks::No) + let position = Self::parse_three_value_quirky(context, input, AllowQuirks::No)?; + if position.is_three_value_syntax() { + return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); + } + Ok(position) } } impl Position { - /// Parses a `<position>`, with quirks. - pub fn parse_quirky<'i, 't>( + /// Parses a `<bg-position>`, with quirks. + pub fn parse_three_value_quirky<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, @@ -183,6 +187,12 @@ impl Position { pub fn center() -> Self { Self::new(PositionComponent::Center, PositionComponent::Center) } + + /// Returns true if this uses a 3 value syntax. + #[inline] + fn is_three_value_syntax(&self) -> bool { + self.horizontal.component_count() != self.vertical.component_count() + } } impl ToCss for Position { @@ -252,6 +262,20 @@ impl<S> PositionComponent<S> { pub fn zero() -> Self { PositionComponent::Length(LengthPercentage::Percentage(Percentage::zero())) } + + /// Returns the count of this component. + fn component_count(&self) -> usize { + match *self { + PositionComponent::Length(..) | PositionComponent::Center => 1, + PositionComponent::Side(_, ref lp) => { + if lp.is_some() { + 2 + } else { + 1 + } + }, + } + } } impl<S: Side> ToComputedValue for PositionComponent<S> { diff --git a/components/style_traits/Cargo.toml b/components/style_traits/Cargo.toml index acf46422861..e2cb4f1bd12 100644 --- a/components/style_traits/Cargo.toml +++ b/components/style_traits/Cargo.toml @@ -10,14 +10,14 @@ name = "style_traits" path = "lib.rs" [features] -servo = ["serde", "servo_atoms", "cssparser/serde", "webrender_api", "servo_url"] +servo = ["serde", "servo_atoms", "cssparser/serde", "webrender_api", "servo_url", "euclid/serde"] gecko = [] [dependencies] app_units = "0.7" cssparser = "0.25" bitflags = "1.0" -euclid = "0.19" +euclid = "0.20" lazy_static = "1" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = "0.1" diff --git a/components/style_traits/viewport.rs b/components/style_traits/viewport.rs index fb10345c1b2..eff1dfca7ad 100644 --- a/components/style_traits/viewport.rs +++ b/components/style_traits/viewport.rs @@ -6,7 +6,7 @@ use crate::{CSSPixel, CssWriter, ParseError, PinchZoomFactor, ToCss}; use cssparser::Parser; -use euclid::TypedSize2D; +use euclid::Size2D; use std::fmt::{self, Write}; define_css_keyword_enum! { @@ -33,7 +33,7 @@ pub struct ViewportConstraints { /// Width and height: /// * https://drafts.csswg.org/css-device-adapt/#width-desc /// * https://drafts.csswg.org/css-device-adapt/#height-desc - pub size: TypedSize2D<f32, CSSPixel>, + pub size: Size2D<f32, CSSPixel>, /// <https://drafts.csswg.org/css-device-adapt/#zoom-desc> pub initial_zoom: PinchZoomFactor, /// <https://drafts.csswg.org/css-device-adapt/#min-max-width-desc> diff --git a/components/webdriver_server/Cargo.toml b/components/webdriver_server/Cargo.toml index 50a3816073a..06b1d539291 100644 --- a/components/webdriver_server/Cargo.toml +++ b/components/webdriver_server/Cargo.toml @@ -14,7 +14,7 @@ path = "lib.rs" base64 = "0.10" cookie = "0.11" crossbeam-channel = "0.3" -euclid = "0.19" +euclid = "0.20" hyper = "0.12" image = "0.21" ipc-channel = "0.11" diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index d227973edc9..dd745ae256d 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -18,7 +18,7 @@ mod capabilities; use base64; use capabilities::ServoCapabilities; use crossbeam_channel::Sender; -use euclid::TypedSize2D; +use euclid::Size2D; use hyper::Method; use image::{DynamicImage, ImageFormat, RgbImage}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; @@ -667,7 +667,7 @@ impl Handler { Some(v) => v, None => 0, }; - let size = TypedSize2D::new(width as u32, height as u32); + let size = Size2D::new(width as u32, height as u32); let top_level_browsing_context_id = self.session()?.top_level_browsing_context_id; let cmd_msg = WebDriverCommandMsg::SetWindowSize( top_level_browsing_context_id, diff --git a/components/webrender_traits/Cargo.toml b/components/webrender_traits/Cargo.toml index 01e2ca2f2e3..76c359d01e6 100644 --- a/components/webrender_traits/Cargo.toml +++ b/components/webrender_traits/Cargo.toml @@ -11,7 +11,7 @@ name = "webrender_traits" path = "lib.rs" [dependencies] -euclid = "0.19" +euclid = "0.20" webrender = {git = "https://github.com/servo/webrender"} webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} diff --git a/components/webrender_traits/lib.rs b/components/webrender_traits/lib.rs index 60492121663..90b1b944369 100644 --- a/components/webrender_traits/lib.rs +++ b/components/webrender_traits/lib.rs @@ -4,7 +4,7 @@ #![deny(unsafe_code)] -use euclid::Size2D; +use euclid::default::Size2D; use std::collections::HashMap; use std::sync::{Arc, Mutex}; use webrender_api::units::TexelRect; diff --git a/components/webvr/Cargo.toml b/components/webvr/Cargo.toml index 02da9dbd6f3..247eb08f818 100644 --- a/components/webvr/Cargo.toml +++ b/components/webvr/Cargo.toml @@ -17,7 +17,7 @@ oculusvr = ['rust-webvr/oculusvr'] [dependencies] canvas_traits = {path = "../canvas_traits"} crossbeam-channel = "0.3" -euclid = "0.19" +euclid = "0.20" gleam = "0.6" ipc-channel = "0.11.2" log = "0.4" diff --git a/components/webvr/webvr_thread.rs b/components/webvr/webvr_thread.rs index 0da3b98d820..c782fb2e562 100644 --- a/components/webvr/webvr_thread.rs +++ b/components/webvr/webvr_thread.rs @@ -4,7 +4,7 @@ use canvas_traits::webgl; use crossbeam_channel::{unbounded, Receiver, Sender}; -use euclid::Size2D; +use euclid::default::Size2D; use gleam::gl::Gl; use ipc_channel::ipc; use ipc_channel::ipc::{IpcReceiver, IpcSender}; diff --git a/ports/glutin/Cargo.toml b/ports/glutin/Cargo.toml index 50bd77efe71..77717076cde 100644 --- a/ports/glutin/Cargo.toml +++ b/ports/glutin/Cargo.toml @@ -49,7 +49,7 @@ backtrace = "0.3" bitflags = "1.0" clipboard = "0.5" crossbeam-channel = "0.3" -euclid = "0.19" +euclid = "0.20" gleam = "0.6" glutin = "0.21.0" keyboard-types = "0.4.3" diff --git a/ports/glutin/browser.rs b/ports/glutin/browser.rs index 042f84072c7..7255390fdf6 100644 --- a/ports/glutin/browser.rs +++ b/ports/glutin/browser.rs @@ -4,7 +4,7 @@ use crate::keyutils::{CMD_OR_ALT, CMD_OR_CONTROL}; use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT}; -use euclid::{TypedPoint2D, TypedVector2D}; +use euclid::{Point2D, Vector2D}; use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher}; use servo::compositing::windowing::{WebRenderDebugOption, WindowEvent}; use servo::embedder_traits::{EmbedderMsg, FilterPattern}; @@ -222,14 +222,14 @@ where self.event_queue.push(WindowEvent::ResetZoom) }) .shortcut(Modifiers::empty(), Key::PageDown, || { - let scroll_location = ScrollLocation::Delta(TypedVector2D::new( + let scroll_location = ScrollLocation::Delta(Vector2D::new( 0.0, -self.window.page_height() + 2.0 * LINE_HEIGHT, )); self.scroll_window_from_key(scroll_location, TouchEventType::Move); }) .shortcut(Modifiers::empty(), Key::PageUp, || { - let scroll_location = ScrollLocation::Delta(TypedVector2D::new( + let scroll_location = ScrollLocation::Delta(Vector2D::new( 0.0, self.window.page_height() - 2.0 * LINE_HEIGHT, )); @@ -243,32 +243,32 @@ where }) .shortcut(Modifiers::empty(), Key::ArrowUp, || { self.scroll_window_from_key( - ScrollLocation::Delta(TypedVector2D::new(0.0, 3.0 * LINE_HEIGHT)), + ScrollLocation::Delta(Vector2D::new(0.0, 3.0 * LINE_HEIGHT)), TouchEventType::Move, ); }) .shortcut(Modifiers::empty(), Key::ArrowDown, || { self.scroll_window_from_key( - ScrollLocation::Delta(TypedVector2D::new(0.0, -3.0 * LINE_HEIGHT)), + ScrollLocation::Delta(Vector2D::new(0.0, -3.0 * LINE_HEIGHT)), TouchEventType::Move, ); }) .shortcut(Modifiers::empty(), Key::ArrowLeft, || { self.scroll_window_from_key( - ScrollLocation::Delta(TypedVector2D::new(LINE_HEIGHT, 0.0)), + ScrollLocation::Delta(Vector2D::new(LINE_HEIGHT, 0.0)), TouchEventType::Move, ); }) .shortcut(Modifiers::empty(), Key::ArrowRight, || { self.scroll_window_from_key( - ScrollLocation::Delta(TypedVector2D::new(-LINE_HEIGHT, 0.0)), + ScrollLocation::Delta(Vector2D::new(-LINE_HEIGHT, 0.0)), TouchEventType::Move, ); }); } fn scroll_window_from_key(&mut self, scroll_location: ScrollLocation, phase: TouchEventType) { - let event = WindowEvent::Scroll(scroll_location, TypedPoint2D::zero(), phase); + let event = WindowEvent::Scroll(scroll_location, Point2D::zero(), phase); self.event_queue.push(event); } diff --git a/ports/glutin/headed_window.rs b/ports/glutin/headed_window.rs index 4de73fdcf78..082f344badb 100644 --- a/ports/glutin/headed_window.rs +++ b/ports/glutin/headed_window.rs @@ -9,7 +9,7 @@ use crate::context::GlContext; use crate::events_loop::EventsLoop; use crate::keyutils::keyboard_event_from_winit; use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT}; -use euclid::{Size2D, TypedPoint2D, TypedScale, TypedSize2D, TypedVector2D}; +use euclid::{default::Size2D as UntypedSize2D, Point2D, Scale, Size2D, Vector2D}; use gleam::gl; use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalSize}; #[cfg(target_os = "macos")] @@ -57,13 +57,13 @@ fn builder_with_platform_options(builder: glutin::WindowBuilder) -> glutin::Wind pub struct Window { gl_context: RefCell<GlContext>, events_loop: Rc<RefCell<EventsLoop>>, - screen_size: TypedSize2D<u32, DeviceIndependentPixel>, - inner_size: Cell<TypedSize2D<u32, DeviceIndependentPixel>>, + screen_size: Size2D<u32, DeviceIndependentPixel>, + inner_size: Cell<Size2D<u32, DeviceIndependentPixel>>, mouse_down_button: Cell<Option<glutin::MouseButton>>, - mouse_down_point: Cell<TypedPoint2D<i32, DevicePixel>>, + mouse_down_point: Cell<Point2D<i32, DevicePixel>>, primary_monitor: glutin::MonitorId, event_queue: RefCell<Vec<WindowEvent>>, - mouse_pos: Cell<TypedPoint2D<i32, DevicePixel>>, + mouse_pos: Cell<Point2D<i32, DevicePixel>>, last_pressed: Cell<Option<KeyboardEvent>>, animation_state: Cell<AnimationState>, fullscreen: Cell<bool>, @@ -71,20 +71,20 @@ pub struct Window { } #[cfg(not(target_os = "windows"))] -fn window_creation_scale_factor() -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { - TypedScale::new(1.0) +fn window_creation_scale_factor() -> Scale<f32, DeviceIndependentPixel, DevicePixel> { + Scale::new(1.0) } #[cfg(target_os = "windows")] -fn window_creation_scale_factor() -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { +fn window_creation_scale_factor() -> Scale<f32, DeviceIndependentPixel, DevicePixel> { let hdc = unsafe { winapi::um::winuser::GetDC(::std::ptr::null_mut()) }; let ppi = unsafe { winapi::um::wingdi::GetDeviceCaps(hdc, winapi::um::wingdi::LOGPIXELSY) }; - TypedScale::new(ppi as f32 / 96.0) + Scale::new(ppi as f32 / 96.0) } impl Window { pub fn new( - win_size: TypedSize2D<u32, DeviceIndependentPixel>, + win_size: Size2D<u32, DeviceIndependentPixel>, sharing: Option<&GlContext>, events_loop: Rc<RefCell<EventsLoop>>, ) -> Window { @@ -139,13 +139,13 @@ impl Window { width: screen_width, height: screen_height, } = primary_monitor.get_dimensions(); - let screen_size = TypedSize2D::new(screen_width as u32, screen_height as u32); + let screen_size = Size2D::new(screen_width as u32, screen_height as u32); // TODO(ajeffrey): can this fail? let LogicalSize { width, height } = context .window() .get_inner_size() .expect("Failed to get window inner size."); - let inner_size = TypedSize2D::new(width as u32, height as u32); + let inner_size = Size2D::new(width as u32, height as u32); context.window().show(); @@ -172,8 +172,8 @@ impl Window { events_loop, event_queue: RefCell::new(vec![]), mouse_down_button: Cell::new(None), - mouse_down_point: Cell::new(TypedPoint2D::new(0, 0)), - mouse_pos: Cell::new(TypedPoint2D::new(0, 0)), + mouse_down_point: Cell::new(Point2D::new(0, 0)), + mouse_pos: Cell::new(Point2D::new(0, 0)), last_pressed: Cell::new(None), gl: gl.clone(), animation_state: Cell::new(AnimationState::Idle), @@ -233,7 +233,7 @@ impl Window { &self, button: glutin::MouseButton, action: glutin::ElementState, - coords: TypedPoint2D<i32, DevicePixel>, + coords: Point2D<i32, DevicePixel>, ) { use servo::script_traits::MouseButton; @@ -271,15 +271,15 @@ impl Window { .push(WindowEvent::MouseWindowEventClass(event)); } - fn device_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { - TypedScale::new(self.gl_context.borrow().window().get_hidpi_factor() as f32) + fn device_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> { + Scale::new(self.gl_context.borrow().window().get_hidpi_factor() as f32) } - fn servo_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { + fn servo_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> { match opts::get().device_pixels_per_px { - Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px), + Some(device_pixels_per_px) => Scale::new(device_pixels_per_px), _ => match opts::get().output_file { - Some(_) => TypedScale::new(1.0), + Some(_) => Scale::new(1.0), None => self.device_hidpi_factor(), }, } @@ -397,10 +397,10 @@ impl WindowPortsMethods for Window { glutin::WindowEvent::CursorMoved { position, .. } => { let pos = position.to_physical(self.device_hidpi_factor().get() as f64); let (x, y): (i32, i32) = pos.into(); - self.mouse_pos.set(TypedPoint2D::new(x, y)); + self.mouse_pos.set(Point2D::new(x, y)); self.event_queue .borrow_mut() - .push(WindowEvent::MouseWindowMoveEventClass(TypedPoint2D::new( + .push(WindowEvent::MouseWindowMoveEventClass(Point2D::new( x as f32, y as f32, ))); }, @@ -418,7 +418,7 @@ impl WindowPortsMethods for Window { // Create wheel event before snapping to the major axis of movement let wheel_delta = WheelDelta { x: dx, y: dy, z: 0.0, mode }; let pos = self.mouse_pos.get(); - let position = TypedPoint2D::new(pos.x as f32, pos.y as f32); + let position = Point2D::new(pos.x as f32, pos.y as f32); let wheel_event = WindowEvent::Wheel(wheel_delta, position); // Scroll events snap to the major axis of movement, with vertical @@ -429,7 +429,7 @@ impl WindowPortsMethods for Window { dy = 0.0; } - let scroll_location = ScrollLocation::Delta(TypedVector2D::new(dx as f32, dy as f32)); + let scroll_location = ScrollLocation::Delta(Vector2D::new(dx as f32, dy as f32)); let phase = winit_phase_to_touch_event_type(phase); let scroll_event = WindowEvent::Scroll(scroll_location, self.mouse_pos.get(), phase); @@ -445,7 +445,7 @@ impl WindowPortsMethods for Window { let position = touch .location .to_physical(self.device_hidpi_factor().get() as f64); - let point = TypedPoint2D::new(position.x as f32, position.y as f32); + let point = Point2D::new(position.x as f32, position.y as f32); self.event_queue .borrow_mut() .push(WindowEvent::Touch(phase, id, point)); @@ -461,7 +461,7 @@ impl WindowPortsMethods for Window { self.gl_context.borrow_mut().resize(physical_size); // window.set_inner_size() takes DeviceIndependentPixel. let (width, height) = size.into(); - let new_size = TypedSize2D::new(width, height); + let new_size = Size2D::new(width, height); if self.inner_size.get() != new_size { self.inner_size.set(new_size); self.event_queue.borrow_mut().push(WindowEvent::Resize); @@ -482,7 +482,7 @@ impl webxr::glwindow::GlWindow for Window { self.gl_context.get_mut().make_not_current(); } - fn size(&self) -> Size2D<gl::GLsizei> { + fn size(&self) -> UntypedSize2D<gl::GLsizei> { let dpr = self.device_hidpi_factor().get() as f64; let LogicalSize { width, height } = self .gl_context @@ -523,8 +523,8 @@ impl WindowMethods for Window { .window() .get_position() .unwrap_or(LogicalPosition::new(0., 0.)); - let win_size = (TypedSize2D::new(width as f32, height as f32) * dpr).to_i32(); - let win_origin = (TypedPoint2D::new(x as f32, y as f32) * dpr).to_i32(); + let win_size = (Size2D::new(width as f32, height as f32) * dpr).to_i32(); + let win_origin = (Point2D::new(x as f32, y as f32) * dpr).to_i32(); let screen = (self.screen_size.to_f32() * dpr).to_i32(); let LogicalSize { width, height } = self @@ -533,9 +533,9 @@ impl WindowMethods for Window { .window() .get_inner_size() .expect("Failed to get window inner size."); - let inner_size = (TypedSize2D::new(width as f32, height as f32) * dpr).to_i32(); - let viewport = DeviceIntRect::new(TypedPoint2D::zero(), inner_size); - let framebuffer = DeviceIntSize::from_untyped(&viewport.size.to_untyped()); + let inner_size = (Size2D::new(width as f32, height as f32) * dpr).to_i32(); + let viewport = DeviceIntRect::new(Point2D::zero(), inner_size); + let framebuffer = DeviceIntSize::from_untyped(viewport.size.to_untyped()); EmbedderCoordinates { viewport, diff --git a/ports/glutin/headless_window.rs b/ports/glutin/headless_window.rs index 934f15b3bd2..e2b4132bc1c 100644 --- a/ports/glutin/headless_window.rs +++ b/ports/glutin/headless_window.rs @@ -6,7 +6,7 @@ use crate::window_trait::WindowPortsMethods; use glutin; -use euclid::{Size2D, TypedPoint2D, TypedScale, TypedSize2D}; +use euclid::{default::Size2D as UntypedSize2D, Point2D, Scale, Size2D}; use gleam::gl; use servo::compositing::windowing::{AnimationState, WindowEvent}; use servo::compositing::windowing::{EmbedderCoordinates, WindowMethods}; @@ -106,7 +106,7 @@ pub struct Window { } impl Window { - pub fn new(size: TypedSize2D<u32, DeviceIndependentPixel>) -> Rc<dyn WindowPortsMethods> { + pub fn new(size: Size2D<u32, DeviceIndependentPixel>) -> Rc<dyn WindowPortsMethods> { let context = HeadlessContext::new(size.width, size.height, None); let gl = unsafe { gl::GlFns::load_with(|s| HeadlessContext::get_proc_address(s)) }; @@ -126,10 +126,10 @@ impl Window { Rc::new(window) } - fn servo_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { + fn servo_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> { match opts::get().device_pixels_per_px { - Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px), - _ => TypedScale::new(1.0), + Some(device_pixels_per_px) => Scale::new(device_pixels_per_px), + _ => Scale::new(1.0), } } } @@ -177,13 +177,13 @@ impl WindowMethods for Window { fn get_coordinates(&self) -> EmbedderCoordinates { let dpr = self.servo_hidpi_factor(); let size = - (TypedSize2D::new(self.context.width, self.context.height).to_f32() * dpr).to_i32(); - let viewport = DeviceIntRect::new(TypedPoint2D::zero(), size); - let framebuffer = DeviceIntSize::from_untyped(&size.to_untyped()); + (Size2D::new(self.context.width, self.context.height).to_f32() * dpr).to_i32(); + let viewport = DeviceIntRect::new(Point2D::zero(), size); + let framebuffer = DeviceIntSize::from_untyped(size.to_untyped()); EmbedderCoordinates { viewport, framebuffer, - window: (size, TypedPoint2D::zero()), + window: (size, Point2D::zero()), screen: size, screen_avail: size, hidpi_factor: dpr, @@ -214,7 +214,7 @@ impl WindowMethods for Window { impl webxr::glwindow::GlWindow for Window { fn make_current(&mut self) {} fn swap_buffers(&mut self) {} - fn size(&self) -> Size2D<gl::GLsizei> { + fn size(&self) -> UntypedSize2D<gl::GLsizei> { let dpr = self.servo_hidpi_factor().get(); Size2D::new((self.context.width as f32 * dpr) as gl::GLsizei, (self.context.height as f32 * dpr) as gl::GLsizei) } diff --git a/ports/libmlservo/src/lib.rs b/ports/libmlservo/src/lib.rs index 310182a813a..07b2912dd87 100644 --- a/ports/libmlservo/src/lib.rs +++ b/ports/libmlservo/src/lib.rs @@ -11,7 +11,7 @@ use libc::{dup2, pipe, read}; use log::info; use log::warn; use rust_webvr::api::MagicLeapVRService; -use servo::euclid::TypedScale; +use servo::euclid::Scale; use servo::keyboard_types::Key; use servo::servo_url::ServoUrl; use servo::webrender_api::units::{DevicePixel, DevicePoint, LayoutPixel}; @@ -176,7 +176,7 @@ pub unsafe extern "C" fn init_servo( let result = Box::new(ServoInstance { scroll_state: ScrollState::TriggerUp, - scroll_scale: TypedScale::new(SCROLL_SCALE / hidpi), + scroll_scale: Scale::new(SCROLL_SCALE / hidpi), shut_down_complete, }); Box::into_raw(result) @@ -389,7 +389,7 @@ impl HostTrait for HostCallbacks { pub struct ServoInstance { scroll_state: ScrollState, - scroll_scale: TypedScale<f32, DevicePixel, LayoutPixel>, + scroll_scale: Scale<f32, DevicePixel, LayoutPixel>, shut_down_complete: Rc<Cell<bool>>, } diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index cbd7ee16fd7..3032fa65a2c 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -15,7 +15,7 @@ use servo::compositing::windowing::{ }; use servo::embedder_traits::resources::{self, Resource, ResourceReaderMethods}; use servo::embedder_traits::EmbedderMsg; -use servo::euclid::{TypedPoint2D, TypedRect, TypedScale, TypedSize2D, TypedVector2D}; +use servo::euclid::{Point2D, Rect, Scale, Size2D, Vector2D}; use servo::keyboard_types::{Key, KeyState, KeyboardEvent}; use servo::msg::constellation_msg::TraversalDirection; use servo::script_traits::{TouchEventType, TouchId}; @@ -61,8 +61,8 @@ pub enum VRInitOptions { #[derive(Clone, Debug)] pub struct Coordinates { - pub viewport: TypedRect<i32, DevicePixel>, - pub framebuffer: TypedSize2D<i32, DevicePixel>, + pub viewport: Rect<i32, DevicePixel>, + pub framebuffer: Size2D<i32, DevicePixel>, } impl Coordinates { @@ -75,8 +75,8 @@ impl Coordinates { fb_height: i32, ) -> Coordinates { Coordinates { - viewport: TypedRect::new(TypedPoint2D::new(x, y), TypedSize2D::new(width, height)), - framebuffer: TypedSize2D::new(fb_width, fb_height), + viewport: Rect::new(Point2D::new(x, y), Size2D::new(width, height)), + framebuffer: Size2D::new(fb_width, fb_height), } } } @@ -324,13 +324,9 @@ impl ServoGlue { /// x/y are scroll coordinates. /// dx/dy are scroll deltas. pub fn scroll_start(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> { - let delta = TypedVector2D::new(dx, dy); + let delta = Vector2D::new(dx, dy); let scroll_location = ScrollLocation::Delta(delta); - let event = WindowEvent::Scroll( - scroll_location, - TypedPoint2D::new(x, y), - TouchEventType::Down, - ); + let event = WindowEvent::Scroll(scroll_location, Point2D::new(x, y), TouchEventType::Down); self.process_event(event) } @@ -338,13 +334,9 @@ impl ServoGlue { /// x/y are scroll coordinates. /// dx/dy are scroll deltas. pub fn scroll(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> { - let delta = TypedVector2D::new(dx, dy); + let delta = Vector2D::new(dx, dy); let scroll_location = ScrollLocation::Delta(delta); - let event = WindowEvent::Scroll( - scroll_location, - TypedPoint2D::new(x, y), - TouchEventType::Move, - ); + let event = WindowEvent::Scroll(scroll_location, Point2D::new(x, y), TouchEventType::Move); self.process_event(event) } @@ -352,10 +344,9 @@ impl ServoGlue { /// x/y are scroll coordinates. /// dx/dy are scroll deltas. pub fn scroll_end(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> { - let delta = TypedVector2D::new(dx, dy); + let delta = Vector2D::new(dx, dy); let scroll_location = ScrollLocation::Delta(delta); - let event = - WindowEvent::Scroll(scroll_location, TypedPoint2D::new(x, y), TouchEventType::Up); + let event = WindowEvent::Scroll(scroll_location, Point2D::new(x, y), TouchEventType::Up); self.process_event(event) } @@ -364,7 +355,7 @@ impl ServoGlue { let event = WindowEvent::Touch( TouchEventType::Down, TouchId(pointer_id), - TypedPoint2D::new(x as f32, y as f32), + Point2D::new(x as f32, y as f32), ); self.process_event(event) } @@ -374,7 +365,7 @@ impl ServoGlue { let event = WindowEvent::Touch( TouchEventType::Move, TouchId(pointer_id), - TypedPoint2D::new(x as f32, y as f32), + Point2D::new(x as f32, y as f32), ); self.process_event(event) } @@ -384,7 +375,7 @@ impl ServoGlue { let event = WindowEvent::Touch( TouchEventType::Up, TouchId(pointer_id), - TypedPoint2D::new(x as f32, y as f32), + Point2D::new(x as f32, y as f32), ); self.process_event(event) } @@ -394,28 +385,28 @@ impl ServoGlue { let event = WindowEvent::Touch( TouchEventType::Cancel, TouchId(pointer_id), - TypedPoint2D::new(x as f32, y as f32), + Point2D::new(x as f32, y as f32), ); self.process_event(event) } /// Register a mouse movement. pub fn move_mouse(&mut self, x: f32, y: f32) -> Result<(), &'static str> { - let point = TypedPoint2D::new(x, y); + let point = Point2D::new(x, y); let event = WindowEvent::MouseWindowMoveEventClass(point); self.process_event(event) } /// Register a mouse button press. pub fn mouse_down(&mut self, x: f32, y: f32, button: MouseButton) -> Result<(), &'static str> { - let point = TypedPoint2D::new(x, y); + let point = Point2D::new(x, y); let event = WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseDown(button, point)); self.process_event(event) } /// Register a mouse button release. pub fn mouse_up(&mut self, x: f32, y: f32, button: MouseButton) -> Result<(), &'static str> { - let point = TypedPoint2D::new(x, y); + let point = Point2D::new(x, y); let event = WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseUp(button, point)); self.process_event(event) } @@ -440,7 +431,7 @@ impl ServoGlue { /// Perform a click. pub fn click(&mut self, x: f32, y: f32) -> Result<(), &'static str> { - let mouse_event = MouseWindowEvent::Click(MouseButton::Left, TypedPoint2D::new(x, y)); + let mouse_event = MouseWindowEvent::Click(MouseButton::Left, Point2D::new(x, y)); let event = WindowEvent::MouseWindowEventClass(mouse_event); self.process_event(event) } @@ -647,10 +638,10 @@ impl WindowMethods for ServoWindowCallbacks { EmbedderCoordinates { viewport: coords.viewport, framebuffer: coords.framebuffer, - window: (coords.viewport.size, TypedPoint2D::new(0, 0)), + window: (coords.viewport.size, Point2D::new(0, 0)), screen: coords.viewport.size, screen_avail: coords.viewport.size, - hidpi_factor: TypedScale::new(self.density), + hidpi_factor: Scale::new(self.density), } } diff --git a/servo-tidy.toml b/servo-tidy.toml index ff8a2ac55e5..4dd6e71ef20 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -33,6 +33,7 @@ rand = [ # Ignored packages with duplicated versions packages = [ "crossbeam-deque", + "euclid", # https://github.com/servo/rust-webvr/pull/89 "gl_generator", # https://github.com/servo/servo/pull/23288#issuecomment-494687746 "lock_api", "nix", # https://github.com/servo/servo/issues/23189#issuecomment-487512605 diff --git a/tests/unit/script/Cargo.toml b/tests/unit/script/Cargo.toml index e772e776bc5..3194bc35ddc 100644 --- a/tests/unit/script/Cargo.toml +++ b/tests/unit/script/Cargo.toml @@ -10,7 +10,7 @@ name = "script_tests" path = "lib.rs" [dependencies] -euclid = "0.19" +euclid = "0.20" keyboard-types = "0.4.3" script = {path = "../../../components/script"} servo_url = {path = "../../../components/url"} diff --git a/tests/unit/style/Cargo.toml b/tests/unit/style/Cargo.toml index b339ed48c52..06e9d2cfd1a 100644 --- a/tests/unit/style/Cargo.toml +++ b/tests/unit/style/Cargo.toml @@ -13,7 +13,7 @@ doctest = false byteorder = "1.0" app_units = "0.7" cssparser = "0.25" -euclid = "0.19" +euclid = "0.20" html5ever = "0.23" rayon = "1" serde_json = "1.0" diff --git a/tests/unit/style/parsing/mod.rs b/tests/unit/style/parsing/mod.rs index aff8d1fc47c..ce4f7a0f600 100644 --- a/tests/unit/style/parsing/mod.rs +++ b/tests/unit/style/parsing/mod.rs @@ -36,27 +36,6 @@ where f(&context, &mut parser) } -fn parse_entirely<T, F>(f: F, s: &'static str) -> Result<T, ParseError<'static>> -where - F: for<'t> Fn(&ParserContext, &mut Parser<'static, 't>) -> Result<T, ParseError<'static>>, -{ - let mut input = ParserInput::new(s); - parse_entirely_input(f, &mut input) -} - -fn parse_entirely_input<'i: 't, 't, T, F>( - f: F, - input: &'t mut ParserInput<'i>, -) -> Result<T, ParseError<'i>> -where - F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>, -{ - parse_input( - |context, parser| parser.parse_entirely(|p| f(context, p)), - input, - ) -} - // This is a macro so that the file/line information // is preserved in the panic macro_rules! assert_roundtrip_with_context { @@ -141,7 +120,6 @@ mod effects; mod image; mod inherited_text; mod outline; -mod position; mod selectors; mod supports; mod text_overflow; diff --git a/tests/unit/style/parsing/position.rs b/tests/unit/style/parsing/position.rs deleted file mode 100644 index f5cf442afdb..00000000000 --- a/tests/unit/style/parsing/position.rs +++ /dev/null @@ -1,145 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -use crate::parsing::{parse, parse_entirely}; -use style::parser::Parse; -use style::values::specified::position::*; -use style_traits::ToCss; - -#[test] -fn test_position() { - // Serialization is not actually specced - // though these are the values expected by basic-shape - // https://github.com/w3c/csswg-drafts/issues/368 - assert_roundtrip_with_context!(Position::parse, "center", "center center"); - assert_roundtrip_with_context!(Position::parse, "top left", "left top"); - assert_roundtrip_with_context!(Position::parse, "left top", "left top"); - assert_roundtrip_with_context!(Position::parse, "top right", "right top"); - assert_roundtrip_with_context!(Position::parse, "right top", "right top"); - assert_roundtrip_with_context!(Position::parse, "bottom left", "left bottom"); - assert_roundtrip_with_context!(Position::parse, "left bottom", "left bottom"); - assert_roundtrip_with_context!(Position::parse, "left center", "left center"); - assert_roundtrip_with_context!(Position::parse, "right center", "right center"); - assert_roundtrip_with_context!(Position::parse, "center top", "center top"); - assert_roundtrip_with_context!(Position::parse, "center bottom", "center bottom"); - assert_roundtrip_with_context!(Position::parse, "center 10px", "center 10px"); - assert_roundtrip_with_context!(Position::parse, "center 10%", "center 10%"); - assert_roundtrip_with_context!(Position::parse, "right 10%", "right 10%"); - - // Only keywords can be reordered - assert!(parse_entirely(Position::parse, "top 40%").is_err()); - assert!(parse_entirely(Position::parse, "40% left").is_err()); - - // 3 and 4 value serialization - assert_roundtrip_with_context!(Position::parse, "left 10px top 15px", "left 10px top 15px"); - assert_roundtrip_with_context!(Position::parse, "top 15px left 10px", "left 10px top 15px"); - assert_roundtrip_with_context!(Position::parse, "left 10% top 15px", "left 10% top 15px"); - assert_roundtrip_with_context!(Position::parse, "top 15px left 10%", "left 10% top 15px"); - assert_roundtrip_with_context!(Position::parse, "left top 15px", "left top 15px"); - assert_roundtrip_with_context!(Position::parse, "top 15px left", "left top 15px"); - assert_roundtrip_with_context!(Position::parse, "left 10px top", "left 10px top"); - assert_roundtrip_with_context!(Position::parse, "top left 10px", "left 10px top"); - assert_roundtrip_with_context!(Position::parse, "right 10px bottom", "right 10px bottom"); - assert_roundtrip_with_context!(Position::parse, "bottom right 10px", "right 10px bottom"); - assert_roundtrip_with_context!(Position::parse, "center right 10px", "right 10px center"); - assert_roundtrip_with_context!(Position::parse, "center bottom 10px", "center bottom 10px"); - - // Invalid 3 value positions - assert!(parse_entirely(Position::parse, "20px 30px 20px").is_err()); - assert!(parse_entirely(Position::parse, "top 30px 20px").is_err()); - assert!(parse_entirely(Position::parse, "50% bottom 20%").is_err()); - - // Only horizontal and vertical keywords can have positions - assert!(parse_entirely(Position::parse, "center 10px left 15px").is_err()); - assert!(parse_entirely(Position::parse, "center 10px 15px").is_err()); - assert!(parse_entirely(Position::parse, "center 10px bottom").is_err()); - - // "Horizontal Horizontal" or "Vertical Vertical" positions cause error - assert!(parse_entirely(Position::parse, "left right").is_err()); - assert!(parse_entirely(Position::parse, "left 10px right").is_err()); - assert!(parse_entirely(Position::parse, "left 10px right 15%").is_err()); - assert!(parse_entirely(Position::parse, "top bottom").is_err()); - assert!(parse_entirely(Position::parse, "top 10px bottom").is_err()); - assert!(parse_entirely(Position::parse, "top 10px bottom 15%").is_err()); - - // Logical keywords are not supported in Position yet. - assert!(parse(Position::parse, "x-start").is_err()); - assert!(parse(Position::parse, "y-end").is_err()); - assert!(parse(Position::parse, "x-start y-end").is_err()); - assert!(parse(Position::parse, "x-end 10px").is_err()); - assert!(parse(Position::parse, "y-start 20px").is_err()); - assert!(parse(Position::parse, "x-start bottom 10%").is_err()); - assert!(parse_entirely(Position::parse, "left y-start 10%").is_err()); - assert!(parse(Position::parse, "x-start 20px y-end 10%").is_err()); -} - -#[test] -fn test_horizontal_position() { - // One value serializations. - assert_roundtrip_with_context!(HorizontalPosition::parse, "20px", "20px"); - assert_roundtrip_with_context!(HorizontalPosition::parse, "25%", "25%"); - assert_roundtrip_with_context!(HorizontalPosition::parse, "center", "center"); - assert_roundtrip_with_context!(HorizontalPosition::parse, "left", "left"); - assert_roundtrip_with_context!(HorizontalPosition::parse, "right", "right"); - - // Two value serializations. - assert_roundtrip_with_context!(HorizontalPosition::parse, "right 10px", "right 10px"); - - // Invalid horizontal positions. - assert!(parse(HorizontalPosition::parse, "top").is_err()); - assert!(parse(HorizontalPosition::parse, "bottom").is_err()); - assert!(parse(HorizontalPosition::parse, "y-start").is_err()); - assert!(parse(HorizontalPosition::parse, "y-end").is_err()); - assert!(parse(HorizontalPosition::parse, "y-end 20px ").is_err()); - assert!(parse(HorizontalPosition::parse, "bottom 20px").is_err()); - assert!(parse(HorizontalPosition::parse, "bottom top").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "20px y-end").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "20px top").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "left center").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "left top").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "left right").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "20px 30px").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "10px left").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "x-end 20%").is_err()); - assert!(parse_entirely(HorizontalPosition::parse, "20px x-start").is_err()); - - // Logical keywords are not supported in Position yet. - assert!(parse(HorizontalPosition::parse, "x-start").is_err()); - assert!(parse(HorizontalPosition::parse, "x-end").is_err()); -} - -#[test] -fn test_vertical_position() { - // One value serializations. - assert_roundtrip_with_context!(VerticalPosition::parse, "20px", "20px"); - assert_roundtrip_with_context!(VerticalPosition::parse, "25%", "25%"); - assert_roundtrip_with_context!(VerticalPosition::parse, "center", "center"); - assert_roundtrip_with_context!(VerticalPosition::parse, "top", "top"); - assert_roundtrip_with_context!(VerticalPosition::parse, "bottom", "bottom"); - - // Two value serializations. - assert_roundtrip_with_context!(VerticalPosition::parse, "bottom 10px", "bottom 10px"); - - // Invalid vertical positions. - assert!(parse(VerticalPosition::parse, "left").is_err()); - assert!(parse(VerticalPosition::parse, "right").is_err()); - assert!(parse(VerticalPosition::parse, "x-start").is_err()); - assert!(parse(VerticalPosition::parse, "x-end").is_err()); - assert!(parse(VerticalPosition::parse, "x-end 20px").is_err()); - assert!(parse(VerticalPosition::parse, "left 20px").is_err()); - assert!(parse(VerticalPosition::parse, "left center").is_err()); - assert!(parse(VerticalPosition::parse, "left top").is_err()); - assert!(parse(VerticalPosition::parse, "left right").is_err()); - assert!(parse_entirely(VerticalPosition::parse, "20px x-end").is_err()); - assert!(parse_entirely(VerticalPosition::parse, "20px right").is_err()); - assert!(parse_entirely(VerticalPosition::parse, "bottom top").is_err()); - assert!(parse_entirely(VerticalPosition::parse, "20px 30px").is_err()); - assert!(parse_entirely(VerticalPosition::parse, "10px top").is_err()); - assert!(parse_entirely(VerticalPosition::parse, "y-end 20%").is_err()); - assert!(parse_entirely(VerticalPosition::parse, "20px y-start").is_err()); - - // Logical keywords are not supported in Position yet. - assert!(parse(VerticalPosition::parse, "y-start").is_err()); - assert!(parse(VerticalPosition::parse, "y-end").is_err()); -} diff --git a/tests/unit/style/stylist.rs b/tests/unit/style/stylist.rs index ce247229740..0d7511f0583 100644 --- a/tests/unit/style/stylist.rs +++ b/tests/unit/style/stylist.rs @@ -3,8 +3,8 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use cssparser::SourceLocation; -use euclid::TypedScale; -use euclid::TypedSize2D; +use euclid::Scale; +use euclid::Size2D; use selectors::parser::{AncestorHashes, Selector}; use servo_arc::Arc; use servo_atoms::Atom; @@ -214,8 +214,8 @@ fn test_insert() { fn mock_stylist() -> Stylist { let device = Device::new( MediaType::screen(), - TypedSize2D::new(0f32, 0f32), - TypedScale::new(1.0), + Size2D::new(0f32, 0f32), + Scale::new(1.0), ); Stylist::new(device, QuirksMode::NoQuirks) } diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs index 23e6c05dc25..636a6321d89 100644 --- a/tests/unit/style/viewport.rs +++ b/tests/unit/style/viewport.rs @@ -3,8 +3,8 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use cssparser::{Parser, ParserInput}; -use euclid::TypedScale; -use euclid::TypedSize2D; +use euclid::Scale; +use euclid::Size2D; use servo_arc::Arc; use servo_config::set_pref; use servo_url::ServoUrl; @@ -113,8 +113,8 @@ macro_rules! viewport_length { fn empty_viewport_rule() { let device = Device::new( MediaType::screen(), - TypedSize2D::new(800., 600.), - TypedScale::new(1.0), + Size2D::new(800., 600.), + Scale::new(1.0), ); test_viewport_rule("@viewport {}", &device, |declarations, css| { @@ -140,8 +140,8 @@ macro_rules! assert_decl_eq { fn simple_viewport_rules() { let device = Device::new( MediaType::screen(), - TypedSize2D::new(800., 600.), - TypedScale::new(1.0), + Size2D::new(800., 600.), + Scale::new(1.0), ); test_viewport_rule( @@ -308,8 +308,8 @@ fn simple_meta_viewport_contents() { fn cascading_within_viewport_rule() { let device = Device::new( MediaType::screen(), - TypedSize2D::new(800., 600.), - TypedScale::new(1.0), + Size2D::new(800., 600.), + Scale::new(1.0), ); // normal order of appearance @@ -448,8 +448,8 @@ fn multiple_stylesheets_cascading() { set_pref!(layout.viewport.enabled, true); let device = Device::new( MediaType::screen(), - TypedSize2D::new(800., 600.), - TypedScale::new(1.0), + Size2D::new(800., 600.), + Scale::new(1.0), ); let shared_lock = SharedRwLock::new(); let stylesheets = vec![ @@ -538,8 +538,8 @@ fn constrain_viewport() { }; } - let initial_viewport = TypedSize2D::new(800., 600.); - let device = Device::new(MediaType::screen(), initial_viewport, TypedScale::new(1.0)); + let initial_viewport = Size2D::new(800., 600.); + let device = Device::new(MediaType::screen(), initial_viewport, Scale::new(1.0)); let mut input = ParserInput::new(""); assert_eq!( ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks), @@ -596,13 +596,13 @@ fn constrain_viewport() { }) ); - let initial_viewport = TypedSize2D::new(200., 150.); - let device = Device::new(MediaType::screen(), initial_viewport, TypedScale::new(1.0)); + let initial_viewport = Size2D::new(200., 150.); + let device = Device::new(MediaType::screen(), initial_viewport, Scale::new(1.0)); let mut input = ParserInput::new("width: 320px auto"); assert_eq!( ViewportConstraints::maybe_new(&device, from_css!(input), QuirksMode::NoQuirks), Some(ViewportConstraints { - size: TypedSize2D::new(320., 240.), + size: Size2D::new(320., 240.), initial_zoom: PinchZoomFactor::new(1.), min_zoom: None, diff --git a/tests/wpt/metadata/css/css-color/parsing/opacity-computed.html.ini b/tests/wpt/metadata/css/css-color/parsing/opacity-computed.html.ini deleted file mode 100644 index 398af5e3762..00000000000 --- a/tests/wpt/metadata/css/css-color/parsing/opacity-computed.html.ini +++ /dev/null @@ -1,7 +0,0 @@ -[opacity-computed.html] - [Property opacity value '-100%' computes to '0'] - expected: FAIL - - [Property opacity value '50%' computes to '0.5'] - expected: FAIL - diff --git a/tests/wpt/metadata/css/css-color/parsing/opacity-valid.html.ini b/tests/wpt/metadata/css/css-color/parsing/opacity-valid.html.ini deleted file mode 100644 index 746de358048..00000000000 --- a/tests/wpt/metadata/css/css-color/parsing/opacity-valid.html.ini +++ /dev/null @@ -1,10 +0,0 @@ -[opacity-valid.html] - [e.style['opacity'\] = "300%" should set the property value] - expected: FAIL - - [e.style['opacity'\] = "50%" should set the property value] - expected: FAIL - - [e.style['opacity'\] = "-100%" should set the property value] - expected: FAIL - diff --git a/tests/wpt/metadata/css/css-images/parsing/gradient-position-invalid.html.ini b/tests/wpt/metadata/css/css-images/parsing/gradient-position-invalid.html.ini deleted file mode 100644 index 3b7cc7d1d16..00000000000 --- a/tests/wpt/metadata/css/css-images/parsing/gradient-position-invalid.html.ini +++ /dev/null @@ -1,25 +0,0 @@ -[gradient-position-invalid.html] - [e.style['background-image'\] = "radial-gradient(at center left 1px, red, blue)" should not set the property value] - expected: FAIL - - [e.style['background-image'\] = "radial-gradient(at center top 2px, red, blue)" should not set the property value] - expected: FAIL - - [e.style['background-image'\] = "radial-gradient(at right 3% center, red, blue)" should not set the property value] - expected: FAIL - - [e.style['background-image'\] = "radial-gradient(at left 4px top, red, blue)" should not set the property value] - expected: FAIL - - [e.style['background-image'\] = "radial-gradient(at right top 5px, red, blue)" should not set the property value] - expected: FAIL - - [e.style['background-image'\] = "radial-gradient(at bottom 6% center, red, blue)" should not set the property value] - expected: FAIL - - [e.style['background-image'\] = "radial-gradient(at bottom 7% left, red, blue)" should not set the property value] - expected: FAIL - - [e.style['background-image'\] = "radial-gradient(at bottom right 8%, red, blue)" should not set the property value] - expected: FAIL - diff --git a/tests/wpt/metadata/css/css-transforms/parsing/perspective-origin-parsing-invalid.html.ini b/tests/wpt/metadata/css/css-transforms/parsing/perspective-origin-parsing-invalid.html.ini deleted file mode 100644 index 0dd0ca7f244..00000000000 --- a/tests/wpt/metadata/css/css-transforms/parsing/perspective-origin-parsing-invalid.html.ini +++ /dev/null @@ -1,25 +0,0 @@ -[perspective-origin-parsing-invalid.html] - [e.style['perspective-origin'\] = "center left 1px" should not set the property value] - expected: FAIL - - [e.style['perspective-origin'\] = "center top 2px" should not set the property value] - expected: FAIL - - [e.style['perspective-origin'\] = "right 3% center" should not set the property value] - expected: FAIL - - [e.style['perspective-origin'\] = "left 4px top" should not set the property value] - expected: FAIL - - [e.style['perspective-origin'\] = "right top 5px" should not set the property value] - expected: FAIL - - [e.style['perspective-origin'\] = "bottom 6% center" should not set the property value] - expected: FAIL - - [e.style['perspective-origin'\] = "bottom 7% left" should not set the property value] - expected: FAIL - - [e.style['perspective-origin'\] = "bottom right 8%" should not set the property value] - expected: FAIL - |