mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
style: Unbox a bunch of color properties.
This builds on https://github.com/servo/rust-cssparser/pull/118.
This commit is contained in:
parent
e394334739
commit
0c102e2350
37 changed files with 185 additions and 195 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -285,7 +285,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.11.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.11.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"canvas_traits 0.0.1",
|
"canvas_traits 0.0.1",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gleam 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gleam 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -301,7 +301,7 @@ dependencies = [
|
||||||
name = "canvas_traits"
|
name = "canvas_traits"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -543,7 +543,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cssparser"
|
name = "cssparser"
|
||||||
version = "0.7.4"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -926,7 +926,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1335,7 +1335,7 @@ dependencies = [
|
||||||
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"canvas_traits 0.0.1",
|
"canvas_traits 0.0.1",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gfx 0.0.1",
|
"gfx 0.0.1",
|
||||||
|
@ -1652,7 +1652,7 @@ name = "msg"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
|
@ -2253,7 +2253,7 @@ dependencies = [
|
||||||
"caseless 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"caseless 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"devtools_traits 0.0.1",
|
"devtools_traits 0.0.1",
|
||||||
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2320,7 +2320,7 @@ dependencies = [
|
||||||
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"canvas_traits 0.0.1",
|
"canvas_traits 0.0.1",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gfx_traits 0.0.1",
|
"gfx_traits 0.0.1",
|
||||||
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2388,7 +2388,7 @@ name = "selectors"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.5 (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)",
|
||||||
]
|
]
|
||||||
|
@ -2741,7 +2741,7 @@ dependencies = [
|
||||||
"bindgen 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bindgen 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2783,7 +2783,7 @@ name = "style_tests"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"html5ever-atoms 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"html5ever-atoms 0.1.3 (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)",
|
||||||
|
@ -2804,7 +2804,7 @@ name = "style_traits"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2819,7 +2819,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"geckoservo 0.0.1",
|
"geckoservo 0.0.1",
|
||||||
|
@ -3378,7 +3378,7 @@ dependencies = [
|
||||||
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
||||||
"checksum core-graphics 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b205856aba54bfd36e69a1058f45fbe0d3c37be7375309dcff4a22a2a631fea"
|
"checksum core-graphics 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b205856aba54bfd36e69a1058f45fbe0d3c37be7375309dcff4a22a2a631fea"
|
||||||
"checksum core-text 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9703f459a41e622b15ca612dbc5fa4b30b6545a32864a83e0fdc538cfa08969c"
|
"checksum core-text 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9703f459a41e622b15ca612dbc5fa4b30b6545a32864a83e0fdc538cfa08969c"
|
||||||
"checksum cssparser 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e562cb0d6ee9d8c367d3801d4dbaa0a0a94807745f710803b4ec4cf723ddd4"
|
"checksum cssparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03414777f8f1b026d920f7f96e4a19d0237456a0485fb6135847b7699c258ec2"
|
||||||
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
|
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
|
||||||
"checksum dbus 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "94d266a872aaf68b50d02083c429a3686935ab6ab54824290509cdc422673eaf"
|
"checksum dbus 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "94d266a872aaf68b50d02083c429a3686935ab6ab54824290509cdc422673eaf"
|
||||||
"checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3"
|
"checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3"
|
||||||
|
|
|
@ -12,7 +12,7 @@ path = "lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
|
azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
|
||||||
canvas_traits = {path = "../canvas_traits"}
|
canvas_traits = {path = "../canvas_traits"}
|
||||||
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
|
cssparser = {version = "0.8", features = ["heap_size", "serde-serialization"]}
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
gleam = "0.2.8"
|
gleam = "0.2.8"
|
||||||
ipc-channel = "0.5"
|
ipc-channel = "0.5"
|
||||||
|
|
|
@ -1016,9 +1016,9 @@ impl ToAzureStyle for RGBA {
|
||||||
type Target = Color;
|
type Target = Color;
|
||||||
|
|
||||||
fn to_azure_style(self) -> Color {
|
fn to_azure_style(self) -> Color {
|
||||||
Color::rgba(self.red as AzFloat,
|
Color::rgba(self.red_f32() as AzFloat,
|
||||||
self.green as AzFloat,
|
self.green_f32() as AzFloat,
|
||||||
self.blue as AzFloat,
|
self.blue_f32() as AzFloat,
|
||||||
self.alpha as AzFloat)
|
self.alpha_f32() as AzFloat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ name = "canvas_traits"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
|
cssparser = {version = "0.8", features = ["heap_size", "serde-serialization"]}
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
heapsize = "0.3.0"
|
heapsize = "0.3.0"
|
||||||
heapsize_derive = "0.1"
|
heapsize_derive = "0.1"
|
||||||
|
|
|
@ -14,7 +14,7 @@ app_units = "0.3"
|
||||||
atomic_refcell = "0.1"
|
atomic_refcell = "0.1"
|
||||||
bitflags = "0.7"
|
bitflags = "0.7"
|
||||||
canvas_traits = {path = "../canvas_traits"}
|
canvas_traits = {path = "../canvas_traits"}
|
||||||
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
|
cssparser = {version = "0.8", features = ["heap_size", "serde-serialization"]}
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
gfx = {path = "../gfx"}
|
gfx = {path = "../gfx"}
|
||||||
|
|
|
@ -2188,7 +2188,7 @@ pub trait ToGfxColor {
|
||||||
|
|
||||||
impl ToGfxColor for RGBA {
|
impl ToGfxColor for RGBA {
|
||||||
fn to_gfx_color(&self) -> ColorF {
|
fn to_gfx_color(&self) -> ColorF {
|
||||||
ColorF::new(self.red, self.green, self.blue, self.alpha)
|
ColorF::new(self.red_f32(), self.green_f32(), self.blue_f32(), self.alpha_f32())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -607,12 +607,7 @@ impl CollapsedBorder {
|
||||||
CollapsedBorder {
|
CollapsedBorder {
|
||||||
style: border_top_style::T::none,
|
style: border_top_style::T::none,
|
||||||
width: Au(0),
|
width: Au(0),
|
||||||
color: Color::RGBA(RGBA {
|
color: Color::RGBA(RGBA::transparent()),
|
||||||
red: 0.0,
|
|
||||||
green: 0.0,
|
|
||||||
blue: 0.0,
|
|
||||||
alpha: 0.0,
|
|
||||||
}),
|
|
||||||
provenance: CollapsedBorderProvenance::FromTable,
|
provenance: CollapsedBorderProvenance::FromTable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "0.7"
|
bitflags = "0.7"
|
||||||
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
|
cssparser = {version = "0.8", features = ["heap_size", "serde-serialization"]}
|
||||||
heapsize = "0.3.0"
|
heapsize = "0.3.0"
|
||||||
heapsize_derive = "0.1"
|
heapsize_derive = "0.1"
|
||||||
plugins = {path = "../plugins"}
|
plugins = {path = "../plugins"}
|
||||||
|
|
|
@ -34,7 +34,7 @@ byteorder = "1.0"
|
||||||
canvas_traits = {path = "../canvas_traits"}
|
canvas_traits = {path = "../canvas_traits"}
|
||||||
caseless = "0.1.0"
|
caseless = "0.1.0"
|
||||||
cookie = {version = "0.2.5", features = ["serialize-rustc"]}
|
cookie = {version = "0.2.5", features = ["serialize-rustc"]}
|
||||||
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
|
cssparser = {version = "0.8", features = ["heap_size", "serde-serialization"]}
|
||||||
devtools_traits = {path = "../devtools_traits"}
|
devtools_traits = {path = "../devtools_traits"}
|
||||||
encoding = "0.2"
|
encoding = "0.2"
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl CanvasGradientMethods for CanvasGradient {
|
||||||
let color = if parser.is_exhausted() {
|
let color = if parser.is_exhausted() {
|
||||||
match color {
|
match color {
|
||||||
Ok(CSSColor::RGBA(rgba)) => rgba,
|
Ok(CSSColor::RGBA(rgba)) => rgba,
|
||||||
Ok(CSSColor::CurrentColor) => RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 },
|
Ok(CSSColor::CurrentColor) => RGBA::new(0, 0, 0, 255),
|
||||||
_ => return Err(Error::Syntax)
|
_ => return Err(Error::Syntax)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -90,12 +90,7 @@ struct CanvasContextState {
|
||||||
|
|
||||||
impl CanvasContextState {
|
impl CanvasContextState {
|
||||||
fn new() -> CanvasContextState {
|
fn new() -> CanvasContextState {
|
||||||
let black = RGBA {
|
let black = RGBA::new(0, 0, 0, 255);
|
||||||
red: 0.0,
|
|
||||||
green: 0.0,
|
|
||||||
blue: 0.0,
|
|
||||||
alpha: 1.0,
|
|
||||||
};
|
|
||||||
CanvasContextState {
|
CanvasContextState {
|
||||||
global_alpha: 1.0,
|
global_alpha: 1.0,
|
||||||
global_composition: CompositionOrBlending::default(),
|
global_composition: CompositionOrBlending::default(),
|
||||||
|
@ -110,7 +105,7 @@ impl CanvasContextState {
|
||||||
shadow_offset_x: 0.0,
|
shadow_offset_x: 0.0,
|
||||||
shadow_offset_y: 0.0,
|
shadow_offset_y: 0.0,
|
||||||
shadow_blur: 0.0,
|
shadow_blur: 0.0,
|
||||||
shadow_color: RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0 }, // transparent black
|
shadow_color: RGBA::transparent(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,12 +485,7 @@ impl CanvasRenderingContext2D {
|
||||||
style.GetPropertyValue(DOMString::from("display")) == "none";
|
style.GetPropertyValue(DOMString::from("display")) == "none";
|
||||||
|
|
||||||
if element_not_rendered {
|
if element_not_rendered {
|
||||||
Ok(RGBA {
|
Ok(RGBA::new(0, 0, 0, 255))
|
||||||
red: 0.0,
|
|
||||||
green: 0.0,
|
|
||||||
blue: 0.0,
|
|
||||||
alpha: 1.0,
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
self.parse_color(&style.GetPropertyValue(DOMString::from("color")))
|
self.parse_color(&style.GetPropertyValue(DOMString::from("color")))
|
||||||
}
|
}
|
||||||
|
@ -1349,11 +1339,11 @@ fn is_rect_valid(rect: Rect<f64>) -> bool {
|
||||||
fn serialize<W>(color: &RGBA, dest: &mut W) -> fmt::Result
|
fn serialize<W>(color: &RGBA, dest: &mut W) -> fmt::Result
|
||||||
where W: fmt::Write
|
where W: fmt::Write
|
||||||
{
|
{
|
||||||
let red = (color.red * 255.).round() as u8;
|
let red = color.red;
|
||||||
let green = (color.green * 255.).round() as u8;
|
let green = color.green;
|
||||||
let blue = (color.blue * 255.).round() as u8;
|
let blue = color.blue;
|
||||||
|
|
||||||
if color.alpha == 1f32 {
|
if color.alpha == 255 {
|
||||||
write!(dest,
|
write!(dest,
|
||||||
"#{:x}{:x}{:x}{:x}{:x}{:x}",
|
"#{:x}{:x}{:x}{:x}{:x}{:x}",
|
||||||
red >> 4,
|
red >> 4,
|
||||||
|
@ -1363,6 +1353,6 @@ fn serialize<W>(color: &RGBA, dest: &mut W) -> fmt::Result
|
||||||
blue >> 4,
|
blue >> 4,
|
||||||
blue & 0xF)
|
blue & 0xF)
|
||||||
} else {
|
} else {
|
||||||
write!(dest, "rgba({}, {}, {}, {})", red, green, blue, color.alpha)
|
write!(dest, "rgba({}, {}, {}, {})", red, green, blue, color.alpha_f32())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,7 +407,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
if let Some(color) = bgcolor {
|
if let Some(color) = bgcolor {
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
|
PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
|
||||||
Box::new(CSSColor { parsed: Color::RGBA(color), authored: None })))));
|
CSSColor { parsed: Color::RGBA(color), authored: None }))));
|
||||||
}
|
}
|
||||||
|
|
||||||
let background = if let Some(this) = self.downcast::<HTMLBodyElement>() {
|
let background = if let Some(this) = self.downcast::<HTMLBodyElement>() {
|
||||||
|
@ -440,10 +440,10 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
|
|
||||||
if let Some(color) = color {
|
if let Some(color) = color {
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
PropertyDeclaration::Color(DeclaredValue::Value(Box::new(CSSRGBA {
|
PropertyDeclaration::Color(DeclaredValue::Value(CSSRGBA {
|
||||||
parsed: color,
|
parsed: color,
|
||||||
authored: None,
|
authored: None,
|
||||||
})))));
|
}))));
|
||||||
}
|
}
|
||||||
|
|
||||||
let font_family = if let Some(this) = self.downcast::<HTMLFontElement>() {
|
let font_family = if let Some(this) = self.downcast::<HTMLFontElement>() {
|
||||||
|
|
|
@ -13,7 +13,7 @@ path = "lib.rs"
|
||||||
app_units = "0.3"
|
app_units = "0.3"
|
||||||
atomic_refcell = "0.1"
|
atomic_refcell = "0.1"
|
||||||
canvas_traits = {path = "../canvas_traits"}
|
canvas_traits = {path = "../canvas_traits"}
|
||||||
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
|
cssparser = {version = "0.8", features = ["heap_size", "serde-serialization"]}
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
gfx_traits = {path = "../gfx_traits"}
|
gfx_traits = {path = "../gfx_traits"}
|
||||||
heapsize = "0.3.0"
|
heapsize = "0.3.0"
|
||||||
|
|
|
@ -18,5 +18,5 @@ path = "lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "0.7"
|
bitflags = "0.7"
|
||||||
matches = "0.1"
|
matches = "0.1"
|
||||||
cssparser = ">=0.6, <0.8"
|
cssparser = ">=0.6, <0.9"
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
|
|
|
@ -26,7 +26,7 @@ app_units = "0.3"
|
||||||
atomic_refcell = "0.1"
|
atomic_refcell = "0.1"
|
||||||
bitflags = "0.7"
|
bitflags = "0.7"
|
||||||
cfg-if = "0.1.0"
|
cfg-if = "0.1.0"
|
||||||
cssparser = "0.7.3"
|
cssparser = "0.8"
|
||||||
encoding = "0.2"
|
encoding = "0.2"
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
|
|
|
@ -394,12 +394,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
|
||||||
hex(input.as_bytes()[1] as char),
|
hex(input.as_bytes()[1] as char),
|
||||||
hex(input.as_bytes()[2] as char),
|
hex(input.as_bytes()[2] as char),
|
||||||
hex(input.as_bytes()[3] as char)) {
|
hex(input.as_bytes()[3] as char)) {
|
||||||
return Ok(RGBA {
|
return Ok(RGBA::new(r * 17, g * 17, b * 17, 255))
|
||||||
red: (r as f32) * 17.0 / 255.0,
|
|
||||||
green: (g as f32) * 17.0 / 255.0,
|
|
||||||
blue: (b as f32) * 17.0 / 255.0,
|
|
||||||
alpha: 1.0,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,12 +461,10 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA, ()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steps 15-20.
|
// Steps 15-20.
|
||||||
return Ok(RGBA {
|
return Ok(RGBA::new(hex_string(red).unwrap(),
|
||||||
red: hex_string(red).unwrap() as f32 / 255.0,
|
hex_string(green).unwrap(),
|
||||||
green: hex_string(green).unwrap() as f32 / 255.0,
|
hex_string(blue).unwrap(),
|
||||||
blue: hex_string(blue).unwrap() as f32 / 255.0,
|
255));
|
||||||
alpha: 1.0,
|
|
||||||
});
|
|
||||||
|
|
||||||
fn hex(ch: char) -> Result<u8, ()> {
|
fn hex(ch: char) -> Result<u8, ()> {
|
||||||
match ch {
|
match ch {
|
||||||
|
|
|
@ -225,20 +225,18 @@ impl GeckoStyleCoordConvertible for None_ {
|
||||||
|
|
||||||
/// Convert a given RGBA value to `nscolor`.
|
/// Convert a given RGBA value to `nscolor`.
|
||||||
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
||||||
(((rgba.alpha * 255.0).round() as u32) << 24) |
|
((rgba.alpha as u32) << 24) |
|
||||||
(((rgba.blue * 255.0).round() as u32) << 16) |
|
((rgba.blue as u32) << 16) |
|
||||||
(((rgba.green * 255.0).round() as u32) << 8) |
|
((rgba.green as u32) << 8) |
|
||||||
((rgba.red * 255.0).round() as u32)
|
(rgba.red as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a given `nscolor` to a Servo RGBA value.
|
/// Convert a given `nscolor` to a Servo RGBA value.
|
||||||
pub fn convert_nscolor_to_rgba(color: u32) -> RGBA {
|
pub fn convert_nscolor_to_rgba(color: u32) -> RGBA {
|
||||||
RGBA {
|
RGBA::new((color & 0xff) as u8,
|
||||||
red: ((color & 0xff) as f32) / 255.0,
|
(color >> 8 & 0xff) as u8,
|
||||||
green: (((color >> 8) & 0xff) as f32) / 255.0,
|
(color >> 16 & 0xff) as u8,
|
||||||
blue: (((color >> 16) & 0xff) as f32) / 255.0,
|
(color >> 24 & 0xff) as u8)
|
||||||
alpha: (((color >> 24) & 0xff) as f32) / 255.0,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Round `width` down to the nearest device pixel, but any non-zero value that
|
/// Round `width` down to the nearest device pixel, but any non-zero value that
|
||||||
|
|
|
@ -510,18 +510,21 @@ impl Interpolate for RGBA {
|
||||||
val.max(0.).min(1.)
|
val.max(0.).min(1.)
|
||||||
}
|
}
|
||||||
|
|
||||||
let alpha = clamp(try!(self.alpha.interpolate(&other.alpha, progress)));
|
let alpha = clamp(try!(self.alpha_f32().interpolate(&other.alpha_f32(), progress)));
|
||||||
if alpha == 0. {
|
if alpha == 0. {
|
||||||
Ok(RGBA { red: 0., green: 0., blue: 0., alpha: 0. })
|
Ok(RGBA::transparent())
|
||||||
} else {
|
} else {
|
||||||
Ok(RGBA { red: clamp(try!((self.red * self.alpha).interpolate(&(other.red * other.alpha), progress))
|
// NB: We rely on RGBA::from_floats clamping already.
|
||||||
* 1. / alpha),
|
let red = try!((self.red_f32() * self.alpha_f32())
|
||||||
green: clamp(try!((self.green * self.alpha).interpolate(&(other.green * other.alpha), progress))
|
.interpolate(&(other.red_f32() * other.alpha_f32()), progress))
|
||||||
* 1. / alpha),
|
* 1. / alpha;
|
||||||
blue: clamp(try!((self.blue * self.alpha).interpolate(&(other.blue * other.alpha), progress))
|
let green = try!((self.green_f32() * self.alpha_f32())
|
||||||
* 1. / alpha),
|
.interpolate(&(other.green_f32() * other.alpha_f32()), progress))
|
||||||
alpha: alpha
|
* 1. / alpha;
|
||||||
})
|
let blue = try!((self.blue_f32() * self.alpha_f32())
|
||||||
|
.interpolate(&(other.blue_f32() * other.alpha_f32()), progress))
|
||||||
|
* 1. / alpha;
|
||||||
|
Ok(RGBA::from_floats(red, green, blue, alpha))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -756,9 +759,7 @@ impl Interpolate for TextShadowList {
|
||||||
offset_x: Au(0),
|
offset_x: Au(0),
|
||||||
offset_y: Au(0),
|
offset_y: Au(0),
|
||||||
blur_radius: Au(0),
|
blur_radius: Au(0),
|
||||||
color: CSSParserColor::RGBA(RGBA {
|
color: CSSParserColor::RGBA(RGBA::transparent()),
|
||||||
red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let max_len = cmp::max(self.0.len(), other.0.len());
|
let max_len = cmp::max(self.0.len(), other.0.len());
|
||||||
|
@ -793,9 +794,7 @@ impl Interpolate for BoxShadowList {
|
||||||
offset_y: Au(0),
|
offset_y: Au(0),
|
||||||
spread_radius: Au(0),
|
spread_radius: Au(0),
|
||||||
blur_radius: Au(0),
|
blur_radius: Au(0),
|
||||||
color: CSSParserColor::RGBA(RGBA {
|
color: CSSParserColor::RGBA(RGBA::transparent()),
|
||||||
red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0
|
|
||||||
}),
|
|
||||||
inset: false,
|
inset: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
<% data.new_style_struct("Background", inherited=False) %>
|
<% data.new_style_struct("Background", inherited=False) %>
|
||||||
|
|
||||||
${helpers.predefined_type("background-color", "CSSColor",
|
${helpers.predefined_type("background-color", "CSSColor",
|
||||||
"::cssparser::Color::RGBA(::cssparser::RGBA { red: 0., green: 0., blue: 0., alpha: 0. }) /* transparent */",
|
"::cssparser::Color::RGBA(::cssparser::RGBA::transparent())",
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#background-color",
|
spec="https://drafts.csswg.org/css-backgrounds/#background-color",
|
||||||
animatable=True, complex_color=True, boxed=True)}
|
animatable=True, complex_color=True)}
|
||||||
|
|
||||||
<%helpers:vector_longhand name="background-image" animatable="False"
|
<%helpers:vector_longhand name="background-image" animatable="False"
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image"
|
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
"::cssparser::Color::CurrentColor",
|
"::cssparser::Color::CurrentColor",
|
||||||
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-color"),
|
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-color"),
|
||||||
spec=maybe_logical_spec(side, "color"),
|
spec=maybe_logical_spec(side, "color"),
|
||||||
animatable=True, logical = side[1], boxed=True)}
|
animatable=True, logical = side[1])}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
% for side in ALL_SIDES:
|
% for side in ALL_SIDES:
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<% data.new_style_struct("Color", inherited=True) %>
|
<% data.new_style_struct("Color", inherited=True) %>
|
||||||
|
|
||||||
<%helpers:raw_longhand name="color" need_clone="True" animatable="True" boxed="True"
|
<%helpers:raw_longhand name="color" need_clone="True" animatable="True"
|
||||||
spec="https://drafts.csswg.org/css-color/#color">
|
spec="https://drafts.csswg.org/css-color/#color">
|
||||||
use cssparser::Color as CSSParserColor;
|
use cssparser::Color as CSSParserColor;
|
||||||
use cssparser::RGBA;
|
use cssparser::RGBA;
|
||||||
|
@ -36,18 +36,18 @@
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
RGBA { red: 0., green: 0., blue: 0., alpha: 1. } /* black */
|
RGBA::new(0, 0, 0, 255) // black
|
||||||
}
|
}
|
||||||
pub fn parse_specified(context: &ParserContext, input: &mut Parser)
|
pub fn parse_specified(context: &ParserContext, input: &mut Parser)
|
||||||
-> Result<DeclaredValue<Box<SpecifiedValue>>, ()> {
|
-> Result<DeclaredValue<SpecifiedValue>, ()> {
|
||||||
let value = try!(CSSColor::parse(context, input));
|
let value = try!(CSSColor::parse(context, input));
|
||||||
let rgba = match value.parsed {
|
let rgba = match value.parsed {
|
||||||
CSSParserColor::RGBA(rgba) => rgba,
|
CSSParserColor::RGBA(rgba) => rgba,
|
||||||
CSSParserColor::CurrentColor => return Ok(DeclaredValue::Inherit)
|
CSSParserColor::CurrentColor => return Ok(DeclaredValue::Inherit)
|
||||||
};
|
};
|
||||||
Ok(DeclaredValue::Value(Box::new(CSSRGBA {
|
Ok(DeclaredValue::Value(CSSRGBA {
|
||||||
parsed: rgba,
|
parsed: rgba,
|
||||||
authored: value.authored,
|
authored: value.authored,
|
||||||
})))
|
}))
|
||||||
}
|
}
|
||||||
</%helpers:raw_longhand>
|
</%helpers:raw_longhand>
|
||||||
|
|
|
@ -147,7 +147,7 @@ ${helpers.single_keyword("column-fill", "auto balance", extra_prefixes="moz",
|
||||||
${helpers.predefined_type("column-rule-color", "CSSColor",
|
${helpers.predefined_type("column-rule-color", "CSSColor",
|
||||||
"::cssparser::Color::CurrentColor",
|
"::cssparser::Color::CurrentColor",
|
||||||
products="gecko", animatable=True, extra_prefixes="moz",
|
products="gecko", animatable=True, extra_prefixes="moz",
|
||||||
complex_color=True, need_clone=True, boxed=True,
|
complex_color=True, need_clone=True,
|
||||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-color")}
|
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-color")}
|
||||||
|
|
||||||
// It's not implemented in servo or gecko yet.
|
// It's not implemented in servo or gecko yet.
|
||||||
|
|
|
@ -429,7 +429,7 @@ ${helpers.single_keyword("text-align-last",
|
||||||
<%helpers:longhand name="-servo-text-decorations-in-effect"
|
<%helpers:longhand name="-servo-text-decorations-in-effect"
|
||||||
derived_from="display text-decoration"
|
derived_from="display text-decoration"
|
||||||
need_clone="True" products="servo"
|
need_clone="True" products="servo"
|
||||||
animatable="False" boxed="True"
|
animatable="False"
|
||||||
spec="Nonstandard (Internal property used by Servo)">
|
spec="Nonstandard (Internal property used by Servo)">
|
||||||
use cssparser::RGBA;
|
use cssparser::RGBA;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -1027,7 +1027,6 @@ ${helpers.predefined_type("text-emphasis-color", "CSSColor",
|
||||||
"::cssparser::Color::CurrentColor",
|
"::cssparser::Color::CurrentColor",
|
||||||
products="gecko", animatable=True,
|
products="gecko", animatable=True,
|
||||||
complex_color=True, need_clone=True,
|
complex_color=True, need_clone=True,
|
||||||
boxed=True,
|
|
||||||
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-color")}
|
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-color")}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1045,14 +1044,14 @@ ${helpers.predefined_type(
|
||||||
"-webkit-text-fill-color", "CSSColor",
|
"-webkit-text-fill-color", "CSSColor",
|
||||||
"CSSParserColor::CurrentColor",
|
"CSSParserColor::CurrentColor",
|
||||||
products="gecko", animatable=True,
|
products="gecko", animatable=True,
|
||||||
complex_color=True, need_clone=True, boxed=True,
|
complex_color=True, need_clone=True,
|
||||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color")}
|
spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color")}
|
||||||
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"-webkit-text-stroke-color", "CSSColor",
|
"-webkit-text-stroke-color", "CSSColor",
|
||||||
"CSSParserColor::CurrentColor",
|
"CSSParserColor::CurrentColor",
|
||||||
products="gecko", animatable=True,
|
products="gecko", animatable=True,
|
||||||
complex_color=True, need_clone=True, boxed=True,
|
complex_color=True, need_clone=True,
|
||||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")}
|
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")}
|
||||||
|
|
||||||
<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" animatable="False"
|
<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" animatable="False"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
// TODO(pcwalton): `invert`
|
// TODO(pcwalton): `invert`
|
||||||
${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::CurrentColor",
|
${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::CurrentColor",
|
||||||
animatable=True, complex_color=True, need_clone=True, boxed=True,
|
animatable=True, complex_color=True, need_clone=True,
|
||||||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-color")}
|
spec="https://drafts.csswg.org/css-ui/#propdef-outline-color")}
|
||||||
|
|
||||||
<%helpers:longhand name="outline-style" need_clone="True" animatable="False"
|
<%helpers:longhand name="outline-style" need_clone="True" animatable="False"
|
||||||
|
|
|
@ -22,10 +22,9 @@ ${helpers.single_keyword("vector-effect", "none non-scaling-stroke",
|
||||||
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"stop-color", "CSSColor",
|
"stop-color", "CSSColor",
|
||||||
"CSSParserColor::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 })",
|
"CSSParserColor::RGBA(RGBA::new(0, 0, 0, 255))",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
animatable=False,
|
animatable=False,
|
||||||
boxed=True,
|
|
||||||
spec="https://www.w3.org/TR/SVGTiny12/painting.html#StopColorProperty")}
|
spec="https://www.w3.org/TR/SVGTiny12/painting.html#StopColorProperty")}
|
||||||
|
|
||||||
${helpers.predefined_type("stop-opacity", "Opacity", "1.0",
|
${helpers.predefined_type("stop-opacity", "Opacity", "1.0",
|
||||||
|
@ -37,10 +36,9 @@ ${helpers.predefined_type("stop-opacity", "Opacity", "1.0",
|
||||||
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"flood-color", "CSSColor",
|
"flood-color", "CSSColor",
|
||||||
"CSSParserColor::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 })",
|
"CSSParserColor::RGBA(RGBA::new(0, 0, 0, 255))",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
animatable=False,
|
animatable=False,
|
||||||
boxed=True,
|
|
||||||
spec="https://www.w3.org/TR/SVG/filters.html#FloodColorProperty")}
|
spec="https://www.w3.org/TR/SVG/filters.html#FloodColorProperty")}
|
||||||
|
|
||||||
${helpers.predefined_type("flood-opacity", "Opacity",
|
${helpers.predefined_type("flood-opacity", "Opacity",
|
||||||
|
@ -49,10 +47,9 @@ ${helpers.predefined_type("flood-opacity", "Opacity",
|
||||||
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"lighting-color", "CSSColor",
|
"lighting-color", "CSSColor",
|
||||||
"CSSParserColor::RGBA(RGBA { red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0 })",
|
"CSSParserColor::RGBA(RGBA::new(255, 255, 255, 255))",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
animatable=False,
|
animatable=False,
|
||||||
boxed=True,
|
|
||||||
spec="https://www.w3.org/TR/SVG/filters.html#LightingColorProperty")}
|
spec="https://www.w3.org/TR/SVG/filters.html#LightingColorProperty")}
|
||||||
|
|
||||||
// CSS Masking Module Level 1
|
// CSS Masking Module Level 1
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
pub enum Side {
|
pub enum Side {
|
||||||
Clip,
|
Clip,
|
||||||
Ellipsis,
|
Ellipsis,
|
||||||
String(String),
|
String(Box<str>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(Side::String(try!(input.expect_string()).into_owned()))
|
Ok(Side::String(try!(input.expect_string()).into_owned().into_boxed_str()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,9 +210,8 @@ ${helpers.single_keyword("text-decoration-style",
|
||||||
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"text-decoration-color", "CSSColor",
|
"text-decoration-color", "CSSColor",
|
||||||
"CSSParserColor::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 })",
|
"CSSParserColor::RGBA(RGBA::new(0, 0, 0, 255))",
|
||||||
complex_color=True,
|
complex_color=True,
|
||||||
products="gecko",
|
products="gecko",
|
||||||
animatable=True,
|
animatable=True,
|
||||||
boxed=True,
|
|
||||||
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-color")}
|
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-color")}
|
||||||
|
|
|
@ -61,7 +61,7 @@ pub fn serialize_four_sides<W, I>(dest: &mut W,
|
||||||
fn serialize_directional_border<W, I,>(dest: &mut W,
|
fn serialize_directional_border<W, I,>(dest: &mut W,
|
||||||
width: &DeclaredValue<I>,
|
width: &DeclaredValue<I>,
|
||||||
style: &DeclaredValue<BorderStyle>,
|
style: &DeclaredValue<BorderStyle>,
|
||||||
color: &DeclaredValue<Box<CSSColor>>)
|
color: &DeclaredValue<CSSColor>)
|
||||||
-> fmt::Result where W: fmt::Write, I: ToCss {
|
-> fmt::Result where W: fmt::Write, I: ToCss {
|
||||||
match *width {
|
match *width {
|
||||||
DeclaredValue::Value(ref width) => {
|
DeclaredValue::Value(ref width) => {
|
||||||
|
|
|
@ -43,14 +43,14 @@ no_viewport_percentage!(i32); // For PropertyDeclaration::Order
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub struct CSSColor {
|
pub struct CSSColor {
|
||||||
pub parsed: cssparser::Color,
|
pub parsed: cssparser::Color,
|
||||||
pub authored: Option<String>,
|
pub authored: Option<Box<str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for CSSColor {
|
impl Parse for CSSColor {
|
||||||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||||
let start_position = input.position();
|
let start_position = input.position();
|
||||||
let authored = match input.next() {
|
let authored = match input.next() {
|
||||||
Ok(Token::Ident(s)) => Some(s.into_owned()),
|
Ok(Token::Ident(s)) => Some(s.into_owned().into_boxed_str()),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
input.reset(start_position);
|
input.reset(start_position);
|
||||||
|
@ -77,7 +77,7 @@ impl ToCss for CSSColor {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub struct CSSRGBA {
|
pub struct CSSRGBA {
|
||||||
pub parsed: cssparser::RGBA,
|
pub parsed: cssparser::RGBA,
|
||||||
pub authored: Option<String>,
|
pub authored: Option<Box<str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
no_viewport_percentage!(CSSRGBA);
|
no_viewport_percentage!(CSSRGBA);
|
||||||
|
|
|
@ -15,7 +15,7 @@ servo = ["heapsize", "heapsize_derive", "serde", "serde_derive",
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
app_units = "0.3"
|
app_units = "0.3"
|
||||||
cssparser = "0.7"
|
cssparser = "0.8"
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
heapsize = {version = "0.3.0", optional = true}
|
heapsize = {version = "0.3.0", optional = true}
|
||||||
heapsize_derive = {version = "0.1", optional = true}
|
heapsize_derive = {version = "0.1", optional = true}
|
||||||
|
|
|
@ -15,7 +15,7 @@ bindgen = ["style/use_bindgen"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
app_units = "0.3"
|
app_units = "0.3"
|
||||||
atomic_refcell = "0.1"
|
atomic_refcell = "0.1"
|
||||||
cssparser = {version = "0.7"}
|
cssparser = {version = "0.8"}
|
||||||
env_logger = {version = "0.4", default-features = false} # disable `regex` to reduce code size
|
env_logger = {version = "0.4", default-features = false} # disable `regex` to reduce code size
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
|
|
|
@ -980,12 +980,12 @@ pub extern "C" fn Servo_DeclarationBlock_AddPresValue(declarations: RawServoDecl
|
||||||
}
|
}
|
||||||
LonghandId::Color => {
|
LonghandId::Color => {
|
||||||
if let Some(color) = css_value.color_value() {
|
if let Some(color) = css_value.color_value() {
|
||||||
PropertyDeclaration::Color(DeclaredValue::Value(Box::new(
|
PropertyDeclaration::Color(DeclaredValue::Value(
|
||||||
specified::CSSRGBA {
|
specified::CSSRGBA {
|
||||||
parsed: convert_nscolor_to_rgba(color),
|
parsed: convert_nscolor_to_rgba(color),
|
||||||
authored: None
|
authored: None
|
||||||
}
|
}
|
||||||
)))
|
))
|
||||||
} else {
|
} else {
|
||||||
error!("stylo: got unexpected non-integer value for color presentation attribute");
|
error!("stylo: got unexpected non-integer value for color presentation attribute");
|
||||||
return
|
return
|
||||||
|
|
|
@ -14,7 +14,7 @@ testing = ["style/testing"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
app_units = "0.3"
|
app_units = "0.3"
|
||||||
cssparser = {version = "0.7", features = ["heap_size"]}
|
cssparser = {version = "0.8", features = ["heap_size"]}
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
html5ever-atoms = "0.1"
|
html5ever-atoms = "0.1"
|
||||||
matches = "0.1"
|
matches = "0.1"
|
||||||
|
|
|
@ -6,31 +6,45 @@ use cssparser::{Color, RGBA};
|
||||||
use style::properties::animated_properties::Interpolate;
|
use style::properties::animated_properties::Interpolate;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rgba_color_interepolation() {
|
fn test_rgba_color_interepolation_preserves_transparent() {
|
||||||
assert_eq!(Color::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0 }).interpolate(
|
assert_eq!(Color::RGBA(RGBA::transparent())
|
||||||
&Color::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0 }), 1.0).unwrap(),
|
.interpolate(&Color::RGBA(RGBA::transparent()), 0.5).unwrap(),
|
||||||
Color::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0 }));
|
Color::RGBA(RGBA::transparent()));
|
||||||
|
}
|
||||||
|
|
||||||
assert_eq!(Color::RGBA(RGBA { red: 1.0, green: 0.0, blue: 0.0, alpha: 0.6 }).interpolate(
|
#[test]
|
||||||
&Color::RGBA(RGBA { red: 0.0, green: 1.0, blue: 0.0, alpha: 0.4 }), 0.5).unwrap(),
|
fn test_rgba_color_interepolation_alpha() {
|
||||||
Color::RGBA(RGBA { red: 0.6, green: 0.4, blue: 0.0, alpha: 0.5 }));
|
assert_eq!(Color::RGBA(RGBA::new(200, 0, 0, 100))
|
||||||
|
.interpolate(&Color::RGBA(RGBA::new(0, 200, 0, 200)), 0.5).unwrap(),
|
||||||
|
Color::RGBA(RGBA::new(66, 133, 0, 150)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rgba_color_interepolation_out_of_range_1() {
|
||||||
// Some cubic-bezier functions produce values that are out of range [0, 1].
|
// Some cubic-bezier functions produce values that are out of range [0, 1].
|
||||||
// Unclamped cases.
|
// Unclamped cases.
|
||||||
assert_eq!(Color::RGBA(RGBA { red: 0.3, green: 0.0, blue: 0.0, alpha: 0.4 }).interpolate(
|
assert_eq!(Color::RGBA(RGBA::from_floats(0.3, 0.0, 0.0, 0.4)).interpolate(
|
||||||
&Color::RGBA(RGBA { red: 0.0, green: 1.0, blue: 0.0, alpha: 0.6 }), -0.5).unwrap(),
|
&Color::RGBA(RGBA::from_floats(0.0, 1.0, 0.0, 0.6)), -0.5).unwrap(),
|
||||||
Color::RGBA(RGBA { red: 0.6, green: 0.0, blue: 0.0, alpha: 0.3 }));
|
Color::RGBA(RGBA::new(152, 0, 0, 76)));
|
||||||
|
}
|
||||||
assert_eq!(Color::RGBA(RGBA { red: 1.0, green: 0.0, blue: 0.0, alpha: 0.6 }).interpolate(
|
|
||||||
&Color::RGBA(RGBA { red: 0.0, green: 0.3, blue: 0.0, alpha: 0.4 }), 1.5).unwrap(),
|
#[test]
|
||||||
Color::RGBA(RGBA { red: 0.0, green: 0.6, blue: 0.0, alpha: 0.3 }));
|
fn test_rgba_color_interepolation_out_of_range_2() {
|
||||||
|
assert_eq!(Color::RGBA(RGBA::from_floats(1.0, 0.0, 0.0, 0.6)).interpolate(
|
||||||
// Clamped cases.
|
&Color::RGBA(RGBA::from_floats(0.0, 0.3, 0.0, 0.4)), 1.5).unwrap(),
|
||||||
assert_eq!(Color::RGBA(RGBA { red: 1.0, green: 0.0, blue: 0.0, alpha: 0.8 }).interpolate(
|
Color::RGBA(RGBA::new(0, 152, 0, 76)));
|
||||||
&Color::RGBA(RGBA { red: 0.0, green: 1.0, blue: 0.0, alpha: 0.2 }), -0.5).unwrap(),
|
}
|
||||||
Color::RGBA(RGBA { red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0 }));
|
|
||||||
|
#[test]
|
||||||
assert_eq!(Color::RGBA(RGBA { red: 1.0, green: 0.0, blue: 0.0, alpha: 0.8 }).interpolate(
|
fn test_rgba_color_interepolation_out_of_range_clamped_1() {
|
||||||
&Color::RGBA(RGBA { red: 0.0, green: 1.0, blue: 0.0, alpha: 0.2 }), 1.5).unwrap(),
|
assert_eq!(Color::RGBA(RGBA::from_floats(1.0, 0.0, 0.0, 0.8)).interpolate(
|
||||||
Color::RGBA(RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0 }));
|
&Color::RGBA(RGBA::from_floats(0.0, 1.0, 0.0, 0.2)), -0.5).unwrap(),
|
||||||
|
Color::RGBA(RGBA::from_floats(1.0, 0.0, 0.0, 1.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rgba_color_interepolation_out_of_range_clamped_2() {
|
||||||
|
assert_eq!(Color::RGBA(RGBA::from_floats(1.0, 0.0, 0.0, 0.8)).interpolate(
|
||||||
|
&Color::RGBA(RGBA::from_floats(0.0, 1.0, 0.0, 0.2)), 1.5).unwrap(),
|
||||||
|
Color::RGBA(RGBA::from_floats(0.0, 0.0, 0.0, 0.0)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,15 +231,15 @@ mod shorthand_serialization {
|
||||||
fn border_color_should_serialize_correctly() {
|
fn border_color_should_serialize_correctly() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let red = DeclaredValue::Value(Box::new(CSSColor {
|
let red = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
|
|
||||||
let blue = DeclaredValue::Value(Box::new(CSSColor {
|
let blue = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 0f32, green: 0f32, blue: 1f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
|
|
||||||
properties.push(PropertyDeclaration::BorderTopColor(blue.clone()));
|
properties.push(PropertyDeclaration::BorderTopColor(blue.clone()));
|
||||||
properties.push(PropertyDeclaration::BorderRightColor(red.clone()));
|
properties.push(PropertyDeclaration::BorderRightColor(red.clone()));
|
||||||
|
@ -281,10 +281,10 @@ mod shorthand_serialization {
|
||||||
|
|
||||||
let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32)));
|
let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32)));
|
||||||
let style = DeclaredValue::Value(BorderStyle::solid);
|
let style = DeclaredValue::Value(BorderStyle::solid);
|
||||||
let color = DeclaredValue::Value(Box::new(CSSColor {
|
let color = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
|
|
||||||
properties.push(PropertyDeclaration::BorderTopWidth(width));
|
properties.push(PropertyDeclaration::BorderTopWidth(width));
|
||||||
properties.push(PropertyDeclaration::BorderTopStyle(style));
|
properties.push(PropertyDeclaration::BorderTopStyle(style));
|
||||||
|
@ -300,10 +300,10 @@ mod shorthand_serialization {
|
||||||
|
|
||||||
let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32)));
|
let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32)));
|
||||||
let style = DeclaredValue::Initial;
|
let style = DeclaredValue::Initial;
|
||||||
let color = DeclaredValue::Value(Box::new(CSSColor {
|
let color = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
|
|
||||||
properties.push(PropertyDeclaration::BorderTopWidth(width));
|
properties.push(PropertyDeclaration::BorderTopWidth(width));
|
||||||
properties.push(PropertyDeclaration::BorderTopStyle(style));
|
properties.push(PropertyDeclaration::BorderTopStyle(style));
|
||||||
|
@ -469,10 +469,10 @@ mod shorthand_serialization {
|
||||||
|
|
||||||
let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32)));
|
let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32)));
|
||||||
let style = DeclaredValue::Value(Either::Second(BorderStyle::solid));
|
let style = DeclaredValue::Value(Either::Second(BorderStyle::solid));
|
||||||
let color = DeclaredValue::Value(Box::new(CSSColor {
|
let color = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
|
|
||||||
properties.push(PropertyDeclaration::OutlineWidth(width));
|
properties.push(PropertyDeclaration::OutlineWidth(width));
|
||||||
properties.push(PropertyDeclaration::OutlineStyle(style));
|
properties.push(PropertyDeclaration::OutlineStyle(style));
|
||||||
|
@ -504,10 +504,10 @@ mod shorthand_serialization {
|
||||||
|
|
||||||
let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32)));
|
let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32)));
|
||||||
let style = DeclaredValue::Initial;
|
let style = DeclaredValue::Initial;
|
||||||
let color = DeclaredValue::Value(Box::new(CSSColor {
|
let color = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
properties.push(PropertyDeclaration::OutlineWidth(width));
|
properties.push(PropertyDeclaration::OutlineWidth(width));
|
||||||
properties.push(PropertyDeclaration::OutlineStyle(style));
|
properties.push(PropertyDeclaration::OutlineStyle(style));
|
||||||
properties.push(PropertyDeclaration::OutlineColor(color));
|
properties.push(PropertyDeclaration::OutlineColor(color));
|
||||||
|
@ -522,10 +522,10 @@ mod shorthand_serialization {
|
||||||
|
|
||||||
let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32)));
|
let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32)));
|
||||||
let style = DeclaredValue::Value(Either::First(Auto));
|
let style = DeclaredValue::Value(Either::First(Auto));
|
||||||
let color = DeclaredValue::Value(Box::new(CSSColor {
|
let color = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
properties.push(PropertyDeclaration::OutlineWidth(width));
|
properties.push(PropertyDeclaration::OutlineWidth(width));
|
||||||
properties.push(PropertyDeclaration::OutlineStyle(style));
|
properties.push(PropertyDeclaration::OutlineStyle(style));
|
||||||
properties.push(PropertyDeclaration::OutlineColor(color));
|
properties.push(PropertyDeclaration::OutlineColor(color));
|
||||||
|
@ -730,10 +730,10 @@ mod shorthand_serialization {
|
||||||
fn background_should_serialize_all_available_properties_when_specified() {
|
fn background_should_serialize_all_available_properties_when_specified() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let color = DeclaredValue::Value(Box::new(CSSColor {
|
let color = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
|
|
||||||
let position_x = single_vec_value_typedef!(position_x,
|
let position_x = single_vec_value_typedef!(position_x,
|
||||||
HorizontalPosition {
|
HorizontalPosition {
|
||||||
|
@ -790,10 +790,10 @@ mod shorthand_serialization {
|
||||||
fn background_should_combine_origin_and_clip_properties_when_equal() {
|
fn background_should_combine_origin_and_clip_properties_when_equal() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let color = DeclaredValue::Value(Box::new(CSSColor {
|
let color = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
|
|
||||||
let position_x = single_vec_value_typedef!(position_x,
|
let position_x = single_vec_value_typedef!(position_x,
|
||||||
HorizontalPosition {
|
HorizontalPosition {
|
||||||
|
@ -849,10 +849,10 @@ mod shorthand_serialization {
|
||||||
fn background_should_always_print_color_and_url_and_repeat_and_attachment_and_position() {
|
fn background_should_always_print_color_and_url_and_repeat_and_attachment_and_position() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let color = DeclaredValue::Value(Box::new(CSSColor {
|
let color = DeclaredValue::Value(CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA { red: 1f32, green: 0f32, blue: 0f32, alpha: 1f32 }),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
authored: None
|
authored: None
|
||||||
}));
|
});
|
||||||
|
|
||||||
let position_x = single_vec_value_typedef!(position_x,
|
let position_x = single_vec_value_typedef!(position_x,
|
||||||
HorizontalPosition {
|
HorizontalPosition {
|
||||||
|
|
|
@ -28,17 +28,25 @@ fn size_of_specified_values() {
|
||||||
let threshold = 40;
|
let threshold = 40;
|
||||||
let longhands = specified_value_sizes();
|
let longhands = specified_value_sizes();
|
||||||
|
|
||||||
|
let mut failing_messages = vec![];
|
||||||
|
|
||||||
for specified_value in longhands {
|
for specified_value in longhands {
|
||||||
if specified_value.1 >= threshold && !specified_value.2 {
|
if specified_value.1 >= threshold && !specified_value.2 {
|
||||||
panic!("Your changes have increased the size of {} SpecifiedValue to {}. The threshold is \
|
failing_messages.push(
|
||||||
|
format!("Your changes have increased the size of {} SpecifiedValue to {}. The threshold is \
|
||||||
currently {}. SpecifiedValues are affect size of PropertyDeclaration enum and \
|
currently {}. SpecifiedValues are affect size of PropertyDeclaration enum and \
|
||||||
increasing the size may dramatically affect our memory footprint. Please consider \
|
increasing the size may dramatically affect our memory footprint. Please consider \
|
||||||
using `boxed=\"True\"` in this longhand.",
|
using `boxed=\"True\"` in this longhand.",
|
||||||
specified_value.0, specified_value.1, threshold)
|
specified_value.0, specified_value.1, threshold));
|
||||||
} else if specified_value.1 < threshold && specified_value.2 {
|
} else if specified_value.1 < threshold && specified_value.2 {
|
||||||
panic!("Your changes have decreased the size of {} SpecifiedValue to {}. Good work! \
|
failing_messages.push(
|
||||||
|
format!("Your changes have decreased the size of {} SpecifiedValue to {}. Good work! \
|
||||||
The threshold is currently {}. Please consider removing `boxed=\"True\"` from this longhand.",
|
The threshold is currently {}. Please consider removing `boxed=\"True\"` from this longhand.",
|
||||||
specified_value.0, specified_value.1, threshold)
|
specified_value.0, specified_value.1, threshold));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !failing_messages.is_empty() {
|
||||||
|
panic!("{}", failing_messages.join("\n\n"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,12 +183,10 @@ fn test_parse_stylesheet() {
|
||||||
block: Arc::new(RwLock::new(PropertyDeclarationBlock {
|
block: Arc::new(RwLock::new(PropertyDeclarationBlock {
|
||||||
declarations: vec![
|
declarations: vec![
|
||||||
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
|
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
|
||||||
Box::new(longhands::background_color::SpecifiedValue {
|
longhands::background_color::SpecifiedValue {
|
||||||
authored: Some("blue".to_owned()),
|
authored: Some("blue".to_owned().into_boxed_str()),
|
||||||
parsed: cssparser::Color::RGBA(cssparser::RGBA {
|
parsed: cssparser::Color::RGBA(cssparser::RGBA::new(0, 0, 255, 255)),
|
||||||
red: 0., green: 0., blue: 1., alpha: 1.
|
}
|
||||||
}),
|
|
||||||
})
|
|
||||||
)),
|
)),
|
||||||
Importance::Normal),
|
Importance::Normal),
|
||||||
(PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value(
|
(PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value(
|
||||||
|
|
|
@ -14,7 +14,7 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
app_units = "0.3"
|
app_units = "0.3"
|
||||||
atomic_refcell = "0.1"
|
atomic_refcell = "0.1"
|
||||||
cssparser = {version = "0.7"}
|
cssparser = {version = "0.8"}
|
||||||
env_logger = "0.4"
|
env_logger = "0.4"
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue