2
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
+ // Allow text like <color> in docs.
6
+ #![ allow( rustdoc:: invalid_html_tags) ]
7
+
5
8
use std:: f32:: consts:: PI ;
6
9
use std:: fmt;
7
10
use std:: str:: FromStr ;
23
26
}
24
27
}
25
28
26
- /// https://drafts.csswg.org/css-color-4/#serializing-alpha-values
29
+ /// < https://drafts.csswg.org/css-color-4/#serializing-alpha-values>
27
30
#[ inline]
28
31
fn serialize_alpha (
29
32
dest : & mut impl fmt:: Write ,
@@ -53,7 +56,7 @@ fn serialize_alpha(
53
56
54
57
// Guaratees hue in [0..360)
55
58
fn normalize_hue ( hue : f32 ) -> f32 {
56
- // https://drafts.csswg.org/css-values/#angles
59
+ // < https://drafts.csswg.org/css-values/#angles>
57
60
// Subtract an integer before rounding, to avoid some rounding errors:
58
61
hue - 360.0 * ( hue / 360.0 ) . floor ( )
59
62
}
@@ -466,24 +469,24 @@ impl_lch_like!(Lch, "lch");
466
469
impl_lch_like ! ( Oklch , "oklch" ) ;
467
470
468
471
/// A Predefined color space specified in:
469
- /// https://drafts.csswg.org/css-color-4/#predefined
472
+ /// < https://drafts.csswg.org/css-color-4/#predefined>
470
473
#[ derive( Clone , Copy , PartialEq , Debug ) ]
471
474
pub enum PredefinedColorSpace {
472
- /// https://drafts.csswg.org/css-color-4/#predefined-sRGB
475
+ /// < https://drafts.csswg.org/css-color-4/#predefined-sRGB>
473
476
Srgb ,
474
- /// https://drafts.csswg.org/css-color-4/#predefined-sRGB-linear
477
+ /// < https://drafts.csswg.org/css-color-4/#predefined-sRGB-linear>
475
478
SrgbLinear ,
476
- /// https://drafts.csswg.org/css-color-4/#predefined-display-p3
479
+ /// < https://drafts.csswg.org/css-color-4/#predefined-display-p3>
477
480
DisplayP3 ,
478
- /// https://drafts.csswg.org/css-color-4/#predefined-a98-rgb
481
+ /// < https://drafts.csswg.org/css-color-4/#predefined-a98-rgb>
479
482
A98Rgb ,
480
- /// https://drafts.csswg.org/css-color-4/#predefined-prophoto-rgb
483
+ /// < https://drafts.csswg.org/css-color-4/#predefined-prophoto-rgb>
481
484
ProphotoRgb ,
482
- /// https://drafts.csswg.org/css-color-4/#predefined-rec2020
485
+ /// < https://drafts.csswg.org/css-color-4/#predefined-rec2020>
483
486
Rec2020 ,
484
- /// https://drafts.csswg.org/css-color-4/#predefined-xyz
487
+ /// < https://drafts.csswg.org/css-color-4/#predefined-xyz>
485
488
XyzD50 ,
486
- /// https://drafts.csswg.org/css-color-4/#predefined-xyz
489
+ /// < https://drafts.csswg.org/css-color-4/#predefined-xyz>
487
490
XyzD65 ,
488
491
}
489
492
@@ -532,7 +535,7 @@ impl ToCss for PredefinedColorSpace {
532
535
}
533
536
534
537
/// A color specified by the color() function.
535
- /// https://drafts.csswg.org/css-color-4/#color-function
538
+ /// < https://drafts.csswg.org/css-color-4/#color-function>
536
539
#[ derive( Clone , Copy , PartialEq , Debug ) ]
537
540
pub struct ColorFunction {
538
541
/// The color space for this color.
@@ -593,7 +596,7 @@ impl ToCss for ColorFunction {
593
596
/// Most components are `Option<_>`, so when the value is `None`, that component
594
597
/// serializes to the "none" keyword.
595
598
///
596
- /// https://drafts.csswg.org/css-color-4/#color-type
599
+ /// < https://drafts.csswg.org/css-color-4/#color-type>
597
600
#[ derive( Clone , Copy , PartialEq , Debug ) ]
598
601
pub enum Color {
599
602
/// The 'currentcolor' keyword.
@@ -881,8 +884,8 @@ where
881
884
} )
882
885
}
883
886
884
- /// Parse a CSS color with the specified [`ColorComponentParser `] and return a
885
- /// new color value on success.
887
+ /// Parse a CSS color using the specified [`ColorParser `] and return a new color
888
+ /// value on success.
886
889
pub fn parse_color_with < ' i , ' t , P > (
887
890
color_parser : & P ,
888
891
input : & mut Parser < ' i , ' t > ,
@@ -1179,12 +1182,12 @@ fn clamp_unit_f32(val: f32) -> u8 {
1179
1182
// Chrome does something similar for the alpha value, but not
1180
1183
// the rgb values.
1181
1184
//
1182
- // See https://bugzilla.mozilla.org/show_bug.cgi?id=1340484
1185
+ // See < https://bugzilla.mozilla.org/show_bug.cgi?id=1340484>
1183
1186
//
1184
1187
// Clamping to 256 and rounding after would let 1.0 map to 256, and
1185
1188
// `256.0_f32 as u8` is undefined behavior:
1186
1189
//
1187
- // https://github.com/rust-lang/rust/issues/10184
1190
+ // < https://github.com/rust-lang/rust/issues/10184>
1188
1191
clamp_floor_256_f32 ( val * 255. )
1189
1192
}
1190
1193
@@ -1353,7 +1356,7 @@ where
1353
1356
1354
1357
/// Parses hsl syntax.
1355
1358
///
1356
- /// https://drafts.csswg.org/css-color/#the-hsl-notation
1359
+ /// < https://drafts.csswg.org/css-color/#the-hsl-notation>
1357
1360
#[ inline]
1358
1361
fn parse_hsl < ' i , ' t , P > (
1359
1362
color_parser : & P ,
@@ -1392,7 +1395,7 @@ where
1392
1395
1393
1396
/// Parses hwb syntax.
1394
1397
///
1395
- /// https://drafts.csswg.org/css-color/#the-hbw-notation
1398
+ /// < https://drafts.csswg.org/css-color/#the-hbw-notation>
1396
1399
#[ inline]
1397
1400
fn parse_hwb < ' i , ' t , P > (
1398
1401
color_parser : & P ,
@@ -1416,7 +1419,7 @@ where
1416
1419
Ok ( P :: Output :: from_hwb ( hue, whiteness, blackness, alpha) )
1417
1420
}
1418
1421
1419
- /// https://drafts.csswg.org/css-color-4/#hwb-to-rgb
1422
+ /// < https://drafts.csswg.org/css-color-4/#hwb-to-rgb>
1420
1423
#[ inline]
1421
1424
pub fn hwb_to_rgb ( h : f32 , w : f32 , b : f32 ) -> ( f32 , f32 , f32 ) {
1422
1425
if w + b >= 1.0 {
@@ -1433,7 +1436,7 @@ pub fn hwb_to_rgb(h: f32, w: f32, b: f32) -> (f32, f32, f32) {
1433
1436
( red, green, blue)
1434
1437
}
1435
1438
1436
- /// https://drafts.csswg.org/css-color/#hsl-color
1439
+ /// < https://drafts.csswg.org/css-color/#hsl-color>
1437
1440
/// except with h pre-multiplied by 3, to avoid some rounding errors.
1438
1441
#[ inline]
1439
1442
pub fn hsl_to_rgb ( hue : f32 , saturation : f32 , lightness : f32 ) -> ( f32 , f32 , f32 ) {
0 commit comments