Implements case insensitive font family names.

One part (of 8!) of css font family disambiguation is that font families should
be matched case-insensitively.

This patch implements that. Once it lands, a bug needs to be filed to do lowercasing
properly (as a string, instead of char-by-char -- it's a unicode thing).

r? @gw
This commit is contained in:
Clark Gaebel 2014-11-03 16:46:21 -08:00
parent 39960f32e4
commit d22a64884d
7 changed files with 44 additions and 14 deletions

View file

@ -7,6 +7,7 @@ use geometry::Au;
use std::from_str::FromStr;
use std::iter::Filter;
use std::str::{CharEq, CharSplits};
use unicode::char::to_lowercase;
pub type DOMString = String;
pub type StaticCharVec = &'static [char];
@ -184,3 +185,22 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto {
}
#[deriving(Clone, Eq, PartialEq, Hash, Show)]
pub struct LowercaseString {
inner: String,
}
impl LowercaseString {
pub fn new(s: &str) -> LowercaseString {
LowercaseString {
inner: s.chars().map(to_lowercase).collect(),
}
}
}
impl Str for LowercaseString {
#[inline]
fn as_slice(&self) -> &str {
self.inner.as_slice()
}
}