Prefix concrete types with 'Servo'.

This commit is contained in:
Bobby Holley 2015-11-18 16:42:50 -08:00
parent 54f2700ba6
commit 9dd45b9f2a
6 changed files with 90 additions and 90 deletions

View file

@ -31,7 +31,7 @@ use util::arc_ptr_eq;
use util::cache::{LRUCache, SimpleHashCache}; use util::cache::{LRUCache, SimpleHashCache};
use util::opts; use util::opts;
use util::vec::ForgetfulSink; use util::vec::ForgetfulSink;
use wrapper::{LayoutElement, LayoutElementTrait, LayoutNode, LayoutNodeTrait}; use wrapper::{ServoLayoutElement, LayoutElementTrait, ServoLayoutNode, LayoutNodeTrait};
pub struct ApplicableDeclarations { pub struct ApplicableDeclarations {
pub normal: SmallVec<[DeclarationBlock; 16]>, pub normal: SmallVec<[DeclarationBlock; 16]>,
@ -160,7 +160,7 @@ pub struct StyleSharingCandidateCache {
cache: LRUCache<StyleSharingCandidate, ()>, cache: LRUCache<StyleSharingCandidate, ()>,
} }
fn create_common_style_affecting_attributes_from_element(element: &LayoutElement) fn create_common_style_affecting_attributes_from_element(element: &ServoLayoutElement)
-> CommonStyleAffectingAttributes { -> CommonStyleAffectingAttributes {
let mut flags = CommonStyleAffectingAttributes::empty(); let mut flags = CommonStyleAffectingAttributes::empty();
for attribute_info in &common_style_affecting_attributes() { for attribute_info in &common_style_affecting_attributes() {
@ -211,7 +211,7 @@ impl StyleSharingCandidate {
/// Attempts to create a style sharing candidate from this node. Returns /// Attempts to create a style sharing candidate from this node. Returns
/// the style sharing candidate or `None` if this node is ineligible for /// the style sharing candidate or `None` if this node is ineligible for
/// style sharing. /// style sharing.
fn new(element: &LayoutElement) -> Option<StyleSharingCandidate> { fn new(element: &ServoLayoutElement) -> Option<StyleSharingCandidate> {
let parent_element = match element.parent_element() { let parent_element = match element.parent_element() {
None => return None, None => return None,
Some(parent_element) => parent_element, Some(parent_element) => parent_element,
@ -257,7 +257,7 @@ impl StyleSharingCandidate {
}) })
} }
fn can_share_style_with(&self, element: &LayoutElement) -> bool { fn can_share_style_with(&self, element: &ServoLayoutElement) -> bool {
if *element.get_local_name() != self.local_name { if *element.get_local_name() != self.local_name {
return false return false
} }
@ -342,7 +342,7 @@ impl StyleSharingCandidateCache {
self.cache.iter() self.cache.iter()
} }
pub fn insert_if_possible(&mut self, element: &LayoutElement) { pub fn insert_if_possible(&mut self, element: &ServoLayoutElement) {
match StyleSharingCandidate::new(element) { match StyleSharingCandidate::new(element) {
None => {} None => {}
Some(candidate) => self.cache.insert(candidate, ()) Some(candidate) => self.cache.insert(candidate, ())
@ -376,7 +376,7 @@ pub trait ElementMatchMethods {
unsafe fn share_style_if_possible(&self, unsafe fn share_style_if_possible(&self,
style_sharing_candidate_cache: style_sharing_candidate_cache:
&mut StyleSharingCandidateCache, &mut StyleSharingCandidateCache,
parent: Option<LayoutNode>) parent: Option<ServoLayoutNode>)
-> StyleSharingResult; -> StyleSharingResult;
} }
@ -396,7 +396,7 @@ pub trait MatchMethods {
unsafe fn cascade_node(&self, unsafe fn cascade_node(&self,
layout_context: &SharedLayoutContext, layout_context: &SharedLayoutContext,
parent: Option<LayoutNode>, parent: Option<ServoLayoutNode>,
applicable_declarations: &ApplicableDeclarations, applicable_declarations: &ApplicableDeclarations,
applicable_declarations_cache: &mut ApplicableDeclarationsCache, applicable_declarations_cache: &mut ApplicableDeclarationsCache,
new_animations_sender: &Mutex<Sender<Animation>>); new_animations_sender: &Mutex<Sender<Animation>>);
@ -418,12 +418,12 @@ trait PrivateMatchMethods {
trait PrivateElementMatchMethods { trait PrivateElementMatchMethods {
fn share_style_with_candidate_if_possible(&self, fn share_style_with_candidate_if_possible(&self,
parent_node: Option<LayoutNode>, parent_node: Option<ServoLayoutNode>,
candidate: &StyleSharingCandidate) candidate: &StyleSharingCandidate)
-> Option<Arc<ComputedValues>>; -> Option<Arc<ComputedValues>>;
} }
impl<'ln> PrivateMatchMethods for LayoutNode<'ln> { impl<'ln> PrivateMatchMethods for ServoLayoutNode<'ln> {
fn cascade_node_pseudo_element(&self, fn cascade_node_pseudo_element(&self,
layout_context: &SharedLayoutContext, layout_context: &SharedLayoutContext,
parent_style: Option<&Arc<ComputedValues>>, parent_style: Option<&Arc<ComputedValues>>,
@ -502,9 +502,9 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
} }
} }
impl<'ln> PrivateElementMatchMethods for LayoutElement<'ln> { impl<'ln> PrivateElementMatchMethods for ServoLayoutElement<'ln> {
fn share_style_with_candidate_if_possible(&self, fn share_style_with_candidate_if_possible(&self,
parent_node: Option<LayoutNode>, parent_node: Option<ServoLayoutNode>,
candidate: &StyleSharingCandidate) candidate: &StyleSharingCandidate)
-> Option<Arc<ComputedValues>> { -> Option<Arc<ComputedValues>> {
let parent_node = match parent_node { let parent_node = match parent_node {
@ -537,7 +537,7 @@ impl<'ln> PrivateElementMatchMethods for LayoutElement<'ln> {
} }
} }
impl<'ln> ElementMatchMethods for LayoutElement<'ln> { impl<'ln> ElementMatchMethods for ServoLayoutElement<'ln> {
fn match_element(&self, fn match_element(&self,
stylist: &Stylist, stylist: &Stylist,
parent_bf: Option<&BloomFilter>, parent_bf: Option<&BloomFilter>,
@ -570,7 +570,7 @@ impl<'ln> ElementMatchMethods for LayoutElement<'ln> {
unsafe fn share_style_if_possible(&self, unsafe fn share_style_if_possible(&self,
style_sharing_candidate_cache: style_sharing_candidate_cache:
&mut StyleSharingCandidateCache, &mut StyleSharingCandidateCache,
parent: Option<LayoutNode>) parent: Option<ServoLayoutNode>)
-> StyleSharingResult { -> StyleSharingResult {
if opts::get().disable_share_style_cache { if opts::get().disable_share_style_cache {
return StyleSharingResult::CannotShare return StyleSharingResult::CannotShare
@ -603,7 +603,7 @@ impl<'ln> ElementMatchMethods for LayoutElement<'ln> {
} }
} }
impl<'ln> MatchMethods for LayoutNode<'ln> { impl<'ln> MatchMethods for ServoLayoutNode<'ln> {
// The below two functions are copy+paste because I can't figure out how to // The below two functions are copy+paste because I can't figure out how to
// write a function which takes a generic function. I don't think it can // write a function which takes a generic function. I don't think it can
// be done. // be done.
@ -645,7 +645,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
unsafe fn cascade_node(&self, unsafe fn cascade_node(&self,
layout_context: &SharedLayoutContext, layout_context: &SharedLayoutContext,
parent: Option<LayoutNode>, parent: Option<ServoLayoutNode>,
applicable_declarations: &ApplicableDeclarations, applicable_declarations: &ApplicableDeclarations,
applicable_declarations_cache: &mut ApplicableDeclarationsCache, applicable_declarations_cache: &mut ApplicableDeclarationsCache,
new_animations_sender: &Mutex<Sender<Animation>>) { new_animations_sender: &Mutex<Sender<Animation>>) {

View file

@ -82,7 +82,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::{LayoutDocumentTrait, LayoutElementTrait, LayoutNode, LayoutNodeTrait, ThreadSafeLayoutNode}; use wrapper::{LayoutDocumentTrait, LayoutElementTrait, ServoLayoutNode, LayoutNodeTrait, 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;
@ -750,7 +750,7 @@ impl LayoutTask {
possibly_locked_rw_data.block(rw_data); possibly_locked_rw_data.block(rw_data);
} }
fn try_get_layout_root(&self, node: LayoutNode) -> Option<FlowRef> { fn try_get_layout_root(&self, node: ServoLayoutNode) -> Option<FlowRef> {
let mut layout_data_ref = node.mutate_layout_data(); let mut layout_data_ref = node.mutate_layout_data();
let layout_data = let layout_data =
match layout_data_ref.as_mut() { match layout_data_ref.as_mut() {
@ -828,7 +828,7 @@ impl LayoutTask {
property: &Atom, property: &Atom,
layout_root: &mut FlowRef) layout_root: &mut FlowRef)
-> Option<String> { -> Option<String> {
let node = unsafe { LayoutNode::new(&requested_node) }; let node = unsafe { ServoLayoutNode::new(&requested_node) };
let layout_node = ThreadSafeLayoutNode::new(&node); let layout_node = ThreadSafeLayoutNode::new(&node);
let layout_node = match pseudo { let layout_node = match pseudo {
@ -1063,14 +1063,14 @@ impl LayoutTask {
fn handle_reflow<'a, 'b>(&mut self, fn handle_reflow<'a, 'b>(&mut self,
data: &ScriptReflow, data: &ScriptReflow,
possibly_locked_rw_data: &mut RwData<'a, 'b>) { possibly_locked_rw_data: &mut RwData<'a, 'b>) {
let document = unsafe { LayoutNode::new(&data.document) }; let document = unsafe { ServoLayoutNode::new(&data.document) };
let document = document.as_document().unwrap(); let document = document.as_document().unwrap();
debug!("layout: received layout request for: {}", self.url.serialize()); debug!("layout: received layout request for: {}", self.url.serialize());
let mut rw_data = possibly_locked_rw_data.lock(); let mut rw_data = possibly_locked_rw_data.lock();
let node: LayoutNode = match document.root_node() { let node: ServoLayoutNode = match document.root_node() {
None => { None => {
// Since we cannot compute anything, give spec-required placeholders. // Since we cannot compute anything, give spec-required placeholders.
debug!("layout: No root node: bailing"); debug!("layout: No root node: bailing");
@ -1418,7 +1418,7 @@ impl LayoutTask {
} }
} }
unsafe fn dirty_all_nodes(node: LayoutNode) { unsafe fn dirty_all_nodes(node: ServoLayoutNode) {
for node in node.traverse_preorder() { for node in node.traverse_preorder() {
// TODO(cgaebel): mark nodes which are sensitive to media queries as // TODO(cgaebel): mark nodes which are sensitive to media queries as
// "changed": // "changed":

View file

@ -23,7 +23,7 @@ use traversal::{PostorderDomTraversal, PreorderDomTraversal};
use util::opts; use util::opts;
use util::workqueue::{WorkQueue, WorkUnit, WorkerProxy}; use util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
use wrapper::UnsafeLayoutNode; use wrapper::UnsafeLayoutNode;
use wrapper::{LayoutNode, LayoutNodeTrait, layout_node_from_unsafe_layout_node, layout_node_to_unsafe_layout_node}; use wrapper::{ServoLayoutNode, LayoutNodeTrait, layout_node_from_unsafe_layout_node, layout_node_to_unsafe_layout_node};
const CHUNK_SIZE: usize = 64; const CHUNK_SIZE: usize = 64;
@ -103,7 +103,7 @@ pub trait ParallelPreorderDomTraversal : PreorderDomTraversal {
let mut discovered_child_nodes = Vec::new(); let mut discovered_child_nodes = Vec::new();
for unsafe_node in *unsafe_nodes.0 { for unsafe_node in *unsafe_nodes.0 {
// Get a real layout node. // Get a real layout node.
let node: LayoutNode = unsafe { let node: ServoLayoutNode = unsafe {
layout_node_from_unsafe_layout_node(&unsafe_node) layout_node_from_unsafe_layout_node(&unsafe_node)
}; };
@ -157,7 +157,7 @@ trait ParallelPostorderDomTraversal : PostorderDomTraversal {
/// fetch-and-subtract the parent's children count. /// fetch-and-subtract the parent's children count.
fn run_parallel(&self, unsafe_node: UnsafeLayoutNode) { fn run_parallel(&self, unsafe_node: UnsafeLayoutNode) {
// Get a real layout node. // Get a real layout node.
let mut node: LayoutNode = unsafe { let mut node: ServoLayoutNode = unsafe {
layout_node_from_unsafe_layout_node(&unsafe_node) layout_node_from_unsafe_layout_node(&unsafe_node)
}; };
loop { loop {
@ -440,7 +440,7 @@ fn run_queue_with_custom_work_data_type<To, F>(
queue.run(shared_layout_context); queue.run(shared_layout_context);
} }
pub fn traverse_dom_preorder(root: LayoutNode, pub fn traverse_dom_preorder(root: ServoLayoutNode,
shared_layout_context: &SharedLayoutContext, shared_layout_context: &SharedLayoutContext,
queue: &mut WorkQueue<SharedLayoutContext, WorkQueueData>) { queue: &mut WorkQueue<SharedLayoutContext, WorkQueueData>) {
run_queue_with_custom_work_data_type(queue, |queue| { run_queue_with_custom_work_data_type(queue, |queue| {

View file

@ -19,11 +19,11 @@ use traversal::{BuildDisplayList, ComputeAbsolutePositions};
use traversal::{PostorderDomTraversal, PreorderDomTraversal}; use traversal::{PostorderDomTraversal, PreorderDomTraversal};
use util::geometry::ZERO_POINT; use util::geometry::ZERO_POINT;
use util::opts; use util::opts;
use wrapper::{LayoutNode, LayoutNodeTrait}; use wrapper::{ServoLayoutNode, LayoutNodeTrait};
pub fn traverse_dom_preorder(root: LayoutNode, pub fn traverse_dom_preorder(root: ServoLayoutNode,
shared_layout_context: &SharedLayoutContext) { shared_layout_context: &SharedLayoutContext) {
fn doit(node: LayoutNode, recalc_style: RecalcStyleForNode, construct_flows: ConstructFlows) { fn doit(node: ServoLayoutNode, recalc_style: RecalcStyleForNode, construct_flows: ConstructFlows) {
recalc_style.process(node); recalc_style.process(node);
for kid in node.children() { for kid in node.children() {

View file

@ -17,7 +17,7 @@ use std::cell::RefCell;
use std::mem; use std::mem;
use util::opts; use util::opts;
use util::tid::tid; use util::tid::tid;
use wrapper::{LayoutNode, LayoutNodeTrait, layout_node_to_unsafe_layout_node}; use wrapper::{ServoLayoutNode, LayoutNodeTrait, layout_node_to_unsafe_layout_node};
use wrapper::{ThreadSafeLayoutNode, UnsafeLayoutNode}; use wrapper::{ThreadSafeLayoutNode, UnsafeLayoutNode};
/// Every time we do another layout, the old bloom filters are invalid. This is /// Every time we do another layout, the old bloom filters are invalid. This is
@ -51,7 +51,7 @@ thread_local!(
/// ///
/// If one does not exist, a new one will be made for you. If it is out of date, /// If one does not exist, a new one will be made for you. If it is out of date,
/// it will be cleared and reused. /// it will be cleared and reused.
fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, fn take_task_local_bloom_filter(parent_node: Option<ServoLayoutNode>,
root: OpaqueNode, root: OpaqueNode,
layout_context: &LayoutContext) layout_context: &LayoutContext)
-> Box<BloomFilter> { -> Box<BloomFilter> {
@ -98,7 +98,7 @@ fn put_task_local_bloom_filter(bf: Box<BloomFilter>,
/// "Ancestors" in this context is inclusive of ourselves. /// "Ancestors" in this context is inclusive of ourselves.
fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>, fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>,
mut n: LayoutNode, mut n: ServoLayoutNode,
root: OpaqueNode) { root: OpaqueNode) {
debug!("[{}] Inserting ancestors.", tid()); debug!("[{}] Inserting ancestors.", tid());
let mut ancestors = 0; let mut ancestors = 0;
@ -118,13 +118,13 @@ fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>,
/// A top-down traversal. /// A top-down traversal.
pub trait PreorderDomTraversal { pub trait PreorderDomTraversal {
/// The operation to perform. Return true to continue or false to stop. /// The operation to perform. Return true to continue or false to stop.
fn process(&self, node: LayoutNode); fn process(&self, node: ServoLayoutNode);
} }
/// A bottom-up traversal, with a optional in-order pass. /// A bottom-up traversal, with a optional in-order pass.
pub trait PostorderDomTraversal { pub trait PostorderDomTraversal {
/// The operation to perform. Return true to continue or false to stop. /// The operation to perform. Return true to continue or false to stop.
fn process(&self, node: LayoutNode); fn process(&self, node: ServoLayoutNode);
} }
/// A bottom-up, parallelizable traversal. /// A bottom-up, parallelizable traversal.
@ -144,7 +144,7 @@ pub struct RecalcStyleForNode<'a> {
impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> { impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
#[inline] #[inline]
#[allow(unsafe_code)] #[allow(unsafe_code)]
fn process(&self, node: LayoutNode) { fn process(&self, node: ServoLayoutNode) {
// Initialize layout data. // Initialize layout data.
// //
// FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML // FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML
@ -249,7 +249,7 @@ pub struct ConstructFlows<'a> {
impl<'a> PostorderDomTraversal for ConstructFlows<'a> { impl<'a> PostorderDomTraversal for ConstructFlows<'a> {
#[inline] #[inline]
#[allow(unsafe_code)] #[allow(unsafe_code)]
fn process(&self, node: LayoutNode) { fn process(&self, node: ServoLayoutNode) {
// Construct flows for this node. // Construct flows for this node.
{ {
let tnode = ThreadSafeLayoutNode::new(&node); let tnode = ThreadSafeLayoutNode::new(&node);

View file

@ -230,13 +230,13 @@ pub struct ServoWrapperTypes<'a> {
} }
impl<'a> WrapperTypes<'a> for ServoWrapperTypes<'a> { impl<'a> WrapperTypes<'a> for ServoWrapperTypes<'a> {
type Node = LayoutNode<'a>; type Node = ServoLayoutNode<'a>;
type Element = LayoutElement<'a>; type Element = ServoLayoutElement<'a>;
type Document = LayoutDocument<'a>; type Document = ServoLayoutDocument<'a>;
} }
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct LayoutNode<'a> { pub struct ServoLayoutNode<'a> {
/// The wrapped node. /// The wrapped node.
node: LayoutJS<Node>, node: LayoutJS<Node>,
@ -244,35 +244,35 @@ pub struct LayoutNode<'a> {
chain: PhantomData<&'a ()>, chain: PhantomData<&'a ()>,
} }
impl<'a> PartialEq for LayoutNode<'a> { impl<'a> PartialEq for ServoLayoutNode<'a> {
#[inline] #[inline]
fn eq(&self, other: &LayoutNode) -> bool { fn eq(&self, other: &ServoLayoutNode) -> bool {
self.node == other.node self.node == other.node
} }
} }
impl<'ln> LayoutNode<'ln> { impl<'ln> ServoLayoutNode<'ln> {
fn from_layout_js(n: LayoutJS<Node>) -> LayoutNode<'ln> { fn from_layout_js(n: LayoutJS<Node>) -> ServoLayoutNode<'ln> {
LayoutNode { ServoLayoutNode {
node: n, node: n,
chain: PhantomData, chain: PhantomData,
} }
} }
pub unsafe fn new(address: &TrustedNodeAddress) -> LayoutNode { pub unsafe fn new(address: &TrustedNodeAddress) -> ServoLayoutNode {
LayoutNode::from_layout_js(LayoutJS::from_trusted_node_address(*address)) ServoLayoutNode::from_layout_js(LayoutJS::from_trusted_node_address(*address))
} }
/// Creates a new layout node with the same lifetime as this layout node. /// Creates a new layout node with the same lifetime as this layout node.
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> LayoutNode<'ln> { pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> ServoLayoutNode<'ln> {
LayoutNode { ServoLayoutNode {
node: *node, node: *node,
chain: self.chain, chain: self.chain,
} }
} }
} }
impl<'ln> LayoutNodeTrait<'ln, ServoWrapperTypes<'ln>> for LayoutNode<'ln> { impl<'ln> LayoutNodeTrait<'ln, ServoWrapperTypes<'ln>> for ServoLayoutNode<'ln> {
fn type_id(&self) -> NodeTypeId { fn type_id(&self) -> NodeTypeId {
unsafe { unsafe {
self.node.type_id_for_layout() self.node.type_id_for_layout()
@ -322,7 +322,7 @@ impl<'ln> LayoutNodeTrait<'ln, ServoWrapperTypes<'ln>> for LayoutNode<'ln> {
} }
} }
fn layout_parent_node(self, reflow_root: OpaqueNode) -> Option<LayoutNode<'ln>> { fn layout_parent_node(self, reflow_root: OpaqueNode) -> Option<ServoLayoutNode<'ln>> {
if self.opaque() == reflow_root { if self.opaque() == reflow_root {
None None
} else { } else {
@ -338,12 +338,12 @@ impl<'ln> LayoutNodeTrait<'ln, ServoWrapperTypes<'ln>> for LayoutNode<'ln> {
unsafe { self.node.children_count() } unsafe { self.node.children_count() }
} }
fn as_element(&self) -> Option<LayoutElement<'ln>> { fn as_element(&self) -> Option<ServoLayoutElement<'ln>> {
as_element(self.node) as_element(self.node)
} }
fn as_document(&self) -> Option<LayoutDocument<'ln>> { fn as_document(&self) -> Option<ServoLayoutDocument<'ln>> {
self.node.downcast().map(|document| LayoutDocument::from_layout_js(document)) self.node.downcast().map(|document| ServoLayoutDocument::from_layout_js(document))
} }
fn has_changed(&self) -> bool { fn has_changed(&self) -> bool {
@ -386,38 +386,38 @@ impl<'ln> LayoutNodeTrait<'ln, ServoWrapperTypes<'ln>> for LayoutNode<'ln> {
} }
} }
fn parent_node(&self) -> Option<LayoutNode<'ln>> { fn parent_node(&self) -> Option<ServoLayoutNode<'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))
} }
} }
fn first_child(&self) -> Option<LayoutNode<'ln>> { fn first_child(&self) -> Option<ServoLayoutNode<'ln>> {
unsafe { unsafe {
self.node.first_child_ref().map(|node| self.new_with_this_lifetime(&node)) self.node.first_child_ref().map(|node| self.new_with_this_lifetime(&node))
} }
} }
fn last_child(&self) -> Option<LayoutNode<'ln>> { fn last_child(&self) -> Option<ServoLayoutNode<'ln>> {
unsafe { unsafe {
self.node.last_child_ref().map(|node| self.new_with_this_lifetime(&node)) self.node.last_child_ref().map(|node| self.new_with_this_lifetime(&node))
} }
} }
fn prev_sibling(&self) -> Option<LayoutNode<'ln>> { fn prev_sibling(&self) -> Option<ServoLayoutNode<'ln>> {
unsafe { unsafe {
self.node.prev_sibling_ref().map(|node| self.new_with_this_lifetime(&node)) self.node.prev_sibling_ref().map(|node| self.new_with_this_lifetime(&node))
} }
} }
fn next_sibling(&self) -> Option<LayoutNode<'ln>> { fn next_sibling(&self) -> Option<ServoLayoutNode<'ln>> {
unsafe { unsafe {
self.node.next_sibling_ref().map(|node| self.new_with_this_lifetime(&node)) self.node.next_sibling_ref().map(|node| self.new_with_this_lifetime(&node))
} }
} }
} }
impl<'ln> LayoutNode<'ln> { impl<'ln> ServoLayoutNode<'ln> {
fn dump_indent(self, indent: u32) { fn dump_indent(self, indent: u32) {
let mut s = String::new(); let mut s = String::new();
for _ in 0..indent { for _ in 0..indent {
@ -503,29 +503,29 @@ impl<'a, Wrappers> Iterator for LayoutTreeIterator<'a, Wrappers> where Wrappers:
// A wrapper around documents that ensures ayout can only ever access safe properties. // A wrapper around documents that ensures ayout can only ever access safe properties.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct LayoutDocument<'ld> { pub struct ServoLayoutDocument<'ld> {
document: LayoutJS<Document>, document: LayoutJS<Document>,
chain: PhantomData<&'ld ()>, chain: PhantomData<&'ld ()>,
} }
impl<'ld> LayoutDocumentTrait<'ld, ServoWrapperTypes<'ld>> for LayoutDocument<'ld> { impl<'ld> LayoutDocumentTrait<'ld, ServoWrapperTypes<'ld>> for ServoLayoutDocument<'ld> {
fn as_node(&self) -> LayoutNode<'ld> { fn as_node(&self) -> ServoLayoutNode<'ld> {
LayoutNode::from_layout_js(self.document.upcast()) ServoLayoutNode::from_layout_js(self.document.upcast())
} }
fn root_node(&self) -> Option<LayoutNode<'ld>> { fn root_node(&self) -> Option<ServoLayoutNode<'ld>> {
self.as_node().children().find(LayoutNode::is_element) self.as_node().children().find(ServoLayoutNode::is_element)
} }
fn drain_modified_elements(&self) -> Vec<(LayoutElement<'ld>, ElementSnapshot)> { fn drain_modified_elements(&self) -> Vec<(ServoLayoutElement<'ld>, ElementSnapshot)> {
let elements = unsafe { self.document.drain_modified_elements() }; let elements = unsafe { self.document.drain_modified_elements() };
elements.into_iter().map(|(el, snapshot)| (LayoutElement::from_layout_js(el), snapshot)).collect() elements.into_iter().map(|(el, snapshot)| (ServoLayoutElement::from_layout_js(el), snapshot)).collect()
} }
} }
impl<'ld> LayoutDocument<'ld> { impl<'ld> ServoLayoutDocument<'ld> {
fn from_layout_js(doc: LayoutJS<Document>) -> LayoutDocument<'ld> { fn from_layout_js(doc: LayoutJS<Document>) -> ServoLayoutDocument<'ld> {
LayoutDocument { ServoLayoutDocument {
document: doc, document: doc,
chain: PhantomData, chain: PhantomData,
} }
@ -534,14 +534,14 @@ impl<'ld> LayoutDocument<'ld> {
/// A wrapper around elements that ensures layout can only ever access safe properties. /// A wrapper around elements that ensures layout can only ever access safe properties.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct LayoutElement<'le> { pub struct ServoLayoutElement<'le> {
element: LayoutJS<Element>, element: LayoutJS<Element>,
chain: PhantomData<&'le ()>, chain: PhantomData<&'le ()>,
} }
impl<'le> LayoutElementTrait<'le, ServoWrapperTypes<'le>> for LayoutElement<'le> { impl<'le> LayoutElementTrait<'le, ServoWrapperTypes<'le>> for ServoLayoutElement<'le> {
fn as_node(&self) -> LayoutNode<'le> { fn as_node(&self) -> ServoLayoutNode<'le> {
LayoutNode::from_layout_js(self.element.upcast()) ServoLayoutNode::from_layout_js(self.element.upcast())
} }
fn style_attribute(&self) -> &'le Option<PropertyDeclarationBlock> { fn style_attribute(&self) -> &'le Option<PropertyDeclarationBlock> {
@ -556,17 +556,17 @@ impl<'le> LayoutElementTrait<'le, ServoWrapperTypes<'le>> for LayoutElement<'le>
} }
impl<'le> LayoutElement<'le> { impl<'le> ServoLayoutElement<'le> {
fn from_layout_js(el: LayoutJS<Element>) -> LayoutElement<'le> { fn from_layout_js(el: LayoutJS<Element>) -> ServoLayoutElement<'le> {
LayoutElement { ServoLayoutElement {
element: el, element: el,
chain: PhantomData, chain: PhantomData,
} }
} }
} }
fn as_element<'le>(node: LayoutJS<Node>) -> Option<LayoutElement<'le>> { fn as_element<'le>(node: LayoutJS<Node>) -> Option<ServoLayoutElement<'le>> {
node.downcast().map(|element| LayoutElement::from_layout_js(element)) node.downcast().map(|element| ServoLayoutElement::from_layout_js(element))
} }
macro_rules! state_getter { macro_rules! state_getter {
@ -579,22 +579,22 @@ macro_rules! state_getter {
} }
} }
impl<'le> ::selectors::Element for LayoutElement<'le> { impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
fn parent_element(&self) -> Option<LayoutElement<'le>> { fn parent_element(&self) -> Option<ServoLayoutElement<'le>> {
unsafe { unsafe {
self.element.upcast().parent_node_ref().and_then(as_element) self.element.upcast().parent_node_ref().and_then(as_element)
} }
} }
fn first_child_element(&self) -> Option<LayoutElement<'le>> { fn first_child_element(&self) -> Option<ServoLayoutElement<'le>> {
self.as_node().children().filter_map(|n| n.as_element()).next() self.as_node().children().filter_map(|n| n.as_element()).next()
} }
fn last_child_element(&self) -> Option<LayoutElement<'le>> { fn last_child_element(&self) -> Option<ServoLayoutElement<'le>> {
self.as_node().rev_children().filter_map(|n| n.as_element()).next() self.as_node().rev_children().filter_map(|n| n.as_element()).next()
} }
fn prev_sibling_element(&self) -> Option<LayoutElement<'le>> { fn prev_sibling_element(&self) -> Option<ServoLayoutElement<'le>> {
let mut node = self.as_node(); let mut node = self.as_node();
while let Some(sibling) = node.prev_sibling() { while let Some(sibling) = node.prev_sibling() {
if let Some(element) = sibling.as_element() { if let Some(element) = sibling.as_element() {
@ -605,7 +605,7 @@ impl<'le> ::selectors::Element for LayoutElement<'le> {
None None
} }
fn next_sibling_element(&self) -> Option<LayoutElement<'le>> { fn next_sibling_element(&self) -> Option<ServoLayoutElement<'le>> {
let mut node = self.as_node(); let mut node = self.as_node();
while let Some(sibling) = node.next_sibling() { while let Some(sibling) = node.next_sibling() {
if let Some(element) = sibling.as_element() { if let Some(element) = sibling.as_element() {
@ -732,7 +732,7 @@ impl<'le> ::selectors::Element for LayoutElement<'le> {
} }
} }
impl<'le> TElementAttributes for LayoutElement<'le> { impl<'le> TElementAttributes for ServoLayoutElement<'le> {
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V) fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
where V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>> where V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>
{ {
@ -785,7 +785,7 @@ impl<T> PseudoElementType<T> {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct ThreadSafeLayoutNode<'ln> { pub struct ThreadSafeLayoutNode<'ln> {
/// The wrapped node. /// The wrapped node.
node: LayoutNode<'ln>, node: ServoLayoutNode<'ln>,
pseudo: PseudoElementType<display::T>, pseudo: PseudoElementType<display::T>,
} }
@ -800,7 +800,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
} }
/// Creates a new `ThreadSafeLayoutNode` from the given `LayoutNode`. /// Creates a new `ThreadSafeLayoutNode` from the given `LayoutNode`.
pub fn new<'a>(node: &LayoutNode<'a>) -> ThreadSafeLayoutNode<'a> { pub fn new<'a>(node: &ServoLayoutNode<'a>) -> ThreadSafeLayoutNode<'a> {
ThreadSafeLayoutNode { ThreadSafeLayoutNode {
node: node.clone(), node: node.clone(),
pseudo: PseudoElementType::Normal, pseudo: PseudoElementType::Normal,
@ -1204,14 +1204,14 @@ impl<'le> ThreadSafeLayoutElement<'le> {
/// Must be transmutable to and from LayoutNode. /// Must be transmutable to and from LayoutNode.
pub type UnsafeLayoutNode = (usize, usize); pub type UnsafeLayoutNode = (usize, usize);
pub fn layout_node_to_unsafe_layout_node(node: &LayoutNode) -> UnsafeLayoutNode { pub fn layout_node_to_unsafe_layout_node(node: &ServoLayoutNode) -> UnsafeLayoutNode {
unsafe { unsafe {
let ptr: usize = mem::transmute_copy(node); let ptr: usize = mem::transmute_copy(node);
(ptr, 0) (ptr, 0)
} }
} }
pub unsafe fn layout_node_from_unsafe_layout_node(node: &UnsafeLayoutNode) -> LayoutNode { pub unsafe fn layout_node_from_unsafe_layout_node(node: &UnsafeLayoutNode) -> ServoLayoutNode {
let (node, _) = *node; let (node, _) = *node;
mem::transmute(node) mem::transmute(node)
} }