aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2014-05-26 14:46:31 +0900
committerTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2014-05-30 03:38:40 +0900
commitda703d6a808346a59ec4ca82c27209b4170a95c8 (patch)
treeab91322feab6ef2ff04b2b52d055514611c0d1d3
parent3e558fdcb1667c162d8f27194696415dcb7eae1f (diff)
downloadservo-da703d6a808346a59ec4ca82c27209b4170a95c8.tar.gz
servo-da703d6a808346a59ec4ca82c27209b4170a95c8.zip
JS<T> contains '*T' instead of RefCell.
-rw-r--r--src/components/main/layout/wrapper.rs8
-rw-r--r--src/components/script/dom/bindings/js.rs15
2 files changed, 15 insertions, 8 deletions
diff --git a/src/components/main/layout/wrapper.rs b/src/components/main/layout/wrapper.rs
index f2d8f094f8d..6cc4037b13e 100644
--- a/src/components/main/layout/wrapper.rs
+++ b/src/components/main/layout/wrapper.rs
@@ -136,6 +136,10 @@ pub struct LayoutNode<'a> {
/// Being chained to a ContravariantLifetime prevents `LayoutNode`s from escaping.
pub chain: ContravariantLifetime<'a>,
+
+ /// Padding to ensure the transmute `JS<T>` -> `LayoutNode`, `LayoutNode` -> `UnsafeLayoutNode`,
+ /// and `UnsafeLayoutNode` -> others.
+ pad: uint
}
impl<'ln> Clone for LayoutNode<'ln> {
@@ -143,6 +147,7 @@ impl<'ln> Clone for LayoutNode<'ln> {
LayoutNode {
node: self.node.clone(),
chain: self.chain,
+ pad: 0,
}
}
}
@@ -160,6 +165,7 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
LayoutNode {
node: node.transmute_copy(),
chain: self.chain,
+ pad: 0,
}
}
@@ -196,6 +202,7 @@ impl<'ln> LayoutNode<'ln> {
f(LayoutNode {
node: node,
chain: ContravariantLifetime,
+ pad: 0,
})
}
@@ -425,6 +432,7 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
node: LayoutNode {
node: node.transmute_copy(),
chain: self.node.chain,
+ pad: 0,
},
pseudo: Normal,
}
diff --git a/src/components/script/dom/bindings/js.rs b/src/components/script/dom/bindings/js.rs
index 44178cb93c3..b5a83b01e7c 100644
--- a/src/components/script/dom/bindings/js.rs
+++ b/src/components/script/dom/bindings/js.rs
@@ -111,7 +111,7 @@ impl<T: Reflectable> Temporary<T> {
/// A rooted, JS-owned value. Must only be used as a field in other JS-owned types.
pub struct JS<T> {
- ptr: RefCell<*mut T>
+ ptr: *T
}
impl<T> Eq for JS<T> {
@@ -134,7 +134,7 @@ impl JS<Node> {
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> JS<Node> {
let TrustedNodeAddress(addr) = inner;
JS {
- ptr: RefCell::new(addr as *mut Node)
+ ptr: addr as *Node
}
}
}
@@ -143,7 +143,7 @@ impl JS<XMLHttpRequest> {
pub unsafe fn from_trusted_xhr_address(inner: TrustedXHRAddress) -> JS<XMLHttpRequest> {
let TrustedXHRAddress(addr) = inner;
JS {
- ptr: RefCell::new(addr as *mut XMLHttpRequest)
+ ptr: addr as *XMLHttpRequest
}
}
}
@@ -152,7 +152,7 @@ impl<T: Reflectable> JS<T> {
/// Create a new JS-owned value wrapped from a raw Rust pointer.
pub unsafe fn from_raw(raw: *mut T) -> JS<T> {
JS {
- ptr: RefCell::new(raw)
+ ptr: raw as *T
}
}
@@ -404,14 +404,13 @@ impl<'a, 'b, T: Reflectable> Root<'a, 'b, T> {
/// It cannot not outlive its associated RootCollection, and it contains a JSRef
/// which cannot outlive this new Root.
fn new(roots: &'a RootCollection, unrooted: &JS<T>) -> Root<'a, 'b, T> {
- let ptr: *T = unrooted.ptr.borrow().clone() as *T;
let root = Root {
root_list: roots,
jsref: JSRef {
- ptr: ptr,
+ ptr: unrooted.ptr.clone(),
chain: ContravariantLifetime,
},
- ptr: ptr,
+ ptr: unrooted.ptr.clone(),
js_ptr: unrooted.reflector().get_jsobject(),
};
roots.root(&root);
@@ -494,7 +493,7 @@ impl<'a,T> JSRef<'a,T> {
pub fn unrooted(&self) -> JS<T> {
JS {
- ptr: RefCell::new(self.ptr as *mut T)
+ ptr: self.ptr
}
}
}