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/htmlanchorelement.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/htmlanchorelement.rs')
-rw-r--r-- | src/components/script/dom/htmlanchorelement.rs | 91 |
1 files changed, 60 insertions, 31 deletions
diff --git a/src/components/script/dom/htmlanchorelement.rs b/src/components/script/dom/htmlanchorelement.rs index c773e8b55b1..6b90e96053a 100644 --- a/src/components/script/dom/htmlanchorelement.rs +++ b/src/components/script/dom/htmlanchorelement.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::BindingDeclarations::HTMLAnchorElementBinding; use dom::bindings::codegen::InheritTypes::HTMLAnchorElementDerived; -use dom::bindings::js::JS; +use dom::bindings::js::{JSRef, Temporary}; use dom::bindings::error::ErrorResult; use dom::document::Document; use dom::element::HTMLAnchorElementTypeId; @@ -28,120 +28,149 @@ impl HTMLAnchorElementDerived for EventTarget { } impl HTMLAnchorElement { - pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLAnchorElement { + pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAnchorElement { HTMLAnchorElement { htmlelement: HTMLElement::new_inherited(HTMLAnchorElementTypeId, localName, document) } } - pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLAnchorElement> { - let element = HTMLAnchorElement::new_inherited(localName, document.clone()); + pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAnchorElement> { + let element = HTMLAnchorElement::new_inherited(localName, document); Node::reflect_node(~element, document, HTMLAnchorElementBinding::Wrap) } } -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(()) } } |