auto merge of #1439 : Ms2ger/servo/reflection-methods, r=jdm

This commit is contained in:
bors-servo 2014-01-01 13:19:16 -08:00
commit 2b487ed3e9
3 changed files with 29 additions and 16 deletions

View file

@ -280,20 +280,40 @@ impl<'self> Element {
} }
} }
// http://www.whatwg.org/html/#reflecting-content-attributes-in-idl-attributes
impl Element {
pub fn get_url_attribute(&self, name: &str) -> DOMString {
// XXX Resolve URL.
self.get_string_attribute(name)
}
pub fn set_url_attribute(&mut self, abstract_self: AbstractNode,
name: &str, value: DOMString) {
self.set_string_attribute(abstract_self, name, value);
}
pub fn get_string_attribute(&self, name: &str) -> DOMString {
match self.get_attr(Null, name) {
Some(x) => x,
None => ~""
}
}
pub fn set_string_attribute(&mut self, abstract_self: AbstractNode,
name: &str, value: DOMString) {
self.set_attribute(abstract_self, Null, name.to_owned(), value);
}
}
impl Element { impl Element {
pub fn TagName(&self) -> DOMString { pub fn TagName(&self) -> DOMString {
self.tag_name.to_ascii_upper() self.tag_name.to_ascii_upper()
} }
pub fn Id(&self, _abstract_self: AbstractNode) -> DOMString { pub fn Id(&self, _abstract_self: AbstractNode) -> DOMString {
match self.get_attr(Null, "id") { self.get_string_attribute("id")
Some(x) => x,
None => ~""
}
} }
pub fn SetId(&mut self, abstract_self: AbstractNode, id: DOMString) { pub fn SetId(&mut self, abstract_self: AbstractNode, id: DOMString) {
self.set_attribute(abstract_self, namespace::Null, ~"id", id); self.set_string_attribute(abstract_self, "id", id);
} }
pub fn Attributes(&mut self, abstract_self: AbstractNode) -> @mut AttrList { pub fn Attributes(&mut self, abstract_self: AbstractNode) -> @mut AttrList {

View file

@ -84,14 +84,12 @@ impl HTMLIFrameElement {
} }
pub fn Sandbox(&self, _abstract_self: AbstractNode) -> DOMString { pub fn Sandbox(&self, _abstract_self: AbstractNode) -> DOMString {
match self.htmlelement.element.GetAttribute(~"sandbox") { self.htmlelement.element.get_string_attribute("sandbox")
Some(s) => s.to_owned(),
None => ~"",
}
} }
pub fn SetSandbox(&mut self, abstract_self: AbstractNode, sandbox: DOMString) { pub fn SetSandbox(&mut self, abstract_self: AbstractNode, sandbox: DOMString) {
self.htmlelement.element.SetAttribute(abstract_self, ~"sandbox", sandbox); self.htmlelement.element.set_string_attribute(abstract_self, "sandbox",
sandbox);
} }
pub fn AfterSetAttr(&mut self, name: DOMString, value: DOMString) { pub fn AfterSetAttr(&mut self, name: DOMString, value: DOMString) {

View file

@ -7,9 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::HTMLScriptElementTypeId; use dom::element::HTMLScriptElementTypeId;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::namespace::Null;
use dom::node::{AbstractNode, Node}; use dom::node::{AbstractNode, Node};
use style::TElement;
pub struct HTMLScriptElement { pub struct HTMLScriptElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
@ -30,10 +28,7 @@ impl HTMLScriptElement {
impl HTMLScriptElement { impl HTMLScriptElement {
pub fn Src(&self) -> DOMString { pub fn Src(&self) -> DOMString {
match self.htmlelement.element.get_attr(Null, "src") { self.htmlelement.element.get_url_attribute("src")
Some(s) => s.to_owned(),
None => ~""
}
} }
pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult {