diff options
author | Josh Matthews <josh@joshmatthews.net> | 2014-09-18 15:34:55 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2014-12-18 12:54:02 -0500 |
commit | 2e14b653bf3fd1e43d099fee6e404c2cc562ffac (patch) | |
tree | 38fbddbe4dfc28c0f3a57f9dcafed7f3137dedfc /components/script/dom/css2properties.rs | |
parent | 2cfa8e85a69cf04fa97b1e5792a9e0d8eb7f30b6 (diff) | |
download | servo-2e14b653bf3fd1e43d099fee6e404c2cc562ffac.tar.gz servo-2e14b653bf3fd1e43d099fee6e404c2cc562ffac.zip |
Add a style property to HTMLElement.
Diffstat (limited to 'components/script/dom/css2properties.rs')
-rw-r--r-- | components/script/dom/css2properties.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/components/script/dom/css2properties.rs b/components/script/dom/css2properties.rs index db1787f42a3..cafb721e6ac 100644 --- a/components/script/dom/css2properties.rs +++ b/components/script/dom/css2properties.rs @@ -2,17 +2,20 @@ * 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::CSS2PropertiesBinding; use dom::bindings::codegen::Bindings::CSS2PropertiesBinding::CSS2PropertiesMethods; use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use dom::bindings::codegen::InheritTypes::CSSStyleDeclarationCast; -use dom::bindings::utils::{Reflectable, Reflector}; -use dom::bindings::js::JSRef; +use dom::bindings::global; +use dom::bindings::js::{JSRef, Temporary}; +use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::cssstyledeclaration::CSSStyleDeclaration; +use dom::window::Window; use servo_util::str::DOMString; #[dom_struct] pub struct CSS2Properties { - declaration: CSSStyleDeclaration, + cssstyledeclaration: CSSStyleDeclaration, } macro_rules! css_getter( @@ -33,6 +36,20 @@ macro_rules! css_setter( ); ) +impl CSS2Properties { + fn new_inherited() -> CSS2Properties { + CSS2Properties { + cssstyledeclaration: CSSStyleDeclaration::new_inherited(), + } + } + + pub fn new(global: &JSRef<Window>) -> Temporary<CSS2Properties> { + reflect_dom_object(box CSS2Properties::new_inherited(), + global::Window(*global), + CSS2PropertiesBinding::Wrap) + } +} + impl<'a> CSS2PropertiesMethods for JSRef<'a, CSS2Properties> { css_getter!(Color, "color") css_setter!(SetColor, "color") @@ -72,6 +89,6 @@ impl<'a> CSS2PropertiesMethods for JSRef<'a, CSS2Properties> { impl Reflectable for CSS2Properties { fn reflector<'a>(&'a self) -> &'a Reflector { - self.declaration.reflector() + self.cssstyledeclaration.reflector() } } |