mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #6555 - frewsxcv:stringify-tokenlist, r=Ms2ger
Join tokens when stringifying DOMTokenList <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6555) <!-- Reviewable:end -->
This commit is contained in:
commit
d64f91863a
8 changed files with 35 additions and 34 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
16
components/servo/Cargo.lock
generated
16
components/servo/Cargo.lock
generated
|
@ -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)",
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
14
ports/cef/Cargo.lock
generated
14
ports/cef/Cargo.lock
generated
|
@ -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",
|
||||
|
|
14
ports/gonk/Cargo.lock
generated
14
ports/gonk/Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[DOMTokenList-stringifier.html]
|
||||
type: testharness
|
||||
[DOMTokenList stringifier]
|
||||
expected: FAIL
|
||||
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue