aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/gecko_string_cache/mod.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-04-25 10:44:10 +0200
committerSimon Sapin <simon.sapin@exyr.org>2017-04-26 13:04:27 +0900
commit0ff64bdc59e75c4fa16927db5cc8797bf60f9a36 (patch)
treed4312e064b4a99df6b8b08ec6081f642f2a8ea0f /components/style/gecko_string_cache/mod.rs
parent11469218661fe3076b255eba35c2b0736dcce500 (diff)
downloadservo-0ff64bdc59e75c4fa16927db5cc8797bf60f9a36.tar.gz
servo-0ff64bdc59e75c4fa16927db5cc8797bf60f9a36.zip
Allow 'decimal' and 'none' in `<counter-style-name>`
… other than in `@counter-style`.
Diffstat (limited to 'components/style/gecko_string_cache/mod.rs')
-rw-r--r--components/style/gecko_string_cache/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs
index b612c027c45..63ba6d7977c 100644
--- a/components/style/gecko_string_cache/mod.rs
+++ b/components/style/gecko_string_cache/mod.rs
@@ -13,6 +13,7 @@ use gecko_bindings::bindings::Gecko_ReleaseAtom;
use gecko_bindings::structs::nsIAtom;
use nsstring::nsAString;
use precomputed_hash::PrecomputedHash;
+use std::ascii::AsciiExt;
use std::borrow::{Cow, Borrow};
use std::char::{self, DecodeUtf16};
use std::fmt::{self, Write};
@@ -224,6 +225,25 @@ impl Atom {
Atom(WeakAtom::new(ptr))
}
}
+
+ /// Return whether two atoms are ASCII-case-insensitive matches
+ pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool {
+ let a = self.as_slice();
+ let b = other.as_slice();
+ a.len() == b.len() && a.iter().zip(b).all(|(&a16, &b16)| {
+ if a16 <= 0x7F && b16 <= 0x7F {
+ (a16 as u8).eq_ignore_ascii_case(&(b16 as u8))
+ } else {
+ a16 == b16
+ }
+ })
+ }
+
+ /// Return whether this atom is an ASCII-case-insensitive match for the given string
+ pub fn eq_str_ignore_ascii_case(&self, other: &str) -> bool {
+ self.chars().map(|r| r.map(|c: char| c.to_ascii_lowercase()))
+ .eq(other.chars().map(|c: char| Ok(c.to_ascii_lowercase())))
+ }
}
impl Hash for Atom {