diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-06-22 11:34:31 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-06-22 11:34:31 +0200 |
commit | a42e11a95f7cdc0c45147f7861c7185b690ebbc2 (patch) | |
tree | f455739f42c836195d7ed59ec3ff8fef4e2983b8 | |
parent | 167a396293ef161223f47fe14563048e1e81f5be (diff) | |
download | servo-a42e11a95f7cdc0c45147f7861c7185b690ebbc2.tar.gz servo-a42e11a95f7cdc0c45147f7861c7185b690ebbc2.zip |
Replace the LayoutDataAccess trait by inherent methods.
-rw-r--r-- | components/layout/construct.rs | 2 | ||||
-rw-r--r-- | components/layout/css/matching.rs | 2 | ||||
-rw-r--r-- | components/layout/data.rs | 40 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 2 | ||||
-rw-r--r-- | components/layout/parallel.rs | 2 | ||||
-rw-r--r-- | components/layout/wrapper.rs | 24 |
6 files changed, 29 insertions, 43 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 27181f34e52..2742c18d271 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -16,7 +16,7 @@ use block::BlockFlow; use context::LayoutContext; use css::node_style::StyledNode; -use data::{HAS_NEWLY_CONSTRUCTED_FLOW, LayoutDataAccess, LayoutDataWrapper}; +use data::{HAS_NEWLY_CONSTRUCTED_FLOW, LayoutDataWrapper}; use floats::FloatKind; use flow::{Descendants, AbsDescendants}; use flow::{Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils}; diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index 24356af6be8..29edbd9e9aa 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -9,7 +9,7 @@ use animation; use context::SharedLayoutContext; use css::node_style::StyledNode; -use data::{LayoutDataAccess, LayoutDataWrapper}; +use data::LayoutDataWrapper; use incremental::{self, RestyleDamage}; use opaque_node::OpaqueNodeMethods; use smallvec::SmallVec16; diff --git a/components/layout/data.rs b/components/layout/data.rs index 6bee6916039..e26e0a28431 100644 --- a/components/layout/data.rs +++ b/components/layout/data.rs @@ -2,19 +2,14 @@ * 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 construct::{ConstructionItem, ConstructionResult}; use incremental::RestyleDamage; use msg::constellation_msg::ConstellationChan; use parallel::DomParallelInfo; -use script::dom::node::{LayoutNodeHelpers, SharedLayoutData}; +use script::dom::node::SharedLayoutData; use script::layout_interface::LayoutChan; -use std::cell::{Ref, RefMut}; -use std::mem; use std::sync::Arc; use style::properties::ComputedValues; -use wrapper::LayoutNode; /// Data that layout associates with a node. pub struct PrivateLayoutData { @@ -95,41 +90,10 @@ impl LayoutDataWrapper { } } -#[allow(dead_code)] +#[allow(dead_code, unsafe_code)] fn static_assertion(x: Option<LayoutDataWrapper>) { unsafe { let _: Option<::script::dom::node::LayoutData> = ::std::intrinsics::transmute(x); } } - -/// A trait that allows access to the layout data of a DOM node. -pub trait LayoutDataAccess { - /// Borrows the layout data without checks. - unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper>; - /// Borrows the layout data immutably. Fails on a conflicting borrow. - fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>>; - /// Borrows the layout data mutably. Fails on a conflicting borrow. - fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>>; -} - -impl<'ln> LayoutDataAccess for LayoutNode<'ln> { - #[inline(always)] - unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper> { - mem::transmute(self.get_jsmanaged().layout_data_unchecked()) - } - - #[inline(always)] - fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> { - unsafe { - mem::transmute(self.get_jsmanaged().layout_data()) - } - } - - #[inline(always)] - fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> { - unsafe { - mem::transmute(self.get_jsmanaged().layout_data_mut()) - } - } -} diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index f4533dbaad5..178d08319a8 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -11,7 +11,7 @@ use animation; use construct::ConstructionResult; use context::{SharedLayoutContext, SharedLayoutContextWrapper, heap_size_of_local_context}; use css::node_style::StyledNode; -use data::{LayoutDataAccess, LayoutDataWrapper}; +use data::LayoutDataWrapper; use display_list_builder::ToGfxColor; use flow::{self, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils}; use flow_ref::FlowRef; diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index 879c2a1eea2..9cc60f31aee 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -12,7 +12,7 @@ use context::{LayoutContext, SharedLayoutContextWrapper, SharedLayoutContext}; use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal}; use flow; use flow_ref::FlowRef; -use data::{LayoutDataAccess, LayoutDataWrapper}; +use data::LayoutDataWrapper; use traversal::{BubbleISizes, AssignISizes, AssignBSizesAndStoreOverflow}; use traversal::{ComputeAbsolutePositions, BuildDisplayList}; use traversal::{RecalcStyleForNode, ConstructFlows}; diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 774873a2964..c4414a55dd6 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -34,7 +34,7 @@ use canvas_traits::CanvasMsg; use context::SharedLayoutContext; use css::node_style::StyledNode; use incremental::RestyleDamage; -use data::{LayoutDataAccess, LayoutDataFlags, LayoutDataWrapper, PrivateLayoutData}; +use data::{LayoutDataFlags, LayoutDataWrapper, PrivateLayoutData}; use opaque_node::OpaqueNodeMethods; use gfx::display_list::OpaqueNode; @@ -332,6 +332,28 @@ impl<'ln> LayoutNode<'ln> { pub unsafe fn set_dirty_descendants(&self, value: bool) { self.node.set_flag(HAS_DIRTY_DESCENDANTS, value) } + + /// Borrows the layout data without checks. + #[inline(always)] + pub unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper> { + mem::transmute(self.get_jsmanaged().layout_data_unchecked()) + } + + /// Borrows the layout data immutably. Fails on a conflicting borrow. + #[inline(always)] + pub fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> { + unsafe { + mem::transmute(self.get_jsmanaged().layout_data()) + } + } + + /// Borrows the layout data mutably. Fails on a conflicting borrow. + #[inline(always)] + pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> { + unsafe { + mem::transmute(self.get_jsmanaged().layout_data_mut()) + } + } } pub struct LayoutNodeChildrenIterator<'a> { |