mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
adding macro to return string or url,
using that macro with the form action, making the form submit process use base url, adding tests.
This commit is contained in:
parent
1ed3521dcf
commit
ce249d9384
6 changed files with 52 additions and 2 deletions
|
@ -123,6 +123,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))|+) => (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue