aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorAlan Jeffrey <ajeffrey@mozilla.com>2017-07-25 15:59:00 -0500
committerAlan Jeffrey <ajeffrey@mozilla.com>2017-07-25 15:59:00 -0500
commit7e6fd297ff44e1fb34c5278492075a5a80e66e93 (patch)
treeb0e15eec52254fa19ebe0efade9fb44af02c5699 /components/script
parente825bf14427c6aab239a82e09d0915467f23aa60 (diff)
downloadservo-7e6fd297ff44e1fb34c5278492075a5a80e66e93.tar.gz
servo-7e6fd297ff44e1fb34c5278492075a5a80e66e93.zip
Implement getProperties for StylePropertyMap.
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/stylepropertymapreadonly.rs26
-rw-r--r--components/script/dom/webidls/StylePropertyMapReadOnly.webidl3
2 files changed, 28 insertions, 1 deletions
diff --git a/components/script/dom/stylepropertymapreadonly.rs b/components/script/dom/stylepropertymapreadonly.rs
index 323f5dae5a9..38632f3e6e9 100644
--- a/components/script/dom/stylepropertymapreadonly.rs
+++ b/components/script/dom/stylepropertymapreadonly.rs
@@ -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
+ }
}
diff --git a/components/script/dom/webidls/StylePropertyMapReadOnly.webidl b/components/script/dom/webidls/StylePropertyMapReadOnly.webidl
index 7557a0d6071..360e3af909d 100644
--- a/components/script/dom/webidls/StylePropertyMapReadOnly.webidl
+++ b/components/script/dom/webidls/StylePropertyMapReadOnly.webidl
@@ -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;
};