Auto merge of #14576 - canaltinova:keyframes-name, r=Manishearth,emilio

Implement CSSKeyframesRule.name

<!-- Please describe your changes on the following line: -->
Implementation of CSSKeyframesRule.name

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [X] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14576)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-12-14 03:37:45 -08:00 committed by GitHub
commit a2391162a1
3 changed files with 41 additions and 5 deletions

View file

@ -5,6 +5,7 @@
use cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods;
use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{MutNullableJS, Root};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
@ -15,6 +16,7 @@ use dom::cssrulelist::{CSSRuleList, RulesSource};
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use parking_lot::RwLock;
use servo_atoms::Atom;
use std::sync::Arc;
use style::keyframes::{Keyframe, KeyframeSelector};
use style::parser::ParserContextExtraData;
@ -101,6 +103,27 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule {
self.rulelist().item(idx as u32)
}).and_then(Root::downcast)
}
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-name
fn Name(&self) -> DOMString {
DOMString::from(&*self.keyframesrule.read().name)
}
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-name
fn SetName(&self, value: DOMString) -> ErrorResult {
// https://github.com/w3c/csswg-drafts/issues/801
// Setting this property to a CSS-wide keyword or `none` will
// throw a Syntax Error.
match_ignore_ascii_case! { value,
"initial" => return Err(Error::Syntax),
"inherit" => return Err(Error::Syntax),
"unset" => return Err(Error::Syntax),
"none" => return Err(Error::Syntax),
_ => ()
}
self.keyframesrule.write().name = Atom::from(value);
Ok(())
}
}
impl SpecificCSSRule for CSSKeyframesRule {

View file

@ -5,7 +5,8 @@
// https://drafts.csswg.org/css-animations/#interface-csskeyframesrule
[Exposed=Window]
interface CSSKeyframesRule : CSSRule {
// attribute DOMString name;
[SetterThrows]
attribute DOMString name;
readonly attribute CSSRuleList cssRules;
void appendRule(DOMString rule);