mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
Use LayoutNode::new to avoid transmute calls in LayoutTask.
This commit is contained in:
parent
1eb8900f48
commit
cce510900e
2 changed files with 18 additions and 25 deletions
|
@ -51,9 +51,7 @@ use profile_traits::time::{self, ProfilerMetadata, profile};
|
||||||
use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request};
|
use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request};
|
||||||
use query::{MarginPadding, MarginRetrievingFragmentBorderBoxIterator, PositionProperty};
|
use query::{MarginPadding, MarginRetrievingFragmentBorderBoxIterator, PositionProperty};
|
||||||
use query::{PositionRetrievingFragmentBorderBoxIterator, Side};
|
use query::{PositionRetrievingFragmentBorderBoxIterator, Side};
|
||||||
use script::dom::bindings::js::LayoutJS;
|
use script::dom::node::LayoutData;
|
||||||
use script::dom::document::Document;
|
|
||||||
use script::dom::node::{LayoutData, Node};
|
|
||||||
use script::layout_interface::Animation;
|
use script::layout_interface::Animation;
|
||||||
use script::layout_interface::{LayoutChan, LayoutRPC, OffsetParentResponse};
|
use script::layout_interface::{LayoutChan, LayoutRPC, OffsetParentResponse};
|
||||||
use script::layout_interface::{Msg, NewLayoutTaskInfo, Reflow, ReflowGoal, ReflowQueryType};
|
use script::layout_interface::{Msg, NewLayoutTaskInfo, Reflow, ReflowGoal, ReflowQueryType};
|
||||||
|
@ -90,7 +88,7 @@ use util::opts;
|
||||||
use util::task::spawn_named_with_send_on_failure;
|
use util::task::spawn_named_with_send_on_failure;
|
||||||
use util::task_state;
|
use util::task_state;
|
||||||
use util::workqueue::WorkQueue;
|
use util::workqueue::WorkQueue;
|
||||||
use wrapper::{LayoutDocument, LayoutNode, ThreadSafeLayoutNode};
|
use wrapper::{LayoutNode, ThreadSafeLayoutNode};
|
||||||
|
|
||||||
/// The number of screens of data we're allowed to generate display lists for in each direction.
|
/// 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;
|
pub const DISPLAY_PORT_SIZE_FACTOR: i32 = 8;
|
||||||
|
@ -895,17 +893,9 @@ impl LayoutTask {
|
||||||
property: &Atom,
|
property: &Atom,
|
||||||
layout_root: &mut FlowRef)
|
layout_root: &mut FlowRef)
|
||||||
-> Option<String> {
|
-> Option<String> {
|
||||||
// FIXME: Isolate this transmutation into a "bridge" module.
|
let node = unsafe { LayoutNode::new(&requested_node) };
|
||||||
// FIXME(rust#16366): The following line had to be moved because of a
|
|
||||||
// rustc bug. It should be in the next unsafe block.
|
|
||||||
let node: LayoutJS<Node> = unsafe {
|
|
||||||
LayoutJS::from_trusted_node_address(requested_node)
|
|
||||||
};
|
|
||||||
let node: &LayoutNode = unsafe {
|
|
||||||
transmute(&node)
|
|
||||||
};
|
|
||||||
|
|
||||||
let layout_node = ThreadSafeLayoutNode::new(node);
|
let layout_node = ThreadSafeLayoutNode::new(&node);
|
||||||
let layout_node = match pseudo {
|
let layout_node = match pseudo {
|
||||||
&Some(PseudoElement::Before) => layout_node.get_before_pseudo(),
|
&Some(PseudoElement::Before) => layout_node.get_before_pseudo(),
|
||||||
&Some(PseudoElement::After) => layout_node.get_after_pseudo(),
|
&Some(PseudoElement::After) => layout_node.get_after_pseudo(),
|
||||||
|
@ -1136,15 +1126,9 @@ impl LayoutTask {
|
||||||
};
|
};
|
||||||
let _ajst = AutoJoinScriptTask { data: data };
|
let _ajst = AutoJoinScriptTask { data: data };
|
||||||
|
|
||||||
// FIXME: Isolate this transmutation into a "bridge" module.
|
let document = unsafe { LayoutNode::new(&data.document) };
|
||||||
let mut doc: LayoutJS<Document> = unsafe {
|
let document = document.as_document().unwrap();
|
||||||
LayoutJS::from_trusted_node_address(data.document).downcast::<Document>().unwrap()
|
let node: LayoutNode = match document.root_node() {
|
||||||
};
|
|
||||||
let doc: &mut LayoutDocument = unsafe {
|
|
||||||
transmute(&mut doc)
|
|
||||||
};
|
|
||||||
|
|
||||||
let node: LayoutNode = match doc.root_node() {
|
|
||||||
None => return,
|
None => return,
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
};
|
};
|
||||||
|
@ -1199,7 +1183,7 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let event_state_changes = doc.drain_event_state_changes();
|
let event_state_changes = document.drain_event_state_changes();
|
||||||
if !needs_dirtying {
|
if !needs_dirtying {
|
||||||
for &(el, state) in event_state_changes.iter() {
|
for &(el, state) in event_state_changes.iter() {
|
||||||
assert!(!state.is_empty());
|
assert!(!state.is_empty());
|
||||||
|
@ -1233,7 +1217,7 @@ impl LayoutTask {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve the (possibly rebuilt) root flow.
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send new canvas renderers to the paint task
|
// Send new canvas renderers to the paint task
|
||||||
|
|
|
@ -221,6 +221,15 @@ impl<'ln> LayoutNode<'ln> {
|
||||||
as_element(self.node)
|
as_element(self.node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn as_document(&self) -> Option<LayoutDocument<'ln>> {
|
||||||
|
self.node.downcast().map(|document| {
|
||||||
|
LayoutDocument {
|
||||||
|
document: document,
|
||||||
|
chain: PhantomData,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn parent_node(&self) -> Option<LayoutNode<'ln>> {
|
fn parent_node(&self) -> Option<LayoutNode<'ln>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.node.parent_node_ref().map(|node| self.new_with_this_lifetime(&node))
|
self.node.parent_node_ref().map(|node| self.new_with_this_lifetime(&node))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue