From 45514b96bb6193812103a3bed104c6292c5be72b Mon Sep 17 00:00:00 2001 From: Butkovits Atila Date: Wed, 15 Mar 2023 19:21:19 +0200 Subject: [PATCH] Backed out changeset deabee2364d4 (bug 1813481) for causing assertion failures at gfxUtils.cpp. CLOSED TREE --- .cargo/config.in | 2 +- Cargo.lock | 4 +- Cargo.toml | 2 +- .../shared/css/generated/properties-db.js | 255 ----- modules/libpref/init/StaticPrefList.yaml | 2 +- servo/components/style/color/convert.rs | 87 +- servo/components/style/color/mod.rs | 131 +-- .../style/values/specified/color.rs | 118 +-- supply-chain/audits.toml | 6 - .../color-computed-color-function.html.ini | 351 +++++++ ...color-computed-color-mix-function.html.ini | 9 + .../parsing/color-computed-hsl.html.ini | 29 + .../parsing/color-computed-hwb.html.ini | 23 + .../parsing/color-computed-lab.html.ini | 62 ++ .../parsing/color-computed-rgb.html.ini | 50 + .../color-valid-color-function.html.ini | 136 +++ .../color-valid-color-mix-function.html.ini | 297 ++++++ .../parsing/color-valid-hsl.html.ini | 29 + .../parsing/color-valid-hwb.html.ini | 23 + .../parsing/color-valid-lab.html.ini | 62 ++ .../parsing/color-valid-rgb.html.ini | 50 + .../color-valid-color-mix-function.html | 78 +- .../rust/cssparser/.cargo-checksum.json | 2 +- third_party/rust/cssparser/Cargo.toml | 78 +- third_party/rust/cssparser/src/color.rs | 870 ++++++------------ third_party/rust/cssparser/src/lib.rs | 4 +- third_party/rust/cssparser/src/tests.rs | 176 ++-- 27 files changed, 1625 insertions(+), 1311 deletions(-) create mode 100644 testing/web-platform/meta/css/css-color/parsing/color-computed-hsl.html.ini create mode 100644 testing/web-platform/meta/css/css-color/parsing/color-computed-hwb.html.ini create mode 100644 testing/web-platform/meta/css/css-color/parsing/color-computed-lab.html.ini create mode 100644 testing/web-platform/meta/css/css-color/parsing/color-computed-rgb.html.ini create mode 100644 testing/web-platform/meta/css/css-color/parsing/color-valid-hsl.html.ini create mode 100644 testing/web-platform/meta/css/css-color/parsing/color-valid-hwb.html.ini create mode 100644 testing/web-platform/meta/css/css-color/parsing/color-valid-lab.html.ini create mode 100644 testing/web-platform/meta/css/css-color/parsing/color-valid-rgb.html.ini diff --git a/.cargo/config.in b/.cargo/config.in index d53dfa047c30..e0679be675a7 100644 --- a/.cargo/config.in +++ b/.cargo/config.in @@ -122,7 +122,7 @@ replace-with = "vendored-sources" [source."https://github.com/servo/rust-cssparser"] git = "https://github.com/servo/rust-cssparser" -rev = "45bc47e2bcb846f1efb5aea156be5fe7d18624bf" +rev = "b196a164dcbb317016d4aa6c58c13147e6045ebb" replace-with = "vendored-sources" diff --git a/Cargo.lock b/Cargo.lock index 197f143a0ebc..27d732be56ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1104,7 +1104,7 @@ dependencies = [ [[package]] name = "cssparser" version = "0.30.0" -source = "git+https://github.com/servo/rust-cssparser?rev=45bc47e2bcb846f1efb5aea156be5fe7d18624bf#45bc47e2bcb846f1efb5aea156be5fe7d18624bf" +source = "git+https://github.com/servo/rust-cssparser?rev=b196a164dcbb317016d4aa6c58c13147e6045ebb#b196a164dcbb317016d4aa6c58c13147e6045ebb" dependencies = [ "cssparser-macros", "dtoa-short", @@ -1119,7 +1119,7 @@ dependencies = [ [[package]] name = "cssparser-macros" version = "0.6.0" -source = "git+https://github.com/servo/rust-cssparser?rev=45bc47e2bcb846f1efb5aea156be5fe7d18624bf#45bc47e2bcb846f1efb5aea156be5fe7d18624bf" +source = "git+https://github.com/servo/rust-cssparser?rev=b196a164dcbb317016d4aa6c58c13147e6045ebb#b196a164dcbb317016d4aa6c58c13147e6045ebb" dependencies = [ "quote", "syn", diff --git a/Cargo.toml b/Cargo.toml index cd9c14716236..63dc1a1f991d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,7 +167,7 @@ minidump-writer = { git = "https://github.com/rust-minidump/minidump-writer.git" # warp 0.3.3 + https://github.com/seanmonstar/warp/pull/1007 warp = { git = "https://github.com/glandium/warp", rev = "4af45fae95bc98b0eba1ef0db17e1dac471bb23d" } -cssparser = { git = "https://github.com/servo/rust-cssparser", rev = "45bc47e2bcb846f1efb5aea156be5fe7d18624bf" } +cssparser = { git = "https://github.com/servo/rust-cssparser", rev = "b196a164dcbb317016d4aa6c58c13147e6045ebb" } # application-services overrides to make updating them all simpler. interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "fe2867dbe82a2aaa85a856648107be94b1534683" } diff --git a/devtools/shared/css/generated/properties-db.js b/devtools/shared/css/generated/properties-db.js index 4fff94e56786..7ad85c40dc26 100644 --- a/devtools/shared/css/generated/properties-db.js +++ b/devtools/shared/css/generated/properties-db.js @@ -341,7 +341,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -355,12 +354,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -384,7 +379,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -392,10 +386,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -503,7 +493,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -517,12 +506,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -546,7 +531,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -554,10 +538,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -1881,7 +1861,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -1890,11 +1869,7 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "none", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -2459,7 +2434,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -2467,10 +2441,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -2506,7 +2476,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -2514,11 +2483,7 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", "medium", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -2539,7 +2504,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -2547,10 +2511,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -2778,7 +2738,6 @@ exports.CSS_PROPERTIES = { "values": [ "COLOR", "auto", - "color", "color-mix", "currentColor", "hsl", @@ -2786,10 +2745,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -3709,7 +3664,6 @@ exports.CSS_PROPERTIES = { "border-box", "bottom", "center", - "color", "color-mix", "conic-gradient", "contain", @@ -3723,15 +3677,11 @@ exports.CSS_PROPERTIES = { "image-set", "inherit", "initial", - "lab", - "lch", "left", "linear-gradient", "local", "no-repeat", "none", - "oklab", - "oklch", "padding-box", "radial-gradient", "repeat", @@ -3830,7 +3780,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -3838,10 +3787,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -4039,7 +3984,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -4053,12 +3997,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -4087,7 +4027,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -4101,12 +4040,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -4131,7 +4066,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -4139,10 +4073,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -4163,7 +4093,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -4177,12 +4106,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -4206,7 +4131,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -4214,10 +4138,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -4279,7 +4199,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -4293,12 +4212,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -4322,7 +4237,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -4330,10 +4244,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -4438,7 +4348,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -4452,12 +4361,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -4481,7 +4386,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -4489,10 +4393,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -4599,7 +4499,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -4607,10 +4506,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -4806,7 +4701,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -4820,12 +4714,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -4850,7 +4740,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -4858,10 +4747,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -4882,7 +4767,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -4896,12 +4780,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -4925,7 +4805,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -4933,10 +4812,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -4998,7 +4873,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -5012,12 +4886,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -5041,7 +4911,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -5049,10 +4918,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -5157,7 +5022,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -5171,12 +5035,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -5200,7 +5060,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -5208,10 +5067,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -5290,7 +5145,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -5304,12 +5158,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -5333,7 +5183,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -5341,10 +5190,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -5475,7 +5320,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -5489,12 +5333,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -5518,7 +5358,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -5526,10 +5365,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -5668,7 +5503,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -5677,11 +5511,7 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "none", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -5791,7 +5621,6 @@ exports.CSS_PROPERTIES = { "values": [ "COLOR", "auto", - "color", "color-mix", "currentColor", "hsl", @@ -5799,10 +5628,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -5901,7 +5726,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -5909,10 +5733,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -6047,7 +5867,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "dashed", @@ -6061,12 +5880,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -6090,7 +5905,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -6098,10 +5912,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -6671,7 +6481,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "context-fill", "context-stroke", @@ -6681,11 +6490,7 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", "none", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -6909,7 +6714,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -6917,10 +6721,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -8251,7 +8051,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -8259,10 +8058,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -9463,7 +9258,6 @@ exports.CSS_PROPERTIES = { "values": [ "COLOR", "auto", - "color", "color-mix", "currentColor", "dashed", @@ -9477,12 +9271,8 @@ exports.CSS_PROPERTIES = { "inherit", "initial", "inset", - "lab", - "lch", "medium", "none", - "oklab", - "oklch", "outset", "revert", "revert-layer", @@ -9506,7 +9296,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -9514,10 +9303,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -10849,7 +10634,6 @@ exports.CSS_PROPERTIES = { "values": [ "COLOR", "auto", - "color", "color-mix", "currentColor", "hsl", @@ -10857,10 +10641,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -11030,7 +10810,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -11038,10 +10817,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -11074,7 +10849,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "context-fill", "context-stroke", @@ -11084,11 +10858,7 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", "none", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -11333,7 +11103,6 @@ exports.CSS_PROPERTIES = { "-moz-none", "auto", "blink", - "color", "color-mix", "currentColor", "dashed", @@ -11345,12 +11114,8 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", "line-through", "none", - "oklab", - "oklch", "overline", "revert", "revert-layer", @@ -11373,7 +11138,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -11381,10 +11145,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -11477,7 +11237,6 @@ exports.CSS_PROPERTIES = { "values": [ "COLOR", "circle", - "color", "color-mix", "currentColor", "dot", @@ -11488,11 +11247,7 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", "none", - "oklab", - "oklch", "open", "revert", "revert-layer", @@ -11514,7 +11269,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -11522,10 +11276,6 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", - "oklab", - "oklch", "revert", "revert-layer", "rgb", @@ -11669,7 +11419,6 @@ exports.CSS_PROPERTIES = { ], "values": [ "COLOR", - "color", "color-mix", "currentColor", "hsl", @@ -11677,11 +11426,7 @@ exports.CSS_PROPERTIES = { "hwb", "inherit", "initial", - "lab", - "lch", "none", - "oklab", - "oklch", "revert", "revert-layer", "rgb", diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 419ebf79edca..0c87cae558a4 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -8899,7 +8899,7 @@ # Enable experimental enhanced color CSS color spaces. (lab(), lch(), oklab(), oklch(), color()) - name: layout.css.more_color_4.enabled type: RelaxedAtomicBool - value: @IS_NIGHTLY_BUILD@ + value: false mirror: always rust: true diff --git a/servo/components/style/color/convert.rs b/servo/components/style/color/convert.rs index 3cf04ec02e20..5c44079a7c17 100644 --- a/servo/components/style/color/convert.rs +++ b/servo/components/style/color/convert.rs @@ -68,7 +68,6 @@ fn hue_to_rgb(t1: f32, t2: f32, hue: f32) -> f32 { } /// Convert from HSL notation to RGB notation. -/// https://drafts.csswg.org/css-color-4/#hsl-to-rgb #[inline] pub fn hsl_to_rgb(from: &ColorComponents) -> ColorComponents { let ColorComponents(hue, saturation, lightness) = *from; @@ -88,26 +87,26 @@ pub fn hsl_to_rgb(from: &ColorComponents) -> ColorComponents { } /// Convert from RGB notation to HSL notation. -/// https://drafts.csswg.org/css-color-4/#rgb-to-hsl +/// https://drafts.csswg.org/css-color/#rgb-to-hsl pub fn rgb_to_hsl(from: &ColorComponents) -> ColorComponents { let ColorComponents(red, green, blue) = *from; let (hue, min, max) = rgb_to_hue_min_max(red, green, blue); - let lightness = (min + max) / 2.0; + let light = (min + max) / 2.0; let delta = max - min; - let saturation = if delta != 0.0 { - if lightness == 0.0 || lightness == 1.0 { + let sat = if delta != 0.0 { + if light == 0.0 || light == 1.0 { 0.0 } else { - (max - lightness) / lightness.min(1.0 - lightness) + (max - light) / light.min(1.0 - light) } } else { 0.0 }; - ColorComponents(hue, saturation, lightness) + ColorComponents(hue, sat, light) } /// Convert from HWB notation to RGB notation. @@ -139,30 +138,6 @@ pub fn rgb_to_hwb(from: &ColorComponents) -> ColorComponents { ColorComponents(hue, whiteness, blackness) } -/// Convert from Lab to Lch. This calculation works for both Lab and Olab. -/// -#[inline] -pub fn lab_to_lch(from: &ColorComponents) -> ColorComponents { - let ColorComponents(lightness, a, b) = *from; - - let hue = normalize_hue(b.atan2(a) * 180.0 / PI); - let chroma = (a.powf(2.0) + b.powf(2.0)).sqrt(); - - ColorComponents(lightness, chroma, hue) -} - -/// Convert from Lch to Lab. This calculation works for both Lch and Oklch. -/// -#[inline] -pub fn lch_to_lab(from: &ColorComponents) -> ColorComponents { - let ColorComponents(lightness, chroma, hue) = *from; - - let a = chroma * (hue * PI / 180.0).cos(); - let b = chroma * (hue * PI / 180.0).sin(); - - ColorComponents(lightness, a, b) -} - #[inline] fn transform(from: &ColorComponents, mat: &Transform) -> ColorComponents { let result = mat.transform_vector3d(Vector::new(from.0, from.1, from.2)); @@ -330,56 +305,6 @@ impl ColorSpaceConversion for Srgb { } } -/// Color specified with hue, saturation and lightness components. -pub struct Hsl; - -impl ColorSpaceConversion for Hsl { - const WHITE_POINT: WhitePoint = Srgb::WHITE_POINT; - - fn to_linear_light(from: &ColorComponents) -> ColorComponents { - Srgb::to_linear_light(&hsl_to_rgb(from)) - } - - #[inline] - fn to_xyz(from: &ColorComponents) -> ColorComponents { - Srgb::to_xyz(from) - } - - #[inline] - fn from_xyz(from: &ColorComponents) -> ColorComponents { - Srgb::from_xyz(from) - } - - fn to_gamma_encoded(from: &ColorComponents) -> ColorComponents { - rgb_to_hsl(&Srgb::to_gamma_encoded(from)) - } -} - -/// Color specified with hue, whiteness and blackness components. -pub struct Hwb; - -impl ColorSpaceConversion for Hwb { - const WHITE_POINT: WhitePoint = Srgb::WHITE_POINT; - - fn to_linear_light(from: &ColorComponents) -> ColorComponents { - Srgb::to_linear_light(&hwb_to_rgb(from)) - } - - #[inline] - fn to_xyz(from: &ColorComponents) -> ColorComponents { - Srgb::to_xyz(from) - } - - #[inline] - fn from_xyz(from: &ColorComponents) -> ColorComponents { - Srgb::from_xyz(from) - } - - fn to_gamma_encoded(from: &ColorComponents) -> ColorComponents { - rgb_to_hwb(&Srgb::to_gamma_encoded(from)) - } -} - /// The same as sRGB color space, except the transfer function is linear light. /// https://drafts.csswg.org/csswg-drafts/css-color-4/#predefined-sRGB-linear pub struct SrgbLinear; diff --git a/servo/components/style/color/mod.rs b/servo/components/style/color/mod.rs index 635a2ca8b2cd..3e49c1d25454 100644 --- a/servo/components/style/color/mod.rs +++ b/servo/components/style/color/mod.rs @@ -26,6 +26,11 @@ impl ColorComponents { /// A color space representation in the CSS specification. /// /// https://drafts.csswg.org/css-color-4/#typedef-color-space +/// +/// NOTE: Right now HSL and HWB colors can not be constructed by the user. They +/// are converted to RGB in the parser. The parser should return the +/// HSL/HWB values as is to avoid unnescessary conversions to/from RGB. +/// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1817035 #[derive( Clone, Copy, @@ -133,15 +138,7 @@ bitflags! { pub struct SerializationFlags : u8 { /// If set, serializes sRGB colors into `color(srgb ...)` instead of /// `rgba(...)`. - const AS_COLOR_FUNCTION = 1 << 0; - /// Whether the 1st color component is `none`. - const C1_IS_NONE = 1 << 1; - /// Whether the 2nd color component is `none`. - const C2_IS_NONE = 1 << 2; - /// Whether the 3rd color component is `none`. - const C3_IS_NONE = 1 << 3; - /// Whether the alpha component is `none`. - const ALPHA_IS_NONE = 1 << 4; + const AS_COLOR_FUNCTION = 0x01; } } @@ -262,69 +259,20 @@ impl AbsoluteColor { return self.clone(); } - // We have simplified conversions that do not need to convert to XYZ - // first. This improves performance, because it skips 2 matrix - // multiplications and reduces float rounding errors. - match (self.color_space, color_space) { - (Srgb, Hsl) => { - return Self::new( - color_space, - convert::rgb_to_hsl(&self.components), - self.alpha, - ); - }, - - (Srgb, Hwb) => { - return Self::new( - color_space, - convert::rgb_to_hwb(&self.components), - self.alpha, - ); - }, - - (Hsl, Srgb) => { - return Self::new( - color_space, - convert::hsl_to_rgb(&self.components), - self.alpha, - ); - }, - - (Hwb, Srgb) => { - return Self::new( - color_space, - convert::hwb_to_rgb(&self.components), - self.alpha, - ); - }, - - (Lab, Lch) | (Oklab, Oklch) => { - return Self::new( - color_space, - convert::lab_to_lch(&self.components), - self.alpha, - ); - }, - - (Lch, Lab) | (Oklch, Oklab) => { - return Self::new( - color_space, - convert::lch_to_lab(&self.components), - self.alpha, - ); - }, - - _ => {}, - } - let (xyz, white_point) = match self.color_space { + Hsl => { + let rgb = convert::hsl_to_rgb(&self.components); + convert::to_xyz::(&rgb) + }, + Hwb => { + let rgb = convert::hwb_to_rgb(&self.components); + convert::to_xyz::(&rgb) + }, Lab => convert::to_xyz::(&self.components), Lch => convert::to_xyz::(&self.components), Oklab => convert::to_xyz::(&self.components), Oklch => convert::to_xyz::(&self.components), Srgb => convert::to_xyz::(&self.components), - Hsl => convert::to_xyz::(&self.components), - Hwb => convert::to_xyz::(&self.components), SrgbLinear => convert::to_xyz::(&self.components), DisplayP3 => convert::to_xyz::(&self.components), A98Rgb => convert::to_xyz::(&self.components), @@ -335,13 +283,19 @@ impl AbsoluteColor { }; let result = match color_space { + Hsl => { + let rgb = convert::from_xyz::(&xyz, white_point); + convert::rgb_to_hsl(&rgb) + }, + Hwb => { + let rgb = convert::from_xyz::(&xyz, white_point); + convert::rgb_to_hwb(&rgb) + }, Lab => convert::from_xyz::(&xyz, white_point), Lch => convert::from_xyz::(&xyz, white_point), Oklab => convert::from_xyz::(&xyz, white_point), Oklch => convert::from_xyz::(&xyz, white_point), Srgb => convert::from_xyz::(&xyz, white_point), - Hsl => convert::from_xyz::(&xyz, white_point), - Hwb => convert::from_xyz::(&xyz, white_point), SrgbLinear => convert::from_xyz::(&xyz, white_point), DisplayP3 => convert::from_xyz::(&xyz, white_point), A98Rgb => convert::from_xyz::(&xyz, white_point), @@ -375,21 +329,6 @@ impl ToCss for AbsoluteColor { where W: Write, { - macro_rules! value_or_none { - ($v:expr,$flag:tt) => {{ - if self.flags.contains(SerializationFlags::$flag) { - None - } else { - Some($v) - } - }}; - } - - let maybe_c1 = value_or_none!(self.components.0, C1_IS_NONE); - let maybe_c2 = value_or_none!(self.components.1, C2_IS_NONE); - let maybe_c3 = value_or_none!(self.components.2, C3_IS_NONE); - let maybe_alpha = value_or_none!(self.alpha, ALPHA_IS_NONE); - match self.color_space { ColorSpace::Hsl => { let rgb = convert::hsl_to_rgb(&self.components); @@ -403,28 +342,30 @@ impl ToCss for AbsoluteColor { }, ColorSpace::Srgb if !self.flags.contains(SerializationFlags::AS_COLOR_FUNCTION) => { - // Althought we are passing Option<_> in here, the to_css fn - // knows that the "none" keyword is not supported in the - // rgb/rgba legacy syntax. cssparser::ToCss::to_css( - &cssparser::RGBA::from_floats(maybe_c1, maybe_c2, maybe_c3, maybe_alpha), + &cssparser::RGBA::from_floats( + self.components.0, + self.components.1, + self.components.2, + self.alpha(), + ), dest, ) }, ColorSpace::Lab => cssparser::ToCss::to_css( - &cssparser::Lab::new(maybe_c1, maybe_c2, maybe_c3, maybe_alpha), + unsafe { color_components_as!(self, cssparser::Lab) }, dest, ), ColorSpace::Lch => cssparser::ToCss::to_css( - &cssparser::Lch::new(maybe_c1, maybe_c2, maybe_c3, maybe_alpha), + unsafe { color_components_as!(self, cssparser::Lch) }, dest, ), ColorSpace::Oklab => cssparser::ToCss::to_css( - &cssparser::Oklab::new(maybe_c1, maybe_c2, maybe_c3, maybe_alpha), + unsafe { color_components_as!(self, cssparser::Oklab) }, dest, ), ColorSpace::Oklch => cssparser::ToCss::to_css( - &cssparser::Oklch::new(maybe_c1, maybe_c2, maybe_c3, maybe_alpha), + unsafe { color_components_as!(self, cssparser::Oklch) }, dest, ), _ => { @@ -452,10 +393,10 @@ impl ToCss for AbsoluteColor { let color_function = cssparser::ColorFunction { color_space, - c1: maybe_c1, - c2: maybe_c2, - c3: maybe_c3, - alpha: maybe_alpha, + c1: self.components.0, + c2: self.components.1, + c3: self.components.2, + alpha: self.alpha, }; let color = cssparser::Color::ColorFunction(color_function); cssparser::ToCss::to_css(&color, dest) diff --git a/servo/components/style/values/specified/color.rs b/servo/components/style/values/specified/color.rs index 259e6ac74540..c3f930beafba 100644 --- a/servo/components/style/values/specified/color.rs +++ b/servo/components/style/values/specified/color.rs @@ -14,7 +14,7 @@ use crate::values::generics::color::{GenericCaretColor, GenericColorMix, Generic use crate::values::specified::calc::CalcNode; use crate::values::specified::Percentage; use crate::values::CustomIdent; -use cssparser::{AngleOrNumber, Color as CSSParserColor, Parser, Token}; +use cssparser::{AngleOrNumber, Color as CSSParserColor, Parser, Token, RGBA}; use cssparser::{BasicParseErrorKind, NumberOrPercentage, ParseErrorKind}; use itoa; use std::fmt::{self, Write}; @@ -393,35 +393,9 @@ impl SystemColor { } #[inline] -fn new_absolute( - color_space: ColorSpace, - c1: Option, - c2: Option, - c3: Option, - alpha: Option, -) -> Color { - let mut flags = SerializationFlags::empty(); - - macro_rules! c { - ($v:expr,$flag:tt) => {{ - if let Some(value) = $v { - value - } else { - flags |= SerializationFlags::$flag; - 0.0 - } - }}; - } - - let c1 = c!(c1, C1_IS_NONE); - let c2 = c!(c2, C2_IS_NONE); - let c3 = c!(c3, C3_IS_NONE); - let alpha = c!(alpha, ALPHA_IS_NONE); - - let mut color = AbsoluteColor::new(color_space, ColorComponents(c1, c2, c3), alpha); - color.flags |= flags; +fn new_absolute(color_space: ColorSpace, c1: f32, c2: f32, c3: f32, alpha: f32) -> Color { Color::Absolute(Box::new(Absolute { - color, + color: AbsoluteColor::new(color_space, ColorComponents(c1, c2, c3), alpha), authored: None, })) } @@ -431,76 +405,38 @@ impl cssparser::FromParsedColor for Color { Color::CurrentColor } - fn from_rgba(red: Option, green: Option, blue: Option, alpha: Option) -> Self { + fn from_rgba(red: u8, green: u8, blue: u8, alpha: f32) -> Self { new_absolute( ColorSpace::Srgb, - red.map(|r| r as f32 / 255.0), - green.map(|g| g as f32 / 255.0), - blue.map(|b| b as f32 / 255.0), + red as f32 / 255.0, + green as f32 / 255.0, + blue as f32 / 255.0, alpha, ) } - fn from_hsl( - hue: Option, - saturation: Option, - lightness: Option, - alpha: Option, - ) -> Self { - new_absolute(ColorSpace::Hsl, hue, saturation, lightness, alpha) - } - - fn from_hwb( - hue: Option, - whiteness: Option, - blackness: Option, - alpha: Option, - ) -> Self { - new_absolute(ColorSpace::Hwb, hue, whiteness, blackness, alpha) - } - - fn from_lab( - lightness: Option, - a: Option, - b: Option, - alpha: Option, - ) -> Self { + fn from_lab(lightness: f32, a: f32, b: f32, alpha: f32) -> Self { new_absolute(ColorSpace::Lab, lightness, a, b, alpha) } - fn from_lch( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self { + fn from_lch(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self { new_absolute(ColorSpace::Lch, lightness, chroma, hue, alpha) } - fn from_oklab( - lightness: Option, - a: Option, - b: Option, - alpha: Option, - ) -> Self { + fn from_oklab(lightness: f32, a: f32, b: f32, alpha: f32) -> Self { new_absolute(ColorSpace::Oklab, lightness, a, b, alpha) } - fn from_oklch( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self { + fn from_oklch(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self { new_absolute(ColorSpace::Oklch, lightness, chroma, hue, alpha) } fn from_color_function( color_space: cssparser::PredefinedColorSpace, - c1: Option, - c2: Option, - c3: Option, - alpha: Option, + c1: f32, + c2: f32, + c3: f32, + alpha: f32, ) -> Self { let mut result = new_absolute(color_space.into(), c1, c2, c3, alpha); if let Color::Absolute(ref mut absolute) = result { @@ -617,17 +553,14 @@ impl Color { Ok(mut color) => { if let Color::Absolute(ref mut absolute) = color { let enabled = { - let is_legacy_color = matches!( - absolute.color.color_space, - ColorSpace::Srgb | ColorSpace::Hsl - ); + let is_srgb = matches!(absolute.color.color_space, ColorSpace::Srgb); let is_color_function = absolute .color .flags .contains(SerializationFlags::AS_COLOR_FUNCTION); let pref_enabled = static_prefs::pref!("layout.css.more_color_4.enabled"); - (is_legacy_color && !is_color_function) || pref_enabled + (is_srgb && !is_color_function) || pref_enabled }; if !enabled { return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); @@ -779,14 +712,23 @@ impl Color { if !allow_quirks.allowed(context.quirks_mode) { return Err(e); } - Color::parse_quirky_color(input).map_err(|_| e) + Color::parse_quirky_color(input) + .map(|rgba| { + Color::from_absolute_color(AbsoluteColor::srgb( + rgba.red as f32 / 255.0, + rgba.green as f32 / 255.0, + rgba.blue as f32 / 255.0, + rgba.alpha, // alpha value is already a float and in range [0..1] + )) + }) + .map_err(|_| e) }) } /// Parse a value. /// /// - fn parse_quirky_color<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { + fn parse_quirky_color<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { let location = input.current_source_location(); let (value, unit) = match *input.next()? { Token::Number { @@ -802,7 +744,7 @@ impl Color { if ident.len() != 3 && ident.len() != 6 { return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)); } - return cssparser::parse_hash_color(ident.as_bytes()).map_err(|()| { + return RGBA::parse_hash(ident.as_bytes()).map_err(|()| { location.new_custom_error(StyleParseErrorKind::UnspecifiedError) }); }, @@ -847,7 +789,7 @@ impl Color { .unwrap(); } debug_assert_eq!(written, 6); - cssparser::parse_hash_color(&serialization) + RGBA::parse_hash(&serialization) .map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError)) } } diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 68902c384484..f35e59af59c4 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -454,12 +454,6 @@ Trivial crate with a single proc macro to compute the max length of the inputs to a match expression. """ -[[audits.cssparser-macros]] -who = "Tiaan Louw " -criteria = "safe-to-deploy" -delta = "0.6.0 -> 0.6.0@git:45bc47e2bcb846f1efb5aea156be5fe7d18624bf" -notes = "Latest version of changes to the cssparser pulled from master branch." - [[audits.cssparser-macros]] who = "Tiaan Louw " criteria = "safe-to-deploy" diff --git a/testing/web-platform/meta/css/css-color/parsing/color-computed-color-function.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-computed-color-function.html.ini index 861db3c4de75..d6b325c7d7a6 100644 --- a/testing/web-platform/meta/css/css-color/parsing/color-computed-color-function.html.ini +++ b/testing/web-platform/meta/css/css-color/parsing/color-computed-color-function.html.ini @@ -1,3 +1,354 @@ [color-computed-color-function.html] + [Property color value 'color(srgb none none none / none)'] + expected: FAIL + + [Property color value 'color(srgb none none none)'] + expected: FAIL + + [Property color value 'color(srgb 10% none none / none)'] + expected: FAIL + + [Property color value 'color(srgb none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(srgb 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(srgb-linear none none none / none)'] + expected: FAIL + + [Property color value 'color(srgb-linear none none none)'] + expected: FAIL + + [Property color value 'color(srgb-linear 10% none none / none)'] + expected: FAIL + + [Property color value 'color(srgb-linear none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(srgb-linear 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(a98-rgb none none none / none)'] + expected: FAIL + + [Property color value 'color(a98-rgb none none none)'] + expected: FAIL + + [Property color value 'color(a98-rgb 10% none none / none)'] + expected: FAIL + + [Property color value 'color(a98-rgb none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(a98-rgb 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(rec2020 none none none / none)'] + expected: FAIL + + [Property color value 'color(rec2020 none none none)'] + expected: FAIL + + [Property color value 'color(rec2020 10% none none / none)'] + expected: FAIL + + [Property color value 'color(rec2020 none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(rec2020 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(prophoto-rgb none none none / none)'] + expected: FAIL + + [Property color value 'color(prophoto-rgb none none none)'] + expected: FAIL + + [Property color value 'color(prophoto-rgb 10% none none / none)'] + expected: FAIL + + [Property color value 'color(prophoto-rgb none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(prophoto-rgb 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(display-p3 none none none / none)'] + expected: FAIL + + [Property color value 'color(display-p3 none none none)'] + expected: FAIL + + [Property color value 'color(display-p3 10% none none / none)'] + expected: FAIL + + [Property color value 'color(display-p3 none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(display-p3 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(xyz none none none / none)'] + expected: FAIL + + [Property color value 'color(xyz none none none)'] + expected: FAIL + + [Property color value 'color(xyz 0.2 none none / none)'] + expected: FAIL + + [Property color value 'color(xyz none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(xyz 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(xyz-d50 none none none / none)'] + expected: FAIL + + [Property color value 'color(xyz-d50 none none none)'] + expected: FAIL + + [Property color value 'color(xyz-d50 0.2 none none / none)'] + expected: FAIL + + [Property color value 'color(xyz-d50 none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(xyz-d50 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(xyz-d65 none none none / none)'] + expected: FAIL + + [Property color value 'color(xyz-d65 none none none)'] + expected: FAIL + + [Property color value 'color(xyz-d65 0.2 none none / none)'] + expected: FAIL + + [Property color value 'color(xyz-d65 none none none / 0.5)'] + expected: FAIL + + [Property color value 'color(xyz-d65 0 0 0 / none)'] + expected: FAIL + + [Property color value 'color(srgb none none none)' [sRGB all none\]] + expected: FAIL + + [Property color value 'color(srgb 1.00 none 0.2)' [sRGB number and none\]] + expected: FAIL + + [Property color value 'color(srgb 100% none 20%)' [sRGB percent and none\]] + expected: FAIL + + [Property color value 'color(srgb 100% none 0.2)' [sRGB number, percent and none\]] + expected: FAIL + + [Property color value 'color(srgb none none none / none)' [sRGB with alpha, all none\]] + expected: FAIL + + [Property color value 'color(srgb 1.00 none 0.2 / none)' [sRGB with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(srgb 100% none 20% / 30%)' [sRGB with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(srgb 100% none 0.2 / 23.7%)' [sRGB with alpha, number, percent and none\]] + expected: FAIL + + [Property color value 'color(srgb-linear none none none)' [Linear-light sRGB all none\]] + expected: FAIL + + [Property color value 'color(srgb-linear 1.00 none 0.2)' [Linear-light sRGB number and none\]] + expected: FAIL + + [Property color value 'color(srgb-linear 100% none 20%)' [Linear-light sRGB percent and none\]] + expected: FAIL + + [Property color value 'color(srgb-linear 100% none 0.2)' [Linear-light sRGB number, percent and none\]] + expected: FAIL + + [Property color value 'color(srgb-linear none none none / none)' [Linear-light sRGB with alpha, all none\]] + expected: FAIL + + [Property color value 'color(srgb-linear 1.00 none 0.2 / none)' [Linear-light sRGB with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(srgb-linear 100% none 20% / 30%)' [Linear-light sRGB with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(srgb-linear 100% none 0.2 / 23.7%)' [Linear-light sRGB with alpha, number, percent and none\]] + expected: FAIL + + [Property color value 'color(display-p3 none none none)' [Display P3 all none\]] + expected: FAIL + + [Property color value 'color(display-p3 1.00 none 0.2)' [Display P3 number and none\]] + expected: FAIL + + [Property color value 'color(display-p3 100% none 20%)' [Display P3 percent and none\]] + expected: FAIL + + [Property color value 'color(display-p3 100% none 0.2)' [Display P3 number, percent and none\]] + expected: FAIL + + [Property color value 'color(display-p3 none none none / none)' [Display P3 with alpha, all none\]] + expected: FAIL + + [Property color value 'color(display-p3 1.00 none 0.2 / none)' [Display P3 with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(display-p3 100% none 20% / 30%)' [Display P3 with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(display-p3 100% none 0.2 / 23.7%)' [Display P3 with alpha, number, percent and none\]] + expected: FAIL + + [Property color value 'color(a98-rgb none none none)' [A98 RGB all none\]] + expected: FAIL + + [Property color value 'color(a98-rgb 1.00 none 0.2)' [A98 RGB number and none\]] + expected: FAIL + + [Property color value 'color(a98-rgb 100% none 20%)' [A98 RGB percent and none\]] + expected: FAIL + + [Property color value 'color(a98-rgb 100% none 0.2)' [A98 RGB number, percent and none\]] + expected: FAIL + + [Property color value 'color(a98-rgb none none none / none)' [A98 RGB with alpha, all none\]] + expected: FAIL + + [Property color value 'color(a98-rgb 1.00 none 0.2 / none)' [A98 RGB with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(a98-rgb 100% none 20% / 30%)' [A98 RGB with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(a98-rgb 100% none 0.2 / 23.7%)' [A98 RGB with alpha, number, percent and none\]] + expected: FAIL + + [Property color value 'color(prophoto-rgb none none none)' [ProPhoto RGB all none\]] + expected: FAIL + + [Property color value 'color(prophoto-rgb 1.00 none 0.2)' [ProPhoto RGB number and none\]] + expected: FAIL + + [Property color value 'color(prophoto-rgb 100% none 20%)' [ProPhoto RGB percent and none\]] + expected: FAIL + + [Property color value 'color(prophoto-rgb 100% none 0.2)' [ProPhoto RGB number, percent and none\]] + expected: FAIL + + [Property color value 'color(prophoto-rgb none none none / none)' [ProPhoto RGB with alpha, all none\]] + expected: FAIL + + [Property color value 'color(prophoto-rgb 1.00 none 0.2 / none)' [ProPhoto RGB with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(prophoto-rgb 100% none 20% / 30%)' [ProPhoto RGB with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(prophoto-rgb 100% none 0.2 / 23.7%)' [ProPhoto RGB with alpha, number, percent and none\]] + expected: FAIL + + [Property color value 'color(rec2020 none none none)' [Rec BT.2020 all none\]] + expected: FAIL + + [Property color value 'color(rec2020 1.00 none 0.2)' [Rec BT.2020 number and none\]] + expected: FAIL + + [Property color value 'color(rec2020 100% none 20%)' [Rec BT.2020 percent and none\]] + expected: FAIL + + [Property color value 'color(rec2020 100% none 0.2)' [Rec BT.2020 number, percent and none\]] + expected: FAIL + + [Property color value 'color(rec2020 none none none / none)' [Rec BT.2020 with alpha, all none\]] + expected: FAIL + + [Property color value 'color(rec2020 1.00 none 0.2 / none)' [Rec BT.2020 with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(rec2020 100% none 20% / 30%)' [Rec BT.2020 with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(rec2020 100% none 0.2 / 23.7%)' [Rec BT.2020 with alpha, number, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz-d50 none none none)' [CIE XYZ D50 all none\]] + expected: FAIL + + [Property color value 'color(xyz-d50 1.00 none 0.2)' [CIE XYZ D50 number and none\]] + expected: FAIL + + [Property color value 'color(xyz-d50 100% none 20%)' [CIE XYZ D50 percent and none\]] + expected: FAIL + + [Property color value 'color(xyz-d50 100% none 0.2)' [CIE XYZ D50 number, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz-d50 none none none / none)' [CIE XYZ D50 with alpha, all none\]] + expected: FAIL + + [Property color value 'color(xyz-d50 1.00 none 0.2 / none)' [CIE XYZ D50 with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(xyz-d50 100% none 20% / 30%)' [CIE XYZ D50 with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz-d50 100% none 0.2 / 23.7%)' [CIE XYZ D50 with alpha, number, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz-d65 none none none)' [CIE XYZ D65 all none\]] + expected: FAIL + + [Property color value 'color(xyz-d65 1.00 none 0.2)' [CIE XYZ D65 number and none\]] + expected: FAIL + + [Property color value 'color(xyz-d65 100% none 20%)' [CIE XYZ D65 percent and none\]] + expected: FAIL + + [Property color value 'color(xyz-d65 100% none 0.2)' [CIE XYZ D65 number, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz-d65 none none none / none)' [CIE XYZ D65 with alpha, all none\]] + expected: FAIL + + [Property color value 'color(xyz-d65 1.00 none 0.2 / none)' [CIE XYZ D65 with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(xyz-d65 100% none 20% / 30%)' [CIE XYZ D65 with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz-d65 100% none 0.2 / 23.7%)' [CIE XYZ D65 with alpha, number, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz none none none)' [CIE XYZ (implicit D65) all none\]] + expected: FAIL + + [Property color value 'color(xyz 1.00 none 0.2)' [CIE XYZ (implicit D65) number and none\]] + expected: FAIL + + [Property color value 'color(xyz 100% none 20%)' [CIE XYZ (implicit D65) percent and none\]] + expected: FAIL + + [Property color value 'color(xyz 100% none 0.2)' [CIE XYZ (implicit D65) number, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz none none none / none)' [CIE XYZ (implicit D65) with alpha, all none\]] + expected: FAIL + + [Property color value 'color(xyz 1.00 none 0.2 / none)' [CIE XYZ (implicit D65) with alpha, number and none\]] + expected: FAIL + + [Property color value 'color(xyz 100% none 20% / 30%)' [CIE XYZ (implicit D65) with alpha, percent and none\]] + expected: FAIL + + [Property color value 'color(xyz 100% none 0.2 / 23.7%)' [CIE XYZ (implicit D65) with alpha, number, percent and none\]] + expected: FAIL + [Property color value 'color(display-p3 184 1.00001 2347329746587)' [Display P3 color with component > 1 should not clamp\]] expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-computed-color-mix-function.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-computed-color-mix-function.html.ini index bcdb9e95a33c..600c7e954c7c 100644 --- a/testing/web-platform/meta/css/css-color/parsing/color-computed-color-mix-function.html.ini +++ b/testing/web-platform/meta/css/css-color/parsing/color-computed-color-mix-function.html.ini @@ -1,4 +1,7 @@ [color-computed-color-mix-function.html] + [Property color value 'color-mix(in hsl, hsl(none none none), hsl(none none none))'] + expected: FAIL + [Property color value 'color-mix(in hsl, hsl(none none none), hsl(30deg 40% 80%))'] expected: FAIL @@ -17,9 +20,15 @@ [Property color value 'color-mix(in hsl, hsl(120deg 40% 40% / none), hsl(0deg 40% 40%))'] expected: FAIL + [Property color value 'color-mix(in hsl, hsl(120deg 40% 40% / none), hsl(0deg 40% 40% / 0.5))'] + expected: FAIL + [Property color value 'color-mix(in hsl, hsl(120deg 40% 40% / none), hsl(0deg 40% 40% / none))'] expected: FAIL + [Property color value 'color-mix(in hwb, hwb(none none none), hwb(none none none))'] + expected: FAIL + [Property color value 'color-mix(in hwb, hwb(none none none), hwb(30deg 30% 40%))'] expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-computed-hsl.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-computed-hsl.html.ini new file mode 100644 index 000000000000..cd4a5fc1a3dd --- /dev/null +++ b/testing/web-platform/meta/css/css-color/parsing/color-computed-hsl.html.ini @@ -0,0 +1,29 @@ +[color-computed-hsl.html] + expected: + if (os == "android") and fission: [TIMEOUT, OK] + [Property color value 'hsl(none none none)'] + expected: FAIL + + [Property color value 'hsl(none none none / none)'] + expected: FAIL + + [Property color value 'hsla(none none none)'] + expected: FAIL + + [Property color value 'hsla(none none none / none)'] + expected: FAIL + + [Property color value 'hsl(120 none none)'] + expected: FAIL + + [Property color value 'hsl(120 80% none)'] + expected: FAIL + + [Property color value 'hsl(120 none 50%)'] + expected: FAIL + + [Property color value 'hsl(120 100% 50% / none)'] + expected: FAIL + + [Property color value 'hsl(none 100% 50%)'] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-computed-hwb.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-computed-hwb.html.ini new file mode 100644 index 000000000000..c8c80b4ee32d --- /dev/null +++ b/testing/web-platform/meta/css/css-color/parsing/color-computed-hwb.html.ini @@ -0,0 +1,23 @@ +[color-computed-hwb.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [Property color value 'hwb(none none none)'] + expected: FAIL + + [Property color value 'hwb(none none none / none)'] + expected: FAIL + + [Property color value 'hwb(120 none none)'] + expected: FAIL + + [Property color value 'hwb(120 80% none)'] + expected: FAIL + + [Property color value 'hwb(120 none 50%)'] + expected: FAIL + + [Property color value 'hwb(120 30% 50% / none)'] + expected: FAIL + + [Property color value 'hwb(none 100% 50% / none)'] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-computed-lab.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-computed-lab.html.ini new file mode 100644 index 000000000000..827ffccc56df --- /dev/null +++ b/testing/web-platform/meta/css/css-color/parsing/color-computed-lab.html.ini @@ -0,0 +1,62 @@ +[color-computed-lab.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [Property color value 'lab(none none none / none)'] + expected: FAIL + + [Property color value 'lab(none none none)'] + expected: FAIL + + [Property color value 'lab(20 none none / none)'] + expected: FAIL + + [Property color value 'lab(none none none / 0.5)'] + expected: FAIL + + [Property color value 'lab(0 0 0 / none)'] + expected: FAIL + + [Property color value 'oklab(none none none / none)'] + expected: FAIL + + [Property color value 'oklab(none none none)'] + expected: FAIL + + [Property color value 'oklab(20 none none / none)'] + expected: FAIL + + [Property color value 'oklab(none none none / 0.5)'] + expected: FAIL + + [Property color value 'oklab(0 0 0 / none)'] + expected: FAIL + + [Property color value 'lch(none none none / none)'] + expected: FAIL + + [Property color value 'lch(none none none)'] + expected: FAIL + + [Property color value 'lch(20 none none / none)'] + expected: FAIL + + [Property color value 'lch(none none none / 0.5)'] + expected: FAIL + + [Property color value 'lch(0 0 0 / none)'] + expected: FAIL + + [Property color value 'oklch(none none none / none)'] + expected: FAIL + + [Property color value 'oklch(none none none)'] + expected: FAIL + + [Property color value 'oklch(20 none none / none)'] + expected: FAIL + + [Property color value 'oklch(none none none / 0.5)'] + expected: FAIL + + [Property color value 'oklch(0 0 0 / none)'] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-computed-rgb.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-computed-rgb.html.ini new file mode 100644 index 000000000000..4dc0ea8a33c4 --- /dev/null +++ b/testing/web-platform/meta/css/css-color/parsing/color-computed-rgb.html.ini @@ -0,0 +1,50 @@ +[color-computed-rgb.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [Property color value 'rgb(none none none)'] + expected: FAIL + + [Property color value 'rgb(none none none / none)'] + expected: FAIL + + [Property color value 'rgb(128 none none)'] + expected: FAIL + + [Property color value 'rgb(128 none none / none)'] + expected: FAIL + + [Property color value 'rgb(none none none / .5)'] + expected: FAIL + + [Property color value 'rgb(20% none none)'] + expected: FAIL + + [Property color value 'rgb(20% none none / none)'] + expected: FAIL + + [Property color value 'rgb(none none none / 50%)'] + expected: FAIL + + [Property color value 'rgba(none none none)'] + expected: FAIL + + [Property color value 'rgba(none none none / none)'] + expected: FAIL + + [Property color value 'rgba(128 none none)'] + expected: FAIL + + [Property color value 'rgba(128 none none / none)'] + expected: FAIL + + [Property color value 'rgba(none none none / .5)'] + expected: FAIL + + [Property color value 'rgba(20% none none)'] + expected: FAIL + + [Property color value 'rgba(20% none none / none)'] + expected: FAIL + + [Property color value 'rgba(none none none / 50%)'] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-valid-color-function.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-valid-color-function.html.ini index da2647e4455b..f1a48ff28e48 100644 --- a/testing/web-platform/meta/css/css-color/parsing/color-valid-color-function.html.ini +++ b/testing/web-platform/meta/css/css-color/parsing/color-valid-color-function.html.ini @@ -1,6 +1,142 @@ [color-valid-color-function.html] expected: if (os == "android") and fission: [OK, TIMEOUT] + + [e.style['color'\] = "color(srgb none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb 10% none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb 0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb-linear none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb-linear none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb-linear 10% none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb-linear none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(srgb-linear 0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(a98-rgb none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(a98-rgb none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(a98-rgb 10% none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(a98-rgb none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(a98-rgb 0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(rec2020 none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(rec2020 none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(rec2020 10% none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(rec2020 none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(rec2020 0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(prophoto-rgb none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(prophoto-rgb none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(prophoto-rgb 10% none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(prophoto-rgb none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(prophoto-rgb 0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(display-p3 none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(display-p3 none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(display-p3 10% none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(display-p3 none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(display-p3 0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz 0.2 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz 0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d50 none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d50 none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d50 0.2 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d50 none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d50 0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d65 none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d65 none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d65 0.2 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d65 none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "color(xyz-d65 0 0 0 / none)" should set the property value] + expected: FAIL + [e.style['color'\] = "color(srgb 0 0 0 / 300%)" should set the property value] expected: if not debug and (os == "mac"): [PASS, FAIL] diff --git a/testing/web-platform/meta/css/css-color/parsing/color-valid-color-mix-function.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-valid-color-mix-function.html.ini index 52aaec72238e..1478ad96eb50 100644 --- a/testing/web-platform/meta/css/css-color/parsing/color-valid-color-mix-function.html.ini +++ b/testing/web-platform/meta/css/css-color/parsing/color-valid-color-mix-function.html.ini @@ -17,6 +17,33 @@ [e.style['color'\] = "color-mix(in hsl, hsl(120deg 10% 20% / .4) 25%, hsl(30deg 30% 40% / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in hsl, hsl(none none none), hsl(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hsl, hsl(none none none), hsl(30deg 40% 80%))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hsl, hsl(120deg 20% 40%), hsl(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hsl, hsl(120deg 20% none), hsl(30deg 40% 60%))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hsl, hsl(120deg 20% 40%), hsl(30deg 20% none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hsl, hsl(none 20% 40%), hsl(30deg none 80%))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hsl, hsl(120deg 40% 40% / none), hsl(0deg 40% 40%))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hsl, hsl(120deg 40% 40% / none), hsl(0deg 40% 40% / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hsl, hsl(120deg 40% 40% / none), hsl(0deg 40% 40% / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in hsl, color(display-p3 0 1 0) 100%, rgb(0, 0, 0) 0%)" should set the property value] expected: FAIL @@ -62,6 +89,33 @@ [e.style['color'\] = "color-mix(in hwb, hwb(120deg 10% 20% / .4) 25%, hwb(30deg 30% 40% / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in hwb, hwb(none none none), hwb(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hwb, hwb(none none none), hwb(30deg 30% 40%))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hwb, hwb(120deg 10% 20%), hwb(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hwb, hwb(120deg 10% none), hwb(30deg 30% 40%))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hwb, hwb(120deg 10% 20%), hwb(30deg 30% none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hwb, hwb(none 10% 20%), hwb(30deg none 40%))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hwb, hwb(120deg 10% 20% / none), hwb(30deg 30% 40%))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hwb, hwb(120deg 10% 20% / none), hwb(30deg 30% 40% / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in hwb, hwb(120deg 10% 20% / none), hwb(30deg 30% 40% / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in hwb, color(display-p3 0 1 0) 100%, rgb(0, 0, 0) 0%)" should set the property value] expected: FAIL @@ -107,6 +161,33 @@ [e.style['color'\] = "color-mix(in lch, lch(10 20 30deg / .4) 25%, lch(50 60 70deg / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in lch, lch(none none none), lch(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lch, lch(none none none), lch(50 60 70deg))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lch, lch(10 20 30deg), lch(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lch, lch(10 20 none), lch(50 60 70deg))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lch, lch(10 20 30deg), lch(50 60 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lch, lch(none 20 30deg), lch(50 none 70deg))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lch, lch(10 20 30deg / none), lch(50 60 70deg))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lch, lch(10 20 30deg / none), lch(50 60 70deg / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lch, lch(10 20 30deg / none), lch(50 60 70deg / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in oklch, oklch(10 20 30deg), 25% oklch(50 60 70deg))" should set the property value] expected: FAIL @@ -125,6 +206,33 @@ [e.style['color'\] = "color-mix(in oklch, oklch(10 20 30deg / .4) 25%, oklch(50 60 70deg / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in oklch, oklch(none none none), oklch(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklch, oklch(none none none), oklch(50 60 70deg))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklch, oklch(10 20 30deg), oklch(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklch, oklch(10 20 none), oklch(50 60 70deg))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklch, oklch(10 20 30deg), oklch(50 60 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklch, oklch(none 20 30deg), oklch(50 none 70deg))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklch, oklch(10 20 30deg / none), oklch(50 60 70deg))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklch, oklch(10 20 30deg / none), oklch(50 60 70deg / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklch, oklch(10 20 30deg / none), oklch(50 60 70deg / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in lab, lab(10 20 30), 25% lab(50 60 70))" should set the property value] expected: FAIL @@ -143,6 +251,33 @@ [e.style['color'\] = "color-mix(in lab, lab(10 20 30 / .4) 25%, lab(50 60 70 / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in lab, lab(none none none), lab(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lab, lab(none none none), lab(50 60 70))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lab, lab(10 20 30), lab(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lab, lab(10 20 none), lab(50 60 70))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lab, lab(10 20 30), lab(50 60 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lab, lab(none 20 30), lab(50 none 70))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lab, lab(10 20 30 / none), lab(50 60 70))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lab, lab(10 20 30 / none), lab(50 60 70 / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in lab, lab(10 20 30 / none), lab(50 60 70 / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in oklab, oklab(10 20 30), 25% oklab(50 60 70))" should set the property value] expected: FAIL @@ -161,6 +296,33 @@ [e.style['color'\] = "color-mix(in oklab, oklab(10 20 30 / .4) 25%, oklab(50 60 70 / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in oklab, oklab(none none none), oklab(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklab, oklab(none none none), oklab(50 60 70))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklab, oklab(10 20 30), oklab(none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklab, oklab(10 20 none), oklab(50 60 70))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklab, oklab(10 20 30), oklab(50 60 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklab, oklab(none 20 30), oklab(50 none 70))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklab, oklab(10 20 30 / none), oklab(50 60 70))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklab, oklab(10 20 30 / none), oklab(50 60 70 / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in oklab, oklab(10 20 30 / none), oklab(50 60 70 / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in srgb, color(srgb .1 .2 .3), color(srgb .5 .6 .7) 25%)" should set the property value] expected: FAIL @@ -173,6 +335,33 @@ [e.style['color'\] = "color-mix(in srgb, color(srgb .1 .2 .3 / .4) 25%, color(srgb .5 .6 .7 / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in srgb, color(srgb none none none), color(srgb none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb, color(srgb none none none), color(srgb .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb, color(srgb .1 .2 .3), color(srgb none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb, color(srgb .1 .2 none), color(srgb .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb, color(srgb .1 .2 .3), color(srgb .5 .6 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb, color(srgb none .2 .3), color(srgb .5 none .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb, color(srgb .1 .2 .3 / none), color(srgb .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb, color(srgb .1 .2 .3 / none), color(srgb .5 .6 .7 / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb, color(srgb .1 .2 .3 / none), color(srgb .5 .6 .7 / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear .1 .2 .3), color(srgb-linear .5 .6 .7) 25%)" should set the property value] expected: FAIL @@ -185,6 +374,33 @@ [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear .1 .2 .3 / .4) 25%, color(srgb-linear .5 .6 .7 / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear none none none), color(srgb-linear none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear none none none), color(srgb-linear .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear .1 .2 .3), color(srgb-linear none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear .1 .2 none), color(srgb-linear .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear .1 .2 .3), color(srgb-linear .5 .6 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear none .2 .3), color(srgb-linear .5 none .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear .1 .2 .3 / none), color(srgb-linear .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear .1 .2 .3 / none), color(srgb-linear .5 .6 .7 / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in srgb-linear, color(srgb-linear .1 .2 .3 / none), color(srgb-linear .5 .6 .7 / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in xyz, color(xyz .1 .2 .3), color(xyz .5 .6 .7) 25%)" should set the property value] expected: FAIL @@ -197,6 +413,33 @@ [e.style['color'\] = "color-mix(in xyz, color(xyz .1 .2 .3 / .4) 25%, color(xyz .5 .6 .7 / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in xyz, color(xyz none none none), color(xyz none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz, color(xyz none none none), color(xyz .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz, color(xyz .1 .2 .3), color(xyz none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz, color(xyz .1 .2 none), color(xyz .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz, color(xyz .1 .2 .3), color(xyz .5 .6 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz, color(xyz none .2 .3), color(xyz .5 none .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz, color(xyz .1 .2 .3 / none), color(xyz .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz, color(xyz .1 .2 .3 / none), color(xyz .5 .6 .7 / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz, color(xyz .1 .2 .3 / none), color(xyz .5 .6 .7 / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 .1 .2 .3), color(xyz-d50 .5 .6 .7) 25%)" should set the property value] expected: FAIL @@ -209,6 +452,33 @@ [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 .1 .2 .3 / .4) 25%, color(xyz-d50 .5 .6 .7 / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 none none none), color(xyz-d50 none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 none none none), color(xyz-d50 .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 .1 .2 .3), color(xyz-d50 none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 .1 .2 none), color(xyz-d50 .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 .1 .2 .3), color(xyz-d50 .5 .6 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 none .2 .3), color(xyz-d50 .5 none .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 .1 .2 .3 / none), color(xyz-d50 .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 .1 .2 .3 / none), color(xyz-d50 .5 .6 .7 / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d50, color(xyz-d50 .1 .2 .3 / none), color(xyz-d50 .5 .6 .7 / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 .1 .2 .3), color(xyz-d65 .5 .6 .7) 25%)" should set the property value] expected: FAIL @@ -221,6 +491,33 @@ [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 .1 .2 .3 / .4) 25%, color(xyz-d65 .5 .6 .7 / .8) 75%)" should set the property value] expected: FAIL + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 none none none), color(xyz-d65 none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 none none none), color(xyz-d65 .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 .1 .2 .3), color(xyz-d65 none none none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 .1 .2 none), color(xyz-d65 .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 .1 .2 .3), color(xyz-d65 .5 .6 none))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 none .2 .3), color(xyz-d65 .5 none .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 .1 .2 .3 / none), color(xyz-d65 .5 .6 .7))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 .1 .2 .3 / none), color(xyz-d65 .5 .6 .7 / 0.5))" should set the property value] + expected: FAIL + + [e.style['color'\] = "color-mix(in xyz-d65, color(xyz-d65 .1 .2 .3 / none), color(xyz-d65 .5 .6 .7 / none))" should set the property value] + expected: FAIL + [e.style['color'\] = "color-mix(in hsl, red 60%, blue 40%)" should set the property value] expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-valid-hsl.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-valid-hsl.html.ini new file mode 100644 index 000000000000..0d545fb20134 --- /dev/null +++ b/testing/web-platform/meta/css/css-color/parsing/color-valid-hsl.html.ini @@ -0,0 +1,29 @@ +[color-valid-hsl.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [e.style['color'\] = "hsl(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hsl(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hsla(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hsla(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hsl(120 none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hsl(120 80% none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hsl(120 none 50%)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hsl(120 100% 50% / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hsl(none 100% 50%)" should set the property value] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-valid-hwb.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-valid-hwb.html.ini new file mode 100644 index 000000000000..a2ef00f2125f --- /dev/null +++ b/testing/web-platform/meta/css/css-color/parsing/color-valid-hwb.html.ini @@ -0,0 +1,23 @@ +[color-valid-hwb.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [e.style['color'\] = "hwb(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hwb(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hwb(120 none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hwb(120 80% none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hwb(120 none 50%)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hwb(120 30% 50% / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "hwb(none 100% 50% / none)" should set the property value] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-valid-lab.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-valid-lab.html.ini new file mode 100644 index 000000000000..8af3a04bbf51 --- /dev/null +++ b/testing/web-platform/meta/css/css-color/parsing/color-valid-lab.html.ini @@ -0,0 +1,62 @@ +[color-valid-lab.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [e.style['color'\] = "lab(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lab(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lab(20 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lab(none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lab(0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklab(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklab(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklab(20 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklab(none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklab(0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lch(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lch(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lch(20 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lch(none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "lch(0 0 0 / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklch(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklch(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklch(20 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklch(none none none / 0.5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "oklch(0 0 0 / none)" should set the property value] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-valid-rgb.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-valid-rgb.html.ini new file mode 100644 index 000000000000..6ba34fbd9998 --- /dev/null +++ b/testing/web-platform/meta/css/css-color/parsing/color-valid-rgb.html.ini @@ -0,0 +1,50 @@ +[color-valid-rgb.html] + expected: + if (os == "android") and fission: [OK, TIMEOUT] + [e.style['color'\] = "rgb(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgb(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgb(128 none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgb(128 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgb(none none none / .5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgb(20% none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgb(20% none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgb(none none none / 50%)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgba(none none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgba(none none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgba(128 none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgba(128 none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgba(none none none / .5)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgba(20% none none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgba(20% none none / none)" should set the property value] + expected: FAIL + + [e.style['color'\] = "rgba(none none none / 50%)" should set the property value] + expected: FAIL diff --git a/testing/web-platform/tests/css/css-color/parsing/color-valid-color-mix-function.html b/testing/web-platform/tests/css/css-color/parsing/color-valid-color-mix-function.html index cbd8e3a19119..7751c2ca1d43 100644 --- a/testing/web-platform/tests/css/css-color/parsing/color-valid-color-mix-function.html +++ b/testing/web-platform/tests/css/css-color/parsing/color-valid-color-mix-function.html @@ -124,36 +124,36 @@ test_valid_value(`color`, `color-mix(in hwb, hwb(60deg 30% 40%), hwb(40deg 30% 40%))`, `color-mix(in hwb, rgb(153, 153, 77), rgb(153, 128, 77))`); test_valid_value(`color`, `color-mix(in hwb, hwb(50deg 30% 40%), hwb(330deg 30% 40%))`, `color-mix(in hwb, rgb(153, 140, 77), rgb(153, 77, 115))`); test_valid_value(`color`, `color-mix(in hwb, hwb(330deg 30% 40%), hwb(50deg 30% 40%))`, `color-mix(in hwb, rgb(153, 77, 115), rgb(153, 140, 77))`); - test_valid_value(`color`, `color-mix(in hwb, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb, rgb(153, 102, 77), rgb(153, 77, 128))`); - test_valid_value(`color`, `color-mix(in hwb, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb, rgb(153, 77, 128), rgb(153, 102, 77))`); + test_valid_value(`color`, `color-mix(in hwb, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb, rgb(153, 102, 77), rgb(153, 77, 127))`); + test_valid_value(`color`, `color-mix(in hwb, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb, rgb(153, 77, 127), rgb(153, 102, 77))`); test_valid_value(`color`, `color-mix(in hwb shorter hue, hwb(40deg 30% 40%), hwb(60deg 30% 40%))`, `color-mix(in hwb, rgb(153, 128, 77), rgb(153, 153, 77))`); test_valid_value(`color`, `color-mix(in hwb shorter hue, hwb(60deg 30% 40%), hwb(40deg 30% 40%))`, `color-mix(in hwb, rgb(153, 153, 77), rgb(153, 128, 77))`); test_valid_value(`color`, `color-mix(in hwb shorter hue, hwb(50deg 30% 40%), hwb(330deg 30% 40%))`, `color-mix(in hwb, rgb(153, 140, 77), rgb(153, 77, 115))`); test_valid_value(`color`, `color-mix(in hwb shorter hue, hwb(330deg 30% 40%), hwb(50deg 30% 40%))`, `color-mix(in hwb, rgb(153, 77, 115), rgb(153, 140, 77))`); - test_valid_value(`color`, `color-mix(in hwb shorter hue, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb, rgb(153, 102, 77), rgb(153, 77, 128))`); - test_valid_value(`color`, `color-mix(in hwb shorter hue, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb, rgb(153, 77, 128), rgb(153, 102, 77))`); + test_valid_value(`color`, `color-mix(in hwb shorter hue, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb, rgb(153, 102, 77), rgb(153, 77, 127))`); + test_valid_value(`color`, `color-mix(in hwb shorter hue, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb, rgb(153, 77, 127), rgb(153, 102, 77))`); test_valid_value(`color`, `color-mix(in hwb longer hue, hwb(40deg 30% 40%), hwb(60deg 30% 40%))`, `color-mix(in hwb longer hue, rgb(153, 128, 77), rgb(153, 153, 77))`); test_valid_value(`color`, `color-mix(in hwb longer hue, hwb(60deg 30% 40%), hwb(40deg 30% 40%))`, `color-mix(in hwb longer hue, rgb(153, 153, 77), rgb(153, 128, 77))`); test_valid_value(`color`, `color-mix(in hwb longer hue, hwb(50deg 30% 40%), hwb(330deg 30% 40%))`, `color-mix(in hwb longer hue, rgb(153, 140, 77), rgb(153, 77, 115))`); test_valid_value(`color`, `color-mix(in hwb longer hue, hwb(330deg 30% 40%), hwb(50deg 30% 40%))`, `color-mix(in hwb longer hue, rgb(153, 77, 115), rgb(153, 140, 77))`); - test_valid_value(`color`, `color-mix(in hwb longer hue, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb longer hue, rgb(153, 102, 77), rgb(153, 77, 128))`); - test_valid_value(`color`, `color-mix(in hwb longer hue, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb longer hue, rgb(153, 77, 128), rgb(153, 102, 77))`); + test_valid_value(`color`, `color-mix(in hwb longer hue, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb longer hue, rgb(153, 102, 77), rgb(153, 77, 127))`); + test_valid_value(`color`, `color-mix(in hwb longer hue, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb longer hue, rgb(153, 77, 127), rgb(153, 102, 77))`); test_valid_value(`color`, `color-mix(in hwb increasing hue, hwb(40deg 30% 40%), hwb(60deg 30% 40%))`, `color-mix(in hwb increasing hue, rgb(153, 128, 77), rgb(153, 153, 77))`); test_valid_value(`color`, `color-mix(in hwb increasing hue, hwb(60deg 30% 40%), hwb(40deg 30% 40%))`, `color-mix(in hwb increasing hue, rgb(153, 153, 77), rgb(153, 128, 77))`); test_valid_value(`color`, `color-mix(in hwb increasing hue, hwb(50deg 30% 40%), hwb(330deg 30% 40%))`, `color-mix(in hwb increasing hue, rgb(153, 140, 77), rgb(153, 77, 115))`); test_valid_value(`color`, `color-mix(in hwb increasing hue, hwb(330deg 30% 40%), hwb(50deg 30% 40%))`, `color-mix(in hwb increasing hue, rgb(153, 77, 115), rgb(153, 140, 77))`); - test_valid_value(`color`, `color-mix(in hwb increasing hue, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb increasing hue, rgb(153, 102, 77), rgb(153, 77, 128))`); - test_valid_value(`color`, `color-mix(in hwb increasing hue, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb increasing hue, rgb(153, 77, 128), rgb(153, 102, 77))`); + test_valid_value(`color`, `color-mix(in hwb increasing hue, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb increasing hue, rgb(153, 102, 77), rgb(153, 77, 127))`); + test_valid_value(`color`, `color-mix(in hwb increasing hue, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb increasing hue, rgb(153, 77, 127), rgb(153, 102, 77))`); test_valid_value(`color`, `color-mix(in hwb decreasing hue, hwb(40deg 30% 40%), hwb(60deg 30% 40%))`, `color-mix(in hwb decreasing hue, rgb(153, 128, 77), rgb(153, 153, 77))`); test_valid_value(`color`, `color-mix(in hwb decreasing hue, hwb(60deg 30% 40%), hwb(40deg 30% 40%))`, `color-mix(in hwb decreasing hue, rgb(153, 153, 77), rgb(153, 128, 77))`); test_valid_value(`color`, `color-mix(in hwb decreasing hue, hwb(50deg 30% 40%), hwb(330deg 30% 40%))`, `color-mix(in hwb decreasing hue, rgb(153, 140, 77), rgb(153, 77, 115))`); test_valid_value(`color`, `color-mix(in hwb decreasing hue, hwb(330deg 30% 40%), hwb(50deg 30% 40%))`, `color-mix(in hwb decreasing hue, rgb(153, 77, 115), rgb(153, 140, 77))`); - test_valid_value(`color`, `color-mix(in hwb decreasing hue, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb decreasing hue, rgb(153, 102, 77), rgb(153, 77, 128))`); - test_valid_value(`color`, `color-mix(in hwb decreasing hue, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb decreasing hue, rgb(153, 77, 128), rgb(153, 102, 77))`); + test_valid_value(`color`, `color-mix(in hwb decreasing hue, hwb(20deg 30% 40%), hwb(320deg 30% 40%))`, `color-mix(in hwb decreasing hue, rgb(153, 102, 77), rgb(153, 77, 127))`); + test_valid_value(`color`, `color-mix(in hwb decreasing hue, hwb(320deg 30% 40%), hwb(20deg 30% 40%))`, `color-mix(in hwb decreasing hue, rgb(153, 77, 127), rgb(153, 102, 77))`); test_valid_value(`color`, `color-mix(in hwb, hwb(none none none), hwb(none none none))`, `color-mix(in hwb, rgb(255, 0, 0), rgb(255, 0, 0))`); test_valid_value(`color`, `color-mix(in hwb, hwb(none none none), hwb(30deg 30% 40%))`, `color-mix(in hwb, rgb(255, 0, 0), rgb(153, 115, 77))`); @@ -274,39 +274,39 @@ test_valid_value(`color`, `color-mix(in ${colorSpace}, ${colorSpace}(10 20 30 / none), ${colorSpace}(50 60 70 / none))`, `color-mix(in ${colorSpace}, ${colorSpace}(10 20 30 / none), ${colorSpace}(50 60 70 / none))`); } - for (const colorSpace of [ "srgb", "srgb-linear", "xyz", "xyz-d50", "xyz-d65" ]) { - const resultColorSpace = colorSpace == "xyz" ? "xyz-d65" : colorSpace; + for (const colorSpace of [ "srgb", "srgb-linear", "xyz", "xyz-d50", "xyz-d65" ]) { + const resultColorSpace = colorSpace == "xyz" ? "xyz-d65" : colorSpace; - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3), color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3), color(${resultColorSpace} 0.5 0.6 0.7))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 25%, color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 25%, color(${resultColorSpace} 0.5 0.6 0.7))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3), color(${colorSpace} .5 .6 .7) 25%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3), color(${resultColorSpace} 0.5 0.6 0.7) 25%)`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 25%, color(${colorSpace} .5 .6 .7) 75%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 25%, color(${resultColorSpace} 0.5 0.6 0.7) 75%)`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 30%, color(${colorSpace} .5 .6 .7) 90%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 30%, color(${resultColorSpace} 0.5 0.6 0.7) 90%)`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 12.5%, color(${colorSpace} .5 .6 .7) 37.5%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 12.5%, color(${resultColorSpace} 0.5 0.6 0.7) 37.5%)`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 0%, color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 0%, color(${resultColorSpace} 0.5 0.6 0.7))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3), color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3), color(${resultColorSpace} 0.5 0.6 0.7))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 25%, color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 25%, color(${resultColorSpace} 0.5 0.6 0.7))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3), color(${colorSpace} .5 .6 .7) 25%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3), color(${resultColorSpace} 0.5 0.6 0.7) 25%)`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 25%, color(${colorSpace} .5 .6 .7) 75%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 25%, color(${resultColorSpace} 0.5 0.6 0.7) 75%)`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 30%, color(${colorSpace} .5 .6 .7) 90%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 30%, color(${resultColorSpace} 0.5 0.6 0.7) 90%)`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 12.5%, color(${colorSpace} .5 .6 .7) 37.5%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 12.5%, color(${resultColorSpace} 0.5 0.6 0.7) 37.5%)`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3) 0%, color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3) 0%, color(${resultColorSpace} 0.5 0.6 0.7))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .5), color(${colorSpace} .5 .6 .7 / .8))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.5), color(${resultColorSpace} 0.5 0.6 0.7 / 0.8))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 25%, color(${colorSpace} .5 .6 .7 / .8))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 25%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4), color(${colorSpace} .5 .6 .7 / .8) 25%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4), color(${resultColorSpace} 0.5 0.6 0.7 / 0.8) 25%)`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 25%, color(${colorSpace} .5 .6 .7 / .8) 75%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 25%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8) 75%)`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 30%, color(${colorSpace} .5 .6 .7 / .8) 90%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 30%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8) 90%)`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 12.5%, color(${colorSpace} .5 .6 .7 / .8) 37.5%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 12.5%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8) 37.5%)`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 0%, color(${colorSpace} .5 .6 .7 / .8))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 0%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .5), color(${colorSpace} .5 .6 .7 / .8))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.5), color(${resultColorSpace} 0.5 0.6 0.7 / 0.8))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 25%, color(${colorSpace} .5 .6 .7 / .8))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 25%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4), color(${colorSpace} .5 .6 .7 / .8) 25%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4), color(${resultColorSpace} 0.5 0.6 0.7 / 0.8) 25%)`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 25%, color(${colorSpace} .5 .6 .7 / .8) 75%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 25%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8) 75%)`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 30%, color(${colorSpace} .5 .6 .7 / .8) 90%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 30%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8) 90%)`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 12.5%, color(${colorSpace} .5 .6 .7 / .8) 37.5%)`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 12.5%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8) 37.5%)`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / .4) 0%, color(${colorSpace} .5 .6 .7 / .8))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / 0.4) 0%, color(${resultColorSpace} 0.5 0.6 0.7 / 0.8))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} 2 3 4 / 5), color(${colorSpace} 4 6 8 / 10))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 2 3 4), color(${resultColorSpace} 4 6 8))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} -2 -3 -4), color(${colorSpace} -4 -6 -8))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} -2 -3 -4), color(${resultColorSpace} -4 -6 -8))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} -2 -3 -4 / -5), color(${colorSpace} -4 -6 -8 / -10))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} -2 -3 -4 / 0), color(${resultColorSpace} -4 -6 -8 / 0))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} 2 3 4 / 5), color(${colorSpace} 4 6 8 / 10))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 2 3 4), color(${resultColorSpace} 4 6 8))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} -2 -3 -4), color(${colorSpace} -4 -6 -8))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} -2 -3 -4), color(${resultColorSpace} -4 -6 -8))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} -2 -3 -4 / -5), color(${colorSpace} -4 -6 -8 / -10))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} -2 -3 -4 / 0), color(${resultColorSpace} -4 -6 -8 / 0))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} none none none), color(${colorSpace} none none none))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} none none none), color(${resultColorSpace} none none none))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} none none none), color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} none none none), color(${resultColorSpace} 0.5 0.6 0.7))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3), color(${colorSpace} none none none))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3), color(${resultColorSpace} none none none))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 none), color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 none), color(${resultColorSpace} 0.5 0.6 0.7))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3), color(${colorSpace} .5 .6 none))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3), color(${resultColorSpace} 0.5 0.6 none))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} none .2 .3), color(${colorSpace} .5 none .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} none 0.2 0.3), color(${resultColorSpace} 0.5 none 0.7))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / none), color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / none), color(${resultColorSpace} 0.5 0.6 0.7))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / none), color(${colorSpace} .5 .6 .7 / 0.5))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / none), color(${resultColorSpace} 0.5 0.6 0.7 / 0.5))`); - test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / none), color(${colorSpace} .5 .6 .7 / none))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / none), color(${resultColorSpace} 0.5 0.6 0.7 / none))`); - } + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} none none none), color(${colorSpace} none none none))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} none none none), color(${resultColorSpace} none none none))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} none none none), color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} none none none), color(${resultColorSpace} 0.5 0.6 0.7))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3), color(${colorSpace} none none none))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3), color(${resultColorSpace} none none none))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 none), color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 none), color(${resultColorSpace} 0.5 0.6 0.7))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3), color(${colorSpace} .5 .6 none))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3), color(${resultColorSpace} 0.5 0.6 none))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} none .2 .3), color(${colorSpace} .5 none .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} none 0.2 0.3), color(${resultColorSpace} 0.5 none 0.7))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / none), color(${colorSpace} .5 .6 .7))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / none), color(${resultColorSpace} 0.5 0.6 0.7))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / none), color(${colorSpace} .5 .6 .7 / 0.5))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / none), color(${resultColorSpace} 0.5 0.6 0.7 / 0.5))`); + test_valid_value(`color`, `color-mix(in ${colorSpace}, color(${colorSpace} .1 .2 .3 / none), color(${colorSpace} .5 .6 .7 / none))`, `color-mix(in ${resultColorSpace}, color(${resultColorSpace} 0.1 0.2 0.3 / none), color(${resultColorSpace} 0.5 0.6 0.7 / none))`); + } diff --git a/third_party/rust/cssparser/.cargo-checksum.json b/third_party/rust/cssparser/.cargo-checksum.json index 9e2df4b967f1..464989c77ddd 100644 --- a/third_party/rust/cssparser/.cargo-checksum.json +++ b/third_party/rust/cssparser/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".github/workflows/main.yml":"d66f2aac0764ebb09540737931fe2b9311e7033a2bf9a116c072cae6bec5e187","Cargo.toml":"50e9595b9b5243dab2200c2006ea9aed05e68118a9109e3320bda3d3bd82924b","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"53a6805edd80f642473514cb93f1f4197e17a911d66a2dfcefc3dc5e82bac206","build.rs":"b30f35bfbd713943822a19ce6ebe5c99017f603cb001ed37354020549aec71fc","build/match_byte.rs":"f57faf0597cb7b3e32999c5fb1215a43a5603121588c67d5031f720362171e1c","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"788898ddc0dec90fc972091642f37ab769fc818199293b8dc1c59c21ad0d3d00","src/cow_rc_str.rs":"89b5dff5cf80eef3fcff0c11799e54a978d02d8b8963a621fbb999d35e7c03a3","src/from_bytes.rs":"b1cf15c4e975523fef46b575598737a39f3c63e5ce0b2bfd6ec627c69c6ea54a","src/lib.rs":"9a6b8657291eb142cd33972eaba1afd8fb2432b96b061687238278fecc3e0de1","src/macros.rs":"0d4c3d27a22677d9eb3616d7f7af604dc3de2932ca04fd1c036102884cd6f079","src/nth.rs":"2fc26915f0a36cb22ac45dd9a7ecbdc64c327b2ec135370258ec3db9f9985460","src/parser.rs":"f9985187ede4361a29b3bf22d248903343d58e5cf369a9b5e046961356a4faf9","src/rules_and_declarations.rs":"d826f82f8c179fc13756b92336556e3ee40a273314ef774f95af71e687745f2a","src/serializer.rs":"3a0155521676deea9a6327c2ed00af6d5dabb29a97e2341d0f565f8c2b66d0a3","src/size_of_tests.rs":"da0cbcaa304f7800e9122e2bce0a11d42a70b9012e646a723cb23ee74a6b858c","src/tests.rs":"9847bd8a60bda34259d2900e2b2d217e4c4a0e7dc6e410c61eee3b0e805b9a7e","src/tokenizer.rs":"71600903284f1d68a7da6b69c938b31f9d641f8d981c7adfd06a3c8b783541f2","src/unicode_range.rs":"20d96f06fbb73921e308cc340c9fe065e27f19843005689fb259007a6a372bcc"},"package":null} \ No newline at end of file +{"files":{".github/workflows/main.yml":"d66f2aac0764ebb09540737931fe2b9311e7033a2bf9a116c072cae6bec5e187","Cargo.toml":"03677b7dd7609f355cdeff66b2034647e2e553b282aa9fe7d0aca93a3ab04299","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"53a6805edd80f642473514cb93f1f4197e17a911d66a2dfcefc3dc5e82bac206","build.rs":"b30f35bfbd713943822a19ce6ebe5c99017f603cb001ed37354020549aec71fc","build/match_byte.rs":"f57faf0597cb7b3e32999c5fb1215a43a5603121588c67d5031f720362171e1c","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"541087948795b2e6e605fb9947db94956c1d0d6956444c6ff4860a430bb421ca","src/cow_rc_str.rs":"89b5dff5cf80eef3fcff0c11799e54a978d02d8b8963a621fbb999d35e7c03a3","src/from_bytes.rs":"b1cf15c4e975523fef46b575598737a39f3c63e5ce0b2bfd6ec627c69c6ea54a","src/lib.rs":"a708572027ee6a21795c2bc2652ecda2871e620b69241120491a6117a8a1eec6","src/macros.rs":"0d4c3d27a22677d9eb3616d7f7af604dc3de2932ca04fd1c036102884cd6f079","src/nth.rs":"2fc26915f0a36cb22ac45dd9a7ecbdc64c327b2ec135370258ec3db9f9985460","src/parser.rs":"f9985187ede4361a29b3bf22d248903343d58e5cf369a9b5e046961356a4faf9","src/rules_and_declarations.rs":"d826f82f8c179fc13756b92336556e3ee40a273314ef774f95af71e687745f2a","src/serializer.rs":"3a0155521676deea9a6327c2ed00af6d5dabb29a97e2341d0f565f8c2b66d0a3","src/size_of_tests.rs":"da0cbcaa304f7800e9122e2bce0a11d42a70b9012e646a723cb23ee74a6b858c","src/tests.rs":"20e2369301229c541955eb7417196419c5f676e1c0dd141b191ba7ddbb51cae3","src/tokenizer.rs":"71600903284f1d68a7da6b69c938b31f9d641f8d981c7adfd06a3c8b783541f2","src/unicode_range.rs":"20d96f06fbb73921e308cc340c9fe065e27f19843005689fb259007a6a372bcc"},"package":null} \ No newline at end of file diff --git a/third_party/rust/cssparser/Cargo.toml b/third_party/rust/cssparser/Cargo.toml index 68920ab7f507..23695b79b693 100644 --- a/third_party/rust/cssparser/Cargo.toml +++ b/third_party/rust/cssparser/Cargo.toml @@ -1,77 +1,41 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - [package] -edition = "2018" -rust-version = "1.56" name = "cssparser" version = "0.30.0" -authors = ["Simon Sapin "] -build = "build.rs" -exclude = [ - "src/css-parsing-tests/**", - "src/big-data-url.css", -] +authors = [ "Simon Sapin " ] + description = "Rust implementation of CSS Syntax Level 3" documentation = "https://docs.rs/cssparser/" -readme = "README.md" -keywords = [ - "css", - "syntax", - "parser", -] -license = "MPL-2.0" repository = "https://github.com/servo/rust-cssparser" +readme = "README.md" +keywords = ["css", "syntax", "parser"] +license = "MPL-2.0" +build = "build.rs" +edition = "2018" +rust-version = "1.56" -[dependencies] -dtoa-short = "0.3" -itoa = "1.0" -smallvec = "1.0" - -[dependencies.cssparser-macros] -version = "0.6" -path = "./macros" - -[dependencies.phf] -version = ">=0.8,<=0.11" -features = ["macros"] - -[dependencies.serde] -version = "1.0" -optional = true +exclude = ["src/css-parsing-tests/**", "src/big-data-url.css"] [dev-dependencies] +serde_json = "1.0" difference = "2.0" encoding_rs = "0.8" -serde_json = "1.0" + +[dependencies] +cssparser-macros = {path = "./macros", version = "0.6"} +dtoa-short = "0.3" +itoa = "1.0" +phf = {version = ">=0.8,<=0.11", features = ["macros"]} +serde = {version = "1.0", optional = true} +smallvec = "1.0" [build-dependencies] -proc-macro2 = "1" +syn = { version = "1", features = ["extra-traits", "fold", "full"] } quote = "1" - -[build-dependencies.syn] -version = "1" -features = [ - "extra-traits", - "fold", - "full", -] +proc-macro2 = "1" [features] bench = [] dummy_match_byte = [] [workspace] -members = [ - ".", - "./macros", - "./procedural-masquerade", -] +members = [".", "./macros", "./procedural-masquerade"] diff --git a/third_party/rust/cssparser/src/color.rs b/third_party/rust/cssparser/src/color.rs index 3c8ecf72141b..adc595235633 100644 --- a/third_party/rust/cssparser/src/color.rs +++ b/third_party/rust/cssparser/src/color.rs @@ -13,28 +13,9 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; const OPAQUE: f32 = 1.0; -fn serialize_none_or(dest: &mut impl fmt::Write, value: &Option) -> fmt::Result -where - T: ToCss, -{ - match value { - Some(v) => v.to_css(dest), - None => dest.write_str("none"), - } -} - /// https://drafts.csswg.org/css-color-4/#serializing-alpha-values #[inline] -fn serialize_alpha( - dest: &mut impl fmt::Write, - alpha: Option, - legacy_syntax: bool, -) -> fmt::Result { - let alpha = match alpha { - None => return dest.write_str(" / none"), - Some(a) => a, - }; - +fn serialize_alpha(dest: &mut impl fmt::Write, alpha: f32, legacy_syntax: bool) -> fmt::Result { // If the alpha component is full opaque, don't emit the alpha value in CSS. if alpha == OPAQUE { return Ok(()); @@ -51,25 +32,18 @@ fn serialize_alpha( rounded_alpha.to_css(dest) } -// Guaratees hue in [0..360) -fn normalize_hue(hue: f32) -> f32 { - // https://drafts.csswg.org/css-values/#angles - // Subtract an integer before rounding, to avoid some rounding errors: - hue - 360.0 * (hue / 360.0).floor() -} - /// A color with red, green, blue, and alpha components, in a byte each. #[derive(Clone, Copy, PartialEq, Debug)] #[repr(C)] pub struct RGBA { /// The red component. - pub red: Option, + pub red: u8, /// The green component. - pub green: Option, + pub green: u8, /// The blue component. - pub blue: Option, + pub blue: u8, /// The alpha component. - pub alpha: Option, + pub alpha: f32, } impl RGBA { @@ -77,28 +51,24 @@ impl RGBA { /// green, blue and alpha channels in that order, and all values will be /// clamped to the 0.0 ... 1.0 range. #[inline] - pub fn from_floats( - red: Option, - green: Option, - blue: Option, - alpha: Option, - ) -> Self { + pub fn from_floats(red: f32, green: f32, blue: f32, alpha: f32) -> Self { Self::new( - red.map(clamp_unit_f32), - green.map(clamp_unit_f32), - blue.map(clamp_unit_f32), - alpha.map(|a| a.clamp(0.0, OPAQUE)), + clamp_unit_f32(red), + clamp_unit_f32(green), + clamp_unit_f32(blue), + alpha.max(0.0).min(1.0), ) } + /// Returns a transparent color. + #[inline] + pub fn transparent() -> Self { + Self::new(0, 0, 0, 0.0) + } + /// Same thing, but with `u8` values instead of floats in the 0 to 1 range. #[inline] - pub const fn new( - red: Option, - green: Option, - blue: Option, - alpha: Option, - ) -> Self { + pub const fn new(red: u8, green: u8, blue: u8, alpha: f32) -> Self { Self { red, green, @@ -106,6 +76,62 @@ impl RGBA { alpha, } } + + /// Returns the red channel in a floating point number form, from 0 to 1. + #[inline] + pub fn red_f32(&self) -> f32 { + self.red as f32 / 255.0 + } + + /// Returns the green channel in a floating point number form, from 0 to 1. + #[inline] + pub fn green_f32(&self) -> f32 { + self.green as f32 / 255.0 + } + + /// Returns the blue channel in a floating point number form, from 0 to 1. + #[inline] + pub fn blue_f32(&self) -> f32 { + self.blue as f32 / 255.0 + } + + /// Returns the alpha channel in a floating point number form, from 0 to 1. + #[inline] + pub fn alpha_f32(&self) -> f32 { + self.alpha + } + + /// Parse a color hash, without the leading '#' character. + #[inline] + pub fn parse_hash(value: &[u8]) -> Result { + Ok(match value.len() { + 8 => Self::new( + from_hex(value[0])? * 16 + from_hex(value[1])?, + from_hex(value[2])? * 16 + from_hex(value[3])?, + from_hex(value[4])? * 16 + from_hex(value[5])?, + (from_hex(value[6])? * 16 + from_hex(value[7])?) as f32 / 255.0, + ), + 6 => Self::new( + from_hex(value[0])? * 16 + from_hex(value[1])?, + from_hex(value[2])? * 16 + from_hex(value[3])?, + from_hex(value[4])? * 16 + from_hex(value[5])?, + OPAQUE, + ), + 4 => Self::new( + from_hex(value[0])? * 17, + from_hex(value[1])? * 17, + from_hex(value[2])? * 17, + (from_hex(value[3])? * 17) as f32 / 255.0, + ), + 3 => Self::new( + from_hex(value[0])? * 17, + from_hex(value[1])? * 17, + from_hex(value[2])? * 17, + OPAQUE, + ), + _ => return Err(()), + }) + } } #[cfg(feature = "serde")] @@ -134,152 +160,21 @@ impl ToCss for RGBA { where W: fmt::Write, { - let has_alpha = self.alpha.unwrap_or(0.0) != OPAQUE; + let has_alpha = self.alpha != OPAQUE; dest.write_str(if has_alpha { "rgba(" } else { "rgb(" })?; - self.red.unwrap_or(0).to_css(dest)?; + self.red.to_css(dest)?; dest.write_str(", ")?; - self.green.unwrap_or(0).to_css(dest)?; + self.green.to_css(dest)?; dest.write_str(", ")?; - self.blue.unwrap_or(0).to_css(dest)?; + self.blue.to_css(dest)?; - // Legacy syntax does not allow none components. - serialize_alpha(dest, Some(self.alpha.unwrap_or(0.0)), true)?; + serialize_alpha(dest, self.alpha, true)?; dest.write_char(')') } } -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Hsl { - /// The hue component. - pub hue: Option, - /// The saturation component. - pub saturation: Option, - /// The lightness component. - pub lightness: Option, - /// The alpha component. - pub alpha: Option, -} - -impl Hsl { - pub fn new( - hue: Option, - saturation: Option, - lightness: Option, - alpha: Option, - ) -> Self { - Self { - hue, - saturation, - lightness, - alpha, - } - } -} - -impl ToCss for Hsl { - fn to_css(&self, dest: &mut W) -> fmt::Result - where - W: fmt::Write, - { - // HSL serializes to RGB, so we have to convert it. - let (red, green, blue) = hsl_to_rgb( - self.hue.unwrap_or(0.0) / 360.0, - self.saturation.unwrap_or(0.0), - self.lightness.unwrap_or(0.0), - ); - - RGBA::from_floats(Some(red), Some(green), Some(blue), self.alpha).to_css(dest) - } -} - -#[cfg(feature = "serde")] -impl Serialize for Hsl { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - (self.hue, self.saturation, self.lightness, self.alpha).serialize(serializer) - } -} - -#[cfg(feature = "serde")] -impl<'de> Deserialize<'de> for Hsl { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let (lightness, a, b, alpha) = Deserialize::deserialize(deserializer)?; - Ok(Self::new(lightness, a, b, alpha)) - } -} - -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct Hwb { - /// The hue component. - pub hue: Option, - /// The whiteness component. - pub whiteness: Option, - /// The blackness component. - pub blackness: Option, - /// The alpha component. - pub alpha: Option, -} - -impl Hwb { - pub fn new( - hue: Option, - whiteness: Option, - blackness: Option, - alpha: Option, - ) -> Self { - Self { - hue, - whiteness, - blackness, - alpha, - } - } -} - -impl ToCss for Hwb { - fn to_css(&self, dest: &mut W) -> fmt::Result - where - W: fmt::Write, - { - // HWB serializes to RGB, so we have to convert it. - let (red, green, blue) = hwb_to_rgb( - self.hue.unwrap_or(0.0) / 360.0, - self.whiteness.unwrap_or(0.0), - self.blackness.unwrap_or(0.0), - ); - - RGBA::from_floats(Some(red), Some(green), Some(blue), self.alpha).to_css(dest) - } -} - -#[cfg(feature = "serde")] -impl Serialize for Hwb { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - (self.hue, self.whiteness, self.blackness, self.alpha).serialize(serializer) - } -} - -#[cfg(feature = "serde")] -impl<'de> Deserialize<'de> for Hwb { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let (lightness, whiteness, blackness, alpha) = Deserialize::deserialize(deserializer)?; - Ok(Self::new(lightness, whiteness, blackness, alpha)) - } -} - // NOTE: LAB and OKLAB is not declared inside the [impl_lab_like] macro, // because it causes cbindgen to ignore them. @@ -288,13 +183,13 @@ impl<'de> Deserialize<'de> for Hwb { #[repr(C)] pub struct Lab { /// The lightness component. - pub lightness: Option, + pub lightness: f32, /// The a-axis component. - pub a: Option, + pub a: f32, /// The b-axis component. - pub b: Option, + pub b: f32, /// The alpha component. - pub alpha: Option, + pub alpha: f32, } /// Color specified by lightness, a- and b-axis components. @@ -302,25 +197,20 @@ pub struct Lab { #[repr(C)] pub struct Oklab { /// The lightness component. - pub lightness: Option, + pub lightness: f32, /// The a-axis component. - pub a: Option, + pub a: f32, /// The b-axis component. - pub b: Option, + pub b: f32, /// The alpha component. - pub alpha: Option, + pub alpha: f32, } macro_rules! impl_lab_like { ($cls:ident, $fname:literal) => { impl $cls { /// Construct a new Lab color format with lightness, a, b and alpha components. - pub fn new( - lightness: Option, - a: Option, - b: Option, - alpha: Option, - ) -> Self { + pub fn new(lightness: f32, a: f32, b: f32, alpha: f32) -> Self { Self { lightness, a, @@ -358,11 +248,11 @@ macro_rules! impl_lab_like { { dest.write_str($fname)?; dest.write_str("(")?; - serialize_none_or(dest, &self.lightness)?; + self.lightness.to_css(dest)?; dest.write_char(' ')?; - serialize_none_or(dest, &self.a)?; + self.a.to_css(dest)?; dest.write_char(' ')?; - serialize_none_or(dest, &self.b)?; + self.b.to_css(dest)?; serialize_alpha(dest, self.alpha, false)?; dest.write_char(')') } @@ -381,13 +271,13 @@ impl_lab_like!(Oklab, "oklab"); #[repr(C)] pub struct Lch { /// The lightness component. - pub lightness: Option, + pub lightness: f32, /// The chroma component. - pub chroma: Option, + pub chroma: f32, /// The hue component. - pub hue: Option, + pub hue: f32, /// The alpha component. - pub alpha: Option, + pub alpha: f32, } /// Color specified by lightness, chroma and hue components. @@ -395,25 +285,20 @@ pub struct Lch { #[repr(C)] pub struct Oklch { /// The lightness component. - pub lightness: Option, + pub lightness: f32, /// The chroma component. - pub chroma: Option, + pub chroma: f32, /// The hue component. - pub hue: Option, + pub hue: f32, /// The alpha component. - pub alpha: Option, + pub alpha: f32, } macro_rules! impl_lch_like { ($cls:ident, $fname:literal) => { impl $cls { /// Construct a new color with lightness, chroma and hue components. - pub fn new( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self { + pub fn new(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self { Self { lightness, chroma, @@ -451,11 +336,11 @@ macro_rules! impl_lch_like { { dest.write_str($fname)?; dest.write_str("(")?; - serialize_none_or(dest, &self.lightness)?; + self.lightness.to_css(dest)?; dest.write_char(' ')?; - serialize_none_or(dest, &self.chroma)?; + self.chroma.to_css(dest)?; dest.write_char(' ')?; - serialize_none_or(dest, &self.hue)?; + self.hue.to_css(dest)?; serialize_alpha(dest, self.alpha, false)?; dest.write_char(')') } @@ -539,25 +424,19 @@ pub struct ColorFunction { /// The color space for this color. pub color_space: PredefinedColorSpace, /// The first component of the color. Either red or x. - pub c1: Option, + pub c1: f32, /// The second component of the color. Either green or y. - pub c2: Option, + pub c2: f32, /// The third component of the color. Either blue or z. - pub c3: Option, + pub c3: f32, /// The alpha component of the color. - pub alpha: Option, + pub alpha: f32, } impl ColorFunction { /// Construct a new color function definition with the given color space and /// color components. - pub fn new( - color_space: PredefinedColorSpace, - c1: Option, - c2: Option, - c3: Option, - alpha: Option, - ) -> Self { + pub fn new(color_space: PredefinedColorSpace, c1: f32, c2: f32, c3: f32, alpha: f32) -> Self { Self { color_space, c1, @@ -576,11 +455,11 @@ impl ToCss for ColorFunction { dest.write_str("color(")?; self.color_space.to_css(dest)?; dest.write_char(' ')?; - serialize_none_or(dest, &self.c1)?; + self.c1.to_css(dest)?; dest.write_char(' ')?; - serialize_none_or(dest, &self.c2)?; + self.c2.to_css(dest)?; dest.write_char(' ')?; - serialize_none_or(dest, &self.c3)?; + self.c3.to_css(dest)?; serialize_alpha(dest, self.alpha, false)?; @@ -596,10 +475,6 @@ pub enum Color { CurrentColor, /// Specify sRGB colors directly by their red/green/blue/alpha chanels. Rgba(RGBA), - /// Specifies a color in sRGB using hue, saturation and lightness components. - Hsl(Hsl), - /// Specifies a color in sRGB using hue, whiteness and blackness components. - Hwb(Hwb), /// Specifies a CIELAB color by CIE Lightness and its a- and b-axis hue /// coordinates (red/green-ness, and yellow/blue-ness) using the CIE LAB /// rectangular coordinate model. @@ -626,8 +501,6 @@ impl ToCss for Color { match *self { Color::CurrentColor => dest.write_str("currentcolor"), Color::Rgba(rgba) => rgba.to_css(dest), - Color::Hsl(hsl) => hsl.to_css(dest), - Color::Hwb(hwb) => hwb.to_css(dest), Color::Lab(lab) => lab.to_css(dest), Color::Lch(lch) => lch.to_css(dest), Color::Oklab(lab) => lab.to_css(dest), @@ -659,13 +532,6 @@ impl NumberOrPercentage { NumberOrPercentage::Percentage { unit_value } => unit_value, } } - - fn value(&self, percentage_basis: f32) -> f32 { - match *self { - Self::Number { value } => value, - Self::Percentage { unit_value } => unit_value * percentage_basis, - } - } } /// Either an angle or a number. @@ -784,97 +650,30 @@ pub trait FromParsedColor { fn from_current_color() -> Self; /// Construct a new color from red, green, blue and alpha components. - fn from_rgba(red: Option, green: Option, blue: Option, alpha: Option) -> Self; - - /// Construct a new color from hue, saturation, lightness and alpha components. - fn from_hsl( - hue: Option, - saturation: Option, - lightness: Option, - alpha: Option, - ) -> Self; - - /// Construct a new color from hue, blackness, whiteness and alpha components. - fn from_hwb( - hue: Option, - whiteness: Option, - blackness: Option, - alpha: Option, - ) -> Self; + fn from_rgba(red: u8, green: u8, blue: u8, alpha: f32) -> Self; /// Construct a new color from the `lab` notation. - fn from_lab(lightness: Option, a: Option, b: Option, alpha: Option) - -> Self; + fn from_lab(lightness: f32, a: f32, b: f32, alpha: f32) -> Self; /// Construct a new color from the `lch` notation. - fn from_lch( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self; + fn from_lch(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self; /// Construct a new color from the `oklab` notation. - fn from_oklab( - lightness: Option, - a: Option, - b: Option, - alpha: Option, - ) -> Self; + fn from_oklab(lightness: f32, a: f32, b: f32, alpha: f32) -> Self; /// Construct a new color from the `oklch` notation. - fn from_oklch( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self; + fn from_oklch(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self; /// Construct a new color with a predefined color space. fn from_color_function( color_space: PredefinedColorSpace, - c1: Option, - c2: Option, - c3: Option, - alpha: Option, + c1: f32, + c2: f32, + c3: f32, + alpha: f32, ) -> Self; } -/// Parse a color hash, without the leading '#' character. -#[inline] -pub fn parse_hash_color<'i, 't, O>(value: &[u8]) -> Result -where - O: FromParsedColor, -{ - Ok(match value.len() { - 8 => O::from_rgba( - Some(from_hex(value[0])? * 16 + from_hex(value[1])?), - Some(from_hex(value[2])? * 16 + from_hex(value[3])?), - Some(from_hex(value[4])? * 16 + from_hex(value[5])?), - Some((from_hex(value[6])? * 16 + from_hex(value[7])?) as f32 / 255.0), - ), - 6 => O::from_rgba( - Some(from_hex(value[0])? * 16 + from_hex(value[1])?), - Some(from_hex(value[2])? * 16 + from_hex(value[3])?), - Some(from_hex(value[4])? * 16 + from_hex(value[5])?), - Some(OPAQUE), - ), - 4 => O::from_rgba( - Some(from_hex(value[0])? * 17), - Some(from_hex(value[1])? * 17), - Some(from_hex(value[2])? * 17), - Some((from_hex(value[3])? * 17) as f32 / 255.0), - ), - 3 => O::from_rgba( - Some(from_hex(value[0])? * 17), - Some(from_hex(value[1])? * 17), - Some(from_hex(value[2])? * 17), - Some(OPAQUE), - ), - _ => return Err(()), - }) -} - /// Parse a CSS color with the specified [`ColorComponentParser`] and return a /// new color value on success. pub fn parse_color_with<'i, 't, P>( @@ -887,7 +686,8 @@ where let location = input.current_source_location(); let token = input.next()?; match *token { - Token::Hash(ref value) | Token::IDHash(ref value) => parse_hash_color(value.as_bytes()), + Token::Hash(ref value) | Token::IDHash(ref value) => RGBA::parse_hash(value.as_bytes()) + .map(|rgba| P::Output::from_rgba(rgba.red, rgba.green, rgba.blue, rgba.alpha)), Token::Ident(ref value) => parse_color_keyword(&*value), Token::Function(ref name) => { let name = name.clone(); @@ -907,75 +707,37 @@ impl FromParsedColor for Color { } #[inline] - fn from_rgba(red: Option, green: Option, blue: Option, alpha: Option) -> Self { + fn from_rgba(red: u8, green: u8, blue: u8, alpha: f32) -> Self { Color::Rgba(RGBA::new(red, green, blue, alpha)) } - fn from_hsl( - hue: Option, - saturation: Option, - lightness: Option, - alpha: Option, - ) -> Self { - Color::Hsl(Hsl::new(hue, saturation, lightness, alpha)) - } - - fn from_hwb( - hue: Option, - blackness: Option, - whiteness: Option, - alpha: Option, - ) -> Self { - Color::Hwb(Hwb::new(hue, blackness, whiteness, alpha)) - } - #[inline] - fn from_lab( - lightness: Option, - a: Option, - b: Option, - alpha: Option, - ) -> Self { + fn from_lab(lightness: f32, a: f32, b: f32, alpha: f32) -> Self { Color::Lab(Lab::new(lightness, a, b, alpha)) } #[inline] - fn from_lch( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self { + fn from_lch(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self { Color::Lch(Lch::new(lightness, chroma, hue, alpha)) } #[inline] - fn from_oklab( - lightness: Option, - a: Option, - b: Option, - alpha: Option, - ) -> Self { + fn from_oklab(lightness: f32, a: f32, b: f32, alpha: f32) -> Self { Color::Oklab(Oklab::new(lightness, a, b, alpha)) } #[inline] - fn from_oklch( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self { + fn from_oklch(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self { Color::Oklch(Oklch::new(lightness, chroma, hue, alpha)) } #[inline] fn from_color_function( color_space: PredefinedColorSpace, - c1: Option, - c2: Option, - c3: Option, - alpha: Option, + c1: f32, + c2: f32, + c3: f32, + alpha: f32, ) -> Self { Color::ColorFunction(ColorFunction::new(color_space, c1, c2, c3, alpha)) } @@ -1146,10 +908,10 @@ where } match_ignore_ascii_case! { ident , - "transparent" => Ok(Output::from_rgba(Some(0), Some(0), Some(0), Some(0.0))), + "transparent" => Ok(Output::from_rgba(0, 0, 0, 0.0)), "currentcolor" => Ok(Output::from_current_color()), _ => keyword(ident) - .map(|(r, g, b)| Output::from_rgba(Some(*r), Some(*g), Some(*b), Some(1.0))) + .map(|(r, g, b)| Output::from_rgba(*r, *g, *b, 1.0)) .ok_or(()), } } @@ -1183,17 +945,7 @@ fn clamp_unit_f32(val: f32) -> u8 { } fn clamp_floor_256_f32(val: f32) -> u8 { - val.round().clamp(0., 255.) as u8 -} - -fn parse_none_or<'i, 't, F, T, E>(input: &mut Parser<'i, 't>, thing: F) -> Result, E> -where - F: FnOnce(&mut Parser<'i, 't>) -> Result, -{ - match input.try_parse(|p| p.expect_ident_matching("none")) { - Ok(_) => Ok(None), - Err(_) => Ok(Some(thing(input)?)), - } + val.round().max(0.).min(255.) as u8 } /// Parse one of the color functions: rgba(), lab(), color(), etc. @@ -1206,30 +958,67 @@ fn parse_color_function<'i, 't, P>( where P: ColorParser<'i>, { + // FIXME: Should the parser clamp values? or should specified/computed + // value processing handle clamping? + let color = match_ignore_ascii_case! { name, "rgb" | "rgba" => parse_rgb(color_parser, arguments), - "hsl" | "hsla" => parse_hsl(color_parser, arguments), + "hsl" | "hsla" => parse_hsl_hwb( + color_parser, + arguments, + hsl_to_rgb, + /* allow_comma = */ true, + ), - "hwb" => parse_hwb(color_parser, arguments), + "hwb" => parse_hsl_hwb( + color_parser, + arguments, + hwb_to_rgb, + /* allow_comma = */ false, + ), // for L: 0% = 0.0, 100% = 100.0 // for a and b: -100% = -125, 100% = 125 - "lab" => parse_lab_like(color_parser, arguments, 100.0, 125.0, P::Output::from_lab), + "lab" => parse_lab_like( + color_parser, + arguments, + 100.0, + 125.0, + P::Output::from_lab, + ), // for L: 0% = 0.0, 100% = 100.0 // for C: 0% = 0, 100% = 150 - "lch" => parse_lch_like(color_parser, arguments, 100.0, 150.0, P::Output::from_lch), + "lch" => parse_lch_like( + color_parser, + arguments, + 100.0, + 150.0, + P::Output::from_lch, + ), // for L: 0% = 0.0, 100% = 1.0 // for a and b: -100% = -0.4, 100% = 0.4 - "oklab" => parse_lab_like(color_parser, arguments, 1.0, 0.4, P::Output::from_oklab), + "oklab" => parse_lab_like( + color_parser, + arguments, + 1.0, + 0.4, + P::Output::from_oklab, + ), // for L: 0% = 0.0, 100% = 1.0 // for C: 0% = 0.0 100% = 0.4 - "oklch" => parse_lch_like(color_parser, arguments, 1.0, 0.4, P::Output::from_oklch), + "oklch" => parse_lch_like( + color_parser, + arguments, + 1.0, + 0.4, + P::Output::from_oklch, + ), - "color" => parse_color_with_color_space(color_parser, arguments), + "color" => parse_color_color_function(color_parser, arguments), _ => return Err(arguments.new_unexpected_token_error(Token::Ident(name.to_owned().into()))), }?; @@ -1239,52 +1028,30 @@ where Ok(color) } -/// Parse the alpha component by itself from either number or percentage, -/// clipping the result to [0.0..1.0]. #[inline] -fn parse_alpha_component<'i, 't, P>( - color_parser: &P, - arguments: &mut Parser<'i, 't>, -) -> Result> -where - P: ColorParser<'i>, -{ - Ok(color_parser - .parse_number_or_percentage(arguments)? - .unit_value() - .clamp(0.0, OPAQUE)) -} - -fn parse_legacy_alpha<'i, 't, P>( +fn parse_alpha<'i, 't, P>( color_parser: &P, arguments: &mut Parser<'i, 't>, + uses_commas: bool, ) -> Result> where P: ColorParser<'i>, { Ok(if !arguments.is_exhausted() { - arguments.expect_comma()?; - parse_alpha_component(color_parser, arguments)? + if uses_commas { + arguments.expect_comma()?; + } else { + arguments.expect_delim('/')?; + }; + color_parser + .parse_number_or_percentage(arguments)? + .unit_value() + .clamp(0.0, OPAQUE) } else { OPAQUE }) } -fn parse_modern_alpha<'i, 't, P>( - color_parser: &P, - arguments: &mut Parser<'i, 't>, -) -> Result, ParseError<'i, P::Error>> -where - P: ColorParser<'i>, -{ - if !arguments.is_exhausted() { - arguments.expect_delim('/')?; - parse_none_or(arguments, |p| parse_alpha_component(color_parser, p)) - } else { - Ok(Some(OPAQUE)) - } -} - #[inline] fn parse_rgb<'i, 't, P>( color_parser: &P, @@ -1293,121 +1060,77 @@ fn parse_rgb<'i, 't, P>( where P: ColorParser<'i>, { - let maybe_red = parse_none_or(arguments, |p| color_parser.parse_number_or_percentage(p))?; - - // If the first component is not "none" and is followed by a comma, then we - // are parsing the legacy syntax. - let is_legacy_syntax = maybe_red.is_some() && arguments.try_parse(|p| p.expect_comma()).is_ok(); - - let red: Option; - let green: Option; - let blue: Option; - - let alpha = if is_legacy_syntax { - match maybe_red.unwrap() { - NumberOrPercentage::Number { value } => { - red = Some(clamp_floor_256_f32(value)); - green = Some(clamp_floor_256_f32(color_parser.parse_number(arguments)?)); - arguments.expect_comma()?; - blue = Some(clamp_floor_256_f32(color_parser.parse_number(arguments)?)); - } - NumberOrPercentage::Percentage { unit_value } => { - red = Some(clamp_unit_f32(unit_value)); - green = Some(clamp_unit_f32(color_parser.parse_percentage(arguments)?)); - arguments.expect_comma()?; - blue = Some(clamp_unit_f32(color_parser.parse_percentage(arguments)?)); - } - } - - Some(parse_legacy_alpha(color_parser, arguments)?) - } else { - #[inline] - fn get_component_value(c: Option) -> Option { - c.map(|c| match c { - NumberOrPercentage::Number { value } => clamp_floor_256_f32(value), - NumberOrPercentage::Percentage { unit_value } => clamp_unit_f32(unit_value), - }) - } - - red = get_component_value(maybe_red); - - green = get_component_value(parse_none_or(arguments, |p| { - color_parser.parse_number_or_percentage(p) - })?); - - blue = get_component_value(parse_none_or(arguments, |p| { - color_parser.parse_number_or_percentage(p) - })?); - - parse_modern_alpha(color_parser, arguments)? + // Either integers or percentages, but all the same type. + // https://drafts.csswg.org/css-color/#rgb-functions + let (red, is_number) = match color_parser.parse_number_or_percentage(arguments)? { + NumberOrPercentage::Number { value } => (clamp_floor_256_f32(value), true), + NumberOrPercentage::Percentage { unit_value } => (clamp_unit_f32(unit_value), false), }; + let uses_commas = arguments.try_parse(|i| i.expect_comma()).is_ok(); + + let green; + let blue; + if is_number { + green = clamp_floor_256_f32(color_parser.parse_number(arguments)?); + if uses_commas { + arguments.expect_comma()?; + } + blue = clamp_floor_256_f32(color_parser.parse_number(arguments)?); + } else { + green = clamp_unit_f32(color_parser.parse_percentage(arguments)?); + if uses_commas { + arguments.expect_comma()?; + } + blue = clamp_unit_f32(color_parser.parse_percentage(arguments)?); + } + + let alpha = parse_alpha(color_parser, arguments, uses_commas)?; + Ok(P::Output::from_rgba(red, green, blue, alpha)) } -/// Parses hsl syntax. +/// Parses hsl and hbw syntax, which happens to be identical. /// /// https://drafts.csswg.org/css-color/#the-hsl-notation -#[inline] -fn parse_hsl<'i, 't, P>( - color_parser: &P, - arguments: &mut Parser<'i, 't>, -) -> Result> -where - P: ColorParser<'i>, -{ - let maybe_hue = parse_none_or(arguments, |p| color_parser.parse_angle_or_number(p))?; - - // If the hue is not "none" and is followed by a comma, then we are parsing - // the legacy syntax. - let is_legacy_syntax = maybe_hue.is_some() && arguments.try_parse(|p| p.expect_comma()).is_ok(); - - let saturation: Option; - let lightness: Option; - - let alpha = if is_legacy_syntax { - saturation = Some(color_parser.parse_percentage(arguments)?); - arguments.expect_comma()?; - lightness = Some(color_parser.parse_percentage(arguments)?); - Some(parse_legacy_alpha(color_parser, arguments)?) - } else { - saturation = parse_none_or(arguments, |p| color_parser.parse_percentage(p))?; - lightness = parse_none_or(arguments, |p| color_parser.parse_percentage(p))?; - - parse_modern_alpha(color_parser, arguments)? - }; - - let hue = maybe_hue.map(|h| normalize_hue(h.degrees())); - let saturation = saturation.map(|s| s.clamp(0.0, 1.0)); - let lightness = lightness.map(|l| l.clamp(0.0, 1.0)); - - Ok(P::Output::from_hsl(hue, saturation, lightness, alpha)) -} - -/// Parses hwb syntax. -/// /// https://drafts.csswg.org/css-color/#the-hbw-notation #[inline] -fn parse_hwb<'i, 't, P>( +fn parse_hsl_hwb<'i, 't, P>( color_parser: &P, arguments: &mut Parser<'i, 't>, + to_rgb: impl FnOnce(f32, f32, f32) -> (f32, f32, f32), + allow_comma: bool, ) -> Result> where P: ColorParser<'i>, { - let (hue, whiteness, blackness, alpha) = parse_components( - color_parser, - arguments, - P::parse_angle_or_number, - P::parse_percentage, - P::parse_percentage, - )?; + // Hue given as an angle + // https://drafts.csswg.org/css-values/#angles + let hue_degrees = color_parser.parse_angle_or_number(arguments)?.degrees(); - let hue = hue.map(|h| normalize_hue(h.degrees())); - let whiteness = whiteness.map(|w| w.clamp(0.0, 1.0)); - let blackness = blackness.map(|b| b.clamp(0.0, 1.0)); + // Subtract an integer before rounding, to avoid some rounding errors: + let hue_normalized_degrees = hue_degrees - 360. * (hue_degrees / 360.).floor(); + let hue = hue_normalized_degrees / 360.; - Ok(P::Output::from_hwb(hue, whiteness, blackness, alpha)) + // Saturation and lightness are clamped to 0% ... 100% + let uses_commas = allow_comma && arguments.try_parse(|i| i.expect_comma()).is_ok(); + + let first_percentage = color_parser.parse_percentage(arguments)?.clamp(0.0, 1.0); + + if uses_commas { + arguments.expect_comma()?; + } + + let second_percentage = color_parser.parse_percentage(arguments)?.clamp(0.0, 1.0); + + let (red, green, blue) = to_rgb(hue, first_percentage, second_percentage); + let red = clamp_unit_f32(red); + let green = clamp_unit_f32(green); + let blue = clamp_unit_f32(blue); + + let alpha = parse_alpha(color_parser, arguments, uses_commas)?; + + Ok(P::Output::from_rgba(red, green, blue, alpha)) } /// https://drafts.csswg.org/css-color-4/#hwb-to-rgb @@ -1418,7 +1141,6 @@ pub fn hwb_to_rgb(h: f32, w: f32, b: f32) -> (f32, f32, f32) { return (gray, gray, gray); } - // hue is expected in the range [0..1]. let (mut red, mut green, mut blue) = hsl_to_rgb(h, 1.0, 0.5); let x = 1.0 - w - b; red = red * x + w; @@ -1431,8 +1153,6 @@ pub fn hwb_to_rgb(h: f32, w: f32, b: f32) -> (f32, f32, f32) { /// except with h pre-multiplied by 3, to avoid some rounding errors. #[inline] pub fn hsl_to_rgb(hue: f32, saturation: f32, lightness: f32) -> (f32, f32, f32) { - debug_assert!(hue >= 0.0 && hue <= 1.0); - fn hue_to_rgb(m1: f32, m2: f32, mut h3: f32) -> f32 { if h3 < 0. { h3 += 3. @@ -1469,22 +1189,30 @@ fn parse_lab_like<'i, 't, P>( arguments: &mut Parser<'i, 't>, lightness_range: f32, a_b_range: f32, - into_color: fn(l: Option, a: Option, b: Option, alpha: Option) -> P::Output, + into_color: fn(l: f32, a: f32, b: f32, alpha: f32) -> P::Output, ) -> Result> where P: ColorParser<'i>, { - let (lightness, a, b, alpha) = parse_components( - color_parser, - arguments, - P::parse_number_or_percentage, - P::parse_number_or_percentage, - P::parse_number_or_percentage, - )?; + let lightness = match color_parser.parse_number_or_percentage(arguments)? { + NumberOrPercentage::Number { value } => value, + NumberOrPercentage::Percentage { unit_value } => unit_value * lightness_range, + } + .max(0.); - let lightness = lightness.map(|l| l.value(lightness_range).max(0.0)); - let a = a.map(|a| a.value(a_b_range)); - let b = b.map(|b| b.value(a_b_range)); + macro_rules! parse_a_b { + () => {{ + match color_parser.parse_number_or_percentage(arguments)? { + NumberOrPercentage::Number { value } => value, + NumberOrPercentage::Percentage { unit_value } => unit_value * a_b_range, + } + }}; + } + + let a = parse_a_b!(); + let b = parse_a_b!(); + + let alpha = parse_alpha(color_parser, arguments, false)?; Ok(into_color(lightness, a, b, alpha)) } @@ -1495,29 +1223,36 @@ fn parse_lch_like<'i, 't, P>( arguments: &mut Parser<'i, 't>, lightness_range: f32, chroma_range: f32, - into_color: fn(l: Option, c: Option, h: Option, alpha: Option) -> P::Output, + into_color: fn(l: f32, c: f32, h: f32, alpha: f32) -> P::Output, ) -> Result> where P: ColorParser<'i>, { - let (lightness, chroma, hue, alpha) = parse_components( - color_parser, - arguments, - P::parse_number_or_percentage, - P::parse_number_or_percentage, - P::parse_angle_or_number, - )?; + // for L: 0% = 0.0, 100% = 100.0 + let lightness = match color_parser.parse_number_or_percentage(arguments)? { + NumberOrPercentage::Number { value } => value, + NumberOrPercentage::Percentage { unit_value } => unit_value * lightness_range, + } + .max(0.); - let lightness = lightness.map(|l| l.value(lightness_range).max(0.0)); - let chroma = chroma.map(|c| c.value(chroma_range).max(0.0)); - let hue = hue.map(|h| normalize_hue(h.degrees())); + // for C: 0% = 0, 100% = 150 + let chroma = match color_parser.parse_number_or_percentage(arguments)? { + NumberOrPercentage::Number { value } => value, + NumberOrPercentage::Percentage { unit_value } => unit_value * chroma_range, + } + .max(0.); + + let hue_degrees = color_parser.parse_angle_or_number(arguments)?.degrees(); + let hue = hue_degrees - 360. * (hue_degrees / 360.).floor(); + + let alpha = parse_alpha(color_parser, arguments, false)?; Ok(into_color(lightness, chroma, hue, alpha)) } /// Parse the color() function. #[inline] -fn parse_color_with_color_space<'i, 't, P>( +fn parse_color_color_function<'i, 't, P>( color_parser: &P, arguments: &mut Parser<'i, 't>, ) -> Result> @@ -1532,17 +1267,19 @@ where .map_err(|_| location.new_unexpected_token_error(Token::Ident(ident.clone())))? }; - let (c1, c2, c3, alpha) = parse_components( - color_parser, - arguments, - P::parse_number_or_percentage, - P::parse_number_or_percentage, - P::parse_number_or_percentage, - )?; + macro_rules! parse_component { + () => {{ + color_parser + .parse_number_or_percentage(arguments)? + .unit_value() + }}; + } - let c1 = c1.map(|c| c.unit_value()); - let c2 = c2.map(|c| c.unit_value()); - let c3 = c3.map(|c| c.unit_value()); + let c1 = parse_component!(); + let c2 = parse_component!(); + let c3 = parse_component!(); + + let alpha = parse_alpha(color_parser, arguments, false)?; Ok(P::Output::from_color_function( color_space, @@ -1552,26 +1289,3 @@ where alpha, )) } - -/// Parse the color components and alpha with the modern [color-4] syntax. -pub fn parse_components<'i, 't, P, F1, F2, F3, R1, R2, R3>( - color_parser: &P, - input: &mut Parser<'i, 't>, - f1: F1, - f2: F2, - f3: F3, -) -> Result<(Option, Option, Option, Option), ParseError<'i, P::Error>> -where - P: ColorParser<'i>, - F1: FnOnce(&P, &mut Parser<'i, 't>) -> Result>, - F2: FnOnce(&P, &mut Parser<'i, 't>) -> Result>, - F3: FnOnce(&P, &mut Parser<'i, 't>) -> Result>, -{ - let r1 = parse_none_or(input, |p| f1(color_parser, p))?; - let r2 = parse_none_or(input, |p| f2(color_parser, p))?; - let r3 = parse_none_or(input, |p| f3(color_parser, p))?; - - let alpha = parse_modern_alpha(color_parser, input)?; - - Ok((r1, r2, r3, alpha)) -} diff --git a/third_party/rust/cssparser/src/lib.rs b/third_party/rust/cssparser/src/lib.rs index 8c37bdff786a..2a1ec858c7b0 100644 --- a/third_party/rust/cssparser/src/lib.rs +++ b/third_party/rust/cssparser/src/lib.rs @@ -68,8 +68,8 @@ fn parse_border_spacing(_context: &ParserContext, input: &mut Parser) #![recursion_limit = "200"] // For color::parse_color_keyword pub use crate::color::{ - hsl_to_rgb, hwb_to_rgb, parse_color_keyword, parse_color_with, parse_hash_color, AngleOrNumber, - Color, ColorFunction, ColorParser, FromParsedColor, Lab, Lch, NumberOrPercentage, Oklab, Oklch, + hsl_to_rgb, hwb_to_rgb, parse_color_keyword, parse_color_with, AngleOrNumber, Color, + ColorFunction, ColorParser, FromParsedColor, Lab, Lch, NumberOrPercentage, Oklab, Oklch, PredefinedColorSpace, RGBA, }; pub use crate::cow_rc_str::CowRcStr; diff --git a/third_party/rust/cssparser/src/tests.rs b/third_party/rust/cssparser/src/tests.rs index 5e527cbc09df..79b0cb23b787 100644 --- a/third_party/rust/cssparser/src/tests.rs +++ b/third_party/rust/cssparser/src/tests.rs @@ -592,19 +592,19 @@ fn serialize_current_color() { #[test] fn serialize_rgb_full_alpha() { - let c = Color::Rgba(RGBA::new(Some(255), Some(230), Some(204), Some(1.0))); + let c = Color::Rgba(RGBA::new(255, 230, 204, 1.0)); assert_eq!(c.to_css_string(), "rgb(255, 230, 204)"); } #[test] fn serialize_rgba() { - let c = Color::Rgba(RGBA::new(Some(26), Some(51), Some(77), Some(0.125))); + let c = Color::Rgba(RGBA::new(26, 51, 77, 0.125)); assert_eq!(c.to_css_string(), "rgba(26, 51, 77, 0.125)"); } #[test] fn serialize_rgba_two_digit_float_if_roundtrips() { - let c = Color::Rgba(RGBA::from_floats(Some(0.), Some(0.), Some(0.), Some(0.5))); + let c = Color::Rgba(RGBA::from_floats(0., 0., 0., 0.5)); assert_eq!(c.to_css_string(), "rgba(0, 0, 0, 0.5)"); } @@ -900,8 +900,6 @@ impl ToJson for Color { Color::Rgba(ref rgba) => { json!([rgba.red, rgba.green, rgba.blue, rgba.alpha]) } - Color::Hsl(ref c) => json!([c.hue, c.saturation, c.lightness, c.alpha]), - Color::Hwb(ref c) => json!([c.hue, c.whiteness, c.blackness, c.alpha]), Color::Lab(ref c) => json!([c.lightness, c.a, c.b, c.alpha]), Color::Lch(ref c) => json!([c.lightness, c.chroma, c.hue, c.alpha]), Color::Oklab(ref c) => json!([c.lightness, c.a, c.b, c.alpha]), @@ -1518,20 +1516,12 @@ fn generic_parser() { #[derive(Debug, PartialEq)] enum OutputType { CurrentColor, - Rgba(Option, Option, Option, Option), - Hsl(Option, Option, Option, Option), - Hwb(Option, Option, Option, Option), - Lab(Option, Option, Option, Option), - Lch(Option, Option, Option, Option), - Oklab(Option, Option, Option, Option), - Oklch(Option, Option, Option, Option), - ColorFunction( - PredefinedColorSpace, - Option, - Option, - Option, - Option, - ), + Rgba(u8, u8, u8, f32), + Lab(f32, f32, f32, f32), + Lch(f32, f32, f32, f32), + Oklab(f32, f32, f32, f32), + Oklch(f32, f32, f32, f32), + ColorFunction(PredefinedColorSpace, f32, f32, f32, f32), } impl FromParsedColor for OutputType { @@ -1539,124 +1529,102 @@ fn generic_parser() { OutputType::CurrentColor } - fn from_rgba( - red: Option, - green: Option, - blue: Option, - alpha: Option, - ) -> Self { + fn from_rgba(red: u8, green: u8, blue: u8, alpha: f32) -> Self { OutputType::Rgba(red, green, blue, alpha) } - fn from_hsl( - hue: Option, - saturation: Option, - lightness: Option, - alpha: Option, - ) -> Self { - OutputType::Hsl(hue, saturation, lightness, alpha) - } - - fn from_hwb( - hue: Option, - blackness: Option, - whiteness: Option, - alpha: Option, - ) -> Self { - OutputType::Hwb(hue, blackness, whiteness, alpha) - } - - fn from_lab( - lightness: Option, - a: Option, - b: Option, - alpha: Option, - ) -> Self { + fn from_lab(lightness: f32, a: f32, b: f32, alpha: f32) -> Self { OutputType::Lab(lightness, a, b, alpha) } - fn from_lch( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self { + fn from_lch(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self { OutputType::Lch(lightness, chroma, hue, alpha) } - fn from_oklab( - lightness: Option, - a: Option, - b: Option, - alpha: Option, - ) -> Self { + fn from_oklab(lightness: f32, a: f32, b: f32, alpha: f32) -> Self { OutputType::Oklab(lightness, a, b, alpha) } - fn from_oklch( - lightness: Option, - chroma: Option, - hue: Option, - alpha: Option, - ) -> Self { + fn from_oklch(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self { OutputType::Oklch(lightness, chroma, hue, alpha) } fn from_color_function( color_space: PredefinedColorSpace, - c1: Option, - c2: Option, - c3: Option, - alpha: Option, + c1: f32, + c2: f32, + c3: f32, + alpha: f32, ) -> Self { OutputType::ColorFunction(color_space, c1, c2, c3, alpha) } } - struct TestColorParser; - impl<'i> ColorParser<'i> for TestColorParser { + struct ComponentParser; + impl<'i> ColorParser<'i> for ComponentParser { type Output = OutputType; type Error = (); } - #[rustfmt::skip] const TESTS: &[(&str, OutputType)] = &[ - ("currentColor", OutputType::CurrentColor), - ("rgb(1, 2, 3)", OutputType::Rgba(Some(1), Some(2), Some(3), Some(1.0))), - ("rgba(1, 2, 3, 0.4)", OutputType::Rgba(Some(1), Some(2), Some(3), Some(0.4))), - ("rgb(none none none / none)", OutputType::Rgba(None, None, None, None)), - ("rgb(1 none 3 / none)", OutputType::Rgba(Some(1), None, Some(3), None)), - - ("hsla(45deg, 20%, 30%, 0.4)", OutputType::Hsl(Some(45.0), Some(0.2), Some(0.3), Some(0.4))), - ("hsl(45deg none none)", OutputType::Hsl(Some(45.0), None, None, Some(1.0))), - ("hsl(none 10% none / none)", OutputType::Hsl(None, Some(0.1), None, None)), - ("hsl(120 100.0% 50.0%)", OutputType::Hsl(Some(120.0), Some(1.0), Some(0.5), Some(1.0))), - - ("hwb(45deg 20% 30% / 0.4)", OutputType::Hwb(Some(45.0), Some(0.2), Some(0.3), Some(0.4))), - - ("lab(100 20 30 / 0.4)", OutputType::Lab(Some(100.0), Some(20.0), Some(30.0), Some(0.4))), - ("lch(100 20 30 / 0.4)", OutputType::Lch(Some(100.0), Some(20.0), Some(30.0), Some(0.4))), - - ("oklab(100 20 30 / 0.4)", OutputType::Oklab(Some(100.0), Some(20.0), Some(30.0), Some(0.4))), - ("oklch(100 20 30 / 0.4)", OutputType::Oklch(Some(100.0), Some(20.0), Some(30.0), Some(0.4))), - - ("color(srgb 0.1 0.2 0.3 / 0.4)", OutputType::ColorFunction(PredefinedColorSpace::Srgb, Some(0.1), Some(0.2), Some(0.3), Some(0.4))), - ("color(srgb none none none)", OutputType::ColorFunction(PredefinedColorSpace::Srgb, None, None, None, Some(1.0))), - ("color(srgb none none none / none)", OutputType::ColorFunction(PredefinedColorSpace::Srgb, None, None, None, None)), - ("color(srgb-linear 0.1 0.2 0.3 / 0.4)", OutputType::ColorFunction(PredefinedColorSpace::SrgbLinear, Some(0.1), Some(0.2), Some(0.3), Some(0.4))), - ("color(display-p3 0.1 0.2 0.3 / 0.4)", OutputType::ColorFunction(PredefinedColorSpace::DisplayP3, Some(0.1), Some(0.2), Some(0.3), Some(0.4))), - ("color(a98-rgb 0.1 0.2 0.3 / 0.4)", OutputType::ColorFunction(PredefinedColorSpace::A98Rgb, Some(0.1), Some(0.2), Some(0.3), Some(0.4))), - ("color(prophoto-rgb 0.1 0.2 0.3 / 0.4)", OutputType::ColorFunction(PredefinedColorSpace::ProphotoRgb, Some(0.1), Some(0.2), Some(0.3), Some(0.4))), - ("color(rec2020 0.1 0.2 0.3 / 0.4)", OutputType::ColorFunction(PredefinedColorSpace::Rec2020, Some(0.1), Some(0.2), Some(0.3), Some(0.4))), - ("color(xyz-d50 0.1 0.2 0.3 / 0.4)", OutputType::ColorFunction(PredefinedColorSpace::XyzD50, Some(0.1), Some(0.2), Some(0.3), Some(0.4))), - ("color(xyz-d65 0.1 0.2 0.3 / 0.4)", OutputType::ColorFunction(PredefinedColorSpace::XyzD65, Some(0.1), Some(0.2), Some(0.3), Some(0.4))), + ("currentColor", OutputType::CurrentColor), + ("rgb(1, 2, 3)", OutputType::Rgba(1, 2, 3, 1.0)), + ("rgba(1, 2, 3, 0.4)", OutputType::Rgba(1, 2, 3, 0.4)), + ( + "lab(100 20 30 / 0.4)", + OutputType::Lab(100.0, 20.0, 30.0, 0.4), + ), + ( + "lch(100 20 30 / 0.4)", + OutputType::Lch(100.0, 20.0, 30.0, 0.4), + ), + ( + "oklab(100 20 30 / 0.4)", + OutputType::Oklab(100.0, 20.0, 30.0, 0.4), + ), + ( + "oklch(100 20 30 / 0.4)", + OutputType::Oklch(100.0, 20.0, 30.0, 0.4), + ), + ( + "color(srgb 0.1 0.2 0.3 / 0.4)", + OutputType::ColorFunction(PredefinedColorSpace::Srgb, 0.1, 0.2, 0.3, 0.4), + ), + ( + "color(srgb-linear 0.1 0.2 0.3 / 0.4)", + OutputType::ColorFunction(PredefinedColorSpace::SrgbLinear, 0.1, 0.2, 0.3, 0.4), + ), + ( + "color(display-p3 0.1 0.2 0.3 / 0.4)", + OutputType::ColorFunction(PredefinedColorSpace::DisplayP3, 0.1, 0.2, 0.3, 0.4), + ), + ( + "color(a98-rgb 0.1 0.2 0.3 / 0.4)", + OutputType::ColorFunction(PredefinedColorSpace::A98Rgb, 0.1, 0.2, 0.3, 0.4), + ), + ( + "color(prophoto-rgb 0.1 0.2 0.3 / 0.4)", + OutputType::ColorFunction(PredefinedColorSpace::ProphotoRgb, 0.1, 0.2, 0.3, 0.4), + ), + ( + "color(rec2020 0.1 0.2 0.3 / 0.4)", + OutputType::ColorFunction(PredefinedColorSpace::Rec2020, 0.1, 0.2, 0.3, 0.4), + ), + ( + "color(xyz-d50 0.1 0.2 0.3 / 0.4)", + OutputType::ColorFunction(PredefinedColorSpace::XyzD50, 0.1, 0.2, 0.3, 0.4), + ), + ( + "color(xyz-d65 0.1 0.2 0.3 / 0.4)", + OutputType::ColorFunction(PredefinedColorSpace::XyzD65, 0.1, 0.2, 0.3, 0.4), + ), ]; for (input, expected) in TESTS { let mut input = ParserInput::new(*input); let mut input = Parser::new(&mut input); - let actual: OutputType = parse_color_with(&TestColorParser, &mut input).unwrap(); + let actual: OutputType = parse_color_with(&ComponentParser, &mut input).unwrap(); assert_eq!(actual, *expected); } }