aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-09-16 22:58:52 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-10-10 17:02:27 -0700
commit2a790d06dd74b1de0c47d433c7fa3a9d8af03efc (patch)
tree83346e183c3bf7ef3d8d4edf554667bc263e73c4 /components/script/dom
parent878ece58da7f60b45e9230356ac7a5bbf7351e5b (diff)
downloadservo-2a790d06dd74b1de0c47d433c7fa3a9d8af03efc.tar.gz
servo-2a790d06dd74b1de0c47d433c7fa3a9d8af03efc.zip
Use Gecko's simpler Bloom filter instead of one based on hash
stretching. This preserves the usage of the Bloom filter throughout style recalc, but the implementation is rewritten. Provides a 15% improvement on Guardians of the Galaxy.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/element.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index ce1371f74ef..ef5ec630670 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -38,6 +38,7 @@ use std::ascii::StrAsciiExt;
use std::cell::RefCell;
use std::default::Default;
use std::mem;
+use std::slice::Items;
use string_cache::{Atom, Namespace};
use url::UrlParser;
@@ -172,6 +173,7 @@ pub trait RawLayoutElementHelpers {
unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &str) -> Vec<&'a str>;
unsafe fn get_attr_atom_for_layout(&self, namespace: &Namespace, name: &str) -> Option<Atom>;
unsafe fn has_class_for_layout(&self, name: &str) -> bool;
+ unsafe fn get_classes_for_layout<'a>(&'a self) -> Option<Items<'a,Atom>>;
}
impl RawLayoutElementHelpers for Element {
@@ -234,6 +236,19 @@ impl RawLayoutElementHelpers for Element {
(*attr).value_tokens_forever().map(|mut tokens| { tokens.any(|atom| atom.as_slice() == name) })
}.take().unwrap())
}
+
+ #[inline]
+ #[allow(unrooted_must_root)]
+ unsafe fn get_classes_for_layout<'a>(&'a self) -> Option<Items<'a,Atom>> {
+ let attrs: *const Vec<JS<Attr>> = mem::transmute(&self.attrs);
+ (*attrs).iter().find(|attr: & &JS<Attr>| {
+ let attr = attr.unsafe_get();
+ (*attr).local_name_atom_forever().as_slice() == "class"
+ }).and_then(|attr| {
+ let attr = attr.unsafe_get();
+ (*attr).value_tokens_forever()
+ })
+ }
}
pub trait LayoutElementHelpers {
@@ -1052,4 +1067,19 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
has_class(self, name)
}
+ fn each_class(self, callback: |&Atom|) {
+ match self.get_attribute(ns!(""), "class").root() {
+ None => {}
+ Some(attr) => {
+ match attr.deref().value().tokens() {
+ None => {}
+ Some(mut tokens) => {
+ for token in tokens {
+ callback(token)
+ }
+ }
+ }
+ }
+ }
+ }
}