diff --git a/src/components/script/dom/attr.rs b/src/components/script/dom/attr.rs index d6c2d530862..5c37ca45632 100644 --- a/src/components/script/dom/attr.rs +++ b/src/components/script/dom/attr.rs @@ -91,31 +91,40 @@ impl Attr { } } -impl Attr { - pub fn LocalName(&self) -> DOMString { +pub trait AttrMethods { + fn LocalName(&self) -> DOMString; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, value: DOMString); + fn Name(&self) -> DOMString; + fn GetNamespaceURI(&self) -> Option; + fn GetPrefix(&self) -> Option; +} + +impl<'a> AttrMethods for JSRef<'a, Attr> { + fn LocalName(&self) -> DOMString { self.local_name.clone() } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { self.value.clone() } - pub fn SetValue(&mut self, value: DOMString) { + fn SetValue(&mut self, value: DOMString) { self.set_value(ReplacedAttr, value); } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { self.name.clone() } - pub fn GetNamespaceURI(&self) -> Option { + fn GetNamespaceURI(&self) -> Option { match self.namespace.to_str() { "" => None, url => Some(url.to_owned()), } } - pub fn GetPrefix(&self) -> Option { + fn GetPrefix(&self) -> Option { self.prefix.clone() } } diff --git a/src/components/script/dom/attrlist.rs b/src/components/script/dom/attrlist.rs index 273378347f0..eca2deade79 100644 --- a/src/components/script/dom/attrlist.rs +++ b/src/components/script/dom/attrlist.rs @@ -29,18 +29,26 @@ impl AttrList { reflect_dom_object(~AttrList::new_inherited(window.unrooted(), elem.unrooted()), window, AttrListBinding::Wrap) } +} - pub fn Length(&self) -> u32 { +pub trait AttrListMethods { + fn Length(&self) -> u32; + fn Item(&self, index: u32) -> Option>; + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option>; +} + +impl<'a> AttrListMethods for JSRef<'a, AttrList> { + fn Length(&self) -> u32 { let roots = RootCollection::new(); self.owner.root(&roots).attrs.len() as u32 } - pub fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { let roots = RootCollection::new(); self.owner.root(&roots).attrs.as_slice().get(index as uint).map(|x| Unrooted::new(x.clone())) } - pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { let item = self.Item(index); *found = item.is_some(); item diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 74de0fe75d4..a8b75a75456 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1395,7 +1395,7 @@ class CGImports(CGWrapper): """ Generates the appropriate import/use statements. """ - def __init__(self, child, imports): + def __init__(self, child, descriptors, imports): """ Adds a set of imports. """ @@ -1415,6 +1415,10 @@ class CGImports(CGWrapper): 'dead_code', ] + for d in descriptors: + name = d.interface.identifier.name + imports.append('dom::%s::%sMethods' % (name.lower(), name)) + statements = ['#![allow(%s)]' % ','.join(ignored_warnings)] statements.extend('use %s;' % i for i in sorted(imports)) @@ -2499,7 +2503,8 @@ class CGSpecializedMethod(CGAbstractExternMethod): return CGWrapper(CGMethodCall(argsPre, nativeName, self.method.isStatic(), self.descriptor, self.method), pre=extraPre + - " let this = &mut *this;\n").define() + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n").define() class CGGenericGetter(CGAbstractBindingMethod): """ @@ -2558,7 +2563,8 @@ class CGSpecializedGetter(CGAbstractExternMethod): return CGWrapper(CGIndenter(CGGetterCall(argsPre, self.attr.type, nativeName, self.descriptor, self.attr)), pre=extraPre + - " let this = &mut *this;\n").define() + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n").define() class CGGenericSetter(CGAbstractBindingMethod): """ @@ -2617,7 +2623,8 @@ class CGSpecializedSetter(CGAbstractExternMethod): return CGWrapper(CGIndenter(CGSetterCall(argsPre, self.attr.type, nativeName, self.descriptor, self.attr)), pre=extraPre + - " let this = &mut *this;\n").define() + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n").define() class CGMemberJITInfo(CGThing): @@ -3508,14 +3515,14 @@ class CGProxyNamedSetter(CGProxySpecialOperation): class CGProxyUnwrap(CGAbstractMethod): def __init__(self, descriptor): args = [Argument('*JSObject', 'obj')] - CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy", '*' + descriptor.concreteType, args, alwaysInline=True) + CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy", '*mut ' + descriptor.concreteType, args, alwaysInline=True) def definition_body(self): return """ /*if (xpc::WrapperFactory::IsXrayWrapper(obj)) { obj = js::UnwrapObject(obj); }*/ //MOZ_ASSERT(IsProxy(obj)); - let box_: *%s = cast::transmute(GetProxyPrivate(obj).to_private()); + let box_: *mut %s = cast::transmute(GetProxyPrivate(obj).to_private()); return box_;""" % (self.descriptor.concreteType) class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): @@ -3540,9 +3547,11 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): templateValues = {'jsvalRef': '(*desc).value', 'successCode': fillDescriptor} get = ("if index.is_some() {\n" + " let index = index.unwrap();\n" + - " let this: *%s = UnwrapProxy(proxy);\n" + + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" + - "}\n") % (self.descriptor.concreteType) + "}\n") if indexedSetter or self.descriptor.operations['NamedSetter']: setOrIndexedGet += "if set != 0 {\n" @@ -3585,9 +3594,11 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): namedGet = ("\n" + "if set == 0 && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" + " let name = Some(jsid_to_str(cx, id));\n" + - " let this: *%s = UnwrapProxy(proxy);\n" + + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" + - "}\n") % (self.descriptor.concreteType) + "}\n") else: namedGet = "" @@ -3628,10 +3639,12 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): set += ("let index = GetArrayIndexFromId(cx, id);\n" + "if index.is_some() {\n" + " let index = index.unwrap();\n" + - " let this: *mut %s = UnwrapProxy(proxy) as *mut %s;\n" + + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() + " return 1;\n" + - "}\n") % (self.descriptor.concreteType, self.descriptor.concreteType) + "}\n") elif self.descriptor.operations['IndexedGetter']: set += ("if GetArrayIndexFromId(cx, id).is_some() {\n" + " return 0;\n" + @@ -3644,20 +3657,24 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): raise TypeError("Can't handle creator that's different from the setter") set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" + " let name = Some(jsid_to_str(cx, id));\n" + - " let this: *%s = UnwrapProxy(proxy);\n" + + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyNamedSetter(self.descriptor)).define() + "\n" + - "}\n") % (self.descriptor.concreteType) + "}\n") elif self.descriptor.operations['NamedGetter']: set += ("if RUST_JSID_IS_STRING(id) {\n" + " let name = Some(jsid_to_str(cx, id));\n" + - " let this: %%s = UnwrapProxy(proxy);\n" + + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + " if (found) {\n" " return 0;\n" + " //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" + " }\n" + " return 1;\n" - "}\n") % (self.descriptor.concreteType, self.descriptor.name) + "}\n") % (self.descriptor.name) return set + """return proxyhandler::defineProperty_(%s);""" % ", ".join(a.name for a in self.args) def definition_body(self): @@ -3675,11 +3692,13 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): indexed = ("let index = GetArrayIndexFromId(cx, id);\n" + "if index.is_some() {\n" + " let index = index.unwrap();\n" + - " let this: *%s = UnwrapProxy(proxy);\n" + + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" + " *bp = found as JSBool;\n" + " return 1;\n" + - "}\n\n") % (self.descriptor.concreteType) + "}\n\n") else: indexed = "" @@ -3687,12 +3706,14 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): if namedGetter: named = ("if RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" + " let name = Some(jsid_to_str(cx, id));\n" + - " let this: *%s = UnwrapProxy(proxy);\n" + + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" + " *bp = found as JSBool;\n" " return 1;\n" "}\n" + - "\n") % (self.descriptor.concreteType) + "\n") else: named = "" @@ -3740,6 +3761,8 @@ if expando.is_not_null() { "if index.is_some() {\n" + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define()) getIndexedOrExpando += """ // Even if we don't have this index, we don't forward the @@ -3756,6 +3779,8 @@ if expando.is_not_null() { getNamed = ("if (JSID_IS_STRING(id)) {\n" + " let name = Some(jsid_to_str(cx, id));\n" + " let this = UnwrapProxy(proxy);\n" + + " let this = JS::from_raw(this);\n" + + " let mut this = this.root(&roots);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "}\n") % (self.descriptor.concreteType) else: @@ -4288,7 +4313,7 @@ class CGBindingRoot(CGThing): # Add imports #XXXjdm This should only import the namespace for the current binding, # not every binding ever. - curr = CGImports(curr, [ + curr = CGImports(curr, descriptors, [ 'js', 'js::{JS_ARGV, JS_CALLEE, JS_THIS_OBJECT}', 'js::{JSCLASS_GLOBAL_SLOT_COUNT, JSCLASS_IS_DOMJSCLASS}', @@ -5253,7 +5278,7 @@ class GlobalGenRoots(): @staticmethod def RegisterBindings(config): # TODO - Generate the methods we want - return CGImports(CGRegisterProtos(config), [ + return CGImports(CGRegisterProtos(config), [], [ 'dom::bindings::codegen', 'dom::bindings::js::{JS, JSRef}', 'dom::window::Window', @@ -5372,7 +5397,7 @@ class GlobalGenRoots(): curr = UnionTypes(config.getDescriptors()) - curr = CGImports(curr, [ + curr = CGImports(curr, [], [ 'dom::bindings::utils::unwrap_jsmanaged', 'dom::bindings::codegen::PrototypeList', 'dom::bindings::conversions::{FromJSValConvertible, ToJSValConvertible}', diff --git a/src/components/script/dom/blob.rs b/src/components/script/dom/blob.rs index 0399568063d..a40715f00f2 100644 --- a/src/components/script/dom/blob.rs +++ b/src/components/script/dom/blob.rs @@ -28,28 +28,35 @@ impl Blob { window, BlobBinding::Wrap) } -} -impl Blob { pub fn Constructor(window: &JSRef) -> Fallible> { Ok(Blob::new(window)) } +} - pub fn Size(&self) -> u64 { +pub trait BlobMethods { + fn Size(&self) -> u64; + fn Type(&self) -> DOMString; + fn Slice(&self, _start: Option, _end: Option, _contentType: Option) -> Unrooted; + fn Close(&self); +} + +impl<'a> BlobMethods for JSRef<'a, Blob> { + fn Size(&self) -> u64 { 0 } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn Slice(&self, _start: Option, _end: Option, _contentType: Option) -> Unrooted { + fn Slice(&self, _start: Option, _end: Option, _contentType: Option) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); Blob::new(&window.root_ref()) } - pub fn Close(&self) {} + fn Close(&self) {} } impl Reflectable for Blob { diff --git a/src/components/script/dom/characterdata.rs b/src/components/script/dom/characterdata.rs index f85246ee12c..44962eea8a9 100644 --- a/src/components/script/dom/characterdata.rs +++ b/src/components/script/dom/characterdata.rs @@ -5,7 +5,7 @@ //! DOM bindings for `CharacterData`. use dom::bindings::codegen::InheritTypes::CharacterDataDerived; -use dom::bindings::js::JS; +use dom::bindings::js::{JS, JSRef}; use dom::bindings::error::{Fallible, ErrorResult, IndexSize}; use dom::bindings::utils::{Reflectable, Reflector}; use dom::document::Document; @@ -37,38 +37,51 @@ impl CharacterData { data: data } } +} - pub fn Data(&self) -> DOMString { +pub trait CharacterDataMethods { + fn Data(&self) -> DOMString; + fn SetData(&mut self, arg: DOMString) -> ErrorResult; + fn Length(&self) -> u32; + fn SubstringData(&self, offset: u32, count: u32) -> Fallible; + fn AppendData(&mut self, arg: DOMString) -> ErrorResult; + fn InsertData(&mut self, _offset: u32, _arg: DOMString) -> ErrorResult; + fn DeleteData(&mut self, _offset: u32, _count: u32) -> ErrorResult; + fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: DOMString) -> ErrorResult; +} + +impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> { + fn Data(&self) -> DOMString { self.data.clone() } - pub fn SetData(&mut self, arg: DOMString) -> ErrorResult { + fn SetData(&mut self, arg: DOMString) -> ErrorResult { self.data = arg; Ok(()) } - pub fn Length(&self) -> u32 { + fn Length(&self) -> u32 { self.data.len() as u32 } - pub fn SubstringData(&self, offset: u32, count: u32) -> Fallible { + fn SubstringData(&self, offset: u32, count: u32) -> Fallible { Ok(self.data.slice(offset as uint, count as uint).to_str()) } - pub fn AppendData(&mut self, arg: DOMString) -> ErrorResult { + fn AppendData(&mut self, arg: DOMString) -> ErrorResult { self.data.push_str(arg); Ok(()) } - pub fn InsertData(&mut self, offset: u32, arg: DOMString) -> ErrorResult { + fn InsertData(&mut self, offset: u32, arg: DOMString) -> ErrorResult { self.ReplaceData(offset, 0, arg) } - pub fn DeleteData(&mut self, offset: u32, count: u32) -> ErrorResult { + fn DeleteData(&mut self, offset: u32, count: u32) -> ErrorResult { self.ReplaceData(offset, count, ~"") } - pub fn ReplaceData(&mut self, offset: u32, count: u32, arg: DOMString) -> ErrorResult { + fn ReplaceData(&mut self, offset: u32, count: u32, arg: DOMString) -> ErrorResult { let length = self.data.len() as u32; if offset > length { return Err(IndexSize); diff --git a/src/components/script/dom/clientrect.rs b/src/components/script/dom/clientrect.rs index 4e4e2dbdcc6..8f07c6b8175 100644 --- a/src/components/script/dom/clientrect.rs +++ b/src/components/script/dom/clientrect.rs @@ -38,29 +38,39 @@ impl ClientRect { let rect = ClientRect::new_inherited(window.unrooted(), top, bottom, left, right); reflect_dom_object(~rect, window, ClientRectBinding::Wrap) } +} +pub trait ClientRectMethods { + fn Top(&self) -> f32; + fn Bottom(&self) -> f32; + fn Left(&self) -> f32; + fn Right(&self) -> f32; + fn Width(&self) -> f32; + fn Height(&self) -> f32; +} - pub fn Top(&self) -> f32 { +impl<'a> ClientRectMethods for JSRef<'a, ClientRect> { + fn Top(&self) -> f32 { self.top } - pub fn Bottom(&self) -> f32 { + fn Bottom(&self) -> f32 { self.bottom } - pub fn Left(&self) -> f32 { + fn Left(&self) -> f32 { self.left } - pub fn Right(&self) -> f32 { + fn Right(&self) -> f32 { self.right } - pub fn Width(&self) -> f32 { + fn Width(&self) -> f32 { (self.right - self.left).abs() } - pub fn Height(&self) -> f32 { + fn Height(&self) -> f32 { (self.bottom - self.top).abs() } } diff --git a/src/components/script/dom/clientrectlist.rs b/src/components/script/dom/clientrectlist.rs index a9beec896e8..30cbb1043e3 100644 --- a/src/components/script/dom/clientrectlist.rs +++ b/src/components/script/dom/clientrectlist.rs @@ -30,12 +30,20 @@ impl ClientRectList { reflect_dom_object(~ClientRectList::new_inherited(window.unrooted(), rects), window, ClientRectListBinding::Wrap) } +} - pub fn Length(&self) -> u32 { +pub trait ClientRectListMethods { + fn Length(&self) -> u32; + fn Item(&self, index: u32) -> Option>; + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option>; +} + +impl<'a> ClientRectListMethods for JSRef<'a, ClientRectList> { + fn Length(&self) -> u32 { self.rects.len() as u32 } - pub fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { if index < self.rects.len() as u32 { Some(Unrooted::new(self.rects.get(index as uint).clone())) } else { @@ -43,7 +51,7 @@ impl ClientRectList { } } - pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { *found = index < self.rects.len() as u32; self.Item(index) } diff --git a/src/components/script/dom/comment.rs b/src/components/script/dom/comment.rs index 779fb6415e9..0814cb7b25c 100644 --- a/src/components/script/dom/comment.rs +++ b/src/components/script/dom/comment.rs @@ -10,7 +10,7 @@ use dom::characterdata::CharacterData; use dom::document::Document; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::node::{CommentNodeTypeId, Node}; -use dom::window::Window; +use dom::window::{Window, WindowMethods}; use servo_util::str::DOMString; /// An HTML comment. @@ -42,9 +42,10 @@ impl Comment { pub fn Constructor(owner: &JSRef, data: DOMString) -> Fallible> { let roots = RootCollection::new(); - let document = owner.get().Document(); - let document = document.root(&roots); - - Ok(Comment::new(data, &document.root_ref())) + let document = owner.Document().root(&roots); + Ok(Comment::new(data, &*document)) } } + +pub trait CommentMethods { +} diff --git a/src/components/script/dom/console.rs b/src/components/script/dom/console.rs index ce41ed45212..ce919980f26 100644 --- a/src/components/script/dom/console.rs +++ b/src/components/script/dom/console.rs @@ -23,24 +23,34 @@ impl Console { pub fn new(window: &JSRef) -> Unrooted { reflect_dom_object(~Console::new_inherited(), window, ConsoleBinding::Wrap) } +} - pub fn Log(&self, message: DOMString) { +pub trait ConsoleMethods { + fn Log(&self, message: DOMString); + fn Debug(&self, message: DOMString); + fn Info(&self, message: DOMString); + fn Warn(&self, message: DOMString); + fn Error(&self, message: DOMString); +} + +impl<'a> ConsoleMethods for JSRef<'a, Console> { + fn Log(&self, message: DOMString) { println!("{:s}", message); } - pub fn Debug(&self, message: DOMString) { + fn Debug(&self, message: DOMString) { println!("{:s}", message); } - pub fn Info(&self, message: DOMString) { + fn Info(&self, message: DOMString) { println!("{:s}", message); } - pub fn Warn(&self, message: DOMString) { + fn Warn(&self, message: DOMString) { println!("{:s}", message); } - pub fn Error(&self, message: DOMString) { + fn Error(&self, message: DOMString) { println!("{:s}", message); } } diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index d0ffb203282..f435b6186af 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -33,7 +33,7 @@ use dom::nodelist::NodeList; use dom::text::Text; use dom::processinginstruction::ProcessingInstruction; use dom::uievent::UIEvent; -use dom::window::Window; +use dom::window::{Window, WindowMethods}; use dom::location::Location; use html::hubbub_html_parser::build_element_from_tag; use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks}; @@ -122,22 +122,108 @@ impl Document { } } + // http://dom.spec.whatwg.org/#dom-document + pub fn Constructor(owner: &JSRef) -> Fallible> { + Ok(Document::new(owner, None, NonHTMLDocument, None)) + } + pub fn new(window: &JSRef, url: Option, doctype: IsHTMLDocument, content_type: Option) -> Unrooted { let document = Document::new_inherited(window.unrooted(), url, doctype, content_type); Document::reflect_document(~document, window, DocumentBinding::Wrap) } -} -impl Document { pub fn url<'a>(&'a self) -> &'a Url { &*self.url } -} -impl Document { - // http://dom.spec.whatwg.org/#dom-document - pub fn Constructor(owner: &JSRef) -> Fallible> { - Ok(Document::new(owner, None, NonHTMLDocument, None)) + pub fn quirks_mode(&self) -> QuirksMode { + *self.quirks_mode + } + + pub fn set_quirks_mode(&mut self, mode: QuirksMode) { + *self.quirks_mode = mode; + } + + pub fn set_encoding_name(&mut self, name: DOMString) { + self.encoding_name = name; + } + + pub fn content_changed(&self) { + self.damage_and_reflow(ContentChangedDocumentDamage); + } + + pub fn damage_and_reflow(&self, damage: DocumentDamageLevel) { + let roots = RootCollection::new(); + self.window.root(&roots).damage_and_reflow(damage); + } + + pub fn wait_until_safe_to_modify_dom(&self) { + let roots = RootCollection::new(); + self.window.root(&roots).wait_until_safe_to_modify_dom(); + } + + + /// Remove any existing association between the provided id and any elements in this document. + pub fn unregister_named_element(&mut self, + abstract_self: &JSRef, + id: DOMString) { + let roots = RootCollection::new(); + let mut is_empty = false; + match self.idmap.find_mut(&id) { + None => {}, + Some(elements) => { + let position = elements.iter() + .map(|elem| elem.root(&roots)) + .position(|element| &*element == abstract_self) + .expect("This element should be in registered."); + elements.remove(position); + is_empty = elements.is_empty(); + } + } + if is_empty { + self.idmap.remove(&id); + } + } + + /// Associate an element present in this document with the provided id. + pub fn register_named_element(&mut self, + abstract_self: &JSRef, + element: &JSRef, + id: DOMString) { + let roots = RootCollection::new(); + assert!({ + let node: &JSRef = NodeCast::from_ref(element); + node.is_in_doc() + }); + + // FIXME https://github.com/mozilla/rust/issues/13195 + // Use mangle() when it exists again. + let root = abstract_self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root(&roots); + match self.idmap.find_mut(&id) { + Some(elements) => { + let new_node: &JSRef = NodeCast::from_ref(element); + let mut head : uint = 0u; + let root: &JSRef = NodeCast::from_ref(&*root); + for node in root.traverse_preorder(&roots) { + let elem: Option<&JSRef> = ElementCast::to_ref(&node); + match elem { + Some(elem) => { + if elements.get(head) == &elem.unrooted() { + head = head + 1; + } + if new_node == &node || head == elements.len() { + break; + } + } + None => {} + } + } + elements.insert(head, element.unrooted()); + return; + }, + None => (), + } + self.idmap.insert(id, vec!(element.unrooted())); } } @@ -151,9 +237,87 @@ impl Reflectable for Document { } } -impl Document { +trait DocumentHelpers { + fn createNodeList(&self, callback: |node: &JSRef| -> bool) -> Unrooted; + fn get_html_element(&self) -> Option>; +} + +impl<'a> DocumentHelpers for JSRef<'a, Document> { + fn createNodeList(&self, callback: |node: &JSRef| -> bool) -> Unrooted { + let roots = RootCollection::new(); + let window = self.window.root(&roots); + + let mut nodes = vec!(); + match self.GetDocumentElement().root(&roots) { + None => {}, + Some(root) => { + let root: &JSRef = NodeCast::from_ref(&*root); + for child in root.traverse_preorder(&roots) { + if callback(&child) { + nodes.push(child); + } + } + } + } + + NodeList::new_simple_list(&*window, nodes) + } + + fn get_html_element(&self) -> Option> { + let roots = RootCollection::new(); + self.GetDocumentElement().root(&roots).filtered(|root| { + root.node.type_id == ElementNodeTypeId(HTMLHtmlElementTypeId) + }).map(|elem| { + Unrooted::new_rooted(HTMLHtmlElementCast::to_ref(&*elem).unwrap()) + }) + } +} + +pub trait DocumentMethods { + fn Implementation(&mut self) -> Unrooted; + fn URL(&self) -> DOMString; + fn DocumentURI(&self) -> DOMString; + fn CompatMode(&self) -> DOMString; + fn CharacterSet(&self) -> DOMString; + fn ContentType(&self) -> DOMString; + fn GetDoctype(&self) -> Option>; + fn GetDocumentElement(&self) -> Option>; + fn GetElementsByTagName(&self, abstract_self: &JSRef, tag_name: DOMString) -> Unrooted; + fn GetElementsByTagNameNS(&self, abstract_self: &JSRef, maybe_ns: Option, tag_name: DOMString) -> Unrooted; + fn GetElementsByClassName(&self, abstract_self: &JSRef, classes: DOMString) -> Unrooted; + fn GetElementById(&self, id: DOMString) -> Option>; + fn CreateElement(&self, abstract_self: &JSRef, local_name: DOMString) -> Fallible>; + fn CreateElementNS(&self, abstract_self: &JSRef, + namespace: Option, + qualified_name: DOMString) -> Fallible>; + fn CreateDocumentFragment(&self, abstract_self: &JSRef) -> Unrooted; + fn CreateTextNode(&self, abstract_self: &JSRef, data: DOMString) -> Unrooted; + fn CreateComment(&self, abstract_self: &JSRef, data: DOMString) -> Unrooted; + fn CreateProcessingInstruction(&self, abstract_self: &JSRef, target: DOMString, data: DOMString) -> Fallible>; + fn ImportNode(&self, abstract_self: &JSRef, node: &JSRef, deep: bool) -> Fallible>; + fn AdoptNode(&self, abstract_self: &JSRef, node: &mut JSRef) -> Fallible>; + fn CreateEvent(&self, interface: DOMString) -> Fallible>; + fn Title(&self, _: &JSRef) -> DOMString; + fn SetTitle(&self, abstract_self: &JSRef, title: DOMString) -> ErrorResult; + fn GetHead(&self) -> Option>; + fn GetBody(&self, _: &JSRef) -> Option>; + fn SetBody(&self, abstract_self: &JSRef, new_body: Option>) -> ErrorResult; + fn GetElementsByName(&self, name: DOMString) -> Unrooted; + fn Images(&self, abstract_self: &JSRef) -> Unrooted; + fn Embeds(&self, abstract_self: &JSRef) -> Unrooted; + fn Plugins(&self, abstract_self: &JSRef) -> Unrooted; + fn Links(&self, abstract_self: &JSRef) -> Unrooted; + fn Forms(&self, abstract_self: &JSRef) -> Unrooted; + fn Scripts(&self, abstract_self: &JSRef) -> Unrooted; + fn Anchors(&self, abstract_self: &JSRef) -> Unrooted; + fn Applets(&self, abstract_self: &JSRef) -> Unrooted; + fn Location(&mut self, _abstract_self: &JSRef) -> Unrooted; + fn Children(&self, abstract_self: &JSRef) -> Unrooted; +} + +impl<'a> DocumentMethods for JSRef<'a, Document> { // http://dom.spec.whatwg.org/#dom-document-implementation - pub fn Implementation(&mut self) -> Unrooted { + fn Implementation(&mut self) -> Unrooted { if self.implementation.is_none() { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -163,47 +327,35 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-url - pub fn URL(&self) -> DOMString { + fn URL(&self) -> DOMString { self.url().to_str() } // http://dom.spec.whatwg.org/#dom-document-documenturi - pub fn DocumentURI(&self) -> DOMString { + fn DocumentURI(&self) -> DOMString { self.URL() } // http://dom.spec.whatwg.org/#dom-document-compatmode - pub fn CompatMode(&self) -> DOMString { + fn CompatMode(&self) -> DOMString { match *self.quirks_mode { NoQuirks => ~"CSS1Compat", LimitedQuirks | FullQuirks => ~"BackCompat" } } - pub fn quirks_mode(&self) -> QuirksMode { - *self.quirks_mode - } - - pub fn set_quirks_mode(&mut self, mode: QuirksMode) { - *self.quirks_mode = mode; - } - // http://dom.spec.whatwg.org/#dom-document-characterset - pub fn CharacterSet(&self) -> DOMString { + fn CharacterSet(&self) -> DOMString { self.encoding_name.to_ascii_lower() } - pub fn set_encoding_name(&mut self, name: DOMString) { - self.encoding_name = name; - } - // http://dom.spec.whatwg.org/#dom-document-content_type - pub fn ContentType(&self) -> DOMString { + fn ContentType(&self) -> DOMString { self.content_type.clone() } // http://dom.spec.whatwg.org/#dom-document-doctype - pub fn GetDoctype(&self) -> Option> { + fn GetDoctype(&self) -> Option> { self.node.children().find(|child| { child.is_doctype() }).map(|node| { @@ -213,19 +365,19 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-documentelement - pub fn GetDocumentElement(&self) -> Option> { + fn GetDocumentElement(&self) -> Option> { self.node.child_elements().next().map(|elem| Unrooted::new_rooted(&elem)) } // http://dom.spec.whatwg.org/#dom-document-getelementsbytagname - pub fn GetElementsByTagName(&self, abstract_self: &JSRef, tag_name: DOMString) -> Unrooted { + fn GetElementsByTagName(&self, abstract_self: &JSRef, tag_name: DOMString) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); HTMLCollection::by_tag_name(&*window, NodeCast::from_ref(abstract_self), tag_name) } // http://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens - pub fn GetElementsByTagNameNS(&self, abstract_self: &JSRef, maybe_ns: Option, tag_name: DOMString) -> Unrooted { + fn GetElementsByTagNameNS(&self, abstract_self: &JSRef, maybe_ns: Option, tag_name: DOMString) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -237,7 +389,7 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-getelementsbyclassname - pub fn GetElementsByClassName(&self, abstract_self: &JSRef, classes: DOMString) -> Unrooted { + fn GetElementsByClassName(&self, abstract_self: &JSRef, classes: DOMString) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -245,7 +397,7 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid - pub fn GetElementById(&self, id: DOMString) -> Option> { + fn GetElementById(&self, id: DOMString) -> Option> { match self.idmap.find_equiv(&id) { None => None, Some(ref elements) => Some(Unrooted::new(elements.get(0).clone())), @@ -253,7 +405,7 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-createelement - pub fn CreateElement(&self, abstract_self: &JSRef, local_name: DOMString) + fn CreateElement(&self, abstract_self: &JSRef, local_name: DOMString) -> Fallible> { if xml_name_type(local_name) == InvalidXMLName { debug!("Not a valid element name"); @@ -264,9 +416,9 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-createelementns - pub fn CreateElementNS(&self, abstract_self: &JSRef, - namespace: Option, - qualified_name: DOMString) -> Fallible> { + fn CreateElementNS(&self, abstract_self: &JSRef, + namespace: Option, + qualified_name: DOMString) -> Fallible> { let ns = Namespace::from_str(null_str_as_empty_ref(&namespace)); match xml_name_type(qualified_name) { InvalidXMLName => { @@ -310,23 +462,23 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-createdocumentfragment - pub fn CreateDocumentFragment(&self, abstract_self: &JSRef) -> Unrooted { + fn CreateDocumentFragment(&self, abstract_self: &JSRef) -> Unrooted { DocumentFragment::new(abstract_self) } // http://dom.spec.whatwg.org/#dom-document-createtextnode - pub fn CreateTextNode(&self, abstract_self: &JSRef, data: DOMString) + fn CreateTextNode(&self, abstract_self: &JSRef, data: DOMString) -> Unrooted { Text::new(data, abstract_self) } // http://dom.spec.whatwg.org/#dom-document-createcomment - pub fn CreateComment(&self, abstract_self: &JSRef, data: DOMString) -> Unrooted { + fn CreateComment(&self, abstract_self: &JSRef, data: DOMString) -> Unrooted { Comment::new(data, abstract_self) } // http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction - pub fn CreateProcessingInstruction(&self, abstract_self: &JSRef, target: DOMString, + fn CreateProcessingInstruction(&self, abstract_self: &JSRef, target: DOMString, data: DOMString) -> Fallible> { // Step 1. if xml_name_type(target) == InvalidXMLName { @@ -343,7 +495,7 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-importnode - pub fn ImportNode(&self, abstract_self: &JSRef, node: &JSRef, deep: bool) -> Fallible> { + fn ImportNode(&self, abstract_self: &JSRef, node: &JSRef, deep: bool) -> Fallible> { // Step 1. if node.is_document() { return Err(NotSupported); @@ -359,7 +511,7 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-adoptnode - pub fn AdoptNode(&self, abstract_self: &JSRef, node: &mut JSRef) -> Fallible> { + fn AdoptNode(&self, abstract_self: &JSRef, node: &mut JSRef) -> Fallible> { // Step 1. if node.is_document() { return Err(NotSupported); @@ -373,7 +525,7 @@ impl Document { } // http://dom.spec.whatwg.org/#dom-document-createevent - pub fn CreateEvent(&self, interface: DOMString) -> Fallible> { + fn CreateEvent(&self, interface: DOMString) -> Fallible> { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -387,7 +539,7 @@ impl Document { } // http://www.whatwg.org/specs/web-apps/current-work/#document.title - pub fn Title(&self, _: &JSRef) -> DOMString { + fn Title(&self, _: &JSRef) -> DOMString { let mut title = ~""; let roots = RootCollection::new(); self.GetDocumentElement().root(&roots).map(|root| { @@ -409,7 +561,7 @@ impl Document { } // http://www.whatwg.org/specs/web-apps/current-work/#document.title - pub fn SetTitle(&self, abstract_self: &JSRef, title: DOMString) -> ErrorResult { + fn SetTitle(&self, abstract_self: &JSRef, title: DOMString) -> ErrorResult { let roots = RootCollection::new(); self.GetDocumentElement().root(&roots).map(|root| { @@ -446,17 +598,8 @@ impl Document { Ok(()) } - fn get_html_element(&self) -> Option> { - let roots = RootCollection::new(); - self.GetDocumentElement().root(&roots).filtered(|root| { - root.node.type_id == ElementNodeTypeId(HTMLHtmlElementTypeId) - }).map(|elem| { - Unrooted::new_rooted(HTMLHtmlElementCast::to_ref(&*elem).unwrap()) - }) - } - // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head - pub fn GetHead(&self) -> Option> { + fn GetHead(&self) -> Option> { let roots = RootCollection::new(); self.get_html_element().and_then(|root| { let root = root.root(&roots); @@ -470,7 +613,7 @@ impl Document { } // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body - pub fn GetBody(&self, _: &JSRef) -> Option> { + fn GetBody(&self, _: &JSRef) -> Option> { let roots = RootCollection::new(); self.get_html_element().and_then(|root| { let root = root.root(&roots); @@ -488,7 +631,7 @@ impl Document { } // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body - pub fn SetBody(&self, abstract_self: &JSRef, new_body: Option>) -> ErrorResult { + fn SetBody(&self, abstract_self: &JSRef, new_body: Option>) -> ErrorResult { let roots = RootCollection::new(); // Step 1. @@ -532,7 +675,7 @@ impl Document { } // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-getelementsbyname - pub fn GetElementsByName(&self, name: DOMString) -> Unrooted { + fn GetElementsByName(&self, name: DOMString) -> Unrooted { let roots = RootCollection::new(); self.createNodeList(|node| { @@ -547,7 +690,7 @@ impl Document { }) } - pub fn Images(&self, abstract_self: &JSRef) -> Unrooted { + fn Images(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -562,7 +705,7 @@ impl Document { HTMLCollection::create(&*window, NodeCast::from_ref(abstract_self), filter) } - pub fn Embeds(&self, abstract_self: &JSRef) -> Unrooted { + fn Embeds(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -577,12 +720,12 @@ impl Document { HTMLCollection::create(&*window, NodeCast::from_ref(abstract_self), filter) } - pub fn Plugins(&self, abstract_self: &JSRef) -> Unrooted { + fn Plugins(&self, abstract_self: &JSRef) -> Unrooted { // FIXME: https://github.com/mozilla/servo/issues/1847 self.Embeds(abstract_self) } - pub fn Links(&self, abstract_self: &JSRef) -> Unrooted { + fn Links(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -598,7 +741,7 @@ impl Document { HTMLCollection::create(&*window, NodeCast::from_ref(abstract_self), filter) } - pub fn Forms(&self, abstract_self: &JSRef) -> Unrooted { + fn Forms(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -613,7 +756,7 @@ impl Document { HTMLCollection::create(&*window, NodeCast::from_ref(abstract_self), filter) } - pub fn Scripts(&self, abstract_self: &JSRef) -> Unrooted { + fn Scripts(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -628,7 +771,7 @@ impl Document { HTMLCollection::create(&*window, NodeCast::from_ref(abstract_self), filter) } - pub fn Anchors(&self, abstract_self: &JSRef) -> Unrooted { + fn Anchors(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -643,7 +786,7 @@ impl Document { HTMLCollection::create(&*window, NodeCast::from_ref(abstract_self), filter) } - pub fn Applets(&self, abstract_self: &JSRef) -> Unrooted { + fn Applets(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); @@ -658,113 +801,16 @@ impl Document { HTMLCollection::create(&*window, NodeCast::from_ref(abstract_self), filter) } - pub fn Location(&mut self, _abstract_self: &JSRef) -> Unrooted { + fn Location(&mut self, _abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let mut window = self.window.root(&roots); let window_alias = self.window.root(&roots); - window.get_mut().Location(&*window_alias) + window.Location(&*window_alias) } - pub fn Children(&self, abstract_self: &JSRef) -> Unrooted { + fn Children(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); HTMLCollection::children(&*window, NodeCast::from_ref(abstract_self)) } - - pub fn createNodeList(&self, callback: |node: &JSRef| -> bool) -> Unrooted { - let roots = RootCollection::new(); - let window = self.window.root(&roots); - - let mut nodes = vec!(); - match self.GetDocumentElement().root(&roots) { - None => {}, - Some(root) => { - let root: &JSRef = NodeCast::from_ref(&*root); - for child in root.traverse_preorder(&roots) { - if callback(&child) { - nodes.push(child); - } - } - } - } - - NodeList::new_simple_list(&*window, nodes) - } - - pub fn content_changed(&self) { - self.damage_and_reflow(ContentChangedDocumentDamage); - } - - pub fn damage_and_reflow(&self, damage: DocumentDamageLevel) { - let roots = RootCollection::new(); - self.window.root(&roots).damage_and_reflow(damage); - } - - pub fn wait_until_safe_to_modify_dom(&self) { - let roots = RootCollection::new(); - self.window.root(&roots).wait_until_safe_to_modify_dom(); - } - - - /// Remove any existing association between the provided id and any elements in this document. - pub fn unregister_named_element(&mut self, - abstract_self: &JSRef, - id: DOMString) { - let roots = RootCollection::new(); - let mut is_empty = false; - match self.idmap.find_mut(&id) { - None => {}, - Some(elements) => { - let position = elements.iter() - .map(|elem| elem.root(&roots)) - .position(|element| &*element == abstract_self) - .expect("This element should be in registered."); - elements.remove(position); - is_empty = elements.is_empty(); - } - } - if is_empty { - self.idmap.remove(&id); - } - } - - /// Associate an element present in this document with the provided id. - pub fn register_named_element(&mut self, - element: &JSRef, - id: DOMString) { - let roots = RootCollection::new(); - assert!({ - let node: &JSRef = NodeCast::from_ref(element); - node.is_in_doc() - }); - - // FIXME https://github.com/mozilla/rust/issues/13195 - // Use mangle() when it exists again. - let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root(&roots); - match self.idmap.find_mut(&id) { - Some(elements) => { - let new_node: &JSRef = NodeCast::from_ref(element); - let mut head : uint = 0u; - let root: &JSRef = NodeCast::from_ref(&*root); - for node in root.traverse_preorder(&roots) { - let elem: Option<&JSRef> = ElementCast::to_ref(&node); - match elem { - Some(elem) => { - if elements.get(head) == &elem.unrooted() { - head = head + 1; - } - if new_node == &node || head == elements.len() { - break; - } - } - None => {} - } - } - elements.insert(head, element.unrooted()); - return; - }, - None => (), - } - self.idmap.insert(id, vec!(element.unrooted())); - } } diff --git a/src/components/script/dom/documentfragment.rs b/src/components/script/dom/documentfragment.rs index 629b68ffdec..aee61d03b51 100644 --- a/src/components/script/dom/documentfragment.rs +++ b/src/components/script/dom/documentfragment.rs @@ -10,7 +10,7 @@ use dom::document::Document; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::htmlcollection::HTMLCollection; use dom::node::{DocumentFragmentNodeTypeId, Node, window_from_node}; -use dom::window::Window; +use dom::window::{Window, WindowMethods}; #[deriving(Encodable)] pub struct DocumentFragment { @@ -38,20 +38,22 @@ impl DocumentFragment { let node = DocumentFragment::new_inherited(document.unrooted()); Node::reflect_node(~node, document, DocumentFragmentBinding::Wrap) } -} -impl DocumentFragment { pub fn Constructor(owner: &JSRef) -> Fallible> { let roots = RootCollection::new(); - let document = owner.get().Document(); + let document = owner.Document(); let document = document.root(&roots); Ok(DocumentFragment::new(&document.root_ref())) } } -impl DocumentFragment { - pub fn Children(&self, abstract_self: &JSRef) -> Unrooted { +pub trait DocumentFragmentMethods { + fn Children(&self, abstract_self: &JSRef) -> Unrooted; +} + +impl<'a> DocumentFragmentMethods for JSRef<'a, DocumentFragment> { + fn Children(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = window_from_node(abstract_self).root(&roots); HTMLCollection::children(&window.root_ref(), NodeCast::from_ref(abstract_self)) diff --git a/src/components/script/dom/documenttype.rs b/src/components/script/dom/documenttype.rs index 21b1a784456..26772db65ec 100644 --- a/src/components/script/dom/documenttype.rs +++ b/src/components/script/dom/documenttype.rs @@ -55,16 +55,23 @@ impl DocumentType { } } -impl DocumentType { - pub fn Name(&self) -> DOMString { +pub trait DocumentTypeMethods { + fn Name(&self) -> DOMString; + fn PublicId(&self) -> DOMString; + fn SystemId(&self) -> DOMString; +} + +impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> { + fn Name(&self) -> DOMString { self.name.clone() } - pub fn PublicId(&self) -> DOMString { + fn PublicId(&self) -> DOMString { self.public_id.clone() } - pub fn SystemId(&self) -> DOMString { + fn SystemId(&self) -> DOMString { self.system_id.clone() } } + diff --git a/src/components/script/dom/domexception.rs b/src/components/script/dom/domexception.rs index 08a8c364deb..78d43b047f1 100644 --- a/src/components/script/dom/domexception.rs +++ b/src/components/script/dom/domexception.rs @@ -64,9 +64,15 @@ impl Reflectable for DOMException { } } -impl DOMException { +pub trait DOMExceptionMethods { + fn Code(&self) -> u16; + fn Name(&self) -> DOMString; + fn Message(&self) -> DOMString; +} + +impl<'a> DOMExceptionMethods for JSRef<'a, DOMException> { // http://dom.spec.whatwg.org/#dom-domexception-code - pub fn Code(&self) -> u16 { + fn Code(&self) -> u16 { match self.code { // http://dom.spec.whatwg.org/#concept-throw EncodingError => 0, @@ -75,12 +81,12 @@ impl DOMException { } // http://dom.spec.whatwg.org/#error-names-0 - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { self.code.to_str() } // http://dom.spec.whatwg.org/#error-names-0 - pub fn Message(&self) -> DOMString { + fn Message(&self) -> DOMString { match self.code { IndexSizeError => ~"The index is not in the allowed range.", HierarchyRequestError => ~"The operation would yield an incorrect node tree.", diff --git a/src/components/script/dom/domimplementation.rs b/src/components/script/dom/domimplementation.rs index 0e824306343..a8f889ddd8c 100644 --- a/src/components/script/dom/domimplementation.rs +++ b/src/components/script/dom/domimplementation.rs @@ -8,7 +8,7 @@ use dom::bindings::js::{JS, JSRef, RootCollection, Unrooted, OptionalRootable}; use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object}; use dom::bindings::error::{Fallible, InvalidCharacter, NamespaceError}; use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type}; -use dom::document::{Document, HTMLDocument, NonHTMLDocument}; +use dom::document::{Document, HTMLDocument, NonHTMLDocument, DocumentMethods}; use dom::documenttype::DocumentType; use dom::htmlbodyelement::HTMLBodyElement; use dom::htmlheadelement::HTMLHeadElement; @@ -16,7 +16,7 @@ use dom::htmlhtmlelement::HTMLHtmlElement; use dom::htmltitleelement::HTMLTitleElement; use dom::node::{Node, AppendChild}; use dom::text::Text; -use dom::window::Window; +use dom::window::{Window, WindowMethods}; use servo_util::str::DOMString; #[deriving(Encodable)] @@ -49,10 +49,17 @@ impl Reflectable for DOMImplementation { } } +pub trait DOMImplementationMethods { + fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible>; + fn CreateDocument(&self, namespace: Option, qname: DOMString, + mut maybe_doctype: Option>) -> Fallible>; + fn CreateHTMLDocument(&self, title: Option) -> Unrooted; +} + // http://dom.spec.whatwg.org/#domimplementation -impl DOMImplementation { +impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> { // http://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype - pub fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible> { + fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible> { let roots = RootCollection::new(); match xml_name_type(qname) { // Step 1. @@ -69,8 +76,8 @@ impl DOMImplementation { } // http://dom.spec.whatwg.org/#dom-domimplementation-createdocument - pub fn CreateDocument(&self, namespace: Option, qname: DOMString, - mut maybe_doctype: Option>) -> Fallible> { + fn CreateDocument(&self, namespace: Option, qname: DOMString, + mut maybe_doctype: Option>) -> Fallible> { let roots = RootCollection::new(); let win = self.owner.root(&roots); @@ -80,7 +87,7 @@ impl DOMImplementation { let mut maybe_elem = if qname.is_empty() { None } else { - match doc.get().CreateElementNS(&*doc, namespace, qname) { + match doc.deref().CreateElementNS(&*doc, namespace, qname) { Err(error) => return Err(error), Ok(elem) => Some(elem) } @@ -114,7 +121,7 @@ impl DOMImplementation { } // http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument - pub fn CreateHTMLDocument(&self, title: Option) -> Unrooted { + fn CreateHTMLDocument(&self, title: Option) -> Unrooted { let roots = RootCollection::new(); let owner = self.owner.root(&roots); diff --git a/src/components/script/dom/domparser.rs b/src/components/script/dom/domparser.rs index 6d77273e11e..9f8785e6fd7 100644 --- a/src/components/script/dom/domparser.rs +++ b/src/components/script/dom/domparser.rs @@ -33,11 +33,17 @@ impl DOMParser { pub fn Constructor(owner: &JSRef) -> Fallible> { Ok(DOMParser::new(owner)) } +} - pub fn ParseFromString(&self, - _s: DOMString, - ty: DOMParserBinding::SupportedType) - -> Fallible> { +pub trait DOMParserMethods { + fn ParseFromString(&self, _s: DOMString, ty: DOMParserBinding::SupportedType) -> Fallible>; +} + +impl<'a> DOMParserMethods for JSRef<'a, DOMParser> { + fn ParseFromString(&self, + _s: DOMString, + ty: DOMParserBinding::SupportedType) + -> Fallible> { let roots = RootCollection::new(); let owner = self.owner.root(&roots); match ty { diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index a3bdeb22d3e..2a66aec0221 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -4,7 +4,7 @@ //! Element nodes. -use dom::attr::{Attr, ReplacedAttr, FirstSetAttr}; +use dom::attr::{Attr, ReplacedAttr, FirstSetAttr, AttrMethods}; use dom::attrlist::AttrList; use dom::bindings::codegen::BindingDeclarations::ElementBinding; use dom::bindings::codegen::InheritTypes::{ElementDerived, NodeCast}; @@ -458,23 +458,51 @@ impl Element { } } -impl Element { +pub trait ElementMethods { + fn NamespaceURI(&self) -> DOMString; + fn LocalName(&self) -> DOMString; + fn GetPrefix(&self) -> Option; + fn TagName(&self) -> DOMString; + fn Id(&self, abstract_self: &JSRef) -> DOMString; + fn SetId(&mut self, abstract_self: &mut JSRef, id: DOMString); + fn ClassName(&self, abstract_self: &JSRef) -> DOMString; + fn SetClassName(&self, abstract_self: &mut JSRef, class: DOMString); + fn Attributes(&mut self, abstract_self: &JSRef) -> Unrooted; + fn GetAttribute(&self, abstract_self: &JSRef, name: DOMString) -> Option; + fn GetAttributeNS(&self, abstract_self: &JSRef, namespace: Option, local_name: DOMString) -> Option; + fn SetAttribute(&self, abstract_self: &mut JSRef, name: DOMString, value: DOMString) -> ErrorResult; + fn SetAttributeNS(&self, abstract_self: &mut JSRef, namespace_url: Option, name: DOMString, value: DOMString) -> ErrorResult; + fn RemoveAttribute(&mut self, abstract_self: &mut JSRef, name: DOMString) -> ErrorResult; + fn RemoveAttributeNS(&mut self, abstract_self: &mut JSRef, namespace: Option, localname: DOMString) -> ErrorResult; + fn HasAttribute(&self, abstract_self: &JSRef, name: DOMString) -> bool; + fn HasAttributeNS(&self, abstract_self: &JSRef, namespace: Option, local_name: DOMString) -> bool; + fn GetElementsByTagName(&self, abstract_self: &JSRef, localname: DOMString) -> Unrooted; + fn GetElementsByTagNameNS(&self, abstract_self: &JSRef, maybe_ns: Option, localname: DOMString) -> Unrooted; + fn GetElementsByClassName(&self, abstract_self: &JSRef, classes: DOMString) -> Unrooted; + fn GetClientRects(&self, abstract_self: &JSRef) -> Unrooted; + fn GetBoundingClientRect(&self, abstract_self: &JSRef) -> Unrooted; + fn GetInnerHTML(&self, abstract_self: &JSRef) -> Fallible; + fn GetOuterHTML(&self, abstract_self: &JSRef) -> Fallible; + fn Children(&self, abstract_self: &JSRef) -> Unrooted; +} + +impl<'a> ElementMethods for JSRef<'a, Element> { // http://dom.spec.whatwg.org/#dom-element-namespaceuri - pub fn NamespaceURI(&self) -> DOMString { + fn NamespaceURI(&self) -> DOMString { self.namespace.to_str().to_owned() } - pub fn LocalName(&self) -> DOMString { + fn LocalName(&self) -> DOMString { self.local_name.clone() } // http://dom.spec.whatwg.org/#dom-element-prefix - pub fn GetPrefix(&self) -> Option { + fn GetPrefix(&self) -> Option { self.prefix.clone() } // http://dom.spec.whatwg.org/#dom-element-tagname - pub fn TagName(&self) -> DOMString { + fn TagName(&self) -> DOMString { match self.prefix { None => { self.local_name.to_ascii_upper() @@ -486,42 +514,42 @@ impl Element { } // http://dom.spec.whatwg.org/#dom-element-id - pub fn Id(&self, abstract_self: &JSRef) -> DOMString { + fn Id(&self, abstract_self: &JSRef) -> DOMString { abstract_self.get_string_attribute("id") } // http://dom.spec.whatwg.org/#dom-element-id - pub fn SetId(&mut self, abstract_self: &mut JSRef, id: DOMString) { + fn SetId(&mut self, abstract_self: &mut JSRef, id: DOMString) { abstract_self.set_string_attribute("id", id); } // http://dom.spec.whatwg.org/#dom-element-classname - pub fn ClassName(&self, abstract_self: &JSRef) -> DOMString { + fn ClassName(&self, abstract_self: &JSRef) -> DOMString { abstract_self.get_string_attribute("class") } // http://dom.spec.whatwg.org/#dom-element-classname - pub fn SetClassName(&self, abstract_self: &mut JSRef, class: DOMString) { + fn SetClassName(&self, abstract_self: &mut JSRef, class: DOMString) { abstract_self.set_string_attribute("class", class); } // http://dom.spec.whatwg.org/#dom-element-attributes - pub fn Attributes(&mut self, abstract_self: &JSRef) -> Unrooted { + fn Attributes(&mut self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); match self.attr_list { - None => { - let doc = self.node.owner_doc().root(&roots); - let window = doc.deref().window.root(&roots); - let list = AttrList::new(&window.root_ref(), abstract_self); - self.attr_list.assign(Some(list)); - Unrooted::new(self.attr_list.get_ref().clone()) - } - Some(ref list) => Unrooted::new(list.clone()) + None => (), + Some(ref list) => return Unrooted::new(list.clone()), } + + let doc = self.node.owner_doc().root(&roots); + let window = doc.deref().window.root(&roots); + let list = AttrList::new(&window.root_ref(), abstract_self); + self.attr_list.assign(Some(list)); + Unrooted::new(self.attr_list.get_ref().clone()) } // http://dom.spec.whatwg.org/#dom-element-getattribute - pub fn GetAttribute(&self, abstract_self: &JSRef, name: DOMString) -> Option { + fn GetAttribute(&self, abstract_self: &JSRef, name: DOMString) -> Option { let roots = RootCollection::new(); let name = if abstract_self.get().html_element_in_html_document() { name.to_ascii_lower() @@ -533,7 +561,7 @@ impl Element { } // http://dom.spec.whatwg.org/#dom-element-getattributens - pub fn GetAttributeNS(&self, abstract_self: &JSRef, + fn GetAttributeNS(&self, abstract_self: &JSRef, namespace: Option, local_name: DOMString) -> Option { let roots = RootCollection::new(); @@ -543,25 +571,25 @@ impl Element { } // http://dom.spec.whatwg.org/#dom-element-setattribute - pub fn SetAttribute(&self, abstract_self: &mut JSRef, - name: DOMString, - value: DOMString) -> ErrorResult { + fn SetAttribute(&self, abstract_self: &mut JSRef, + name: DOMString, + value: DOMString) -> ErrorResult { abstract_self.SetAttribute_(name, value) } // http://dom.spec.whatwg.org/#dom-element-setattributens - pub fn SetAttributeNS(&self, - abstract_self: &mut JSRef, - namespace_url: Option, - name: DOMString, - value: DOMString) -> ErrorResult { + fn SetAttributeNS(&self, + abstract_self: &mut JSRef, + namespace_url: Option, + name: DOMString, + value: DOMString) -> ErrorResult { abstract_self.SetAttributeNS_(namespace_url, name, value) } // http://dom.spec.whatwg.org/#dom-element-removeattribute - pub fn RemoveAttribute(&mut self, - abstract_self: &mut JSRef, - name: DOMString) -> ErrorResult { + fn RemoveAttribute(&mut self, + abstract_self: &mut JSRef, + name: DOMString) -> ErrorResult { let name = if self.html_element_in_html_document() { name.to_ascii_lower() } else { @@ -571,7 +599,7 @@ impl Element { } // http://dom.spec.whatwg.org/#dom-element-removeattributens - pub fn RemoveAttributeNS(&mut self, + fn RemoveAttributeNS(&mut self, abstract_self: &mut JSRef, namespace: Option, localname: DOMString) -> ErrorResult { @@ -580,25 +608,25 @@ impl Element { } // http://dom.spec.whatwg.org/#dom-element-hasattribute - pub fn HasAttribute(&self, abstract_self: &JSRef, + fn HasAttribute(&self, abstract_self: &JSRef, name: DOMString) -> bool { self.GetAttribute(abstract_self, name).is_some() } // http://dom.spec.whatwg.org/#dom-element-hasattributens - pub fn HasAttributeNS(&self, abstract_self: &JSRef, + fn HasAttributeNS(&self, abstract_self: &JSRef, namespace: Option, local_name: DOMString) -> bool { self.GetAttributeNS(abstract_self, namespace, local_name).is_some() } - pub fn GetElementsByTagName(&self, abstract_self: &JSRef, localname: DOMString) -> Unrooted { + fn GetElementsByTagName(&self, abstract_self: &JSRef, localname: DOMString) -> Unrooted { let roots = RootCollection::new(); let window = window_from_node(abstract_self).root(&roots); HTMLCollection::by_tag_name(&*window, NodeCast::from_ref(abstract_self), localname) } - pub fn GetElementsByTagNameNS(&self, abstract_self: &JSRef, maybe_ns: Option, + fn GetElementsByTagNameNS(&self, abstract_self: &JSRef, maybe_ns: Option, localname: DOMString) -> Unrooted { let roots = RootCollection::new(); let namespace = match maybe_ns { @@ -609,14 +637,14 @@ impl Element { HTMLCollection::by_tag_name_ns(&*window, NodeCast::from_ref(abstract_self), localname, namespace) } - pub fn GetElementsByClassName(&self, abstract_self: &JSRef, classes: DOMString) -> Unrooted { + fn GetElementsByClassName(&self, abstract_self: &JSRef, classes: DOMString) -> Unrooted { let roots = RootCollection::new(); let window = window_from_node(abstract_self).root(&roots); HTMLCollection::by_class_name(&*window, NodeCast::from_ref(abstract_self), classes) } // http://dev.w3.org/csswg/cssom-view/#dom-element-getclientrects - pub fn GetClientRects(&self, abstract_self: &JSRef) -> Unrooted { + fn GetClientRects(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let win = window_from_node(abstract_self).root(&roots); let node: &JSRef = NodeCast::from_ref(abstract_self); @@ -634,7 +662,7 @@ impl Element { } // http://dev.w3.org/csswg/cssom-view/#dom-element-getboundingclientrect - pub fn GetBoundingClientRect(&self, abstract_self: &JSRef) -> Unrooted { + fn GetBoundingClientRect(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let win = window_from_node(abstract_self).root(&roots); let node: &JSRef = NodeCast::from_ref(abstract_self); @@ -647,18 +675,18 @@ impl Element { rect.origin.x + rect.size.width) } - pub fn GetInnerHTML(&self, abstract_self: &JSRef) -> Fallible { + fn GetInnerHTML(&self, abstract_self: &JSRef) -> Fallible { //XXX TODO: XML case let roots = RootCollection::new(); Ok(serialize(&mut NodeIterator::new(&roots, NodeCast::from_ref(abstract_self), false, false))) } - pub fn GetOuterHTML(&self, abstract_self: &JSRef) -> Fallible { + fn GetOuterHTML(&self, abstract_self: &JSRef) -> Fallible { let roots = RootCollection::new(); Ok(serialize(&mut NodeIterator::new(&roots, NodeCast::from_ref(abstract_self), true, false))) } - pub fn Children(&self, abstract_self: &JSRef) -> Unrooted { + fn Children(&self, abstract_self: &JSRef) -> Unrooted { let roots = RootCollection::new(); let window = window_from_node(abstract_self).root(&roots); HTMLCollection::children(&window.root_ref(), NodeCast::from_ref(abstract_self)) @@ -701,7 +729,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> { let node: &JSRef = NodeCast::from_ref(self); if node.is_in_doc() { let mut doc = document_from_node(self).root(&roots); - doc.register_named_element(self, value.clone()); + let doc_alias = (*doc).clone(); + doc.register_named_element(&doc_alias, self, value.clone()); } } _ => () @@ -744,7 +773,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> { match self.get_attribute(Null, "id").root(&roots) { Some(attr) => { let mut doc = document_from_node(self).root(&roots); - doc.register_named_element(self, attr.deref().Value()); + let doc_alias = (*doc).clone(); + doc.register_named_element(&doc_alias, self, attr.deref().Value()); } _ => () } diff --git a/src/components/script/dom/event.rs b/src/components/script/dom/event.rs index 68f83a5d509..08fdc818ed6 100644 --- a/src/components/script/dom/event.rs +++ b/src/components/script/dom/event.rs @@ -86,54 +86,81 @@ impl Event { EventBinding::Wrap) } - pub fn EventPhase(&self) -> u16 { + pub fn Constructor(global: &JSRef, + type_: DOMString, + init: &EventBinding::EventInit) -> Fallible> { + let roots = RootCollection::new(); + let mut ev = Event::new(global).root(&roots); + ev.InitEvent(type_, init.bubbles, init.cancelable); + Ok(Unrooted::new_rooted(&*ev)) + } +} + +pub trait EventMethods { + fn EventPhase(&self) -> u16; + fn Type(&self) -> DOMString; + fn GetTarget(&self) -> Option>; + fn GetCurrentTarget(&self) -> Option>; + fn DefaultPrevented(&self) -> bool; + fn PreventDefault(&mut self); + fn StopPropagation(&mut self); + fn StopImmediatePropagation(&mut self); + fn Bubbles(&self) -> bool; + fn Cancelable(&self) -> bool; + fn TimeStamp(&self) -> u64; + fn InitEvent(&mut self, type_: DOMString, bubbles: bool, cancelable: bool); + fn IsTrusted(&self) -> bool; +} + +impl<'a> EventMethods for JSRef<'a, Event> { + fn EventPhase(&self) -> u16 { self.phase as u16 } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { self.type_.clone() } - pub fn GetTarget(&self) -> Option> { + fn GetTarget(&self) -> Option> { self.target.as_ref().map(|target| Unrooted::new(target.clone())) } - pub fn GetCurrentTarget(&self) -> Option> { + fn GetCurrentTarget(&self) -> Option> { self.current_target.as_ref().map(|target| Unrooted::new(target.clone())) } - pub fn DefaultPrevented(&self) -> bool { + fn DefaultPrevented(&self) -> bool { self.canceled } - pub fn PreventDefault(&mut self) { + fn PreventDefault(&mut self) { if self.cancelable { self.canceled = true } } - pub fn StopPropagation(&mut self) { + fn StopPropagation(&mut self) { self.stop_propagation = true; } - pub fn StopImmediatePropagation(&mut self) { + fn StopImmediatePropagation(&mut self) { self.stop_immediate = true; self.stop_propagation = true; } - pub fn Bubbles(&self) -> bool { + fn Bubbles(&self) -> bool { self.bubbles } - pub fn Cancelable(&self) -> bool { + fn Cancelable(&self) -> bool { self.cancelable } - pub fn TimeStamp(&self) -> u64 { + fn TimeStamp(&self) -> u64 { self.timestamp } - pub fn InitEvent(&mut self, + fn InitEvent(&mut self, type_: DOMString, bubbles: bool, cancelable: bool) { @@ -151,18 +178,9 @@ impl Event { self.cancelable = cancelable; } - pub fn IsTrusted(&self) -> bool { + fn IsTrusted(&self) -> bool { self.trusted } - - pub fn Constructor(global: &JSRef, - type_: DOMString, - init: &EventBinding::EventInit) -> Fallible> { - let roots = RootCollection::new(); - let mut ev = Event::new(global).root(&roots); - ev.InitEvent(type_, init.bubbles, init.cancelable); - Ok(Unrooted::new_rooted(&*ev)) - } } impl Reflectable for Event { diff --git a/src/components/script/dom/eventdispatcher.rs b/src/components/script/dom/eventdispatcher.rs index 9d45b398e02..a70533da2a1 100644 --- a/src/components/script/dom/eventdispatcher.rs +++ b/src/components/script/dom/eventdispatcher.rs @@ -6,7 +6,7 @@ use dom::bindings::callback::ReportExceptions; use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, NodeDerived}; use dom::bindings::js::{JSRef, OptionalAssignable, RootCollection, Root}; use dom::eventtarget::{Capturing, Bubbling, EventTarget}; -use dom::event::{Event, PhaseAtTarget, PhaseNone, PhaseBubbling, PhaseCapturing}; +use dom::event::{Event, PhaseAtTarget, PhaseNone, PhaseBubbling, PhaseCapturing, EventMethods}; use dom::node::{Node, NodeHelpers}; // See http://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm @@ -119,7 +119,6 @@ pub fn dispatch_event<'a>(target: &JSRef<'a, EventTarget>, let _ = chain.pop(); } - let event = event.get_mut(); event.dispatching = false; event.phase = PhaseNone; event.current_target = None; diff --git a/src/components/script/dom/eventtarget.rs b/src/components/script/dom/eventtarget.rs index 67dc0ac7af9..d743a011227 100644 --- a/src/components/script/dom/eventtarget.rs +++ b/src/components/script/dom/eventtarget.rs @@ -65,10 +65,35 @@ impl EventTarget { }) } - pub fn AddEventListener(&mut self, - ty: DOMString, - listener: Option, - capture: bool) { + pub fn dispatch_event_with_target<'a>(&self, + abstract_self: &JSRef<'a, EventTarget>, + abstract_target: Option>, + event: &mut JSRef) -> Fallible { + if event.get().dispatching || !event.get().initialized { + return Err(InvalidState); + } + Ok(dispatch_event(abstract_self, abstract_target, event)) + } +} + +pub trait EventTargetMethods { + fn AddEventListener(&mut self, + ty: DOMString, + listener: Option, + capture: bool); + fn RemoveEventListener(&mut self, + ty: DOMString, + listener: Option, + capture: bool); + fn DispatchEvent(&self, abstract_self: &JSRef, + event: &mut JSRef) -> Fallible; +} + +impl<'a> EventTargetMethods for JSRef<'a, EventTarget> { + fn AddEventListener(&mut self, + ty: DOMString, + listener: Option, + capture: bool) { for &listener in listener.iter() { let entry = self.handlers.find_or_insert_with(ty.clone(), |_| vec!()); let phase = if capture { Capturing } else { Bubbling }; @@ -82,10 +107,10 @@ impl EventTarget { } } - pub fn RemoveEventListener(&mut self, - ty: DOMString, - listener: Option, - capture: bool) { + fn RemoveEventListener(&mut self, + ty: DOMString, + listener: Option, + capture: bool) { for &listener in listener.iter() { let mut entry = self.handlers.find_mut(&ty); for entry in entry.mut_iter() { @@ -102,20 +127,10 @@ impl EventTarget { } } - pub fn DispatchEvent(&self, abstract_self: &JSRef, - event: &mut JSRef) -> Fallible { + fn DispatchEvent(&self, abstract_self: &JSRef, + event: &mut JSRef) -> Fallible { self.dispatch_event_with_target(abstract_self, None, event) } - - pub fn dispatch_event_with_target<'a>(&self, - abstract_self: &JSRef<'a, EventTarget>, - abstract_target: Option>, - event: &mut JSRef) -> Fallible { - if event.get().dispatching || !event.get().initialized { - return Err(InvalidState); - } - Ok(dispatch_event(abstract_self, abstract_target, event)) - } } impl Reflectable for EventTarget { diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs index e1a7b0e7ddb..88be3e4314e 100644 --- a/src/components/script/dom/formdata.rs +++ b/src/components/script/dom/formdata.rs @@ -41,12 +41,18 @@ impl FormData { reflect_dom_object(~FormData::new_inherited(form, window.unrooted()), window, FormDataBinding::Wrap) } - pub fn Constructor(window: &JSRef, form: Option>) - -> Fallible> { + pub fn Constructor(window: &JSRef, form: Option>) -> Fallible> { Ok(FormData::new(form, window)) } +} - pub fn Append(&mut self, name: DOMString, value: &JSRef, filename: Option) { +pub trait FormDataMethods { + fn Append(&mut self, name: DOMString, value: &JSRef, filename: Option); + fn Append_(&mut self, name: DOMString, value: DOMString); +} + +impl<'a> FormDataMethods for JSRef<'a, FormData> { + fn Append(&mut self, name: DOMString, value: &JSRef, filename: Option) { let blob = BlobData { blob: value.unrooted(), name: filename.unwrap_or(~"default") @@ -54,7 +60,7 @@ impl FormData { self.data.insert(name.clone(), blob); } - pub fn Append_(&mut self, name: DOMString, value: DOMString) { + fn Append_(&mut self, name: DOMString, value: DOMString) { self.data.insert(name, StringData(value)); } } diff --git a/src/components/script/dom/htmlanchorelement.rs b/src/components/script/dom/htmlanchorelement.rs index d03723402eb..22e7846269c 100644 --- a/src/components/script/dom/htmlanchorelement.rs +++ b/src/components/script/dom/htmlanchorelement.rs @@ -40,108 +40,137 @@ impl HTMLAnchorElement { } } -impl HTMLAnchorElement { - pub fn Href(&self) -> DOMString { +pub trait HTMLAnchorElementMethods { + fn Href(&self) -> DOMString; + fn SetHref(&mut self, _href: DOMString) -> ErrorResult; + fn Target(&self) -> DOMString; + fn SetTarget(&self, _target: DOMString) -> ErrorResult; + fn Download(&self) -> DOMString; + fn SetDownload(&self, _download: DOMString) -> ErrorResult; + fn Ping(&self) -> DOMString; + fn SetPing(&self, _ping: DOMString) -> ErrorResult; + fn Rel(&self) -> DOMString; + fn SetRel(&self, _rel: DOMString) -> ErrorResult; + fn Hreflang(&self) -> DOMString; + fn SetHreflang(&self, _href_lang: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Text(&self) -> DOMString; + fn SetText(&mut self, _text: DOMString) -> ErrorResult; + fn Coords(&self) -> DOMString; + fn SetCoords(&mut self, _coords: DOMString) -> ErrorResult; + fn Charset(&self) -> DOMString; + fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Rev(&self) -> DOMString; + fn SetRev(&mut self, _rev: DOMString) -> ErrorResult; + fn Shape(&self) -> DOMString; + fn SetShape(&mut self, _shape: DOMString) -> ErrorResult; +} + +impl<'a> HTMLAnchorElementMethods for JSRef<'a, HTMLAnchorElement> { + fn Href(&self) -> DOMString { ~"" } - pub fn SetHref(&mut self, _href: DOMString) -> ErrorResult { + fn SetHref(&mut self, _href: DOMString) -> ErrorResult { Ok(()) } - pub fn Target(&self) -> DOMString { + fn Target(&self) -> DOMString { ~"" } - pub fn SetTarget(&self, _target: DOMString) -> ErrorResult { + fn SetTarget(&self, _target: DOMString) -> ErrorResult { Ok(()) } - pub fn Download(&self) -> DOMString { + fn Download(&self) -> DOMString { ~"" } - pub fn SetDownload(&self, _download: DOMString) -> ErrorResult { + fn SetDownload(&self, _download: DOMString) -> ErrorResult { Ok(()) } - pub fn Ping(&self) -> DOMString { + fn Ping(&self) -> DOMString { ~"" } - pub fn SetPing(&self, _ping: DOMString) -> ErrorResult { + fn SetPing(&self, _ping: DOMString) -> ErrorResult { Ok(()) } - pub fn Rel(&self) -> DOMString { + fn Rel(&self) -> DOMString { ~"" } - pub fn SetRel(&self, _rel: DOMString) -> ErrorResult { + fn SetRel(&self, _rel: DOMString) -> ErrorResult { Ok(()) } - pub fn Hreflang(&self) -> DOMString { + fn Hreflang(&self) -> DOMString { ~"" } - pub fn SetHreflang(&self, _href_lang: DOMString) -> ErrorResult { + fn SetHreflang(&self, _href_lang: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Text(&self) -> DOMString { + fn Text(&self) -> DOMString { ~"" } - pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { + fn SetText(&mut self, _text: DOMString) -> ErrorResult { Ok(()) } - pub fn Coords(&self) -> DOMString { + fn Coords(&self) -> DOMString { ~"" } - pub fn SetCoords(&mut self, _coords: DOMString) -> ErrorResult { + fn SetCoords(&mut self, _coords: DOMString) -> ErrorResult { Ok(()) } - pub fn Charset(&self) -> DOMString { + fn Charset(&self) -> DOMString { ~"" } - pub fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { + fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Rev(&self) -> DOMString { + fn Rev(&self) -> DOMString { ~"" } - pub fn SetRev(&mut self, _rev: DOMString) -> ErrorResult { + fn SetRev(&mut self, _rev: DOMString) -> ErrorResult { Ok(()) } - pub fn Shape(&self) -> DOMString { + fn Shape(&self) -> DOMString { ~"" } - pub fn SetShape(&mut self, _shape: DOMString) -> ErrorResult { + fn SetShape(&mut self, _shape: DOMString) -> ErrorResult { Ok(()) } } diff --git a/src/components/script/dom/htmlappletelement.rs b/src/components/script/dom/htmlappletelement.rs index ea253003fd4..bcf7481d4d7 100644 --- a/src/components/script/dom/htmlappletelement.rs +++ b/src/components/script/dom/htmlappletelement.rs @@ -40,92 +40,117 @@ impl HTMLAppletElement { } } -impl HTMLAppletElement { - pub fn Align(&self) -> DOMString { +pub trait HTMLAppletElementMethods { + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; + fn Alt(&self) -> DOMString; + fn SetAlt(&self, _alt: DOMString) -> ErrorResult; + fn Archive(&self) -> DOMString; + fn SetArchive(&self, _archive: DOMString) -> ErrorResult; + fn Code(&self) -> DOMString; + fn SetCode(&self, _code: DOMString) -> ErrorResult; + fn CodeBase(&self) -> DOMString; + fn SetCodeBase(&self, _code_base: DOMString) -> ErrorResult; + fn Height(&self) -> DOMString; + fn SetHeight(&self, _height: DOMString) -> ErrorResult; + fn Hspace(&self) -> u32; + fn SetHspace(&mut self, _hspace: u32) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Object(&self) -> DOMString; + fn SetObject(&mut self, _object: DOMString) -> ErrorResult; + fn Vspace(&self) -> u32; + fn SetVspace(&mut self, _vspace: u32) -> ErrorResult; + fn Width(&self) -> DOMString; + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult; +} + +impl<'a> HTMLAppletElementMethods for JSRef<'a, HTMLAppletElement> { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Alt(&self) -> DOMString { + fn Alt(&self) -> DOMString { ~"" } - pub fn SetAlt(&self, _alt: DOMString) -> ErrorResult { + fn SetAlt(&self, _alt: DOMString) -> ErrorResult { Ok(()) } - pub fn Archive(&self) -> DOMString { + fn Archive(&self) -> DOMString { ~"" } - pub fn SetArchive(&self, _archive: DOMString) -> ErrorResult { + fn SetArchive(&self, _archive: DOMString) -> ErrorResult { Ok(()) } - pub fn Code(&self) -> DOMString { + fn Code(&self) -> DOMString { ~"" } - pub fn SetCode(&self, _code: DOMString) -> ErrorResult { + fn SetCode(&self, _code: DOMString) -> ErrorResult { Ok(()) } - pub fn CodeBase(&self) -> DOMString { + fn CodeBase(&self) -> DOMString { ~"" } - pub fn SetCodeBase(&self, _code_base: DOMString) -> ErrorResult { + fn SetCodeBase(&self, _code_base: DOMString) -> ErrorResult { Ok(()) } - pub fn Height(&self) -> DOMString { + fn Height(&self) -> DOMString { ~"" } - pub fn SetHeight(&self, _height: DOMString) -> ErrorResult { + fn SetHeight(&self, _height: DOMString) -> ErrorResult { Ok(()) } - pub fn Hspace(&self) -> u32 { + fn Hspace(&self) -> u32 { 0 } - pub fn SetHspace(&mut self, _hspace: u32) -> ErrorResult { + fn SetHspace(&mut self, _hspace: u32) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Object(&self) -> DOMString { + fn Object(&self) -> DOMString { ~"" } - pub fn SetObject(&mut self, _object: DOMString) -> ErrorResult { + fn SetObject(&mut self, _object: DOMString) -> ErrorResult { Ok(()) } - pub fn Vspace(&self) -> u32 { + fn Vspace(&self) -> u32 { 0 } - pub fn SetVspace(&mut self, _vspace: u32) -> ErrorResult { + fn SetVspace(&mut self, _vspace: u32) -> ErrorResult { Ok(()) } - pub fn Width(&self) -> DOMString { + fn Width(&self) -> DOMString { ~"" } - pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { Ok(()) } } diff --git a/src/components/script/dom/htmlareaelement.rs b/src/components/script/dom/htmlareaelement.rs index d98f2033b77..d22e8a45a67 100644 --- a/src/components/script/dom/htmlareaelement.rs +++ b/src/components/script/dom/htmlareaelement.rs @@ -40,68 +40,87 @@ impl HTMLAreaElement { } } -impl HTMLAreaElement { - pub fn Alt(&self) -> DOMString { +pub trait HTMLAreaElementMethods { + fn Alt(&self) -> DOMString; + fn SetAlt(&self, _alt: DOMString) -> ErrorResult; + fn Coords(&self) -> DOMString; + fn SetCoords(&self, _coords: DOMString) -> ErrorResult; + fn Shape(&self) -> DOMString; + fn SetShape(&self, _shape: DOMString) -> ErrorResult; + fn Href(&self) -> DOMString; + fn SetHref(&self, _href: DOMString) -> ErrorResult; + fn Target(&self) -> DOMString; + fn SetTarget(&self, _target: DOMString) -> ErrorResult; + fn Download(&self) -> DOMString; + fn SetDownload(&self, _download: DOMString) -> ErrorResult; + fn Ping(&self) -> DOMString; + fn SetPing(&self, _ping: DOMString) -> ErrorResult; + fn NoHref(&self) -> bool; + fn SetNoHref(&mut self, _no_href: bool) -> ErrorResult; +} + +impl<'a> HTMLAreaElementMethods for JSRef<'a, HTMLAreaElement> { + fn Alt(&self) -> DOMString { ~"" } - pub fn SetAlt(&self, _alt: DOMString) -> ErrorResult { + fn SetAlt(&self, _alt: DOMString) -> ErrorResult { Ok(()) } - pub fn Coords(&self) -> DOMString { + fn Coords(&self) -> DOMString { ~"" } - pub fn SetCoords(&self, _coords: DOMString) -> ErrorResult { + fn SetCoords(&self, _coords: DOMString) -> ErrorResult { Ok(()) } - pub fn Shape(&self) -> DOMString { + fn Shape(&self) -> DOMString { ~"" } - pub fn SetShape(&self, _shape: DOMString) -> ErrorResult { + fn SetShape(&self, _shape: DOMString) -> ErrorResult { Ok(()) } - pub fn Href(&self) -> DOMString { + fn Href(&self) -> DOMString { ~"" } - pub fn SetHref(&self, _href: DOMString) -> ErrorResult { + fn SetHref(&self, _href: DOMString) -> ErrorResult { Ok(()) } - pub fn Target(&self) -> DOMString { + fn Target(&self) -> DOMString { ~"" } - pub fn SetTarget(&self, _target: DOMString) -> ErrorResult { + fn SetTarget(&self, _target: DOMString) -> ErrorResult { Ok(()) } - pub fn Download(&self) -> DOMString { + fn Download(&self) -> DOMString { ~"" } - pub fn SetDownload(&self, _download: DOMString) -> ErrorResult { + fn SetDownload(&self, _download: DOMString) -> ErrorResult { Ok(()) } - pub fn Ping(&self) -> DOMString { + fn Ping(&self) -> DOMString { ~"" } - pub fn SetPing(&self, _ping: DOMString) -> ErrorResult { + fn SetPing(&self, _ping: DOMString) -> ErrorResult { Ok(()) } - pub fn NoHref(&self) -> bool { + fn NoHref(&self) -> bool { false } - pub fn SetNoHref(&mut self, _no_href: bool) -> ErrorResult { + fn SetNoHref(&mut self, _no_href: bool) -> ErrorResult { Ok(()) } } diff --git a/src/components/script/dom/htmlaudioelement.rs b/src/components/script/dom/htmlaudioelement.rs index a4ea33c7052..7e3826dd4c6 100644 --- a/src/components/script/dom/htmlaudioelement.rs +++ b/src/components/script/dom/htmlaudioelement.rs @@ -38,3 +38,6 @@ impl HTMLAudioElement { Node::reflect_node(~element, document, HTMLAudioElementBinding::Wrap) } } + +pub trait HTMLAudioElementMethods { +} diff --git a/src/components/script/dom/htmlbaseelement.rs b/src/components/script/dom/htmlbaseelement.rs index bfaf1a74410..83cdf3607ac 100644 --- a/src/components/script/dom/htmlbaseelement.rs +++ b/src/components/script/dom/htmlbaseelement.rs @@ -40,20 +40,28 @@ impl HTMLBaseElement { } } -impl HTMLBaseElement { - pub fn Href(&self) -> DOMString { +pub trait HTMLBaseElementMethods { + fn Href(&self) -> DOMString; + fn SetHref(&self, _href: DOMString) -> ErrorResult; + fn Target(&self) -> DOMString; + fn SetTarget(&self, _target: DOMString) -> ErrorResult; +} + +impl<'a> HTMLBaseElementMethods for JSRef<'a, HTMLBaseElement> { + fn Href(&self) -> DOMString { ~"" } - pub fn SetHref(&self, _href: DOMString) -> ErrorResult { + fn SetHref(&self, _href: DOMString) -> ErrorResult { Ok(()) } - pub fn Target(&self) -> DOMString { + fn Target(&self) -> DOMString { ~"" } - pub fn SetTarget(&self, _target: DOMString) -> ErrorResult { + fn SetTarget(&self, _target: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlbodyelement.rs b/src/components/script/dom/htmlbodyelement.rs index 22b41c283ba..cb59f0c6fb4 100644 --- a/src/components/script/dom/htmlbodyelement.rs +++ b/src/components/script/dom/htmlbodyelement.rs @@ -40,52 +40,68 @@ impl HTMLBodyElement { } } -impl HTMLBodyElement { - pub fn Text(&self) -> DOMString { +pub trait HTMLBodyElementMethods { + fn Text(&self) -> DOMString; + fn SetText(&mut self, _text: DOMString) -> ErrorResult; + fn Link(&self) -> DOMString; + fn SetLink(&self, _link: DOMString) -> ErrorResult; + fn VLink(&self) -> DOMString; + fn SetVLink(&self, _v_link: DOMString) -> ErrorResult; + fn ALink(&self) -> DOMString; + fn SetALink(&self, _a_link: DOMString) -> ErrorResult; + fn BgColor(&self) -> DOMString; + fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult; + fn Background(&self) -> DOMString; + fn SetBackground(&self, _background: DOMString) -> ErrorResult; +} + +impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> { + fn Text(&self) -> DOMString { ~"" } - pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { + fn SetText(&mut self, _text: DOMString) -> ErrorResult { Ok(()) } - pub fn Link(&self) -> DOMString { + fn Link(&self) -> DOMString { ~"" } - pub fn SetLink(&self, _link: DOMString) -> ErrorResult { + fn SetLink(&self, _link: DOMString) -> ErrorResult { Ok(()) } - pub fn VLink(&self) -> DOMString { + fn VLink(&self) -> DOMString { ~"" } - pub fn SetVLink(&self, _v_link: DOMString) -> ErrorResult { + fn SetVLink(&self, _v_link: DOMString) -> ErrorResult { Ok(()) } - pub fn ALink(&self) -> DOMString { + fn ALink(&self) -> DOMString { ~"" } - pub fn SetALink(&self, _a_link: DOMString) -> ErrorResult { + fn SetALink(&self, _a_link: DOMString) -> ErrorResult { Ok(()) } - pub fn BgColor(&self) -> DOMString { + fn BgColor(&self) -> DOMString { ~"" } - pub fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { + fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { Ok(()) } - pub fn Background(&self) -> DOMString { + fn Background(&self) -> DOMString { ~"" } - pub fn SetBackground(&self, _background: DOMString) -> ErrorResult { + fn SetBackground(&self, _background: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlbrelement.rs b/src/components/script/dom/htmlbrelement.rs index 5e23734042c..5b06b1467ea 100644 --- a/src/components/script/dom/htmlbrelement.rs +++ b/src/components/script/dom/htmlbrelement.rs @@ -40,12 +40,18 @@ impl HTMLBRElement { } } -impl HTMLBRElement { - pub fn Clear(&self) -> DOMString { +pub trait HTMLBRElementMethods { + fn Clear(&self) -> DOMString; + fn SetClear(&mut self, _text: DOMString) -> ErrorResult; +} + +impl<'a> HTMLBRElementMethods for JSRef<'a, HTMLBRElement> { + fn Clear(&self) -> DOMString { ~"" } - pub fn SetClear(&mut self, _text: DOMString) -> ErrorResult { + fn SetClear(&mut self, _text: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlbuttonelement.rs b/src/components/script/dom/htmlbuttonelement.rs index 30f031f8058..2b2b04aca35 100644 --- a/src/components/script/dom/htmlbuttonelement.rs +++ b/src/components/script/dom/htmlbuttonelement.rs @@ -42,119 +42,152 @@ impl HTMLButtonElement { } } -impl HTMLButtonElement { - pub fn Autofocus(&self) -> bool { +pub trait HTMLButtonElementMethods { + fn Autofocus(&self) -> bool; + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult; + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult; + fn GetForm(&self) -> Option>; + fn FormAction(&self) -> DOMString; + fn SetFormAction(&mut self, _formaction: DOMString) -> ErrorResult; + fn FormEnctype(&self) -> DOMString; + fn SetFormEnctype(&mut self, _formenctype: DOMString) -> ErrorResult; + fn FormMethod(&self) -> DOMString; + fn SetFormMethod(&mut self, _formmethod: DOMString) -> ErrorResult; + fn FormNoValidate(&self) -> bool; + fn SetFormNoValidate(&mut self, _novalidate: bool) -> ErrorResult; + fn FormTarget(&self) -> DOMString; + fn SetFormTarget(&mut self, _formtarget: DOMString) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString) -> ErrorResult; + fn WillValidate(&self) -> bool; + fn SetWillValidate(&mut self, _will_validate: bool); + fn Validity(&self) -> Unrooted; + fn SetValidity(&mut self, _validity: JS); + fn ValidationMessage(&self) -> DOMString; + fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult; + fn CheckValidity(&self) -> bool; + fn SetCustomValidity(&mut self, _error: DOMString); +} + +impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> { + fn Autofocus(&self) -> bool { false } - pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { Ok(()) } - pub fn Disabled(&self) -> bool { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { Ok(()) } - pub fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { None } - pub fn FormAction(&self) -> DOMString { + fn FormAction(&self) -> DOMString { ~"" } - pub fn SetFormAction(&mut self, _formaction: DOMString) -> ErrorResult { + fn SetFormAction(&mut self, _formaction: DOMString) -> ErrorResult { Ok(()) } - pub fn FormEnctype(&self) -> DOMString { + fn FormEnctype(&self) -> DOMString { ~"" } - pub fn SetFormEnctype(&mut self, _formenctype: DOMString) -> ErrorResult { + fn SetFormEnctype(&mut self, _formenctype: DOMString) -> ErrorResult { Ok(()) } - pub fn FormMethod(&self) -> DOMString { + fn FormMethod(&self) -> DOMString { ~"" } - pub fn SetFormMethod(&mut self, _formmethod: DOMString) -> ErrorResult { + fn SetFormMethod(&mut self, _formmethod: DOMString) -> ErrorResult { Ok(()) } - pub fn FormNoValidate(&self) -> bool { + fn FormNoValidate(&self) -> bool { false } - pub fn SetFormNoValidate(&mut self, _novalidate: bool) -> ErrorResult { + fn SetFormNoValidate(&mut self, _novalidate: bool) -> ErrorResult { Ok(()) } - pub fn FormTarget(&self) -> DOMString { + fn FormTarget(&self) -> DOMString { ~"" } - pub fn SetFormTarget(&mut self, _formtarget: DOMString) -> ErrorResult { + fn SetFormTarget(&mut self, _formtarget: DOMString) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { + fn SetValue(&mut self, _value: DOMString) -> ErrorResult { Ok(()) } - pub fn WillValidate(&self) -> bool { + fn WillValidate(&self) -> bool { false } - pub fn SetWillValidate(&mut self, _will_validate: bool) { + fn SetWillValidate(&mut self, _will_validate: bool) { } - pub fn Validity(&self) -> Unrooted { + fn Validity(&self) -> Unrooted { let roots = RootCollection::new(); let doc = self.htmlelement.element.node.owner_doc().root(&roots); ValidityState::new(&*doc.deref().window.root(&roots)) } - pub fn SetValidity(&mut self, _validity: JS) { + fn SetValidity(&mut self, _validity: JS) { } - pub fn ValidationMessage(&self) -> DOMString { + fn ValidationMessage(&self) -> DOMString { ~"" } - pub fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { + fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { Ok(()) } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { true } - pub fn SetCustomValidity(&mut self, _error: DOMString) { + fn SetCustomValidity(&mut self, _error: DOMString) { } } + diff --git a/src/components/script/dom/htmlcanvaselement.rs b/src/components/script/dom/htmlcanvaselement.rs index 469bb8b8643..32af35a06b7 100644 --- a/src/components/script/dom/htmlcanvaselement.rs +++ b/src/components/script/dom/htmlcanvaselement.rs @@ -40,20 +40,28 @@ impl HTMLCanvasElement { } } -impl HTMLCanvasElement { - pub fn Width(&self) -> u32 { +pub trait HTMLCanvasElementMethods { + fn Width(&self) -> u32; + fn SetWidth(&mut self, _width: u32) -> ErrorResult; + fn Height(&self) -> u32; + fn SetHeight(&mut self, _height: u32) -> ErrorResult; +} + +impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> { + fn Width(&self) -> u32 { 0 } - pub fn SetWidth(&mut self, _width: u32) -> ErrorResult { + fn SetWidth(&mut self, _width: u32) -> ErrorResult { Ok(()) } - pub fn Height(&self) -> u32 { + fn Height(&self) -> u32 { 0 } - pub fn SetHeight(&mut self, _height: u32) -> ErrorResult { + fn SetHeight(&mut self, _height: u32) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlcollection.rs b/src/components/script/dom/htmlcollection.rs index 73b4835ff2e..77ddb563805 100644 --- a/src/components/script/dom/htmlcollection.rs +++ b/src/components/script/dom/htmlcollection.rs @@ -118,9 +118,17 @@ impl HTMLCollection { } } -impl HTMLCollection { +pub trait HTMLCollectionMethods { + fn Length(&self) -> u32; + fn Item(&self, index: u32) -> Option>; + fn NamedItem(&self, key: DOMString) -> Option>; + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option>; + fn NamedGetter(&self, maybe_name: Option, found: &mut bool) -> Option>; +} + +impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> { // http://dom.spec.whatwg.org/#dom-htmlcollection-length - pub fn Length(&self) -> u32 { + fn Length(&self) -> u32 { let roots = RootCollection::new(); match self.collection { Static(ref elems) => elems.len() as u32, @@ -136,7 +144,7 @@ impl HTMLCollection { } // http://dom.spec.whatwg.org/#dom-htmlcollection-item - pub fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { let roots = RootCollection::new(); match self.collection { Static(ref elems) => elems @@ -159,7 +167,7 @@ impl HTMLCollection { } // http://dom.spec.whatwg.org/#dom-htmlcollection-nameditem - pub fn NamedItem(&self, key: DOMString) -> Option> { + fn NamedItem(&self, key: DOMString) -> Option> { let roots = RootCollection::new(); // Step 1. @@ -190,16 +198,14 @@ impl HTMLCollection { } } } -} -impl HTMLCollection { - pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { let maybe_elem = self.Item(index); *found = maybe_elem.is_some(); maybe_elem } - pub fn NamedGetter(&self, maybe_name: Option, found: &mut bool) -> Option> { + fn NamedGetter(&self, maybe_name: Option, found: &mut bool) -> Option> { match maybe_name { Some(name) => { let maybe_elem = self.NamedItem(name); diff --git a/src/components/script/dom/htmldataelement.rs b/src/components/script/dom/htmldataelement.rs index 767b3b18598..4e412665595 100644 --- a/src/components/script/dom/htmldataelement.rs +++ b/src/components/script/dom/htmldataelement.rs @@ -40,12 +40,18 @@ impl HTMLDataElement { } } -impl HTMLDataElement { - pub fn Value(&self) -> DOMString { +pub trait HTMLDataElementMethods { + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString) -> ErrorResult; +} + +impl<'a> HTMLDataElementMethods for JSRef<'a, HTMLDataElement> { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { + fn SetValue(&mut self, _value: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmldatalistelement.rs b/src/components/script/dom/htmldatalistelement.rs index e4ac02bd83f..9fcb291ae4f 100644 --- a/src/components/script/dom/htmldatalistelement.rs +++ b/src/components/script/dom/htmldatalistelement.rs @@ -40,8 +40,12 @@ impl HTMLDataListElement { } } -impl HTMLDataListElement { - pub fn Options(&self, abstract_self: &JSRef) -> Unrooted { +pub trait HTMLDataListElementMethods { + fn Options(&self, abstract_self: &JSRef) -> Unrooted; +} + +impl<'a> HTMLDataListElementMethods for JSRef<'a, HTMLDataListElement> { + fn Options(&self, abstract_self: &JSRef) -> Unrooted { struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOptionsFilter { fn filter(&self, elem: &JSRef, _root: &JSRef) -> bool { @@ -55,3 +59,4 @@ impl HTMLDataListElement { HTMLCollection::create(&*window, node, filter) } } + diff --git a/src/components/script/dom/htmldirectoryelement.rs b/src/components/script/dom/htmldirectoryelement.rs index f4b77ee5cf0..cc7dd99920b 100644 --- a/src/components/script/dom/htmldirectoryelement.rs +++ b/src/components/script/dom/htmldirectoryelement.rs @@ -40,12 +40,18 @@ impl HTMLDirectoryElement { } } -impl HTMLDirectoryElement { - pub fn Compact(&self) -> bool { +pub trait HTMLDirectoryElementMethods { + fn Compact(&self) -> bool; + fn SetCompact(&mut self, _compact: bool) -> ErrorResult; +} + +impl<'a> HTMLDirectoryElementMethods for JSRef<'a, HTMLDirectoryElement> { + fn Compact(&self) -> bool { false } - pub fn SetCompact(&mut self, _compact: bool) -> ErrorResult { + fn SetCompact(&mut self, _compact: bool) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmldivelement.rs b/src/components/script/dom/htmldivelement.rs index 6053582738d..d50b95c72cd 100644 --- a/src/components/script/dom/htmldivelement.rs +++ b/src/components/script/dom/htmldivelement.rs @@ -40,12 +40,18 @@ impl HTMLDivElement { } } -impl HTMLDivElement { - pub fn Align(&self) -> DOMString { +pub trait HTMLDivElementMethods { + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; +} + +impl<'a> HTMLDivElementMethods for JSRef<'a, HTMLDivElement> { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmldlistelement.rs b/src/components/script/dom/htmldlistelement.rs index 113547af9d6..838c694a33c 100644 --- a/src/components/script/dom/htmldlistelement.rs +++ b/src/components/script/dom/htmldlistelement.rs @@ -40,20 +40,28 @@ impl HTMLDListElement { } } -impl HTMLDListElement { - pub fn Compact(&self) -> bool { +pub trait HTMLDListElementMethods { + fn Compact(&self) -> bool; + fn SetCompact(&mut self, _compact: bool) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; +} + +impl<'a> HTMLDListElementMethods for JSRef<'a, HTMLDListElement> { + fn Compact(&self) -> bool { false } - pub fn SetCompact(&mut self, _compact: bool) -> ErrorResult { + fn SetCompact(&mut self, _compact: bool) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlelement.rs b/src/components/script/dom/htmlelement.rs index d49ce843bd1..c7596688cdb 100644 --- a/src/components/script/dom/htmlelement.rs +++ b/src/components/script/dom/htmlelement.rs @@ -45,121 +45,154 @@ impl HTMLElement { } } -impl HTMLElement { - pub fn Title(&self) -> DOMString { +pub trait HTMLElementMethods { + fn Title(&self) -> DOMString; + fn SetTitle(&mut self, _title: DOMString); + fn Lang(&self) -> DOMString; + fn SetLang(&mut self, _lang: DOMString); + fn Dir(&self) -> DOMString; + fn SetDir(&mut self, _dir: DOMString) -> ErrorResult; + fn GetItemValue(&self, _cx: *JSContext) -> Fallible; + fn SetItemValue(&mut self, _cx: *JSContext, _val: JSVal) -> ErrorResult; + fn Hidden(&self) -> bool; + fn SetHidden(&mut self, _hidden: bool) -> ErrorResult; + fn Click(&self); + fn TabIndex(&self) -> i32; + fn SetTabIndex(&mut self, _index: i32) -> ErrorResult; + fn Focus(&self) -> ErrorResult; + fn Blur(&self) -> ErrorResult; + fn AccessKey(&self) -> DOMString; + fn SetAccessKey(&self, _key: DOMString) -> ErrorResult; + fn AccessKeyLabel(&self) -> DOMString; + fn Draggable(&self) -> bool; + fn SetDraggable(&mut self, _draggable: bool) -> ErrorResult; + fn ContentEditable(&self) -> DOMString; + fn SetContentEditable(&mut self, _val: DOMString) -> ErrorResult; + fn IsContentEditable(&self) -> bool; + fn Spellcheck(&self) -> bool; + fn SetSpellcheck(&self, _val: bool) -> ErrorResult; + fn GetOffsetParent(&self) -> Option>; + fn OffsetTop(&self) -> i32; + fn OffsetLeft(&self) -> i32; + fn OffsetWidth(&self) -> i32; + fn OffsetHeight(&self) -> i32; +} + +impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> { + fn Title(&self) -> DOMString { ~"" } - pub fn SetTitle(&mut self, _title: DOMString) { + fn SetTitle(&mut self, _title: DOMString) { } - pub fn Lang(&self) -> DOMString { + fn Lang(&self) -> DOMString { ~"" } - pub fn SetLang(&mut self, _lang: DOMString) { + fn SetLang(&mut self, _lang: DOMString) { } - pub fn Dir(&self) -> DOMString { + fn Dir(&self) -> DOMString { ~"" } - pub fn SetDir(&mut self, _dir: DOMString) -> ErrorResult { + fn SetDir(&mut self, _dir: DOMString) -> ErrorResult { Ok(()) } - pub fn GetItemValue(&self, _cx: *JSContext) -> Fallible { + fn GetItemValue(&self, _cx: *JSContext) -> Fallible { Ok(NullValue()) } - pub fn SetItemValue(&mut self, _cx: *JSContext, _val: JSVal) -> ErrorResult { + fn SetItemValue(&mut self, _cx: *JSContext, _val: JSVal) -> ErrorResult { Ok(()) } - pub fn Hidden(&self) -> bool { + fn Hidden(&self) -> bool { false } - pub fn SetHidden(&mut self, _hidden: bool) -> ErrorResult { + fn SetHidden(&mut self, _hidden: bool) -> ErrorResult { Ok(()) } - pub fn Click(&self) { + fn Click(&self) { } - pub fn TabIndex(&self) -> i32 { + fn TabIndex(&self) -> i32 { 0 } - pub fn SetTabIndex(&mut self, _index: i32) -> ErrorResult { + fn SetTabIndex(&mut self, _index: i32) -> ErrorResult { Ok(()) } - pub fn Focus(&self) -> ErrorResult { + fn Focus(&self) -> ErrorResult { Ok(()) } - pub fn Blur(&self) -> ErrorResult { + fn Blur(&self) -> ErrorResult { Ok(()) } - pub fn AccessKey(&self) -> DOMString { + fn AccessKey(&self) -> DOMString { ~"" } - pub fn SetAccessKey(&self, _key: DOMString) -> ErrorResult { + fn SetAccessKey(&self, _key: DOMString) -> ErrorResult { Ok(()) } - pub fn AccessKeyLabel(&self) -> DOMString { + fn AccessKeyLabel(&self) -> DOMString { ~"" } - pub fn Draggable(&self) -> bool { + fn Draggable(&self) -> bool { false } - pub fn SetDraggable(&mut self, _draggable: bool) -> ErrorResult { + fn SetDraggable(&mut self, _draggable: bool) -> ErrorResult { Ok(()) } - pub fn ContentEditable(&self) -> DOMString { + fn ContentEditable(&self) -> DOMString { ~"" } - pub fn SetContentEditable(&mut self, _val: DOMString) -> ErrorResult { + fn SetContentEditable(&mut self, _val: DOMString) -> ErrorResult { Ok(()) } - pub fn IsContentEditable(&self) -> bool { + fn IsContentEditable(&self) -> bool { false } - pub fn Spellcheck(&self) -> bool { + fn Spellcheck(&self) -> bool { false } - pub fn SetSpellcheck(&self, _val: bool) -> ErrorResult { + fn SetSpellcheck(&self, _val: bool) -> ErrorResult { Ok(()) } - pub fn GetOffsetParent(&self) -> Option> { + fn GetOffsetParent(&self) -> Option> { None } - pub fn OffsetTop(&self) -> i32 { + fn OffsetTop(&self) -> i32 { 0 } - pub fn OffsetLeft(&self) -> i32 { + fn OffsetLeft(&self) -> i32 { 0 } - pub fn OffsetWidth(&self) -> i32 { + fn OffsetWidth(&self) -> i32 { 0 } - pub fn OffsetHeight(&self) -> i32 { + fn OffsetHeight(&self) -> i32 { 0 } } diff --git a/src/components/script/dom/htmlembedelement.rs b/src/components/script/dom/htmlembedelement.rs index 864e1a1829c..715f113987e 100644 --- a/src/components/script/dom/htmlembedelement.rs +++ b/src/components/script/dom/htmlembedelement.rs @@ -40,56 +40,73 @@ impl HTMLEmbedElement { } } -impl HTMLEmbedElement { - pub fn Src(&self) -> DOMString { +pub trait HTMLEmbedElementMethods { + fn Src(&self) -> DOMString; + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Width(&self) -> DOMString; + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult; + fn Height(&self) -> DOMString; + fn SetHeight(&mut self, _height: DOMString) -> ErrorResult; + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _type: DOMString) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _type: DOMString) -> ErrorResult; + fn GetSVGDocument(&self) -> Option>; +} + +impl<'a> HTMLEmbedElementMethods for JSRef<'a, HTMLEmbedElement> { + fn Src(&self) -> DOMString { ~"" } - pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Width(&self) -> DOMString { + fn Width(&self) -> DOMString { ~"" } - pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { Ok(()) } - pub fn Height(&self) -> DOMString { + fn Height(&self) -> DOMString { ~"" } - pub fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { + fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { Ok(()) } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _type: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _type: DOMString) -> ErrorResult { + fn SetName(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn GetSVGDocument(&self) -> Option> { + fn GetSVGDocument(&self) -> Option> { None } } + diff --git a/src/components/script/dom/htmlfieldsetelement.rs b/src/components/script/dom/htmlfieldsetelement.rs index 1bb9146e4e7..4f3d06d987c 100644 --- a/src/components/script/dom/htmlfieldsetelement.rs +++ b/src/components/script/dom/htmlfieldsetelement.rs @@ -43,33 +43,48 @@ impl HTMLFieldSetElement { } } -impl HTMLFieldSetElement { - pub fn Disabled(&self) -> bool { +pub trait HTMLFieldSetElementMethods { + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult; + fn GetForm(&self) -> Option>; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn Elements(&self, abstract_self: &JSRef) -> Unrooted; + fn WillValidate(&self) -> bool; + fn Validity(&self) -> Unrooted; + fn ValidationMessage(&self) -> DOMString; + fn CheckValidity(&self) -> bool; + fn SetCustomValidity(&mut self, _error: DOMString); +} + +impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { Ok(()) } - pub fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { None } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } // http://www.whatwg.org/html/#dom-fieldset-elements - pub fn Elements(&self, abstract_self: &JSRef) -> Unrooted { + fn Elements(&self, abstract_self: &JSRef) -> Unrooted { struct ElementsFilter; impl CollectionFilter for ElementsFilter { fn filter(&self, elem: &JSRef, root: &JSRef) -> bool { @@ -86,25 +101,26 @@ impl HTMLFieldSetElement { HTMLCollection::create(&*window, node, filter) } - pub fn WillValidate(&self) -> bool { + fn WillValidate(&self) -> bool { false } - pub fn Validity(&self) -> Unrooted { + fn Validity(&self) -> Unrooted { let roots = RootCollection::new(); let doc = self.htmlelement.element.node.owner_doc().root(&roots); let window = doc.deref().window.root(&roots); ValidityState::new(&*window) } - pub fn ValidationMessage(&self) -> DOMString { + fn ValidationMessage(&self) -> DOMString { ~"" } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { false } - pub fn SetCustomValidity(&mut self, _error: DOMString) { + fn SetCustomValidity(&mut self, _error: DOMString) { } } + diff --git a/src/components/script/dom/htmlfontelement.rs b/src/components/script/dom/htmlfontelement.rs index fefc9c0f4df..eca6b946b23 100644 --- a/src/components/script/dom/htmlfontelement.rs +++ b/src/components/script/dom/htmlfontelement.rs @@ -40,28 +40,38 @@ impl HTMLFontElement { } } -impl HTMLFontElement { - pub fn Color(&self) -> DOMString { +pub trait HTMLFontElementMethods { + fn Color(&self) -> DOMString; + fn SetColor(&mut self, _color: DOMString) -> ErrorResult; + fn Face(&self) -> DOMString; + fn SetFace(&mut self, _face: DOMString) -> ErrorResult; + fn Size(&self) -> DOMString; + fn SetSize(&mut self, _size: DOMString) -> ErrorResult; +} + +impl<'a> HTMLFontElementMethods for JSRef<'a, HTMLFontElement> { + fn Color(&self) -> DOMString { ~"" } - pub fn SetColor(&mut self, _color: DOMString) -> ErrorResult { + fn SetColor(&mut self, _color: DOMString) -> ErrorResult { Ok(()) } - pub fn Face(&self) -> DOMString { + fn Face(&self) -> DOMString { ~"" } - pub fn SetFace(&mut self, _face: DOMString) -> ErrorResult { + fn SetFace(&mut self, _face: DOMString) -> ErrorResult { Ok(()) } - pub fn Size(&self) -> DOMString { + fn Size(&self) -> DOMString { ~"" } - pub fn SetSize(&mut self, _size: DOMString) -> ErrorResult { + fn SetSize(&mut self, _size: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlformelement.rs b/src/components/script/dom/htmlformelement.rs index 329b9e07baf..f045c1437c3 100644 --- a/src/components/script/dom/htmlformelement.rs +++ b/src/components/script/dom/htmlformelement.rs @@ -41,80 +41,107 @@ impl HTMLFormElement { } } -impl HTMLFormElement { - pub fn AcceptCharset(&self) -> DOMString { +pub trait HTMLFormElementMethods { + fn AcceptCharset(&self) -> DOMString; + fn SetAcceptCharset(&mut self, _accept_charset: DOMString) -> ErrorResult; + fn Action(&self) -> DOMString; + fn SetAction(&mut self, _action: DOMString) -> ErrorResult; + fn Autocomplete(&self) -> DOMString; + fn SetAutocomplete(&mut self, _autocomplete: DOMString) -> ErrorResult; + fn Enctype(&self) -> DOMString; + fn SetEnctype(&mut self, _enctype: DOMString) -> ErrorResult; + fn Encoding(&self) -> DOMString; + fn SetEncoding(&mut self, _encoding: DOMString) -> ErrorResult; + fn Method(&self) -> DOMString; + fn SetMethod(&mut self, _method: DOMString) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn NoValidate(&self) -> bool; + fn SetNoValidate(&mut self, _no_validate: bool) -> ErrorResult; + fn Target(&self) -> DOMString; + fn SetTarget(&mut self, _target: DOMString) -> ErrorResult; + fn Elements(&self) -> Unrooted; + fn Length(&self) -> i32; + fn Submit(&self) -> ErrorResult; + fn Reset(&self); + fn CheckValidity(&self) -> bool; + fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Unrooted; +} + +impl<'a> HTMLFormElementMethods for JSRef<'a, HTMLFormElement> { + fn AcceptCharset(&self) -> DOMString { ~"" } - pub fn SetAcceptCharset(&mut self, _accept_charset: DOMString) -> ErrorResult { + fn SetAcceptCharset(&mut self, _accept_charset: DOMString) -> ErrorResult { Ok(()) } - pub fn Action(&self) -> DOMString { + fn Action(&self) -> DOMString { ~"" } - pub fn SetAction(&mut self, _action: DOMString) -> ErrorResult { + fn SetAction(&mut self, _action: DOMString) -> ErrorResult { Ok(()) } - pub fn Autocomplete(&self) -> DOMString { + fn Autocomplete(&self) -> DOMString { ~"" } - pub fn SetAutocomplete(&mut self, _autocomplete: DOMString) -> ErrorResult { + fn SetAutocomplete(&mut self, _autocomplete: DOMString) -> ErrorResult { Ok(()) } - pub fn Enctype(&self) -> DOMString { + fn Enctype(&self) -> DOMString { ~"" } - pub fn SetEnctype(&mut self, _enctype: DOMString) -> ErrorResult { + fn SetEnctype(&mut self, _enctype: DOMString) -> ErrorResult { Ok(()) } - pub fn Encoding(&self) -> DOMString { + fn Encoding(&self) -> DOMString { ~"" } - pub fn SetEncoding(&mut self, _encoding: DOMString) -> ErrorResult { + fn SetEncoding(&mut self, _encoding: DOMString) -> ErrorResult { Ok(()) } - pub fn Method(&self) -> DOMString { + fn Method(&self) -> DOMString { ~"" } - pub fn SetMethod(&mut self, _method: DOMString) -> ErrorResult { + fn SetMethod(&mut self, _method: DOMString) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn NoValidate(&self) -> bool { + fn NoValidate(&self) -> bool { false } - pub fn SetNoValidate(&mut self, _no_validate: bool) -> ErrorResult { + fn SetNoValidate(&mut self, _no_validate: bool) -> ErrorResult { Ok(()) } - pub fn Target(&self) -> DOMString { + fn Target(&self) -> DOMString { ~"" } - pub fn SetTarget(&mut self, _target: DOMString) -> ErrorResult { + fn SetTarget(&mut self, _target: DOMString) -> ErrorResult { Ok(()) } - pub fn Elements(&self) -> Unrooted { + fn Elements(&self) -> Unrooted { // FIXME: https://github.com/mozilla/servo/issues/1844 let roots = RootCollection::new(); let doc = self.htmlelement.element.node.owner_doc().root(&roots); @@ -122,22 +149,23 @@ impl HTMLFormElement { HTMLCollection::new(&*window, Static(vec!())) } - pub fn Length(&self) -> i32 { + fn Length(&self) -> i32 { 0 } - pub fn Submit(&self) -> ErrorResult { + fn Submit(&self) -> ErrorResult { Ok(()) } - pub fn Reset(&self) { + fn Reset(&self) { } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { false } - pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Unrooted { + fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Unrooted { fail!("Not implemented.") } } + diff --git a/src/components/script/dom/htmlframeelement.rs b/src/components/script/dom/htmlframeelement.rs index 180124bf6dd..5dd705b494f 100644 --- a/src/components/script/dom/htmlframeelement.rs +++ b/src/components/script/dom/htmlframeelement.rs @@ -41,76 +41,98 @@ impl HTMLFrameElement { } } -impl HTMLFrameElement { - pub fn Name(&self) -> DOMString { +pub trait HTMLFrameElementMethods { + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Scrolling(&self) -> DOMString; + fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult; + fn Src(&self) -> DOMString; + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult; + fn FrameBorder(&self) -> DOMString; + fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult; + fn LongDesc(&self) -> DOMString; + fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult; + fn NoResize(&self) -> bool; + fn SetNoResize(&mut self, _no_resize: bool) -> ErrorResult; + fn GetContentDocument(&self) -> Option>; + fn GetContentWindow(&self) -> Option>; + fn MarginHeight(&self) -> DOMString; + fn SetMarginHeight(&mut self, _height: DOMString) -> ErrorResult; + fn MarginWidth(&self) -> DOMString; + fn SetMarginWidth(&mut self, _height: DOMString) -> ErrorResult; +} + +impl<'a> HTMLFrameElementMethods for JSRef<'a, HTMLFrameElement> { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Scrolling(&self) -> DOMString { + fn Scrolling(&self) -> DOMString { ~"" } - pub fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult { + fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult { Ok(()) } - pub fn Src(&self) -> DOMString { + fn Src(&self) -> DOMString { ~"" } - pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { Ok(()) } - pub fn FrameBorder(&self) -> DOMString { + fn FrameBorder(&self) -> DOMString { ~"" } - pub fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult { + fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult { Ok(()) } - pub fn LongDesc(&self) -> DOMString { + fn LongDesc(&self) -> DOMString { ~"" } - pub fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult { + fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult { Ok(()) } - pub fn NoResize(&self) -> bool { + fn NoResize(&self) -> bool { false } - pub fn SetNoResize(&mut self, _no_resize: bool) -> ErrorResult { + fn SetNoResize(&mut self, _no_resize: bool) -> ErrorResult { Ok(()) } - pub fn GetContentDocument(&self) -> Option> { + fn GetContentDocument(&self) -> Option> { None } - pub fn GetContentWindow(&self) -> Option> { + fn GetContentWindow(&self) -> Option> { None } - pub fn MarginHeight(&self) -> DOMString { + fn MarginHeight(&self) -> DOMString { ~"" } - pub fn SetMarginHeight(&mut self, _height: DOMString) -> ErrorResult { + fn SetMarginHeight(&mut self, _height: DOMString) -> ErrorResult { Ok(()) } - pub fn MarginWidth(&self) -> DOMString { + fn MarginWidth(&self) -> DOMString { ~"" } - pub fn SetMarginWidth(&mut self, _height: DOMString) -> ErrorResult { + fn SetMarginWidth(&mut self, _height: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlframesetelement.rs b/src/components/script/dom/htmlframesetelement.rs index 9177c197ae8..1e58cba197a 100644 --- a/src/components/script/dom/htmlframesetelement.rs +++ b/src/components/script/dom/htmlframesetelement.rs @@ -40,20 +40,28 @@ impl HTMLFrameSetElement { } } -impl HTMLFrameSetElement { - pub fn Cols(&self) -> DOMString { +pub trait HTMLFrameSetElementMethods { + fn Cols(&self) -> DOMString; + fn SetCols(&mut self, _cols: DOMString) -> ErrorResult; + fn Rows(&self) -> DOMString; + fn SetRows(&mut self, _rows: DOMString) -> ErrorResult; +} + +impl<'a> HTMLFrameSetElementMethods for JSRef<'a, HTMLFrameSetElement> { + fn Cols(&self) -> DOMString { ~"" } - pub fn SetCols(&mut self, _cols: DOMString) -> ErrorResult { + fn SetCols(&mut self, _cols: DOMString) -> ErrorResult { Ok(()) } - pub fn Rows(&self) -> DOMString { + fn Rows(&self) -> DOMString { ~"" } - pub fn SetRows(&mut self, _rows: DOMString) -> ErrorResult { + fn SetRows(&mut self, _rows: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlheadelement.rs b/src/components/script/dom/htmlheadelement.rs index 6b10c6078c3..440a95310f6 100644 --- a/src/components/script/dom/htmlheadelement.rs +++ b/src/components/script/dom/htmlheadelement.rs @@ -38,3 +38,6 @@ impl HTMLHeadElement { Node::reflect_node(~element, document, HTMLHeadElementBinding::Wrap) } } + +pub trait HTMLHeadElementMethods { +} diff --git a/src/components/script/dom/htmlheadingelement.rs b/src/components/script/dom/htmlheadingelement.rs index 4574189d7bf..f05ef59a211 100644 --- a/src/components/script/dom/htmlheadingelement.rs +++ b/src/components/script/dom/htmlheadingelement.rs @@ -51,11 +51,17 @@ impl HTMLHeadingElement { } } -impl HTMLHeadingElement { - pub fn Align(&self) -> DOMString { +pub trait HTMLHeadingElementMethods { + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString); +} + +impl<'a> HTMLHeadingElementMethods for JSRef<'a, HTMLHeadingElement> { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) { + fn SetAlign(&mut self, _align: DOMString) { } } + diff --git a/src/components/script/dom/htmlhrelement.rs b/src/components/script/dom/htmlhrelement.rs index 14098388c1d..2ad58999b61 100644 --- a/src/components/script/dom/htmlhrelement.rs +++ b/src/components/script/dom/htmlhrelement.rs @@ -40,44 +40,58 @@ impl HTMLHRElement { } } -impl HTMLHRElement { - pub fn Align(&self) -> DOMString { +pub trait HTMLHRElementMethods { + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; + fn Color(&self) -> DOMString; + fn SetColor(&mut self, _color: DOMString) -> ErrorResult; + fn NoShade(&self) -> bool; + fn SetNoShade(&self, _no_shade: bool) -> ErrorResult; + fn Size(&self) -> DOMString; + fn SetSize(&mut self, _size: DOMString) -> ErrorResult; + fn Width(&self) -> DOMString; + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult; +} + +impl<'a> HTMLHRElementMethods for JSRef<'a, HTMLHRElement> { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Color(&self) -> DOMString { + fn Color(&self) -> DOMString { ~"" } - pub fn SetColor(&mut self, _color: DOMString) -> ErrorResult { + fn SetColor(&mut self, _color: DOMString) -> ErrorResult { Ok(()) } - pub fn NoShade(&self) -> bool { + fn NoShade(&self) -> bool { false } - pub fn SetNoShade(&self, _no_shade: bool) -> ErrorResult { + fn SetNoShade(&self, _no_shade: bool) -> ErrorResult { Ok(()) } - pub fn Size(&self) -> DOMString { + fn Size(&self) -> DOMString { ~"" } - pub fn SetSize(&mut self, _size: DOMString) -> ErrorResult { + fn SetSize(&mut self, _size: DOMString) -> ErrorResult { Ok(()) } - pub fn Width(&self) -> DOMString { + fn Width(&self) -> DOMString { ~"" } - pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlhtmlelement.rs b/src/components/script/dom/htmlhtmlelement.rs index 1930ce271c2..e30968f91f4 100644 --- a/src/components/script/dom/htmlhtmlelement.rs +++ b/src/components/script/dom/htmlhtmlelement.rs @@ -40,12 +40,18 @@ impl HTMLHtmlElement { } } -impl HTMLHtmlElement { - pub fn Version(&self) -> DOMString { +pub trait HTMLHtmlElementMethods { + fn Version(&self) -> DOMString; + fn SetVersion(&mut self, _version: DOMString) -> ErrorResult; +} + +impl<'a> HTMLHtmlElementMethods for JSRef<'a, HTMLHtmlElement> { + fn Version(&self) -> DOMString { ~"" } - pub fn SetVersion(&mut self, _version: DOMString) -> ErrorResult { + fn SetVersion(&mut self, _version: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmliframeelement.rs b/src/components/script/dom/htmliframeelement.rs index c157e2ad445..316468342f1 100644 --- a/src/components/script/dom/htmliframeelement.rs +++ b/src/components/script/dom/htmliframeelement.rs @@ -80,122 +80,154 @@ impl HTMLIFrameElement { } } -impl HTMLIFrameElement { - pub fn Src(&self) -> DOMString { +pub trait HTMLIFrameElementMethods { + fn Src(&self) -> DOMString; + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult; + fn Srcdoc(&self) -> DOMString; + fn SetSrcdoc(&mut self, _srcdoc: DOMString) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Sandbox(&self, abstract_self: &JSRef) -> DOMString; + fn SetSandbox(&mut self, abstract_self: &mut JSRef, sandbox: DOMString); + fn AllowFullscreen(&self) -> bool; + fn SetAllowFullscreen(&mut self, _allow: bool) -> ErrorResult; + fn Width(&self) -> DOMString; + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult; + fn Height(&self) -> DOMString; + fn SetHeight(&mut self, _height: DOMString) -> ErrorResult; + fn GetContentDocument(&self) -> Option>; + fn GetContentWindow(&self) -> Option>; + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; + fn Scrolling(&self) -> DOMString; + fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult; + fn FrameBorder(&self) -> DOMString; + fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult; + fn LongDesc(&self) -> DOMString; + fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult; + fn MarginHeight(&self) -> DOMString; + fn SetMarginHeight(&mut self, _marginheight: DOMString) -> ErrorResult; + fn MarginWidth(&self) -> DOMString; + fn SetMarginWidth(&mut self, _marginwidth: DOMString) -> ErrorResult; + fn GetSVGDocument(&self) -> Option>; +} + +impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> { + fn Src(&self) -> DOMString { ~"" } - pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { Ok(()) } - pub fn Srcdoc(&self) -> DOMString { + fn Srcdoc(&self) -> DOMString { ~"" } - pub fn SetSrcdoc(&mut self, _srcdoc: DOMString) -> ErrorResult { + fn SetSrcdoc(&mut self, _srcdoc: DOMString) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Sandbox(&self, abstract_self: &JSRef) -> DOMString { + fn Sandbox(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_string_attribute("sandbox") } - pub fn SetSandbox(&mut self, abstract_self: &mut JSRef, sandbox: DOMString) { + fn SetSandbox(&mut self, abstract_self: &mut JSRef, sandbox: DOMString) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_string_attribute("sandbox", sandbox); } - pub fn AllowFullscreen(&self) -> bool { + fn AllowFullscreen(&self) -> bool { false } - pub fn SetAllowFullscreen(&mut self, _allow: bool) -> ErrorResult { + fn SetAllowFullscreen(&mut self, _allow: bool) -> ErrorResult { Ok(()) } - pub fn Width(&self) -> DOMString { + fn Width(&self) -> DOMString { ~"" } - pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { Ok(()) } - pub fn Height(&self) -> DOMString { + fn Height(&self) -> DOMString { ~"" } - pub fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { + fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { Ok(()) } - pub fn GetContentDocument(&self) -> Option> { + fn GetContentDocument(&self) -> Option> { None } - pub fn GetContentWindow(&self) -> Option> { + fn GetContentWindow(&self) -> Option> { None } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Scrolling(&self) -> DOMString { + fn Scrolling(&self) -> DOMString { ~"" } - pub fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult { + fn SetScrolling(&mut self, _scrolling: DOMString) -> ErrorResult { Ok(()) } - pub fn FrameBorder(&self) -> DOMString { + fn FrameBorder(&self) -> DOMString { ~"" } - pub fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult { + fn SetFrameBorder(&mut self, _frameborder: DOMString) -> ErrorResult { Ok(()) } - pub fn LongDesc(&self) -> DOMString { + fn LongDesc(&self) -> DOMString { ~"" } - pub fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult { + fn SetLongDesc(&mut self, _longdesc: DOMString) -> ErrorResult { Ok(()) } - pub fn MarginHeight(&self) -> DOMString { + fn MarginHeight(&self) -> DOMString { ~"" } - pub fn SetMarginHeight(&mut self, _marginheight: DOMString) -> ErrorResult { + fn SetMarginHeight(&mut self, _marginheight: DOMString) -> ErrorResult { Ok(()) } - pub fn MarginWidth(&self) -> DOMString { + fn MarginWidth(&self) -> DOMString { ~"" } - pub fn SetMarginWidth(&mut self, _marginwidth: DOMString) -> ErrorResult { + fn SetMarginWidth(&mut self, _marginwidth: DOMString) -> ErrorResult { Ok(()) } - pub fn GetSVGDocument(&self) -> Option> { + fn GetSVGDocument(&self) -> Option> { None } } diff --git a/src/components/script/dom/htmlimageelement.rs b/src/components/script/dom/htmlimageelement.rs index 04528c54283..efe6a0401d6 100644 --- a/src/components/script/dom/htmlimageelement.rs +++ b/src/components/script/dom/htmlimageelement.rs @@ -47,9 +47,7 @@ impl HTMLImageElement { let element = HTMLImageElement::new_inherited(localName, document.unrooted()); Node::reflect_node(~element, document, HTMLImageElementBinding::Wrap) } -} -impl HTMLImageElement { pub fn image<'a>(&'a self) -> &'a Option { &*self.image } @@ -79,145 +77,179 @@ impl HTMLImageElement { } } } +} - pub fn Alt(&self, abstract_self: &JSRef) -> DOMString { +pub trait HTMLImageElementMethods { + fn Alt(&self, abstract_self: &JSRef) -> DOMString; + fn SetAlt(&mut self, abstract_self: &mut JSRef, alt: DOMString); + fn Src(&self, abstract_self: &JSRef) -> DOMString; + fn SetSrc(&mut self, abstract_self: &mut JSRef, src: DOMString); + fn CrossOrigin(&self) -> DOMString; + fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult; + fn UseMap(&self, abstract_self: &JSRef) -> DOMString; + fn SetUseMap(&mut self, abstract_self: &mut JSRef, use_map: DOMString); + fn IsMap(&self, abstract_self: &JSRef) -> bool; + fn SetIsMap(&self, abstract_self: &mut JSRef, is_map: bool); + fn Width(&self, abstract_self: &JSRef) -> u32; + fn SetWidth(&mut self, abstract_self: &mut JSRef, width: u32); + fn Height(&self, abstract_self: &JSRef) -> u32; + fn SetHeight(&mut self, abstract_self: &mut JSRef, height: u32); + fn NaturalWidth(&self) -> u32; + fn NaturalHeight(&self) -> u32; + fn Complete(&self) -> bool; + fn Name(&self, abstract_self: &JSRef) -> DOMString; + fn SetName(&mut self, abstract_self: &mut JSRef, name: DOMString); + fn Align(&self, abstract_self: &JSRef) -> DOMString; + fn SetAlign(&mut self, abstract_self: &mut JSRef, align: DOMString); + fn Hspace(&self, abstract_self: &JSRef) -> u32; + fn SetHspace(&mut self, abstract_self: &mut JSRef, hspace: u32); + fn Vspace(&self, abstract_self: &JSRef) -> u32; + fn SetVspace(&mut self, abstract_self: &mut JSRef, vspace: u32); + fn LongDesc(&self, abstract_self: &JSRef) -> DOMString; + fn SetLongDesc(&mut self, abstract_self: &mut JSRef, longdesc: DOMString); + fn Border(&self, abstract_self: &JSRef) -> DOMString; + fn SetBorder(&mut self, abstract_self: &mut JSRef, border: DOMString); +} + +impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> { + fn Alt(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_string_attribute("alt") } - pub fn SetAlt(&mut self, abstract_self: &mut JSRef, alt: DOMString) { + fn SetAlt(&mut self, abstract_self: &mut JSRef, alt: DOMString) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_string_attribute("alt", alt) } - pub fn Src(&self, abstract_self: &JSRef) -> DOMString { + fn Src(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_string_attribute("src") } - pub fn SetSrc(&mut self, abstract_self: &mut JSRef, src: DOMString) { + fn SetSrc(&mut self, abstract_self: &mut JSRef, src: DOMString) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_url_attribute("src", src) } - pub fn CrossOrigin(&self) -> DOMString { + fn CrossOrigin(&self) -> DOMString { ~"" } - pub fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { + fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { Ok(()) } - pub fn UseMap(&self, abstract_self: &JSRef) -> DOMString { + fn UseMap(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_string_attribute("useMap") } - pub fn SetUseMap(&mut self, abstract_self: &mut JSRef, use_map: DOMString) { + fn SetUseMap(&mut self, abstract_self: &mut JSRef, use_map: DOMString) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_string_attribute("useMap", use_map) } - pub fn IsMap(&self, abstract_self: &JSRef) -> bool { + fn IsMap(&self, abstract_self: &JSRef) -> bool { let element: &JSRef = ElementCast::from_ref(abstract_self); from_str::(element.get_string_attribute("hspace")).unwrap() } - pub fn SetIsMap(&self, abstract_self: &mut JSRef, is_map: bool) { + fn SetIsMap(&self, abstract_self: &mut JSRef, is_map: bool) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_string_attribute("isMap", is_map.to_str()) } - pub fn Width(&self, abstract_self: &JSRef) -> u32 { + fn Width(&self, abstract_self: &JSRef) -> u32 { let node: &JSRef = NodeCast::from_ref(abstract_self); let rect = node.get_bounding_content_box(); to_px(rect.size.width) as u32 } - pub fn SetWidth(&mut self, abstract_self: &mut JSRef, width: u32) { + fn SetWidth(&mut self, abstract_self: &mut JSRef, width: u32) { let elem: &mut JSRef = ElementCast::from_mut_ref(abstract_self); elem.set_uint_attribute("width", width) } - pub fn Height(&self, abstract_self: &JSRef) -> u32 { + fn Height(&self, abstract_self: &JSRef) -> u32 { let node: &JSRef = NodeCast::from_ref(abstract_self); let rect = node.get_bounding_content_box(); to_px(rect.size.height) as u32 } - pub fn SetHeight(&mut self, abstract_self: &mut JSRef, height: u32) { + fn SetHeight(&mut self, abstract_self: &mut JSRef, height: u32) { let elem: &mut JSRef = ElementCast::from_mut_ref(abstract_self); elem.set_uint_attribute("height", height) } - pub fn NaturalWidth(&self) -> u32 { + fn NaturalWidth(&self) -> u32 { 0 } - pub fn NaturalHeight(&self) -> u32 { + fn NaturalHeight(&self) -> u32 { 0 } - pub fn Complete(&self) -> bool { + fn Complete(&self) -> bool { false } - pub fn Name(&self, abstract_self: &JSRef) -> DOMString { + fn Name(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_string_attribute("name") } - pub fn SetName(&mut self, abstract_self: &mut JSRef, name: DOMString) { + fn SetName(&mut self, abstract_self: &mut JSRef, name: DOMString) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_string_attribute("name", name) } - pub fn Align(&self, abstract_self: &JSRef) -> DOMString { + fn Align(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_string_attribute("longdesc") } - pub fn SetAlign(&mut self, abstract_self: &mut JSRef, align: DOMString) { + fn SetAlign(&mut self, abstract_self: &mut JSRef, align: DOMString) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_string_attribute("align", align) } - pub fn Hspace(&self, abstract_self: &JSRef) -> u32 { + fn Hspace(&self, abstract_self: &JSRef) -> u32 { let element: &JSRef = ElementCast::from_ref(abstract_self); from_str::(element.get_string_attribute("hspace")).unwrap() } - pub fn SetHspace(&mut self, abstract_self: &mut JSRef, hspace: u32) { + fn SetHspace(&mut self, abstract_self: &mut JSRef, hspace: u32) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_uint_attribute("hspace", hspace) } - pub fn Vspace(&self, abstract_self: &JSRef) -> u32 { + fn Vspace(&self, abstract_self: &JSRef) -> u32 { let element: &JSRef = ElementCast::from_ref(abstract_self); from_str::(element.get_string_attribute("vspace")).unwrap() } - pub fn SetVspace(&mut self, abstract_self: &mut JSRef, vspace: u32) { + fn SetVspace(&mut self, abstract_self: &mut JSRef, vspace: u32) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_uint_attribute("vspace", vspace) } - pub fn LongDesc(&self, abstract_self: &JSRef) -> DOMString { + fn LongDesc(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_string_attribute("longdesc") } - pub fn SetLongDesc(&mut self, abstract_self: &mut JSRef, longdesc: DOMString) { + fn SetLongDesc(&mut self, abstract_self: &mut JSRef, longdesc: DOMString) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_string_attribute("longdesc", longdesc) } - pub fn Border(&self, abstract_self: &JSRef) -> DOMString { + fn Border(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_string_attribute("border") } - pub fn SetBorder(&mut self, abstract_self: &mut JSRef, border: DOMString) { + fn SetBorder(&mut self, abstract_self: &mut JSRef, border: DOMString) { let element: &mut JSRef = ElementCast::from_mut_ref(abstract_self); element.set_string_attribute("border", border) } diff --git a/src/components/script/dom/htmlinputelement.rs b/src/components/script/dom/htmlinputelement.rs index 55d8fc7c1a7..f56578c6cdd 100644 --- a/src/components/script/dom/htmlinputelement.rs +++ b/src/components/script/dom/htmlinputelement.rs @@ -40,310 +40,392 @@ impl HTMLInputElement { } } -impl HTMLInputElement { - pub fn Accept(&self) -> DOMString { +pub trait HTMLInputElementMethods { + fn Accept(&self) -> DOMString; + fn SetAccept(&mut self, _accept: DOMString) -> ErrorResult; + fn Alt(&self) -> DOMString; + fn SetAlt(&mut self, _alt: DOMString) -> ErrorResult; + fn Autocomplete(&self) -> DOMString; + fn SetAutocomplete(&mut self, _autocomple: DOMString) -> ErrorResult; + fn Autofocus(&self) -> bool; + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult; + fn DefaultChecked(&self) -> bool; + fn SetDefaultChecked(&mut self, _default_checked: bool) -> ErrorResult; + fn Checked(&self) -> bool; + fn SetChecked(&mut self, _checked: bool); + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult; + fn FormAction(&self) -> DOMString; + fn SetFormAction(&mut self, _form_action: DOMString) -> ErrorResult; + fn FormEnctype(&self) -> DOMString; + fn SetFormEnctype(&mut self, _form_enctype: DOMString) -> ErrorResult; + fn FormMethod(&self) -> DOMString; + fn SetFormMethod(&mut self, _form_method: DOMString) -> ErrorResult; + fn FormNoValidate(&self) -> bool; + fn SetFormNoValidate(&mut self, _form_no_validate: bool) -> ErrorResult; + fn FormTarget(&self) -> DOMString; + fn SetFormTarget(&mut self, _form_target: DOMString) -> ErrorResult; + fn Height(&self) -> u32; + fn SetHeight(&mut self, _height: u32) -> ErrorResult; + fn Indeterminate(&self) -> bool; + fn SetIndeterminate(&mut self, _indeterminate: bool); + fn InputMode(&self) -> DOMString; + fn SetInputMode(&mut self, _input_mode: DOMString) -> ErrorResult; + fn Max(&self) -> DOMString; + fn SetMax(&mut self, _max: DOMString) -> ErrorResult; + fn MaxLength(&self) -> i32; + fn SetMaxLength(&mut self, _max_length: i32) -> ErrorResult; + fn Min(&self) -> DOMString; + fn SetMin(&mut self, _min: DOMString) -> ErrorResult; + fn Multiple(&self) -> bool; + fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Pattern(&self) -> DOMString; + fn SetPattern(&mut self, _pattern: DOMString) -> ErrorResult; + fn Placeholder(&self) -> DOMString; + fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult; + fn ReadOnly(&self) -> bool; + fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult; + fn Required(&self) -> bool; + fn SetRequired(&mut self, _required: bool) -> ErrorResult; + fn Size(&self) -> u32; + fn SetSize(&mut self, _size: u32) -> ErrorResult; + fn Src(&self) -> DOMString; + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult; + fn Step(&self) -> DOMString; + fn SetStep(&mut self, _step: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn DefaultValue(&self) -> DOMString; + fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString) -> ErrorResult; + fn Width(&self) -> u32; + fn SetWidth(&mut self, _width: u32); + fn WillValidate(&self) -> bool; + fn SetWillValidate(&self, _will_validate: bool); + fn GetValidationMessage(&self) -> Fallible; + fn CheckValidity(&self) -> bool; + fn SetCustomValidity(&self, _error: DOMString); + fn Select(&self); + fn GetSelectionStart(&self) -> Fallible; + fn SetSelectionStart(&mut self, _selection_start: i32) -> ErrorResult; + fn GetSelectionEnd(&self) -> Fallible; + fn SetSelectionEnd(&mut self, _selection_end: i32) -> ErrorResult; + fn GetSelectionDirection(&self) -> Fallible; + fn SetSelectionDirection(&mut self, _selection_direction: DOMString) -> ErrorResult; + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; + fn UseMap(&self) -> DOMString; + fn SetUseMap(&mut self, _align: DOMString) -> ErrorResult; +} + +impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> { + fn Accept(&self) -> DOMString { ~"" } - pub fn SetAccept(&mut self, _accept: DOMString) -> ErrorResult { + fn SetAccept(&mut self, _accept: DOMString) -> ErrorResult { Ok(()) } - pub fn Alt(&self) -> DOMString { + fn Alt(&self) -> DOMString { ~"" } - pub fn SetAlt(&mut self, _alt: DOMString) -> ErrorResult { + fn SetAlt(&mut self, _alt: DOMString) -> ErrorResult { Ok(()) } - pub fn Autocomplete(&self) -> DOMString { + fn Autocomplete(&self) -> DOMString { ~"" } - pub fn SetAutocomplete(&mut self, _autocomple: DOMString) -> ErrorResult { + fn SetAutocomplete(&mut self, _autocomple: DOMString) -> ErrorResult { Ok(()) } - pub fn Autofocus(&self) -> bool { + fn Autofocus(&self) -> bool { false } - pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { Ok(()) } - pub fn DefaultChecked(&self) -> bool { + fn DefaultChecked(&self) -> bool { false } - pub fn SetDefaultChecked(&mut self, _default_checked: bool) -> ErrorResult { + fn SetDefaultChecked(&mut self, _default_checked: bool) -> ErrorResult { Ok(()) } - pub fn Checked(&self) -> bool { + fn Checked(&self) -> bool { false } - pub fn SetChecked(&mut self, _checked: bool) { + fn SetChecked(&mut self, _checked: bool) { } - pub fn Disabled(&self) -> bool { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { Ok(()) } - pub fn FormAction(&self) -> DOMString { + fn FormAction(&self) -> DOMString { ~"" } - pub fn SetFormAction(&mut self, _form_action: DOMString) -> ErrorResult { + fn SetFormAction(&mut self, _form_action: DOMString) -> ErrorResult { Ok(()) } - pub fn FormEnctype(&self) -> DOMString { + fn FormEnctype(&self) -> DOMString { ~"" } - pub fn SetFormEnctype(&mut self, _form_enctype: DOMString) -> ErrorResult { + fn SetFormEnctype(&mut self, _form_enctype: DOMString) -> ErrorResult { Ok(()) } - pub fn FormMethod(&self) -> DOMString { + fn FormMethod(&self) -> DOMString { ~"" } - pub fn SetFormMethod(&mut self, _form_method: DOMString) -> ErrorResult { + fn SetFormMethod(&mut self, _form_method: DOMString) -> ErrorResult { Ok(()) } - pub fn FormNoValidate(&self) -> bool { + fn FormNoValidate(&self) -> bool { false } - pub fn SetFormNoValidate(&mut self, _form_no_validate: bool) -> ErrorResult { + fn SetFormNoValidate(&mut self, _form_no_validate: bool) -> ErrorResult { Ok(()) } - pub fn FormTarget(&self) -> DOMString { + fn FormTarget(&self) -> DOMString { ~"" } - pub fn SetFormTarget(&mut self, _form_target: DOMString) -> ErrorResult { + fn SetFormTarget(&mut self, _form_target: DOMString) -> ErrorResult { Ok(()) } - pub fn Height(&self) -> u32 { + fn Height(&self) -> u32 { 0 } - pub fn SetHeight(&mut self, _height: u32) -> ErrorResult { + fn SetHeight(&mut self, _height: u32) -> ErrorResult { Ok(()) } - pub fn Indeterminate(&self) -> bool { + fn Indeterminate(&self) -> bool { false } - pub fn SetIndeterminate(&mut self, _indeterminate: bool) { + fn SetIndeterminate(&mut self, _indeterminate: bool) { } - pub fn InputMode(&self) -> DOMString { + fn InputMode(&self) -> DOMString { ~"" } - pub fn SetInputMode(&mut self, _input_mode: DOMString) -> ErrorResult { + fn SetInputMode(&mut self, _input_mode: DOMString) -> ErrorResult { Ok(()) } - pub fn Max(&self) -> DOMString { + fn Max(&self) -> DOMString { ~"" } - pub fn SetMax(&mut self, _max: DOMString) -> ErrorResult { + fn SetMax(&mut self, _max: DOMString) -> ErrorResult { Ok(()) } - pub fn MaxLength(&self) -> i32 { + fn MaxLength(&self) -> i32 { 0 } - pub fn SetMaxLength(&mut self, _max_length: i32) -> ErrorResult { + fn SetMaxLength(&mut self, _max_length: i32) -> ErrorResult { Ok(()) } - pub fn Min(&self) -> DOMString { + fn Min(&self) -> DOMString { ~"" } - pub fn SetMin(&mut self, _min: DOMString) -> ErrorResult { + fn SetMin(&mut self, _min: DOMString) -> ErrorResult { Ok(()) } - pub fn Multiple(&self) -> bool { + fn Multiple(&self) -> bool { false } - pub fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult { + fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Pattern(&self) -> DOMString { + fn Pattern(&self) -> DOMString { ~"" } - pub fn SetPattern(&mut self, _pattern: DOMString) -> ErrorResult { + fn SetPattern(&mut self, _pattern: DOMString) -> ErrorResult { Ok(()) } - pub fn Placeholder(&self) -> DOMString { + fn Placeholder(&self) -> DOMString { ~"" } - pub fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult { + fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult { Ok(()) } - pub fn ReadOnly(&self) -> bool { + fn ReadOnly(&self) -> bool { false } - pub fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult { + fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult { Ok(()) } - pub fn Required(&self) -> bool { + fn Required(&self) -> bool { false } - pub fn SetRequired(&mut self, _required: bool) -> ErrorResult { + fn SetRequired(&mut self, _required: bool) -> ErrorResult { Ok(()) } - pub fn Size(&self) -> u32 { + fn Size(&self) -> u32 { 0 } - pub fn SetSize(&mut self, _size: u32) -> ErrorResult { + fn SetSize(&mut self, _size: u32) -> ErrorResult { Ok(()) } - pub fn Src(&self) -> DOMString { + fn Src(&self) -> DOMString { ~"" } - pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { Ok(()) } - pub fn Step(&self) -> DOMString { + fn Step(&self) -> DOMString { ~"" } - pub fn SetStep(&mut self, _step: DOMString) -> ErrorResult { + fn SetStep(&mut self, _step: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn DefaultValue(&self) -> DOMString { + fn DefaultValue(&self) -> DOMString { ~"" } - pub fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult { + fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult { Ok(()) } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { + fn SetValue(&mut self, _value: DOMString) -> ErrorResult { Ok(()) } - pub fn Width(&self) -> u32 { + fn Width(&self) -> u32 { 0 } - pub fn SetWidth(&mut self, _width: u32) { + fn SetWidth(&mut self, _width: u32) { } - pub fn WillValidate(&self) -> bool { + fn WillValidate(&self) -> bool { false } - pub fn SetWillValidate(&self, _will_validate: bool) { + fn SetWillValidate(&self, _will_validate: bool) { } - pub fn GetValidationMessage(&self) -> Fallible { + fn GetValidationMessage(&self) -> Fallible { Ok(~"") } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { false } - pub fn SetCustomValidity(&self, _error: DOMString) { + fn SetCustomValidity(&self, _error: DOMString) { } - pub fn Select(&self) { + fn Select(&self) { } - pub fn GetSelectionStart(&self) -> Fallible { + fn GetSelectionStart(&self) -> Fallible { Ok(0) } - pub fn SetSelectionStart(&mut self, _selection_start: i32) -> ErrorResult { + fn SetSelectionStart(&mut self, _selection_start: i32) -> ErrorResult { Ok(()) } - pub fn GetSelectionEnd(&self) -> Fallible { + fn GetSelectionEnd(&self) -> Fallible { Ok(0) } - pub fn SetSelectionEnd(&mut self, _selection_end: i32) -> ErrorResult { + fn SetSelectionEnd(&mut self, _selection_end: i32) -> ErrorResult { Ok(()) } - pub fn GetSelectionDirection(&self) -> Fallible { + fn GetSelectionDirection(&self) -> Fallible { Ok(~"") } - pub fn SetSelectionDirection(&mut self, _selection_direction: DOMString) -> ErrorResult { + fn SetSelectionDirection(&mut self, _selection_direction: DOMString) -> ErrorResult { Ok(()) } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn UseMap(&self) -> DOMString { + fn UseMap(&self) -> DOMString { ~"" } - pub fn SetUseMap(&mut self, _align: DOMString) -> ErrorResult { + fn SetUseMap(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmllabelelement.rs b/src/components/script/dom/htmllabelelement.rs index dcd080f7f24..c11132a7e9b 100644 --- a/src/components/script/dom/htmllabelelement.rs +++ b/src/components/script/dom/htmllabelelement.rs @@ -39,11 +39,17 @@ impl HTMLLabelElement { } } -impl HTMLLabelElement { - pub fn HtmlFor(&self) -> DOMString { +pub trait HTMLLabelElementMethods { + fn HtmlFor(&self) -> DOMString; + fn SetHtmlFor(&mut self, _html_for: DOMString); +} + +impl<'a> HTMLLabelElementMethods for JSRef<'a, HTMLLabelElement> { + fn HtmlFor(&self) -> DOMString { ~"" } - pub fn SetHtmlFor(&mut self, _html_for: DOMString) { + fn SetHtmlFor(&mut self, _html_for: DOMString) { } } + diff --git a/src/components/script/dom/htmllegendelement.rs b/src/components/script/dom/htmllegendelement.rs index 696247f40db..22ddb92aca5 100644 --- a/src/components/script/dom/htmllegendelement.rs +++ b/src/components/script/dom/htmllegendelement.rs @@ -40,12 +40,18 @@ impl HTMLLegendElement { } } -impl HTMLLegendElement { - pub fn Align(&self) -> DOMString { +pub trait HTMLLegendElementMethods { + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; +} + +impl<'a> HTMLLegendElementMethods for JSRef<'a, HTMLLegendElement> { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmllielement.rs b/src/components/script/dom/htmllielement.rs index d3b625e5987..97dee3e3f25 100644 --- a/src/components/script/dom/htmllielement.rs +++ b/src/components/script/dom/htmllielement.rs @@ -40,20 +40,28 @@ impl HTMLLIElement { } } -impl HTMLLIElement { - pub fn Value(&self) -> i32 { +pub trait HTMLLIElementMethods { + fn Value(&self) -> i32; + fn SetValue(&mut self, _value: i32) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; +} + +impl<'a> HTMLLIElementMethods for JSRef<'a, HTMLLIElement> { + fn Value(&self) -> i32 { 0 } - pub fn SetValue(&mut self, _value: i32) -> ErrorResult { + fn SetValue(&mut self, _value: i32) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmllinkelement.rs b/src/components/script/dom/htmllinkelement.rs index 3d474d1af64..f40bd112585 100644 --- a/src/components/script/dom/htmllinkelement.rs +++ b/src/components/script/dom/htmllinkelement.rs @@ -40,83 +40,107 @@ impl HTMLLinkElement { } } -impl HTMLLinkElement { - pub fn Disabled(&self) -> bool { +pub trait HTMLLinkElementMethods { + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disable: bool); + fn Href(&self) -> DOMString; + fn SetHref(&mut self, _href: DOMString) -> ErrorResult; + fn CrossOrigin(&self) -> DOMString; + fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult; + fn Rel(&self) -> DOMString; + fn SetRel(&mut self, _rel: DOMString) -> ErrorResult; + fn Media(&self) -> DOMString; + fn SetMedia(&mut self, _media: DOMString) -> ErrorResult; + fn Hreflang(&self) -> DOMString; + fn SetHreflang(&mut self, _href: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Charset(&self) -> DOMString; + fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult; + fn Rev(&self) -> DOMString; + fn SetRev(&mut self, _rev: DOMString) -> ErrorResult; + fn Target(&self) -> DOMString; + fn SetTarget(&mut self, _target: DOMString) -> ErrorResult; +} + +impl<'a> HTMLLinkElementMethods for JSRef<'a, HTMLLinkElement> { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disable: bool) { + fn SetDisabled(&mut self, _disable: bool) { } - pub fn Href(&self) -> DOMString { + fn Href(&self) -> DOMString { ~"" } - pub fn SetHref(&mut self, _href: DOMString) -> ErrorResult { + fn SetHref(&mut self, _href: DOMString) -> ErrorResult { Ok(()) } - pub fn CrossOrigin(&self) -> DOMString { + fn CrossOrigin(&self) -> DOMString { ~"" } - pub fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { + fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { Ok(()) } - pub fn Rel(&self) -> DOMString { + fn Rel(&self) -> DOMString { ~"" } - pub fn SetRel(&mut self, _rel: DOMString) -> ErrorResult { + fn SetRel(&mut self, _rel: DOMString) -> ErrorResult { Ok(()) } - pub fn Media(&self) -> DOMString { + fn Media(&self) -> DOMString { ~"" } - pub fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { + fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { Ok(()) } - pub fn Hreflang(&self) -> DOMString { + fn Hreflang(&self) -> DOMString { ~"" } - pub fn SetHreflang(&mut self, _href: DOMString) -> ErrorResult { + fn SetHreflang(&mut self, _href: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Charset(&self) -> DOMString { + fn Charset(&self) -> DOMString { ~"" } - pub fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { + fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { Ok(()) } - pub fn Rev(&self) -> DOMString { + fn Rev(&self) -> DOMString { ~"" } - pub fn SetRev(&mut self, _rev: DOMString) -> ErrorResult { + fn SetRev(&mut self, _rev: DOMString) -> ErrorResult { Ok(()) } - pub fn Target(&self) -> DOMString { + fn Target(&self) -> DOMString { ~"" } - pub fn SetTarget(&mut self, _target: DOMString) -> ErrorResult { + fn SetTarget(&mut self, _target: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlmainelement.rs b/src/components/script/dom/htmlmainelement.rs index ad9a2c6af1e..4024f1ee7fa 100644 --- a/src/components/script/dom/htmlmainelement.rs +++ b/src/components/script/dom/htmlmainelement.rs @@ -38,3 +38,6 @@ impl HTMLMainElement { Node::reflect_node(~element, document, HTMLMainElementBinding::Wrap) } } + +pub trait HTMLMainElementMethods { +} diff --git a/src/components/script/dom/htmlmapelement.rs b/src/components/script/dom/htmlmapelement.rs index 18dfd17e88b..dbc55463351 100644 --- a/src/components/script/dom/htmlmapelement.rs +++ b/src/components/script/dom/htmlmapelement.rs @@ -41,16 +41,22 @@ impl HTMLMapElement { } } -impl HTMLMapElement { - pub fn Name(&self) -> DOMString { +pub trait HTMLMapElementMethods { + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Areas(&self) -> Unrooted; +} + +impl<'a> HTMLMapElementMethods for JSRef<'a, HTMLMapElement> { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Areas(&self) -> Unrooted { + fn Areas(&self) -> Unrooted { let roots = RootCollection::new(); // FIXME: https://github.com/mozilla/servo/issues/1845 let doc = self.htmlelement.element.node.owner_doc().root(&roots); @@ -58,3 +64,4 @@ impl HTMLMapElement { HTMLCollection::new(&*window, Static(vec!())) } } + diff --git a/src/components/script/dom/htmlmediaelement.rs b/src/components/script/dom/htmlmediaelement.rs index 179c8e97407..4f68a11f9c0 100644 --- a/src/components/script/dom/htmlmediaelement.rs +++ b/src/components/script/dom/htmlmediaelement.rs @@ -2,7 +2,7 @@ * 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::js::JS; +use dom::bindings::js::{JS, JSRef}; use dom::bindings::codegen::InheritTypes::HTMLMediaElementDerived; use dom::bindings::error::ErrorResult; use dom::document::Document; @@ -35,139 +35,177 @@ impl HTMLMediaElement { } } -impl HTMLMediaElement { - pub fn Src(&self) -> DOMString { +pub trait HTMLMediaElementMethods { + fn Src(&self) -> DOMString; + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult; + fn CurrentSrc(&self) -> DOMString; + fn CrossOrigin(&self) -> DOMString; + fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult; + fn Preload(&self) -> DOMString; + fn SetPreload(&mut self, _preload: DOMString) -> ErrorResult; + fn Load(&self); + fn CanPlayType(&self, _type: DOMString) -> DOMString; + fn ReadyState(&self) -> u16; + fn Seeking(&self) -> bool; + fn CurrentTime(&self) -> f64; + fn SetCurrentTime(&mut self, _current_time: f64) -> ErrorResult; + fn GetDuration(&self) -> f64; + fn Paused(&self) -> bool; + fn DefaultPlaybackRate(&self) -> f64; + fn SetDefaultPlaybackRate(&mut self, _default_playback_rate: f64) -> ErrorResult; + fn PlaybackRate(&self) -> f64; + fn SetPlaybackRate(&mut self, _playback_rate: f64) -> ErrorResult; + fn Ended(&self) -> bool; + fn Autoplay(&self) -> bool; + fn SetAutoplay(&mut self, _autoplay: bool) -> ErrorResult; + fn Loop(&self) -> bool; + fn SetLoop(&mut self, _loop: bool) -> ErrorResult; + fn Play(&self) -> ErrorResult; + fn Pause(&self) -> ErrorResult; + fn Controls(&self) -> bool; + fn SetControls(&mut self, _controls: bool) -> ErrorResult; + fn Volume(&self) -> f64; + fn SetVolume(&mut self, _volume: f64) -> ErrorResult; + fn Muted(&self) -> bool; + fn SetMuted(&mut self, _muted: bool); + fn DefaultMuted(&self) -> bool; + fn SetDefaultMuted(&mut self, _default_muted: bool) -> ErrorResult; +} + +impl<'a> HTMLMediaElementMethods for JSRef<'a, HTMLMediaElement> { + fn Src(&self) -> DOMString { ~"" } - pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { Ok(()) } - pub fn CurrentSrc(&self) -> DOMString { + fn CurrentSrc(&self) -> DOMString { ~"" } - pub fn CrossOrigin(&self) -> DOMString { + fn CrossOrigin(&self) -> DOMString { ~"" } - pub fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { + fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { Ok(()) } - pub fn Preload(&self) -> DOMString { + fn Preload(&self) -> DOMString { ~"" } - pub fn SetPreload(&mut self, _preload: DOMString) -> ErrorResult { + fn SetPreload(&mut self, _preload: DOMString) -> ErrorResult { Ok(()) } - pub fn Load(&self) { + fn Load(&self) { } - pub fn CanPlayType(&self, _type: DOMString) -> DOMString { + fn CanPlayType(&self, _type: DOMString) -> DOMString { ~"" } - pub fn ReadyState(&self) -> u16 { + fn ReadyState(&self) -> u16 { 0 } - pub fn Seeking(&self) -> bool { + fn Seeking(&self) -> bool { false } - pub fn CurrentTime(&self) -> f64 { + fn CurrentTime(&self) -> f64 { 0f64 } - pub fn SetCurrentTime(&mut self, _current_time: f64) -> ErrorResult { + fn SetCurrentTime(&mut self, _current_time: f64) -> ErrorResult { Ok(()) } - pub fn GetDuration(&self) -> f64 { + fn GetDuration(&self) -> f64 { 0f64 } - pub fn Paused(&self) -> bool { + fn Paused(&self) -> bool { false } - pub fn DefaultPlaybackRate(&self) -> f64 { + fn DefaultPlaybackRate(&self) -> f64 { 0f64 } - pub fn SetDefaultPlaybackRate(&mut self, _default_playback_rate: f64) -> ErrorResult { + fn SetDefaultPlaybackRate(&mut self, _default_playback_rate: f64) -> ErrorResult { Ok(()) } - pub fn PlaybackRate(&self) -> f64 { + fn PlaybackRate(&self) -> f64 { 0f64 } - pub fn SetPlaybackRate(&mut self, _playback_rate: f64) -> ErrorResult { + fn SetPlaybackRate(&mut self, _playback_rate: f64) -> ErrorResult { Ok(()) } - pub fn Ended(&self) -> bool { + fn Ended(&self) -> bool { false } - pub fn Autoplay(&self) -> bool { + fn Autoplay(&self) -> bool { false } - pub fn SetAutoplay(&mut self, _autoplay: bool) -> ErrorResult { + fn SetAutoplay(&mut self, _autoplay: bool) -> ErrorResult { Ok(()) } - pub fn Loop(&self) -> bool { + fn Loop(&self) -> bool { false } - pub fn SetLoop(&mut self, _loop: bool) -> ErrorResult { + fn SetLoop(&mut self, _loop: bool) -> ErrorResult { Ok(()) } - pub fn Play(&self) -> ErrorResult { + fn Play(&self) -> ErrorResult { Ok(()) } - pub fn Pause(&self) -> ErrorResult { + fn Pause(&self) -> ErrorResult { Ok(()) } - pub fn Controls(&self) -> bool { + fn Controls(&self) -> bool { false } - pub fn SetControls(&mut self, _controls: bool) -> ErrorResult { + fn SetControls(&mut self, _controls: bool) -> ErrorResult { Ok(()) } - pub fn Volume(&self) -> f64 { + fn Volume(&self) -> f64 { 0f64 } - pub fn SetVolume(&mut self, _volume: f64) -> ErrorResult { + fn SetVolume(&mut self, _volume: f64) -> ErrorResult { Ok(()) } - pub fn Muted(&self) -> bool { + fn Muted(&self) -> bool { false } - pub fn SetMuted(&mut self, _muted: bool) { + fn SetMuted(&mut self, _muted: bool) { } - pub fn DefaultMuted(&self) -> bool { + fn DefaultMuted(&self) -> bool { false } - pub fn SetDefaultMuted(&mut self, _default_muted: bool) -> ErrorResult { + fn SetDefaultMuted(&mut self, _default_muted: bool) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlmetaelement.rs b/src/components/script/dom/htmlmetaelement.rs index 737cc6710fc..89520346b53 100644 --- a/src/components/script/dom/htmlmetaelement.rs +++ b/src/components/script/dom/htmlmetaelement.rs @@ -40,36 +40,48 @@ impl HTMLMetaElement { } } -impl HTMLMetaElement { - pub fn Name(&self) -> DOMString { +pub trait HTMLMetaElementMethods { + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn HttpEquiv(&self) -> DOMString; + fn SetHttpEquiv(&mut self, _http_equiv: DOMString) -> ErrorResult; + fn Content(&self) -> DOMString; + fn SetContent(&mut self, _content: DOMString) -> ErrorResult; + fn Scheme(&self) -> DOMString; + fn SetScheme(&mut self, _scheme: DOMString) -> ErrorResult; +} + +impl<'a> HTMLMetaElementMethods for JSRef<'a, HTMLMetaElement> { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn HttpEquiv(&self) -> DOMString { + fn HttpEquiv(&self) -> DOMString { ~"" } - pub fn SetHttpEquiv(&mut self, _http_equiv: DOMString) -> ErrorResult { + fn SetHttpEquiv(&mut self, _http_equiv: DOMString) -> ErrorResult { Ok(()) } - pub fn Content(&self) -> DOMString { + fn Content(&self) -> DOMString { ~"" } - pub fn SetContent(&mut self, _content: DOMString) -> ErrorResult { + fn SetContent(&mut self, _content: DOMString) -> ErrorResult { Ok(()) } - pub fn Scheme(&self) -> DOMString { + fn Scheme(&self) -> DOMString { ~"" } - pub fn SetScheme(&mut self, _scheme: DOMString) -> ErrorResult { + fn SetScheme(&mut self, _scheme: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlmeterelement.rs b/src/components/script/dom/htmlmeterelement.rs index 9d5f699ae14..685d96f7a0b 100644 --- a/src/components/script/dom/htmlmeterelement.rs +++ b/src/components/script/dom/htmlmeterelement.rs @@ -40,52 +40,68 @@ impl HTMLMeterElement { } } -impl HTMLMeterElement { - pub fn Value(&self) -> f64 { +pub trait HTMLMeterElementMethods { + fn Value(&self) -> f64; + fn SetValue(&mut self, _value: f64) -> ErrorResult; + fn Min(&self) -> f64; + fn SetMin(&mut self, _min: f64) -> ErrorResult; + fn Max(&self) -> f64; + fn SetMax(&mut self, _max: f64) -> ErrorResult; + fn Low(&self) -> f64; + fn SetLow(&mut self, _low: f64) -> ErrorResult; + fn High(&self) -> f64; + fn SetHigh(&mut self, _high: f64) -> ErrorResult; + fn Optimum(&self) -> f64; + fn SetOptimum(&mut self, _optimum: f64) -> ErrorResult; +} + +impl<'a> HTMLMeterElementMethods for JSRef<'a, HTMLMeterElement> { + fn Value(&self) -> f64 { 0.0 } - pub fn SetValue(&mut self, _value: f64) -> ErrorResult { + fn SetValue(&mut self, _value: f64) -> ErrorResult { Ok(()) } - pub fn Min(&self) -> f64 { + fn Min(&self) -> f64 { 0.0 } - pub fn SetMin(&mut self, _min: f64) -> ErrorResult { + fn SetMin(&mut self, _min: f64) -> ErrorResult { Ok(()) } - pub fn Max(&self) -> f64 { + fn Max(&self) -> f64 { 0.0 } - pub fn SetMax(&mut self, _max: f64) -> ErrorResult { + fn SetMax(&mut self, _max: f64) -> ErrorResult { Ok(()) } - pub fn Low(&self) -> f64 { + fn Low(&self) -> f64 { 0.0 } - pub fn SetLow(&mut self, _low: f64) -> ErrorResult { + fn SetLow(&mut self, _low: f64) -> ErrorResult { Ok(()) } - pub fn High(&self) -> f64 { + fn High(&self) -> f64 { 0.0 } - pub fn SetHigh(&mut self, _high: f64) -> ErrorResult { + fn SetHigh(&mut self, _high: f64) -> ErrorResult { Ok(()) } - pub fn Optimum(&self) -> f64 { + fn Optimum(&self) -> f64 { 0.0 } - pub fn SetOptimum(&mut self, _optimum: f64) -> ErrorResult { + fn SetOptimum(&mut self, _optimum: f64) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlmodelement.rs b/src/components/script/dom/htmlmodelement.rs index 41ed8244a9d..6a9b33106a2 100644 --- a/src/components/script/dom/htmlmodelement.rs +++ b/src/components/script/dom/htmlmodelement.rs @@ -40,20 +40,28 @@ impl HTMLModElement { } } -impl HTMLModElement { - pub fn Cite(&self) -> DOMString { +pub trait HTMLModElementMethods { + fn Cite(&self) -> DOMString; + fn SetCite(&mut self, _cite: DOMString) -> ErrorResult; + fn DateTime(&self) -> DOMString; + fn SetDateTime(&mut self, _datetime: DOMString) -> ErrorResult; +} + +impl<'a> HTMLModElementMethods for JSRef<'a, HTMLModElement> { + fn Cite(&self) -> DOMString { ~"" } - pub fn SetCite(&mut self, _cite: DOMString) -> ErrorResult { + fn SetCite(&mut self, _cite: DOMString) -> ErrorResult { Ok(()) } - pub fn DateTime(&self) -> DOMString { + fn DateTime(&self) -> DOMString { ~"" } - pub fn SetDateTime(&mut self, _datetime: DOMString) -> ErrorResult { + fn SetDateTime(&mut self, _datetime: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlobjectelement.rs b/src/components/script/dom/htmlobjectelement.rs index 4814ac4b337..7fcc3c0a5da 100644 --- a/src/components/script/dom/htmlobjectelement.rs +++ b/src/components/script/dom/htmlobjectelement.rs @@ -2,6 +2,7 @@ * 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::attr::AttrMethods; use dom::bindings::codegen::BindingDeclarations::HTMLObjectElementBinding; use dom::bindings::codegen::InheritTypes::HTMLObjectElementDerived; use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast}; @@ -79,170 +80,214 @@ impl<'a> ProcessDataURL for JSRef<'a, HTMLObjectElement> { } } -impl HTMLObjectElement { - pub fn Data(&self) -> DOMString { +pub trait HTMLObjectElementMethods { + fn Data(&self) -> DOMString; + fn SetData(&mut self, _data: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn UseMap(&self) -> DOMString; + fn SetUseMap(&mut self, _use_map: DOMString) -> ErrorResult; + fn GetForm(&self) -> Option>; + fn Width(&self) -> DOMString; + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult; + fn Height(&self) -> DOMString; + fn SetHeight(&mut self, _height: DOMString) -> ErrorResult; + fn GetContentDocument(&self) -> Option>; + fn GetContentWindow(&self) -> Option>; + fn WillValidate(&self) -> bool; + fn Validity(&self) -> Unrooted; + fn ValidationMessage(&self) -> DOMString; + fn CheckValidity(&self) -> bool; + fn SetCustomValidity(&mut self, _error: DOMString); + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; + fn Archive(&self) -> DOMString; + fn SetArchive(&mut self, _archive: DOMString) -> ErrorResult; + fn Code(&self) -> DOMString; + fn SetCode(&mut self, _code: DOMString) -> ErrorResult; + fn Declare(&self) -> bool; + fn SetDeclare(&mut self, _declare: bool) -> ErrorResult; + fn Hspace(&self) -> u32; + fn SetHspace(&mut self, _hspace: u32) -> ErrorResult; + fn Standby(&self) -> DOMString; + fn SetStandby(&mut self, _standby: DOMString) -> ErrorResult; + fn Vspace(&self) -> u32; + fn SetVspace(&mut self, _vspace: u32) -> ErrorResult; + fn CodeBase(&self) -> DOMString; + fn SetCodeBase(&mut self, _codebase: DOMString) -> ErrorResult; + fn CodeType(&self) -> DOMString; + fn SetCodeType(&mut self, _codetype: DOMString) -> ErrorResult; + fn Border(&self) -> DOMString; + fn SetBorder(&mut self, _border: DOMString) -> ErrorResult; + fn GetSVGDocument(&self) -> Option>; +} + +impl<'a> HTMLObjectElementMethods for JSRef<'a, HTMLObjectElement> { + fn Data(&self) -> DOMString { ~"" } - pub fn SetData(&mut self, _data: DOMString) -> ErrorResult { + fn SetData(&mut self, _data: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn UseMap(&self) -> DOMString { + fn UseMap(&self) -> DOMString { ~"" } - pub fn SetUseMap(&mut self, _use_map: DOMString) -> ErrorResult { + fn SetUseMap(&mut self, _use_map: DOMString) -> ErrorResult { Ok(()) } - pub fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { None } - pub fn Width(&self) -> DOMString { + fn Width(&self) -> DOMString { ~"" } - pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { Ok(()) } - pub fn Height(&self) -> DOMString { + fn Height(&self) -> DOMString { ~"" } - pub fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { + fn SetHeight(&mut self, _height: DOMString) -> ErrorResult { Ok(()) } - pub fn GetContentDocument(&self) -> Option> { + fn GetContentDocument(&self) -> Option> { None } - pub fn GetContentWindow(&self) -> Option> { + fn GetContentWindow(&self) -> Option> { None } - pub fn WillValidate(&self) -> bool { + fn WillValidate(&self) -> bool { false } - pub fn Validity(&self) -> Unrooted { + fn Validity(&self) -> Unrooted { let roots = RootCollection::new(); let doc = self.htmlelement.element.node.owner_doc().root(&roots); let window = doc.deref().window.root(&roots); ValidityState::new(&window.root_ref()) } - pub fn ValidationMessage(&self) -> DOMString { + fn ValidationMessage(&self) -> DOMString { ~"" } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { false } - pub fn SetCustomValidity(&mut self, _error: DOMString) { + fn SetCustomValidity(&mut self, _error: DOMString) { } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Archive(&self) -> DOMString { + fn Archive(&self) -> DOMString { ~"" } - pub fn SetArchive(&mut self, _archive: DOMString) -> ErrorResult { + fn SetArchive(&mut self, _archive: DOMString) -> ErrorResult { Ok(()) } - pub fn Code(&self) -> DOMString { + fn Code(&self) -> DOMString { ~"" } - pub fn SetCode(&mut self, _code: DOMString) -> ErrorResult { + fn SetCode(&mut self, _code: DOMString) -> ErrorResult { Ok(()) } - pub fn Declare(&self) -> bool { + fn Declare(&self) -> bool { false } - pub fn SetDeclare(&mut self, _declare: bool) -> ErrorResult { + fn SetDeclare(&mut self, _declare: bool) -> ErrorResult { Ok(()) } - pub fn Hspace(&self) -> u32 { + fn Hspace(&self) -> u32 { 0 } - pub fn SetHspace(&mut self, _hspace: u32) -> ErrorResult { + fn SetHspace(&mut self, _hspace: u32) -> ErrorResult { Ok(()) } - pub fn Standby(&self) -> DOMString { + fn Standby(&self) -> DOMString { ~"" } - pub fn SetStandby(&mut self, _standby: DOMString) -> ErrorResult { + fn SetStandby(&mut self, _standby: DOMString) -> ErrorResult { Ok(()) } - pub fn Vspace(&self) -> u32 { + fn Vspace(&self) -> u32 { 0 } - pub fn SetVspace(&mut self, _vspace: u32) -> ErrorResult { + fn SetVspace(&mut self, _vspace: u32) -> ErrorResult { Ok(()) } - pub fn CodeBase(&self) -> DOMString { + fn CodeBase(&self) -> DOMString { ~"" } - pub fn SetCodeBase(&mut self, _codebase: DOMString) -> ErrorResult { + fn SetCodeBase(&mut self, _codebase: DOMString) -> ErrorResult { Ok(()) } - pub fn CodeType(&self) -> DOMString { + fn CodeType(&self) -> DOMString { ~"" } - pub fn SetCodeType(&mut self, _codetype: DOMString) -> ErrorResult { + fn SetCodeType(&mut self, _codetype: DOMString) -> ErrorResult { Ok(()) } - pub fn Border(&self) -> DOMString { + fn Border(&self) -> DOMString { ~"" } - pub fn SetBorder(&mut self, _border: DOMString) -> ErrorResult { + fn SetBorder(&mut self, _border: DOMString) -> ErrorResult { Ok(()) } - pub fn GetSVGDocument(&self) -> Option> { + fn GetSVGDocument(&self) -> Option> { None } } diff --git a/src/components/script/dom/htmlolistelement.rs b/src/components/script/dom/htmlolistelement.rs index 1330e2cbd40..a7191eb4f31 100644 --- a/src/components/script/dom/htmlolistelement.rs +++ b/src/components/script/dom/htmlolistelement.rs @@ -40,36 +40,48 @@ impl HTMLOListElement { } } -impl HTMLOListElement { - pub fn Reversed(&self) -> bool { +pub trait HTMLOListElementMethods { + fn Reversed(&self) -> bool; + fn SetReversed(&self, _reversed: bool) -> ErrorResult; + fn Start(&self) -> i32; + fn SetStart(&mut self, _start: i32) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Compact(&self) -> bool; + fn SetCompact(&self, _compact: bool) -> ErrorResult; +} + +impl<'a> HTMLOListElementMethods for JSRef<'a, HTMLOListElement> { + fn Reversed(&self) -> bool { false } - pub fn SetReversed(&self, _reversed: bool) -> ErrorResult { + fn SetReversed(&self, _reversed: bool) -> ErrorResult { Ok(()) } - pub fn Start(&self) -> i32 { + fn Start(&self) -> i32 { 0 } - pub fn SetStart(&mut self, _start: i32) -> ErrorResult { + fn SetStart(&mut self, _start: i32) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Compact(&self) -> bool { + fn Compact(&self) -> bool { false } - pub fn SetCompact(&self, _compact: bool) -> ErrorResult { + fn SetCompact(&self, _compact: bool) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmloptgroupelement.rs b/src/components/script/dom/htmloptgroupelement.rs index d5eab9bec46..05f4cb5ef03 100644 --- a/src/components/script/dom/htmloptgroupelement.rs +++ b/src/components/script/dom/htmloptgroupelement.rs @@ -40,20 +40,28 @@ impl HTMLOptGroupElement { } } -impl HTMLOptGroupElement { - pub fn Disabled(&self) -> bool { +pub trait HTMLOptGroupElementMethods { + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult; + fn Label(&self) -> DOMString; + fn SetLabel(&mut self, _label: DOMString) -> ErrorResult; +} + +impl<'a> HTMLOptGroupElementMethods for JSRef<'a, HTMLOptGroupElement> { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { Ok(()) } - pub fn Label(&self) -> DOMString { + fn Label(&self) -> DOMString { ~"" } - pub fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { + fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmloptionelement.rs b/src/components/script/dom/htmloptionelement.rs index bf1f594009e..e9793fc1690 100644 --- a/src/components/script/dom/htmloptionelement.rs +++ b/src/components/script/dom/htmloptionelement.rs @@ -41,60 +41,78 @@ impl HTMLOptionElement { } } -impl HTMLOptionElement { - pub fn Disabled(&self) -> bool { +pub trait HTMLOptionElementMethods { + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult; + fn GetForm(&self) -> Option>; + fn Label(&self) -> DOMString; + fn SetLabel(&mut self, _label: DOMString) -> ErrorResult; + fn DefaultSelected(&self) -> bool; + fn SetDefaultSelected(&mut self, _default_selected: bool) -> ErrorResult; + fn Selected(&self) -> bool; + fn SetSelected(&mut self, _selected: bool) -> ErrorResult; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString) -> ErrorResult; + fn Text(&self) -> DOMString; + fn SetText(&mut self, _text: DOMString) -> ErrorResult; + fn Index(&self) -> i32; +} + +impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { Ok(()) } - pub fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { None } - pub fn Label(&self) -> DOMString { + fn Label(&self) -> DOMString { ~"" } - pub fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { + fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { Ok(()) } - pub fn DefaultSelected(&self) -> bool { + fn DefaultSelected(&self) -> bool { false } - pub fn SetDefaultSelected(&mut self, _default_selected: bool) -> ErrorResult { + fn SetDefaultSelected(&mut self, _default_selected: bool) -> ErrorResult { Ok(()) } - pub fn Selected(&self) -> bool { + fn Selected(&self) -> bool { false } - pub fn SetSelected(&mut self, _selected: bool) -> ErrorResult { + fn SetSelected(&mut self, _selected: bool) -> ErrorResult { Ok(()) } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { + fn SetValue(&mut self, _value: DOMString) -> ErrorResult { Ok(()) } - pub fn Text(&self) -> DOMString { + fn Text(&self) -> DOMString { ~"" } - pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { + fn SetText(&mut self, _text: DOMString) -> ErrorResult { Ok(()) } - pub fn Index(&self) -> i32 { + fn Index(&self) -> i32 { 0 } } + diff --git a/src/components/script/dom/htmloutputelement.rs b/src/components/script/dom/htmloutputelement.rs index a72d9410d20..c7262b23de0 100644 --- a/src/components/script/dom/htmloutputelement.rs +++ b/src/components/script/dom/htmloutputelement.rs @@ -42,68 +42,88 @@ impl HTMLOutputElement { } } -impl HTMLOutputElement { - pub fn GetForm(&self) -> Option> { +pub trait HTMLOutputElementMethods { + fn GetForm(&self) -> Option>; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn DefaultValue(&self) -> DOMString; + fn SetDefaultValue(&mut self, _value: DOMString) -> ErrorResult; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString) -> ErrorResult; + fn WillValidate(&self) -> bool; + fn SetWillValidate(&mut self, _will_validate: bool); + fn Validity(&self) -> Unrooted; + fn SetValidity(&mut self, _validity: JS); + fn ValidationMessage(&self) -> DOMString; + fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult; + fn CheckValidity(&self) -> bool; + fn SetCustomValidity(&mut self, _error: DOMString); +} + +impl<'a> HTMLOutputElementMethods for JSRef<'a, HTMLOutputElement> { + fn GetForm(&self) -> Option> { None } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn DefaultValue(&self) -> DOMString { + fn DefaultValue(&self) -> DOMString { ~"" } - pub fn SetDefaultValue(&mut self, _value: DOMString) -> ErrorResult { + fn SetDefaultValue(&mut self, _value: DOMString) -> ErrorResult { Ok(()) } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { + fn SetValue(&mut self, _value: DOMString) -> ErrorResult { Ok(()) } - pub fn WillValidate(&self) -> bool { + fn WillValidate(&self) -> bool { false } - pub fn SetWillValidate(&mut self, _will_validate: bool) { + fn SetWillValidate(&mut self, _will_validate: bool) { } - pub fn Validity(&self) -> Unrooted { + fn Validity(&self) -> Unrooted { let roots = RootCollection::new(); let doc = self.htmlelement.element.node.owner_doc().root(&roots); let window = doc.deref().window.root(&roots); ValidityState::new(&*window) } - pub fn SetValidity(&mut self, _validity: JS) { + fn SetValidity(&mut self, _validity: JS) { } - pub fn ValidationMessage(&self) -> DOMString { + fn ValidationMessage(&self) -> DOMString { ~"" } - pub fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { + fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { Ok(()) } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { true } - pub fn SetCustomValidity(&mut self, _error: DOMString) { + fn SetCustomValidity(&mut self, _error: DOMString) { } } + diff --git a/src/components/script/dom/htmlparagraphelement.rs b/src/components/script/dom/htmlparagraphelement.rs index d5dafd6abda..90e3282c915 100644 --- a/src/components/script/dom/htmlparagraphelement.rs +++ b/src/components/script/dom/htmlparagraphelement.rs @@ -40,12 +40,18 @@ impl HTMLParagraphElement { } } -impl HTMLParagraphElement { - pub fn Align(&self) -> DOMString { +pub trait HTMLParagraphElementMethods { + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; +} + +impl<'a> HTMLParagraphElementMethods for JSRef<'a, HTMLParagraphElement> { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlparamelement.rs b/src/components/script/dom/htmlparamelement.rs index db4d9ec1b89..41f45b31d17 100644 --- a/src/components/script/dom/htmlparamelement.rs +++ b/src/components/script/dom/htmlparamelement.rs @@ -40,36 +40,48 @@ impl HTMLParamElement { } } -impl HTMLParamElement { - pub fn Name(&self) -> DOMString { +pub trait HTMLParamElementMethods { + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn ValueType(&self) -> DOMString; + fn SetValueType(&mut self, _value_type: DOMString) -> ErrorResult; +} + +impl<'a> HTMLParamElementMethods for JSRef<'a, HTMLParamElement> { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) -> ErrorResult { + fn SetValue(&mut self, _value: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn ValueType(&self) -> DOMString { + fn ValueType(&self) -> DOMString { ~"" } - pub fn SetValueType(&mut self, _value_type: DOMString) -> ErrorResult { + fn SetValueType(&mut self, _value_type: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlpreelement.rs b/src/components/script/dom/htmlpreelement.rs index e2c404074bd..34eb9923a52 100644 --- a/src/components/script/dom/htmlpreelement.rs +++ b/src/components/script/dom/htmlpreelement.rs @@ -40,12 +40,18 @@ impl HTMLPreElement { } } -impl HTMLPreElement { - pub fn Width(&self) -> i32 { +pub trait HTMLPreElementMethods { + fn Width(&self) -> i32; + fn SetWidth(&mut self, _width: i32) -> ErrorResult; +} + +impl<'a> HTMLPreElementMethods for JSRef<'a, HTMLPreElement> { + fn Width(&self) -> i32 { 0 } - pub fn SetWidth(&mut self, _width: i32) -> ErrorResult { + fn SetWidth(&mut self, _width: i32) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlprogresselement.rs b/src/components/script/dom/htmlprogresselement.rs index 024025afa6d..891df6918fe 100644 --- a/src/components/script/dom/htmlprogresselement.rs +++ b/src/components/script/dom/htmlprogresselement.rs @@ -40,28 +40,38 @@ impl HTMLProgressElement { } } -impl HTMLProgressElement { - pub fn Value(&self) -> f64 { +pub trait HTMLProgressElementMethods { + fn Value(&self) -> f64; + fn SetValue(&mut self, _value: f64) -> ErrorResult; + fn Max(&self) -> f64; + fn SetMax(&mut self, _max: f64) -> ErrorResult; + fn Position(&self) -> f64; + fn GetPositiom(&self) -> Fallible; +} + +impl<'a> HTMLProgressElementMethods for JSRef<'a, HTMLProgressElement> { + fn Value(&self) -> f64 { 0f64 } - pub fn SetValue(&mut self, _value: f64) -> ErrorResult { + fn SetValue(&mut self, _value: f64) -> ErrorResult { Ok(()) } - pub fn Max(&self) -> f64 { + fn Max(&self) -> f64 { 0f64 } - pub fn SetMax(&mut self, _max: f64) -> ErrorResult { + fn SetMax(&mut self, _max: f64) -> ErrorResult { Ok(()) } - pub fn Position(&self) -> f64 { + fn Position(&self) -> f64 { 0f64 } - pub fn GetPositiom(&self) -> Fallible { + fn GetPositiom(&self) -> Fallible { Ok(0f64) } } + diff --git a/src/components/script/dom/htmlquoteelement.rs b/src/components/script/dom/htmlquoteelement.rs index 9c67c2ac2f4..db7edcbede4 100644 --- a/src/components/script/dom/htmlquoteelement.rs +++ b/src/components/script/dom/htmlquoteelement.rs @@ -40,12 +40,18 @@ impl HTMLQuoteElement { } } -impl HTMLQuoteElement { - pub fn Cite(&self) -> DOMString { +pub trait HTMLQuoteElementMethods { + fn Cite(&self) -> DOMString; + fn SetCite(&self, _cite: DOMString) -> ErrorResult; +} + +impl<'a> HTMLQuoteElementMethods for JSRef<'a, HTMLQuoteElement> { + fn Cite(&self) -> DOMString { ~"" } - pub fn SetCite(&self, _cite: DOMString) -> ErrorResult { + fn SetCite(&self, _cite: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlscriptelement.rs b/src/components/script/dom/htmlscriptelement.rs index 808b05a12cf..fabe876a10f 100644 --- a/src/components/script/dom/htmlscriptelement.rs +++ b/src/components/script/dom/htmlscriptelement.rs @@ -41,77 +41,99 @@ impl HTMLScriptElement { } } -impl HTMLScriptElement { - pub fn Src(&self, abstract_self: &JSRef) -> DOMString { +pub trait HTMLScriptElementMethods { + fn Src(&self, abstract_self: &JSRef) -> DOMString; + fn SetSrc(&mut self, _abstract_self: &JSRef, _src: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Charset(&self) -> DOMString; + fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult; + fn Async(&self) -> bool; + fn SetAsync(&self, _async: bool) -> ErrorResult; + fn Defer(&self) -> bool; + fn SetDefer(&self, _defer: bool) -> ErrorResult; + fn CrossOrigin(&self) -> DOMString; + fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult; + fn Text(&self) -> DOMString; + fn SetText(&mut self, _text: DOMString) -> ErrorResult; + fn Event(&self) -> DOMString; + fn SetEvent(&mut self, _event: DOMString) -> ErrorResult; + fn HtmlFor(&self) -> DOMString; + fn SetHtmlFor(&mut self, _html_for: DOMString) -> ErrorResult; +} + +impl<'a> HTMLScriptElementMethods for JSRef<'a, HTMLScriptElement> { + fn Src(&self, abstract_self: &JSRef) -> DOMString { let element: &JSRef = ElementCast::from_ref(abstract_self); element.get_url_attribute("src") } - pub fn SetSrc(&mut self, _abstract_self: &JSRef, _src: DOMString) -> ErrorResult { + fn SetSrc(&mut self, _abstract_self: &JSRef, _src: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Charset(&self) -> DOMString { + fn Charset(&self) -> DOMString { ~"" } - pub fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { + fn SetCharset(&mut self, _charset: DOMString) -> ErrorResult { Ok(()) } - pub fn Async(&self) -> bool { + fn Async(&self) -> bool { false } - pub fn SetAsync(&self, _async: bool) -> ErrorResult { + fn SetAsync(&self, _async: bool) -> ErrorResult { Ok(()) } - pub fn Defer(&self) -> bool { + fn Defer(&self) -> bool { false } - pub fn SetDefer(&self, _defer: bool) -> ErrorResult { + fn SetDefer(&self, _defer: bool) -> ErrorResult { Ok(()) } - pub fn CrossOrigin(&self) -> DOMString { + fn CrossOrigin(&self) -> DOMString { ~"" } - pub fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { + fn SetCrossOrigin(&mut self, _cross_origin: DOMString) -> ErrorResult { Ok(()) } - pub fn Text(&self) -> DOMString { + fn Text(&self) -> DOMString { ~"" } - pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { + fn SetText(&mut self, _text: DOMString) -> ErrorResult { Ok(()) } - pub fn Event(&self) -> DOMString { + fn Event(&self) -> DOMString { ~"" } - pub fn SetEvent(&mut self, _event: DOMString) -> ErrorResult { + fn SetEvent(&mut self, _event: DOMString) -> ErrorResult { Ok(()) } - pub fn HtmlFor(&self) -> DOMString { + fn HtmlFor(&self) -> DOMString { ~"" } - pub fn SetHtmlFor(&mut self, _html_for: DOMString) -> ErrorResult { + fn SetHtmlFor(&mut self, _html_for: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlselectelement.rs b/src/components/script/dom/htmlselectelement.rs index 666cb529774..6aa15a1e982 100644 --- a/src/components/script/dom/htmlselectelement.rs +++ b/src/components/script/dom/htmlselectelement.rs @@ -44,141 +44,180 @@ impl HTMLSelectElement { } } -impl HTMLSelectElement { - pub fn Autofocus(&self) -> bool { +pub trait HTMLSelectElementMethods { + fn Autofocus(&self) -> bool; + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult; + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult; + fn GetForm(&self) -> Option>; + fn Multiple(&self) -> bool; + fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Required(&self) -> bool; + fn SetRequired(&mut self, _multiple: bool) -> ErrorResult; + fn Size(&self) -> u32; + fn SetSize(&mut self, _size: u32) -> ErrorResult; + fn Type(&self) -> DOMString; + fn Length(&self) -> u32; + fn SetLength(&mut self, _length: u32) -> ErrorResult; + fn Item(&self, _index: u32) -> Option>; + fn NamedItem(&self, _name: DOMString) -> Option>; + fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option>; + fn IndexedSetter(&mut self, _index: u32, _option: Option>) -> ErrorResult; + fn Remove_(&self); + fn Remove(&self, _index: i32); + fn SelectedIndex(&self) -> i32; + fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString); + fn WillValidate(&self) -> bool; + fn SetWillValidate(&mut self, _will_validate: bool); + fn Validity(&self) -> Unrooted; + fn SetValidity(&mut self, _validity: JS); + fn ValidationMessage(&self) -> DOMString; + fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult; + fn CheckValidity(&self) -> bool; + fn SetCustomValidity(&mut self, _error: DOMString); + fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option) -> ErrorResult; +} + +impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> { + fn Autofocus(&self) -> bool { false } - pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { Ok(()) } - pub fn Disabled(&self) -> bool { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { Ok(()) } - pub fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { None } - pub fn Multiple(&self) -> bool { + fn Multiple(&self) -> bool { false } - pub fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult { + fn SetMultiple(&mut self, _multiple: bool) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Required(&self) -> bool { + fn Required(&self) -> bool { false } - pub fn SetRequired(&mut self, _multiple: bool) -> ErrorResult { + fn SetRequired(&mut self, _multiple: bool) -> ErrorResult { Ok(()) } - pub fn Size(&self) -> u32 { + fn Size(&self) -> u32 { 0 } - pub fn SetSize(&mut self, _size: u32) -> ErrorResult { + fn SetSize(&mut self, _size: u32) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn Length(&self) -> u32 { + fn Length(&self) -> u32 { 0 } - pub fn SetLength(&mut self, _length: u32) -> ErrorResult { + fn SetLength(&mut self, _length: u32) -> ErrorResult { Ok(()) } - pub fn Item(&self, _index: u32) -> Option> { + fn Item(&self, _index: u32) -> Option> { None } - pub fn NamedItem(&self, _name: DOMString) -> Option> { + fn NamedItem(&self, _name: DOMString) -> Option> { None } - pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option> { + fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option> { None } - pub fn IndexedSetter(&mut self, _index: u32, _option: Option>) -> ErrorResult { + fn IndexedSetter(&mut self, _index: u32, _option: Option>) -> ErrorResult { Ok(()) } - pub fn Remove_(&self) { + fn Remove_(&self) { } - pub fn Remove(&self, _index: i32) { + fn Remove(&self, _index: i32) { } - pub fn SelectedIndex(&self) -> i32 { + fn SelectedIndex(&self) -> i32 { 0 } - pub fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult { + fn SetSelectedIndex(&mut self, _index: i32) -> ErrorResult { Ok(()) } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) { + fn SetValue(&mut self, _value: DOMString) { } - pub fn WillValidate(&self) -> bool { + fn WillValidate(&self) -> bool { false } - pub fn SetWillValidate(&mut self, _will_validate: bool) { + fn SetWillValidate(&mut self, _will_validate: bool) { } - pub fn Validity(&self) -> Unrooted { + fn Validity(&self) -> Unrooted { let roots = RootCollection::new(); let doc = self.htmlelement.element.node.owner_doc().root(&roots); let window = doc.deref().window.root(&roots); ValidityState::new(&*window) } - pub fn SetValidity(&mut self, _validity: JS) { + fn SetValidity(&mut self, _validity: JS) { } - pub fn ValidationMessage(&self) -> DOMString { + fn ValidationMessage(&self) -> DOMString { ~"" } - pub fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { + fn SetValidationMessage(&mut self, _message: DOMString) -> ErrorResult { Ok(()) } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { true } - pub fn SetCustomValidity(&mut self, _error: DOMString) { + fn SetCustomValidity(&mut self, _error: DOMString) { } - pub fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option) -> ErrorResult { + fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlsourceelement.rs b/src/components/script/dom/htmlsourceelement.rs index ef7ec5c9108..76d7cb28bab 100644 --- a/src/components/script/dom/htmlsourceelement.rs +++ b/src/components/script/dom/htmlsourceelement.rs @@ -40,28 +40,38 @@ impl HTMLSourceElement { } } -impl HTMLSourceElement { - pub fn Src(&self) -> DOMString { +pub trait HTMLSourceElementMethods { + fn Src(&self) -> DOMString; + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Media(&self) -> DOMString; + fn SetMedia(&mut self, _media: DOMString) -> ErrorResult; +} + +impl<'a> HTMLSourceElementMethods for JSRef<'a, HTMLSourceElement> { + fn Src(&self) -> DOMString { ~"" } - pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Media(&self) -> DOMString { + fn Media(&self) -> DOMString { ~"" } - pub fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { + fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlspanelement.rs b/src/components/script/dom/htmlspanelement.rs index 3867fa591de..dac10e30b68 100644 --- a/src/components/script/dom/htmlspanelement.rs +++ b/src/components/script/dom/htmlspanelement.rs @@ -38,3 +38,6 @@ impl HTMLSpanElement { Node::reflect_node(~element, document, HTMLSpanElementBinding::Wrap) } } + +pub trait HTMLSpanElementMethods { +} diff --git a/src/components/script/dom/htmlstyleelement.rs b/src/components/script/dom/htmlstyleelement.rs index ec2a997586b..aac38920342 100644 --- a/src/components/script/dom/htmlstyleelement.rs +++ b/src/components/script/dom/htmlstyleelement.rs @@ -10,7 +10,7 @@ use dom::document::Document; use dom::element::HTMLStyleElementTypeId; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::htmlelement::HTMLElement; -use dom::node::{Node, ElementNodeTypeId, window_from_node}; +use dom::node::{Node, NodeMethods, ElementNodeTypeId, window_from_node}; use dom::virtualmethods::VirtualMethods; use html::cssparse::parse_inline_css; use layout_interface::{AddStylesheetMsg, LayoutChan}; @@ -43,35 +43,46 @@ impl HTMLStyleElement { } } -impl HTMLStyleElement { - pub fn Disabled(&self) -> bool { +pub trait HTMLStyleElementMethods { + fn Disabled(&self) -> bool; + fn SetDisabled(&self, _disabled: bool); + fn Media(&self) -> DOMString; + fn SetMedia(&mut self, _media: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; + fn Scoped(&self) -> bool; + fn SetScoped(&self, _scoped: bool) -> ErrorResult; +} + +impl<'a> HTMLStyleElementMethods for JSRef<'a, HTMLStyleElement> { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&self, _disabled: bool) { + fn SetDisabled(&self, _disabled: bool) { } - pub fn Media(&self) -> DOMString { + fn Media(&self) -> DOMString { ~"" } - pub fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { + fn SetMedia(&mut self, _media: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } - pub fn Scoped(&self) -> bool { + fn Scoped(&self) -> bool { false } - pub fn SetScoped(&self, _scoped: bool) -> ErrorResult { + fn SetScoped(&self, _scoped: bool) -> ErrorResult { Ok(()) } } @@ -87,7 +98,7 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> { let win = window_from_node(node).root(&roots); let url = win.get().page().get_url(); - let data = node.get().GetTextContent(node).expect("Element.textContent must be a string"); + let data = node.GetTextContent(node).expect("Element.textContent must be a string"); let sheet = parse_inline_css(url, data); let LayoutChan(ref layout_chan) = *win.get().page().layout_chan; layout_chan.send(AddStylesheetMsg(sheet)); diff --git a/src/components/script/dom/htmltablecaptionelement.rs b/src/components/script/dom/htmltablecaptionelement.rs index ba83cd93ae8..45f3d6ec079 100644 --- a/src/components/script/dom/htmltablecaptionelement.rs +++ b/src/components/script/dom/htmltablecaptionelement.rs @@ -40,12 +40,18 @@ impl HTMLTableCaptionElement { } } -impl HTMLTableCaptionElement { - pub fn Align(&self) -> DOMString { +pub trait HTMLTableCaptionElementMethods { + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; +} + +impl<'a> HTMLTableCaptionElementMethods for JSRef<'a, HTMLTableCaptionElement> { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmltablecellelement.rs b/src/components/script/dom/htmltablecellelement.rs index b00c1d78fcd..47010ccbac7 100644 --- a/src/components/script/dom/htmltablecellelement.rs +++ b/src/components/script/dom/htmltablecellelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::InheritTypes::HTMLTableCellElementDerived; -use dom::bindings::js::JS; +use dom::bindings::js::{JS, JSRef}; use dom::bindings::error::ErrorResult; use dom::document::Document; use dom::element::{ElementTypeId, HTMLTableDataCellElementTypeId, HTMLTableHeaderCellElementTypeId}; @@ -35,125 +35,159 @@ impl HTMLTableCellElement { } } -impl HTMLTableCellElement { - pub fn ColSpan(&self) -> u32 { +pub trait HTMLTableCellElementMethods { + fn ColSpan(&self) -> u32; + fn SetColSpan(&self, _col_span: u32) -> ErrorResult; + fn RowSpan(&self) -> u32; + fn SetRowSpan(&self, _col_span: u32) -> ErrorResult; + fn Headers(&self) -> DOMString; + fn SetHeaders(&self, _headers: DOMString) -> ErrorResult; + fn CellIndex(&self) -> i32; + fn GetCellIndex(&self, _cell_index: i32) -> ErrorResult; + fn Abbr(&self) -> DOMString; + fn SetAbbr(&self, _abbr: DOMString) -> ErrorResult; + fn Scope(&self) -> DOMString; + fn SetScope(&self, _abbr: DOMString) -> ErrorResult; + fn Align(&self) -> DOMString; + fn SetAlign(&self, _align: DOMString) -> ErrorResult; + fn Axis(&self) -> DOMString; + fn SetAxis(&self, _axis: DOMString) -> ErrorResult; + fn Height(&self) -> DOMString; + fn SetHeight(&self, _height: DOMString) -> ErrorResult; + fn Width(&self) -> DOMString; + fn SetWidth(&self, _width: DOMString) -> ErrorResult; + fn Ch(&self) -> DOMString; + fn SetCh(&self, _ch: DOMString) -> ErrorResult; + fn ChOff(&self) -> DOMString; + fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult; + fn NoWrap(&self) -> bool; + fn SetNoWrap(&self, _no_wrap: bool) -> ErrorResult; + fn VAlign(&self) -> DOMString; + fn SetVAlign(&self, _valign: DOMString) -> ErrorResult; + fn BgColor(&self) -> DOMString; + fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult; +} + +impl<'a> HTMLTableCellElementMethods for JSRef<'a, HTMLTableCellElement> { + fn ColSpan(&self) -> u32 { 0 } - pub fn SetColSpan(&self, _col_span: u32) -> ErrorResult { + fn SetColSpan(&self, _col_span: u32) -> ErrorResult { Ok(()) } - pub fn RowSpan(&self) -> u32 { + fn RowSpan(&self) -> u32 { 0 } - pub fn SetRowSpan(&self, _col_span: u32) -> ErrorResult { + fn SetRowSpan(&self, _col_span: u32) -> ErrorResult { Ok(()) } - pub fn Headers(&self) -> DOMString { + fn Headers(&self) -> DOMString { ~"" } - pub fn SetHeaders(&self, _headers: DOMString) -> ErrorResult { + fn SetHeaders(&self, _headers: DOMString) -> ErrorResult { Ok(()) } - pub fn CellIndex(&self) -> i32 { + fn CellIndex(&self) -> i32 { 0 } - pub fn GetCellIndex(&self, _cell_index: i32) -> ErrorResult { + fn GetCellIndex(&self, _cell_index: i32) -> ErrorResult { Ok(()) } - pub fn Abbr(&self) -> DOMString { + fn Abbr(&self) -> DOMString { ~"" } - pub fn SetAbbr(&self, _abbr: DOMString) -> ErrorResult { + fn SetAbbr(&self, _abbr: DOMString) -> ErrorResult { Ok(()) } - pub fn Scope(&self) -> DOMString { + fn Scope(&self) -> DOMString { ~"" } - pub fn SetScope(&self, _abbr: DOMString) -> ErrorResult { + fn SetScope(&self, _abbr: DOMString) -> ErrorResult { Ok(()) } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&self, _align: DOMString) -> ErrorResult { + fn SetAlign(&self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Axis(&self) -> DOMString { + fn Axis(&self) -> DOMString { ~"" } - pub fn SetAxis(&self, _axis: DOMString) -> ErrorResult { + fn SetAxis(&self, _axis: DOMString) -> ErrorResult { Ok(()) } - pub fn Height(&self) -> DOMString { + fn Height(&self) -> DOMString { ~"" } - pub fn SetHeight(&self, _height: DOMString) -> ErrorResult { + fn SetHeight(&self, _height: DOMString) -> ErrorResult { Ok(()) } - pub fn Width(&self) -> DOMString { + fn Width(&self) -> DOMString { ~"" } - pub fn SetWidth(&self, _width: DOMString) -> ErrorResult { + fn SetWidth(&self, _width: DOMString) -> ErrorResult { Ok(()) } - pub fn Ch(&self) -> DOMString { + fn Ch(&self) -> DOMString { ~"" } - pub fn SetCh(&self, _ch: DOMString) -> ErrorResult { + fn SetCh(&self, _ch: DOMString) -> ErrorResult { Ok(()) } - pub fn ChOff(&self) -> DOMString { + fn ChOff(&self) -> DOMString { ~"" } - pub fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult { + fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult { Ok(()) } - pub fn NoWrap(&self) -> bool { + fn NoWrap(&self) -> bool { false } - pub fn SetNoWrap(&self, _no_wrap: bool) -> ErrorResult { + fn SetNoWrap(&self, _no_wrap: bool) -> ErrorResult { Ok(()) } - pub fn VAlign(&self) -> DOMString { + fn VAlign(&self) -> DOMString { ~"" } - pub fn SetVAlign(&self, _valign: DOMString) -> ErrorResult { + fn SetVAlign(&self, _valign: DOMString) -> ErrorResult { Ok(()) } - pub fn BgColor(&self) -> DOMString { + fn BgColor(&self) -> DOMString { ~"" } - pub fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { + fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmltablecolelement.rs b/src/components/script/dom/htmltablecolelement.rs index c8b8c74ad6b..97c85275ee9 100644 --- a/src/components/script/dom/htmltablecolelement.rs +++ b/src/components/script/dom/htmltablecolelement.rs @@ -40,52 +40,68 @@ impl HTMLTableColElement { } } -impl HTMLTableColElement { - pub fn Span(&self) -> u32 { +pub trait HTMLTableColElementMethods { + fn Span(&self) -> u32; + fn SetSpan(&mut self, _span: u32) -> ErrorResult; + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; + fn Ch(&self) -> DOMString; + fn SetCh(&mut self, _ch: DOMString) -> ErrorResult; + fn ChOff(&self) -> DOMString; + fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult; + fn VAlign(&self) -> DOMString; + fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult; + fn Width(&self) -> DOMString; + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult; +} + +impl<'a> HTMLTableColElementMethods for JSRef<'a, HTMLTableColElement> { + fn Span(&self) -> u32 { 0 } - pub fn SetSpan(&mut self, _span: u32) -> ErrorResult { + fn SetSpan(&mut self, _span: u32) -> ErrorResult { Ok(()) } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Ch(&self) -> DOMString { + fn Ch(&self) -> DOMString { ~"" } - pub fn SetCh(&mut self, _ch: DOMString) -> ErrorResult { + fn SetCh(&mut self, _ch: DOMString) -> ErrorResult { Ok(()) } - pub fn ChOff(&self) -> DOMString { + fn ChOff(&self) -> DOMString { ~"" } - pub fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult { + fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult { Ok(()) } - pub fn VAlign(&self) -> DOMString { + fn VAlign(&self) -> DOMString { ~"" } - pub fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult { + fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult { Ok(()) } - pub fn Width(&self) -> DOMString { + fn Width(&self) -> DOMString { ~"" } - pub fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { + fn SetWidth(&mut self, _width: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmltabledatacellelement.rs b/src/components/script/dom/htmltabledatacellelement.rs index 830740127f0..359e2837744 100644 --- a/src/components/script/dom/htmltabledatacellelement.rs +++ b/src/components/script/dom/htmltabledatacellelement.rs @@ -38,3 +38,6 @@ impl HTMLTableDataCellElement { Node::reflect_node(~element, document, HTMLTableDataCellElementBinding::Wrap) } } + +pub trait HTMLTableDataCellElementMethods { +} diff --git a/src/components/script/dom/htmltableelement.rs b/src/components/script/dom/htmltableelement.rs index 8150c68d3a6..6451e2d7276 100644 --- a/src/components/script/dom/htmltableelement.rs +++ b/src/components/script/dom/htmltableelement.rs @@ -40,99 +40,128 @@ impl HTMLTableElement { } } -impl HTMLTableElement { - pub fn DeleteCaption(&self) { +pub trait HTMLTableElementMethods { + fn DeleteCaption(&self); + fn DeleteTHead(&self); + fn DeleteTFoot(&self); + fn DeleteRow(&mut self, _index: i32) -> ErrorResult; + fn Sortable(&self) -> bool; + fn SetSortable(&self, _sortable: bool); + fn StopSorting(&self); + fn Align(&self) -> DOMString; + fn SetAlign(&self, _align: DOMString) -> ErrorResult; + fn Border(&self) -> DOMString; + fn SetBorder(&self, _border: DOMString) -> ErrorResult; + fn Frame(&self) -> DOMString; + fn SetFrame(&self, _frame: DOMString) -> ErrorResult; + fn Rules(&self) -> DOMString; + fn SetRules(&self, _rules: DOMString) -> ErrorResult; + fn Summary(&self) -> DOMString; + fn SetSummary(&self, _summary: DOMString) -> ErrorResult; + fn Width(&self) -> DOMString; + fn SetWidth(&self, _width: DOMString) -> ErrorResult; + fn BgColor(&self) -> DOMString; + fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult; + fn CellPadding(&self) -> DOMString; + fn SetCellPadding(&self, _cell_padding: DOMString) -> ErrorResult; + fn CellSpacing(&self) -> DOMString; + fn SetCellSpacing(&self, _cell_spacing: DOMString) -> ErrorResult; +} + +impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> { + fn DeleteCaption(&self) { } - pub fn DeleteTHead(&self) { + fn DeleteTHead(&self) { } - pub fn DeleteTFoot(&self) { + fn DeleteTFoot(&self) { } - pub fn DeleteRow(&mut self, _index: i32) -> ErrorResult { + fn DeleteRow(&mut self, _index: i32) -> ErrorResult { Ok(()) } - pub fn Sortable(&self) -> bool { + fn Sortable(&self) -> bool { false } - pub fn SetSortable(&self, _sortable: bool) { + fn SetSortable(&self, _sortable: bool) { } - pub fn StopSorting(&self) { + fn StopSorting(&self) { } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&self, _align: DOMString) -> ErrorResult { + fn SetAlign(&self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Border(&self) -> DOMString { + fn Border(&self) -> DOMString { ~"" } - pub fn SetBorder(&self, _border: DOMString) -> ErrorResult { + fn SetBorder(&self, _border: DOMString) -> ErrorResult { Ok(()) } - pub fn Frame(&self) -> DOMString { + fn Frame(&self) -> DOMString { ~"" } - pub fn SetFrame(&self, _frame: DOMString) -> ErrorResult { + fn SetFrame(&self, _frame: DOMString) -> ErrorResult { Ok(()) } - pub fn Rules(&self) -> DOMString { + fn Rules(&self) -> DOMString { ~"" } - pub fn SetRules(&self, _rules: DOMString) -> ErrorResult { + fn SetRules(&self, _rules: DOMString) -> ErrorResult { Ok(()) } - pub fn Summary(&self) -> DOMString { + fn Summary(&self) -> DOMString { ~"" } - pub fn SetSummary(&self, _summary: DOMString) -> ErrorResult { + fn SetSummary(&self, _summary: DOMString) -> ErrorResult { Ok(()) } - pub fn Width(&self) -> DOMString { + fn Width(&self) -> DOMString { ~"" } - pub fn SetWidth(&self, _width: DOMString) -> ErrorResult { + fn SetWidth(&self, _width: DOMString) -> ErrorResult { Ok(()) } - pub fn BgColor(&self) -> DOMString { + fn BgColor(&self) -> DOMString { ~"" } - pub fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { + fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { Ok(()) } - pub fn CellPadding(&self) -> DOMString { + fn CellPadding(&self) -> DOMString { ~"" } - pub fn SetCellPadding(&self, _cell_padding: DOMString) -> ErrorResult { + fn SetCellPadding(&self, _cell_padding: DOMString) -> ErrorResult { Ok(()) } - pub fn CellSpacing(&self) -> DOMString { + fn CellSpacing(&self) -> DOMString { ~"" } - pub fn SetCellSpacing(&self, _cell_spacing: DOMString) -> ErrorResult { + fn SetCellSpacing(&self, _cell_spacing: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmltableheadercellelement.rs b/src/components/script/dom/htmltableheadercellelement.rs index 90dba152b44..ce1dc6a8241 100644 --- a/src/components/script/dom/htmltableheadercellelement.rs +++ b/src/components/script/dom/htmltableheadercellelement.rs @@ -38,3 +38,6 @@ impl HTMLTableHeaderCellElement { Node::reflect_node(~element, document, HTMLTableHeaderCellElementBinding::Wrap) } } + +pub trait HTMLTableHeaderCellElementMethods { +} diff --git a/src/components/script/dom/htmltablerowelement.rs b/src/components/script/dom/htmltablerowelement.rs index 2b77faeadab..d7d05516798 100644 --- a/src/components/script/dom/htmltablerowelement.rs +++ b/src/components/script/dom/htmltablerowelement.rs @@ -40,64 +40,83 @@ impl HTMLTableRowElement { } } -impl HTMLTableRowElement { - pub fn RowIndex(&self) -> i32 { +pub trait HTMLTableRowElementMethods { + fn RowIndex(&self) -> i32; + fn GetRowIndex(&self) -> i32; + fn SectionRowIndex(&self) -> i32; + fn GetSectionRowIndex(&self) -> i32; + fn DeleteCell(&mut self, _index: i32) -> ErrorResult; + fn Align(&self) -> DOMString; + fn SetAlign(&self, _align: DOMString) -> ErrorResult; + fn Ch(&self) -> DOMString; + fn SetCh(&self, _ch: DOMString) -> ErrorResult; + fn ChOff(&self) -> DOMString; + fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult; + fn VAlign(&self) -> DOMString; + fn SetVAlign(&self, _v_align: DOMString) -> ErrorResult; + fn BgColor(&self) -> DOMString; + fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult; +} + +impl<'a> HTMLTableRowElementMethods for JSRef<'a, HTMLTableRowElement> { + fn RowIndex(&self) -> i32 { 0 } - pub fn GetRowIndex(&self) -> i32 { + fn GetRowIndex(&self) -> i32 { 0 } - pub fn SectionRowIndex(&self) -> i32 { + fn SectionRowIndex(&self) -> i32 { 0 } - pub fn GetSectionRowIndex(&self) -> i32 { + fn GetSectionRowIndex(&self) -> i32 { 0 } - pub fn DeleteCell(&mut self, _index: i32) -> ErrorResult { + fn DeleteCell(&mut self, _index: i32) -> ErrorResult { Ok(()) } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&self, _align: DOMString) -> ErrorResult { + fn SetAlign(&self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Ch(&self) -> DOMString { + fn Ch(&self) -> DOMString { ~"" } - pub fn SetCh(&self, _ch: DOMString) -> ErrorResult { + fn SetCh(&self, _ch: DOMString) -> ErrorResult { Ok(()) } - pub fn ChOff(&self) -> DOMString { + fn ChOff(&self) -> DOMString { ~"" } - pub fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult { + fn SetChOff(&self, _ch_off: DOMString) -> ErrorResult { Ok(()) } - pub fn VAlign(&self) -> DOMString { + fn VAlign(&self) -> DOMString { ~"" } - pub fn SetVAlign(&self, _v_align: DOMString) -> ErrorResult { + fn SetVAlign(&self, _v_align: DOMString) -> ErrorResult { Ok(()) } - pub fn BgColor(&self) -> DOMString { + fn BgColor(&self) -> DOMString { ~"" } - pub fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { + fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmltablesectionelement.rs b/src/components/script/dom/htmltablesectionelement.rs index b44aba6e9dc..62dd52e9758 100644 --- a/src/components/script/dom/htmltablesectionelement.rs +++ b/src/components/script/dom/htmltablesectionelement.rs @@ -40,40 +40,53 @@ impl HTMLTableSectionElement { } } -impl HTMLTableSectionElement { - pub fn DeleteRow(&mut self, _index: i32) -> ErrorResult { +pub trait HTMLTableSectionElementMethods { + fn DeleteRow(&mut self, _index: i32) -> ErrorResult; + fn Align(&self) -> DOMString; + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult; + fn Ch(&self) -> DOMString; + fn SetCh(&mut self, _ch: DOMString) -> ErrorResult; + fn ChOff(&self) -> DOMString; + fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult; + fn VAlign(&self) -> DOMString; + fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult; +} + +impl<'a> HTMLTableSectionElementMethods for JSRef<'a, HTMLTableSectionElement> { + fn DeleteRow(&mut self, _index: i32) -> ErrorResult { Ok(()) } - pub fn Align(&self) -> DOMString { + fn Align(&self) -> DOMString { ~"" } - pub fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { + fn SetAlign(&mut self, _align: DOMString) -> ErrorResult { Ok(()) } - pub fn Ch(&self) -> DOMString { + fn Ch(&self) -> DOMString { ~"" } - pub fn SetCh(&mut self, _ch: DOMString) -> ErrorResult { + fn SetCh(&mut self, _ch: DOMString) -> ErrorResult { Ok(()) } - pub fn ChOff(&self) -> DOMString { + fn ChOff(&self) -> DOMString { ~"" } - pub fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult { + fn SetChOff(&mut self, _ch_off: DOMString) -> ErrorResult { Ok(()) } - pub fn VAlign(&self) -> DOMString { + fn VAlign(&self) -> DOMString { ~"" } - pub fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult { + fn SetVAlign(&mut self, _v_align: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmltemplateelement.rs b/src/components/script/dom/htmltemplateelement.rs index f645e1815d3..245ce104439 100644 --- a/src/components/script/dom/htmltemplateelement.rs +++ b/src/components/script/dom/htmltemplateelement.rs @@ -38,3 +38,6 @@ impl HTMLTemplateElement { Node::reflect_node(~element, document, HTMLTemplateElementBinding::Wrap) } } + +pub trait HTMLTemplateElementMethods { +} diff --git a/src/components/script/dom/htmltextareaelement.rs b/src/components/script/dom/htmltextareaelement.rs index 4955085c751..2005a6384e4 100644 --- a/src/components/script/dom/htmltextareaelement.rs +++ b/src/components/script/dom/htmltextareaelement.rs @@ -40,163 +40,208 @@ impl HTMLTextAreaElement { } } -impl HTMLTextAreaElement { - pub fn Autofocus(&self) -> bool { +pub trait HTMLTextAreaElementMethods { + fn Autofocus(&self) -> bool; + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult; + fn Cols(&self) -> u32; + fn SetCols(&self, _cols: u32) -> ErrorResult; + fn Disabled(&self) -> bool; + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult; + fn MaxLength(&self) -> i32; + fn SetMaxLength(&self, _max_length: i32) -> ErrorResult; + fn Name(&self) -> DOMString; + fn SetName(&mut self, _name: DOMString) -> ErrorResult; + fn Placeholder(&self) -> DOMString; + fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult; + fn ReadOnly(&self) -> bool; + fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult; + fn Required(&self) -> bool; + fn SetRequired(&mut self, _required: bool) -> ErrorResult; + fn Rows(&self) -> u32; + fn SetRows(&self, _rows: u32) -> ErrorResult; + fn Wrap(&self) -> DOMString; + fn SetWrap(&mut self, _wrap: DOMString) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString); + fn DefaultValue(&self) -> DOMString; + fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult; + fn Value(&self) -> DOMString; + fn SetValue(&mut self, _value: DOMString); + fn TextLength(&self) -> u32; + fn SetTextLength(&self, _text_length: u32) -> ErrorResult; + fn WillValidate(&self) -> bool; + fn SetWillValidate(&mut self, _will_validate: bool) -> ErrorResult; + fn ValidationMessage(&self) -> DOMString; + fn CheckValidity(&self) -> bool; + fn SetCustomValidity(&self, _error: DOMString); + fn Select(&self); + fn GetSelectionStart(&self) -> Fallible; + fn SetSelectionStart(&self, _selection_start: u32) -> ErrorResult; + fn GetSelectionEnd(&self) -> Fallible; + fn SetSelectionEnd(&self, _selection_end: u32) -> ErrorResult; + fn GetSelectionDirection(&self) -> Fallible; + fn SetSelectionDirection(&self, _selection_direction: DOMString) -> ErrorResult; + fn SetRangeText(&self, _replacement: DOMString); +} + +impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> { + fn Autofocus(&self) -> bool { false } - pub fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { + fn SetAutofocus(&mut self, _autofocus: bool) -> ErrorResult { Ok(()) } - pub fn Cols(&self) -> u32 { + fn Cols(&self) -> u32 { 0 } - pub fn SetCols(&self, _cols: u32) -> ErrorResult { + fn SetCols(&self, _cols: u32) -> ErrorResult { Ok(()) } - pub fn Disabled(&self) -> bool { + fn Disabled(&self) -> bool { false } - pub fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { + fn SetDisabled(&mut self, _disabled: bool) -> ErrorResult { Ok(()) } - pub fn MaxLength(&self) -> i32 { + fn MaxLength(&self) -> i32 { 0 } - pub fn SetMaxLength(&self, _max_length: i32) -> ErrorResult { + fn SetMaxLength(&self, _max_length: i32) -> ErrorResult { Ok(()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&mut self, _name: DOMString) -> ErrorResult { + fn SetName(&mut self, _name: DOMString) -> ErrorResult { Ok(()) } - pub fn Placeholder(&self) -> DOMString { + fn Placeholder(&self) -> DOMString { ~"" } - pub fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult { + fn SetPlaceholder(&mut self, _placeholder: DOMString) -> ErrorResult { Ok(()) } - pub fn ReadOnly(&self) -> bool { + fn ReadOnly(&self) -> bool { false } - pub fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult { + fn SetReadOnly(&mut self, _read_only: bool) -> ErrorResult { Ok(()) } - pub fn Required(&self) -> bool { + fn Required(&self) -> bool { false } - pub fn SetRequired(&mut self, _required: bool) -> ErrorResult { + fn SetRequired(&mut self, _required: bool) -> ErrorResult { Ok(()) } - pub fn Rows(&self) -> u32 { + fn Rows(&self) -> u32 { 0 } - pub fn SetRows(&self, _rows: u32) -> ErrorResult { + fn SetRows(&self, _rows: u32) -> ErrorResult { Ok(()) } - pub fn Wrap(&self) -> DOMString { + fn Wrap(&self) -> DOMString { ~"" } - pub fn SetWrap(&mut self, _wrap: DOMString) -> ErrorResult { + fn SetWrap(&mut self, _wrap: DOMString) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) { + fn SetType(&mut self, _type: DOMString) { } - pub fn DefaultValue(&self) -> DOMString { + fn DefaultValue(&self) -> DOMString { ~"" } - pub fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult { + fn SetDefaultValue(&mut self, _default_value: DOMString) -> ErrorResult { Ok(()) } - pub fn Value(&self) -> DOMString { + fn Value(&self) -> DOMString { ~"" } - pub fn SetValue(&mut self, _value: DOMString) { + fn SetValue(&mut self, _value: DOMString) { } - pub fn TextLength(&self) -> u32 { + fn TextLength(&self) -> u32 { 0 } - pub fn SetTextLength(&self, _text_length: u32) -> ErrorResult { + fn SetTextLength(&self, _text_length: u32) -> ErrorResult { Ok(()) } - pub fn WillValidate(&self) -> bool { + fn WillValidate(&self) -> bool { false } - pub fn SetWillValidate(&mut self, _will_validate: bool) -> ErrorResult { + fn SetWillValidate(&mut self, _will_validate: bool) -> ErrorResult { Ok(()) } - pub fn ValidationMessage(&self) -> DOMString { + fn ValidationMessage(&self) -> DOMString { ~"" } - pub fn CheckValidity(&self) -> bool { + fn CheckValidity(&self) -> bool { false } - pub fn SetCustomValidity(&self, _error: DOMString) { + fn SetCustomValidity(&self, _error: DOMString) { } - pub fn Select(&self) { + fn Select(&self) { } - pub fn GetSelectionStart(&self) -> Fallible { + fn GetSelectionStart(&self) -> Fallible { Ok(0) } - pub fn SetSelectionStart(&self, _selection_start: u32) -> ErrorResult { + fn SetSelectionStart(&self, _selection_start: u32) -> ErrorResult { Ok(()) } - pub fn GetSelectionEnd(&self) -> Fallible { + fn GetSelectionEnd(&self) -> Fallible { Ok(0) } - pub fn SetSelectionEnd(&self, _selection_end: u32) -> ErrorResult { + fn SetSelectionEnd(&self, _selection_end: u32) -> ErrorResult { Ok(()) } - pub fn GetSelectionDirection(&self) -> Fallible { + fn GetSelectionDirection(&self) -> Fallible { Ok(~"") } - pub fn SetSelectionDirection(&self, _selection_direction: DOMString) -> ErrorResult { + fn SetSelectionDirection(&self, _selection_direction: DOMString) -> ErrorResult { Ok(()) } - pub fn SetRangeText(&self, _replacement: DOMString) { + fn SetRangeText(&self, _replacement: DOMString) { } } + diff --git a/src/components/script/dom/htmltimeelement.rs b/src/components/script/dom/htmltimeelement.rs index df74323fc01..dd2a9b28f97 100644 --- a/src/components/script/dom/htmltimeelement.rs +++ b/src/components/script/dom/htmltimeelement.rs @@ -40,12 +40,18 @@ impl HTMLTimeElement { } } -impl HTMLTimeElement { - pub fn DateTime(&self) -> DOMString { +pub trait HTMLTimeElementMethods { + fn DateTime(&self) -> DOMString; + fn SetDateTime(&mut self, _dateTime: DOMString) -> ErrorResult; +} + +impl<'a> HTMLTimeElementMethods for JSRef<'a, HTMLTimeElement> { + fn DateTime(&self) -> DOMString { ~"" } - pub fn SetDateTime(&mut self, _dateTime: DOMString) -> ErrorResult { + fn SetDateTime(&mut self, _dateTime: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmltitleelement.rs b/src/components/script/dom/htmltitleelement.rs index 2c1af9b5291..c78b26ee4cb 100644 --- a/src/components/script/dom/htmltitleelement.rs +++ b/src/components/script/dom/htmltitleelement.rs @@ -40,12 +40,18 @@ impl HTMLTitleElement { } } -impl HTMLTitleElement { - pub fn Text(&self) -> DOMString { +pub trait HTMLTitleElementMethods { + fn Text(&self) -> DOMString; + fn SetText(&mut self, _text: DOMString) -> ErrorResult; +} + +impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> { + fn Text(&self) -> DOMString { ~"" } - pub fn SetText(&mut self, _text: DOMString) -> ErrorResult { + fn SetText(&mut self, _text: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmltrackelement.rs b/src/components/script/dom/htmltrackelement.rs index 408da82d53b..db25ab17130 100644 --- a/src/components/script/dom/htmltrackelement.rs +++ b/src/components/script/dom/htmltrackelement.rs @@ -40,48 +40,63 @@ impl HTMLTrackElement { } } -impl HTMLTrackElement { - pub fn Kind(&self) -> DOMString { +pub trait HTMLTrackElementMethods { + fn Kind(&self) -> DOMString; + fn SetKind(&mut self, _kind: DOMString) -> ErrorResult; + fn Src(&self) -> DOMString; + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult; + fn Srclang(&self) -> DOMString; + fn SetSrclang(&mut self, _srclang: DOMString) -> ErrorResult; + fn Label(&self) -> DOMString; + fn SetLabel(&mut self, _label: DOMString) -> ErrorResult; + fn Default(&self) -> bool; + fn SetDefault(&mut self, _default: bool) -> ErrorResult; + fn ReadyState(&self) -> u16; +} + +impl<'a> HTMLTrackElementMethods for JSRef<'a, HTMLTrackElement> { + fn Kind(&self) -> DOMString { ~"" } - pub fn SetKind(&mut self, _kind: DOMString) -> ErrorResult { + fn SetKind(&mut self, _kind: DOMString) -> ErrorResult { Ok(()) } - pub fn Src(&self) -> DOMString { + fn Src(&self) -> DOMString { ~"" } - pub fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { + fn SetSrc(&mut self, _src: DOMString) -> ErrorResult { Ok(()) } - pub fn Srclang(&self) -> DOMString { + fn Srclang(&self) -> DOMString { ~"" } - pub fn SetSrclang(&mut self, _srclang: DOMString) -> ErrorResult { + fn SetSrclang(&mut self, _srclang: DOMString) -> ErrorResult { Ok(()) } - pub fn Label(&self) -> DOMString { + fn Label(&self) -> DOMString { ~"" } - pub fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { + fn SetLabel(&mut self, _label: DOMString) -> ErrorResult { Ok(()) } - pub fn Default(&self) -> bool { + fn Default(&self) -> bool { false } - pub fn SetDefault(&mut self, _default: bool) -> ErrorResult { + fn SetDefault(&mut self, _default: bool) -> ErrorResult { Ok(()) } - pub fn ReadyState(&self) -> u16 { + fn ReadyState(&self) -> u16 { 0 } } + diff --git a/src/components/script/dom/htmlulistelement.rs b/src/components/script/dom/htmlulistelement.rs index c2661a5ee46..bed085157ce 100644 --- a/src/components/script/dom/htmlulistelement.rs +++ b/src/components/script/dom/htmlulistelement.rs @@ -40,20 +40,28 @@ impl HTMLUListElement { } } -impl HTMLUListElement { - pub fn Compact(&self) -> bool { +pub trait HTMLUListElementMethods { + fn Compact(&self) -> bool; + fn SetCompact(&mut self, _compact: bool) -> ErrorResult; + fn Type(&self) -> DOMString; + fn SetType(&mut self, _type: DOMString) -> ErrorResult; +} + +impl<'a> HTMLUListElementMethods for JSRef<'a, HTMLUListElement> { + fn Compact(&self) -> bool { false } - pub fn SetCompact(&mut self, _compact: bool) -> ErrorResult { + fn SetCompact(&mut self, _compact: bool) -> ErrorResult { Ok(()) } - pub fn Type(&self) -> DOMString { + fn Type(&self) -> DOMString { ~"" } - pub fn SetType(&mut self, _type: DOMString) -> ErrorResult { + fn SetType(&mut self, _type: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/htmlunknownelement.rs b/src/components/script/dom/htmlunknownelement.rs index da68e0c51bf..da14d35b69f 100644 --- a/src/components/script/dom/htmlunknownelement.rs +++ b/src/components/script/dom/htmlunknownelement.rs @@ -38,3 +38,6 @@ impl HTMLUnknownElement { Node::reflect_node(~element, document, HTMLUnknownElementBinding::Wrap) } } + +pub trait HTMLUnknownElementMethods { +} diff --git a/src/components/script/dom/htmlvideoelement.rs b/src/components/script/dom/htmlvideoelement.rs index aba9c3c3436..60e9d6a09cf 100644 --- a/src/components/script/dom/htmlvideoelement.rs +++ b/src/components/script/dom/htmlvideoelement.rs @@ -40,36 +40,48 @@ impl HTMLVideoElement { } } -impl HTMLVideoElement { - pub fn Width(&self) -> u32 { +pub trait HTMLVideoElementMethods { + fn Width(&self) -> u32; + fn SetWidth(&mut self, _width: u32) -> ErrorResult; + fn Height(&self) -> u32; + fn SetHeight(&mut self, _height: u32) -> ErrorResult; + fn VideoWidth(&self) -> u32; + fn VideoHeight(&self) -> u32; + fn Poster(&self) -> DOMString; + fn SetPoster(&mut self, _poster: DOMString) -> ErrorResult; +} + +impl<'a> HTMLVideoElementMethods for JSRef<'a, HTMLVideoElement> { + fn Width(&self) -> u32 { 0 } - pub fn SetWidth(&mut self, _width: u32) -> ErrorResult { + fn SetWidth(&mut self, _width: u32) -> ErrorResult { Ok(()) } - pub fn Height(&self) -> u32 { + fn Height(&self) -> u32 { 0 } - pub fn SetHeight(&mut self, _height: u32) -> ErrorResult { + fn SetHeight(&mut self, _height: u32) -> ErrorResult { Ok(()) } - pub fn VideoWidth(&self) -> u32 { + fn VideoWidth(&self) -> u32 { 0 } - pub fn VideoHeight(&self) -> u32 { + fn VideoHeight(&self) -> u32 { 0 } - pub fn Poster(&self) -> DOMString { + fn Poster(&self) -> DOMString { ~"" } - pub fn SetPoster(&mut self, _poster: DOMString) -> ErrorResult { + fn SetPoster(&mut self, _poster: DOMString) -> ErrorResult { Ok(()) } } + diff --git a/src/components/script/dom/location.rs b/src/components/script/dom/location.rs index 762da0a383b..4a28e1c449d 100644 --- a/src/components/script/dom/location.rs +++ b/src/components/script/dom/location.rs @@ -34,104 +34,134 @@ impl Location { window, LocationBinding::Wrap) } +} - pub fn Assign(&self, _url: DOMString) { +pub trait LocationMethods { + fn Assign(&self, _url: DOMString); + fn Replace(&self, _url: DOMString); + fn Reload(&self); + fn Href(&self) -> DOMString; + fn SetHref(&self, _href: DOMString) -> Fallible<()>; + fn Origin(&self) -> DOMString; + fn Protocol(&self) -> DOMString; + fn SetProtocol(&self, _protocol: DOMString); + fn Username(&self) -> DOMString; + fn SetUsername(&self, _username: DOMString); + fn Password(&self) -> DOMString; + fn SetPassword(&self, _password: DOMString); + fn Host(&self) -> DOMString; + fn SetHost(&self, _host: DOMString); + fn Hostname(&self) -> DOMString; + fn SetHostname(&self, _hostname: DOMString); + fn Port(&self) -> DOMString; + fn SetPort(&self, _port: DOMString); + fn Pathname(&self) -> DOMString; + fn SetPathname(&self, _pathname: DOMString); + fn Search(&self) -> DOMString; + fn SetSearch(&self, _search: DOMString); + fn Hash(&self) -> DOMString; + fn SetHash(&self, _hash: DOMString); +} + +impl<'a> LocationMethods for JSRef<'a, Location> { + fn Assign(&self, _url: DOMString) { } - pub fn Replace(&self, _url: DOMString) { + fn Replace(&self, _url: DOMString) { } - pub fn Reload(&self) { + fn Reload(&self) { } - pub fn Href(&self) -> DOMString { + fn Href(&self) -> DOMString { self.page.get_url().to_str() } - pub fn SetHref(&self, _href: DOMString) -> Fallible<()> { + fn SetHref(&self, _href: DOMString) -> Fallible<()> { Ok(()) } - pub fn Origin(&self) -> DOMString { + fn Origin(&self) -> DOMString { ~"" } - pub fn Protocol(&self) -> DOMString { + fn Protocol(&self) -> DOMString { ~"" } - pub fn SetProtocol(&self, _protocol: DOMString) { + fn SetProtocol(&self, _protocol: DOMString) { } - pub fn Username(&self) -> DOMString { + fn Username(&self) -> DOMString { ~"" } - pub fn SetUsername(&self, _username: DOMString) { + fn SetUsername(&self, _username: DOMString) { } - pub fn Password(&self) -> DOMString { + fn Password(&self) -> DOMString { ~"" } - pub fn SetPassword(&self, _password: DOMString) { + fn SetPassword(&self, _password: DOMString) { } - pub fn Host(&self) -> DOMString { + fn Host(&self) -> DOMString { ~"" } - pub fn SetHost(&self, _host: DOMString) { + fn SetHost(&self, _host: DOMString) { } - pub fn Hostname(&self) -> DOMString { + fn Hostname(&self) -> DOMString { ~"" } - pub fn SetHostname(&self, _hostname: DOMString) { + fn SetHostname(&self, _hostname: DOMString) { } - pub fn Port(&self) -> DOMString { + fn Port(&self) -> DOMString { ~"" } - pub fn SetPort(&self, _port: DOMString) { + fn SetPort(&self, _port: DOMString) { } - pub fn Pathname(&self) -> DOMString { + fn Pathname(&self) -> DOMString { ~"" } - pub fn SetPathname(&self, _pathname: DOMString) { + fn SetPathname(&self, _pathname: DOMString) { } - pub fn Search(&self) -> DOMString { + fn Search(&self) -> DOMString { ~"" } - pub fn SetSearch(&self, _search: DOMString) { + fn SetSearch(&self, _search: DOMString) { } - pub fn Hash(&self) -> DOMString { + fn Hash(&self) -> DOMString { ~"" } - pub fn SetHash(&self, _hash: DOMString) { + fn SetHash(&self, _hash: DOMString) { } } + impl Reflectable for Location { fn reflector<'a>(&'a self) -> &'a Reflector { &self.reflector_ diff --git a/src/components/script/dom/mouseevent.rs b/src/components/script/dom/mouseevent.rs index b771b1b091c..fbfc9cf783d 100644 --- a/src/components/script/dom/mouseevent.rs +++ b/src/components/script/dom/mouseevent.rs @@ -3,13 +3,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::BindingDeclarations::MouseEventBinding; -use dom::bindings::codegen::InheritTypes::MouseEventDerived; +use dom::bindings::codegen::InheritTypes::{UIEventCast, MouseEventDerived}; use dom::bindings::js::{JS, JSRef, RootCollection, RootedReference, Unrooted}; use dom::bindings::error::Fallible; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::event::{Event, MouseEventTypeId}; use dom::eventtarget::EventTarget; -use dom::uievent::UIEvent; +use dom::uievent::{UIEvent, UIEventMethods}; use dom::window::Window; use servo_util::str::DOMString; @@ -64,81 +64,117 @@ impl MouseEvent { let mut ev = MouseEvent::new(owner).root(&roots); let view = init.view.as_ref().map(|view| view.root(&roots)); let related_target = init.relatedTarget.as_ref().map(|relatedTarget| relatedTarget.root(&roots)); - ev.get_mut().InitMouseEvent(type_, init.bubbles, init.cancelable, view.root_ref(), - init.detail, init.screenX, init.screenY, - init.clientX, init.clientY, init.ctrlKey, - init.altKey, init.shiftKey, init.metaKey, - init.button, related_target.root_ref()); + ev.InitMouseEvent(type_, init.bubbles, init.cancelable, view.root_ref(), + init.detail, init.screenX, init.screenY, + init.clientX, init.clientY, init.ctrlKey, + init.altKey, init.shiftKey, init.metaKey, + init.button, related_target.root_ref()); Ok(Unrooted::new_rooted(&*ev)) } +} - pub fn ScreenX(&self) -> i32 { +pub trait MouseEventMethods { + fn ScreenX(&self) -> i32; + fn ScreenY(&self) -> i32; + fn ClientX(&self) -> i32; + fn ClientY(&self) -> i32; + fn CtrlKey(&self) -> bool; + fn ShiftKey(&self) -> bool; + fn AltKey(&self) -> bool; + fn MetaKey(&self) -> bool; + fn Button(&self) -> u16; + fn Buttons(&self)-> u16; + fn GetRelatedTarget(&self) -> Option>; + fn GetModifierState(&self, _keyArg: DOMString) -> bool; + fn InitMouseEvent(&mut self, + typeArg: DOMString, + canBubbleArg: bool, + cancelableArg: bool, + viewArg: Option>, + detailArg: i32, + screenXArg: i32, + screenYArg: i32, + clientXArg: i32, + clientYArg: i32, + ctrlKeyArg: bool, + altKeyArg: bool, + shiftKeyArg: bool, + metaKeyArg: bool, + buttonArg: u16, + relatedTargetArg: Option>); +} + +impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> { + fn ScreenX(&self) -> i32 { self.screen_x } - pub fn ScreenY(&self) -> i32 { + fn ScreenY(&self) -> i32 { self.screen_y } - pub fn ClientX(&self) -> i32 { + fn ClientX(&self) -> i32 { self.client_x } - pub fn ClientY(&self) -> i32 { + fn ClientY(&self) -> i32 { self.client_y } - pub fn CtrlKey(&self) -> bool { + fn CtrlKey(&self) -> bool { self.ctrl_key } - pub fn ShiftKey(&self) -> bool { + fn ShiftKey(&self) -> bool { self.shift_key } - pub fn AltKey(&self) -> bool { + fn AltKey(&self) -> bool { self.alt_key } - pub fn MetaKey(&self) -> bool { + fn MetaKey(&self) -> bool { self.meta_key } - pub fn Button(&self) -> u16 { + fn Button(&self) -> u16 { self.button } - pub fn Buttons(&self)-> u16 { + fn Buttons(&self)-> u16 { //TODO 0 } - pub fn GetRelatedTarget(&self) -> Option> { + fn GetRelatedTarget(&self) -> Option> { self.related_target.clone().map(|target| Unrooted::new(target)) } - pub fn GetModifierState(&self, _keyArg: DOMString) -> bool { + fn GetModifierState(&self, _keyArg: DOMString) -> bool { //TODO false } - pub fn InitMouseEvent(&mut self, - typeArg: DOMString, - canBubbleArg: bool, - cancelableArg: bool, - viewArg: Option>, - detailArg: i32, - screenXArg: i32, - screenYArg: i32, - clientXArg: i32, - clientYArg: i32, - ctrlKeyArg: bool, - altKeyArg: bool, - shiftKeyArg: bool, - metaKeyArg: bool, - buttonArg: u16, - relatedTargetArg: Option>) { - self.mouseevent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); + fn InitMouseEvent(&mut self, + typeArg: DOMString, + canBubbleArg: bool, + cancelableArg: bool, + viewArg: Option>, + detailArg: i32, + screenXArg: i32, + screenYArg: i32, + clientXArg: i32, + clientYArg: i32, + ctrlKeyArg: bool, + altKeyArg: bool, + shiftKeyArg: bool, + metaKeyArg: bool, + buttonArg: u16, + relatedTargetArg: Option>) { + { + let uievent: &mut JSRef = UIEventCast::from_mut_ref(self); + uievent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); + } self.screen_x = screenXArg; self.screen_y = screenYArg; self.client_x = clientXArg; @@ -152,6 +188,7 @@ impl MouseEvent { } } + impl Reflectable for MouseEvent { fn reflector<'a>(&'a self) -> &'a Reflector { self.mouseevent.reflector() diff --git a/src/components/script/dom/navigator.rs b/src/components/script/dom/navigator.rs index 494175cb6b8..9e54bffb0c1 100644 --- a/src/components/script/dom/navigator.rs +++ b/src/components/script/dom/navigator.rs @@ -26,72 +26,94 @@ impl Navigator { window, NavigatorBinding::Wrap) } +} - pub fn DoNotTrack(&self) -> DOMString { +pub trait NavigatorMethods { + fn DoNotTrack(&self) -> DOMString; + fn Vendor(&self) -> DOMString; + fn VendorSub(&self) -> DOMString; + fn Product(&self) -> DOMString; + fn ProductSub(&self) -> DOMString; + fn CookieEnabled(&self) -> bool; + fn GetBuildID(&self) -> Fallible; + fn JavaEnabled(&self) -> Fallible; + fn TaintEnabled(&self) -> bool; + fn AppName(&self) -> DOMString; + fn GetAppCodeName(&self) -> Fallible; + fn GetAppVersion(&self) -> Fallible; + fn GetPlatform(&self) -> Fallible; + fn GetUserAgent(&self) -> Fallible; + fn GetLanguage(&self) -> Option; + fn OnLine(&self) -> bool; +} + +impl<'a> NavigatorMethods for JSRef<'a, Navigator> { + fn DoNotTrack(&self) -> DOMString { ~"unspecified" } - pub fn Vendor(&self) -> DOMString { + fn Vendor(&self) -> DOMString { ~"" // Like Gecko } - pub fn VendorSub(&self) -> DOMString { + fn VendorSub(&self) -> DOMString { ~"" // Like Gecko } - pub fn Product(&self) -> DOMString { + fn Product(&self) -> DOMString { ~"Gecko" } - pub fn ProductSub(&self) -> DOMString { + fn ProductSub(&self) -> DOMString { ~"" } - pub fn CookieEnabled(&self) -> bool { + fn CookieEnabled(&self) -> bool { false } - pub fn GetBuildID(&self) -> Fallible { + fn GetBuildID(&self) -> Fallible { Ok(~"") } - pub fn JavaEnabled(&self) -> Fallible { + fn JavaEnabled(&self) -> Fallible { Ok(false) } - pub fn TaintEnabled(&self) -> bool { + fn TaintEnabled(&self) -> bool { false } - pub fn AppName(&self) -> DOMString { + fn AppName(&self) -> DOMString { ~"Netscape" // Like Gecko/Webkit } - pub fn GetAppCodeName(&self) -> Fallible { + fn GetAppCodeName(&self) -> Fallible { Ok(~"Mozilla") // Like Gecko/Webkit } - pub fn GetAppVersion(&self) -> Fallible { + fn GetAppVersion(&self) -> Fallible { Ok(~"") } - pub fn GetPlatform(&self) -> Fallible { + fn GetPlatform(&self) -> Fallible { Ok(~"") } - pub fn GetUserAgent(&self) -> Fallible { + fn GetUserAgent(&self) -> Fallible { Ok(~"") } - pub fn GetLanguage(&self) -> Option { + fn GetLanguage(&self) -> Option { None } - pub fn OnLine(&self) -> bool { + fn OnLine(&self) -> bool { true } } + impl Reflectable for Navigator { fn reflector<'a>(&'a self) -> &'a Reflector { &self.reflector_ diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index fd911b3f0ba..f3aefd223cc 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -16,15 +16,15 @@ use dom::bindings::js::{ResultRootable, OptionalRootable}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::error::{ErrorResult, Fallible, NotFound, HierarchyRequest}; use dom::bindings::utils; -use dom::characterdata::CharacterData; +use dom::characterdata::{CharacterData, CharacterDataMethods}; use dom::comment::Comment; -use dom::document::{Document, HTMLDocument, NonHTMLDocument}; +use dom::document::{Document, DocumentMethods, HTMLDocument, NonHTMLDocument}; use dom::documentfragment::DocumentFragment; use dom::documenttype::DocumentType; -use dom::element::{Element, ElementTypeId, HTMLAnchorElementTypeId}; +use dom::element::{Element, ElementMethods, ElementTypeId, HTMLAnchorElementTypeId}; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::nodelist::{NodeList}; -use dom::processinginstruction::ProcessingInstruction; +use dom::processinginstruction::{ProcessingInstruction, ProcessingInstructionMethods}; use dom::text::Text; use dom::virtualmethods::{VirtualMethods, vtable_for}; use dom::window::Window; @@ -226,17 +226,17 @@ pub enum NodeTypeId { pub fn AppendChild<'a>(self_: &mut JSRef<'a, Node>, node: &mut JSRef) -> Fallible> { let mut self_alias = self_.clone(); - self_.get_mut().AppendChild(&mut self_alias, node) + self_.AppendChild(&mut self_alias, node) } pub fn ReplaceChild<'a>(self_: &mut JSRef<'a, Node>, node: &mut JSRef, child: &mut JSRef) -> Fallible> { let mut self_alias = self_.clone(); - self_.get_mut().ReplaceChild(&mut self_alias, node, child) + self_.ReplaceChild(&mut self_alias, node, child) } pub fn RemoveChild<'a>(self_: &mut JSRef<'a, Node>, node: &mut JSRef) -> Fallible> { let mut self_alias = self_.clone(); - self_.get_mut().RemoveChild(&mut self_alias, node) + self_.RemoveChild(&mut self_alias, node) } pub trait NodeHelpers { @@ -839,6 +839,12 @@ impl Node { }) } + pub fn wait_until_safe_to_modify_dom(&self) { + let roots = RootCollection::new(); + let document = self.owner_doc().root(&roots); + document.get().wait_until_safe_to_modify_dom(); + } + pub fn reflect_node (node: ~N, document: &JSRef, @@ -897,211 +903,6 @@ impl Node { } } - // http://dom.spec.whatwg.org/#dom-node-nodetype - pub fn NodeType(&self) -> u16 { - match self.type_id { - ElementNodeTypeId(_) => NodeConstants::ELEMENT_NODE, - TextNodeTypeId => NodeConstants::TEXT_NODE, - ProcessingInstructionNodeTypeId => NodeConstants::PROCESSING_INSTRUCTION_NODE, - CommentNodeTypeId => NodeConstants::COMMENT_NODE, - DocumentNodeTypeId => NodeConstants::DOCUMENT_NODE, - DoctypeNodeTypeId => NodeConstants::DOCUMENT_TYPE_NODE, - DocumentFragmentNodeTypeId => NodeConstants::DOCUMENT_FRAGMENT_NODE, - } - } - - // http://dom.spec.whatwg.org/#dom-node-nodename - pub fn NodeName(&self, abstract_self: &JSRef) -> DOMString { - match self.type_id { - ElementNodeTypeId(..) => { - let elem: &JSRef = ElementCast::to_ref(abstract_self).unwrap(); - elem.get().TagName() - } - TextNodeTypeId => ~"#text", - ProcessingInstructionNodeTypeId => { - let processing_instruction: &JSRef = - ProcessingInstructionCast::to_ref(abstract_self).unwrap(); - processing_instruction.get().Target() - } - CommentNodeTypeId => ~"#comment", - DoctypeNodeTypeId => { - let doctype: &JSRef = DocumentTypeCast::to_ref(abstract_self).unwrap(); - doctype.get().name.clone() - }, - DocumentFragmentNodeTypeId => ~"#document-fragment", - DocumentNodeTypeId => ~"#document" - } - } - - // http://dom.spec.whatwg.org/#dom-node-baseuri - pub fn GetBaseURI(&self) -> Option { - // FIXME (#1824) implement. - None - } - - // http://dom.spec.whatwg.org/#dom-node-ownerdocument - pub fn GetOwnerDocument(&self) -> Option> { - match self.type_id { - ElementNodeTypeId(..) | - CommentNodeTypeId | - TextNodeTypeId | - ProcessingInstructionNodeTypeId | - DoctypeNodeTypeId | - DocumentFragmentNodeTypeId => Some(self.owner_doc()), - DocumentNodeTypeId => None - } - } - - // http://dom.spec.whatwg.org/#dom-node-parentnode - pub fn GetParentNode(&self) -> Option> { - self.parent_node.clone().map(|node| Unrooted::new(node)) - } - - // http://dom.spec.whatwg.org/#dom-node-parentelement - pub fn GetParentElement(&self) -> Option> { - let roots = RootCollection::new(); - self.parent_node.clone() - .and_then(|parent| { - let parent = parent.root(&roots); - ElementCast::to_ref(&*parent).map(|elem| { - Unrooted::new_rooted(elem) - }) - }) - } - - // http://dom.spec.whatwg.org/#dom-node-haschildnodes - pub fn HasChildNodes(&self) -> bool { - self.first_child.is_some() - } - - // http://dom.spec.whatwg.org/#dom-node-childnodes - pub fn ChildNodes(&mut self, abstract_self: &JSRef) -> Unrooted { - let roots = RootCollection::new(); - match self.child_list { - None => { - let doc = self.owner_doc().root(&roots); - let window = doc.deref().window.root(&roots); - self.child_list.assign(Some(NodeList::new_child_list(&*window, abstract_self))); - Unrooted::new(self.child_list.get_ref().clone()) - } - Some(ref list) => Unrooted::new(list.clone()) - } - } - - // http://dom.spec.whatwg.org/#dom-node-firstchild - pub fn GetFirstChild(&self) -> Option> { - self.first_child.clone().map(|node| Unrooted::new(node)) - } - - // http://dom.spec.whatwg.org/#dom-node-lastchild - pub fn GetLastChild(&self) -> Option> { - self.last_child.clone().map(|node| Unrooted::new(node)) - } - - // http://dom.spec.whatwg.org/#dom-node-previoussibling - pub fn GetPreviousSibling(&self) -> Option> { - self.prev_sibling.clone().map(|node| Unrooted::new(node)) - } - - // http://dom.spec.whatwg.org/#dom-node-nextsibling - pub fn GetNextSibling(&self) -> Option> { - self.next_sibling.clone().map(|node| Unrooted::new(node)) - } - - // http://dom.spec.whatwg.org/#dom-node-nodevalue - pub fn GetNodeValue(&self, abstract_self: &JSRef) -> Option { - match self.type_id { - CommentNodeTypeId | - TextNodeTypeId | - ProcessingInstructionNodeTypeId => { - let chardata: &JSRef = CharacterDataCast::to_ref(abstract_self).unwrap(); - Some(chardata.get().Data()) - } - _ => { - None - } - } - } - - // http://dom.spec.whatwg.org/#dom-node-nodevalue - pub fn SetNodeValue(&mut self, abstract_self: &mut JSRef, val: Option) - -> ErrorResult { - match self.type_id { - CommentNodeTypeId | - TextNodeTypeId | - ProcessingInstructionNodeTypeId => { - self.SetTextContent(abstract_self, val) - } - _ => Ok(()) - } - } - - // http://dom.spec.whatwg.org/#dom-node-textcontent - pub fn GetTextContent(&self, abstract_self: &JSRef) -> Option { - let roots = RootCollection::new(); - match self.type_id { - DocumentFragmentNodeTypeId | - ElementNodeTypeId(..) => { - let mut content = ~""; - for node in abstract_self.traverse_preorder(&roots) { - if node.is_text() { - let text: &JSRef = TextCast::to_ref(&node).unwrap(); - content.push_str(text.get().characterdata.data.as_slice()); - } - } - Some(content) - } - CommentNodeTypeId | - TextNodeTypeId | - ProcessingInstructionNodeTypeId => { - let characterdata: &JSRef = CharacterDataCast::to_ref(abstract_self).unwrap(); - Some(characterdata.get().Data()) - } - DoctypeNodeTypeId | - DocumentNodeTypeId => { - None - } - } - } - - // http://dom.spec.whatwg.org/#dom-node-textcontent - pub fn SetTextContent(&mut self, abstract_self: &mut JSRef, value: Option) - -> ErrorResult { - let roots = RootCollection::new(); - let value = null_str_as_empty(&value); - match self.type_id { - DocumentFragmentNodeTypeId | - ElementNodeTypeId(..) => { - // Step 1-2. - let node = if value.len() == 0 { - None - } else { - let document = self.owner_doc(); - let document = document.root(&roots); - Some(NodeCast::from_unrooted(document.deref().CreateTextNode(&*document, value))) - }.root(&roots); - - // Step 3. - Node::replace_all(node.root_ref(), abstract_self); - } - CommentNodeTypeId | - TextNodeTypeId | - ProcessingInstructionNodeTypeId => { - self.wait_until_safe_to_modify_dom(); - - let characterdata: &mut JSRef = CharacterDataCast::to_mut_ref(abstract_self).unwrap(); - characterdata.get_mut().data = value.clone(); - - // Notify the document that the content of this node is different - let document = self.owner_doc().root(&roots); - document.get().content_changed(); - } - DoctypeNodeTypeId | - DocumentNodeTypeId => {} - } - Ok(()) - } - // http://dom.spec.whatwg.org/#concept-node-adopt pub fn adopt(node: &mut JSRef, document: &JSRef) { let roots = RootCollection::new(); @@ -1505,26 +1306,334 @@ impl Node { Unrooted::new_rooted(&*copy) } + // + // Low-level pointer stitching + // + + pub fn set_parent_node(&mut self, new_parent_node: Option>) { + let roots = RootCollection::new(); + let doc = self.owner_doc().root(&roots); + doc.get().wait_until_safe_to_modify_dom(); + self.parent_node.assign(new_parent_node); + } + + pub fn set_first_child(&mut self, new_first_child: Option>) { + let roots = RootCollection::new(); + let doc = self.owner_doc().root(&roots); + doc.get().wait_until_safe_to_modify_dom(); + self.first_child.assign(new_first_child); + } + + pub fn set_last_child(&mut self, new_last_child: Option>) { + let roots = RootCollection::new(); + let doc = self.owner_doc().root(&roots); + doc.get().wait_until_safe_to_modify_dom(); + self.last_child.assign(new_last_child); + } + + pub fn set_prev_sibling(&mut self, new_prev_sibling: Option>) { + let roots = RootCollection::new(); + let doc = self.owner_doc().root(&roots); + doc.get().wait_until_safe_to_modify_dom(); + self.prev_sibling.assign(new_prev_sibling); + } + + pub fn set_next_sibling(&mut self, new_next_sibling: Option>) { + let roots = RootCollection::new(); + let doc = self.owner_doc().root(&roots); + doc.get().wait_until_safe_to_modify_dom(); + self.next_sibling.assign(new_next_sibling); + } + + pub fn get_hover_state(&self) -> bool { + self.flags.get_in_hover_state() + } + + pub fn set_hover_state(&mut self, state: bool) { + self.flags.set_is_in_hover_state(state); + } + + #[inline] + pub fn parent_node_ref<'a>(&'a self) -> Option<&'a JS> { + self.parent_node.as_ref() + } + + #[inline] + pub fn first_child_ref<'a>(&'a self) -> Option<&'a JS> { + self.first_child.as_ref() + } + + #[inline] + pub fn last_child_ref<'a>(&'a self) -> Option<&'a JS> { + self.last_child.as_ref() + } + + #[inline] + pub fn prev_sibling_ref<'a>(&'a self) -> Option<&'a JS> { + self.prev_sibling.as_ref() + } + + #[inline] + pub fn next_sibling_ref<'a>(&'a self) -> Option<&'a JS> { + self.next_sibling.as_ref() + } + + pub unsafe fn get_hover_state_for_layout(&self) -> bool { + let unsafe_this: *Node = cast::transmute::<&Node,*Node>(self); + (*unsafe_this).flags.get_in_hover_state() + } +} + +pub trait NodeMethods { + fn NodeType(&self) -> u16; + fn NodeName(&self, abstract_self: &JSRef) -> DOMString; + fn GetBaseURI(&self) -> Option; + fn GetOwnerDocument(&self) -> Option>; + fn GetParentNode(&self) -> Option>; + fn GetParentElement(&self) -> Option>; + fn HasChildNodes(&self) -> bool; + fn ChildNodes(&mut self, abstract_self: &JSRef) -> Unrooted; + fn GetFirstChild(&self) -> Option>; + fn GetLastChild(&self) -> Option>; + fn GetPreviousSibling(&self) -> Option>; + fn GetNextSibling(&self) -> Option>; + fn GetNodeValue(&self, abstract_self: &JSRef) -> Option; + fn SetNodeValue(&mut self, abstract_self: &mut JSRef, val: Option) -> ErrorResult; + fn GetTextContent(&self, abstract_self: &JSRef) -> Option; + fn SetTextContent(&mut self, abstract_self: &mut JSRef, value: Option) -> ErrorResult; + fn InsertBefore(&self, abstract_self: &mut JSRef, node: &mut JSRef, child: Option>) -> Fallible>; + fn AppendChild(&self, abstract_self: &mut JSRef, node: &mut JSRef) -> Fallible>; + fn ReplaceChild(&self, parent: &mut JSRef, node: &mut JSRef, child: &mut JSRef) -> Fallible>; + fn RemoveChild(&self, abstract_self: &mut JSRef, node: &mut JSRef) -> Fallible>; + fn Normalize(&mut self, abstract_self: &mut JSRef); + fn CloneNode(&self, abstract_self: &mut JSRef, deep: bool) -> Unrooted; + fn IsEqualNode(&self, abstract_self: &JSRef, maybe_node: Option>) -> bool; + fn CompareDocumentPosition(&self, abstract_self: &JSRef, other: &JSRef) -> u16; + fn Contains(&self, abstract_self: &JSRef, maybe_other: Option>) -> bool; + fn LookupPrefix(&self, _prefix: Option) -> Option; + fn LookupNamespaceURI(&self, _namespace: Option) -> Option; + fn IsDefaultNamespace(&self, _namespace: Option) -> bool; +} + +impl<'a> NodeMethods for JSRef<'a, Node> { + // http://dom.spec.whatwg.org/#dom-node-nodetype + fn NodeType(&self) -> u16 { + match self.type_id { + ElementNodeTypeId(_) => NodeConstants::ELEMENT_NODE, + TextNodeTypeId => NodeConstants::TEXT_NODE, + ProcessingInstructionNodeTypeId => NodeConstants::PROCESSING_INSTRUCTION_NODE, + CommentNodeTypeId => NodeConstants::COMMENT_NODE, + DocumentNodeTypeId => NodeConstants::DOCUMENT_NODE, + DoctypeNodeTypeId => NodeConstants::DOCUMENT_TYPE_NODE, + DocumentFragmentNodeTypeId => NodeConstants::DOCUMENT_FRAGMENT_NODE, + } + } + + // http://dom.spec.whatwg.org/#dom-node-nodename + fn NodeName(&self, abstract_self: &JSRef) -> DOMString { + match self.type_id { + ElementNodeTypeId(..) => { + let elem: &JSRef = ElementCast::to_ref(abstract_self).unwrap(); + elem.TagName() + } + TextNodeTypeId => ~"#text", + ProcessingInstructionNodeTypeId => { + let processing_instruction: &JSRef = + ProcessingInstructionCast::to_ref(abstract_self).unwrap(); + processing_instruction.Target() + } + CommentNodeTypeId => ~"#comment", + DoctypeNodeTypeId => { + let doctype: &JSRef = DocumentTypeCast::to_ref(abstract_self).unwrap(); + doctype.get().name.clone() + }, + DocumentFragmentNodeTypeId => ~"#document-fragment", + DocumentNodeTypeId => ~"#document" + } + } + + // http://dom.spec.whatwg.org/#dom-node-baseuri + fn GetBaseURI(&self) -> Option { + // FIXME (#1824) implement. + None + } + + // http://dom.spec.whatwg.org/#dom-node-ownerdocument + fn GetOwnerDocument(&self) -> Option> { + match self.type_id { + ElementNodeTypeId(..) | + CommentNodeTypeId | + TextNodeTypeId | + ProcessingInstructionNodeTypeId | + DoctypeNodeTypeId | + DocumentFragmentNodeTypeId => Some(self.owner_doc()), + DocumentNodeTypeId => None + } + } + + // http://dom.spec.whatwg.org/#dom-node-parentnode + fn GetParentNode(&self) -> Option> { + self.parent_node.clone().map(|node| Unrooted::new(node)) + } + + // http://dom.spec.whatwg.org/#dom-node-parentelement + fn GetParentElement(&self) -> Option> { + let roots = RootCollection::new(); + self.parent_node.clone() + .and_then(|parent| { + let parent = parent.root(&roots); + ElementCast::to_ref(&*parent).map(|elem| { + Unrooted::new_rooted(elem) + }) + }) + } + + // http://dom.spec.whatwg.org/#dom-node-haschildnodes + fn HasChildNodes(&self) -> bool { + self.first_child.is_some() + } + + // http://dom.spec.whatwg.org/#dom-node-childnodes + fn ChildNodes(&mut self, abstract_self: &JSRef) -> Unrooted { + let roots = RootCollection::new(); + match self.child_list { + None => (), + Some(ref list) => return Unrooted::new(list.clone()), + } + + let doc = self.deref().owner_doc().root(&roots); + let window = doc.deref().window.root(&roots); + self.child_list.assign(Some(NodeList::new_child_list(&*window, abstract_self))); + Unrooted::new(self.child_list.get_ref().clone()) + } + + // http://dom.spec.whatwg.org/#dom-node-firstchild + fn GetFirstChild(&self) -> Option> { + self.first_child.clone().map(|node| Unrooted::new(node)) + } + + // http://dom.spec.whatwg.org/#dom-node-lastchild + fn GetLastChild(&self) -> Option> { + self.last_child.clone().map(|node| Unrooted::new(node)) + } + + // http://dom.spec.whatwg.org/#dom-node-previoussibling + fn GetPreviousSibling(&self) -> Option> { + self.prev_sibling.clone().map(|node| Unrooted::new(node)) + } + + // http://dom.spec.whatwg.org/#dom-node-nextsibling + fn GetNextSibling(&self) -> Option> { + self.next_sibling.clone().map(|node| Unrooted::new(node)) + } + + // http://dom.spec.whatwg.org/#dom-node-nodevalue + fn GetNodeValue(&self, abstract_self: &JSRef) -> Option { + match self.type_id { + CommentNodeTypeId | + TextNodeTypeId | + ProcessingInstructionNodeTypeId => { + let chardata: &JSRef = CharacterDataCast::to_ref(abstract_self).unwrap(); + Some(chardata.Data()) + } + _ => { + None + } + } + } + + // http://dom.spec.whatwg.org/#dom-node-nodevalue + fn SetNodeValue(&mut self, abstract_self: &mut JSRef, val: Option) + -> ErrorResult { + match self.type_id { + CommentNodeTypeId | + TextNodeTypeId | + ProcessingInstructionNodeTypeId => { + self.SetTextContent(abstract_self, val) + } + _ => Ok(()) + } + } + + // http://dom.spec.whatwg.org/#dom-node-textcontent + fn GetTextContent(&self, abstract_self: &JSRef) -> Option { + let roots = RootCollection::new(); + match self.type_id { + DocumentFragmentNodeTypeId | + ElementNodeTypeId(..) => { + let mut content = ~""; + for node in abstract_self.traverse_preorder(&roots) { + if node.is_text() { + let text: &JSRef = TextCast::to_ref(&node).unwrap(); + content.push_str(text.get().characterdata.data.as_slice()); + } + } + Some(content) + } + CommentNodeTypeId | + TextNodeTypeId | + ProcessingInstructionNodeTypeId => { + let characterdata: &JSRef = CharacterDataCast::to_ref(abstract_self).unwrap(); + Some(characterdata.Data()) + } + DoctypeNodeTypeId | + DocumentNodeTypeId => { + None + } + } + } + + // http://dom.spec.whatwg.org/#dom-node-textcontent + fn SetTextContent(&mut self, abstract_self: &mut JSRef, value: Option) + -> ErrorResult { + let roots = RootCollection::new(); + let value = null_str_as_empty(&value); + match self.type_id { + DocumentFragmentNodeTypeId | + ElementNodeTypeId(..) => { + // Step 1-2. + let node = if value.len() == 0 { + None + } else { + let document = self.owner_doc().root(&roots); + Some(NodeCast::from_unrooted(document.deref().CreateTextNode(&*document, value))) + }.root(&roots); + + // Step 3. + Node::replace_all(node.root_ref(), abstract_self); + } + CommentNodeTypeId | + TextNodeTypeId | + ProcessingInstructionNodeTypeId => { + self.wait_until_safe_to_modify_dom(); + + let characterdata: &mut JSRef = CharacterDataCast::to_mut_ref(abstract_self).unwrap(); + characterdata.get_mut().data = value.clone(); + + // Notify the document that the content of this node is different + let document = self.owner_doc().root(&roots); + document.get().content_changed(); + } + DoctypeNodeTypeId | + DocumentNodeTypeId => {} + } + Ok(()) + } + // http://dom.spec.whatwg.org/#dom-node-insertbefore - pub fn InsertBefore(&self, abstract_self: &mut JSRef, node: &mut JSRef, child: Option>) + fn InsertBefore(&self, abstract_self: &mut JSRef, node: &mut JSRef, child: Option>) -> Fallible> { Node::pre_insert(node, abstract_self, child) } - pub fn wait_until_safe_to_modify_dom(&self) { - let roots = RootCollection::new(); - let document = self.owner_doc().root(&roots); - document.get().wait_until_safe_to_modify_dom(); - } - // http://dom.spec.whatwg.org/#dom-node-appendchild - pub fn AppendChild(&self, abstract_self: &mut JSRef, node: &mut JSRef) + fn AppendChild(&self, abstract_self: &mut JSRef, node: &mut JSRef) -> Fallible> { Node::pre_insert(node, abstract_self, None) } // http://dom.spec.whatwg.org/#concept-node-replace - pub fn ReplaceChild(&self, parent: &mut JSRef, node: &mut JSRef, child: &mut JSRef) + fn ReplaceChild(&self, parent: &mut JSRef, node: &mut JSRef, child: &mut JSRef) -> Fallible> { let roots = RootCollection::new(); @@ -1655,26 +1764,26 @@ impl Node { } // http://dom.spec.whatwg.org/#dom-node-removechild - pub fn RemoveChild(&self, abstract_self: &mut JSRef, node: &mut JSRef) + fn RemoveChild(&self, abstract_self: &mut JSRef, node: &mut JSRef) -> Fallible> { Node::pre_remove(node, abstract_self) } // http://dom.spec.whatwg.org/#dom-node-normalize - pub fn Normalize(&mut self, abstract_self: &mut JSRef) { + fn Normalize(&mut self, abstract_self: &mut JSRef) { let roots = RootCollection::new(); let mut prev_text = None; for mut child in self.children() { if child.is_text() { let mut child_alias = child.clone(); let characterdata: &JSRef = CharacterDataCast::to_ref(&child).unwrap(); - if characterdata.get().Length() == 0 { + if characterdata.Length() == 0 { abstract_self.remove_child(&mut child_alias); } else { match prev_text { Some(ref mut text_node) => { let prev_characterdata: &mut JSRef = CharacterDataCast::to_mut_ref(text_node).unwrap(); - let _ = prev_characterdata.get_mut().AppendData(characterdata.get().Data()); + let _ = prev_characterdata.AppendData(characterdata.Data()); abstract_self.remove_child(&mut child_alias); }, None => prev_text = Some(child_alias) @@ -1682,7 +1791,7 @@ impl Node { } } else { let mut c = child.clone(); - child.get_mut().Normalize(&mut c); + child.Normalize(&mut c); prev_text = None; } @@ -1690,7 +1799,7 @@ impl Node { } // http://dom.spec.whatwg.org/#dom-node-clonenode - pub fn CloneNode(&self, abstract_self: &mut JSRef, deep: bool) -> Unrooted { + fn CloneNode(&self, abstract_self: &mut JSRef, deep: bool) -> Unrooted { match deep { true => Node::clone(abstract_self, None, CloneChildren), false => Node::clone(abstract_self, None, DoNotCloneChildren) @@ -1698,7 +1807,7 @@ impl Node { } // http://dom.spec.whatwg.org/#dom-node-isequalnode - pub fn IsEqualNode(&self, abstract_self: &JSRef, maybe_node: Option>) -> bool { + fn IsEqualNode(&self, abstract_self: &JSRef, maybe_node: Option>) -> bool { fn is_equal_doctype(node: &JSRef, other: &JSRef) -> bool { let doctype: &JSRef = DocumentTypeCast::to_ref(node).unwrap(); let other_doctype: &JSRef = DocumentTypeCast::to_ref(other).unwrap(); @@ -1775,7 +1884,7 @@ impl Node { } // http://dom.spec.whatwg.org/#dom-node-comparedocumentposition - pub fn CompareDocumentPosition(&self, abstract_self: &JSRef, other: &JSRef) -> u16 { + fn CompareDocumentPosition(&self, abstract_self: &JSRef, other: &JSRef) -> u16 { let roots = RootCollection::new(); if abstract_self == other { // step 2. @@ -1830,7 +1939,7 @@ impl Node { } // http://dom.spec.whatwg.org/#dom-node-contains - pub fn Contains(&self, abstract_self: &JSRef, maybe_other: Option>) -> bool { + fn Contains(&self, abstract_self: &JSRef, maybe_other: Option>) -> bool { match maybe_other { None => false, Some(ref other) => abstract_self.is_inclusive_ancestor_of(other) @@ -1838,100 +1947,25 @@ impl Node { } // http://dom.spec.whatwg.org/#dom-node-lookupprefix - pub fn LookupPrefix(&self, _prefix: Option) -> Option { + fn LookupPrefix(&self, _prefix: Option) -> Option { // FIXME (#1826) implement. None } // http://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri - pub fn LookupNamespaceURI(&self, _namespace: Option) -> Option { + fn LookupNamespaceURI(&self, _namespace: Option) -> Option { // FIXME (#1826) implement. None } // http://dom.spec.whatwg.org/#dom-node-isdefaultnamespace - pub fn IsDefaultNamespace(&self, _namespace: Option) -> bool { + fn IsDefaultNamespace(&self, _namespace: Option) -> bool { // FIXME (#1826) implement. false } - - // - // Low-level pointer stitching - // - - pub fn set_parent_node(&mut self, new_parent_node: Option>) { - let roots = RootCollection::new(); - let doc = self.owner_doc().root(&roots); - doc.get().wait_until_safe_to_modify_dom(); - self.parent_node.assign(new_parent_node); - } - - pub fn set_first_child(&mut self, new_first_child: Option>) { - let roots = RootCollection::new(); - let doc = self.owner_doc().root(&roots); - doc.get().wait_until_safe_to_modify_dom(); - self.first_child.assign(new_first_child); - } - - pub fn set_last_child(&mut self, new_last_child: Option>) { - let roots = RootCollection::new(); - let doc = self.owner_doc().root(&roots); - doc.get().wait_until_safe_to_modify_dom(); - self.last_child.assign(new_last_child); - } - - pub fn set_prev_sibling(&mut self, new_prev_sibling: Option>) { - let roots = RootCollection::new(); - let doc = self.owner_doc().root(&roots); - doc.get().wait_until_safe_to_modify_dom(); - self.prev_sibling.assign(new_prev_sibling); - } - - pub fn set_next_sibling(&mut self, new_next_sibling: Option>) { - let roots = RootCollection::new(); - let doc = self.owner_doc().root(&roots); - doc.get().wait_until_safe_to_modify_dom(); - self.next_sibling.assign(new_next_sibling); - } - - pub fn get_hover_state(&self) -> bool { - self.flags.get_in_hover_state() - } - - pub fn set_hover_state(&mut self, state: bool) { - self.flags.set_is_in_hover_state(state); - } - - #[inline] - pub fn parent_node_ref<'a>(&'a self) -> Option<&'a JS> { - self.parent_node.as_ref() - } - - #[inline] - pub fn first_child_ref<'a>(&'a self) -> Option<&'a JS> { - self.first_child.as_ref() - } - - #[inline] - pub fn last_child_ref<'a>(&'a self) -> Option<&'a JS> { - self.last_child.as_ref() - } - - #[inline] - pub fn prev_sibling_ref<'a>(&'a self) -> Option<&'a JS> { - self.prev_sibling.as_ref() - } - - #[inline] - pub fn next_sibling_ref<'a>(&'a self) -> Option<&'a JS> { - self.next_sibling.as_ref() - } - - pub unsafe fn get_hover_state_for_layout(&self) -> bool { - self.flags.get_in_hover_state() - } } + impl Reflectable for Node { fn reflector<'a>(&'a self) -> &'a Reflector { self.eventtarget.reflector() diff --git a/src/components/script/dom/nodelist.rs b/src/components/script/dom/nodelist.rs index 219731034f1..a874a068b65 100644 --- a/src/components/script/dom/nodelist.rs +++ b/src/components/script/dom/nodelist.rs @@ -44,8 +44,16 @@ impl NodeList { pub fn new_child_list(window: &JSRef, node: &JSRef) -> Unrooted { NodeList::new(window, Children(node.unrooted())) } +} - pub fn Length(&self) -> u32 { +pub trait NodeListMethods { + fn Length(&self) -> u32; + fn Item(&self, index: u32) -> Option>; + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option>; +} + +impl<'a> NodeListMethods for JSRef<'a, NodeList> { + fn Length(&self) -> u32 { let roots = RootCollection::new(); match self.list_type { Simple(ref elems) => elems.len() as u32, @@ -56,7 +64,7 @@ impl NodeList { } } - pub fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { let roots = RootCollection::new(); match self.list_type { _ if index >= self.Length() => None, @@ -69,7 +77,7 @@ impl NodeList { } } - pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { let item = self.Item(index); *found = item.is_some(); item diff --git a/src/components/script/dom/processinginstruction.rs b/src/components/script/dom/processinginstruction.rs index c094e4ae654..ee88cb51bf6 100644 --- a/src/components/script/dom/processinginstruction.rs +++ b/src/components/script/dom/processinginstruction.rs @@ -41,8 +41,13 @@ impl ProcessingInstruction { } } -impl ProcessingInstruction { - pub fn Target(&self) -> DOMString { +pub trait ProcessingInstructionMethods { + fn Target(&self) -> DOMString; +} + +impl<'a> ProcessingInstructionMethods for JSRef<'a, ProcessingInstruction> { + fn Target(&self) -> DOMString { self.target.clone() } } + diff --git a/src/components/script/dom/testbinding.rs b/src/components/script/dom/testbinding.rs index 76bb587b134..3ad4f8fa202 100644 --- a/src/components/script/dom/testbinding.rs +++ b/src/components/script/dom/testbinding.rs @@ -22,192 +22,372 @@ pub struct TestBinding { pub window: JS, } -impl TestBinding { - pub fn BooleanAttribute(&self) -> bool { false } - pub fn SetBooleanAttribute(&self, _: bool) {} - pub fn ByteAttribute(&self) -> i8 { 0 } - pub fn SetByteAttribute(&self, _: i8) {} - pub fn OctetAttribute(&self) -> u8 { 0 } - pub fn SetOctetAttribute(&self, _: u8) {} - pub fn ShortAttribute(&self) -> i16 { 0 } - pub fn SetShortAttribute(&self, _: i16) {} - pub fn UnsignedShortAttribute(&self) -> u16 { 0 } - pub fn SetUnsignedShortAttribute(&self, _: u16) {} - pub fn LongAttribute(&self) -> i32 { 0 } - pub fn SetLongAttribute(&self, _: i32) {} - pub fn UnsignedLongAttribute(&self) -> u32 { 0 } - pub fn SetUnsignedLongAttribute(&self, _: u32) {} - pub fn LongLongAttribute(&self) -> i64 { 0 } - pub fn SetLongLongAttribute(&self, _: i64) {} - pub fn UnsignedLongLongAttribute(&self) -> u64 { 0 } - pub fn SetUnsignedLongLongAttribute(&self, _: u64) {} - pub fn FloatAttribute(&self) -> f32 { 0. } - pub fn SetFloatAttribute(&self, _: f32) {} - pub fn DoubleAttribute(&self) -> f64 { 0. } - pub fn SetDoubleAttribute(&self, _: f64) {} - pub fn StringAttribute(&self) -> DOMString { ~"" } - pub fn SetStringAttribute(&self, _: DOMString) {} - pub fn ByteStringAttribute(&self) -> ByteString { ByteString::new(vec!()) } - pub fn SetByteStringAttribute(&self, _: ByteString) {} - pub fn EnumAttribute(&self) -> TestEnum { _empty } - pub fn SetEnumAttribute(&self, _: TestEnum) {} - pub fn InterfaceAttribute(&self) -> Unrooted { +pub trait TestBindingMethods { + fn BooleanAttribute(&self) -> bool; + fn SetBooleanAttribute(&self, _: bool); + fn ByteAttribute(&self) -> i8; + fn SetByteAttribute(&self, _: i8); + fn OctetAttribute(&self) -> u8; + fn SetOctetAttribute(&self, _: u8); + fn ShortAttribute(&self) -> i16; + fn SetShortAttribute(&self, _: i16); + fn UnsignedShortAttribute(&self) -> u16; + fn SetUnsignedShortAttribute(&self, _: u16); + fn LongAttribute(&self) -> i32; + fn SetLongAttribute(&self, _: i32); + fn UnsignedLongAttribute(&self) -> u32; + fn SetUnsignedLongAttribute(&self, _: u32); + fn LongLongAttribute(&self) -> i64; + fn SetLongLongAttribute(&self, _: i64); + fn UnsignedLongLongAttribute(&self) -> u64; + fn SetUnsignedLongLongAttribute(&self, _: u64); + fn FloatAttribute(&self) -> f32; + fn SetFloatAttribute(&self, _: f32); + fn DoubleAttribute(&self) -> f64; + fn SetDoubleAttribute(&self, _: f64); + fn StringAttribute(&self) -> DOMString; + fn SetStringAttribute(&self, _: DOMString); + fn ByteStringAttribute(&self) -> ByteString; + fn SetByteStringAttribute(&self, _: ByteString); + fn EnumAttribute(&self) -> TestEnum; + fn SetEnumAttribute(&self, _: TestEnum); + fn InterfaceAttribute(&self) -> Unrooted; + fn SetInterfaceAttribute(&self, _: &JSRef); + fn AnyAttribute(&self, _: *JSContext) -> JSVal; + fn SetAnyAttribute(&self, _: *JSContext, _: JSVal); + + fn GetBooleanAttributeNullable(&self) -> Option; + fn SetBooleanAttributeNullable(&self, _: Option); + fn GetByteAttributeNullable(&self) -> Option; + fn SetByteAttributeNullable(&self, _: Option); + fn GetOctetAttributeNullable(&self) -> Option; + fn SetOctetAttributeNullable(&self, _: Option); + fn GetShortAttributeNullable(&self) -> Option; + fn SetShortAttributeNullable(&self, _: Option); + fn GetUnsignedShortAttributeNullable(&self) -> Option; + fn SetUnsignedShortAttributeNullable(&self, _: Option); + fn GetLongAttributeNullable(&self) -> Option; + fn SetLongAttributeNullable(&self, _: Option); + fn GetUnsignedLongAttributeNullable(&self) -> Option; + fn SetUnsignedLongAttributeNullable(&self, _: Option); + fn GetLongLongAttributeNullable(&self) -> Option; + fn SetLongLongAttributeNullable(&self, _: Option); + fn GetUnsignedLongLongAttributeNullable(&self) -> Option; + fn SetUnsignedLongLongAttributeNullable(&self, _: Option); + fn GetFloatAttributeNullable(&self) -> Option; + fn SetFloatAttributeNullable(&self, _: Option); + fn GetDoubleAttributeNullable(&self) -> Option; + fn SetDoubleAttributeNullable(&self, _: Option); + fn GetByteStringAttributeNullable(&self) -> Option; + fn SetByteStringAttributeNullable(&self, _: Option); + fn GetStringAttributeNullable(&self) -> Option; + fn SetStringAttributeNullable(&self, _: Option); + fn GetEnumAttributeNullable(&self) -> Option; + fn GetInterfaceAttributeNullable(&self) -> Option>; + fn SetInterfaceAttributeNullable(&self, _: Option>); + + fn PassBoolean(&self, _: bool); + fn PassByte(&self, _: i8); + fn PassOctet(&self, _: u8); + fn PassShort(&self, _: i16); + fn PassUnsignedShort(&self, _: u16); + fn PassLong(&self, _: i32); + fn PassUnsignedLong(&self, _: u32); + fn PassLongLong(&self, _: i64); + fn PassUnsignedLongLong(&self, _: u64); + fn PassFloat(&self, _: f32); + fn PassDouble(&self, _: f64); + fn PassString(&self, _: DOMString); + fn PassByteString(&self, _: ByteString); + fn PassEnum(&self, _: TestEnum); + fn PassInterface(&self, _: &JSRef); + fn PassUnion(&self, _: HTMLElementOrLong); + fn PassAny(&self, _: *JSContext, _: JSVal); + + fn PassNullableBoolean(&self, _: Option); + fn PassNullableByte(&self, _: Option); + fn PassNullableOctet(&self, _: Option); + fn PassNullableShort(&self, _: Option); + fn PassNullableUnsignedShort(&self, _: Option); + fn PassNullableLong(&self, _: Option); + fn PassNullableUnsignedLong(&self, _: Option); + fn PassNullableLongLong(&self, _: Option); + fn PassNullableUnsignedLongLong(&self, _: Option); + fn PassNullableFloat(&self, _: Option); + fn PassNullableDouble(&self, _: Option); + fn PassNullableString(&self, _: Option); + fn PassNullableByteString(&self, _: Option) {} + // fn PassNullableEnum(&self, _: Option); + fn PassNullableInterface(&self, _: Option>); + fn PassNullableUnion(&self, _: Option); + fn PassNullableAny(&self, _: *JSContext, _: Option); + + fn PassOptionalBoolean(&self, _: Option); + fn PassOptionalByte(&self, _: Option); + fn PassOptionalOctet(&self, _: Option); + fn PassOptionalShort(&self, _: Option); + fn PassOptionalUnsignedShort(&self, _: Option); + fn PassOptionalLong(&self, _: Option); + fn PassOptionalUnsignedLong(&self, _: Option); + fn PassOptionalLongLong(&self, _: Option); + fn PassOptionalUnsignedLongLong(&self, _: Option); + fn PassOptionalFloat(&self, _: Option); + fn PassOptionalDouble(&self, _: Option); + fn PassOptionalString(&self, _: Option); + fn PassOptionalByteString(&self, _: Option) {} + fn PassOptionalEnum(&self, _: Option); + fn PassOptionalInterface(&self, _: Option>); + fn PassOptionalUnion(&self, _: Option); + fn PassOptionalAny(&self, _: *JSContext, _: Option); + + fn PassOptionalNullableBoolean(&self, _: Option>); + fn PassOptionalNullableByte(&self, _: Option>); + fn PassOptionalNullableOctet(&self, _: Option>); + fn PassOptionalNullableShort(&self, _: Option>); + fn PassOptionalNullableUnsignedShort(&self, _: Option>); + fn PassOptionalNullableLong(&self, _: Option>); + fn PassOptionalNullableUnsignedLong(&self, _: Option>); + fn PassOptionalNullableLongLong(&self, _: Option>); + fn PassOptionalNullableUnsignedLongLong(&self, _: Option>); + fn PassOptionalNullableFloat(&self, _: Option>); + fn PassOptionalNullableDouble(&self, _: Option>); + fn PassOptionalNullableString(&self, _: Option>); + fn PassOptionalNullableByteString(&self, _: Option>) {} + // fn PassOptionalNullableEnum(&self, _: Option>); + fn PassOptionalNullableInterface(&self, _: Option>>); + fn PassOptionalNullableUnion(&self, _: Option>); + + fn PassOptionalBooleanWithDefault(&self, _: bool); + fn PassOptionalByteWithDefault(&self, _: i8); + fn PassOptionalOctetWithDefault(&self, _: u8); + fn PassOptionalShortWithDefault(&self, _: i16); + fn PassOptionalUnsignedShortWithDefault(&self, _: u16); + fn PassOptionalLongWithDefault(&self, _: i32); + fn PassOptionalUnsignedLongWithDefault(&self, _: u32); + fn PassOptionalLongLongWithDefault(&self, _: i64); + fn PassOptionalUnsignedLongLongWithDefault(&self, _: u64); + fn PassOptionalStringWithDefault(&self, _: DOMString); + fn PassOptionalEnumWithDefault(&self, _: TestEnum); + + fn PassOptionalNullableBooleanWithDefault(&self, _: Option); + fn PassOptionalNullableByteWithDefault(&self, _: Option); + fn PassOptionalNullableOctetWithDefault(&self, _: Option); + fn PassOptionalNullableShortWithDefault(&self, _: Option); + fn PassOptionalNullableUnsignedShortWithDefault(&self, _: Option); + fn PassOptionalNullableLongWithDefault(&self, _: Option); + fn PassOptionalNullableUnsignedLongWithDefault(&self, _: Option); + fn PassOptionalNullableLongLongWithDefault(&self, _: Option); + fn PassOptionalNullableUnsignedLongLongWithDefault(&self, _: Option); + fn PassOptionalNullableFloatWithDefault(&self, _: Option); + fn PassOptionalNullableDoubleWithDefault(&self, _: Option); + fn PassOptionalNullableStringWithDefault(&self, _: Option); + fn PassOptionalNullableByteStringWithDefault(&self, _: Option) {} + // fn PassOptionalNullableEnumWithDefault(&self, _: Option); + fn PassOptionalNullableInterfaceWithDefault(&self, _: Option>); + fn PassOptionalNullableUnionWithDefault(&self, _: Option); + fn PassOptionalAnyWithDefault(&self, _: *JSContext, _: JSVal); + + fn PassOptionalNullableBooleanWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableByteWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableOctetWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableShortWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableUnsignedShortWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableLongWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableUnsignedLongWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableLongLongWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableUnsignedLongLongWithNonNullDefault(&self, _: Option); + // fn PassOptionalNullableFloatWithNonNullDefault(&self, _: Option); + // fn PassOptionalNullableDoubleWithNonNullDefault(&self, _: Option); + fn PassOptionalNullableStringWithNonNullDefault(&self, _: Option); + // fn PassOptionalNullableEnumWithNonNullDefault(&self, _: Option); +} + +impl<'a> TestBindingMethods for JSRef<'a, TestBinding> { + fn BooleanAttribute(&self) -> bool { false } + fn SetBooleanAttribute(&self, _: bool) {} + fn ByteAttribute(&self) -> i8 { 0 } + fn SetByteAttribute(&self, _: i8) {} + fn OctetAttribute(&self) -> u8 { 0 } + fn SetOctetAttribute(&self, _: u8) {} + fn ShortAttribute(&self) -> i16 { 0 } + fn SetShortAttribute(&self, _: i16) {} + fn UnsignedShortAttribute(&self) -> u16 { 0 } + fn SetUnsignedShortAttribute(&self, _: u16) {} + fn LongAttribute(&self) -> i32 { 0 } + fn SetLongAttribute(&self, _: i32) {} + fn UnsignedLongAttribute(&self) -> u32 { 0 } + fn SetUnsignedLongAttribute(&self, _: u32) {} + fn LongLongAttribute(&self) -> i64 { 0 } + fn SetLongLongAttribute(&self, _: i64) {} + fn UnsignedLongLongAttribute(&self) -> u64 { 0 } + fn SetUnsignedLongLongAttribute(&self, _: u64) {} + fn FloatAttribute(&self) -> f32 { 0. } + fn SetFloatAttribute(&self, _: f32) {} + fn DoubleAttribute(&self) -> f64 { 0. } + fn SetDoubleAttribute(&self, _: f64) {} + fn StringAttribute(&self) -> DOMString { ~"" } + fn SetStringAttribute(&self, _: DOMString) {} + fn ByteStringAttribute(&self) -> ByteString { ByteString::new(vec!()) } + fn SetByteStringAttribute(&self, _: ByteString) {} + fn EnumAttribute(&self) -> TestEnum { _empty } + fn SetEnumAttribute(&self, _: TestEnum) {} + fn InterfaceAttribute(&self) -> Unrooted { let roots = RootCollection::new(); let window = self.window.root(&roots); Blob::new(&*window) } - pub fn SetInterfaceAttribute(&self, _: &JSRef) {} - pub fn AnyAttribute(&self, _: *JSContext) -> JSVal { NullValue() } - pub fn SetAnyAttribute(&self, _: *JSContext, _: JSVal) {} + fn SetInterfaceAttribute(&self, _: &JSRef) {} + fn AnyAttribute(&self, _: *JSContext) -> JSVal { NullValue() } + fn SetAnyAttribute(&self, _: *JSContext, _: JSVal) {} - pub fn GetBooleanAttributeNullable(&self) -> Option { Some(false) } - pub fn SetBooleanAttributeNullable(&self, _: Option) {} - pub fn GetByteAttributeNullable(&self) -> Option { Some(0) } - pub fn SetByteAttributeNullable(&self, _: Option) {} - pub fn GetOctetAttributeNullable(&self) -> Option { Some(0) } - pub fn SetOctetAttributeNullable(&self, _: Option) {} - pub fn GetShortAttributeNullable(&self) -> Option { Some(0) } - pub fn SetShortAttributeNullable(&self, _: Option) {} - pub fn GetUnsignedShortAttributeNullable(&self) -> Option { Some(0) } - pub fn SetUnsignedShortAttributeNullable(&self, _: Option) {} - pub fn GetLongAttributeNullable(&self) -> Option { Some(0) } - pub fn SetLongAttributeNullable(&self, _: Option) {} - pub fn GetUnsignedLongAttributeNullable(&self) -> Option { Some(0) } - pub fn SetUnsignedLongAttributeNullable(&self, _: Option) {} - pub fn GetLongLongAttributeNullable(&self) -> Option { Some(0) } - pub fn SetLongLongAttributeNullable(&self, _: Option) {} - pub fn GetUnsignedLongLongAttributeNullable(&self) -> Option { Some(0) } - pub fn SetUnsignedLongLongAttributeNullable(&self, _: Option) {} - pub fn GetFloatAttributeNullable(&self) -> Option { Some(0.) } - pub fn SetFloatAttributeNullable(&self, _: Option) {} - pub fn GetDoubleAttributeNullable(&self) -> Option { Some(0.) } - pub fn SetDoubleAttributeNullable(&self, _: Option) {} - pub fn GetByteStringAttributeNullable(&self) -> Option { Some(ByteString::new(vec!())) } - pub fn SetByteStringAttributeNullable(&self, _: Option) {} - pub fn GetStringAttributeNullable(&self) -> Option { Some(~"") } - pub fn SetStringAttributeNullable(&self, _: Option) {} - pub fn GetEnumAttributeNullable(&self) -> Option { Some(_empty) } - pub fn GetInterfaceAttributeNullable(&self) -> Option> { + fn GetBooleanAttributeNullable(&self) -> Option { Some(false) } + fn SetBooleanAttributeNullable(&self, _: Option) {} + fn GetByteAttributeNullable(&self) -> Option { Some(0) } + fn SetByteAttributeNullable(&self, _: Option) {} + fn GetOctetAttributeNullable(&self) -> Option { Some(0) } + fn SetOctetAttributeNullable(&self, _: Option) {} + fn GetShortAttributeNullable(&self) -> Option { Some(0) } + fn SetShortAttributeNullable(&self, _: Option) {} + fn GetUnsignedShortAttributeNullable(&self) -> Option { Some(0) } + fn SetUnsignedShortAttributeNullable(&self, _: Option) {} + fn GetLongAttributeNullable(&self) -> Option { Some(0) } + fn SetLongAttributeNullable(&self, _: Option) {} + fn GetUnsignedLongAttributeNullable(&self) -> Option { Some(0) } + fn SetUnsignedLongAttributeNullable(&self, _: Option) {} + fn GetLongLongAttributeNullable(&self) -> Option { Some(0) } + fn SetLongLongAttributeNullable(&self, _: Option) {} + fn GetUnsignedLongLongAttributeNullable(&self) -> Option { Some(0) } + fn SetUnsignedLongLongAttributeNullable(&self, _: Option) {} + fn GetFloatAttributeNullable(&self) -> Option { Some(0.) } + fn SetFloatAttributeNullable(&self, _: Option) {} + fn GetDoubleAttributeNullable(&self) -> Option { Some(0.) } + fn SetDoubleAttributeNullable(&self, _: Option) {} + fn GetByteStringAttributeNullable(&self) -> Option { Some(ByteString::new(vec!())) } + fn SetByteStringAttributeNullable(&self, _: Option) {} + fn GetStringAttributeNullable(&self) -> Option { Some(~"") } + fn SetStringAttributeNullable(&self, _: Option) {} + fn GetEnumAttributeNullable(&self) -> Option { Some(_empty) } + fn GetInterfaceAttributeNullable(&self) -> Option> { let roots = RootCollection::new(); let window = self.window.root(&roots); Some(Blob::new(&(*window))) } - pub fn SetInterfaceAttributeNullable(&self, _: Option>) {} + fn SetInterfaceAttributeNullable(&self, _: Option>) {} - pub fn PassBoolean(&self, _: bool) {} - pub fn PassByte(&self, _: i8) {} - pub fn PassOctet(&self, _: u8) {} - pub fn PassShort(&self, _: i16) {} - pub fn PassUnsignedShort(&self, _: u16) {} - pub fn PassLong(&self, _: i32) {} - pub fn PassUnsignedLong(&self, _: u32) {} - pub fn PassLongLong(&self, _: i64) {} - pub fn PassUnsignedLongLong(&self, _: u64) {} - pub fn PassFloat(&self, _: f32) {} - pub fn PassDouble(&self, _: f64) {} - pub fn PassString(&self, _: DOMString) {} - pub fn PassByteString(&self, _: ByteString) {} - pub fn PassEnum(&self, _: TestEnum) {} - pub fn PassInterface(&self, _: &JSRef) {} - pub fn PassUnion(&self, _: HTMLElementOrLong) {} - pub fn PassAny(&self, _: *JSContext, _: JSVal) {} + fn PassBoolean(&self, _: bool) {} + fn PassByte(&self, _: i8) {} + fn PassOctet(&self, _: u8) {} + fn PassShort(&self, _: i16) {} + fn PassUnsignedShort(&self, _: u16) {} + fn PassLong(&self, _: i32) {} + fn PassUnsignedLong(&self, _: u32) {} + fn PassLongLong(&self, _: i64) {} + fn PassUnsignedLongLong(&self, _: u64) {} + fn PassFloat(&self, _: f32) {} + fn PassDouble(&self, _: f64) {} + fn PassString(&self, _: DOMString) {} + fn PassByteString(&self, _: ByteString) {} + fn PassEnum(&self, _: TestEnum) {} + fn PassInterface(&self, _: &JSRef) {} + fn PassUnion(&self, _: HTMLElementOrLong) {} + fn PassAny(&self, _: *JSContext, _: JSVal) {} - pub fn PassNullableBoolean(&self, _: Option) {} - pub fn PassNullableByte(&self, _: Option) {} - pub fn PassNullableOctet(&self, _: Option) {} - pub fn PassNullableShort(&self, _: Option) {} - pub fn PassNullableUnsignedShort(&self, _: Option) {} - pub fn PassNullableLong(&self, _: Option) {} - pub fn PassNullableUnsignedLong(&self, _: Option) {} - pub fn PassNullableLongLong(&self, _: Option) {} - pub fn PassNullableUnsignedLongLong(&self, _: Option) {} - pub fn PassNullableFloat(&self, _: Option) {} - pub fn PassNullableDouble(&self, _: Option) {} - pub fn PassNullableString(&self, _: Option) {} - pub fn PassNullableByteString(&self, _: Option) {} - // pub fn PassNullableEnum(&self, _: Option) {} - pub fn PassNullableInterface(&self, _: Option>) {} - pub fn PassNullableUnion(&self, _: Option) {} - pub fn PassNullableAny(&self, _: *JSContext, _: Option) {} + fn PassNullableBoolean(&self, _: Option) {} + fn PassNullableByte(&self, _: Option) {} + fn PassNullableOctet(&self, _: Option) {} + fn PassNullableShort(&self, _: Option) {} + fn PassNullableUnsignedShort(&self, _: Option) {} + fn PassNullableLong(&self, _: Option) {} + fn PassNullableUnsignedLong(&self, _: Option) {} + fn PassNullableLongLong(&self, _: Option) {} + fn PassNullableUnsignedLongLong(&self, _: Option) {} + fn PassNullableFloat(&self, _: Option) {} + fn PassNullableDouble(&self, _: Option) {} + fn PassNullableString(&self, _: Option) {} + fn PassNullableByteString(&self, _: Option) {} + // fn PassNullableEnum(&self, _: Option) {} + fn PassNullableInterface(&self, _: Option>) {} + fn PassNullableUnion(&self, _: Option) {} + fn PassNullableAny(&self, _: *JSContext, _: Option) {} - pub fn PassOptionalBoolean(&self, _: Option) {} - pub fn PassOptionalByte(&self, _: Option) {} - pub fn PassOptionalOctet(&self, _: Option) {} - pub fn PassOptionalShort(&self, _: Option) {} - pub fn PassOptionalUnsignedShort(&self, _: Option) {} - pub fn PassOptionalLong(&self, _: Option) {} - pub fn PassOptionalUnsignedLong(&self, _: Option) {} - pub fn PassOptionalLongLong(&self, _: Option) {} - pub fn PassOptionalUnsignedLongLong(&self, _: Option) {} - pub fn PassOptionalFloat(&self, _: Option) {} - pub fn PassOptionalDouble(&self, _: Option) {} - pub fn PassOptionalString(&self, _: Option) {} - pub fn PassOptionalByteString(&self, _: Option) {} - pub fn PassOptionalEnum(&self, _: Option) {} - pub fn PassOptionalInterface(&self, _: Option>) {} - pub fn PassOptionalUnion(&self, _: Option) {} - pub fn PassOptionalAny(&self, _: *JSContext, _: Option) {} + fn PassOptionalBoolean(&self, _: Option) {} + fn PassOptionalByte(&self, _: Option) {} + fn PassOptionalOctet(&self, _: Option) {} + fn PassOptionalShort(&self, _: Option) {} + fn PassOptionalUnsignedShort(&self, _: Option) {} + fn PassOptionalLong(&self, _: Option) {} + fn PassOptionalUnsignedLong(&self, _: Option) {} + fn PassOptionalLongLong(&self, _: Option) {} + fn PassOptionalUnsignedLongLong(&self, _: Option) {} + fn PassOptionalFloat(&self, _: Option) {} + fn PassOptionalDouble(&self, _: Option) {} + fn PassOptionalString(&self, _: Option) {} + fn PassOptionalByteString(&self, _: Option) {} + fn PassOptionalEnum(&self, _: Option) {} + fn PassOptionalInterface(&self, _: Option>) {} + fn PassOptionalUnion(&self, _: Option) {} + fn PassOptionalAny(&self, _: *JSContext, _: Option) {} - pub fn PassOptionalNullableBoolean(&self, _: Option>) {} - pub fn PassOptionalNullableByte(&self, _: Option>) {} - pub fn PassOptionalNullableOctet(&self, _: Option>) {} - pub fn PassOptionalNullableShort(&self, _: Option>) {} - pub fn PassOptionalNullableUnsignedShort(&self, _: Option>) {} - pub fn PassOptionalNullableLong(&self, _: Option>) {} - pub fn PassOptionalNullableUnsignedLong(&self, _: Option>) {} - pub fn PassOptionalNullableLongLong(&self, _: Option>) {} - pub fn PassOptionalNullableUnsignedLongLong(&self, _: Option>) {} - pub fn PassOptionalNullableFloat(&self, _: Option>) {} - pub fn PassOptionalNullableDouble(&self, _: Option>) {} - pub fn PassOptionalNullableString(&self, _: Option>) {} - pub fn PassOptionalNullableByteString(&self, _: Option>) {} - // pub fn PassOptionalNullableEnum(&self, _: Option>) {} - pub fn PassOptionalNullableInterface(&self, _: Option>>) {} - pub fn PassOptionalNullableUnion(&self, _: Option>) {} + fn PassOptionalNullableBoolean(&self, _: Option>) {} + fn PassOptionalNullableByte(&self, _: Option>) {} + fn PassOptionalNullableOctet(&self, _: Option>) {} + fn PassOptionalNullableShort(&self, _: Option>) {} + fn PassOptionalNullableUnsignedShort(&self, _: Option>) {} + fn PassOptionalNullableLong(&self, _: Option>) {} + fn PassOptionalNullableUnsignedLong(&self, _: Option>) {} + fn PassOptionalNullableLongLong(&self, _: Option>) {} + fn PassOptionalNullableUnsignedLongLong(&self, _: Option>) {} + fn PassOptionalNullableFloat(&self, _: Option>) {} + fn PassOptionalNullableDouble(&self, _: Option>) {} + fn PassOptionalNullableString(&self, _: Option>) {} + fn PassOptionalNullableByteString(&self, _: Option>) {} + // fn PassOptionalNullableEnum(&self, _: Option>) {} + fn PassOptionalNullableInterface(&self, _: Option>>) {} + fn PassOptionalNullableUnion(&self, _: Option>) {} - pub fn PassOptionalBooleanWithDefault(&self, _: bool) {} - pub fn PassOptionalByteWithDefault(&self, _: i8) {} - pub fn PassOptionalOctetWithDefault(&self, _: u8) {} - pub fn PassOptionalShortWithDefault(&self, _: i16) {} - pub fn PassOptionalUnsignedShortWithDefault(&self, _: u16) {} - pub fn PassOptionalLongWithDefault(&self, _: i32) {} - pub fn PassOptionalUnsignedLongWithDefault(&self, _: u32) {} - pub fn PassOptionalLongLongWithDefault(&self, _: i64) {} - pub fn PassOptionalUnsignedLongLongWithDefault(&self, _: u64) {} - pub fn PassOptionalStringWithDefault(&self, _: DOMString) {} - pub fn PassOptionalEnumWithDefault(&self, _: TestEnum) {} + fn PassOptionalBooleanWithDefault(&self, _: bool) {} + fn PassOptionalByteWithDefault(&self, _: i8) {} + fn PassOptionalOctetWithDefault(&self, _: u8) {} + fn PassOptionalShortWithDefault(&self, _: i16) {} + fn PassOptionalUnsignedShortWithDefault(&self, _: u16) {} + fn PassOptionalLongWithDefault(&self, _: i32) {} + fn PassOptionalUnsignedLongWithDefault(&self, _: u32) {} + fn PassOptionalLongLongWithDefault(&self, _: i64) {} + fn PassOptionalUnsignedLongLongWithDefault(&self, _: u64) {} + fn PassOptionalStringWithDefault(&self, _: DOMString) {} + fn PassOptionalEnumWithDefault(&self, _: TestEnum) {} - pub fn PassOptionalNullableBooleanWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableByteWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableOctetWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableShortWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableUnsignedShortWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableLongWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableUnsignedLongWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableLongLongWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableUnsignedLongLongWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableFloatWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableDoubleWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableStringWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableByteStringWithDefault(&self, _: Option) {} - // pub fn PassOptionalNullableEnumWithDefault(&self, _: Option) {} - pub fn PassOptionalNullableInterfaceWithDefault(&self, _: Option>) {} - pub fn PassOptionalNullableUnionWithDefault(&self, _: Option) {} - pub fn PassOptionalAnyWithDefault(&self, _: *JSContext, _: JSVal) {} + fn PassOptionalNullableBooleanWithDefault(&self, _: Option) {} + fn PassOptionalNullableByteWithDefault(&self, _: Option) {} + fn PassOptionalNullableOctetWithDefault(&self, _: Option) {} + fn PassOptionalNullableShortWithDefault(&self, _: Option) {} + fn PassOptionalNullableUnsignedShortWithDefault(&self, _: Option) {} + fn PassOptionalNullableLongWithDefault(&self, _: Option) {} + fn PassOptionalNullableUnsignedLongWithDefault(&self, _: Option) {} + fn PassOptionalNullableLongLongWithDefault(&self, _: Option) {} + fn PassOptionalNullableUnsignedLongLongWithDefault(&self, _: Option) {} + fn PassOptionalNullableFloatWithDefault(&self, _: Option) {} + fn PassOptionalNullableDoubleWithDefault(&self, _: Option) {} + fn PassOptionalNullableStringWithDefault(&self, _: Option) {} + fn PassOptionalNullableByteStringWithDefault(&self, _: Option) {} + // fn PassOptionalNullableEnumWithDefault(&self, _: Option) {} + fn PassOptionalNullableInterfaceWithDefault(&self, _: Option>) {} + fn PassOptionalNullableUnionWithDefault(&self, _: Option) {} + fn PassOptionalAnyWithDefault(&self, _: *JSContext, _: JSVal) {} - pub fn PassOptionalNullableBooleanWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableByteWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableOctetWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableShortWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableUnsignedShortWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableLongWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableUnsignedLongWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableLongLongWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableUnsignedLongLongWithNonNullDefault(&self, _: Option) {} - // pub fn PassOptionalNullableFloatWithNonNullDefault(&self, _: Option) {} - // pub fn PassOptionalNullableDoubleWithNonNullDefault(&self, _: Option) {} - pub fn PassOptionalNullableStringWithNonNullDefault(&self, _: Option) {} - // pub fn PassOptionalNullableEnumWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableBooleanWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableByteWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableOctetWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableShortWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableUnsignedShortWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableLongWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableUnsignedLongWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableLongLongWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableUnsignedLongLongWithNonNullDefault(&self, _: Option) {} + // fn PassOptionalNullableFloatWithNonNullDefault(&self, _: Option) {} + // fn PassOptionalNullableDoubleWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableStringWithNonNullDefault(&self, _: Option) {} + // fn PassOptionalNullableEnumWithNonNullDefault(&self, _: Option) {} } impl Reflectable for TestBinding { diff --git a/src/components/script/dom/text.rs b/src/components/script/dom/text.rs index cdcfdac6af3..570c1412833 100644 --- a/src/components/script/dom/text.rs +++ b/src/components/script/dom/text.rs @@ -10,7 +10,7 @@ use dom::characterdata::CharacterData; use dom::document::Document; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::node::{Node, TextNodeTypeId}; -use dom::window::Window; +use dom::window::{Window, WindowMethods}; use servo_util::str::DOMString; /// An HTML text node. @@ -42,16 +42,23 @@ impl Text { pub fn Constructor(owner: &JSRef, text: DOMString) -> Fallible> { let roots = RootCollection::new(); - let document = owner.get().Document(); - let document = document.root(&roots); - Ok(Text::new(text.clone(), &document.root_ref())) + let document = owner.Document().root(&roots); + Ok(Text::new(text.clone(), &*document)) } +} - pub fn SplitText(&self, _offset: u32) -> Fallible> { +pub trait TextMethods { + fn SplitText(&self, _offset: u32) -> Fallible>; + fn GetWholeText(&self) -> Fallible; +} + +impl<'a> TextMethods for JSRef<'a, Text> { + fn SplitText(&self, _offset: u32) -> Fallible> { fail!("unimplemented") } - pub fn GetWholeText(&self) -> Fallible { + fn GetWholeText(&self) -> Fallible { Ok(~"") } } + diff --git a/src/components/script/dom/uievent.rs b/src/components/script/dom/uievent.rs index f42edeb42bf..cb1365181e5 100644 --- a/src/components/script/dom/uievent.rs +++ b/src/components/script/dom/uievent.rs @@ -3,11 +3,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::BindingDeclarations::UIEventBinding; -use dom::bindings::codegen::InheritTypes::UIEventDerived; +use dom::bindings::codegen::InheritTypes::{EventCast, UIEventDerived}; use dom::bindings::js::{JS, JSRef, RootCollection, RootedReference, Unrooted}; use dom::bindings::error::Fallible; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; -use dom::event::{Event, EventTypeId, UIEventTypeId}; +use dom::event::{Event, EventMethods, EventTypeId, UIEventTypeId}; use dom::node::Node; use dom::window::Window; use servo_util::str::DOMString; @@ -48,80 +48,107 @@ impl UIEvent { let roots = RootCollection::new(); let mut ev = UIEvent::new(owner).root(&roots); let view = init.view.as_ref().map(|view| view.root(&roots)); - ev.get_mut().InitUIEvent(type_, init.parent.bubbles, init.parent.cancelable, - view.root_ref(), init.detail); + ev.InitUIEvent(type_, init.parent.bubbles, init.parent.cancelable, + view.root_ref(), init.detail); Ok(Unrooted::new_rooted(&*ev)) } +} - pub fn GetView(&self) -> Option> { +pub trait UIEventMethods { + fn GetView(&self) -> Option>; + fn Detail(&self) -> i32; + fn LayerX(&self) -> i32; + fn LayerY(&self) -> i32; + fn PageX(&self) -> i32; + fn PageY(&self) -> i32; + fn Which(&self) -> u32; + fn GetRangeParent(&self) -> Option>; + fn RangeOffset(&self) -> i32; + fn CancelBubble(&self) -> bool; + fn SetCancelBubble(&mut self, _val: bool); + fn IsChar(&self) -> bool; + fn InitUIEvent(&mut self, + type_: DOMString, + can_bubble: bool, + cancelable: bool, + view: Option>, + detail: i32); +} + +impl<'a> UIEventMethods for JSRef<'a, UIEvent> { + fn GetView(&self) -> Option> { self.view.clone().map(|view| Unrooted::new(view)) } - pub fn Detail(&self) -> i32 { + fn Detail(&self) -> i32 { self.detail } - pub fn InitUIEvent(&mut self, - type_: DOMString, - can_bubble: bool, - cancelable: bool, - view: Option>, - detail: i32) { - self.event.InitEvent(type_, can_bubble, cancelable); + fn InitUIEvent(&mut self, + type_: DOMString, + can_bubble: bool, + cancelable: bool, + view: Option>, + detail: i32) { + { + let event: &mut JSRef = EventCast::from_mut_ref(self); + event.InitEvent(type_, can_bubble, cancelable); + } self.view = view.map(|view| view.unrooted()); self.detail = detail; } - pub fn LayerX(&self) -> i32 { + fn LayerX(&self) -> i32 { //TODO 0 } - pub fn LayerY(&self) -> i32 { + fn LayerY(&self) -> i32 { //TODO 0 } - pub fn PageX(&self) -> i32 { + fn PageX(&self) -> i32 { //TODO 0 } - pub fn PageY(&self) -> i32 { + fn PageY(&self) -> i32 { //TODO 0 } - pub fn Which(&self) -> u32 { + fn Which(&self) -> u32 { //TODO 0 } - pub fn GetRangeParent(&self) -> Option> { + fn GetRangeParent(&self) -> Option> { //TODO None } - pub fn RangeOffset(&self) -> i32 { + fn RangeOffset(&self) -> i32 { //TODO 0 } - pub fn CancelBubble(&self) -> bool { + fn CancelBubble(&self) -> bool { //TODO false } - pub fn SetCancelBubble(&mut self, _val: bool) { + fn SetCancelBubble(&mut self, _val: bool) { //TODO } - pub fn IsChar(&self) -> bool { + fn IsChar(&self) -> bool { //TODO false } } + impl Reflectable for UIEvent { fn reflector<'a>(&'a self) -> &'a Reflector { self.event.reflector() diff --git a/src/components/script/dom/validitystate.rs b/src/components/script/dom/validitystate.rs index 02b0b9a7a11..d4d829f842b 100644 --- a/src/components/script/dom/validitystate.rs +++ b/src/components/script/dom/validitystate.rs @@ -30,44 +30,57 @@ impl ValidityState { } } -impl ValidityState { - pub fn ValueMissing(&self) -> bool { +pub trait ValidityStateMethods { + fn ValueMissing(&self) -> bool; + fn TypeMismatch(&self) -> bool; + fn PatternMismatch(&self) -> bool; + fn TooLong(&self) -> bool; + fn RangeUnderflow(&self) -> bool; + fn RangeOverflow(&self) -> bool; + fn StepMismatch(&self) -> bool; + fn CustomError(&self) -> bool; + fn Valid(&self) -> bool; +} + +impl<'a> ValidityStateMethods for JSRef<'a, ValidityState> { + fn ValueMissing(&self) -> bool { false } - pub fn TypeMismatch(&self) -> bool { + fn TypeMismatch(&self) -> bool { false } - pub fn PatternMismatch(&self) -> bool { + fn PatternMismatch(&self) -> bool { false } - pub fn TooLong(&self) -> bool { + fn TooLong(&self) -> bool { false } - pub fn RangeUnderflow(&self) -> bool { + fn RangeUnderflow(&self) -> bool { false } - pub fn RangeOverflow(&self) -> bool { + fn RangeOverflow(&self) -> bool { false } - pub fn StepMismatch(&self) -> bool { + fn StepMismatch(&self) -> bool { false } - pub fn CustomError(&self) -> bool { + fn CustomError(&self) -> bool { false } - pub fn Valid(&self) -> bool { + fn Valid(&self) -> bool { true } } + impl Reflectable for ValidityState { fn reflector<'a>(&'a self) -> &'a Reflector { &self.reflector_ diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs index ff46c27ed79..dda1a0fa295 100644 --- a/src/components/script/dom/window.rs +++ b/src/components/script/dom/window.rs @@ -105,88 +105,146 @@ pub struct TimerData { pub funval: Traceable, } -impl Window { - pub fn Alert(&self, s: DOMString) { +pub trait WindowMethods { + fn Alert(&self, s: DOMString); + fn Close(&self); + fn Document(&self) -> Unrooted; + fn Name(&self) -> DOMString; + fn SetName(&self, _name: DOMString); + fn Status(&self) -> DOMString; + fn SetStatus(&self, _status: DOMString); + fn Closed(&self) -> bool; + fn Stop(&self); + fn Focus(&self); + fn Blur(&self); + fn GetFrameElement(&self) -> Option>; + fn Location(&mut self, abstract_self: &JSRef) -> Unrooted; + fn Console(&mut self, abstract_self: &JSRef) -> Unrooted; + fn Navigator(&mut self, abstract_self: &JSRef) -> Unrooted; + fn Confirm(&self, _message: DOMString) -> bool; + fn Prompt(&self, _message: DOMString, _default: DOMString) -> Option; + fn Print(&self); + fn ShowModalDialog(&self, _cx: *JSContext, _url: DOMString, _argument: Option) -> JSVal; + fn SetTimeout(&mut self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32; + fn ClearTimeout(&mut self, handle: i32); + fn SetInterval(&mut self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32; + fn ClearInterval(&mut self, handle: i32); + fn Window(&self, abstract_self: &JSRef) -> Unrooted; + fn Self(&self, abstract_self: &JSRef) -> Unrooted; +} + +impl<'a> WindowMethods for JSRef<'a, Window> { + fn Alert(&self, s: DOMString) { // Right now, just print to the console println!("ALERT: {:s}", s); } - pub fn Close(&self) { + fn Close(&self) { let ScriptChan(ref chan) = self.script_chan; chan.send(ExitWindowMsg(self.page.id.clone())); } - pub fn Document(&self) -> Unrooted { + fn Document(&self) -> Unrooted { let frame = self.page().frame(); Unrooted::new(frame.get_ref().document.clone()) } - pub fn Name(&self) -> DOMString { + fn Name(&self) -> DOMString { ~"" } - pub fn SetName(&self, _name: DOMString) { + fn SetName(&self, _name: DOMString) { } - pub fn Status(&self) -> DOMString { + fn Status(&self) -> DOMString { ~"" } - pub fn SetStatus(&self, _status: DOMString) { + fn SetStatus(&self, _status: DOMString) { } - pub fn Closed(&self) -> bool { + fn Closed(&self) -> bool { false } - pub fn Stop(&self) { + fn Stop(&self) { } - pub fn Focus(&self) { + fn Focus(&self) { } - pub fn Blur(&self) { + fn Blur(&self) { } - pub fn GetFrameElement(&self) -> Option> { + fn GetFrameElement(&self) -> Option> { None } - pub fn Location(&mut self, abstract_self: &JSRef) -> Unrooted { + fn Location(&mut self, abstract_self: &JSRef) -> Unrooted { if self.location.is_none() { - self.location.assign(Some(Location::new(abstract_self, self.page.clone()))); + let page = self.deref().page.clone(); + self.location.assign(Some(Location::new(abstract_self, page))); } Unrooted::new(self.location.get_ref().clone()) } - pub fn Console(&mut self, abstract_self: &JSRef) -> Unrooted { + fn Console(&mut self, abstract_self: &JSRef) -> Unrooted { if self.console.is_none() { self.console.assign(Some(Console::new(abstract_self))); } Unrooted::new(self.console.get_ref().clone()) } - pub fn Navigator(&mut self, abstract_self: &JSRef) -> Unrooted { + fn Navigator(&mut self, abstract_self: &JSRef) -> Unrooted { if self.navigator.is_none() { self.navigator.assign(Some(Navigator::new(abstract_self))); } Unrooted::new(self.navigator.get_ref().clone()) } - pub fn Confirm(&self, _message: DOMString) -> bool { + fn Confirm(&self, _message: DOMString) -> bool { false } - pub fn Prompt(&self, _message: DOMString, _default: DOMString) -> Option { + fn Prompt(&self, _message: DOMString, _default: DOMString) -> Option { None } - pub fn Print(&self) { + fn Print(&self) { } - pub fn ShowModalDialog(&self, _cx: *JSContext, _url: DOMString, _argument: Option) -> JSVal { + fn ShowModalDialog(&self, _cx: *JSContext, _url: DOMString, _argument: Option) -> JSVal { NullValue() } + + fn SetTimeout(&mut self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32 { + self.set_timeout_or_interval(callback, timeout, false) + } + + fn ClearTimeout(&mut self, handle: i32) { + let mut timer_handle = self.active_timers.pop(&TimerId(handle)); + match timer_handle { + Some(ref mut handle) => handle.cancel(), + None => { } + } + self.active_timers.remove(&TimerId(handle)); + } + + fn SetInterval(&mut self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32 { + self.set_timeout_or_interval(callback, timeout, true) + } + + fn ClearInterval(&mut self, handle: i32) { + self.ClearTimeout(handle); + } + + fn Window(&self, abstract_self: &JSRef) -> Unrooted { + Unrooted::new_rooted(abstract_self) + } + + fn Self(&self, abstract_self: &JSRef) -> Unrooted { + self.Window(abstract_self) + } } impl Reflectable for Window { @@ -258,35 +316,6 @@ impl Window { handle } - pub fn SetTimeout(&mut self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32 { - self.set_timeout_or_interval(callback, timeout, false) - } - - pub fn ClearTimeout(&mut self, handle: i32) { - let mut timer_handle = self.active_timers.pop(&TimerId(handle)); - match timer_handle { - Some(ref mut handle) => handle.cancel(), - None => { } - } - self.active_timers.remove(&TimerId(handle)); - } - - pub fn SetInterval(&mut self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32 { - self.set_timeout_or_interval(callback, timeout, true) - } - - pub fn ClearInterval(&mut self, handle: i32) { - self.ClearTimeout(handle); - } - - pub fn Window(&self, abstract_self: &JSRef) -> Unrooted { - Unrooted::new_rooted(abstract_self) - } - - pub fn Self(&self, abstract_self: &JSRef) -> Unrooted { - self.Window(abstract_self) - } - pub fn damage_and_reflow(&self, damage: DocumentDamageLevel) { // FIXME This should probably be ReflowForQuery, not Display. All queries currently // currently rely on the display list, which means we can't destroy it by diff --git a/src/components/script/dom/xmlhttprequest.rs b/src/components/script/dom/xmlhttprequest.rs index 8327135d566..a0ffa15c772 100644 --- a/src/components/script/dom/xmlhttprequest.rs +++ b/src/components/script/dom/xmlhttprequest.rs @@ -66,71 +66,100 @@ impl XMLHttpRequest { pub fn Constructor(owner: &JSRef) -> Fallible> { Ok(XMLHttpRequest::new(owner)) } - pub fn ReadyState(&self) -> u16 { +} + +pub trait XMLHttpRequestMethods { + fn ReadyState(&self) -> u16; + fn Open(&self, _method: ByteString, _url: DOMString); + fn Open_(&self, _method: ByteString, _url: DOMString, _async: bool, + _username: Option, _password: Option); + fn SetRequestHeader(&self, _name: ByteString, _value: ByteString); + fn Timeout(&self) -> u32; + fn SetTimeout(&mut self, timeout: u32); + fn WithCredentials(&self) -> bool; + fn SetWithCredentials(&mut self, with_credentials: bool); + fn Upload(&self) -> Unrooted; + fn Send(&self, _data: Option); + fn Abort(&self); + fn ResponseURL(&self) -> DOMString; + fn Status(&self) -> u16; + fn StatusText(&self) -> ByteString; + fn GetResponseHeader(&self, _name: ByteString) -> Option; + fn GetAllResponseHeaders(&self) -> ByteString; + fn OverrideMimeType(&self, _mime: DOMString); + fn ResponseType(&self) -> XMLHttpRequestResponseType; + fn SetResponseType(&mut self, response_type: XMLHttpRequestResponseType); + fn Response(&self, _cx: *JSContext) -> JSVal; + fn ResponseText(&self) -> DOMString; + fn GetResponseXML(&self) -> Option>; +} + +impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { + fn ReadyState(&self) -> u16 { self.ready_state } - pub fn Open(&self, _method: ByteString, _url: DOMString) { + fn Open(&self, _method: ByteString, _url: DOMString) { } - pub fn Open_(&self, _method: ByteString, _url: DOMString, _async: bool, + fn Open_(&self, _method: ByteString, _url: DOMString, _async: bool, _username: Option, _password: Option) { } - pub fn SetRequestHeader(&self, _name: ByteString, _value: ByteString) { + fn SetRequestHeader(&self, _name: ByteString, _value: ByteString) { } - pub fn Timeout(&self) -> u32 { + fn Timeout(&self) -> u32 { self.timeout } - pub fn SetTimeout(&mut self, timeout: u32) { + fn SetTimeout(&mut self, timeout: u32) { self.timeout = timeout } - pub fn WithCredentials(&self) -> bool { + fn WithCredentials(&self) -> bool { self.with_credentials } - pub fn SetWithCredentials(&mut self, with_credentials: bool) { + fn SetWithCredentials(&mut self, with_credentials: bool) { self.with_credentials = with_credentials } - pub fn Upload(&self) -> Unrooted { + fn Upload(&self) -> Unrooted { Unrooted::new(self.upload.get_ref().clone()) } - pub fn Send(&self, _data: Option) { + fn Send(&self, _data: Option) { } - pub fn Abort(&self) { + fn Abort(&self) { } - pub fn ResponseURL(&self) -> DOMString { + fn ResponseURL(&self) -> DOMString { self.response_url.clone() } - pub fn Status(&self) -> u16 { + fn Status(&self) -> u16 { self.status } - pub fn StatusText(&self) -> ByteString { + fn StatusText(&self) -> ByteString { self.status_text.clone() } - pub fn GetResponseHeader(&self, _name: ByteString) -> Option { + fn GetResponseHeader(&self, _name: ByteString) -> Option { None } - pub fn GetAllResponseHeaders(&self) -> ByteString { + fn GetAllResponseHeaders(&self) -> ByteString { ByteString::new(vec!()) } - pub fn OverrideMimeType(&self, _mime: DOMString) { + fn OverrideMimeType(&self, _mime: DOMString) { } - pub fn ResponseType(&self) -> XMLHttpRequestResponseType { + fn ResponseType(&self) -> XMLHttpRequestResponseType { self.response_type } - pub fn SetResponseType(&mut self, response_type: XMLHttpRequestResponseType) { + fn SetResponseType(&mut self, response_type: XMLHttpRequestResponseType) { self.response_type = response_type } - pub fn Response(&self, _cx: *JSContext) -> JSVal { + fn Response(&self, _cx: *JSContext) -> JSVal { NullValue() } - pub fn ResponseText(&self) -> DOMString { + fn ResponseText(&self) -> DOMString { self.response_text.clone() } - pub fn GetResponseXML(&self) -> Option> { + fn GetResponseXML(&self) -> Option> { self.response_xml.clone().map(|response| Unrooted::new(response)) } } diff --git a/src/components/script/dom/xmlhttprequesteventtarget.rs b/src/components/script/dom/xmlhttprequesteventtarget.rs index 55708581a1d..68d67fab89b 100644 --- a/src/components/script/dom/xmlhttprequesteventtarget.rs +++ b/src/components/script/dom/xmlhttprequesteventtarget.rs @@ -37,4 +37,7 @@ impl Reflectable for XMLHttpRequestEventTarget { fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector { self.eventtarget.mut_reflector() } +} + +pub trait XMLHttpRequestEventTargetMethods { } \ No newline at end of file diff --git a/src/components/script/dom/xmlhttprequestupload.rs b/src/components/script/dom/xmlhttprequestupload.rs index 8e251dd4e8f..c2332d84ee0 100644 --- a/src/components/script/dom/xmlhttprequestupload.rs +++ b/src/components/script/dom/xmlhttprequestupload.rs @@ -45,4 +45,7 @@ impl XMLHttpRequestUploadDerived for EventTarget { _ => false } } +} + +pub trait XMLHttpRequestUploadMethods { } \ No newline at end of file diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index a90a696063c..0121b023783 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -2,6 +2,7 @@ * 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::attr::AttrMethods; use dom::bindings::codegen::InheritTypes::{NodeBase, NodeCast, TextCast, ElementCast}; use dom::bindings::codegen::InheritTypes::HTMLIFrameElementCast; use dom::bindings::js::{JS, JSRef, RootCollection, Unrooted, OptionalRootable}; @@ -476,7 +477,7 @@ pub fn parse_html(page: &Page, let script: &JSRef = &*from_hubbub_node(script, None).root(&roots); match script.get_attribute(Null, "src").root(&roots) { Some(src) => { - debug!("found script: {:s}", src.get().Value()); + debug!("found script: {:s}", src.deref().Value()); let new_url = parse_url(src.get().value_ref(), Some(url3.clone())); js_chan2.send(JSTaskNewFile(new_url)); } diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index 36fc83b1aee..df7e6f2b994 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -5,17 +5,18 @@ //! The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing //! and layout tasks. +use dom::attr::AttrMethods; use dom::bindings::codegen::RegisterBindings; use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, ElementCast, EventCast}; use dom::bindings::js::{JS, JSRef, RootCollection, Unrooted, OptionalAssignable}; use dom::bindings::js::OptionalRootable; use dom::bindings::trace::{Traceable, Untraceable}; use dom::bindings::utils::{Reflectable, GlobalStaticData, wrap_for_same_compartment}; -use dom::document::{Document, HTMLDocument}; +use dom::document::{Document, HTMLDocument, DocumentMethods}; use dom::element::{Element, AttributeHandlers}; use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent}; -use dom::event::Event; -use dom::uievent::UIEvent; +use dom::event::{Event, EventMethods}; +use dom::uievent::{UIEvent, UIEventMethods}; use dom::eventtarget::EventTarget; use dom::node; use dom::node::{Node, NodeHelpers}; @@ -409,7 +410,7 @@ impl Page { fn find_fragment_node(&self, fragid: ~str) -> Option> { let roots = RootCollection::new(); let document = self.frame().get_ref().document.root(&roots); - match document.get().GetElementById(fragid.to_owned()) { + match document.deref().GetElementById(fragid.to_owned()) { Some(node) => Some(node), None => { let doc_node: &JSRef = NodeCast::from_ref(&*document); @@ -445,7 +446,7 @@ impl Page { let roots = RootCollection::new(); let frame = self.frame(); let document = frame.get_ref().document.root(&roots); - let root = document.get().GetDocumentElement().root(&roots); + let root = document.deref().GetDocumentElement().root(&roots); if root.is_none() { return None; } @@ -468,7 +469,7 @@ impl Page { let roots = RootCollection::new(); let frame = self.frame(); let document = frame.get_ref().document.root(&roots); - let root = document.get().GetDocumentElement().root(&roots); + let root = document.deref().GetDocumentElement().root(&roots); if root.is_none() { return None; } @@ -985,7 +986,7 @@ impl ScriptTask { // "load" event as soon as we've finished executing all scripts parsed during // the initial load. let mut event = Event::new(&*window).root(&roots); - event.get_mut().InitEvent(~"load", false, false); + event.InitEvent(~"load", false, false); let doctarget: &JSRef = EventTargetCast::from_ref(&*document); let wintarget: &mut JSRef = EventTargetCast::from_mut_ref(&mut *window); let wintarget_alias = wintarget.clone(); @@ -1055,8 +1056,8 @@ impl ScriptTask { // http://dev.w3.org/csswg/cssom-view/#resizing-viewports // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize let mut uievent = UIEvent::new(&*window).root(&roots); - uievent.get_mut().InitUIEvent(~"resize", false, false, - Some((*window).clone()), 0i32); + uievent.InitUIEvent(~"resize", false, false, + Some((*window).clone()), 0i32); let event: &mut JSRef = EventCast::from_mut_ref(&mut *uievent); let wintarget: &mut JSRef = EventTargetCast::from_mut_ref(&mut *window); @@ -1194,7 +1195,7 @@ impl ScriptTask { // if the node's element is "a," load url from href attr let attr = element.get_attribute(Null, "href"); for href in attr.root(&roots).iter() { - debug!("ScriptTask: clicked on link to {:s}", href.get().Value()); + debug!("ScriptTask: clicked on link to {:s}", href.Value()); let click_frag = href.get().value_ref().starts_with("#"); let base_url = Some(page.get_url()); debug!("ScriptTask: current url is {:?}", base_url);