Replace TLayoutNode by inherent methods.

There is no reason for this trait to exist.
This commit is contained in:
Ms2ger 2015-06-21 17:29:08 +02:00
parent 50d4084e9a
commit 167a396293
3 changed files with 15 additions and 28 deletions

View file

@ -14,7 +14,7 @@ use std::cell::{Ref, RefMut};
use std::mem;
use std::sync::Arc;
use style::properties::ComputedValues;
use wrapper::{LayoutNode, TLayoutNode};
use wrapper::LayoutNode;
/// Data that layout associates with a node.
pub struct PrivateLayoutData {

View file

@ -10,7 +10,7 @@ use script::dom::bindings::js::LayoutJS;
use script::dom::node::Node;
use script::layout_interface::{TrustedNodeAddress};
use script_traits::UntrustedNodeAddress;
use wrapper::{LayoutNode, TLayoutNode, ThreadSafeLayoutNode};
use wrapper::{LayoutNode, ThreadSafeLayoutNode};
pub trait OpaqueNodeMethods {
/// Converts a DOM node (layout view) to an `OpaqueNode`.

View file

@ -75,16 +75,6 @@ use style::node::{TElement, TElementAttributes, TNode};
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
use url::Url;
/// Allows some convenience methods on generic layout nodes.
pub trait TLayoutNode {
/// Creates a new layout node with the same lifetime as this layout node.
unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> Self;
/// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to
/// call and as such is marked `unsafe`.
unsafe fn get_jsmanaged<'a>(&'a self) -> &'a LayoutJS<Node>;
}
/// A wrapper so that layout can access only the methods that it should have access to. Layout must
/// only ever see these and must never see instances of `LayoutJS`.
#[derive(Copy, Clone)]
@ -103,20 +93,15 @@ impl<'a> PartialEq for LayoutNode<'a> {
}
}
impl<'ln> TLayoutNode for LayoutNode<'ln> {
unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> LayoutNode<'ln> {
impl<'ln> LayoutNode<'ln> {
/// Creates a new layout node with the same lifetime as this layout node.
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> LayoutNode<'ln> {
LayoutNode {
node: *node,
chain: self.chain,
}
}
unsafe fn get_jsmanaged<'a>(&'a self) -> &'a LayoutJS<Node> {
&self.node
}
}
impl<'ln> LayoutNode<'ln> {
/// Returns the type ID of this node.
pub fn type_id(&self) -> NodeTypeId {
unsafe {
@ -179,6 +164,8 @@ impl<'ln> LayoutNode<'ln> {
}
/// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to
/// call and as such is marked `unsafe`.
pub unsafe fn get_jsmanaged<'a>(&'a self) -> &'a LayoutJS<Node> {
&self.node
}
@ -603,21 +590,15 @@ pub struct ThreadSafeLayoutNode<'ln> {
pseudo: PseudoElementType,
}
impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
impl<'ln> ThreadSafeLayoutNode<'ln> {
/// Creates a new layout node with the same lifetime as this layout node.
unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> ThreadSafeLayoutNode<'ln> {
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> ThreadSafeLayoutNode<'ln> {
ThreadSafeLayoutNode {
node: self.node.new_with_this_lifetime(node),
pseudo: PseudoElementType::Normal,
}
}
unsafe fn get_jsmanaged<'a>(&'a self) -> &'a LayoutJS<Node> {
self.node.get_jsmanaged()
}
}
impl<'ln> ThreadSafeLayoutNode<'ln> {
/// Creates a new `ThreadSafeLayoutNode` from the given `LayoutNode`.
pub fn new<'a>(node: &LayoutNode<'a>) -> ThreadSafeLayoutNode<'a> {
ThreadSafeLayoutNode {
@ -635,6 +616,12 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
}
}
/// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to
/// call and as such is marked `unsafe`.
pub unsafe fn get_jsmanaged<'a>(&'a self) -> &'a LayoutJS<Node> {
self.node.get_jsmanaged()
}
/// Returns the type ID of this node.
/// Returns `None` if this is a pseudo-element; otherwise, returns `Some`.
pub fn type_id(&self) -> Option<NodeTypeId> {