aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/layout_task.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/layout_task.rs')
-rw-r--r--components/layout/layout_task.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs
index f3fd3546671..4ea12e58796 100644
--- a/components/layout/layout_task.rs
+++ b/components/layout/layout_task.rs
@@ -52,6 +52,7 @@ use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_re
use query::{MarginPadding, MarginRetrievingFragmentBorderBoxIterator, PositionProperty};
use query::{PositionRetrievingFragmentBorderBoxIterator, Side};
use script::dom::bindings::js::LayoutJS;
+use script::dom::document::Document;
use script::dom::node::{LayoutData, Node};
use script::layout_interface::Animation;
use script::layout_interface::{LayoutChan, LayoutRPC, OffsetParentResponse};
@@ -89,8 +90,7 @@ use util::opts;
use util::task::spawn_named_with_send_on_failure;
use util::task_state;
use util::workqueue::WorkQueue;
-use wrapper::LayoutNode;
-use wrapper::ThreadSafeLayoutNode;
+use wrapper::{LayoutDocument, LayoutNode, 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;
@@ -1137,13 +1137,16 @@ impl LayoutTask {
let _ajst = AutoJoinScriptTask { data: data };
// FIXME: Isolate this transmutation into a "bridge" module.
- // FIXME(rust#16366): The following line had to be moved because of a
- // rustc bug. It should be in the next unsafe block.
- let mut node: LayoutJS<Node> = unsafe {
- LayoutJS::from_trusted_node_address(data.document_root)
+ let mut doc: LayoutJS<Document> = unsafe {
+ LayoutJS::from_trusted_node_address(data.document).downcast::<Document>().unwrap()
};
- let node: &mut LayoutNode = unsafe {
- transmute(&mut node)
+ let doc: &mut LayoutDocument = unsafe {
+ transmute(&mut doc)
+ };
+
+ let mut node: LayoutNode = match doc.root_node() {
+ None => return,
+ Some(x) => x,
};
debug!("layout: received layout request for: {}", self.url.serialize());
@@ -1187,11 +1190,11 @@ impl LayoutTask {
let needs_reflow = screen_size_changed && !needs_dirtying;
unsafe {
if needs_dirtying {
- LayoutTask::dirty_all_nodes(node);
+ LayoutTask::dirty_all_nodes(&mut node);
}
}
if needs_reflow {
- if let Some(mut flow) = self.try_get_layout_root(*node) {
+ if let Some(mut flow) = self.try_get_layout_root(node) {
LayoutTask::reflow_all_nodes(flow_ref::deref_mut(&mut flow));
}
}
@@ -1213,16 +1216,16 @@ impl LayoutTask {
let rw_data = &mut *rw_data;
match rw_data.parallel_traversal {
None => {
- sequential::traverse_dom_preorder(*node, &shared_layout_context);
+ sequential::traverse_dom_preorder(node, &shared_layout_context);
}
Some(ref mut traversal) => {
- parallel::traverse_dom_preorder(*node, &shared_layout_context, traversal);
+ parallel::traverse_dom_preorder(node, &shared_layout_context, traversal);
}
}
});
// Retrieve the (possibly rebuilt) root flow.
- rw_data.root_flow = self.try_get_layout_root((*node).clone());
+ rw_data.root_flow = self.try_get_layout_root(node.clone());
}
// Send new canvas renderers to the paint task