aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2015-06-21 17:29:08 +0200
committerMs2ger <ms2ger@gmail.com>2015-06-22 11:04:43 +0200
commit167a396293ef161223f47fe14563048e1e81f5be (patch)
treed5129876324dca200895360355412121d20d3e59
parent50d4084e9ab26cbfe587bc84cb03bf205e2291de (diff)
downloadservo-167a396293ef161223f47fe14563048e1e81f5be.tar.gz
servo-167a396293ef161223f47fe14563048e1e81f5be.zip
Replace TLayoutNode by inherent methods.
There is no reason for this trait to exist.
-rw-r--r--components/layout/data.rs2
-rw-r--r--components/layout/opaque_node.rs2
-rw-r--r--components/layout/wrapper.rs39
3 files changed, 15 insertions, 28 deletions
diff --git a/components/layout/data.rs b/components/layout/data.rs
index f679435a91f..6bee6916039 100644
--- a/components/layout/data.rs
+++ b/components/layout/data.rs
@@ -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 {
diff --git a/components/layout/opaque_node.rs b/components/layout/opaque_node.rs
index 666d3a9eb11..ea22df50668 100644
--- a/components/layout/opaque_node.rs
+++ b/components/layout/opaque_node.rs
@@ -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`.
diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs
index 895c80ba678..774873a2964 100644
--- a/components/layout/wrapper.rs
+++ b/components/layout/wrapper.rs
@@ -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> {