Replace OpaqueNodeMethods::from_{threadsafe_,}layout_node by opaque methods.

This commit is contained in:
Ms2ger 2015-06-24 12:57:47 +02:00
parent 6247a96761
commit 2ea32829af
6 changed files with 20 additions and 37 deletions

View file

@ -31,7 +31,6 @@ use incremental::{RECONSTRUCT_FLOW, RestyleDamage};
use inline::{InlineFlow, InlineFragmentNodeInfo};
use list_item::{ListItemFlow, ListStyleTypeContent};
use multicol::MulticolFlow;
use opaque_node::OpaqueNodeMethods;
use parallel;
use table::TableFlow;
use table_caption::TableCaptionFlow;
@ -209,7 +208,7 @@ impl InlineFragmentsAccumulator {
InlineFragmentsAccumulator {
fragments: IntermediateInlineFragments::new(),
enclosing_node: Some(InlineFragmentNodeInfo {
address: OpaqueNodeMethods::from_thread_safe_layout_node(node),
address: node.opaque(),
style: node.style().clone(),
}),
}
@ -690,9 +689,8 @@ impl<'a> FlowConstructor<'a> {
}
};
let opaque_node = OpaqueNodeMethods::from_thread_safe_layout_node(node);
fragments.fragments
.push_back(Fragment::from_opaque_node_and_style(opaque_node,
.push_back(Fragment::from_opaque_node_and_style(node.opaque(),
style.clone(),
node.restyle_damage(),
specific))
@ -852,9 +850,8 @@ impl<'a> FlowConstructor<'a> {
//
// FIXME(#2001, pcwalton): Don't do this if there's padding or borders.
if node.is_ignorable_whitespace() {
let opaque_node = OpaqueNodeMethods::from_thread_safe_layout_node(node);
return ConstructionResult::ConstructionItem(ConstructionItem::Whitespace(
opaque_node,
node.opaque(),
node.style().clone(),
node.restyle_damage()))
}

View file

@ -11,7 +11,6 @@ use context::SharedLayoutContext;
use css::node_style::StyledNode;
use data::LayoutDataWrapper;
use incremental::{self, RestyleDamage};
use opaque_node::OpaqueNodeMethods;
use smallvec::SmallVec16;
use wrapper::{LayoutElement, LayoutNode};
@ -480,9 +479,8 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
// This is a newly-created node; we've nothing to transition from!
}
Some(ref style) => {
let node = OpaqueNodeMethods::from_layout_node(self);
animation::start_transitions_if_applicable(new_animations_sender,
node,
self.opaque(),
&**style,
&mut this_style);
}

View file

@ -404,8 +404,7 @@ impl ReplacedImageFragmentInfo {
dom_width: Option<Au>,
dom_height: Option<Au>) -> ReplacedImageFragmentInfo {
let is_vertical = node.style().writing_mode.is_vertical();
let opaque_node: OpaqueNode = OpaqueNodeMethods::from_thread_safe_layout_node(node);
let untrusted_node: UntrustedNodeAddress = opaque_node.to_untrusted_node_address();
let untrusted_node = node.opaque().to_untrusted_node_address();
ReplacedImageFragmentInfo {
for_node: untrusted_node,
@ -736,7 +735,7 @@ impl Fragment {
let style = node.style().clone();
let writing_mode = style.writing_mode;
Fragment {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
node: node.opaque(),
style: style,
restyle_damage: node.restyle_damage(),
border_box: LogicalRect::zero(writing_mode),
@ -766,7 +765,7 @@ impl Fragment {
let node_style = cascade_anonymous(&**node.style());
let writing_mode = node_style.writing_mode;
Fragment {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
node: node.opaque(),
style: Arc::new(node_style),
restyle_damage: node.restyle_damage(),
border_box: LogicalRect::zero(writing_mode),

View file

@ -385,7 +385,7 @@ impl LayoutTask {
canvas_layers_sender: self.canvas_layers_sender.clone(),
stylist: &*rw_data.stylist,
url: (*url).clone(),
reflow_root: reflow_root.map(|node| OpaqueNodeMethods::from_layout_node(node)),
reflow_root: reflow_root.map(|node| node.opaque()),
dirty: Rect::zero(),
visible_rects: rw_data.visible_rects.clone(),
generation: rw_data.generation,

View file

@ -10,15 +10,8 @@ use script::dom::bindings::js::LayoutJS;
use script::dom::node::Node;
use script::layout_interface::{TrustedNodeAddress};
use script_traits::UntrustedNodeAddress;
use wrapper::{LayoutNode, ThreadSafeLayoutNode};
pub trait OpaqueNodeMethods {
/// Converts a DOM node (layout view) to an `OpaqueNode`.
fn from_layout_node(node: &LayoutNode) -> Self;
/// Converts a thread-safe DOM node (layout view) to an `OpaqueNode`.
fn from_thread_safe_layout_node(node: &ThreadSafeLayoutNode) -> Self;
/// Converts a DOM node (script view) to an `OpaqueNode`.
fn from_script_node(node: TrustedNodeAddress) -> Self;
@ -31,18 +24,6 @@ pub trait OpaqueNodeMethods {
}
impl OpaqueNodeMethods for OpaqueNode {
fn from_layout_node(node: &LayoutNode) -> OpaqueNode {
unsafe {
OpaqueNodeMethods::from_jsmanaged(node.get_jsmanaged())
}
}
fn from_thread_safe_layout_node(node: &ThreadSafeLayoutNode) -> OpaqueNode {
unsafe {
OpaqueNodeMethods::from_jsmanaged(node.get_jsmanaged())
}
}
fn from_script_node(node: TrustedNodeAddress) -> OpaqueNode {
unsafe {
OpaqueNodeMethods::from_jsmanaged(&LayoutJS::from_trusted_node_address(node))

View file

@ -170,6 +170,11 @@ impl<'ln> LayoutNode<'ln> {
&self.node
}
/// Converts self into an `OpaqueNode`.
pub fn opaque(&self) -> OpaqueNode {
OpaqueNodeMethods::from_jsmanaged(unsafe { self.get_jsmanaged() })
}
/// Resets layout data and styles for the node.
///
/// FIXME(pcwalton): Do this as part of fragment building instead of in a traversal.
@ -197,8 +202,7 @@ impl<'ln> LayoutNode<'ln> {
match shared.reflow_root {
None => panic!("layout_parent_node(): This layout has no access to the DOM!"),
Some(reflow_root) => {
let opaque_node: OpaqueNode = OpaqueNodeMethods::from_layout_node(&self);
if opaque_node == reflow_root {
if self.opaque() == reflow_root {
None
} else {
self.parent_node()
@ -208,8 +212,7 @@ impl<'ln> LayoutNode<'ln> {
}
pub fn debug_id(self) -> usize {
let opaque: OpaqueNode = OpaqueNodeMethods::from_layout_node(&self);
opaque.to_untrusted_node_address().0 as usize
self.opaque().to_untrusted_node_address().0 as usize
}
}
@ -644,6 +647,11 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
self.node.get_jsmanaged()
}
/// Converts self into an `OpaqueNode`.
pub fn opaque(&self) -> OpaqueNode {
OpaqueNodeMethods::from_jsmanaged(unsafe { self.get_jsmanaged() })
}
/// Returns the type ID of this node.
/// Returns `None` if this is a pseudo-element; otherwise, returns `Some`.
pub fn type_id(&self) -> Option<NodeTypeId> {