Introduce enums for identifying CSS properties.

* `LonghandId` and `ShorthandId` are C-like enums
* `Atom` is used for the name of custom properties.
* `PropertyDeclarationId` is the identifier for `PropertyDeclaration`,
  after parsing and shorthand expansion. (Longhand or custom property.)
* `PropertyId` represents any CSS property, e.g. in CSSOM.
  (Longhand, shorthand, or custom.)

Using these instead of strings avoids some memory allocations and copies.
This commit is contained in:
Simon Sapin 2016-10-10 16:00:28 +02:00
parent 97344b150d
commit 137e30b825
10 changed files with 334 additions and 278 deletions

View file

@ -286,6 +286,12 @@ impl Into<Vec<u8>> for DOMString {
}
}
impl<'a> Into<Cow<'a, str>> for DOMString {
fn into(self) -> Cow<'a, str> {
self.0.into()
}
}
impl Extend<char> for DOMString {
fn extend<I>(&mut self, iterable: I) where I: IntoIterator<Item=char> {
self.0.extend(iterable)