diff options
-rw-r--r-- | components/layout/layout_task.rs | 4 | ||||
-rw-r--r-- | components/layout/util.rs | 4 | ||||
-rw-r--r-- | components/script/dom/bindings/js.rs | 10 |
3 files changed, 14 insertions, 4 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index b9bdc48a3ea..285e3889bf3 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -32,7 +32,7 @@ use gfx::paint_task::{PaintChan, PaintLayer}; use gfx::paint_task::Msg as PaintMsg; use layout_traits::{LayoutControlMsg, LayoutTaskFactory}; use log; -use script::dom::bindings::js::{JS, LayoutJS}; +use script::dom::bindings::js::LayoutJS; use script::dom::node::{LayoutDataRef, Node, NodeTypeId}; use script::dom::element::ElementTypeId; use script::dom::htmlelement::HTMLElementTypeId; @@ -720,7 +720,7 @@ impl LayoutTask { // FIXME(rust#16366): The following line had to be moved because of a // rustc bug. It should be in the next unsafe block. let mut node: LayoutJS<Node> = unsafe { - JS::from_trusted_node_address(data.document_root).to_layout() + LayoutJS::from_trusted_node_address(data.document_root) }; let node: &mut LayoutNode = unsafe { mem::transmute(&mut node) diff --git a/components/layout/util.rs b/components/layout/util.rs index 984c2c44657..f7692fc3cda 100644 --- a/components/layout/util.rs +++ b/components/layout/util.rs @@ -10,7 +10,7 @@ use wrapper::{LayoutNode, TLayoutNode, ThreadSafeLayoutNode}; use gfx::display_list::OpaqueNode; use gfx; use libc::uintptr_t; -use script::dom::bindings::js::{JS, LayoutJS}; +use script::dom::bindings::js::LayoutJS; use script::dom::bindings::utils::Reflectable; use script::dom::node::{Node, SharedLayoutData}; use script::layout_interface::{LayoutChan, TrustedNodeAddress}; @@ -150,7 +150,7 @@ impl OpaqueNodeMethods for OpaqueNode { fn from_script_node(node: TrustedNodeAddress) -> OpaqueNode { unsafe { - OpaqueNodeMethods::from_jsmanaged(&JS::from_trusted_node_address(node).to_layout()) + OpaqueNodeMethods::from_jsmanaged(&LayoutJS::from_trusted_node_address(node)) } } diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index 2e229a28df3..3b74bd65194 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -191,6 +191,16 @@ impl JS<Node> { } } +impl LayoutJS<Node> { + /// Create a new JS-owned value wrapped from an address known to be a `Node` pointer. + pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutJS<Node> { + let TrustedNodeAddress(addr) = inner; + LayoutJS { + ptr: NonZero::new(addr as *const Node) + } + } +} + impl<T: Reflectable> JS<T> { /// Create a new JS-owned value wrapped from a raw Rust pointer. pub unsafe fn from_raw(raw: *const T) -> JS<T> { |