mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Implement getProperties for StylePropertyMap.
This commit is contained in:
parent
e825bf1442
commit
7e6fd297ff
5 changed files with 31 additions and 4 deletions
|
@ -13,6 +13,7 @@ use dom::cssstylevalue::CSSStyleValue;
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_atoms::Atom;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
use std::iter::Iterator;
|
||||
|
||||
|
@ -63,4 +64,29 @@ impl StylePropertyMapReadOnlyMethods for StylePropertyMapReadOnly {
|
|||
// TODO: avoid constructing an Atom
|
||||
self.entries.contains_key(&Atom::from(property))
|
||||
}
|
||||
|
||||
/// https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymapreadonly-getproperties
|
||||
fn GetProperties(&self) -> Vec<DOMString> {
|
||||
let mut result: Vec<DOMString> = self.entries.keys()
|
||||
.map(|key| DOMString::from(&**key))
|
||||
.collect();
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-getproperties
|
||||
// requires this sort order
|
||||
result.sort_by(|key1, key2| {
|
||||
if key1.starts_with("-") {
|
||||
if key2.starts_with("-") {
|
||||
key1.cmp(key2)
|
||||
} else {
|
||||
Ordering::Greater
|
||||
}
|
||||
} else {
|
||||
if key2.starts_with("-") {
|
||||
Ordering::Less
|
||||
} else {
|
||||
key1.cmp(key2)
|
||||
}
|
||||
}
|
||||
});
|
||||
result
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ interface StylePropertyMapReadOnly {
|
|||
// sequence<CSSStyleValue> getAll(DOMString property);
|
||||
boolean has(DOMString property);
|
||||
// iterable<DOMString, (CSSStyleValue or sequence<CSSStyleValue>)>;
|
||||
// sequence<DOMString> getProperties();
|
||||
sequence<DOMString> getProperties();
|
||||
// https://github.com/w3c/css-houdini-drafts/issues/268
|
||||
// stringifier;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[style-background-image.html]
|
||||
type: reftest
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/17579
|
||||
bug: https://github.com/servo/servo/issues/17378
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[style-before-pseudo.html]
|
||||
type: reftest
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/17579
|
||||
bug: https://github.com/servo/servo/issues/17854
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[style-first-letter-pseudo.html]
|
||||
type: reftest
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/17579
|
||||
bug: https://github.com/servo/servo/issues/17854
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue