aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/wrapper.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-07-15 15:44:45 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-07-15 16:41:12 +0200
commitbf9369b29d42255ea52b172e3ddd9b44db922d44 (patch)
tree46ade80599ca2cd87eeb68a98a8992aefa421dcc /components/layout/wrapper.rs
parentf9642b36bda3beb01dfedbc33e3586e5f7df473a (diff)
downloadservo-bf9369b29d42255ea52b172e3ddd9b44db922d44.tar.gz
servo-bf9369b29d42255ea52b172e3ddd9b44db922d44.zip
script: Move the layout_wrapper outside of script.
This allows us to have ensure_data() and clear_data() functions on the TElement trait, instead of hacking around it adding methods in random traits. This also allows us to do some further cleanup, which I'd rather do in a followup.
Diffstat (limited to 'components/layout/wrapper.rs')
-rw-r--r--components/layout/wrapper.rs34
1 files changed, 1 insertions, 33 deletions
diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs
index 87fe65bb3b9..2a31e17cfa1 100644
--- a/components/layout/wrapper.rs
+++ b/components/layout/wrapper.rs
@@ -31,21 +31,13 @@
#![allow(unsafe_code)]
use atomic_refcell::{AtomicRef, AtomicRefMut};
-use core::nonzero::NonZero;
use data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
-use script_layout_interface::{OpaqueStyleAndLayoutData, StyleData};
-use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
+use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use script_layout_interface::wrapper_traits::GetLayoutData;
use style::computed_values::content::{self, ContentItem};
use style::dom::{NodeInfo, TNode};
use style::selector_parser::RestyleDamage;
-pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) {
- let ptr: *mut StyleData = data.ptr.get();
- let non_opaque: *mut StyleAndLayoutData = ptr as *mut _;
- let _ = Box::from_raw(non_opaque);
-}
-
pub trait LayoutNodeLayoutData {
/// Similar to borrow_data*, but returns the full PersistentLayoutData rather
/// than only the style::data::ElementData.
@@ -81,30 +73,6 @@ impl<T: GetLayoutData> GetRawData for T {
}
}
-pub trait LayoutNodeHelpers {
- fn initialize_data(&self);
- fn clear_data(&self);
-}
-
-impl<T: LayoutNode> LayoutNodeHelpers for T {
- fn initialize_data(&self) {
- if self.get_raw_data().is_none() {
- let ptr: *mut StyleAndLayoutData =
- Box::into_raw(Box::new(StyleAndLayoutData::new()));
- let opaque = OpaqueStyleAndLayoutData {
- ptr: unsafe { NonZero::new(ptr as *mut StyleData) }
- };
- unsafe { self.init_style_and_layout_data(opaque) };
- };
- }
-
- fn clear_data(&self) {
- if self.get_raw_data().is_some() {
- unsafe { drop_style_and_layout_data(self.take_style_and_layout_data()) };
- }
- }
-}
-
pub trait ThreadSafeLayoutNodeHelpers {
/// Returns the layout data flags for this node.
fn flags(self) -> LayoutDataFlags;