1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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::AttrBinding;
use dom::bindings::utils::{Reflectable, Reflector, DOMString};
use dom::bindings::utils::reflect_dom_object;
use dom::namespace::{Namespace, Null};
use dom::window::Window;
pub struct Attr {
reflector_: Reflector,
local_name: DOMString,
value: DOMString,
name: DOMString,
namespace: Namespace,
prefix: Option<DOMString>
}
impl Reflectable for Attr {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
&mut self.reflector_
}
}
impl Attr {
fn new_inherited(local_name: DOMString, value: DOMString,
name: DOMString, namespace: Namespace,
prefix: Option<DOMString>) -> Attr {
Attr {
reflector_: Reflector::new(),
local_name: local_name,
value: value,
name: name, //TODO: Intern attribute names
namespace: namespace,
prefix: prefix
}
}
pub fn new(window: &Window, local_name: DOMString, value: DOMString) -> @mut Attr {
let name = local_name.clone();
Attr::new_helper(window, local_name, value, name, Null, None)
}
pub fn new_ns(window: &Window, local_name: DOMString, value: DOMString,
name: DOMString, namespace: Namespace,
prefix: Option<DOMString>) -> @mut Attr {
Attr::new_helper(window, name, value, local_name, namespace, prefix)
}
fn new_helper(window: &Window, name: DOMString, value: DOMString, local_name: DOMString,
namespace: Namespace, prefix: Option<DOMString>) -> @mut Attr {
let attr = Attr::new_inherited(name, value, local_name, namespace, prefix);
reflect_dom_object(@mut attr, window, AttrBinding::Wrap)
}
pub fn LocalName(&self) -> DOMString {
self.local_name.clone()
}
pub fn Value(&self) -> DOMString {
self.value.clone()
}
pub fn SetValue(&mut self, value: &DOMString) {
self.value = value.clone();
}
pub fn Name(&self) -> DOMString {
self.name.clone()
}
pub fn GetNamespaceURI(&self) -> Option<DOMString> {
self.namespace.to_str()
}
pub fn GetPrefix(&self) -> Option<DOMString> {
self.prefix.clone()
}
}
|