Add Dimension member to AttrValue

Fixes #8417
This commit is contained in:
Corey Farwell 2015-11-09 18:17:14 -05:00
parent f39faaf994
commit 73314ab10c
3 changed files with 37 additions and 3 deletions

View file

@ -230,6 +230,21 @@ macro_rules! make_legacy_color_setter(
);
);
#[macro_export]
macro_rules! make_dimension_setter(
( $attr:ident, $htmlname:expr ) => (
fn $attr(&self, value: DOMString) {
use dom::bindings::inheritance::Castable;
use dom::element::Element;
use string_cache::Atom;
let element = self.upcast::<Element>();
let value = AttrValue::parse_dimension(value);
// FIXME(pcwalton): Do this at compile time, not at runtime.
element.set_attribute(&Atom::from_slice($htmlname), value)
}
);
);
/// For use on non-jsmanaged types
/// Use #[derive(JSTraceable)] on JS managed types
macro_rules! no_jsmanaged_fields(