22 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
5+ // Allow text like <color> in docs.
6+ #![ allow( rustdoc:: invalid_html_tags) ]
7+
58use std:: f32:: consts:: PI ;
69use std:: fmt;
710use std:: str:: FromStr ;
2326 }
2427}
2528
26- /// https://drafts.csswg.org/css-color-4/#serializing-alpha-values
29+ /// < https://drafts.csswg.org/css-color-4/#serializing-alpha-values>
2730#[ inline]
2831fn serialize_alpha (
2932 dest : & mut impl fmt:: Write ,
@@ -53,7 +56,7 @@ fn serialize_alpha(
5356
5457// Guaratees hue in [0..360)
5558fn normalize_hue ( hue : f32 ) -> f32 {
56- // https://drafts.csswg.org/css-values/#angles
59+ // < https://drafts.csswg.org/css-values/#angles>
5760 // Subtract an integer before rounding, to avoid some rounding errors:
5861 hue - 360.0 * ( hue / 360.0 ) . floor ( )
5962}
@@ -466,24 +469,24 @@ impl_lch_like!(Lch, "lch");
466469impl_lch_like ! ( Oklch , "oklch" ) ;
467470
468471/// A Predefined color space specified in:
469- /// https://drafts.csswg.org/css-color-4/#predefined
472+ /// < https://drafts.csswg.org/css-color-4/#predefined>
470473#[ derive( Clone , Copy , PartialEq , Debug ) ]
471474pub enum PredefinedColorSpace {
472- /// https://drafts.csswg.org/css-color-4/#predefined-sRGB
475+ /// < https://drafts.csswg.org/css-color-4/#predefined-sRGB>
473476 Srgb ,
474- /// https://drafts.csswg.org/css-color-4/#predefined-sRGB-linear
477+ /// < https://drafts.csswg.org/css-color-4/#predefined-sRGB-linear>
475478 SrgbLinear ,
476- /// https://drafts.csswg.org/css-color-4/#predefined-display-p3
479+ /// < https://drafts.csswg.org/css-color-4/#predefined-display-p3>
477480 DisplayP3 ,
478- /// https://drafts.csswg.org/css-color-4/#predefined-a98-rgb
481+ /// < https://drafts.csswg.org/css-color-4/#predefined-a98-rgb>
479482 A98Rgb ,
480- /// https://drafts.csswg.org/css-color-4/#predefined-prophoto-rgb
483+ /// < https://drafts.csswg.org/css-color-4/#predefined-prophoto-rgb>
481484 ProphotoRgb ,
482- /// https://drafts.csswg.org/css-color-4/#predefined-rec2020
485+ /// < https://drafts.csswg.org/css-color-4/#predefined-rec2020>
483486 Rec2020 ,
484- /// https://drafts.csswg.org/css-color-4/#predefined-xyz
487+ /// < https://drafts.csswg.org/css-color-4/#predefined-xyz>
485488 XyzD50 ,
486- /// https://drafts.csswg.org/css-color-4/#predefined-xyz
489+ /// < https://drafts.csswg.org/css-color-4/#predefined-xyz>
487490 XyzD65 ,
488491}
489492
@@ -532,7 +535,7 @@ impl ToCss for PredefinedColorSpace {
532535}
533536
534537/// 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>
536539#[ derive( Clone , Copy , PartialEq , Debug ) ]
537540pub struct ColorFunction {
538541 /// The color space for this color.
@@ -593,7 +596,7 @@ impl ToCss for ColorFunction {
593596/// Most components are `Option<_>`, so when the value is `None`, that component
594597/// serializes to the "none" keyword.
595598///
596- /// https://drafts.csswg.org/css-color-4/#color-type
599+ /// < https://drafts.csswg.org/css-color-4/#color-type>
597600#[ derive( Clone , Copy , PartialEq , Debug ) ]
598601pub enum Color {
599602 /// The 'currentcolor' keyword.
@@ -881,8 +884,8 @@ where
881884 } )
882885}
883886
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.
886889pub fn parse_color_with < ' i , ' t , P > (
887890 color_parser : & P ,
888891 input : & mut Parser < ' i , ' t > ,
@@ -1179,12 +1182,12 @@ fn clamp_unit_f32(val: f32) -> u8 {
11791182 // Chrome does something similar for the alpha value, but not
11801183 // the rgb values.
11811184 //
1182- // See https://bugzilla.mozilla.org/show_bug.cgi?id=1340484
1185+ // See < https://bugzilla.mozilla.org/show_bug.cgi?id=1340484>
11831186 //
11841187 // Clamping to 256 and rounding after would let 1.0 map to 256, and
11851188 // `256.0_f32 as u8` is undefined behavior:
11861189 //
1187- // https://github.com/rust-lang/rust/issues/10184
1190+ // < https://github.com/rust-lang/rust/issues/10184>
11881191 clamp_floor_256_f32 ( val * 255. )
11891192}
11901193
@@ -1353,7 +1356,7 @@ where
13531356
13541357/// Parses hsl syntax.
13551358///
1356- /// https://drafts.csswg.org/css-color/#the-hsl-notation
1359+ /// < https://drafts.csswg.org/css-color/#the-hsl-notation>
13571360#[ inline]
13581361fn parse_hsl < ' i , ' t , P > (
13591362 color_parser : & P ,
@@ -1392,7 +1395,7 @@ where
13921395
13931396/// Parses hwb syntax.
13941397///
1395- /// https://drafts.csswg.org/css-color/#the-hbw-notation
1398+ /// < https://drafts.csswg.org/css-color/#the-hbw-notation>
13961399#[ inline]
13971400fn parse_hwb < ' i , ' t , P > (
13981401 color_parser : & P ,
@@ -1416,7 +1419,7 @@ where
14161419 Ok ( P :: Output :: from_hwb ( hue, whiteness, blackness, alpha) )
14171420}
14181421
1419- /// https://drafts.csswg.org/css-color-4/#hwb-to-rgb
1422+ /// < https://drafts.csswg.org/css-color-4/#hwb-to-rgb>
14201423#[ inline]
14211424pub fn hwb_to_rgb ( h : f32 , w : f32 , b : f32 ) -> ( f32 , f32 , f32 ) {
14221425 if w + b >= 1.0 {
@@ -1433,7 +1436,7 @@ pub fn hwb_to_rgb(h: f32, w: f32, b: f32) -> (f32, f32, f32) {
14331436 ( red, green, blue)
14341437}
14351438
1436- /// https://drafts.csswg.org/css-color/#hsl-color
1439+ /// < https://drafts.csswg.org/css-color/#hsl-color>
14371440/// except with h pre-multiplied by 3, to avoid some rounding errors.
14381441#[ inline]
14391442pub fn hsl_to_rgb ( hue : f32 , saturation : f32 , lightness : f32 ) -> ( f32 , f32 , f32 ) {
0 commit comments