Implement a LayoutNode::new function.

This commit is contained in:
Ms2ger 2015-10-25 11:13:56 +01:00
parent 244bd11f3f
commit 06f9a2bc34

View file

@ -54,6 +54,7 @@ use script::dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaEl
use script::dom::node::{HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; use script::dom::node::{HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY};
use script::dom::node::{LayoutNodeHelpers, Node, SharedLayoutData}; use script::dom::node::{LayoutNodeHelpers, Node, SharedLayoutData};
use script::dom::text::Text; use script::dom::text::Text;
use script::layout_interface::TrustedNodeAddress;
use selectors::matching::DeclarationBlock; use selectors::matching::DeclarationBlock;
use selectors::parser::{AttrSelector, NamespaceConstraint}; use selectors::parser::{AttrSelector, NamespaceConstraint};
use smallvec::VecLike; use smallvec::VecLike;
@ -92,6 +93,14 @@ impl<'a> PartialEq for LayoutNode<'a> {
} }
impl<'ln> LayoutNode<'ln> { impl<'ln> LayoutNode<'ln> {
pub unsafe fn new(address: &TrustedNodeAddress) -> LayoutNode {
let node = LayoutJS::from_trusted_node_address(*address);
LayoutNode {
node: node,
chain: PhantomData,
}
}
/// Creates a new layout node with the same lifetime as this layout node. /// 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> { pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> LayoutNode<'ln> {
LayoutNode { LayoutNode {