aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/macros.rs
diff options
context:
space:
mode:
authorJake Goldsborough <rjgoldsborough@gmail.com>2016-09-20 21:16:51 -0700
committerJake Goldsborough <rjgoldsborough@gmail.com>2016-09-27 09:33:11 -0700
commitce249d9384a613a463781c673b8243658be69891 (patch)
tree6ae0135ea0462dd4cc6209b27d93fe5de586d806 /components/script/dom/macros.rs
parent1ed3521dcfdf573dd68afe18148e785a8af2389a (diff)
downloadservo-ce249d9384a613a463781c673b8243658be69891.tar.gz
servo-ce249d9384a613a463781c673b8243658be69891.zip
adding macro to return string or url,
using that macro with the form action, making the form submit process use base url, adding tests.
Diffstat (limited to 'components/script/dom/macros.rs')
-rw-r--r--components/script/dom/macros.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index 2b29ec8014c..e69255b6aed 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -124,6 +124,26 @@ macro_rules! make_url_or_base_getter(
);
#[macro_export]
+macro_rules! make_string_or_document_url_getter(
+ ( $attr:ident, $htmlname:tt ) => (
+ fn $attr(&self) -> DOMString {
+ use dom::bindings::inheritance::Castable;
+ use dom::element::Element;
+ use dom::node::document_from_node;
+ let element = self.upcast::<Element>();
+ let val = element.get_string_attribute(&atom!($htmlname));
+
+ if val.is_empty() {
+ let doc = document_from_node(self);
+ DOMString::from(doc.url().clone().into_string())
+ } else {
+ val
+ }
+ }
+ );
+);
+
+#[macro_export]
macro_rules! make_enumerated_getter(
( $attr:ident, $htmlname:tt, $default:expr, $(($choices: pat))|+) => (
fn $attr(&self) -> DOMString {