diff options
-rw-r--r-- | Cargo.lock | 576 | ||||
-rw-r--r-- | components/canvas/Cargo.toml | 4 | ||||
-rw-r--r-- | components/servo/Cargo.toml | 2 | ||||
-rw-r--r-- | components/webrender_surfman/Cargo.toml | 4 | ||||
-rw-r--r-- | ports/gstplugin/Cargo.toml | 4 | ||||
-rw-r--r-- | ports/gstplugin/servowebsrc.rs | 4 | ||||
-rw-r--r-- | ports/libsimpleservo/api/Cargo.toml | 2 | ||||
-rw-r--r-- | ports/libsimpleservo/capi/Cargo.toml | 2 | ||||
-rw-r--r-- | ports/winit/Cargo.toml | 4 | ||||
-rw-r--r-- | ports/winit/app.rs | 198 | ||||
-rw-r--r-- | ports/winit/embedder.rs | 11 | ||||
-rw-r--r-- | ports/winit/events_loop.rs | 90 | ||||
-rw-r--r-- | ports/winit/headed_window.rs | 258 | ||||
-rw-r--r-- | ports/winit/headless_window.rs | 13 | ||||
-rw-r--r-- | ports/winit/keyutils.rs | 18 | ||||
-rw-r--r-- | ports/winit/window_trait.rs | 11 | ||||
-rw-r--r-- | servo-tidy.toml | 11 | ||||
-rw-r--r-- | tests/wpt/metadata-layout-2020/css/css-flexbox/flexible-order.html.ini | 2 |
18 files changed, 683 insertions, 531 deletions
diff --git a/Cargo.lock b/Cargo.lock index 029cf147954..7994a8971aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,6 +3,12 @@ version = 3 [[package]] +name = "ab_glyph_rasterizer" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9fe5e32de01730eb1f6b7f5b51c17e03e2325bf40a74f754f04f130043affff" + +[[package]] name = "accountable-refcell" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -58,12 +64,11 @@ dependencies = [ [[package]] name = "andrew" -version = "0.2.1" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e" +checksum = "8c4afb09dd642feec8408e33f92f3ffc4052946f6b20f32fb99c1f58cd4fa7cf" dependencies = [ "bitflags", - "line_drawing", "rusttype", "walkdir", "xdg", @@ -71,12 +76,6 @@ dependencies = [ ] [[package]] -name = "android_glue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" - -[[package]] name = "android_injected_glue" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -126,15 +125,6 @@ dependencies = [ ] [[package]] -name = "approx" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f71f10b5c4946a64aad7b8cf65e3406cd3da22fc448595991d22423cf6db67b4" -dependencies = [ - "num-traits", -] - -[[package]] name = "array-init" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -224,7 +214,7 @@ dependencies = [ "log", "mach", "msg", - "nix", + "nix 0.14.1", "serde_json", "unwind-sys", ] @@ -290,8 +280,8 @@ dependencies = [ "lazycell", "log", "peeking_take_while", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "regex", "rustc-hash", "shlex", @@ -535,6 +525,16 @@ dependencies = [ ] [[package]] +name = "calloop" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b036167e76041694579972c28cf4877b4f92da222560ddb49008937b6a6727c" +dependencies = [ + "log", + "nix 0.18.0", +] + +[[package]] name = "canvas" version = "0.0.1" dependencies = [ @@ -604,8 +604,8 @@ dependencies = [ "clap", "heck", "log", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "serde", "serde_json", "syn", @@ -634,7 +634,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" dependencies = [ - "nom", + "nom 5.1.2", ] [[package]] @@ -695,7 +695,7 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", @@ -752,9 +752,9 @@ dependencies = [ [[package]] name = "cocoa" -version = "0.18.5" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54" +checksum = "f29f7768b2d1be17b96158e3285951d366b40211320fb30826a76cb7a0da6400" dependencies = [ "bitflags", "block", @@ -767,14 +767,14 @@ dependencies = [ [[package]] name = "cocoa" -version = "0.19.1" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29f7768b2d1be17b96158e3285951d366b40211320fb30826a76cb7a0da6400" +checksum = "8f7b6f3f7f4f0b3ec5c5039aaa9e8c3cef97a7a480a400fd62944841314f293d" dependencies = [ "bitflags", "block", - "core-foundation 0.6.4", - "core-graphics 0.17.3", + "core-foundation 0.7.0", + "core-graphics 0.19.0", "foreign-types", "libc", "objc", @@ -782,14 +782,15 @@ dependencies = [ [[package]] name = "cocoa" -version = "0.20.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7b6f3f7f4f0b3ec5c5039aaa9e8c3cef97a7a480a400fd62944841314f293d" +checksum = "6f63902e9223530efb4e26ccd0cf55ec30d592d3b42e21a28defc42a9586e832" dependencies = [ "bitflags", "block", - "core-foundation 0.7.0", - "core-graphics 0.19.0", + "cocoa-foundation", + "core-foundation 0.9.0", + "core-graphics 0.22.0", "foreign-types", "libc", "objc", @@ -1053,6 +1054,19 @@ dependencies = [ ] [[package]] +name = "core-video-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828" +dependencies = [ + "cfg-if 0.1.10", + "core-foundation-sys 0.7.0", + "core-graphics 0.19.0", + "libc", + "objc", +] + +[[package]] name = "cpuid-bool" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1182,8 +1196,8 @@ dependencies = [ "itoa", "matches", "phf", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "serde", "smallvec 1.6.1", "syn", @@ -1195,7 +1209,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e" dependencies = [ - "quote 1.0.2", + "quote", "syn", ] @@ -1248,8 +1262,9 @@ checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", + "strsim 0.9.3", "syn", ] @@ -1260,7 +1275,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core", - "quote 1.0.2", + "quote", "syn", ] @@ -1309,12 +1324,23 @@ dependencies = [ ] [[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "derive_common" version = "0.0.1" dependencies = [ "darling", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", "synstructure", ] @@ -1325,8 +1351,8 @@ version = "0.99.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2127768764f1556535c01b5326ef94bd60ff08dcfbdc544d53e69ed155610f5d" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -1420,6 +1446,12 @@ dependencies = [ ] [[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] name = "display-link" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1441,10 +1473,19 @@ dependencies = [ ] [[package]] +name = "dlib" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" +dependencies = [ + "libloading 0.7.0", +] + +[[package]] name = "dom_struct" version = "0.0.1" dependencies = [ - "quote 1.0.2", + "quote", "syn", ] @@ -1452,8 +1493,8 @@ dependencies = [ name = "domobject_derive" version = "0.0.1" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -1558,8 +1599,8 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df9d0cef4b051baf3ef7f9b1674273dc78cd56e02cba60fa187f9c0ff4ff5e0" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -1843,8 +1884,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -2677,8 +2718,8 @@ dependencies = [ "log", "mac", "markup5ever", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -2998,7 +3039,7 @@ dependencies = [ name = "jstraceable_derive" version = "0.0.1" dependencies = [ - "proc-macro2 1.0.24", + "proc-macro2", "syn", "synstructure", ] @@ -3235,9 +3276,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.76" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3" +checksum = "265d751d31d6780a3f956bb5b8022feba2d94eeee5a84ba64f4212eedca42213" [[package]] name = "libdbus-sys" @@ -3280,6 +3321,16 @@ dependencies = [ ] [[package]] +name = "libloading" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +dependencies = [ + "cfg-if 1.0.0", + "winapi", +] + +[[package]] name = "libmlservo" version = "0.0.1" dependencies = [ @@ -3363,15 +3414,6 @@ dependencies = [ ] [[package]] -name = "line_drawing" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" -dependencies = [ - "num-traits", -] - -[[package]] name = "linked-hash-map" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3512,7 +3554,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" dependencies = [ - "proc-macro2 1.0.24", + "proc-macro2", "syn", "synstructure", ] @@ -3577,13 +3619,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] -name = "memmap" -version = "0.7.0" +name = "memmap2" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +checksum = "d9b70ca2a6103ac8b665dc150b142ef0e4e89df640c9e6cf295d189c3caebe5a" dependencies = [ "libc", - "winapi", ] [[package]] @@ -3871,6 +3912,51 @@ dependencies = [ ] [[package]] +name = "ndk" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb167c1febed0a496639034d0c76b3b74263636045db5489eee52143c246e73" +dependencies = [ + "jni-sys", + "ndk-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "ndk-glue" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf399b8b7a39c6fb153c4ec32c72fd5fe789df24a647f229c239aa7adb15241" +dependencies = [ + "lazy_static", + "libc", + "log", + "ndk", + "ndk-macro", + "ndk-sys", +] + +[[package]] +name = "ndk-macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d1c6307dc424d0f65b9b06e94f88248e6305726b14729fd67a5e47b2dc481d" +dependencies = [ + "darling", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ndk-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c44922cb3dbb1c70b5e5f443d63b64363a898564d739ba5198e3a9138442868d" + +[[package]] name = "net" version = "0.0.1" dependencies = [ @@ -3990,6 +4076,30 @@ dependencies = [ ] [[package]] +name = "nix" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" +dependencies = [ + "bitflags", + "cc", + "cfg-if 0.1.10", + "libc", +] + +[[package]] +name = "nix" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a" +dependencies = [ + "bitflags", + "cc", + "cfg-if 1.0.0", + "libc", +] + +[[package]] name = "nodrop" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4006,6 +4116,16 @@ dependencies = [ ] [[package]] +name = "nom" +version = "6.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" +dependencies = [ + "memchr", + "version_check", +] + +[[package]] name = "num-complex" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4021,8 +4141,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -4089,10 +4209,32 @@ dependencies = [ ] [[package]] +name = "num_enum" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca565a7df06f3d4b485494f25ba05da1435950f4dc263440eda7a6fa9b8e36e4" +dependencies = [ + "derivative", + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "objc" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" dependencies = [ "malloc_buf", "objc_exception", @@ -4205,21 +4347,21 @@ dependencies = [ ] [[package]] -name = "ordered-float" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" -dependencies = [ - "num-traits", -] - -[[package]] name = "ordermap" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" [[package]] +name = "owned_ttf_parser" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f923fb806c46266c02ab4a5b239735c144bdeda724a50ed058e5226f594cde3" +dependencies = [ + "ttf-parser", +] + +[[package]] name = "owning_ref" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4321,8 +4463,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4214c9e912ef61bf42b81ba9a47e8aad1b2ffaf739ab162bf96d1e011f54e6c5" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -4359,11 +4501,11 @@ name = "peek-poke-derive" version = "0.2.1" source = "git+https://github.com/jdm/webrender?branch=crash-backtrace#920168aff79a7cf52980b0c90965a591f2f4204a" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", "synstructure", - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -4438,8 +4580,8 @@ dependencies = [ "phf_generator", "phf_shared", "proc-macro-hack", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -4476,8 +4618,8 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -4487,8 +4629,8 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -4563,6 +4705,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] name = "proc-macro-hack" version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4576,20 +4727,11 @@ checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" [[package]] name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -4656,20 +4798,11 @@ dependencies = [ [[package]] name = "quote" -version = "0.6.13" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -dependencies = [ - "proc-macro2 1.0.24", + "proc-macro2", ] [[package]] @@ -4934,14 +5067,12 @@ dependencies = [ [[package]] name = "rusttype" -version = "0.7.2" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8eb11f5b0a98c8eca2fb1483f42646d8c340e83e46ab416f8a063a0fd0eeb20" +checksum = "dc7c727aded0be18c5b80c1640eae0ac8e396abf6fa8477d96cb37d18ee5ec59" dependencies = [ - "approx", - "arrayvec 0.4.12", - "ordered-float", - "stb_truetype", + "ab_glyph_rasterizer", + "owned_ttf_parser", ] [[package]] @@ -5259,8 +5390,8 @@ version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -5577,8 +5708,8 @@ name = "servo_config_plugins" version = "0.0.1" dependencies = [ "itertools", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -5598,8 +5729,8 @@ name = "servo_media_derive" version = "0.1.0" source = "git+https://github.com/servo/media#b23e72285ecbe352737eafa4100e65763cc9ccfc" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -5797,18 +5928,20 @@ dependencies = [ [[package]] name = "smithay-client-toolkit" -version = "0.4.6" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccb8c57049b2a34d2cc2b203fa785020ba0129d31920ef0d317430adaf748fa" +checksum = "316e13a3eb853ce7bf72ad3530dc186cb2005c57c521ef5f4ada5ee4eed74de6" dependencies = [ "andrew", "bitflags", - "dlib", + "calloop", + "dlib 0.4.2", "lazy_static", - "memmap", - "nix", + "log", + "memmap2", + "nix 0.18.0", "wayland-client", - "wayland-commons", + "wayland-cursor", "wayland-protocols", ] @@ -5867,15 +6000,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" [[package]] -name = "stb_truetype" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fa7d3136d8645909de1f7c7eb5416cc43057a75ace08fc39ae736bc9da8af1" -dependencies = [ - "byteorder", -] - -[[package]] name = "std_test_override" version = "0.0.1" dependencies = [ @@ -5921,8 +6045,8 @@ checksum = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97" dependencies = [ "phf_generator", "phf_shared", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", ] [[package]] @@ -5932,6 +6056,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] +name = "strsim" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" + +[[package]] name = "style" version = "0.0.1" dependencies = [ @@ -5995,8 +6125,8 @@ version = "0.0.1" dependencies = [ "darling", "derive_common", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", "synstructure", ] @@ -6045,9 +6175,9 @@ dependencies = [ [[package]] name = "surfman" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d85bf0eb91b66b93dda5c04627f00074ea1fa008c2980b132a065fafe7a1ab" +checksum = "84898d7f74abdd4b956334d71d1ddf60e63bff8fd2fa6c91be8653d50d30cbf3" dependencies = [ "bitflags", "cfg_aliases", @@ -6075,9 +6205,9 @@ dependencies = [ [[package]] name = "surfman-chains" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535c83982bfef221218a5546905774634ba7736a0a73cb76c5dff7735add8ec4" +checksum = "99e707090691623a80d36f4faaba50105cc7a611eda51b0312b53eeec36a0a25" dependencies = [ "euclid", "fnv", @@ -6117,9 +6247,9 @@ version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", - "unicode-xid 0.2.0", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -6128,10 +6258,10 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -6223,8 +6353,8 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -6314,8 +6444,8 @@ version = "0.0.1" dependencies = [ "darling", "derive_common", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", "synstructure", ] @@ -6430,8 +6560,8 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", ] @@ -6608,6 +6738,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" [[package]] +name = "ttf-parser" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc" + +[[package]] name = "tungstenite" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -6702,12 +6838,6 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" @@ -6852,8 +6982,8 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", "wasm-bindgen-shared", ] @@ -6864,7 +6994,7 @@ version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" dependencies = [ - "quote 1.0.2", + "quote", "wasm-bindgen-macro-support", ] @@ -6874,8 +7004,8 @@ version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.2", + "proc-macro2", + "quote", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -6889,71 +7019,85 @@ checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad" [[package]] name = "wayland-client" -version = "0.21.13" +version = "0.28.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713" +checksum = "06ca44d86554b85cf449f1557edc6cc7da935cc748c8e4bf1c507cbd43bae02c" dependencies = [ "bitflags", "downcast-rs", "libc", - "nix", + "nix 0.20.0", + "scoped-tls", "wayland-commons", "wayland-scanner", - "wayland-sys 0.21.13", + "wayland-sys 0.28.5", ] [[package]] name = "wayland-commons" -version = "0.21.13" +version = "0.28.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec" +checksum = "8bd75ae380325dbcff2707f0cd9869827ea1d2d6d534cff076858d3f0460fd5a" dependencies = [ - "nix", - "wayland-sys 0.21.13", + "nix 0.20.0", + "once_cell", + "smallvec 1.6.1", + "wayland-sys 0.28.5", +] + +[[package]] +name = "wayland-cursor" +version = "0.28.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b37e5455ec72f5de555ec39b5c3704036ac07c2ecd50d0bffe02d5fe2d4e65ab" +dependencies = [ + "nix 0.20.0", + "wayland-client", + "xcursor", ] [[package]] name = "wayland-protocols" -version = "0.21.13" +version = "0.28.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145" +checksum = "95df3317872bcf9eec096c864b69aa4769a1d5d6291a5b513f8ba0af0efbd52c" dependencies = [ "bitflags", "wayland-client", "wayland-commons", "wayland-scanner", - "wayland-sys 0.21.13", ] [[package]] name = "wayland-scanner" -version = "0.21.13" +version = "0.28.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e" +checksum = "389d680d7bd67512dc9c37f39560224327038deb0f0e8d33f870900441b68720" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", + "proc-macro2", + "quote", "xml-rs", ] [[package]] name = "wayland-sys" -version = "0.21.13" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628" +checksum = "695d1a3f30f853d3b9b530df7d9ed1c32ff9b025b5d51529827a231521f2f2e4" dependencies = [ - "dlib", + "dlib 0.4.2", "lazy_static", ] [[package]] name = "wayland-sys" -version = "0.24.0" +version = "0.28.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "695d1a3f30f853d3b9b530df7d9ed1c32ff9b025b5d51529827a231521f2f2e4" +checksum = "2907bd297eef464a95ba9349ea771611771aa285b932526c633dc94d5400a8e2" dependencies = [ - "dlib", + "dlib 0.5.0", "lazy_static", + "pkg-config", ] [[package]] @@ -7117,7 +7261,7 @@ dependencies = [ [[package]] name = "webxr" version = "0.0.1" -source = "git+https://github.com/servo/webxr#cc6af6d8f4244dd5523a2dbc1f49d5f60b054f57" +source = "git+https://github.com/servo/webxr#80700ee558b466f68f4a54cc50a9744c02cf7a42" dependencies = [ "android_injected_glue", "bindgen", @@ -7140,7 +7284,7 @@ dependencies = [ [[package]] name = "webxr-api" version = "0.0.1" -source = "git+https://github.com/servo/webxr#cc6af6d8f4244dd5523a2dbc1f49d5f60b054f57" +source = "git+https://github.com/servo/webxr#80700ee558b466f68f4a54cc50a9744c02cf7a42" dependencies = [ "euclid", "ipc-channel", @@ -7234,22 +7378,29 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winit" -version = "0.19.3" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d0da905e61ae52d55c5ca6f8bea1e09daf5e325b6c77b0947c65a5179b49f5f" +checksum = "da4eda6fce0eb84bd0a33e3c8794eb902e1033d0a1d5a31bc4f19b1b4bbff597" dependencies = [ - "android_glue", - "backtrace", "bitflags", - "cocoa 0.18.5", - "core-foundation 0.6.4", - "core-graphics 0.17.3", + "cocoa 0.24.0", + "core-foundation 0.9.0", + "core-graphics 0.22.0", + "core-video-sys", + "dispatch", + "instant", "lazy_static", "libc", "log", + "mio", + "mio-extras", + "ndk", + "ndk-glue", + "ndk-sys", "objc", - "parking_lot 0.9.0", + "parking_lot 0.11.0", "percent-encoding", + "raw-window-handle", "smithay-client-toolkit", "wayland-client", "winapi", @@ -7343,6 +7494,15 @@ dependencies = [ ] [[package]] +name = "xcursor" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9a231574ae78801646617cefd13bfe94be907c0e4fa979cfd8b770aa3c5d08" +dependencies = [ + "nom 6.1.2", +] + +[[package]] name = "xdg" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -7356,9 +7516,9 @@ checksum = "12ea8eda4b1eb72f02d148402e23832d56a33f55d8c1b2d5bcdde91d79d47cb1" [[package]] name = "xml-rs" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" +checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" [[package]] name = "xml5ever" diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index 74545af1b93..38e594d2a70 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -40,8 +40,8 @@ sparkle = "0.1.25" style = { path = "../style" } style_traits = { path = "../style_traits" } # NOTE: the sm-angle feature only enables angle on windows, not other platforms! -surfman = { version = "0.3", features = ["sm-angle","sm-angle-default"] } -surfman-chains = "0.5" +surfman = { version = "0.4", features = ["sm-angle","sm-angle-default"] } +surfman-chains = "0.6" surfman-chains-api = "0.2" time = { version = "0.1.0", optional = true } webrender = { git = "https://github.com/servo/webrender" } diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 7fc827fa387..a5f17aa70c5 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -78,7 +78,7 @@ servo_url = { path = "../url" } sparkle = "0.1" style = { path = "../style", features = ["servo"] } style_traits = { path = "../style_traits", features = ["servo"] } -surfman = "0.3" +surfman = "0.4" webdriver_server = { path = "../webdriver_server", optional = true } webgpu = { path = "../webgpu" } webrender = { git = "https://github.com/servo/webrender" } diff --git a/components/webrender_surfman/Cargo.toml b/components/webrender_surfman/Cargo.toml index 663b30be7b1..68b514db260 100644 --- a/components/webrender_surfman/Cargo.toml +++ b/components/webrender_surfman/Cargo.toml @@ -12,6 +12,6 @@ path = "lib.rs" [dependencies] euclid = "0.20" -surfman = "0.3" -surfman-chains = "0.5" +surfman = "0.4" +surfman-chains = "0.6" diff --git a/ports/gstplugin/Cargo.toml b/ports/gstplugin/Cargo.toml index 4ad10399c0d..6bc536351d4 100644 --- a/ports/gstplugin/Cargo.toml +++ b/ports/gstplugin/Cargo.toml @@ -29,8 +29,8 @@ libservo = { path = "../../components/servo" } log = "0.4" servo-media = { git = "https://github.com/servo/media" } sparkle = "0.1" -surfman = "0.3" -surfman-chains = "0.5" +surfman = "0.4" +surfman-chains = "0.6" surfman-chains-api = "0.2" webxr = { git = "https://github.com/servo/webxr", features = ["glwindow"] } diff --git a/ports/gstplugin/servowebsrc.rs b/ports/gstplugin/servowebsrc.rs index 4a8e8291b00..4ca85470228 100644 --- a/ports/gstplugin/servowebsrc.rs +++ b/ports/gstplugin/servowebsrc.rs @@ -249,7 +249,9 @@ impl ServoThread { ServoWebSrcMsg::GetSwapChain(sender) => self.send_swap_chain(sender), ServoWebSrcMsg::SetSwapChain(swap_chain) => self.swap_chain = Some(swap_chain.0), ServoWebSrcMsg::Resize(size) => self.resize(size), - ServoWebSrcMsg::Heartbeat => self.servo.handle_events(vec![]), + ServoWebSrcMsg::Heartbeat => { + self.servo.handle_events(vec![]); + } ServoWebSrcMsg::Stop => break, } } diff --git a/ports/libsimpleservo/api/Cargo.toml b/ports/libsimpleservo/api/Cargo.toml index 97e6b5e53ae..9b945d066d3 100644 --- a/ports/libsimpleservo/api/Cargo.toml +++ b/ports/libsimpleservo/api/Cargo.toml @@ -12,7 +12,7 @@ ipc-channel = "0.14" libservo = { path = "../../../components/servo" } log = "0.4" servo-media = { git = "https://github.com/servo/media" } -surfman = { version = "0.3", features = ["sm-angle-default"] } +surfman = { version = "0.4", features = ["sm-angle-default"] } webxr = { git = "https://github.com/servo/webxr"} webxr-api = { git = "https://github.com/servo/webxr", features = ["ipc"] } diff --git a/ports/libsimpleservo/capi/Cargo.toml b/ports/libsimpleservo/capi/Cargo.toml index dc3765d9b40..26a6ff47af4 100644 --- a/ports/libsimpleservo/capi/Cargo.toml +++ b/ports/libsimpleservo/capi/Cargo.toml @@ -18,7 +18,7 @@ env_logger = "0.8" lazy_static = "1" log = "0.4" simpleservo = { path = "../api" } -surfman = "0.3" +surfman = "0.4" keyboard-types = "0.5" [target.'cfg(target_os = "windows")'.dependencies] diff --git a/ports/winit/Cargo.toml b/ports/winit/Cargo.toml index 3f3247f558e..0353f05ca3b 100644 --- a/ports/winit/Cargo.toml +++ b/ports/winit/Cargo.toml @@ -57,10 +57,10 @@ libservo = { path = "../../components/servo" } log = "0.4" servo-media = { git = "https://github.com/servo/media" } shellwords = "1.0.0" -surfman = { version = "0.3", features = ["sm-winit", "sm-x11"] } +surfman = { version = "0.4", features = ["sm-winit", "sm-x11"] } tinyfiledialogs = "3.0" webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless"] } -winit = "0.19" +winit = "0.24" [target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies] image = "0.23" diff --git a/ports/winit/app.rs b/ports/winit/app.rs index 9edfd20928d..3280a3104de 100644 --- a/ports/winit/app.rs +++ b/ports/winit/app.rs @@ -6,9 +6,11 @@ use crate::browser::Browser; use crate::embedder::EmbedderCallbacks; -use crate::events_loop::EventsLoop; +use crate::events_loop::{EventsLoop, ServoEvent}; use crate::window_trait::WindowPortsMethods; use crate::{headed_window, headless_window}; +use winit::window::WindowId; +use winit::event_loop::EventLoopWindowTarget; use servo::compositing::windowing::WindowEvent; use servo::config::opts::{self, parse_url_or_filename}; use servo::servo_config::pref; @@ -20,15 +22,13 @@ use std::env; use std::mem; use std::rc::Rc; use webxr::glwindow::GlWindowDiscovery; -use winit::WindowId; thread_local! { pub static WINDOWS: RefCell<HashMap<WindowId, Rc<dyn WindowPortsMethods>>> = RefCell::new(HashMap::new()); } pub struct App { - events_loop: Rc<RefCell<EventsLoop>>, - servo: RefCell<Servo<dyn WindowPortsMethods>>, + servo: Option<Servo<dyn WindowPortsMethods>>, browser: RefCell<Browser<dyn WindowPortsMethods>>, event_queue: RefCell<Vec<WindowEvent>>, suspended: Cell<bool>, @@ -48,49 +48,96 @@ impl App { } else { Rc::new(headed_window::Window::new( opts::get().initial_window_size, - events_loop.clone(), + &events_loop, no_native_titlebar, device_pixels_per_px, )) }; - let xr_discovery = if pref!(dom.webxr.glwindow.enabled) { - let window = window.clone(); - let surfman = window.webrender_surfman(); - let events_loop = events_loop.clone(); - let factory = Box::new(move || Ok(window.new_glwindow(&*events_loop.borrow()))); - Some(GlWindowDiscovery::new( - surfman.connection(), - surfman.adapter(), - surfman.context_attributes(), - factory, - )) - } else { - None - }; - - // Implements embedder methods, used by libservo and constellation. - let embedder = Box::new(EmbedderCallbacks::new(events_loop.clone(), xr_discovery)); - // Handle browser state. let browser = Browser::new(window.clone()); - let mut servo = Servo::new(embedder, window.clone(), user_agent); - let browser_id = BrowserId::new(); - servo.handle_events(vec![WindowEvent::NewBrowser(get_default_url(), browser_id)]); - servo.setup_logging(); - - register_window(window); - - let app = App { + let mut app = App { event_queue: RefCell::new(vec![]), - events_loop, browser: RefCell::new(browser), - servo: RefCell::new(servo), + servo: None, suspended: Cell::new(false), }; - app.run_loop(); + let ev_waker = events_loop.create_event_loop_waker(); + events_loop.run_forever(move |e, w, control_flow| { + if let winit::event::Event::NewEvents(winit::event::StartCause::Init) = e { + let surfman = window.webrender_surfman(); + + let xr_discovery = if pref!(dom.webxr.glwindow.enabled) { + let window = window.clone(); + // This should be safe because run_forever does, in fact, + // run forever. The event loop window target doesn't get + // moved, and does outlast this closure, and we won't + // ever try to make use of it once shutdown begins and + // it stops being valid. + let w = unsafe { + std::mem::transmute::< + &EventLoopWindowTarget<ServoEvent>, + &'static EventLoopWindowTarget<ServoEvent> + >(w.unwrap()) + }; + let factory = Box::new(move || Ok(window.new_glwindow(w))); + Some(GlWindowDiscovery::new( + surfman.connection(), + surfman.adapter(), + surfman.context_attributes(), + factory, + )) + } else { + None + }; + + let window = window.clone(); + // Implements embedder methods, used by libservo and constellation. + let embedder = Box::new(EmbedderCallbacks::new( + ev_waker.clone(), + xr_discovery, + )); + + let mut servo = Servo::new(embedder, window.clone(), user_agent.clone()); + let browser_id = BrowserId::new(); + servo.handle_events(vec![WindowEvent::NewBrowser(get_default_url(), browser_id)]); + servo.setup_logging(); + + register_window(window.clone()); + app.servo = Some(servo); + } + + // If self.servo is None here, it means that we're in the process of shutting down, + // let's ignore events. + if app.servo.is_none() { + return; + } + + // Handle the event + app.winit_event_to_servo_event(e); + + let animating = WINDOWS.with(|windows| { + windows + .borrow() + .iter() + .any(|(_, window)| window.is_animating()) + }); + + // Block until the window gets an event + if !animating || app.suspended.get() { + *control_flow = winit::event_loop::ControlFlow::Wait; + } else { + *control_flow = winit::event_loop::ControlFlow::Poll; + } + + let stop = app.handle_events(); + if stop { + *control_flow = winit::event_loop::ControlFlow::Exit; + app.servo.take().unwrap().deinit(); + } + }); } fn get_events(&self) -> Vec<WindowEvent> { @@ -98,87 +145,50 @@ impl App { } // This function decides whether the event should be handled during `run_forever`. - fn winit_event_to_servo_event(&self, event: winit::Event) -> winit::ControlFlow { + fn winit_event_to_servo_event(&self, event: winit::event::Event<ServoEvent>) { match event { // App level events - winit::Event::Suspended(suspended) => { - self.suspended.set(suspended); - if !suspended { - self.event_queue.borrow_mut().push(WindowEvent::Idle); - } + winit::event::Event::Suspended => { + self.suspended.set(true); + }, + winit::event::Event::Resumed => { + self.suspended.set(false); + self.event_queue.borrow_mut().push(WindowEvent::Idle); }, - winit::Event::Awakened => { + winit::event::Event::UserEvent(_) => { + self.event_queue.borrow_mut().push(WindowEvent::Idle); + }, + winit::event::Event::DeviceEvent { .. } => {}, + + winit::event::Event::RedrawRequested(_) => { self.event_queue.borrow_mut().push(WindowEvent::Idle); }, - winit::Event::DeviceEvent { .. } => {}, // Window level events - winit::Event::WindowEvent { + winit::event::Event::WindowEvent { window_id, event, .. } => { return WINDOWS.with(|windows| { match windows.borrow().get(&window_id) { None => { warn!("Got an event from unknown window"); - winit::ControlFlow::Break }, Some(window) => { - // Resize events need to be handled during run_forever - let cont = if let winit::WindowEvent::Resized(_) = event { - winit::ControlFlow::Continue - } else { - winit::ControlFlow::Break - }; window.winit_event_to_servo_event(event); - return cont; }, } }); }, - } - winit::ControlFlow::Break - } - fn run_loop(self) { - loop { - let animating = WINDOWS.with(|windows| { - windows - .borrow() - .iter() - .any(|(_, window)| window.is_animating()) - }); - if !animating || self.suspended.get() { - // If there's no animations running then we block on the window event loop. - self.events_loop.borrow_mut().run_forever(|e| { - let cont = self.winit_event_to_servo_event(e); - if cont == winit::ControlFlow::Continue { - // Note we need to be careful to make sure that any events - // that are handled during run_forever aren't re-entrant, - // since we are handling them while holding onto a mutable borrow - // of the events loop - self.handle_events(); - } - cont - }); - } - // Grab any other events that may have happened - self.events_loop.borrow_mut().poll_events(|e| { - self.winit_event_to_servo_event(e); - }); - // If animations are running, we block on compositing - // (self.handle_events() ends up calling swap_buffers) - let stop = self.handle_events(); - if stop { - break; - } + winit::event::Event::LoopDestroyed | + winit::event::Event::NewEvents(..) | + winit::event::Event::MainEventsCleared | + winit::event::Event::RedrawEventsCleared => {}, } - - self.servo.into_inner().deinit() } - fn handle_events(&self) -> bool { + fn handle_events(&mut self) -> bool { let mut browser = self.browser.borrow_mut(); - let mut servo = self.servo.borrow_mut(); // FIXME: // As of now, we support only one browser (self.browser) @@ -203,21 +213,21 @@ impl App { browser.handle_window_events(app_events); - let mut servo_events = servo.get_events(); + let mut servo_events = self.servo.as_mut().unwrap().get_events(); loop { browser.handle_servo_events(servo_events); - servo.handle_events(browser.get_events()); + self.servo.as_mut().unwrap().handle_events(browser.get_events()); if browser.shutdown_requested() { return true; } - servo_events = servo.get_events(); + servo_events = self.servo.as_mut().unwrap().get_events(); if servo_events.is_empty() { break; } } if need_resize { - servo.repaint_synchronously(); + self.servo.as_mut().unwrap().repaint_synchronously(); } false } diff --git a/ports/winit/embedder.rs b/ports/winit/embedder.rs index 039f003da19..7f0c1f6034c 100644 --- a/ports/winit/embedder.rs +++ b/ports/winit/embedder.rs @@ -4,26 +4,23 @@ //! Implements the global methods required by Servo (not window/gl/compositor related). -use crate::events_loop::EventsLoop; use servo::compositing::windowing::EmbedderMethods; use servo::embedder_traits::{EmbedderProxy, EventLoopWaker}; use servo::servo_config::pref; -use std::cell::RefCell; -use std::rc::Rc; use webxr::glwindow::GlWindowDiscovery; pub struct EmbedderCallbacks { - events_loop: Rc<RefCell<EventsLoop>>, + event_loop_waker: Box<dyn EventLoopWaker>, xr_discovery: Option<GlWindowDiscovery>, } impl EmbedderCallbacks { pub fn new( - events_loop: Rc<RefCell<EventsLoop>>, + event_loop_waker: Box<dyn EventLoopWaker>, xr_discovery: Option<GlWindowDiscovery>, ) -> EmbedderCallbacks { EmbedderCallbacks { - events_loop, + event_loop_waker, xr_discovery, } } @@ -31,7 +28,7 @@ impl EmbedderCallbacks { impl EmbedderMethods for EmbedderCallbacks { fn create_event_loop_waker(&mut self) -> Box<dyn EventLoopWaker> { - self.events_loop.borrow().create_event_loop_waker() + self.event_loop_waker.clone() } fn register_webxr( diff --git a/ports/winit/events_loop.rs b/ports/winit/events_loop.rs index 5de70bd000d..97cad32d781 100644 --- a/ports/winit/events_loop.rs +++ b/ports/winit/events_loop.rs @@ -5,16 +5,19 @@ //! An event loop implementation that works in headless mode. use servo::embedder_traits::EventLoopWaker; -use std::cell::RefCell; -use std::rc::Rc; use std::sync::{Arc, Condvar, Mutex}; use std::time; use winit; +#[derive(Debug)] +pub enum ServoEvent { + Awakened, +} + #[allow(dead_code)] enum EventLoop { /// A real Winit windowing event loop. - Winit(Option<winit::EventsLoop>), + Winit(Option<winit::event_loop::EventLoop<ServoEvent>>), /// A fake event loop which contains a signalling flag used to ensure /// that pending events get processed in a timely fashion, and a condition /// variable to allow waiting on that flag changing state. @@ -27,19 +30,16 @@ impl EventsLoop { // Ideally, we could use the winit event loop in both modes, // but on Linux, the event loop requires a X11 server. #[cfg(not(target_os = "linux"))] - pub fn new(_headless: bool) -> Rc<RefCell<EventsLoop>> { - Rc::new(RefCell::new(EventsLoop(EventLoop::Winit(Some( - winit::EventsLoop::new(), - ))))) + pub fn new(_headless: bool) -> EventsLoop { + EventsLoop(EventLoop::Winit(Some(winit::event_loop::EventLoop::with_user_event()))) } #[cfg(target_os = "linux")] - pub fn new(headless: bool) -> Rc<RefCell<EventsLoop>> { - let events_loop = if headless { + pub fn new(headless: bool) -> EventsLoop { + EventsLoop(if headless { EventLoop::Headless(Arc::new((Mutex::new(false), Condvar::new()))) } else { - EventLoop::Winit(Some(winit::EventsLoop::new())) - }; - Rc::new(RefCell::new(EventsLoop(events_loop))) + EventLoop::Winit(Some(winit::event_loop::EventLoop::with_user_event())) + }) } } @@ -55,7 +55,7 @@ impl EventsLoop { EventLoop::Headless(ref data) => Box::new(HeadlessEventLoopWaker(data.clone())), } } - pub fn as_winit(&self) -> &winit::EventsLoop { + pub fn as_winit(&self) -> &winit::event_loop::EventLoop<ServoEvent> { match self.0 { EventLoop::Winit(Some(ref event_loop)) => event_loop, EventLoop::Winit(None) | EventLoop::Headless(..) => { @@ -64,49 +64,41 @@ impl EventsLoop { } } - pub fn poll_events<F>(&mut self, callback: F) - where - F: FnMut(winit::Event), - { + pub fn run_forever<F: 'static>(self, mut callback: F) + where F: FnMut( + winit::event::Event<ServoEvent>, + Option<&winit::event_loop::EventLoopWindowTarget<ServoEvent>>, + &mut winit::event_loop::ControlFlow + ) { match self.0 { - EventLoop::Winit(Some(ref mut events_loop)) => events_loop.poll_events(callback), - EventLoop::Winit(None) => (), - EventLoop::Headless(ref data) => { - // This is subtle - the use of the event loop in App::run_loop - // optionally calls run_forever, then always calls poll_events. - // If our signalling flag is true before we call run_forever, - // we don't want to reset it before poll_events is called or - // we'll end up sleeping even though there are events waiting - // to be handled. We compromise by only resetting the flag here - // in poll_events, so that both poll_events and run_forever can - // check it first and avoid sleeping unnecessarily. - self.sleep(&data.0, &data.1); - *data.0.lock().unwrap() = false; - }, - } - } - pub fn run_forever<F>(&mut self, mut callback: F) - where - F: FnMut(winit::Event) -> winit::ControlFlow, - { - match self.0 { - EventLoop::Winit(ref mut events_loop) => { + EventLoop::Winit(events_loop) => { let events_loop = events_loop - .as_mut() .expect("Can't run an unavailable event loop."); - events_loop.run_forever(callback); - }, + events_loop.run(move |e, window_target, ref mut control_flow| { + callback(e, Some(window_target), control_flow) + }); + } EventLoop::Headless(ref data) => { let &(ref flag, ref condvar) = &**data; - while !*flag.lock().unwrap() { + loop { self.sleep(flag, condvar); - if callback(winit::Event::Awakened) == winit::ControlFlow::Break { + let mut control_flow = winit::event_loop::ControlFlow::Poll; + + callback( + winit::event::Event::<ServoEvent>::UserEvent(ServoEvent::Awakened), + None, + &mut control_flow + ); + if control_flow != winit::event_loop::ControlFlow::Poll { + *flag.lock().unwrap() = false; + } else if control_flow == winit::event_loop::ControlFlow::Exit { break; } } }, } } + fn sleep(&self, lock: &Mutex<bool>, condvar: &Condvar) { // To avoid sleeping when we should be processing events, do two things: // * before sleeping, check whether our signalling flag has been set @@ -123,18 +115,18 @@ impl EventsLoop { } struct HeadedEventLoopWaker { - proxy: Arc<winit::EventsLoopProxy>, + proxy: Arc<Mutex<winit::event_loop::EventLoopProxy<ServoEvent>>>, } impl HeadedEventLoopWaker { - fn new(events_loop: &winit::EventsLoop) -> HeadedEventLoopWaker { - let proxy = Arc::new(events_loop.create_proxy()); + fn new(events_loop: &winit::event_loop::EventLoop<ServoEvent>) -> HeadedEventLoopWaker { + let proxy = Arc::new(Mutex::new(events_loop.create_proxy())); HeadedEventLoopWaker { proxy } } } impl EventLoopWaker for HeadedEventLoopWaker { fn wake(&self) { - // kick the OS event loop awake. - if let Err(err) = self.proxy.wakeup() { + // Kick the OS event loop awake. + if let Err(err) = self.proxy.lock().unwrap().send_event(ServoEvent::Awakened) { warn!("Failed to wake up event loop ({}).", err); } } diff --git a/ports/winit/headed_window.rs b/ports/winit/headed_window.rs index 6572fc3a6bc..8938ced4935 100644 --- a/ports/winit/headed_window.rs +++ b/ports/winit/headed_window.rs @@ -4,10 +4,18 @@ //! A winit window implementation. -use crate::events_loop::EventsLoop; +use crate::events_loop::{EventsLoop, ServoEvent}; use crate::keyutils::keyboard_event_from_winit; use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT}; -use euclid::{Angle, Point2D, Rotation3D, Scale, Size2D, UnknownUnit, Vector2D, Vector3D}; +use euclid::{ + Angle, Point2D, Rotation3D, Scale, Size2D, UnknownUnit, + Vector2D, Vector3D, +}; +#[cfg(target_os = "macos")] +use winit::platform::macos::{ActivationPolicy, WindowBuilderExtMacOS}; +#[cfg(any(target_os = "linux", target_os = "windows"))] +use winit::window::Icon; +use winit::event::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode}; #[cfg(any(target_os = "linux", target_os = "windows"))] use image; use keyboard_types::{Key, KeyState, KeyboardEvent}; @@ -39,17 +47,11 @@ use surfman::GLVersion; use surfman::SurfaceType; #[cfg(target_os = "windows")] use winapi; -use winit::dpi::{LogicalPosition, LogicalSize, PhysicalSize}; -#[cfg(target_os = "macos")] -use winit::os::macos::{ActivationPolicy, WindowBuilderExt}; -#[cfg(any(target_os = "linux", target_os = "windows"))] -use winit::Icon; -use winit::{ - ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode, -}; +use winit::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize}; +use winit::event::ModifiersState; #[cfg(target_os = "macos")] -fn builder_with_platform_options(mut builder: winit::WindowBuilder) -> winit::WindowBuilder { +fn builder_with_platform_options(mut builder: winit::window::WindowBuilder) -> winit::window::WindowBuilder { if opts::get().output_file.is_some() { // Prevent the window from showing in Dock.app, stealing focus, // when generating an output file. @@ -59,18 +61,18 @@ fn builder_with_platform_options(mut builder: winit::WindowBuilder) -> winit::Wi } #[cfg(not(target_os = "macos"))] -fn builder_with_platform_options(builder: winit::WindowBuilder) -> winit::WindowBuilder { +fn builder_with_platform_options(builder: winit::window::WindowBuilder) -> winit::window::WindowBuilder { builder } pub struct Window { - winit_window: winit::Window, + winit_window: winit::window::Window, webrender_surfman: WebrenderSurfman, screen_size: Size2D<u32, DeviceIndependentPixel>, inner_size: Cell<Size2D<u32, DeviceIndependentPixel>>, - mouse_down_button: Cell<Option<winit::MouseButton>>, + mouse_down_button: Cell<Option<winit::event::MouseButton>>, mouse_down_point: Cell<Point2D<i32, DevicePixel>>, - primary_monitor: winit::MonitorId, + primary_monitor: winit::monitor::MonitorHandle, event_queue: RefCell<Vec<WindowEvent>>, mouse_pos: Cell<Point2D<i32, DevicePixel>>, last_pressed: Cell<Option<(KeyboardEvent, Option<VirtualKeyCode>)>>, @@ -81,6 +83,7 @@ pub struct Window { fullscreen: Cell<bool>, device_pixels_per_px: Option<f32>, xr_window_poses: RefCell<Vec<Rc<XRWindowPose>>>, + modifiers_state: Cell<ModifiersState>, } #[cfg(not(target_os = "windows"))] @@ -98,7 +101,7 @@ fn window_creation_scale_factor() -> Scale<f32, DeviceIndependentPixel, DevicePi impl Window { pub fn new( win_size: Size2D<u32, DeviceIndependentPixel>, - events_loop: Rc<RefCell<EventsLoop>>, + events_loop: &EventsLoop, no_native_titlebar: bool, device_pixels_per_px: Option<f32>, ) -> Window { @@ -114,19 +117,16 @@ impl Window { let width = win_size.to_untyped().width; let height = win_size.to_untyped().height; - let mut window_builder = winit::WindowBuilder::new() + let mut window_builder = winit::window::WindowBuilder::new() .with_title("Servo".to_string()) .with_decorations(!no_native_titlebar) - .with_transparency(no_native_titlebar) - .with_dimensions(LogicalSize::new(width as f64, height as f64)) - .with_visibility(visible) - .with_multitouch(); + .with_transparent(no_native_titlebar) + .with_inner_size(PhysicalSize::new(width as f64, height as f64)) + .with_visible(visible); window_builder = builder_with_platform_options(window_builder); - let winit_window = window_builder - .build(events_loop.borrow().as_winit()) - .expect("Failed to create window."); + let winit_window = window_builder.build(events_loop.as_winit()).expect("Failed to create window."); #[cfg(any(target_os = "linux", target_os = "windows"))] { @@ -134,21 +134,16 @@ impl Window { winit_window.set_window_icon(Some(load_icon(icon_bytes))); } - let primary_monitor = events_loop.borrow().as_winit().get_primary_monitor(); + let primary_monitor = events_loop.as_winit().available_monitors().nth(0).expect("No monitor detected"); let PhysicalSize { width: screen_width, height: screen_height, - } = primary_monitor.get_dimensions(); + } = primary_monitor.clone().size(); let screen_size = Size2D::new(screen_width as u32, screen_height as u32); - // TODO(ajeffrey): can this fail? - let LogicalSize { width, height } = winit_window - .get_inner_size() - .expect("Failed to get window inner size."); + let PhysicalSize { width, height } = winit_window.inner_size(); let inner_size = Size2D::new(width as u32, height as u32); - winit_window.show(); - // Initialize surfman let connection = Connection::from_winit_window(&winit_window).expect("Failed to create connection"); @@ -179,6 +174,7 @@ impl Window { screen_size, device_pixels_per_px, xr_window_poses: RefCell::new(vec![]), + modifiers_state: Cell::new(ModifiersState::empty()), } } @@ -227,7 +223,7 @@ impl Window { } fn handle_keyboard_input(&self, input: KeyboardInput) { - let mut event = keyboard_event_from_winit(input); + let mut event = keyboard_event_from_winit(input, self.modifiers_state.get()); trace!("handling {:?}", event); if event.state == KeyState::Down && event.key == Key::Unidentified { // If pressed and probably printable, we expect a ReceivedCharacter event. @@ -247,7 +243,7 @@ impl Window { self.last_pressed.set(None); let xr_poses = self.xr_window_poses.borrow(); for xr_window_pose in &*xr_poses { - xr_window_pose.handle_xr_rotation(&input); + xr_window_pose.handle_xr_rotation(&input, self.modifiers_state.get()); } self.event_queue .borrow_mut() @@ -258,17 +254,17 @@ impl Window { /// Helper function to handle a click fn handle_mouse( &self, - button: winit::MouseButton, - action: winit::ElementState, + button: winit::event::MouseButton, + action: winit::event::ElementState, coords: Point2D<i32, DevicePixel>, ) { use servo::script_traits::MouseButton; let max_pixel_dist = 10.0 * self.servo_hidpi_factor().get(); let mouse_button = match &button { - winit::MouseButton::Left => MouseButton::Left, - winit::MouseButton::Right => MouseButton::Right, - winit::MouseButton::Middle => MouseButton::Middle, + winit::event::MouseButton::Left => MouseButton::Left, + winit::event::MouseButton::Right => MouseButton::Right, + winit::event::MouseButton::Middle => MouseButton::Middle, _ => MouseButton::Left, }; let event = match action { @@ -305,7 +301,7 @@ impl Window { } fn device_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> { - Scale::new(self.winit_window.get_hidpi_factor() as f32) + Scale::new(self.winit_window.scale_factor() as f32) } fn servo_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> { @@ -332,8 +328,7 @@ impl WindowPortsMethods for Window { let dpr = self.servo_hidpi_factor(); let size = self .winit_window - .get_inner_size() - .expect("Failed to get window inner size."); + .inner_size(); size.height as f32 * dpr.get() } @@ -342,24 +337,23 @@ impl WindowPortsMethods for Window { } fn set_inner_size(&self, size: DeviceIntSize) { - let size = size.to_f32() / self.device_hidpi_factor(); self.winit_window - .set_inner_size(LogicalSize::new(size.width.into(), size.height.into())) + .set_inner_size::<PhysicalSize<i32>>(PhysicalSize::new(size.width.into(), size.height.into())) } fn set_position(&self, point: DeviceIntPoint) { - let point = point.to_f32() / self.device_hidpi_factor(); self.winit_window - .set_position(LogicalPosition::new(point.x.into(), point.y.into())) + .set_outer_position::<PhysicalPosition<i32>>(PhysicalPosition::new(point.x.into(), point.y.into())) } fn set_fullscreen(&self, state: bool) { if self.fullscreen.get() != state { - self.winit_window.set_fullscreen(if state { - Some(self.primary_monitor.clone()) - } else { - None - }); + self.winit_window + .set_fullscreen( + if state { + Some(winit::window::Fullscreen::Borderless(Some(self.primary_monitor.clone()))) + } else { None } + ); } self.fullscreen.set(state); } @@ -369,68 +363,68 @@ impl WindowPortsMethods for Window { } fn set_cursor(&self, cursor: Cursor) { - use winit::MouseCursor; + use winit::window::CursorIcon; let winit_cursor = match cursor { - Cursor::Default => MouseCursor::Default, - Cursor::Pointer => MouseCursor::Hand, - Cursor::ContextMenu => MouseCursor::ContextMenu, - Cursor::Help => MouseCursor::Help, - Cursor::Progress => MouseCursor::Progress, - Cursor::Wait => MouseCursor::Wait, - Cursor::Cell => MouseCursor::Cell, - Cursor::Crosshair => MouseCursor::Crosshair, - Cursor::Text => MouseCursor::Text, - Cursor::VerticalText => MouseCursor::VerticalText, - Cursor::Alias => MouseCursor::Alias, - Cursor::Copy => MouseCursor::Copy, - Cursor::Move => MouseCursor::Move, - Cursor::NoDrop => MouseCursor::NoDrop, - Cursor::NotAllowed => MouseCursor::NotAllowed, - Cursor::Grab => MouseCursor::Grab, - Cursor::Grabbing => MouseCursor::Grabbing, - Cursor::EResize => MouseCursor::EResize, - Cursor::NResize => MouseCursor::NResize, - Cursor::NeResize => MouseCursor::NeResize, - Cursor::NwResize => MouseCursor::NwResize, - Cursor::SResize => MouseCursor::SResize, - Cursor::SeResize => MouseCursor::SeResize, - Cursor::SwResize => MouseCursor::SwResize, - Cursor::WResize => MouseCursor::WResize, - Cursor::EwResize => MouseCursor::EwResize, - Cursor::NsResize => MouseCursor::NsResize, - Cursor::NeswResize => MouseCursor::NeswResize, - Cursor::NwseResize => MouseCursor::NwseResize, - Cursor::ColResize => MouseCursor::ColResize, - Cursor::RowResize => MouseCursor::RowResize, - Cursor::AllScroll => MouseCursor::AllScroll, - Cursor::ZoomIn => MouseCursor::ZoomIn, - Cursor::ZoomOut => MouseCursor::ZoomOut, - _ => MouseCursor::Default, + Cursor::Default => CursorIcon::Default, + Cursor::Pointer => CursorIcon::Hand, + Cursor::ContextMenu => CursorIcon::ContextMenu, + Cursor::Help => CursorIcon::Help, + Cursor::Progress => CursorIcon::Progress, + Cursor::Wait => CursorIcon::Wait, + Cursor::Cell => CursorIcon::Cell, + Cursor::Crosshair => CursorIcon::Crosshair, + Cursor::Text => CursorIcon::Text, + Cursor::VerticalText => CursorIcon::VerticalText, + Cursor::Alias => CursorIcon::Alias, + Cursor::Copy => CursorIcon::Copy, + Cursor::Move => CursorIcon::Move, + Cursor::NoDrop => CursorIcon::NoDrop, + Cursor::NotAllowed => CursorIcon::NotAllowed, + Cursor::Grab => CursorIcon::Grab, + Cursor::Grabbing => CursorIcon::Grabbing, + Cursor::EResize => CursorIcon::EResize, + Cursor::NResize => CursorIcon::NResize, + Cursor::NeResize => CursorIcon::NeResize, + Cursor::NwResize => CursorIcon::NwResize, + Cursor::SResize => CursorIcon::SResize, + Cursor::SeResize => CursorIcon::SeResize, + Cursor::SwResize => CursorIcon::SwResize, + Cursor::WResize => CursorIcon::WResize, + Cursor::EwResize => CursorIcon::EwResize, + Cursor::NsResize => CursorIcon::NsResize, + Cursor::NeswResize => CursorIcon::NeswResize, + Cursor::NwseResize => CursorIcon::NwseResize, + Cursor::ColResize => CursorIcon::ColResize, + Cursor::RowResize => CursorIcon::RowResize, + Cursor::AllScroll => CursorIcon::AllScroll, + Cursor::ZoomIn => CursorIcon::ZoomIn, + Cursor::ZoomOut => CursorIcon::ZoomOut, + _ => CursorIcon::Default, }; - self.winit_window.set_cursor(winit_cursor); + self.winit_window.set_cursor_icon(winit_cursor); } fn is_animating(&self) -> bool { self.animation_state.get() == AnimationState::Animating } - fn id(&self) -> winit::WindowId { + fn id(&self) -> winit::window::WindowId { self.winit_window.id() } - fn winit_event_to_servo_event(&self, event: winit::WindowEvent) { + fn winit_event_to_servo_event(&self, event: winit::event::WindowEvent) { match event { - winit::WindowEvent::ReceivedCharacter(ch) => self.handle_received_character(ch), - winit::WindowEvent::KeyboardInput { input, .. } => self.handle_keyboard_input(input), - winit::WindowEvent::MouseInput { state, button, .. } => { + winit::event::WindowEvent::ReceivedCharacter(ch) => self.handle_received_character(ch), + winit::event::WindowEvent::KeyboardInput { input, .. } => self.handle_keyboard_input(input), + winit::event::WindowEvent::ModifiersChanged(state) => self.modifiers_state.set(state), + winit::event::WindowEvent::MouseInput { state, button, .. } => { if button == MouseButton::Left || button == MouseButton::Right { self.handle_mouse(button, state, self.mouse_pos.get()); } }, - winit::WindowEvent::CursorMoved { position, .. } => { - let pos = position.to_physical(self.device_hidpi_factor().get() as f64); - let (x, y): (i32, i32) = pos.into(); + winit::event::WindowEvent::CursorMoved { position, .. } => { + let (x, y): (i32, i32) = position.into(); self.mouse_pos.set(Point2D::new(x, y)); self.event_queue .borrow_mut() @@ -438,15 +432,15 @@ impl WindowPortsMethods for Window { x as f32, y as f32, ))); }, - winit::WindowEvent::MouseWheel { delta, phase, .. } => { + winit::event::WindowEvent::MouseWheel { delta, phase, .. } => { let (mut dx, mut dy, mode) = match delta { MouseScrollDelta::LineDelta(dx, dy) => { (dx as f64, (dy * LINE_HEIGHT) as f64, WheelMode::DeltaLine) }, MouseScrollDelta::PixelDelta(position) => { - let position = - position.to_physical(self.device_hidpi_factor().get() as f64); - (position.x as f64, position.y as f64, WheelMode::DeltaPixel) + let position: LogicalPosition<f64> = + position.to_logical(self.device_hidpi_factor().get() as f64); + (position.x, position.y, WheelMode::DeltaPixel) }, }; @@ -478,30 +472,24 @@ impl WindowPortsMethods for Window { self.event_queue.borrow_mut().push(wheel_event); self.event_queue.borrow_mut().push(scroll_event); }, - winit::WindowEvent::Touch(touch) => { + winit::event::WindowEvent::Touch(touch) => { use servo::script_traits::TouchId; let phase = winit_phase_to_touch_event_type(touch.phase); let id = TouchId(touch.id as i32); - let position = touch - .location - .to_physical(self.device_hidpi_factor().get() as f64); + let position = touch.location; let point = Point2D::new(position.x as f32, position.y as f32); self.event_queue .borrow_mut() .push(WindowEvent::Touch(phase, id, point)); }, - winit::WindowEvent::Refresh => { - self.event_queue.borrow_mut().push(WindowEvent::Refresh); - }, - winit::WindowEvent::CloseRequested => { + winit::event::WindowEvent::CloseRequested => { self.event_queue.borrow_mut().push(WindowEvent::Quit); }, - winit::WindowEvent::Resized(size) => { - let (width, height) = size.into(); + winit::event::WindowEvent::Resized(physical_size) => { + let (width, height) = physical_size.into(); let new_size = Size2D::new(width, height); if self.inner_size.get() != new_size { - let physical_size = size.to_physical(self.device_hidpi_factor().get() as f64); let physical_size = Size2D::new(physical_size.width, physical_size.height); self.webrender_surfman .resize(physical_size.to_i32()) @@ -514,21 +502,20 @@ impl WindowPortsMethods for Window { } } - fn new_glwindow(&self, events_loop: &EventsLoop) -> Box<dyn webxr::glwindow::GlWindow> { - let size = self - .winit_window - .get_outer_size() - .expect("Failed to get window outer size"); + fn new_glwindow( + &self, + event_loop: &winit::event_loop::EventLoopWindowTarget<ServoEvent> + ) -> Box<dyn webxr::glwindow::GlWindow> { + let size = self.winit_window.outer_size(); - let mut window_builder = winit::WindowBuilder::new() + let mut window_builder = winit::window::WindowBuilder::new() .with_title("Servo XR".to_string()) - .with_dimensions(size) - .with_visibility(true); + .with_inner_size(size) + .with_visible(true); window_builder = builder_with_platform_options(window_builder); - let winit_window = window_builder - .build(events_loop.as_winit()) + let winit_window = window_builder.build(event_loop) .expect("Failed to create window."); let pose = Rc::new(XRWindowPose { @@ -542,24 +529,23 @@ impl WindowPortsMethods for Window { impl WindowMethods for Window { fn get_coordinates(&self) -> EmbedderCoordinates { - // TODO(ajeffrey): can this fail? - let dpr = self.device_hidpi_factor(); - let LogicalSize { width, height } = self + // Needed to convince the type system that winit's physical pixels + // are actually device pixels. + let dpr: Scale<f32, DeviceIndependentPixel, DevicePixel> = Scale::new(1.0); + let PhysicalSize { width, height } = self .winit_window - .get_outer_size() - .expect("Failed to get window outer size."); - let LogicalPosition { x, y } = self + .outer_size(); + let PhysicalPosition { x, y } = self .winit_window - .get_position() - .unwrap_or(LogicalPosition::new(0., 0.)); + .outer_position() + .unwrap_or(PhysicalPosition::new(0, 0)); 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 + let PhysicalSize { width, height } = self .winit_window - .get_inner_size() - .expect("Failed to get window inner size."); + .inner_size(); 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()); @@ -684,7 +670,7 @@ fn load_icon(icon_bytes: &[u8]) -> Icon { } struct XRWindow { - winit_window: winit::Window, + winit_window: winit::window::Window, pose: Rc<XRWindowPose>, } @@ -757,8 +743,8 @@ impl XRWindowPose { self.xr_translation.set(vec); } - fn handle_xr_rotation(&self, input: &KeyboardInput) { - if input.state != winit::ElementState::Pressed { + fn handle_xr_rotation(&self, input: &KeyboardInput, modifiers: ModifiersState) { + if input.state != winit::event::ElementState::Pressed { return; } let mut x = 0.0; @@ -770,7 +756,7 @@ impl XRWindowPose { Some(VirtualKeyCode::Right) => y = -1.0, _ => return, }; - if input.modifiers.shift { + if modifiers.shift() { x = 10.0 * x; y = 10.0 * y; } diff --git a/ports/winit/headless_window.rs b/ports/winit/headless_window.rs index 98a719718c5..49b23072257 100644 --- a/ports/winit/headless_window.rs +++ b/ports/winit/headless_window.rs @@ -4,7 +4,7 @@ //! A headless window implementation. -use crate::events_loop::EventsLoop; +use crate::events_loop::ServoEvent; use crate::window_trait::WindowPortsMethods; use euclid::{Point2D, Rotation3D, Scale, Size2D, UnknownUnit, Vector3D}; use servo::compositing::windowing::{AnimationState, WindowEvent}; @@ -71,8 +71,8 @@ impl WindowPortsMethods for Window { false } - fn id(&self) -> winit::WindowId { - unsafe { winit::WindowId::dummy() } + fn id(&self) -> winit::window::WindowId { + unsafe { winit::window::WindowId::dummy() } } fn page_height(&self) -> f32 { @@ -98,11 +98,14 @@ impl WindowPortsMethods for Window { self.animation_state.get() == AnimationState::Animating } - fn winit_event_to_servo_event(&self, _event: winit::WindowEvent) { + fn winit_event_to_servo_event(&self, _event: winit::event::WindowEvent) { // Not expecting any winit events. } - fn new_glwindow(&self, _events_loop: &EventsLoop) -> Box<dyn webxr::glwindow::GlWindow> { + fn new_glwindow( + &self, + _events_loop: &winit::event_loop::EventLoopWindowTarget<ServoEvent> + ) -> Box<dyn webxr::glwindow::GlWindow> { unimplemented!() } } diff --git a/ports/winit/keyutils.rs b/ports/winit/keyutils.rs index 5be6e8e9685..ddc54afe544 100644 --- a/ports/winit/keyutils.rs +++ b/ports/winit/keyutils.rs @@ -2,8 +2,8 @@ * 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 winit::event::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode}; use keyboard_types::{Code, Key, KeyState, KeyboardEvent, Location, Modifiers}; -use winit::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode}; // Some shortcuts use Cmd on Mac and Control on other systems. #[cfg(target_os = "macos")] @@ -18,7 +18,7 @@ pub const CMD_OR_ALT: Modifiers = Modifiers::META; pub const CMD_OR_ALT: Modifiers = Modifiers::ALT; fn get_servo_key_from_winit_key(key: Option<VirtualKeyCode>) -> Key { - use winit::VirtualKeyCode::*; + use winit::event::VirtualKeyCode::*; // TODO: figure out how to map NavigateForward, NavigateBackward // TODO: map the remaining keys if possible let key = if let Some(key) = key { @@ -127,7 +127,7 @@ fn get_servo_key_from_winit_key(key: Option<VirtualKeyCode>) -> Key { } fn get_servo_location_from_winit_key(key: Option<VirtualKeyCode>) -> Location { - use winit::VirtualKeyCode::*; + use winit::event::VirtualKeyCode::*; // TODO: add more numpad keys let key = if let Some(key) = key { key @@ -243,14 +243,14 @@ fn get_servo_code_from_scancode(_scancode: u32) -> Code { fn get_modifiers(mods: ModifiersState) -> Modifiers { let mut modifiers = Modifiers::empty(); - modifiers.set(Modifiers::CONTROL, mods.ctrl); - modifiers.set(Modifiers::SHIFT, mods.shift); - modifiers.set(Modifiers::ALT, mods.alt); - modifiers.set(Modifiers::META, mods.logo); + modifiers.set(Modifiers::CONTROL, mods.ctrl()); + modifiers.set(Modifiers::SHIFT, mods.shift()); + modifiers.set(Modifiers::ALT, mods.alt()); + modifiers.set(Modifiers::META, mods.logo()); modifiers } -pub fn keyboard_event_from_winit(input: KeyboardInput) -> KeyboardEvent { +pub fn keyboard_event_from_winit(input: KeyboardInput, state: ModifiersState) -> KeyboardEvent { info!("winit keyboard input: {:?}", input); KeyboardEvent { state: match input.state { @@ -260,7 +260,7 @@ pub fn keyboard_event_from_winit(input: KeyboardInput) -> KeyboardEvent { key: get_servo_key_from_winit_key(input.virtual_keycode), code: get_servo_code_from_scancode(input.scancode), location: get_servo_location_from_winit_key(input.virtual_keycode), - modifiers: get_modifiers(input.modifiers), + modifiers: get_modifiers(state), repeat: false, is_composing: false, } diff --git a/ports/winit/window_trait.rs b/ports/winit/window_trait.rs index a6faa676589..e02f7dfba60 100644 --- a/ports/winit/window_trait.rs +++ b/ports/winit/window_trait.rs @@ -5,7 +5,7 @@ //! Definition of Window. //! Implemented by headless and headed windows. -use crate::events_loop::EventsLoop; +use crate::events_loop::ServoEvent; use servo::compositing::windowing::{WindowEvent, WindowMethods}; use servo::embedder_traits::Cursor; use servo::webrender_api::units::{DeviceIntPoint, DeviceIntSize}; @@ -16,16 +16,19 @@ pub const LINE_HEIGHT: f32 = 38.0; pub trait WindowPortsMethods: WindowMethods { fn get_events(&self) -> Vec<WindowEvent>; - fn id(&self) -> winit::WindowId; + fn id(&self) -> winit::window::WindowId; fn has_events(&self) -> bool; fn page_height(&self) -> f32; fn get_fullscreen(&self) -> bool; - fn winit_event_to_servo_event(&self, event: winit::WindowEvent); + fn winit_event_to_servo_event(&self, event: winit::event::WindowEvent); fn is_animating(&self) -> bool; fn set_title(&self, _title: &str) {} fn set_inner_size(&self, _size: DeviceIntSize) {} fn set_position(&self, _point: DeviceIntPoint) {} fn set_fullscreen(&self, _state: bool) {} fn set_cursor(&self, _cursor: Cursor) {} - fn new_glwindow(&self, events_loop: &EventsLoop) -> Box<dyn webxr::glwindow::GlWindow>; + fn new_glwindow( + &self, + events_loop: &winit::event_loop::EventLoopWindowTarget<ServoEvent> + ) -> Box<dyn webxr::glwindow::GlWindow>; } diff --git a/servo-tidy.toml b/servo-tidy.toml index 1f6cffbe04f..f16b226dda4 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -67,17 +67,18 @@ packages = [ # Lots of crates to update. "smallvec", - # https://github.com/servo/servo/issues/24421 - "proc-macro2", - "quote", - "unicode-xid", - # https://github.com/servo/servo/pull/25518 "core-foundation", "core-foundation-sys", "core-graphics", "lyon_geom", + # https://github.com/servo/servo/pull/28236 + "dlib", + "nix", + "nom", + "strsim", + # Duplicated by webrender debugger via ws "digest", "generic-array", diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/flexible-order.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/flexible-order.html.ini deleted file mode 100644 index 788f10d4854..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-flexbox/flexible-order.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[flexible-order.html] - expected: FAIL |