aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/htmlvideoelement.rs
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2014-05-03 14:25:22 -0400
committerbors-servo <release+servo@mozilla.com>2014-05-03 14:25:22 -0400
commit731e66ff132e41cdc49bc5324c0e15be19c46ec2 (patch)
treeccce9b42e8a6c54245e53620082efe0b9840eae1 /src/components/script/dom/htmlvideoelement.rs
parent4051a8096d7ba7e7f9c86e76d0b4bffd83e85805 (diff)
parent91278da9dd55582401154e07f9eea34425a332c2 (diff)
downloadservo-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/htmlvideoelement.rs')
-rw-r--r--src/components/script/dom/htmlvideoelement.rs37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/components/script/dom/htmlvideoelement.rs b/src/components/script/dom/htmlvideoelement.rs
index 4ef1d9c57a3..eaa4e98eb06 100644
--- a/src/components/script/dom/htmlvideoelement.rs
+++ b/src/components/script/dom/htmlvideoelement.rs
@@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLVideoElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLVideoElementDerived;
-use dom::bindings::js::JS;
+use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult;
use dom::document::Document;
use dom::element::HTMLVideoElementTypeId;
@@ -28,48 +28,59 @@ impl HTMLVideoElementDerived for EventTarget {
}
impl HTMLVideoElement {
- pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLVideoElement {
+ pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLVideoElement {
HTMLVideoElement {
htmlmediaelement: HTMLMediaElement::new_inherited(HTMLVideoElementTypeId, localName, document)
}
}
- pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLVideoElement> {
- let element = HTMLVideoElement::new_inherited(localName, document.clone());
+ pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLVideoElement> {
+ let element = HTMLVideoElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLVideoElementBinding::Wrap)
}
}
-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(())
}
}