diff options
-rw-r--r-- | components/script/dom/attr.rs | 4 | ||||
-rw-r--r-- | components/script/dom/domtokenlist.rs | 5 | ||||
-rw-r--r-- | components/servo/Cargo.lock | 16 | ||||
-rw-r--r-- | components/util/str.rs | 8 | ||||
-rw-r--r-- | ports/cef/Cargo.lock | 14 | ||||
-rw-r--r-- | ports/gonk/Cargo.lock | 14 | ||||
-rw-r--r-- | tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini | 5 | ||||
-rw-r--r-- | tests/wpt/metadata/dom/nodes/Element-classlist.html.ini | 3 |
8 files changed, 35 insertions, 34 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 0c8e92f7d42..782ab3fd884 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -14,7 +14,7 @@ use dom::window::Window; use dom::virtualmethods::vtable_for; use devtools_traits::AttrInfo; -use util::str::{DOMString, parse_unsigned_integer, split_html_space_chars}; +use util::str::{DOMString, parse_unsigned_integer, split_html_space_chars, str_join}; use string_cache::{Atom, Namespace}; @@ -49,7 +49,7 @@ impl AttrValue { } pub fn from_atomic_tokens(atoms: Vec<Atom>) -> AttrValue { - let tokens = atoms.iter().map(|x| &**x).collect::<Vec<_>>().connect("\x20"); + let tokens = str_join(&atoms, "\x20"); AttrValue::TokenList(tokens, atoms) } diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index b3656ae4b7c..f7a02cdf572 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -13,7 +13,7 @@ use dom::bindings::utils::{Reflector, reflect_dom_object}; use dom::element::{Element, AttributeHandlers}; use dom::node::window_from_node; -use util::str::{DOMString, HTML_SPACE_CHARACTERS}; +use util::str::{DOMString, HTML_SPACE_CHARACTERS, str_join}; use string_cache::Atom; use std::borrow::ToOwned; @@ -157,6 +157,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList { // https://dom.spec.whatwg.org/#stringification-behavior fn Stringifier(self) -> DOMString { - self.element.root().r().get_string_attribute(&self.local_name) + let tokenlist = self.element.root().r().get_tokenlist_attribute(&self.local_name); + str_join(&tokenlist, "\x20") } } diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 0bbe543825d..78236a22a4b 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -437,7 +437,7 @@ dependencies = [ "script_traits 0.0.1", "skia 0.0.20130412 (git+https://github.com/servo/skia)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -561,7 +561,7 @@ dependencies = [ "mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -684,7 +684,7 @@ dependencies = [ "script_traits 0.0.1", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1076,7 +1076,7 @@ dependencies = [ "script_traits 0.0.1", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1120,7 +1120,7 @@ dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quicksort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "string_cache" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1200,7 +1200,7 @@ dependencies = [ "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", @@ -1213,7 +1213,7 @@ dependencies = [ "cssparser 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/util/str.rs b/components/util/str.rs index b82f46598b7..fe6127e1106 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -327,3 +327,11 @@ impl Deref for LowercaseString { pub unsafe fn c_str_to_string(s: *const c_char) -> String { from_utf8(CStr::from_ptr(s).to_bytes()).unwrap().to_owned() } + +pub fn str_join<T: AsRef<str>>(strs: &[T], join: &str) -> String { + strs.iter().fold(String::new(), |mut acc, s| { + if !acc.is_empty() { acc.push_str(join); } + acc.push_str(s.as_ref()); + acc + }) +} diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 9af15d80c30..d79dbf5450b 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ "script_traits 0.0.1", "skia 0.0.20130412 (git+https://github.com/servo/skia)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -553,7 +553,7 @@ dependencies = [ "mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -676,7 +676,7 @@ dependencies = [ "script_traits 0.0.1", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1056,7 +1056,7 @@ dependencies = [ "script_traits 0.0.1", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1092,7 +1092,7 @@ dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quicksort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1155,7 +1155,7 @@ dependencies = [ [[package]] name = "string_cache" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1198,7 +1198,7 @@ dependencies = [ "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 387c69785bf..88eee3bc717 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -415,7 +415,7 @@ dependencies = [ "script_traits 0.0.1", "skia 0.0.20130412 (git+https://github.com/servo/skia)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -487,7 +487,7 @@ dependencies = [ "mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -610,7 +610,7 @@ dependencies = [ "script_traits 0.0.1", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -964,7 +964,7 @@ dependencies = [ "script_traits 0.0.1", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "tendril 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1000,7 +1000,7 @@ dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quicksort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1053,7 +1053,7 @@ dependencies = [ [[package]] name = "string_cache" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1096,7 +1096,7 @@ dependencies = [ "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", diff --git a/tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini b/tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini deleted file mode 100644 index fa87a8bd09b..00000000000 --- a/tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[DOMTokenList-stringifier.html] - type: testharness - [DOMTokenList stringifier] - expected: FAIL - diff --git a/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini b/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini index 2526f96f80b..de405c47bc8 100644 --- a/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini +++ b/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini @@ -3,9 +3,6 @@ [CSS .foo selectors must not match elements without any class] expected: FAIL - [empty classList should return the empty string since the ordered set parser skip the whitespaces] - expected: FAIL - [computed style must update when setting .className] expected: FAIL |