diff options
author | bors-servo <release+servo@mozilla.com> | 2014-05-03 14:25:22 -0400 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2014-05-03 14:25:22 -0400 |
commit | 731e66ff132e41cdc49bc5324c0e15be19c46ec2 (patch) | |
tree | ccce9b42e8a6c54245e53620082efe0b9840eae1 /src/components/script/dom/htmlappletelement.rs | |
parent | 4051a8096d7ba7e7f9c86e76d0b4bffd83e85805 (diff) | |
parent | 91278da9dd55582401154e07f9eea34425a332c2 (diff) | |
download | servo-731e66ff132e41cdc49bc5324c0e15be19c46ec2.tar.gz servo-731e66ff132e41cdc49bc5324c0e15be19c46ec2.zip |
auto merge of #2101 : jdm/servo/newroot_rebase, r=Ms2ger
As described in #1764, this strategy uses the following properties:
* DOM members are `JS<T>` types. These cannot be used with being explicitly rooted, but they are required for compiler-derived trace hooks.
* Methods that take DOM type arguments receive `&[mut] JSRef<T>`. These are rooted value references that are cloneable but cannot escape.
* Methods that return DOM values use `Unrooted<T>`. These are values that may or may not be rooted elsewhere, but callers must root them in order to interact with them in any way. One unsoundness hole exists - `Unrooted` values must be rooted ASAP, or there exists the danger that JSAPI calls could be made that could cause the underlying JS value to be GCed.
* All methods are implemented on `JSRef<T>`, enforcing the requirement that all DOM values are rooted for the duration of a method call (with a few exceptions for layout-related code, which cannot root values and therefore interacts with `JS<T>` and `&T` values - this is safe under the assumption that layout code interacts with DOM nodes that are in the tree, therefore rooted, and does not run concurrently with content code)
Diffstat (limited to 'src/components/script/dom/htmlappletelement.rs')
-rw-r--r-- | src/components/script/dom/htmlappletelement.rs | 79 |
1 files changed, 52 insertions, 27 deletions
diff --git a/src/components/script/dom/htmlappletelement.rs b/src/components/script/dom/htmlappletelement.rs index a6b4de0e21f..385750d0a16 100644 --- a/src/components/script/dom/htmlappletelement.rs +++ b/src/components/script/dom/htmlappletelement.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::BindingDeclarations::HTMLAppletElementBinding; use dom::bindings::codegen::InheritTypes::HTMLAppletElementDerived; -use dom::bindings::js::JS; +use dom::bindings::js::{JSRef, Temporary}; use dom::bindings::error::ErrorResult; use dom::document::Document; use dom::element::HTMLAppletElementTypeId; @@ -28,104 +28,129 @@ impl HTMLAppletElementDerived for EventTarget { } impl HTMLAppletElement { - pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLAppletElement { + pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAppletElement { HTMLAppletElement { htmlelement: HTMLElement::new_inherited(HTMLAppletElementTypeId, localName, document) } } - pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLAppletElement> { - let element = HTMLAppletElement::new_inherited(localName, document.clone()); + pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAppletElement> { + let element = HTMLAppletElement::new_inherited(localName, document); Node::reflect_node(~element, document, HTMLAppletElementBinding::Wrap) } } -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(()) } } |