mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Optimize serialization of identifiers of length <= 16 🐉🐲
Much like we optimize to_ascii_lowercase. This also fixes a bug in Servo where attr() rules with an unknown namespace prefix are parsed, which is wrong.
This commit is contained in:
parent
e57319a734
commit
f4c9c598a3
13 changed files with 96 additions and 65 deletions
|
@ -33,6 +33,25 @@ define_keyword_type!(None_, "none");
|
|||
define_keyword_type!(Auto, "auto");
|
||||
define_keyword_type!(Normal, "normal");
|
||||
|
||||
/// Serialize an identifier which is represented as an atom.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn serialize_atom_identifier<W>(ident: &Atom, dest: &mut W) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
ident.with_str(|s| serialize_identifier(s, dest))
|
||||
}
|
||||
|
||||
/// Serialize an identifier which is represented as an atom.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn serialize_atom_identifier<Static, W>(ident: &::string_cache::Atom<Static>, dest: &mut W) -> fmt::Result
|
||||
where
|
||||
Static: ::string_cache::StaticAtomSet,
|
||||
W: Write,
|
||||
{
|
||||
serialize_identifier(&ident, dest)
|
||||
}
|
||||
|
||||
/// Serialize a normalized value into percentage.
|
||||
pub fn serialize_percentage<W>(value: CSSFloat, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
@ -114,7 +133,7 @@ impl ToCss for CustomIdent {
|
|||
where
|
||||
W: Write,
|
||||
{
|
||||
serialize_identifier(&self.0.to_string(), dest)
|
||||
serialize_atom_identifier(&self.0, dest)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue