mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
commit
1d6a1fc066
6 changed files with 88 additions and 88 deletions
|
@ -48,7 +48,7 @@ pub trait CharacterDataMethods {
|
||||||
fn InsertData(&mut self, _offset: u32, _arg: DOMString) -> ErrorResult;
|
fn InsertData(&mut self, _offset: u32, _arg: DOMString) -> ErrorResult;
|
||||||
fn DeleteData(&mut self, _offset: u32, _count: u32) -> ErrorResult;
|
fn DeleteData(&mut self, _offset: u32, _count: u32) -> ErrorResult;
|
||||||
fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: DOMString) -> ErrorResult;
|
fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: DOMString) -> ErrorResult;
|
||||||
fn Remove(&mut self);
|
fn Remove(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
||||||
|
@ -101,8 +101,8 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-childnode-remove
|
// http://dom.spec.whatwg.org/#dom-childnode-remove
|
||||||
fn Remove(&mut self) {
|
fn Remove(&self) {
|
||||||
let node: &mut JSRef<Node> = NodeCast::from_mut_ref(self);
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
node.remove_self();
|
node.remove_self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub trait DocumentTypeMethods {
|
||||||
fn Name(&self) -> DOMString;
|
fn Name(&self) -> DOMString;
|
||||||
fn PublicId(&self) -> DOMString;
|
fn PublicId(&self) -> DOMString;
|
||||||
fn SystemId(&self) -> DOMString;
|
fn SystemId(&self) -> DOMString;
|
||||||
fn Remove(&mut self);
|
fn Remove(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
|
impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
|
||||||
|
@ -73,8 +73,8 @@ impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-childnode-remove
|
// http://dom.spec.whatwg.org/#dom-childnode-remove
|
||||||
fn Remove(&mut self) {
|
fn Remove(&self) {
|
||||||
let node: &mut JSRef<Node> = NodeCast::from_mut_ref(self);
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
node.remove_self();
|
node.remove_self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,25 +208,25 @@ impl<'a> ElementHelpers for JSRef<'a, Element> {
|
||||||
|
|
||||||
pub trait AttributeHandlers {
|
pub trait AttributeHandlers {
|
||||||
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>>;
|
fn get_attribute(&self, namespace: Namespace, name: &str) -> Option<Temporary<Attr>>;
|
||||||
fn set_attribute_from_parser(&mut self, local_name: DOMString,
|
fn set_attribute_from_parser(&self, local_name: DOMString,
|
||||||
value: DOMString, namespace: Namespace,
|
value: DOMString, namespace: Namespace,
|
||||||
prefix: Option<DOMString>);
|
prefix: Option<DOMString>);
|
||||||
fn set_attribute(&mut self, namespace: Namespace, name: DOMString,
|
fn set_attribute(&self, namespace: Namespace, name: DOMString,
|
||||||
value: DOMString) -> ErrorResult;
|
value: DOMString) -> ErrorResult;
|
||||||
fn do_set_attribute(&mut self, local_name: DOMString, value: DOMString,
|
fn do_set_attribute(&self, local_name: DOMString, value: DOMString,
|
||||||
name: DOMString, namespace: Namespace,
|
name: DOMString, namespace: Namespace,
|
||||||
prefix: Option<DOMString>, cb: |&JSRef<Attr>| -> bool);
|
prefix: Option<DOMString>, cb: |&JSRef<Attr>| -> bool);
|
||||||
|
|
||||||
fn remove_attribute(&mut self, namespace: Namespace, name: DOMString) -> ErrorResult;
|
fn remove_attribute(&self, namespace: Namespace, name: DOMString) -> ErrorResult;
|
||||||
fn notify_attribute_changed(&self, local_name: DOMString);
|
fn notify_attribute_changed(&self, local_name: DOMString);
|
||||||
fn has_class(&self, name: &str) -> bool;
|
fn has_class(&self, name: &str) -> bool;
|
||||||
|
|
||||||
// http://www.whatwg.org/html/#reflecting-content-attributes-in-idl-attributes
|
// http://www.whatwg.org/html/#reflecting-content-attributes-in-idl-attributes
|
||||||
fn get_url_attribute(&self, name: &str) -> DOMString;
|
fn get_url_attribute(&self, name: &str) -> DOMString;
|
||||||
fn set_url_attribute(&mut self, name: &str, value: DOMString);
|
fn set_url_attribute(&self, name: &str, value: DOMString);
|
||||||
fn get_string_attribute(&self, name: &str) -> DOMString;
|
fn get_string_attribute(&self, name: &str) -> DOMString;
|
||||||
fn set_string_attribute(&mut self, name: &str, value: DOMString);
|
fn set_string_attribute(&self, name: &str, value: DOMString);
|
||||||
fn set_uint_attribute(&mut self, name: &str, value: u32);
|
fn set_uint_attribute(&self, name: &str, value: u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
|
@ -245,7 +245,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
}).map(|x| Temporary::from_rooted(&*x))
|
}).map(|x| Temporary::from_rooted(&*x))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_attribute_from_parser(&mut self, local_name: DOMString,
|
fn set_attribute_from_parser(&self, local_name: DOMString,
|
||||||
value: DOMString, namespace: Namespace,
|
value: DOMString, namespace: Namespace,
|
||||||
prefix: Option<DOMString>) {
|
prefix: Option<DOMString>) {
|
||||||
let name = match prefix {
|
let name = match prefix {
|
||||||
|
@ -255,7 +255,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
self.do_set_attribute(local_name, value, name, namespace, prefix, |_| false)
|
self.do_set_attribute(local_name, value, name, namespace, prefix, |_| false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_attribute(&mut self, namespace: Namespace, name: DOMString,
|
fn set_attribute(&self, namespace: Namespace, name: DOMString,
|
||||||
value: DOMString) -> ErrorResult {
|
value: DOMString) -> ErrorResult {
|
||||||
let (prefix, local_name) = get_attribute_parts(name.clone());
|
let (prefix, local_name) = get_attribute_parts(name.clone());
|
||||||
match prefix {
|
match prefix {
|
||||||
|
@ -269,8 +269,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let self_alias = self.clone();
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
let node: &JSRef<Node> = NodeCast::from_ref(&self_alias);
|
|
||||||
node.wait_until_safe_to_modify_dom();
|
node.wait_until_safe_to_modify_dom();
|
||||||
|
|
||||||
let position: |&JSRef<Attr>| -> bool =
|
let position: |&JSRef<Attr>| -> bool =
|
||||||
|
@ -283,7 +282,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_set_attribute(&mut self, local_name: DOMString, value: DOMString,
|
fn do_set_attribute(&self, local_name: DOMString, value: DOMString,
|
||||||
name: DOMString, namespace: Namespace,
|
name: DOMString, namespace: Namespace,
|
||||||
prefix: Option<DOMString>, cb: |&JSRef<Attr>| -> bool) {
|
prefix: Option<DOMString>, cb: |&JSRef<Attr>| -> bool) {
|
||||||
let idx = self.deref().attrs.borrow().iter()
|
let idx = self.deref().attrs.borrow().iter()
|
||||||
|
@ -303,7 +302,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
self.deref().attrs.borrow().get(idx).root().set_value(set_type, value);
|
self.deref().attrs.borrow().get(idx).root().set_value(set_type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_attribute(&mut self, namespace: Namespace, name: DOMString) -> ErrorResult {
|
fn remove_attribute(&self, namespace: Namespace, name: DOMString) -> ErrorResult {
|
||||||
let (_, local_name) = get_attribute_parts(name.clone());
|
let (_, local_name) = get_attribute_parts(name.clone());
|
||||||
|
|
||||||
let idx = self.deref().attrs.borrow().iter().map(|attr| attr.root()).position(|attr| {
|
let idx = self.deref().attrs.borrow().iter().map(|attr| attr.root()).position(|attr| {
|
||||||
|
@ -314,13 +313,14 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
None => (),
|
None => (),
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
{
|
{
|
||||||
let node: &mut JSRef<Node> = NodeCast::from_mut_ref(self);
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
node.wait_until_safe_to_modify_dom();
|
node.wait_until_safe_to_modify_dom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if namespace == namespace::Null {
|
if namespace == namespace::Null {
|
||||||
let removed_raw_value = self.deref().attrs.borrow().get(idx).root().Value();
|
let removed_raw_value = self.deref().attrs.borrow().get(idx).root().Value();
|
||||||
vtable_for(NodeCast::from_mut_ref(self))
|
let mut self_alias = self.clone();
|
||||||
|
vtable_for(NodeCast::from_mut_ref(&mut self_alias))
|
||||||
.before_remove_attr(local_name.clone(), removed_raw_value);
|
.before_remove_attr(local_name.clone(), removed_raw_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
// XXX Resolve URL.
|
// XXX Resolve URL.
|
||||||
self.get_string_attribute(name)
|
self.get_string_attribute(name)
|
||||||
}
|
}
|
||||||
fn set_url_attribute(&mut self, name: &str, value: DOMString) {
|
fn set_url_attribute(&self, name: &str, value: DOMString) {
|
||||||
self.set_string_attribute(name, value);
|
self.set_string_attribute(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,12 +366,12 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
None => "".to_owned()
|
None => "".to_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn set_string_attribute(&mut self, name: &str, value: DOMString) {
|
fn set_string_attribute(&self, name: &str, value: DOMString) {
|
||||||
assert!(name == name.to_ascii_lower());
|
assert!(name == name.to_ascii_lower());
|
||||||
assert!(self.set_attribute(Null, name.to_owned(), value).is_ok());
|
assert!(self.set_attribute(Null, name.to_owned(), value).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_uint_attribute(&mut self, name: &str, value: u32) {
|
fn set_uint_attribute(&self, name: &str, value: u32) {
|
||||||
assert!(name == name.to_ascii_lower());
|
assert!(name == name.to_ascii_lower());
|
||||||
assert!(self.set_attribute(Null, name.to_owned(), value.to_str()).is_ok());
|
assert!(self.set_attribute(Null, name.to_owned(), value.to_str()).is_ok());
|
||||||
}
|
}
|
||||||
|
@ -399,16 +399,16 @@ pub trait ElementMethods {
|
||||||
fn GetPrefix(&self) -> Option<DOMString>;
|
fn GetPrefix(&self) -> Option<DOMString>;
|
||||||
fn TagName(&self) -> DOMString;
|
fn TagName(&self) -> DOMString;
|
||||||
fn Id(&self) -> DOMString;
|
fn Id(&self) -> DOMString;
|
||||||
fn SetId(&mut self, id: DOMString);
|
fn SetId(&self, id: DOMString);
|
||||||
fn ClassName(&self) -> DOMString;
|
fn ClassName(&self) -> DOMString;
|
||||||
fn SetClassName(&mut self, class: DOMString);
|
fn SetClassName(&self, class: DOMString);
|
||||||
fn Attributes(&mut self) -> Temporary<AttrList>;
|
fn Attributes(&self) -> Temporary<AttrList>;
|
||||||
fn GetAttribute(&self, name: DOMString) -> Option<DOMString>;
|
fn GetAttribute(&self, name: DOMString) -> Option<DOMString>;
|
||||||
fn GetAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> Option<DOMString>;
|
fn GetAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> Option<DOMString>;
|
||||||
fn SetAttribute(&mut self, name: DOMString, value: DOMString) -> ErrorResult;
|
fn SetAttribute(&self, name: DOMString, value: DOMString) -> ErrorResult;
|
||||||
fn SetAttributeNS(&mut self, namespace_url: Option<DOMString>, name: DOMString, value: DOMString) -> ErrorResult;
|
fn SetAttributeNS(&self, namespace_url: Option<DOMString>, name: DOMString, value: DOMString) -> ErrorResult;
|
||||||
fn RemoveAttribute(&mut self, name: DOMString) -> ErrorResult;
|
fn RemoveAttribute(&self, name: DOMString) -> ErrorResult;
|
||||||
fn RemoveAttributeNS(&mut self, namespace: Option<DOMString>, localname: DOMString) -> ErrorResult;
|
fn RemoveAttributeNS(&self, namespace: Option<DOMString>, localname: DOMString) -> ErrorResult;
|
||||||
fn HasAttribute(&self, name: DOMString) -> bool;
|
fn HasAttribute(&self, name: DOMString) -> bool;
|
||||||
fn HasAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> bool;
|
fn HasAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> bool;
|
||||||
fn GetElementsByTagName(&self, localname: DOMString) -> Temporary<HTMLCollection>;
|
fn GetElementsByTagName(&self, localname: DOMString) -> Temporary<HTMLCollection>;
|
||||||
|
@ -419,7 +419,7 @@ pub trait ElementMethods {
|
||||||
fn GetInnerHTML(&self) -> Fallible<DOMString>;
|
fn GetInnerHTML(&self) -> Fallible<DOMString>;
|
||||||
fn GetOuterHTML(&self) -> Fallible<DOMString>;
|
fn GetOuterHTML(&self) -> Fallible<DOMString>;
|
||||||
fn Children(&self) -> Temporary<HTMLCollection>;
|
fn Children(&self) -> Temporary<HTMLCollection>;
|
||||||
fn Remove(&mut self);
|
fn Remove(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ElementMethods for JSRef<'a, Element> {
|
impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
|
@ -455,7 +455,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-id
|
// http://dom.spec.whatwg.org/#dom-element-id
|
||||||
fn SetId(&mut self, id: DOMString) {
|
fn SetId(&self, id: DOMString) {
|
||||||
self.set_string_attribute("id", id);
|
self.set_string_attribute("id", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,12 +465,12 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-classname
|
// http://dom.spec.whatwg.org/#dom-element-classname
|
||||||
fn SetClassName(&mut self, class: DOMString) {
|
fn SetClassName(&self, class: DOMString) {
|
||||||
self.set_string_attribute("class", class);
|
self.set_string_attribute("class", class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-attributes
|
// http://dom.spec.whatwg.org/#dom-element-attributes
|
||||||
fn Attributes(&mut self) -> Temporary<AttrList> {
|
fn Attributes(&self) -> Temporary<AttrList> {
|
||||||
match self.attr_list.get() {
|
match self.attr_list.get() {
|
||||||
None => (),
|
None => (),
|
||||||
Some(ref list) => return Temporary::new(list.clone()),
|
Some(ref list) => return Temporary::new(list.clone()),
|
||||||
|
@ -507,7 +507,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-setattribute
|
// http://dom.spec.whatwg.org/#dom-element-setattribute
|
||||||
fn SetAttribute(&mut self,
|
fn SetAttribute(&self,
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
value: DOMString) -> ErrorResult {
|
value: DOMString) -> ErrorResult {
|
||||||
{
|
{
|
||||||
|
@ -536,7 +536,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-setattributens
|
// http://dom.spec.whatwg.org/#dom-element-setattributens
|
||||||
fn SetAttributeNS(&mut self,
|
fn SetAttributeNS(&self,
|
||||||
namespace_url: Option<DOMString>,
|
namespace_url: Option<DOMString>,
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
value: DOMString) -> ErrorResult {
|
value: DOMString) -> ErrorResult {
|
||||||
|
@ -598,7 +598,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-removeattribute
|
// http://dom.spec.whatwg.org/#dom-element-removeattribute
|
||||||
fn RemoveAttribute(&mut self,
|
fn RemoveAttribute(&self,
|
||||||
name: DOMString) -> ErrorResult {
|
name: DOMString) -> ErrorResult {
|
||||||
let name = if self.html_element_in_html_document() {
|
let name = if self.html_element_in_html_document() {
|
||||||
name.to_ascii_lower()
|
name.to_ascii_lower()
|
||||||
|
@ -609,7 +609,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-removeattributens
|
// http://dom.spec.whatwg.org/#dom-element-removeattributens
|
||||||
fn RemoveAttributeNS(&mut self,
|
fn RemoveAttributeNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
localname: DOMString) -> ErrorResult {
|
localname: DOMString) -> ErrorResult {
|
||||||
let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace));
|
let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace));
|
||||||
|
@ -694,8 +694,8 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-childnode-remove
|
// http://dom.spec.whatwg.org/#dom-childnode-remove
|
||||||
fn Remove(&mut self) {
|
fn Remove(&self) {
|
||||||
let node: &mut JSRef<Node> = NodeCast::from_mut_ref(self);
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
node.remove_self();
|
node.remove_self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl HTMLIFrameElement {
|
||||||
|
|
||||||
pub trait HTMLIFrameElementMethods {
|
pub trait HTMLIFrameElementMethods {
|
||||||
fn Sandbox(&self) -> DOMString;
|
fn Sandbox(&self) -> DOMString;
|
||||||
fn SetSandbox(&mut self, sandbox: DOMString);
|
fn SetSandbox(&self, sandbox: DOMString);
|
||||||
fn GetContentWindow(&self) -> Option<Temporary<Window>>;
|
fn GetContentWindow(&self) -> Option<Temporary<Window>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
element.get_string_attribute("sandbox")
|
element.get_string_attribute("sandbox")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetSandbox(&mut self, sandbox: DOMString) {
|
fn SetSandbox(&self, sandbox: DOMString) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute("sandbox", sandbox);
|
element.set_string_attribute("sandbox", sandbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,29 +89,29 @@ impl LayoutHTMLImageElementHelpers for JS<HTMLImageElement> {
|
||||||
|
|
||||||
pub trait HTMLImageElementMethods {
|
pub trait HTMLImageElementMethods {
|
||||||
fn Alt(&self) -> DOMString;
|
fn Alt(&self) -> DOMString;
|
||||||
fn SetAlt(&mut self, alt: DOMString);
|
fn SetAlt(&self, alt: DOMString);
|
||||||
fn Src(&self) -> DOMString;
|
fn Src(&self) -> DOMString;
|
||||||
fn SetSrc(&mut self, src: DOMString);
|
fn SetSrc(&self, src: DOMString);
|
||||||
fn UseMap(&self) -> DOMString;
|
fn UseMap(&self) -> DOMString;
|
||||||
fn SetUseMap(&mut self, use_map: DOMString);
|
fn SetUseMap(&self, use_map: DOMString);
|
||||||
fn IsMap(&self) -> bool;
|
fn IsMap(&self) -> bool;
|
||||||
fn SetIsMap(&mut self, is_map: bool);
|
fn SetIsMap(&self, is_map: bool);
|
||||||
fn Width(&self) -> u32;
|
fn Width(&self) -> u32;
|
||||||
fn SetWidth(&mut self, width: u32);
|
fn SetWidth(&self, width: u32);
|
||||||
fn Height(&self) -> u32;
|
fn Height(&self) -> u32;
|
||||||
fn SetHeight(&mut self, height: u32);
|
fn SetHeight(&self, height: u32);
|
||||||
fn Name(&self) -> DOMString;
|
fn Name(&self) -> DOMString;
|
||||||
fn SetName(&mut self, name: DOMString);
|
fn SetName(&self, name: DOMString);
|
||||||
fn Align(&self) -> DOMString;
|
fn Align(&self) -> DOMString;
|
||||||
fn SetAlign(&mut self, align: DOMString);
|
fn SetAlign(&self, align: DOMString);
|
||||||
fn Hspace(&self) -> u32;
|
fn Hspace(&self) -> u32;
|
||||||
fn SetHspace(&mut self, hspace: u32);
|
fn SetHspace(&self, hspace: u32);
|
||||||
fn Vspace(&self) -> u32;
|
fn Vspace(&self) -> u32;
|
||||||
fn SetVspace(&mut self, vspace: u32);
|
fn SetVspace(&self, vspace: u32);
|
||||||
fn LongDesc(&self) -> DOMString;
|
fn LongDesc(&self) -> DOMString;
|
||||||
fn SetLongDesc(&mut self, longdesc: DOMString);
|
fn SetLongDesc(&self, longdesc: DOMString);
|
||||||
fn Border(&self) -> DOMString;
|
fn Border(&self) -> DOMString;
|
||||||
fn SetBorder(&mut self, border: DOMString);
|
fn SetBorder(&self, border: DOMString);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
|
@ -120,8 +120,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
element.get_string_attribute("alt")
|
element.get_string_attribute("alt")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetAlt(&mut self, alt: DOMString) {
|
fn SetAlt(&self, alt: DOMString) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute("alt", alt)
|
element.set_string_attribute("alt", alt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,8 +130,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
element.get_string_attribute("src")
|
element.get_string_attribute("src")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetSrc(&mut self, src: DOMString) {
|
fn SetSrc(&self, src: DOMString) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_url_attribute("src", src)
|
element.set_url_attribute("src", src)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
element.get_string_attribute("useMap")
|
element.get_string_attribute("useMap")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetUseMap(&mut self, use_map: DOMString) {
|
fn SetUseMap(&self, use_map: DOMString) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute("useMap", use_map)
|
element.set_string_attribute("useMap", use_map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,8 +150,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
from_str::<bool>(element.get_string_attribute("hspace")).unwrap()
|
from_str::<bool>(element.get_string_attribute("hspace")).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetIsMap(&mut self, is_map: bool) {
|
fn SetIsMap(&self, is_map: bool) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute("isMap", is_map.to_str())
|
element.set_string_attribute("isMap", is_map.to_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,8 +161,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
to_px(rect.size.width) as u32
|
to_px(rect.size.width) as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetWidth(&mut self, width: u32) {
|
fn SetWidth(&self, width: u32) {
|
||||||
let elem: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let elem: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
elem.set_uint_attribute("width", width)
|
elem.set_uint_attribute("width", width)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,8 +172,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
to_px(rect.size.height) as u32
|
to_px(rect.size.height) as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetHeight(&mut self, height: u32) {
|
fn SetHeight(&self, height: u32) {
|
||||||
let elem: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let elem: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
elem.set_uint_attribute("height", height)
|
elem.set_uint_attribute("height", height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,8 +182,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
element.get_string_attribute("name")
|
element.get_string_attribute("name")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetName(&mut self, name: DOMString) {
|
fn SetName(&self, name: DOMString) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute("name", name)
|
element.set_string_attribute("name", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,8 +192,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
element.get_string_attribute("align")
|
element.get_string_attribute("align")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetAlign(&mut self, align: DOMString) {
|
fn SetAlign(&self, align: DOMString) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute("align", align)
|
element.set_string_attribute("align", align)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +202,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
from_str::<u32>(element.get_string_attribute("hspace")).unwrap()
|
from_str::<u32>(element.get_string_attribute("hspace")).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetHspace(&mut self, hspace: u32) {
|
fn SetHspace(&self, hspace: u32) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_uint_attribute("hspace", hspace)
|
element.set_uint_attribute("hspace", hspace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
from_str::<u32>(element.get_string_attribute("vspace")).unwrap()
|
from_str::<u32>(element.get_string_attribute("vspace")).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetVspace(&mut self, vspace: u32) {
|
fn SetVspace(&self, vspace: u32) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_uint_attribute("vspace", vspace)
|
element.set_uint_attribute("vspace", vspace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +222,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
element.get_string_attribute("longdesc")
|
element.get_string_attribute("longdesc")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetLongDesc(&mut self, longdesc: DOMString) {
|
fn SetLongDesc(&self, longdesc: DOMString) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute("longdesc", longdesc)
|
element.set_string_attribute("longdesc", longdesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,8 +232,8 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||||
element.get_string_attribute("border")
|
element.get_string_attribute("border")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetBorder(&mut self, border: DOMString) {
|
fn SetBorder(&self, border: DOMString) {
|
||||||
let element: &mut JSRef<Element> = ElementCast::from_mut_ref(self);
|
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||||
element.set_string_attribute("border", border)
|
element.set_string_attribute("border", border)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,7 +370,7 @@ pub fn parse_html(page: &Page,
|
||||||
// NOTE: tmp vars are workaround for lifetime issues. Both required.
|
// NOTE: tmp vars are workaround for lifetime issues. Both required.
|
||||||
let tmp_borrow = doc_cell.borrow();
|
let tmp_borrow = doc_cell.borrow();
|
||||||
let tmp = &*tmp_borrow;
|
let tmp = &*tmp_borrow;
|
||||||
let mut element = build_element_from_tag(tag.name.clone(), *tmp).root();
|
let element: Root<Element> = build_element_from_tag(tag.name.clone(), *tmp).root();
|
||||||
|
|
||||||
debug!("-- attach attrs");
|
debug!("-- attach attrs");
|
||||||
for attr in tag.attributes.iter() {
|
for attr in tag.attributes.iter() {
|
||||||
|
@ -381,20 +381,20 @@ pub fn parse_html(page: &Page,
|
||||||
XmlNsNs => (namespace::XMLNS, Some("xmlns")),
|
XmlNsNs => (namespace::XMLNS, Some("xmlns")),
|
||||||
ns => fail!("Not expecting namespace {:?}", ns),
|
ns => fail!("Not expecting namespace {:?}", ns),
|
||||||
};
|
};
|
||||||
element.set_attribute_from_parser(attr.name.clone(),
|
element.deref().set_attribute_from_parser(attr.name.clone(),
|
||||||
attr.value.clone(),
|
attr.value.clone(),
|
||||||
namespace,
|
namespace,
|
||||||
prefix.map(|p| p.to_owned()));
|
prefix.map(|p| p.to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: workaround for https://github.com/mozilla/rust/issues/13246;
|
//FIXME: workaround for https://github.com/mozilla/rust/issues/13246;
|
||||||
// we get unrooting order failures if these are inside the match.
|
// we get unrooting order failures if these are inside the match.
|
||||||
let rel = {
|
let rel = {
|
||||||
let rel = element.get_attribute(Null, "rel").root();
|
let rel = element.deref().get_attribute(Null, "rel").root();
|
||||||
rel.map(|a| a.deref().Value())
|
rel.map(|a| a.deref().Value())
|
||||||
};
|
};
|
||||||
let href = {
|
let href = {
|
||||||
let href= element.get_attribute(Null, "href").root();
|
let href= element.deref().get_attribute(Null, "href").root();
|
||||||
href.map(|a| a.deref().Value())
|
href.map(|a| a.deref().Value())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ pub fn parse_html(page: &Page,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { element.to_hubbub_node() }
|
unsafe { element.deref().to_hubbub_node() }
|
||||||
},
|
},
|
||||||
create_text: |data: ~str| {
|
create_text: |data: ~str| {
|
||||||
debug!("create text");
|
debug!("create text");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue