mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Rename LayoutJS<T> to LayoutDom<T>
This commit is contained in:
parent
c52fd0a780
commit
e2dac78d36
27 changed files with 104 additions and 104 deletions
|
@ -68,10 +68,10 @@ impl<T> HeapSizeOf for Dom<T> {
|
|||
}
|
||||
|
||||
impl<T> Dom<T> {
|
||||
/// Returns `LayoutJS<T>` containing the same pointer.
|
||||
pub unsafe fn to_layout(&self) -> LayoutJS<T> {
|
||||
/// Returns `LayoutDom<T>` containing the same pointer.
|
||||
pub unsafe fn to_layout(&self) -> LayoutDom<T> {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutJS {
|
||||
LayoutDom {
|
||||
ptr: self.ptr.clone(),
|
||||
}
|
||||
}
|
||||
|
@ -124,32 +124,32 @@ unsafe impl<T: DomObject> JSTraceable for Dom<T> {
|
|||
/// An unrooted reference to a DOM object for use in layout. `Layout*Helpers`
|
||||
/// traits must be implemented on this.
|
||||
#[allow_unrooted_interior]
|
||||
pub struct LayoutJS<T> {
|
||||
pub struct LayoutDom<T> {
|
||||
ptr: NonZero<*const T>,
|
||||
}
|
||||
|
||||
impl<T: Castable> LayoutJS<T> {
|
||||
impl<T: Castable> LayoutDom<T> {
|
||||
/// Cast a DOM object root upwards to one of the interfaces it derives from.
|
||||
pub fn upcast<U>(&self) -> LayoutJS<U>
|
||||
pub fn upcast<U>(&self) -> LayoutDom<U>
|
||||
where U: Castable,
|
||||
T: DerivedFrom<U>
|
||||
{
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
let ptr: *const T = self.ptr.get();
|
||||
LayoutJS {
|
||||
LayoutDom {
|
||||
ptr: unsafe { NonZero::new_unchecked(ptr as *const U) },
|
||||
}
|
||||
}
|
||||
|
||||
/// Cast a DOM object downwards to one of the interfaces it might implement.
|
||||
pub fn downcast<U>(&self) -> Option<LayoutJS<U>>
|
||||
pub fn downcast<U>(&self) -> Option<LayoutDom<U>>
|
||||
where U: DerivedFrom<T>
|
||||
{
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
unsafe {
|
||||
if (*self.unsafe_get()).is::<U>() {
|
||||
let ptr: *const T = self.ptr.get();
|
||||
Some(LayoutJS {
|
||||
Some(LayoutDom {
|
||||
ptr: NonZero::new_unchecked(ptr as *const U),
|
||||
})
|
||||
} else {
|
||||
|
@ -159,7 +159,7 @@ impl<T: Castable> LayoutJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> LayoutJS<T> {
|
||||
impl<T: DomObject> LayoutDom<T> {
|
||||
/// Get the reflector.
|
||||
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
|
@ -167,7 +167,7 @@ impl<T: DomObject> LayoutJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Copy for LayoutJS<T> {}
|
||||
impl<T> Copy for LayoutDom<T> {}
|
||||
|
||||
impl<T> PartialEq for Dom<T> {
|
||||
fn eq(&self, other: &Dom<T>) -> bool {
|
||||
|
@ -177,13 +177,13 @@ impl<T> PartialEq for Dom<T> {
|
|||
|
||||
impl<T> Eq for Dom<T> {}
|
||||
|
||||
impl<T> PartialEq for LayoutJS<T> {
|
||||
fn eq(&self, other: &LayoutJS<T>) -> bool {
|
||||
impl<T> PartialEq for LayoutDom<T> {
|
||||
fn eq(&self, other: &LayoutDom<T>) -> bool {
|
||||
self.ptr == other.ptr
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Eq for LayoutJS<T> {}
|
||||
impl<T> Eq for LayoutDom<T> {}
|
||||
|
||||
impl<T> Hash for Dom<T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
|
@ -191,7 +191,7 @@ impl<T> Hash for Dom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Hash for LayoutJS<T> {
|
||||
impl<T> Hash for LayoutDom<T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.ptr.hash(state)
|
||||
}
|
||||
|
@ -208,23 +208,23 @@ impl <T> Clone for Dom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl <T> Clone for LayoutJS<T> {
|
||||
impl <T> Clone for LayoutDom<T> {
|
||||
#[inline]
|
||||
fn clone(&self) -> LayoutJS<T> {
|
||||
fn clone(&self) -> LayoutDom<T> {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutJS {
|
||||
LayoutDom {
|
||||
ptr: self.ptr.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutJS<Node> {
|
||||
impl LayoutDom<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> {
|
||||
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutDom<Node> {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
let TrustedNodeAddress(addr) = inner;
|
||||
LayoutJS {
|
||||
LayoutDom {
|
||||
ptr: NonZero::new_unchecked(addr as *const Node),
|
||||
}
|
||||
}
|
||||
|
@ -327,10 +327,10 @@ impl<T: DomObject> MutNullableDom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Retrieve a copy of the inner optional `Dom<T>` as `LayoutJS<T>`.
|
||||
/// Retrieve a copy of the inner optional `Dom<T>` as `LayoutDom<T>`.
|
||||
/// For use by layout, which can't use safe types like Temporary.
|
||||
#[allow(unrooted_must_root)]
|
||||
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
|
||||
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
ptr::read(self.ptr.get()).map(|js| js.to_layout())
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ unsafe impl<T: DomObject> JSTraceable for OnceCellJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> LayoutJS<T> {
|
||||
impl<T: DomObject> LayoutDom<T> {
|
||||
/// Returns an unsafe pointer to the interior of this JS object. This is
|
||||
/// the only method that be safely accessed from layout. (The fact that
|
||||
/// this is unsafe is what necessitates the layout wrappers.)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue