diff options
Diffstat (limited to 'components/script/dom/csskeyframerule.rs')
-rw-r--r-- | components/script/dom/csskeyframerule.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/components/script/dom/csskeyframerule.rs b/components/script/dom/csskeyframerule.rs index 78916d339ab..9d245d98343 100644 --- a/components/script/dom/csskeyframerule.rs +++ b/components/script/dom/csskeyframerule.rs @@ -2,11 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding; -use dom::bindings::js::Root; -use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::{self, CSSKeyframeRuleMethods}; +use dom::bindings::js::{JS, MutNullableJS, Root}; +use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::cssrule::{CSSRule, SpecificCSSRule}; +use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner}; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use parking_lot::RwLock; @@ -19,6 +20,7 @@ pub struct CSSKeyframeRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] keyframerule: Arc<RwLock<Keyframe>>, + style_decl: MutNullableJS<CSSStyleDeclaration>, } impl CSSKeyframeRule { @@ -27,6 +29,7 @@ impl CSSKeyframeRule { CSSKeyframeRule { cssrule: CSSRule::new_inherited(parent_stylesheet), keyframerule: keyframerule, + style_decl: Default::default(), } } @@ -39,6 +42,19 @@ impl CSSKeyframeRule { } } +impl CSSKeyframeRuleMethods for CSSKeyframeRule { + // https://drafts.csswg.org/css-animations/#dom-csskeyframerule-style + fn Style(&self) -> Root<CSSStyleDeclaration> { + self.style_decl.or_init(|| { + CSSStyleDeclaration::new(self.global().as_window(), + CSSStyleOwner::CSSRule(JS::from_ref(self.global().as_window()), + self.keyframerule.read().block.clone()), + None, + CSSModificationAccess::ReadWrite) + }) + } +} + impl SpecificCSSRule for CSSKeyframeRule { fn ty(&self) -> u16 { use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants; |