aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/macros.rs')
-rw-r--r--components/script/dom/macros.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index d230bec5404..007abac569d 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -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(