diff --git a/components/layout/layout_thread.rs b/components/layout/layout_thread.rs index abe3fd7d33a..d0c27743667 100644 --- a/components/layout/layout_thread.rs +++ b/components/layout/layout_thread.rs @@ -46,10 +46,10 @@ use query::process_offset_parent_query; use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request}; use query::{process_node_geometry_request, process_node_layer_id_request, process_node_scroll_area_request}; use query::{process_node_overflow_request, process_resolved_style_request, process_margin_style_query}; -use script::layout_interface::OpaqueStyleAndLayoutData; use script::layout_interface::{LayoutRPC, OffsetParentResponse, NodeOverflowResponse, MarginStyleResponse}; use script::layout_interface::{Msg, NewLayoutThreadInfo, Reflow, ReflowQueryType, ScriptReflow}; use script::reporter::CSSErrorReporter; +use script_layout_interface::OpaqueStyleAndLayoutData; use script_layout_interface::restyle_damage::{REPAINT, STORE_OVERFLOW, REFLOW_OUT_OF_FLOW, REFLOW}; use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; use script_traits::{StackingContextScrollState, UntrustedNodeAddress}; diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 7a20337607e..82c3d1416d5 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -42,8 +42,9 @@ use script::layout_interface::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCEND use script::layout_interface::{CharacterDataTypeId, Document, Element, ElementTypeId}; use script::layout_interface::{HTMLCanvasData, HTMLElementTypeId, LayoutCharacterDataHelpers}; use script::layout_interface::{LayoutDocumentHelpers, LayoutElementHelpers, LayoutJS}; -use script::layout_interface::{LayoutNodeHelpers, Node, NodeTypeId, OpaqueStyleAndLayoutData}; +use script::layout_interface::{LayoutNodeHelpers, Node, NodeTypeId}; use script::layout_interface::{RawLayoutElementHelpers, Text, TrustedNodeAddress}; +use script_layout_interface::OpaqueStyleAndLayoutData; use script_layout_interface::restyle_damage::RestyleDamage; use selectors::matching::{DeclarationBlock, ElementFlags}; use selectors::parser::{AttrSelector, NamespaceConstraint}; diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 911f1b9cc67..bbb086a308d 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -52,6 +52,7 @@ ref_filter_map = "1.0" ref_slice = "1.0" regex = "0.1.43" rustc-serialize = "0.3" +script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} selectors = {version = "0.6", features = ["heap_size"]} serde = "0.7" diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 34ec7d19e14..070a3e1b954 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -67,6 +67,7 @@ use net_traits::{Metadata, NetworkError, ResourceThreads}; use offscreen_gl_context::GLLimits; use profile_traits::mem::ProfilerChan as MemProfilerChan; use profile_traits::time::ProfilerChan as TimeProfilerChan; +use script_layout_interface::OpaqueStyleAndLayoutData; use script_runtime::ScriptChan; use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase, UntrustedNodeAddress}; use serde::{Deserialize, Serialize}; @@ -328,6 +329,7 @@ no_jsmanaged_fields!(ReferrerPolicy); no_jsmanaged_fields!(ResourceThreads); no_jsmanaged_fields!(SystemTime); no_jsmanaged_fields!(SelectedFileId); +no_jsmanaged_fields!(OpaqueStyleAndLayoutData); impl JSTraceable for Box { #[inline] diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 4554ac3210c..a6834d487d4 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -5,7 +5,6 @@ //! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements. use app_units::Au; -use core::nonzero::NonZero; use devtools_traits::NodeInfo; use document_loader::DocumentLoader; use dom::attr::Attr; @@ -62,6 +61,7 @@ use libc::{self, c_void, uintptr_t}; use msg::constellation_msg::PipelineId; use parse::html::parse_html_fragment; use ref_slice::ref_slice; +use script_layout_interface::OpaqueStyleAndLayoutData; use script_traits::UntrustedNodeAddress; use selectors::matching::matches; use selectors::parser::Selector; @@ -184,18 +184,6 @@ enum SuppressObserver { Unsuppressed } -#[derive(Copy, Clone, HeapSizeOf)] -pub struct OpaqueStyleAndLayoutData { - #[ignore_heap_size_of = "TODO(#6910) Box value that should be counted but \ - the type lives in layout"] - pub ptr: NonZero<*mut ()> -} - -#[allow(unsafe_code)] -unsafe impl Send for OpaqueStyleAndLayoutData {} - -no_jsmanaged_fields!(OpaqueStyleAndLayoutData); - impl Node { /// Sends the style and layout data, if any, back to the layout thread to be destroyed. pub fn dispose(&self, data: OpaqueStyleAndLayoutData) { diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index 37b6d169481..ae68cc0ec55 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -14,6 +14,7 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::{PanicMsg, PipelineId, WindowSizeData}; use net_traits::image_cache_thread::ImageCacheThread; use profile_traits::mem::ReportsChan; +use script_layout_interface::OpaqueStyleAndLayoutData; use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; use script_traits::{StackingContextScrollState, UntrustedNodeAddress}; use std::sync::Arc; @@ -37,7 +38,6 @@ pub use dom::htmlobjectelement::is_image_data; pub use dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; pub use dom::node::LayoutNodeHelpers; pub use dom::node::Node; -pub use dom::node::OpaqueStyleAndLayoutData; pub use dom::node::TrustedNodeAddress; pub use dom::text::Text; diff --git a/components/script/lib.rs b/components/script/lib.rs index 307376854ca..a47d549cc31 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -68,6 +68,7 @@ extern crate ref_filter_map; extern crate ref_slice; extern crate regex; extern crate rustc_serialize; +extern crate script_layout_interface; extern crate script_traits; extern crate selectors; extern crate serde; diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index 3069b1a3b8d..cbc36fa02c4 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -10,5 +10,7 @@ path = "lib.rs" [dependencies] bitflags = "0.7" +heapsize = "0.3.0" +heapsize_plugin = "0.1.2" plugins = {path = "../plugins"} style = {path = "../style"} diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs index 1aed95b6210..b2e3b6fd475 100644 --- a/components/script_layout_interface/lib.rs +++ b/components/script_layout_interface/lib.rs @@ -7,12 +7,30 @@ //! to depend on script. #![deny(unsafe_code)] +#![feature(custom_attribute)] +#![feature(custom_derive)] +#![feature(nonzero)] #![feature(plugin)] +#![plugin(heapsize_plugin)] #![plugin(plugins)] #[allow(unused_extern_crates)] #[macro_use] extern crate bitflags; +extern crate core; +extern crate heapsize; extern crate style; pub mod restyle_damage; + +use core::nonzero::NonZero; + +#[derive(Copy, Clone, HeapSizeOf)] +pub struct OpaqueStyleAndLayoutData { + #[ignore_heap_size_of = "TODO(#6910) Box value that should be counted but \ + the type lives in layout"] + pub ptr: NonZero<*mut ()> +} + +#[allow(unsafe_code)] +unsafe impl Send for OpaqueStyleAndLayoutData {} diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index d2e8c8a42e4..5636de1687b 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -1909,6 +1909,7 @@ dependencies = [ "ref_slice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "script_layout_interface 0.0.1", "script_traits 0.0.1", "selectors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1930,6 +1931,8 @@ name = "script_layout_interface" version = "0.0.1" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "style 0.0.1", ] diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 4edf3ccacc0..8467c3bd56d 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -1767,6 +1767,7 @@ dependencies = [ "ref_slice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "script_layout_interface 0.0.1", "script_traits 0.0.1", "selectors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1788,6 +1789,8 @@ name = "script_layout_interface" version = "0.0.1" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "style 0.0.1", ]