Skip to content

Commit d5230b9

Browse files
committed
Make the serialize_alpha function public as serialize_color_alpha.
1 parent 6ce91af commit d5230b9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/color.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ where
2626
}
2727
}
2828

29+
/// Serialize the alpha copmonent of a color according to the specification.
2930
/// <https://drafts.csswg.org/css-color-4/#serializing-alpha-values>
3031
#[inline]
31-
fn serialize_alpha(
32+
pub fn serialize_color_alpha(
3233
dest: &mut impl fmt::Write,
3334
alpha: Option<f32>,
3435
legacy_syntax: bool,
@@ -146,7 +147,7 @@ impl ToCss for RGBA {
146147
self.blue.unwrap_or(0).to_css(dest)?;
147148

148149
// Legacy syntax does not allow none components.
149-
serialize_alpha(dest, Some(self.alpha.unwrap_or(0.0)), true)?;
150+
serialize_color_alpha(dest, Some(self.alpha.unwrap_or(0.0)), true)?;
150151

151152
dest.write_char(')')
152153
}
@@ -367,7 +368,7 @@ macro_rules! impl_lab_like {
367368
serialize_none_or(dest, &self.a)?;
368369
dest.write_char(' ')?;
369370
serialize_none_or(dest, &self.b)?;
370-
serialize_alpha(dest, self.alpha, false)?;
371+
serialize_color_alpha(dest, self.alpha, false)?;
371372
dest.write_char(')')
372373
}
373374
}
@@ -458,7 +459,7 @@ macro_rules! impl_lch_like {
458459
serialize_none_or(dest, &self.chroma)?;
459460
dest.write_char(' ')?;
460461
serialize_none_or(dest, &self.hue)?;
461-
serialize_alpha(dest, self.alpha, false)?;
462+
serialize_color_alpha(dest, self.alpha, false)?;
462463
dest.write_char(')')
463464
}
464465
}
@@ -584,7 +585,7 @@ impl ToCss for ColorFunction {
584585
dest.write_char(' ')?;
585586
serialize_none_or(dest, &self.c3)?;
586587

587-
serialize_alpha(dest, self.alpha, false)?;
588+
serialize_color_alpha(dest, self.alpha, false)?;
588589

589590
dest.write_char(')')
590591
}

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ fn parse_border_spacing(_context: &ParserContext, input: &mut Parser)
6868
#![recursion_limit = "200"] // For color::parse_color_keyword
6969

7070
pub use crate::color::{
71-
hsl_to_rgb, hwb_to_rgb, parse_color_keyword, parse_color_with, parse_hash_color, AngleOrNumber,
72-
Color, ColorFunction, ColorParser, FromParsedColor, Hsl, Hwb, Lab, Lch, NumberOrPercentage,
73-
Oklab, Oklch, PredefinedColorSpace, RGBA,
71+
hsl_to_rgb, hwb_to_rgb, parse_color_keyword, parse_color_with, parse_hash_color,
72+
serialize_color_alpha, AngleOrNumber, Color, ColorFunction, ColorParser, FromParsedColor, Hsl,
73+
Hwb, Lab, Lch, NumberOrPercentage, Oklab, Oklch, PredefinedColorSpace, RGBA,
7474
};
7575
pub use crate::cow_rc_str::CowRcStr;
7676
pub use crate::from_bytes::{stylesheet_encoding, EncodingSupport};
@@ -84,7 +84,7 @@ pub use crate::parser::{Delimiter, Delimiters, Parser, ParserInput, ParserState}
8484
pub use crate::rules_and_declarations::{parse_important, parse_one_declaration};
8585
pub use crate::rules_and_declarations::{parse_one_rule, StyleSheetParser};
8686
pub use crate::rules_and_declarations::{AtRuleParser, QualifiedRuleParser};
87-
pub use crate::rules_and_declarations::{RuleBodyParser, RuleBodyItemParser, DeclarationParser};
87+
pub use crate::rules_and_declarations::{DeclarationParser, RuleBodyItemParser, RuleBodyParser};
8888
pub use crate::serializer::{serialize_identifier, serialize_name, serialize_string};
8989
pub use crate::serializer::{CssStringWriter, ToCss, TokenSerializationType};
9090
pub use crate::tokenizer::{SourceLocation, SourcePosition, Token};

0 commit comments

Comments
 (0)