aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/layout_task.rs
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2015-12-17 16:21:29 -0800
committerBobby Holley <bobbyholley@gmail.com>2015-12-29 11:50:03 -0800
commit47059d2d26f14f71e5b7212fa8bc01608eca11b5 (patch)
treed0693fb9987a7113323c7d6fb5502cb5621d8f15 /components/layout/layout_task.rs
parent89ab368258eb827b0dcc8d6e6deecd3ed3c1de71 (diff)
downloadservo-47059d2d26f14f71e5b7212fa8bc01608eca11b5.tar.gz
servo-47059d2d26f14f71e5b7212fa8bc01608eca11b5.zip
Separate style+layout and layout-specific wrapper functionality.
This patch does a number of things, unfortunately all at once: * Hoists a large subset of the layout wrapper functionality into the style system. * Merges TElementAttributes into the newly-created TElement. * Reorganizes LayoutData by style vs layout, and removes LayoutDataShared. * Simplifies the API for borrowing style/layout data. There's still more to do to make the style system usable standalone, but this is a good start.
Diffstat (limited to 'components/layout/layout_task.rs')
-rw-r--r--components/layout/layout_task.rs33
1 files changed, 15 insertions, 18 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs
index 3063690778d..7cec9ed2948 100644
--- a/components/layout/layout_task.rs
+++ b/components/layout/layout_task.rs
@@ -13,7 +13,6 @@ use azure::azure::AzColor;
use canvas_traits::CanvasMsg;
use construct::ConstructionResult;
use context::{SharedLayoutContext, StylistWrapper, heap_size_of_local_context};
-use data::LayoutDataWrapper;
use display_list_builder::ToGfxColor;
use euclid::Matrix4;
use euclid::point::Point2D;
@@ -45,7 +44,7 @@ use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
use profile_traits::time::{self, TimerMetadata, profile};
use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request};
use query::{process_node_geometry_request, process_offset_parent_query, process_resolved_style_request};
-use script::dom::node::LayoutData;
+use script::dom::node::OpaqueStyleAndLayoutData;
use script::layout_interface::Animation;
use script::layout_interface::{LayoutRPC, OffsetParentResponse};
use script::layout_interface::{Msg, NewLayoutTaskInfo, Reflow, ReflowGoal, ReflowQueryType};
@@ -65,6 +64,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::{channel, Sender, Receiver};
use std::sync::{Arc, Mutex, MutexGuard, RwLock};
use style::computed_values::{filter, mix_blend_mode};
+use style::dom::{TDocument, TElement, TNode};
use style::media_queries::{Device, MediaType};
use style::selector_matching::{Stylist, USER_OR_USER_AGENT_STYLESHEETS};
use style::stylesheets::{CSSRuleIteratorExt, Stylesheet};
@@ -77,8 +77,7 @@ use util::opts;
use util::task;
use util::task_state;
use util::workqueue::WorkQueue;
-use wrapper::{LayoutDocument, LayoutElement, LayoutNode};
-use wrapper::{ServoLayoutNode, ThreadSafeLayoutNode};
+use wrapper::{LayoutNode, NonOpaqueStyleAndLayoutData, ServoLayoutNode, ThreadSafeLayoutNode};
/// The number of screens of data we're allowed to generate display lists for in each direction.
pub const DISPLAY_PORT_SIZE_FACTOR: i32 = 8;
@@ -607,9 +606,9 @@ impl LayoutTask {
Msg::SetVisibleRects(new_visible_rects) => {
self.set_visible_rects(new_visible_rects, possibly_locked_rw_data);
}
- Msg::ReapLayoutData(dead_layout_data) => {
+ Msg::ReapStyleAndLayoutData(dead_data) => {
unsafe {
- self.handle_reap_layout_data(dead_layout_data)
+ self.handle_reap_style_and_layout_data(dead_data)
}
}
Msg::CollectReports(reports_chan) => {
@@ -707,9 +706,9 @@ impl LayoutTask {
response_chan.send(()).unwrap();
loop {
match self.port.recv().unwrap() {
- Msg::ReapLayoutData(dead_layout_data) => {
+ Msg::ReapStyleAndLayoutData(dead_data) => {
unsafe {
- self.handle_reap_layout_data(dead_layout_data)
+ self.handle_reap_style_and_layout_data(dead_data)
}
}
Msg::ExitNow => {
@@ -765,14 +764,11 @@ impl LayoutTask {
}
fn try_get_layout_root<'ln, N: LayoutNode<'ln>>(&self, node: N) -> Option<FlowRef> {
- let mut layout_data_ref = node.mutate_layout_data();
- let layout_data =
- match layout_data_ref.as_mut() {
- None => return None,
- Some(layout_data) => layout_data,
- };
-
- let result = layout_data.data.flow_construction_result.swap_out();
+ let mut data = match node.mutate_layout_data() {
+ Some(x) => x,
+ None => return None,
+ };
+ let result = data.flow_construction_result.swap_out();
let mut flow = match result {
ConstructionResult::Flow(mut flow, abs_descendants) => {
@@ -1312,8 +1308,9 @@ impl LayoutTask {
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
/// because the struct type is transmuted to a different type on the script side.
- unsafe fn handle_reap_layout_data(&self, layout_data: LayoutData) {
- let _: LayoutDataWrapper = transmute(layout_data);
+ unsafe fn handle_reap_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData) {
+ let non_opaque: NonOpaqueStyleAndLayoutData = transmute(data.ptr);
+ let _ = Box::from_raw(non_opaque);
}
/// Returns profiling information which is passed to the time profiler.