mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Add a style property to HTMLElement.
This commit is contained in:
parent
2cfa8e85a6
commit
2e14b653bf
5 changed files with 62 additions and 9 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue