mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Introduce LayoutJS<Node>::opaque() to replace OpaqueNodeMethods::from_jsmanaged().
This commit is contained in:
parent
14a7e9bce1
commit
7de3d165ad
3 changed files with 12 additions and 17 deletions
|
@ -2,31 +2,17 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use gfx::display_list::OpaqueNode;
|
||||
use libc::{c_void, uintptr_t};
|
||||
use script::layout_interface::LayoutJS;
|
||||
use script::layout_interface::Node;
|
||||
use libc::c_void;
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
|
||||
pub trait OpaqueNodeMethods {
|
||||
/// Converts a DOM node to an `OpaqueNode'.
|
||||
fn from_jsmanaged(node: &LayoutJS<Node>) -> Self;
|
||||
|
||||
/// Converts this node to an `UntrustedNodeAddress`. An `UntrustedNodeAddress` is just the type
|
||||
/// of node that script expects to receive in a hit test.
|
||||
fn to_untrusted_node_address(&self) -> UntrustedNodeAddress;
|
||||
}
|
||||
|
||||
impl OpaqueNodeMethods for OpaqueNode {
|
||||
fn from_jsmanaged(node: &LayoutJS<Node>) -> OpaqueNode {
|
||||
unsafe {
|
||||
let ptr: uintptr_t = node.get_jsobject() as uintptr_t;
|
||||
OpaqueNode(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
fn to_untrusted_node_address(&self) -> UntrustedNodeAddress {
|
||||
UntrustedNodeAddress(self.0 as *const c_void)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue