mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #22680 - emilio:gecko-sync, r=emilio
style: Sync changes from mozilla-central. See each individual commit for details. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22680) <!-- Reviewable:end -->
This commit is contained in:
commit
6197f1adda
40 changed files with 306 additions and 455 deletions
36
Cargo.lock
generated
36
Cargo.lock
generated
|
@ -403,7 +403,7 @@ dependencies = [
|
||||||
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"offscreen_gl_context 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"offscreen_gl_context 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pixels 0.0.1",
|
"pixels 0.0.1",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -899,7 +899,7 @@ dependencies = [
|
||||||
"http 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"http 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"servo_url 0.0.1",
|
"servo_url 0.0.1",
|
||||||
|
@ -1304,7 +1304,7 @@ name = "gfx_traits"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"range 0.0.1",
|
"range 0.0.1",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -2288,7 +2288,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "malloc_size_of_derive"
|
name = "malloc_size_of_derive"
|
||||||
version = "0.0.1"
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2355,7 +2356,7 @@ dependencies = [
|
||||||
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
|
@ -2529,7 +2530,7 @@ name = "msg"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"size_of_test 0.0.1",
|
"size_of_test 0.0.1",
|
||||||
"webrender_api 0.57.2 (git+https://github.com/servo/webrender)",
|
"webrender_api 0.57.2 (git+https://github.com/servo/webrender)",
|
||||||
|
@ -2564,7 +2565,7 @@ dependencies = [
|
||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2617,7 +2618,7 @@ dependencies = [
|
||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2914,7 +2915,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"euclid 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3059,7 +3060,7 @@ name = "range"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"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)",
|
"num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -3249,7 +3250,7 @@ dependencies = [
|
||||||
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"metrics 0.0.1",
|
"metrics 0.0.1",
|
||||||
"mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3316,7 +3317,7 @@ dependencies = [
|
||||||
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"metrics 0.0.1",
|
"metrics 0.0.1",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
|
@ -3372,7 +3373,7 @@ dependencies = [
|
||||||
"keyboard-types 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"keyboard-types 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
"pixels 0.0.1",
|
"pixels 0.0.1",
|
||||||
|
@ -3632,7 +3633,7 @@ dependencies = [
|
||||||
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"webrender_api 0.57.2 (git+https://github.com/servo/webrender)",
|
"webrender_api 0.57.2 (git+https://github.com/servo/webrender)",
|
||||||
]
|
]
|
||||||
|
@ -3670,7 +3671,7 @@ name = "servo_url"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"servo_rand 0.0.1",
|
"servo_rand 0.0.1",
|
||||||
"url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3875,7 +3876,7 @@ dependencies = [
|
||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num-derive 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-derive 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3952,7 +3953,7 @@ dependencies = [
|
||||||
"cssparser 0.25.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.25.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"malloc_size_of 0.0.1",
|
"malloc_size_of 0.0.1",
|
||||||
"malloc_size_of_derive 0.0.1",
|
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.21.0",
|
"selectors 0.21.0",
|
||||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"servo_arc 0.1.1",
|
"servo_arc 0.1.1",
|
||||||
|
@ -5011,6 +5012,7 @@ dependencies = [
|
||||||
"checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
|
"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"
|
"checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1"
|
||||||
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
|
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
|
||||||
|
"checksum malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "35adee9ed962cf7d07d62cb58bc45029f3227f5b5b86246caa8632f06c187bc3"
|
||||||
"checksum markup5ever 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "897636f9850c3eef4905a5540683ed53dc9393860f0846cab2c2ddf9939862ff"
|
"checksum markup5ever 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "897636f9850c3eef4905a5540683ed53dc9393860f0846cab2c2ddf9939862ff"
|
||||||
"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1"
|
"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1"
|
||||||
"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16"
|
"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16"
|
||||||
|
|
|
@ -20,7 +20,7 @@ ipc-channel = "0.11"
|
||||||
gleam = "0.6.7"
|
gleam = "0.6.7"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
offscreen_gl_context = {version = "0.21", features = ["serde"]}
|
offscreen_gl_context = {version = "0.21", features = ["serde"]}
|
||||||
pixels = {path = "../pixels"}
|
pixels = {path = "../pixels"}
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
|
|
@ -15,7 +15,7 @@ bitflags = "1.0"
|
||||||
http = "0.1"
|
http = "0.1"
|
||||||
ipc-channel = "0.11"
|
ipc-channel = "0.11"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
servo_url = {path = "../url"}
|
servo_url = {path = "../url"}
|
||||||
|
|
|
@ -14,6 +14,6 @@ path = "lib.rs"
|
||||||
app_units = "0.7"
|
app_units = "0.7"
|
||||||
euclid = "0.19"
|
euclid = "0.19"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
style_traits = { path = "../style_traits" }
|
style_traits = { path = "../style_traits" }
|
||||||
webrender_api = { git = "https://github.com/servo/webrender" }
|
webrender_api = { git = "https://github.com/servo/webrender" }
|
||||||
|
|
|
@ -12,6 +12,6 @@ path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
range = {path = "../range"}
|
range = {path = "../range"}
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
//! fields in structs, because it makes it clear that the Box is being
|
//! fields in structs, because it makes it clear that the Box is being
|
||||||
//! measured as well as the thing it points to. E.g.
|
//! measured as well as the thing it points to. E.g.
|
||||||
//! `<Box<_> as MallocSizeOf>::size_of(field, ops)`.
|
//! `<Box<_> as MallocSizeOf>::size_of(field, ops)`.
|
||||||
|
//!
|
||||||
|
//! Note: WebRender has a reduced for of this crate, so that we can avoid
|
||||||
|
//! publishing this crate on crates.io.
|
||||||
|
|
||||||
extern crate app_units;
|
extern crate app_units;
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "malloc_size_of_derive"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = ["The Servo Project Developers"]
|
|
||||||
license = "MIT/Apache-2.0"
|
|
||||||
publish = false
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
path = "lib.rs"
|
|
||||||
proc-macro = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
proc-macro2 = "0.4"
|
|
||||||
syn = { version = "0.15", features = ["full"] }
|
|
||||||
synstructure = "0.10"
|
|
|
@ -1,201 +0,0 @@
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
|
@ -1,23 +0,0 @@
|
||||||
Permission is hereby granted, free of charge, to any
|
|
||||||
person obtaining a copy of this software and associated
|
|
||||||
documentation files (the "Software"), to deal in the
|
|
||||||
Software without restriction, including without
|
|
||||||
limitation the rights to use, copy, modify, merge,
|
|
||||||
publish, distribute, sublicense, and/or sell copies of
|
|
||||||
the Software, and to permit persons to whom the Software
|
|
||||||
is furnished to do so, subject to the following
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice
|
|
||||||
shall be included in all copies or substantial portions
|
|
||||||
of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
||||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
||||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
||||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
|
@ -1,125 +0,0 @@
|
||||||
// Copyright 2016-2017 The Servo Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
//! A crate for deriving the MallocSizeOf trait.
|
|
||||||
|
|
||||||
extern crate proc_macro2;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate syn;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate synstructure;
|
|
||||||
|
|
||||||
#[cfg(not(test))]
|
|
||||||
decl_derive!([MallocSizeOf, attributes(ignore_malloc_size_of)] => malloc_size_of_derive);
|
|
||||||
|
|
||||||
fn malloc_size_of_derive(s: synstructure::Structure) -> proc_macro2::TokenStream {
|
|
||||||
let match_body = s.each(|binding| {
|
|
||||||
let ignore = binding
|
|
||||||
.ast()
|
|
||||||
.attrs
|
|
||||||
.iter()
|
|
||||||
.any(|attr| match attr.interpret_meta().unwrap() {
|
|
||||||
syn::Meta::Word(ref ident) | syn::Meta::List(syn::MetaList { ref ident, .. })
|
|
||||||
if ident == "ignore_malloc_size_of" =>
|
|
||||||
{
|
|
||||||
panic!(
|
|
||||||
"#[ignore_malloc_size_of] should have an explanation, \
|
|
||||||
e.g. #[ignore_malloc_size_of = \"because reasons\"]"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
syn::Meta::NameValue(syn::MetaNameValue { ref ident, .. })
|
|
||||||
if ident == "ignore_malloc_size_of" =>
|
|
||||||
{
|
|
||||||
true
|
|
||||||
},
|
|
||||||
_ => false,
|
|
||||||
});
|
|
||||||
if ignore {
|
|
||||||
None
|
|
||||||
} else if let syn::Type::Array(..) = binding.ast().ty {
|
|
||||||
Some(quote! {
|
|
||||||
for item in #binding.iter() {
|
|
||||||
sum += ::malloc_size_of::MallocSizeOf::size_of(item, ops);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Some(quote! {
|
|
||||||
sum += ::malloc_size_of::MallocSizeOf::size_of(#binding, ops);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let ast = s.ast();
|
|
||||||
let name = &ast.ident;
|
|
||||||
let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
|
|
||||||
let mut where_clause = where_clause.unwrap_or(&parse_quote!(where)).clone();
|
|
||||||
for param in ast.generics.type_params() {
|
|
||||||
let ident = ¶m.ident;
|
|
||||||
where_clause
|
|
||||||
.predicates
|
|
||||||
.push(parse_quote!(#ident: ::malloc_size_of::MallocSizeOf));
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = quote! {
|
|
||||||
impl #impl_generics ::malloc_size_of::MallocSizeOf for #name #ty_generics #where_clause {
|
|
||||||
#[inline]
|
|
||||||
#[allow(unused_variables, unused_mut, unreachable_code)]
|
|
||||||
fn size_of(&self, ops: &mut ::malloc_size_of::MallocSizeOfOps) -> usize {
|
|
||||||
let mut sum = 0;
|
|
||||||
match *self {
|
|
||||||
#match_body
|
|
||||||
}
|
|
||||||
sum
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tokens
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_struct() {
|
|
||||||
let source = syn::parse_str(
|
|
||||||
"struct Foo<T> { bar: Bar, baz: T, #[ignore_malloc_size_of = \"\"] z: Arc<T> }",
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let source = synstructure::Structure::new(&source);
|
|
||||||
|
|
||||||
let expanded = malloc_size_of_derive(source).to_string();
|
|
||||||
let mut no_space = expanded.replace(" ", "");
|
|
||||||
macro_rules! match_count {
|
|
||||||
($e: expr, $count: expr) => {
|
|
||||||
assert_eq!(
|
|
||||||
no_space.matches(&$e.replace(" ", "")).count(),
|
|
||||||
$count,
|
|
||||||
"counting occurences of {:?} in {:?} (whitespace-insensitive)",
|
|
||||||
$e,
|
|
||||||
expanded
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
match_count!("struct", 0);
|
|
||||||
match_count!("ignore_malloc_size_of", 0);
|
|
||||||
match_count!("impl<T> ::malloc_size_of::MallocSizeOf for Foo<T> where T: ::malloc_size_of::MallocSizeOf {", 1);
|
|
||||||
match_count!("sum += ::malloc_size_of::MallocSizeOf::size_of(", 2);
|
|
||||||
|
|
||||||
let source = syn::parse_str("struct Bar([Baz; 3]);").unwrap();
|
|
||||||
let source = synstructure::Structure::new(&source);
|
|
||||||
let expanded = malloc_size_of_derive(source).to_string();
|
|
||||||
no_space = expanded.replace(" ", "");
|
|
||||||
match_count!("for item in", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[should_panic(expected = "should have an explanation")]
|
|
||||||
#[test]
|
|
||||||
fn test_no_reason() {
|
|
||||||
let input = syn::parse_str("struct A { #[ignore_malloc_size_of] b: C }").unwrap();
|
|
||||||
malloc_size_of_derive(synstructure::Structure::new(&input));
|
|
||||||
}
|
|
|
@ -15,7 +15,7 @@ gfx_traits = {path = "../gfx_traits"}
|
||||||
ipc-channel = "0.11"
|
ipc-channel = "0.11"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
profile_traits = {path = "../profile_traits"}
|
profile_traits = {path = "../profile_traits"}
|
||||||
script_traits = {path = "../script_traits"}
|
script_traits = {path = "../script_traits"}
|
||||||
|
|
|
@ -14,7 +14,7 @@ doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
serde = "1.0.60"
|
serde = "1.0.60"
|
||||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ ipc-channel = "0.11"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
matches = "0.1"
|
matches = "0.1"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
mime_guess = "2.0.0-alpha.6"
|
mime_guess = "2.0.0-alpha.6"
|
||||||
|
|
|
@ -25,7 +25,7 @@ ipc-channel = "0.11"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
|
|
|
@ -13,5 +13,5 @@ path = "lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
euclid = "0.19"
|
euclid = "0.19"
|
||||||
malloc_size_of = {path = "../malloc_size_of"}
|
malloc_size_of = {path = "../malloc_size_of"}
|
||||||
malloc_size_of_derive = {path = "../malloc_size_of_derive"}
|
malloc_size_of_derive = "0.1"
|
||||||
serde = {version = "1", features = ["derive"]}
|
serde = {version = "1", features = ["derive"]}
|
||||||
|
|
|
@ -13,6 +13,6 @@ path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
|
|
@ -68,7 +68,7 @@ lazy_static = "1"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
metrics = {path = "../metrics"}
|
metrics = {path = "../metrics"}
|
||||||
mitochondria = "1.1.2"
|
mitochondria = "1.1.2"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
|
|
|
@ -24,7 +24,7 @@ libc = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
time = "0.1.17"
|
time = "0.1.17"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
metrics = {path = "../metrics"}
|
metrics = {path = "../metrics"}
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
net_traits = {path = "../net_traits"}
|
net_traits = {path = "../net_traits"}
|
||||||
|
|
|
@ -26,7 +26,7 @@ ipc-channel = "0.11"
|
||||||
keyboard-types = "0.4.3"
|
keyboard-types = "0.4.3"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
net_traits = {path = "../net_traits"}
|
net_traits = {path = "../net_traits"}
|
||||||
pixels = {path = "../pixels"}
|
pixels = {path = "../pixels"}
|
||||||
|
|
|
@ -44,7 +44,7 @@ itoa = "0.4"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
matches = "0.1"
|
matches = "0.1"
|
||||||
num_cpus = {version = "1.1.0"}
|
num_cpus = {version = "1.1.0"}
|
||||||
num-integer = "0.1"
|
num-integer = "0.1"
|
||||||
|
|
|
@ -63,6 +63,7 @@ include = [
|
||||||
"Float",
|
"Float",
|
||||||
"OverscrollBehavior",
|
"OverscrollBehavior",
|
||||||
"ScrollSnapType",
|
"ScrollSnapType",
|
||||||
|
"OverflowAnchor",
|
||||||
"OverflowClipBox",
|
"OverflowClipBox",
|
||||||
"Resize",
|
"Resize",
|
||||||
"Overflow",
|
"Overflow",
|
||||||
|
|
|
@ -130,6 +130,7 @@ RULE_TEMPLATE = '''
|
||||||
'''[1:]
|
'''[1:]
|
||||||
|
|
||||||
MACRO_TEMPLATE = '''
|
MACRO_TEMPLATE = '''
|
||||||
|
/// Returns a static atom by passing the literal string it represents.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! atom {{
|
macro_rules! atom {{
|
||||||
{body}\
|
{body}\
|
||||||
|
|
|
@ -11,6 +11,8 @@ use std::borrow::Borrow;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
|
/// In Gecko namespaces are just regular atoms, so this is a simple macro to
|
||||||
|
/// forward one macro to the other.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! ns {
|
macro_rules! ns {
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -38,10 +38,8 @@ impl MediaListKey {
|
||||||
pub trait ToMediaListKey: Sized {
|
pub trait ToMediaListKey: Sized {
|
||||||
/// Get a `MediaListKey` for this item. This key needs to uniquely identify
|
/// Get a `MediaListKey` for this item. This key needs to uniquely identify
|
||||||
/// the item.
|
/// the item.
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn to_media_list_key(&self) -> MediaListKey {
|
fn to_media_list_key(&self) -> MediaListKey {
|
||||||
use std::mem;
|
MediaListKey(self as *const Self as usize)
|
||||||
MediaListKey(unsafe { mem::transmute(self as *const Self) })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,6 +326,7 @@ class Longhand(object):
|
||||||
"Opacity",
|
"Opacity",
|
||||||
"OutlineStyle",
|
"OutlineStyle",
|
||||||
"Overflow",
|
"Overflow",
|
||||||
|
"OverflowAnchor",
|
||||||
"OverflowClipBox",
|
"OverflowClipBox",
|
||||||
"OverflowWrap",
|
"OverflowWrap",
|
||||||
"OverscrollBehavior",
|
"OverscrollBehavior",
|
||||||
|
|
|
@ -1419,6 +1419,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
|
||||||
"Number": impl_simple,
|
"Number": impl_simple,
|
||||||
"Opacity": impl_simple,
|
"Opacity": impl_simple,
|
||||||
"OverflowWrap": impl_simple,
|
"OverflowWrap": impl_simple,
|
||||||
|
"OverflowAnchor": impl_simple,
|
||||||
"Perspective": impl_style_coord,
|
"Perspective": impl_style_coord,
|
||||||
"Position": impl_position,
|
"Position": impl_position,
|
||||||
"RGBAColor": impl_rgba_color,
|
"RGBAColor": impl_rgba_color,
|
||||||
|
|
|
@ -125,6 +125,18 @@ ${helpers.predefined_type(
|
||||||
servo_restyle_damage = "reflow",
|
servo_restyle_damage = "reflow",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
${helpers.predefined_type(
|
||||||
|
"overflow-anchor",
|
||||||
|
"OverflowAnchor",
|
||||||
|
"computed::OverflowAnchor::Auto",
|
||||||
|
initial_specified_value="specified::OverflowAnchor::Auto",
|
||||||
|
products="gecko",
|
||||||
|
needs_context=False,
|
||||||
|
gecko_pref="layout.css.scroll-anchoring.enabled",
|
||||||
|
spec="https://drafts.csswg.org/css-scroll-anchoring/#exclusion-api",
|
||||||
|
animation_value_type="discrete",
|
||||||
|
)}
|
||||||
|
|
||||||
<% transition_extra_prefixes = "moz:layout.css.prefixes.transitions webkit" %>
|
<% transition_extra_prefixes = "moz:layout.css.prefixes.transitions webkit" %>
|
||||||
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
|
|
|
@ -383,7 +383,7 @@ ${helpers.predefined_type(
|
||||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-%ss" % kind,
|
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-%ss" % kind,
|
||||||
boxed=True,
|
boxed=True,
|
||||||
flags="GETCS_NEEDS_LAYOUT_FLUSH",
|
flags="GETCS_NEEDS_LAYOUT_FLUSH",
|
||||||
animation_value_type="discrete",
|
animation_value_type="ComputedValue",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
% endfor
|
% endfor
|
||||||
|
|
|
@ -345,14 +345,6 @@ where
|
||||||
self.data_validity = cmp::max(validity, self.data_validity);
|
self.data_validity = cmp::max(validity, self.data_validity);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepend(&mut self, sheet: S) {
|
|
||||||
debug_assert!(!self.contains(&sheet));
|
|
||||||
// Inserting stylesheets somewhere but at the end changes the validity
|
|
||||||
// of the cascade data, but not the invalidation data.
|
|
||||||
self.set_data_validity_at_least(DataValidity::CascadeInvalid);
|
|
||||||
self.entries.insert(0, StylesheetSetEntry::new(sheet));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an iterator over the current list of stylesheets.
|
/// Returns an iterator over the current list of stylesheets.
|
||||||
fn iter(&self) -> StylesheetCollectionIterator<S> {
|
fn iter(&self) -> StylesheetCollectionIterator<S> {
|
||||||
StylesheetCollectionIterator(self.entries.iter())
|
StylesheetCollectionIterator(self.entries.iter())
|
||||||
|
@ -417,20 +409,6 @@ macro_rules! sheet_set_methods {
|
||||||
collection.append(sheet);
|
collection.append(sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepend a new stylesheet to the current set.
|
|
||||||
pub fn prepend_stylesheet(
|
|
||||||
&mut self,
|
|
||||||
device: Option<&Device>,
|
|
||||||
sheet: S,
|
|
||||||
guard: &SharedRwLockReadGuard,
|
|
||||||
) {
|
|
||||||
debug!(concat!($set_name, "::prepend_stylesheet"));
|
|
||||||
self.collect_invalidations_for(device, &sheet, guard);
|
|
||||||
|
|
||||||
let collection = self.collection_for(&sheet, guard);
|
|
||||||
collection.prepend(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Insert a given stylesheet before another stylesheet in the document.
|
/// Insert a given stylesheet before another stylesheet in the document.
|
||||||
pub fn insert_stylesheet_before(
|
pub fn insert_stylesheet_before(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
@ -582,12 +582,6 @@ impl Stylist {
|
||||||
.append_stylesheet(Some(&self.device), sheet, guard)
|
.append_stylesheet(Some(&self.device), sheet, guard)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Appends a new stylesheet to the current set.
|
|
||||||
pub fn prepend_stylesheet(&mut self, sheet: StylistSheet, guard: &SharedRwLockReadGuard) {
|
|
||||||
self.stylesheets
|
|
||||||
.prepend_stylesheet(Some(&self.device), sheet, guard)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove a given stylesheet to the current set.
|
/// Remove a given stylesheet to the current set.
|
||||||
pub fn remove_stylesheet(&mut self, sheet: StylistSheet, guard: &SharedRwLockReadGuard) {
|
pub fn remove_stylesheet(&mut self, sheet: StylistSheet, guard: &SharedRwLockReadGuard) {
|
||||||
self.stylesheets
|
self.stylesheets
|
||||||
|
|
171
components/style/values/animated/grid.rs
Normal file
171
components/style/values/animated/grid.rs
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
//! Animation implementation for various grid-related types.
|
||||||
|
|
||||||
|
// Note: we can implement Animate on their generic types directly, but in this case we need to
|
||||||
|
// make sure two trait bounds, L: Clone and I: PartialEq, are satisfied on almost all the
|
||||||
|
// grid-related types and their other trait implementations because Animate needs them. So in
|
||||||
|
// order to avoid adding these two trait bounds (or maybe more..) everywhere, we implement
|
||||||
|
// Animate for the computed types, instead of the generic types.
|
||||||
|
|
||||||
|
use super::{Animate, Procedure, ToAnimatedZero};
|
||||||
|
use crate::values::computed::Integer;
|
||||||
|
use crate::values::computed::LengthPercentage;
|
||||||
|
use crate::values::computed::{GridTemplateComponent, TrackList, TrackSize};
|
||||||
|
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||||
|
use crate::values::generics::grid as generics;
|
||||||
|
|
||||||
|
fn discrete<T: Clone>(from: &T, to: &T, procedure: Procedure) -> Result<T, ()> {
|
||||||
|
if let Procedure::Interpolate { progress } = procedure {
|
||||||
|
Ok(if progress < 0.5 {
|
||||||
|
from.clone()
|
||||||
|
} else {
|
||||||
|
to.clone()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn animate_with_discrete_fallback<T: Animate + Clone>(
|
||||||
|
from: &T,
|
||||||
|
to: &T,
|
||||||
|
procedure: Procedure,
|
||||||
|
) -> Result<T, ()> {
|
||||||
|
from.animate(to, procedure)
|
||||||
|
.or_else(|_| discrete(from, to, procedure))
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Animate for TrackSize {
|
||||||
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||||
|
match (self, other) {
|
||||||
|
(&generics::TrackSize::Breadth(ref from), &generics::TrackSize::Breadth(ref to)) => {
|
||||||
|
animate_with_discrete_fallback(from, to, procedure)
|
||||||
|
.map(generics::TrackSize::Breadth)
|
||||||
|
},
|
||||||
|
(
|
||||||
|
&generics::TrackSize::Minmax(ref from_min, ref from_max),
|
||||||
|
&generics::TrackSize::Minmax(ref to_min, ref to_max),
|
||||||
|
) => Ok(generics::TrackSize::Minmax(
|
||||||
|
animate_with_discrete_fallback(from_min, to_min, procedure)?,
|
||||||
|
animate_with_discrete_fallback(from_max, to_max, procedure)?,
|
||||||
|
)),
|
||||||
|
(
|
||||||
|
&generics::TrackSize::FitContent(ref from),
|
||||||
|
&generics::TrackSize::FitContent(ref to),
|
||||||
|
) => animate_with_discrete_fallback(from, to, procedure)
|
||||||
|
.map(generics::TrackSize::FitContent),
|
||||||
|
(_, _) => discrete(self, other, procedure),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Animate for generics::TrackRepeat<LengthPercentage, Integer>
|
||||||
|
where
|
||||||
|
generics::RepeatCount<Integer>: PartialEq,
|
||||||
|
{
|
||||||
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||||
|
// If the keyword, auto-fit/fill, is the same it can result in different
|
||||||
|
// number of tracks. For both auto-fit/fill, the number of columns isn't
|
||||||
|
// known until you do layout since it depends on the container size, item
|
||||||
|
// placement and other factors, so we cannot do the correct interpolation
|
||||||
|
// by computed values. Therefore, return Err(()) if it's keywords. If it
|
||||||
|
// is Number, we support animation only if the count is the same and the
|
||||||
|
// length of track_sizes is the same.
|
||||||
|
// https://github.com/w3c/csswg-drafts/issues/3503
|
||||||
|
match (&self.count, &other.count) {
|
||||||
|
(&generics::RepeatCount::Number(from), &generics::RepeatCount::Number(to))
|
||||||
|
if from == to =>
|
||||||
|
{
|
||||||
|
()
|
||||||
|
},
|
||||||
|
(_, _) => return Err(()),
|
||||||
|
}
|
||||||
|
|
||||||
|
// The length of track_sizes should be matched.
|
||||||
|
if self.track_sizes.len() != other.track_sizes.len() {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let count = self.count;
|
||||||
|
let track_sizes = self
|
||||||
|
.track_sizes
|
||||||
|
.iter()
|
||||||
|
.zip(other.track_sizes.iter())
|
||||||
|
.map(|(a, b)| a.animate(b, procedure))
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
// The length of |line_names| is always 0 or N+1, where N is the length
|
||||||
|
// of |track_sizes|. Besides, <line-names> is always discrete.
|
||||||
|
let line_names = discrete(&self.line_names, &other.line_names, procedure)?;
|
||||||
|
|
||||||
|
Ok(generics::TrackRepeat {
|
||||||
|
count,
|
||||||
|
line_names,
|
||||||
|
track_sizes,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Animate for TrackList {
|
||||||
|
// Based on https://github.com/w3c/csswg-drafts/issues/3201:
|
||||||
|
// 1. Check interpolation type per track, so we need to handle discrete animations
|
||||||
|
// in TrackSize, so any Err(()) returned from TrackSize doesn't make all TrackSize
|
||||||
|
// fallback to discrete animation.
|
||||||
|
// 2. line-names is always discrete.
|
||||||
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||||
|
if self.values.len() != other.values.len() {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.list_type != other.list_type {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
|
||||||
|
// For now, repeat(auto-fill/auto-fit, ...) is not animatable. TrackRepeat will
|
||||||
|
// return Err(()) if we use keywords. Therefore, we can early return here to avoid
|
||||||
|
// traversing |values| in <auto-track-list>. This may be updated in the future.
|
||||||
|
// https://github.com/w3c/csswg-drafts/issues/3503
|
||||||
|
if let generics::TrackListType::Auto(_) = self.list_type {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let list_type = self.list_type;
|
||||||
|
let auto_repeat = self.auto_repeat.animate(&other.auto_repeat, procedure)?;
|
||||||
|
let values = self
|
||||||
|
.values
|
||||||
|
.iter()
|
||||||
|
.zip(other.values.iter())
|
||||||
|
.map(|(a, b)| a.animate(b, procedure))
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
// The length of |line_names| is always 0 or N+1, where N is the length
|
||||||
|
// of |track_sizes|. Besides, <line-names> is always discrete.
|
||||||
|
let line_names = discrete(&self.line_names, &other.line_names, procedure)?;
|
||||||
|
|
||||||
|
Ok(TrackList {
|
||||||
|
list_type,
|
||||||
|
values,
|
||||||
|
line_names,
|
||||||
|
auto_repeat,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ComputeSquaredDistance for GridTemplateComponent {
|
||||||
|
#[inline]
|
||||||
|
fn compute_squared_distance(&self, _other: &Self) -> Result<SquaredDistance, ()> {
|
||||||
|
// TODO: Bug 1518585, we should implement ComputeSquaredDistance.
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToAnimatedZero for GridTemplateComponent {
|
||||||
|
#[inline]
|
||||||
|
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||||
|
// It's not clear to get a zero grid track list based on the current definition
|
||||||
|
// of spec, so we return Err(()) directly.
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ use std::cmp;
|
||||||
pub mod color;
|
pub mod color;
|
||||||
pub mod effects;
|
pub mod effects;
|
||||||
mod font;
|
mod font;
|
||||||
|
mod grid;
|
||||||
mod length;
|
mod length;
|
||||||
mod svg;
|
mod svg;
|
||||||
pub mod transform;
|
pub mod transform;
|
||||||
|
@ -113,7 +114,8 @@ pub fn animate_multiplicative_factor(
|
||||||
/// function has been specified through `#[animate(fallback)]`.
|
/// function has been specified through `#[animate(fallback)]`.
|
||||||
///
|
///
|
||||||
/// Trait bounds for type parameter `Foo` can be opted out of with
|
/// Trait bounds for type parameter `Foo` can be opted out of with
|
||||||
/// `#[animation(no_bound(Foo))]` on the type definition.
|
/// `#[animation(no_bound(Foo))]` on the type definition, trait bounds for
|
||||||
|
/// fields can be opted into with `#[animation(field_bound)]` on the field.
|
||||||
pub trait Animate: Sized {
|
pub trait Animate: Sized {
|
||||||
/// Animate a value towards another one, given an animation procedure.
|
/// Animate a value towards another one, given an animation procedure.
|
||||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()>;
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()>;
|
||||||
|
|
|
@ -13,7 +13,8 @@ use crate::values::specified::box_ as specified;
|
||||||
|
|
||||||
pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin};
|
pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin};
|
||||||
pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
|
pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
|
||||||
pub use crate::values::specified::box_::{Contain, Display, Overflow, OverflowClipBox};
|
pub use crate::values::specified::box_::{Contain, Display, Overflow};
|
||||||
|
pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox};
|
||||||
pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapType};
|
pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapType};
|
||||||
pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
|
pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
|
||||||
pub use self::border::{BorderImageSlice, BorderImageWidth};
|
pub use self::border::{BorderImageSlice, BorderImageWidth};
|
||||||
pub use self::box_::{AnimationIterationCount, AnimationName, Contain};
|
pub use self::box_::{AnimationIterationCount, AnimationName, Contain};
|
||||||
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
|
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
|
||||||
pub use self::box_::{Display, Overflow, TransitionProperty};
|
pub use self::box_::{Display, Overflow, OverflowAnchor, TransitionProperty};
|
||||||
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
|
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
|
||||||
pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange};
|
pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange};
|
||||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||||
|
|
|
@ -151,6 +151,7 @@ impl Parse for GridLine<specified::Integer> {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
#[derive(
|
#[derive(
|
||||||
|
Animate,
|
||||||
Clone,
|
Clone,
|
||||||
Copy,
|
Copy,
|
||||||
Debug,
|
Debug,
|
||||||
|
@ -172,7 +173,9 @@ pub enum TrackKeyword {
|
||||||
/// avoid re-implementing it for the computed type.
|
/// avoid re-implementing it for the computed type.
|
||||||
///
|
///
|
||||||
/// <https://drafts.csswg.org/css-grid/#typedef-track-breadth>
|
/// <https://drafts.csswg.org/css-grid/#typedef-track-breadth>
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
#[derive(
|
||||||
|
Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
||||||
|
)]
|
||||||
pub enum TrackBreadth<L> {
|
pub enum TrackBreadth<L> {
|
||||||
/// The generic type is almost always a non-negative `<length-percentage>`
|
/// The generic type is almost always a non-negative `<length-percentage>`
|
||||||
Breadth(L),
|
Breadth(L),
|
||||||
|
@ -481,12 +484,14 @@ impl<L: Clone> TrackRepeat<L, specified::Integer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Track list values. Can be <track-size> or <track-repeat>
|
/// Track list values. Can be <track-size> or <track-repeat>
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
#[derive(
|
||||||
|
Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
||||||
|
)]
|
||||||
pub enum TrackListValue<LengthPercentage, Integer> {
|
pub enum TrackListValue<LengthPercentage, Integer> {
|
||||||
/// A <track-size> value.
|
/// A <track-size> value.
|
||||||
TrackSize(TrackSize<LengthPercentage>),
|
TrackSize(#[animation(field_bound)] TrackSize<LengthPercentage>),
|
||||||
/// A <track-repeat> value.
|
/// A <track-repeat> value.
|
||||||
TrackRepeat(TrackRepeat<LengthPercentage, Integer>),
|
TrackRepeat(#[animation(field_bound)] TrackRepeat<LengthPercentage, Integer>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type of a `<track-list>` as determined during parsing.
|
/// The type of a `<track-list>` as determined during parsing.
|
||||||
|
@ -692,13 +697,21 @@ impl ToCss for LineNameList {
|
||||||
/// Variants for `<grid-template-rows> | <grid-template-columns>`
|
/// Variants for `<grid-template-rows> | <grid-template-columns>`
|
||||||
/// Subgrid deferred to Level 2 spec due to lack of implementation.
|
/// Subgrid deferred to Level 2 spec due to lack of implementation.
|
||||||
/// But it's implemented in gecko, so we have to as well.
|
/// But it's implemented in gecko, so we have to as well.
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
#[derive(
|
||||||
|
Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
||||||
|
)]
|
||||||
pub enum GridTemplateComponent<L, I> {
|
pub enum GridTemplateComponent<L, I> {
|
||||||
/// `none` value.
|
/// `none` value.
|
||||||
None,
|
None,
|
||||||
/// The grid `<track-list>`
|
/// The grid `<track-list>`
|
||||||
TrackList(#[compute(field_bound)] TrackList<L, I>),
|
TrackList(
|
||||||
|
#[animation(field_bound)]
|
||||||
|
#[compute(field_bound)]
|
||||||
|
TrackList<L, I>,
|
||||||
|
),
|
||||||
/// A `subgrid <line-name-list>?`
|
/// A `subgrid <line-name-list>?`
|
||||||
|
/// TODO: Support animations for this after subgrid is addressed in [grid-2] spec.
|
||||||
|
#[animation(error)]
|
||||||
Subgrid(LineNameList),
|
Subgrid(LineNameList),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,6 +413,26 @@ pub enum OverscrollBehavior {
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
Debug,
|
||||||
|
Eq,
|
||||||
|
MallocSizeOf,
|
||||||
|
Parse,
|
||||||
|
PartialEq,
|
||||||
|
SpecifiedValueInfo,
|
||||||
|
ToComputedValue,
|
||||||
|
ToCss,
|
||||||
|
)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum OverflowAnchor {
|
||||||
|
Auto,
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
|
@ -36,7 +36,8 @@ pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||||
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
|
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
|
||||||
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
|
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
|
||||||
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
|
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
|
||||||
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float, Overflow};
|
pub use self::box_::{Appearance, BreakBetween, BreakWithin};
|
||||||
|
pub use self::box_::{Clear, Float, Overflow, OverflowAnchor};
|
||||||
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
|
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
|
||||||
pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
|
pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
|
||||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::cg;
|
||||||
use darling::util::IdentList;
|
use darling::util::IdentList;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::TokenStreamExt;
|
use quote::TokenStreamExt;
|
||||||
use syn::{DeriveInput, Path};
|
use syn::{DeriveInput, Path, WhereClause};
|
||||||
use synstructure::{Structure, VariantInfo};
|
use synstructure::{Structure, VariantInfo};
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
|
@ -21,22 +21,25 @@ pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let (mut match_body, append_error_clause) = {
|
||||||
|
let s = Structure::new(&input);
|
||||||
|
let mut append_error_clause = s.variants().len() > 1;
|
||||||
|
|
||||||
|
let mut match_body = s.variants().iter().fold(quote!(), |body, variant| {
|
||||||
|
let arm = match derive_variant_arm(variant, &mut where_clause) {
|
||||||
|
Ok(arm) => arm,
|
||||||
|
Err(()) => {
|
||||||
|
append_error_clause = true;
|
||||||
|
return body;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
quote! { #body #arm }
|
||||||
|
});
|
||||||
|
(match_body, append_error_clause)
|
||||||
|
};
|
||||||
|
|
||||||
input.generics.where_clause = where_clause;
|
input.generics.where_clause = where_clause;
|
||||||
|
|
||||||
let s = Structure::new(&input);
|
|
||||||
let mut append_error_clause = s.variants().len() > 1;
|
|
||||||
|
|
||||||
let mut match_body = s.variants().iter().fold(quote!(), |body, variant| {
|
|
||||||
let arm = match derive_variant_arm(variant) {
|
|
||||||
Ok(arm) => arm,
|
|
||||||
Err(()) => {
|
|
||||||
append_error_clause = true;
|
|
||||||
return body;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
quote! { #body #arm }
|
|
||||||
});
|
|
||||||
|
|
||||||
if append_error_clause {
|
if append_error_clause {
|
||||||
let input_attrs = cg::parse_input_attrs::<AnimateInputAttrs>(&input);
|
let input_attrs = cg::parse_input_attrs::<AnimateInputAttrs>(&input);
|
||||||
if let Some(fallback) = input_attrs.fallback {
|
if let Some(fallback) = input_attrs.fallback {
|
||||||
|
@ -68,7 +71,10 @@ pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn derive_variant_arm(variant: &VariantInfo) -> Result<TokenStream, ()> {
|
fn derive_variant_arm(
|
||||||
|
variant: &VariantInfo,
|
||||||
|
where_clause: &mut Option<WhereClause>,
|
||||||
|
) -> Result<TokenStream, ()> {
|
||||||
let variant_attrs = cg::parse_variant_attrs_from_ast::<AnimationVariantAttrs>(&variant.ast());
|
let variant_attrs = cg::parse_variant_attrs_from_ast::<AnimationVariantAttrs>(&variant.ast());
|
||||||
if variant_attrs.error {
|
if variant_attrs.error {
|
||||||
return Err(());
|
return Err(());
|
||||||
|
@ -80,6 +86,13 @@ fn derive_variant_arm(variant: &VariantInfo) -> Result<TokenStream, ()> {
|
||||||
let iter = result_info.iter().zip(this_info.iter().zip(&other_info));
|
let iter = result_info.iter().zip(this_info.iter().zip(&other_info));
|
||||||
computations.append_all(iter.map(|(result, (this, other))| {
|
computations.append_all(iter.map(|(result, (this, other))| {
|
||||||
let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&result.ast());
|
let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&result.ast());
|
||||||
|
if field_attrs.field_bound {
|
||||||
|
let ty = &this.ast().ty;
|
||||||
|
cg::add_predicate(
|
||||||
|
where_clause,
|
||||||
|
parse_quote!(#ty: crate::values::animated::Animate),
|
||||||
|
);
|
||||||
|
}
|
||||||
if field_attrs.constant {
|
if field_attrs.constant {
|
||||||
quote! {
|
quote! {
|
||||||
if #this != #other {
|
if #this != #other {
|
||||||
|
@ -127,4 +140,5 @@ pub struct AnimationVariantAttrs {
|
||||||
#[derive(Default, FromField)]
|
#[derive(Default, FromField)]
|
||||||
pub struct AnimationFieldAttrs {
|
pub struct AnimationFieldAttrs {
|
||||||
pub constant: bool,
|
pub constant: bool,
|
||||||
|
pub field_bound: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ cssparser = "0.25"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
euclid = "0.19"
|
euclid = "0.19"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
selectors = { path = "../selectors" }
|
selectors = { path = "../selectors" }
|
||||||
serde = {version = "1.0", optional = true}
|
serde = {version = "1.0", optional = true}
|
||||||
webrender_api = {git = "https://github.com/servo/webrender", optional = true}
|
webrender_api = {git = "https://github.com/servo/webrender", optional = true}
|
||||||
|
|
|
@ -12,7 +12,7 @@ path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
malloc_size_of = { path = "../malloc_size_of", features = ["servo"] }
|
malloc_size_of = { path = "../malloc_size_of", features = ["servo"] }
|
||||||
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
|
malloc_size_of_derive = "0.1"
|
||||||
serde = {version = "1.0", features = ["derive"]}
|
serde = {version = "1.0", features = ["derive"]}
|
||||||
servo_rand = {path = "../rand"}
|
servo_rand = {path = "../rand"}
|
||||||
url = "1.2"
|
url = "1.2"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue