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/htmlbodyelement.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/htmlbodyelement.rs')
-rw-r--r-- | src/components/script/dom/htmlbodyelement.rs | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/src/components/script/dom/htmlbodyelement.rs b/src/components/script/dom/htmlbodyelement.rs index 6e7e0349e40..4c28b446524 100644 --- a/src/components/script/dom/htmlbodyelement.rs +++ b/src/components/script/dom/htmlbodyelement.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::BindingDeclarations::HTMLBodyElementBinding; use dom::bindings::codegen::InheritTypes::HTMLBodyElementDerived; use dom::bindings::error::ErrorResult; -use dom::bindings::js::JS; +use dom::bindings::js::{JSRef, Temporary}; use dom::document::Document; use dom::element::HTMLBodyElementTypeId; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; @@ -28,64 +28,79 @@ impl HTMLBodyElementDerived for EventTarget { } impl HTMLBodyElement { - pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLBodyElement { + pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBodyElement { HTMLBodyElement { htmlelement: HTMLElement::new_inherited(HTMLBodyElementTypeId, localName, document) } } - pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLBodyElement> { - let element = HTMLBodyElement::new_inherited(localName, document.clone()); + pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLBodyElement> { + let element = HTMLBodyElement::new_inherited(localName, document); Node::reflect_node(~element, document, HTMLBodyElementBinding::Wrap) } } -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(()) } } |