Upgrade Stylo to 2024-03-01 (#32089)

* Upgrade Stylo to 2024-03-01

* Fixup for https://bugzil.la/1882754

* Update test expectations
This commit is contained in:
Oriol Brufau 2024-04-16 14:27:51 +02:00 committed by GitHub
parent 0678136b17
commit f5bdfdfe94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 290 additions and 302 deletions

217
Cargo.lock generated
View file

@ -572,6 +572,7 @@ dependencies = [
"byteorder",
"canvas_traits",
"crossbeam-channel",
"cssparser",
"euclid",
"fnv",
"font-kit",
@ -1001,6 +1002,15 @@ dependencies = [
"libc",
]
[[package]]
name = "core_maths"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b02505ccb8c50b0aa21ace0fc08c3e53adebd4e58caa18a36152803c7709a3"
dependencies = [
"libm",
]
[[package]]
name = "cpufeatures"
version = "0.2.12"
@ -1196,7 +1206,7 @@ dependencies = [
[[package]]
name = "derive_common"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"darling",
"proc-macro2",
@ -1296,6 +1306,17 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
[[package]]
name = "displaydoc"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
]
[[package]]
name = "dlib"
version = "0.5.2"
@ -2767,6 +2788,80 @@ dependencies = [
"cc",
]
[[package]]
name = "icu_collections"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "137d96353afc8544d437e8a99eceb10ab291352699573b0de5b08bda38c78c60"
dependencies = [
"displaydoc",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_locid"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c0aa2536adc14c07e2a521e95512b75ed8ef832f0fdf9299d4a0a45d2be2a9d"
dependencies = [
"displaydoc",
"litemap",
"tinystr",
"writeable",
]
[[package]]
name = "icu_provider"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba58e782287eb6950247abbf11719f83f5d4e4a5c1f2cd490d30a334bc47c2f4"
dependencies = [
"displaydoc",
"icu_locid",
"icu_provider_macros",
"stable_deref_trait",
"tinystr",
"writeable",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_provider_macros"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2abdd3a62551e8337af119c5899e600ca0c88ec8f23a46c60ba216c803dcf1a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
]
[[package]]
name = "icu_segmenter"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2dc1e8f4ba33a6a4956770ac5c08570f255d6605519fb3a859a0c0a270a2f8f"
dependencies = [
"core_maths",
"displaydoc",
"icu_collections",
"icu_locid",
"icu_provider",
"icu_segmenter_data",
"utf8_iter",
"zerovec",
]
[[package]]
name = "icu_segmenter_data"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3673d6698dcffce08cfe8fc5da3c11c3f2c663d5d6137fd58ab2cbf44235ab46"
[[package]]
name = "ident_case"
version = "1.0.1"
@ -3395,6 +3490,12 @@ version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "litemap"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d642685b028806386b2b6e75685faadd3eb65a85fff7df711ce18446a422da"
[[package]]
name = "lock_api"
version = "0.4.11"
@ -3449,7 +3550,7 @@ dependencies = [
[[package]]
name = "malloc_size_of"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"accountable-refcell",
"app_units",
@ -5062,7 +5163,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.24.0"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"bitflags 2.5.0",
"cssparser",
@ -5350,7 +5451,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.2.0"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"nodrop",
"serde",
@ -5360,7 +5461,7 @@ dependencies = [
[[package]]
name = "servo_atoms"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"string_cache",
"string_cache_codegen",
@ -5558,7 +5659,7 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]]
name = "size_of_test"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"static_assertions",
]
@ -5684,7 +5785,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "static_prefs"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
[[package]]
name = "strict-num"
@ -5721,7 +5822,7 @@ dependencies = [
[[package]]
name = "style"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"app_units",
"arrayvec",
@ -5734,6 +5835,7 @@ dependencies = [
"euclid",
"fxhash",
"html5ever",
"icu_segmenter",
"indexmap 1.9.3",
"itertools 0.10.5",
"itoa",
@ -5771,7 +5873,6 @@ dependencies = [
"to_shmem_derive",
"uluru",
"unicode-bidi",
"unicode-segmentation",
"url",
"void",
"walkdir",
@ -5780,7 +5881,7 @@ dependencies = [
[[package]]
name = "style_config"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"lazy_static",
]
@ -5788,7 +5889,7 @@ dependencies = [
[[package]]
name = "style_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"darling",
"derive_common",
@ -5819,7 +5920,7 @@ dependencies = [
[[package]]
name = "style_traits"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"app_units",
"bitflags 2.5.0",
@ -6155,6 +6256,15 @@ dependencies = [
"libc",
]
[[package]]
name = "tinystr"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83c02bf3c538ab32ba913408224323915f4ef9a6d61c0e85d493f355921c0ece"
dependencies = [
"displaydoc",
]
[[package]]
name = "tinyvec"
version = "1.6.0"
@ -6173,7 +6283,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "to_shmem"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"cssparser",
"servo_arc",
@ -6186,7 +6296,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-01-16#e801dd17ccf274844d7484e37172664fa3f99488"
source = "git+https://github.com/servo/stylo?branch=2024-03-01#df595694fd3182d68ad2f4373795cd3b50eff9ac"
dependencies = [
"darling",
"derive_common",
@ -6518,6 +6628,12 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "utf8_iter"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
name = "uuid"
version = "1.8.0"
@ -7397,6 +7513,12 @@ dependencies = [
"euclid",
]
[[package]]
name = "writeable"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dad7bb64b8ef9c0aa27b6da38b452b0ee9fd82beaf276a87dd796fb55cbae14e"
[[package]]
name = "x11"
version = "2.21.0"
@ -7487,6 +7609,30 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "yoke"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65e71b2e4f287f467794c671e2b8f8a5f3716b3c829079a1c44740148eff07e4"
dependencies = [
"serde",
"stable_deref_trait",
"yoke-derive",
"zerofrom",
]
[[package]]
name = "yoke-derive"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e6936f0cce458098a201c245a11bef556c6a0181129c7034d10d76d1ec3a2b8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
"synstructure 0.13.1",
]
[[package]]
name = "zerocopy"
version = "0.7.32"
@ -7507,6 +7653,49 @@ dependencies = [
"syn 2.0.58",
]
[[package]]
name = "zerofrom"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "655b0814c5c0b19ade497851070c640773304939a6c0fd5f5fb43da0696d05b7"
dependencies = [
"zerofrom-derive",
]
[[package]]
name = "zerofrom-derive"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6a647510471d372f2e6c2e6b7219e44d8c574d24fdc11c610a61455782f18c3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
"synstructure 0.13.1",
]
[[package]]
name = "zerovec"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eff4439ae91fb5c72b8abc12f3f2dbf51bd27e6eadb9f8a5bc8898dddb0e27ea"
dependencies = [
"yoke",
"zerofrom",
"zerovec-derive",
]
[[package]]
name = "zerovec-derive"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4e5997cbf58990550ef1f0e5124a05e47e1ebd33a84af25739be6031a62c20"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
]
[[package]]
name = "zune-inflate"
version = "0.2.54"

View file

@ -64,7 +64,7 @@ keyboard-types = "0.6"
lazy_static = "1.4"
libc = "0.2"
log = "0.4"
malloc_size_of = { git = "https://github.com/servo/stylo", branch = "2024-01-16", features = ["servo"] }
malloc_size_of = { git = "https://github.com/servo/stylo", branch = "2024-03-01", features = ["servo"] }
malloc_size_of_derive = "0.1"
mime = "0.3.13"
mime_guess = "2.0.3"
@ -87,31 +87,31 @@ rustls = { version = "0.21.10", features = ["dangerous_configuration"] }
rustls-pemfile = "1.0.4"
script_layout_interface = { path = "components/shared/script_layout" }
script_traits = { path = "components/shared/script" }
selectors = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
selectors = { git = "https://github.com/servo/stylo", branch = "2024-03-01" }
serde = "1.0.197"
serde_bytes = "0.11"
serde_json = "1.0"
servo-media = { git = "https://github.com/servo/media" }
servo-media-dummy = { git = "https://github.com/servo/media" }
servo-media-gstreamer = { git = "https://github.com/servo/media" }
servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
size_of_test = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-03-01" }
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-03-01" }
size_of_test = { git = "https://github.com/servo/stylo", branch = "2024-03-01" }
smallbitvec = "2.5.3"
smallvec = "1.13"
sparkle = "0.1.26"
string_cache = "0.8"
string_cache_codegen = "0.5"
style = { git = "https://github.com/servo/stylo", branch = "2024-01-16", features = ["servo"] }
style_config = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2024-01-16", features = ["servo"] }
style = { git = "https://github.com/servo/stylo", branch = "2024-03-01", features = ["servo"] }
style_config = { git = "https://github.com/servo/stylo", branch = "2024-03-01" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2024-03-01", features = ["servo"] }
# NOTE: the sm-angle feature only enables ANGLE on Windows, not other platforms!
surfman = { version = "0.9", features = ["chains", "sm-angle", "sm-angle-default"] }
syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
synstructure = "0.13"
thin-vec = "0.2.13"
time = "0.1.41"
to_shmem = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
to_shmem = { git = "https://github.com/servo/stylo", branch = "2024-03-01" }
tokio = "1"
tokio-rustls = "0.24"
tungstenite = "0.20"

View file

@ -20,6 +20,7 @@ bitflags = { workspace = true }
byteorder = { workspace = true }
canvas_traits = { workspace = true }
crossbeam-channel = { workspace = true }
cssparser = { workspace = true }
euclid = { workspace = true }
font-kit = "0.11"
fnv = { workspace = true }

View file

@ -21,7 +21,7 @@ use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
use log::{debug, error, warn};
use num_traits::ToPrimitive;
use servo_arc::Arc as ServoArc;
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font;
use style_traits::values::ToCss;
@ -74,7 +74,7 @@ impl PathState {
pub trait Backend {
fn get_composition_op(&self, opts: &DrawOptions) -> CompositionOp;
fn need_to_draw_shadow(&self, color: &Color) -> bool;
fn set_shadow_color(&mut self, color: RgbaLegacy, state: &mut CanvasPaintState<'_>);
fn set_shadow_color(&mut self, color: AbsoluteColor, state: &mut CanvasPaintState<'_>);
fn set_fill_style(
&mut self,
style: FillOrStrokeStyle,
@ -1155,7 +1155,7 @@ impl<'a> CanvasData<'a> {
self.state.shadow_blur = value;
}
pub fn set_shadow_color(&mut self, value: RgbaLegacy) {
pub fn set_shadow_color(&mut self, value: AbsoluteColor) {
self.backend.set_shadow_color(value, &mut self.state);
}

View file

@ -3,13 +3,14 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use canvas_traits::canvas::*;
use cssparser::color::clamp_unit_f32;
use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D};
use euclid::Angle;
use font_kit::font::Font;
use log::warn;
use lyon_geom::Arc;
use raqote::PathOp;
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use crate::canvas_data;
use crate::canvas_data::{
@ -29,7 +30,7 @@ impl Backend for RaqoteBackend {
color.as_raqote().a != 0
}
fn set_shadow_color(&mut self, color: RgbaLegacy, state: &mut CanvasPaintState<'_>) {
fn set_shadow_color(&mut self, color: AbsoluteColor, state: &mut CanvasPaintState<'_>) {
state.shadow_color = Color::Raqote(color.to_raqote_style());
}
@ -850,40 +851,14 @@ pub trait ToRaqoteGradientStop {
fn to_raqote(self) -> raqote::GradientStop;
}
/// Clamp a 0..1 number to a 0..255 range to u8.
///
/// Whilst scaling by 256 and flooring would provide
/// an equal distribution of integers to percentage inputs,
/// this is not what Gecko does so we instead multiply by 255
/// and round (adding 0.5 and flooring is equivalent to rounding)
///
/// Chrome does something similar for the alpha value, but not
/// the rgb values.
///
/// See <https://bugzilla.mozilla.org/show_bug.cgi?id=1340484>
///
/// Clamping to 256 and rounding after would let 1.0 map to 256, and
/// `256.0_f32 as u8` is undefined behavior:
///
/// <https://github.com/rust-lang/rust/issues/10184>
#[inline]
pub fn clamp_unit_f32(val: f32) -> u8 {
clamp_floor_256_f32(val * 255.)
}
/// Round and clamp a single number to a u8.
#[inline]
pub fn clamp_floor_256_f32(val: f32) -> u8 {
val.round().clamp(0., 255.) as u8
}
impl ToRaqoteGradientStop for CanvasGradientStop {
fn to_raqote(self) -> raqote::GradientStop {
let srgb = self.color.into_srgb_legacy();
let color = raqote::Color::new(
clamp_unit_f32(self.color.alpha),
self.color.red,
self.color.green,
self.color.blue,
clamp_unit_f32(srgb.alpha),
clamp_unit_f32(srgb.components.0),
clamp_unit_f32(srgb.components.1),
clamp_unit_f32(srgb.components.2),
);
let position = self.offset as f32;
raqote::GradientStop { position, color }
@ -896,12 +871,15 @@ impl ToRaqotePattern<'_> for FillOrStrokeStyle {
use canvas_traits::canvas::FillOrStrokeStyle::*;
match self {
Color(color) => Some(Pattern::Color(
clamp_unit_f32(color.alpha),
color.red,
color.green,
color.blue,
)),
Color(color) => {
let srgb = color.into_srgb_legacy();
Some(Pattern::Color(
clamp_unit_f32(srgb.alpha),
clamp_unit_f32(srgb.components.0),
clamp_unit_f32(srgb.components.1),
clamp_unit_f32(srgb.components.2),
))
},
LinearGradient(style) => {
let start = Point2D::new(style.x0 as f32, style.y0 as f32);
let end = Point2D::new(style.x1 as f32, style.y1 as f32);
@ -951,15 +929,16 @@ impl Color {
}
}
impl ToRaqoteStyle for RgbaLegacy {
impl ToRaqoteStyle for AbsoluteColor {
type Target = raqote::SolidSource;
fn to_raqote_style(self) -> Self::Target {
let srgb = self.into_srgb_legacy();
raqote::SolidSource::from_unpremultiplied_argb(
clamp_unit_f32(self.alpha),
self.red,
self.green,
self.blue,
clamp_unit_f32(srgb.alpha),
clamp_unit_f32(srgb.components.0),
clamp_unit_f32(srgb.components.1),
clamp_unit_f32(srgb.components.2),
)
}
}

View file

@ -12,6 +12,7 @@ use canvas_traits::canvas::{
FillRule, LineCapStyle, LineJoinStyle, LinearGradientStyle, RadialGradientStyle,
RepetitionStyle, TextAlign, TextBaseline,
};
use cssparser::color::clamp_unit_f32;
use cssparser::{Parser, ParserInput};
use euclid::default::{Point2D, Rect, Size2D, Transform2D};
use euclid::vec2;
@ -22,8 +23,7 @@ use pixels::PixelFormat;
use profile_traits::ipc as profiled_ipc;
use script_traits::ScriptMsg;
use servo_url::{ImmutableOrigin, ServoUrl};
use style::color::parsing::RgbaLegacy;
use style::color::{AbsoluteColor, ColorSpace};
use style::color::{AbsoluteColor, ColorFlags, ColorSpace};
use style::context::QuirksMode;
use style::parser::ParserContext;
use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps;
@ -32,7 +32,7 @@ use style::stylesheets::{CssRuleType, Origin};
use style::values::computed::font::FontStyle;
use style::values::specified::color::Color;
use style_traits::values::ToCss;
use style_traits::ParsingMode;
use style_traits::{CssWriter, ParsingMode};
use url::Url;
use crate::dom::bindings::cell::DomRefCell;
@ -63,7 +63,7 @@ use crate::unpremultiplytable::UNPREMULTIPLY_TABLE;
#[derive(Clone, JSTraceable, MallocSizeOf)]
#[allow(dead_code)]
pub(crate) enum CanvasFillOrStrokeStyle {
Color(#[no_trace] RgbaLegacy),
Color(#[no_trace] AbsoluteColor),
Gradient(Dom<CanvasGradient>),
Pattern(Dom<CanvasPattern>),
}
@ -99,7 +99,7 @@ pub(crate) struct CanvasContextState {
shadow_offset_y: f64,
shadow_blur: f64,
#[no_trace]
shadow_color: RgbaLegacy,
shadow_color: AbsoluteColor,
#[no_trace]
font_style: Option<Font>,
#[no_trace]
@ -114,13 +114,12 @@ impl CanvasContextState {
const DEFAULT_FONT_STYLE: &'static str = "10px sans-serif";
pub(crate) fn new() -> CanvasContextState {
let black = RgbaLegacy::new(0, 0, 0, 1.0);
CanvasContextState {
global_alpha: 1.0,
global_composition: CompositionOrBlending::default(),
image_smoothing_enabled: true,
fill_style: CanvasFillOrStrokeStyle::Color(black),
stroke_style: CanvasFillOrStrokeStyle::Color(black),
fill_style: CanvasFillOrStrokeStyle::Color(AbsoluteColor::BLACK),
stroke_style: CanvasFillOrStrokeStyle::Color(AbsoluteColor::BLACK),
line_width: 1.0,
line_cap: LineCapStyle::Butt,
line_join: LineJoinStyle::Miter,
@ -129,7 +128,7 @@ impl CanvasContextState {
shadow_offset_x: 0.0,
shadow_offset_y: 0.0,
shadow_blur: 0.0,
shadow_color: RgbaLegacy::new(0, 0, 0, 0.0),
shadow_color: AbsoluteColor::TRANSPARENT_BLACK,
font_style: None,
text_align: Default::default(),
text_baseline: Default::default(),
@ -1689,7 +1688,7 @@ impl CanvasState {
}
}
pub fn parse_color(canvas: Option<&HTMLCanvasElement>, string: &str) -> Result<RgbaLegacy, ()> {
pub fn parse_color(canvas: Option<&HTMLCanvasElement>, string: &str) -> Result<AbsoluteColor, ()> {
let mut input = ParserInput::new(string);
let mut parser = Parser::new(&mut input);
let url = Url::parse("about:blank").unwrap().into();
@ -1726,15 +1725,7 @@ pub fn parse_color(canvas: Option<&HTMLCanvasElement>, string: &str) -> Result<R
},
};
let rgba = color
.resolve_to_absolute(&current_color)
.to_color_space(ColorSpace::Srgb);
Ok(RgbaLegacy::from_floats(
rgba.components.0,
rgba.components.1,
rgba.components.2,
rgba.alpha,
))
Ok(color.resolve_to_absolute(&current_color))
},
None => Err(()),
}
@ -1747,17 +1738,21 @@ pub fn is_rect_valid(rect: Rect<f64>) -> bool {
}
// https://html.spec.whatwg.org/multipage/#serialisation-of-a-color
pub fn serialize<W>(color: &RgbaLegacy, dest: &mut W) -> fmt::Result
pub fn serialize<W>(color: &AbsoluteColor, dest: &mut W) -> fmt::Result
where
W: fmt::Write,
{
let RgbaLegacy {
red,
green,
blue,
alpha,
} = color;
if *alpha == 1.0 {
let srgb = match color.color_space {
ColorSpace::Srgb if color.flags.contains(ColorFlags::IS_LEGACY_SRGB) => *color,
ColorSpace::Hsl | ColorSpace::Hwb => color.into_srgb_legacy(),
_ => return color.to_css(&mut CssWriter::new(dest)),
};
debug_assert!(srgb.flags.contains(ColorFlags::IS_LEGACY_SRGB));
let red = clamp_unit_f32(srgb.components.0);
let green = clamp_unit_f32(srgb.components.1);
let blue = clamp_unit_f32(srgb.components.2);
let alpha = srgb.alpha;
if alpha == 1.0 {
write!(
dest,
"#{:x}{:x}{:x}{:x}{:x}{:x}",

View file

@ -709,15 +709,9 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
};
if let Some(color) = bgcolor {
use style::color::parsing::FromParsedColor;
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::BackgroundColor(specified::Color::from_rgba(
color.red,
color.green,
color.blue,
color.alpha,
)),
PropertyDeclaration::BackgroundColor(specified::Color::from_absolute_color(color)),
));
}
@ -749,11 +743,10 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
};
if let Some(color) = color {
use style::color::parsing::FromParsedColor;
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Color(longhands::color::SpecifiedValue(
specified::Color::from_rgba(color.red, color.green, color.blue, color.alpha),
specified::Color::from_absolute_color(color),
)),
));
}

View file

@ -8,7 +8,7 @@ use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use servo_url::ServoUrl;
use style::attr::AttrValue;
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLBodyElementBinding::HTMLBodyElementMethods;
@ -100,20 +100,20 @@ impl HTMLBodyElementMethods for HTMLBodyElement {
}
pub trait HTMLBodyElementLayoutHelpers {
fn get_background_color(self) -> Option<RgbaLegacy>;
fn get_color(self) -> Option<RgbaLegacy>;
fn get_background_color(self) -> Option<AbsoluteColor>;
fn get_color(self) -> Option<AbsoluteColor>;
fn get_background(self) -> Option<ServoUrl>;
}
impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
fn get_background_color(self) -> Option<RgbaLegacy> {
fn get_background_color(self) -> Option<AbsoluteColor> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
fn get_color(self) -> Option<RgbaLegacy> {
fn get_color(self) -> Option<AbsoluteColor> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("text"))
.and_then(AttrValue::as_color)

View file

@ -7,7 +7,7 @@ use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use servo_atoms::Atom;
use style::attr::AttrValue;
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use style::str::{read_numbers, HTML_SPACE_CHARACTERS};
use crate::dom::attr::Attr;
@ -107,13 +107,13 @@ impl VirtualMethods for HTMLFontElement {
}
pub trait HTMLFontElementLayoutHelpers {
fn get_color(self) -> Option<RgbaLegacy>;
fn get_color(self) -> Option<AbsoluteColor>;
fn get_face(self) -> Option<Atom>;
fn get_size(self) -> Option<u32>;
}
impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
fn get_color(self) -> Option<RgbaLegacy> {
fn get_color(self) -> Option<AbsoluteColor> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("color"))
.and_then(AttrValue::as_color)

View file

@ -6,7 +6,7 @@ use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use crate::dom::bindings::codegen::Bindings::HTMLHRElementBinding::HTMLHRElementMethods;
use crate::dom::bindings::inheritance::Castable;
@ -70,12 +70,12 @@ impl HTMLHRElementMethods for HTMLHRElement {
}
pub trait HTMLHRLayoutHelpers {
fn get_color(self) -> Option<RgbaLegacy>;
fn get_color(self) -> Option<AbsoluteColor>;
fn get_width(self) -> LengthOrPercentageOrAuto;
}
impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> {
fn get_color(self) -> Option<RgbaLegacy> {
fn get_color(self) -> Option<AbsoluteColor> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("color"))
.and_then(AttrValue::as_color)

View file

@ -6,7 +6,7 @@ use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use style::context::QuirksMode;
use crate::dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods;
@ -106,7 +106,7 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement {
}
pub trait HTMLTableCellElementLayoutHelpers<'dom> {
fn get_background_color(self) -> Option<RgbaLegacy>;
fn get_background_color(self) -> Option<AbsoluteColor>;
fn get_colspan(self) -> Option<u32>;
fn get_rowspan(self) -> Option<u32>;
fn get_table(self) -> Option<LayoutDom<'dom, HTMLTableElement>>;
@ -114,7 +114,7 @@ pub trait HTMLTableCellElementLayoutHelpers<'dom> {
}
impl<'dom> HTMLTableCellElementLayoutHelpers<'dom> for LayoutDom<'dom, HTMLTableCellElement> {
fn get_background_color(self) -> Option<RgbaLegacy> {
fn get_background_color(self) -> Option<AbsoluteColor> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)

View file

@ -8,7 +8,7 @@ use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::{parse_unsigned_integer, AttrValue, LengthOrPercentageOrAuto};
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
@ -438,7 +438,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
}
pub trait HTMLTableElementLayoutHelpers {
fn get_background_color(self) -> Option<RgbaLegacy>;
fn get_background_color(self) -> Option<AbsoluteColor>;
fn get_border(self) -> Option<u32>;
fn get_cellpadding(self) -> Option<u32>;
fn get_cellspacing(self) -> Option<u32>;
@ -446,7 +446,7 @@ pub trait HTMLTableElementLayoutHelpers {
}
impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
fn get_background_color(self) -> Option<RgbaLegacy> {
fn get_background_color(self) -> Option<AbsoluteColor> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)

View file

@ -6,7 +6,7 @@ use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::AttrValue;
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods;
use crate::dom::bindings::codegen::Bindings::HTMLTableRowElementBinding::HTMLTableRowElementMethods;
@ -153,11 +153,11 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
}
pub trait HTMLTableRowElementLayoutHelpers {
fn get_background_color(self) -> Option<RgbaLegacy>;
fn get_background_color(self) -> Option<AbsoluteColor>;
}
impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> {
fn get_background_color(self) -> Option<RgbaLegacy> {
fn get_background_color(self) -> Option<AbsoluteColor> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)

View file

@ -6,7 +6,7 @@ use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use style::attr::AttrValue;
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableSectionElementMethods;
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
@ -91,11 +91,11 @@ impl HTMLTableSectionElementMethods for HTMLTableSectionElement {
}
pub trait HTMLTableSectionElementLayoutHelpers {
fn get_background_color(self) -> Option<RgbaLegacy>;
fn get_background_color(self) -> Option<AbsoluteColor>;
}
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<'_, HTMLTableSectionElement> {
fn get_background_color(self) -> Option<RgbaLegacy> {
fn get_background_color(self) -> Option<AbsoluteColor> {
self.upcast::<Element>()
.get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)

View file

@ -10,7 +10,7 @@ use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSender, IpcSharedMem
use malloc_size_of_derive::MallocSizeOf;
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;
use style::color::parsing::RgbaLegacy;
use style::color::AbsoluteColor;
use style::properties::style_structs::Font as FontStyleStruct;
use webrender_api::ImageKey;
@ -75,7 +75,7 @@ pub enum Canvas2dMsg {
SetShadowOffsetX(f64),
SetShadowOffsetY(f64),
SetShadowBlur(f64),
SetShadowColor(RgbaLegacy),
SetShadowColor(AbsoluteColor),
SetFont(FontStyleStruct),
SetTextAlign(TextAlign),
SetTextBaseline(TextBaseline),
@ -94,7 +94,7 @@ pub enum FromScriptMsg {
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct CanvasGradientStop {
pub offset: f64,
pub color: RgbaLegacy,
pub color: AbsoluteColor,
}
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
@ -183,7 +183,7 @@ impl SurfaceStyle {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FillOrStrokeStyle {
Color(RgbaLegacy),
Color(AbsoluteColor),
LinearGradient(LinearGradientStyle),
RadialGradient(RadialGradientStyle),
Surface(SurfaceStyle),

View file

@ -1,2 +0,0 @@
[overflow-overlay.html]
expected: FAIL

View file

@ -1,6 +1,3 @@
[overlay-transition-property.html]
[Property transition value 'overlay 1s']
expected: FAIL
[e.style['transition'\] = "overlay 2s" should set the property value]
expected: FAIL

View file

@ -1,24 +0,0 @@
[transition-valid.html]
[e.style['transition'\] = "1s" should set the property value]
expected: FAIL
[e.style['transition'\] = "cubic-bezier(0, -2, 1, 3)" should set the property value]
expected: FAIL
[e.style['transition'\] = "1s -3s" should set the property value]
expected: FAIL
[e.style['transition'\] = "none" should set the property value]
expected: FAIL
[e.style['transition'\] = "top" should set the property value]
expected: FAIL
[e.style['transition'\] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should set the property value]
expected: FAIL
[e.style['transition'\] = "all" should set the property value]
expected: FAIL
[e.style['transition'\] = "all 1s" should set the property value]
expected: FAIL

View file

@ -1,27 +0,0 @@
[signed-zero.html]
[clamp(-1, 1 / sign(min( 0, -0)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(max(-0, 0)), 1) should be used-value-equivalent to 1]
expected: FAIL
[clamp(-1, 1 / sign(clamp(-0, 0, -0)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(clamp(0, -0, -0)), 1) should be used-value-equivalent to 1]
expected: FAIL
[clamp(-1, 1 / sign(clamp(0, 1, -0)), 1) should be used-value-equivalent to 1]
expected: FAIL
[clamp(-1, 1 / sign(mod(-1, -1)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(mod( 1, -1)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(rem(-1, -1)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(rem(-1, 1)), 1) should be used-value-equivalent to -1]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.fillStyle.colormix.currentcolor.html]
[color-mix works as color input with currentcolor]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.fillStyle.colormix.html]
[color-mix works as color input]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.strokeStyle.colormix.html]
[color-mix works as color input]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.fillStyle.colormix.html]
[color-mix works as color input]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.fillStyle.colormix.worker.html]
[color-mix works as color input]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.strokeStyle.colormix.html]
[color-mix works as color input]
expected: FAIL

View file

@ -1,2 +0,0 @@
[overflow-overlay.html]
expected: FAIL

View file

@ -1,6 +0,0 @@
[overlay-transition-property.html]
[e.style['transition'\] = "overlay 2s" should set the property value]
expected: FAIL
[Property transition value 'overlay 1s']
expected: FAIL

View file

@ -1,27 +0,0 @@
[transition-computed.html]
[Property transition value '1s -3s']
expected: FAIL
[Property transition value '1s -3s, cubic-bezier(0, -2, 1, 3) top']
expected: FAIL
[Property transition value 'none']
expected: FAIL
[Property transition value '1s']
expected: FAIL
[Property transition value 'cubic-bezier(0, -2, 1, 3)']
expected: FAIL
[Property transition value 'top']
expected: FAIL
[Default transition value]
expected: FAIL
[Property transition value 'all, all']
expected: FAIL
[Transition with a delay but no duration]
expected: FAIL

View file

@ -1,24 +0,0 @@
[transition-valid.html]
[e.style['transition'\] = "1s" should set the property value]
expected: FAIL
[e.style['transition'\] = "cubic-bezier(0, -2, 1, 3)" should set the property value]
expected: FAIL
[e.style['transition'\] = "1s -3s" should set the property value]
expected: FAIL
[e.style['transition'\] = "none" should set the property value]
expected: FAIL
[e.style['transition'\] = "top" should set the property value]
expected: FAIL
[e.style['transition'\] = "1s -3s, cubic-bezier(0, -2, 1, 3) top" should set the property value]
expected: FAIL
[e.style['transition'\] = "all" should set the property value]
expected: FAIL
[e.style['transition'\] = "all 1s" should set the property value]
expected: FAIL

View file

@ -1,27 +0,0 @@
[signed-zero.html]
[clamp(-1, 1 / sign(min( 0, -0)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(max(-0, 0)), 1) should be used-value-equivalent to 1]
expected: FAIL
[clamp(-1, 1 / sign(clamp(-0, 0, -0)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(clamp(0, -0, -0)), 1) should be used-value-equivalent to 1]
expected: FAIL
[clamp(-1, 1 / sign(clamp(0, 1, -0)), 1) should be used-value-equivalent to 1]
expected: FAIL
[clamp(-1, 1 / sign(mod(-1, -1)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(mod( 1, -1)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(rem(-1, -1)), 1) should be used-value-equivalent to -1]
expected: FAIL
[clamp(-1, 1 / sign(rem(-1, 1)), 1) should be used-value-equivalent to -1]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.fillStyle.colormix.currentcolor.html]
[color-mix works as color input with currentcolor]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.fillStyle.colormix.html]
[color-mix works as color input]
expected: FAIL

View file

@ -1,3 +0,0 @@
[2d.strokeStyle.colormix.html]
[color-mix works as color input]
expected: FAIL