mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
auto merge of #2097 : SimonSapin/servo/pseudo-cleanup, r=pcwalton
This commit is contained in:
commit
0616297c46
3 changed files with 19 additions and 33 deletions
|
@ -25,7 +25,7 @@ impl<'ln> NodeUtil for ThreadSafeLayoutNode<'ln> {
|
|||
fn get_css_select_results<'a>(&'a self) -> &'a Arc<ComputedValues> {
|
||||
unsafe {
|
||||
let layout_data_ref = self.borrow_layout_data();
|
||||
match self.get_element_type() {
|
||||
match self.get_pseudo_element_type() {
|
||||
Before | BeforeBlock => {
|
||||
cast::transmute_region(layout_data_ref.as_ref()
|
||||
.unwrap()
|
||||
|
|
|
@ -487,7 +487,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
// List of absolute descendants, in tree order.
|
||||
let mut abs_descendants = Descendants::new();
|
||||
for kid in node.children() {
|
||||
if kid.get_element_type() != Normal {
|
||||
if kid.get_pseudo_element_type() != Normal {
|
||||
self.process(&kid);
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
|
||||
// Concatenate all the boxes of our kids, creating {ib} splits as necessary.
|
||||
for kid in node.children() {
|
||||
if kid.get_element_type() != Normal {
|
||||
if kid.get_pseudo_element_type() != Normal {
|
||||
self.process(&kid);
|
||||
}
|
||||
match kid.swap_out_construction_result() {
|
||||
|
@ -1127,7 +1127,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
|||
let mut layout_data_ref = self.mutate_layout_data();
|
||||
match &mut *layout_data_ref {
|
||||
&Some(ref mut layout_data) =>{
|
||||
match self.get_element_type() {
|
||||
match self.get_pseudo_element_type() {
|
||||
Before | BeforeBlock => {
|
||||
layout_data.data.before_flow_construction_result = result
|
||||
},
|
||||
|
@ -1146,7 +1146,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
|||
let mut layout_data_ref = self.mutate_layout_data();
|
||||
match &mut *layout_data_ref {
|
||||
&Some(ref mut layout_data) => {
|
||||
match self.get_element_type() {
|
||||
match self.get_pseudo_element_type() {
|
||||
Before | BeforeBlock => {
|
||||
mem::replace(&mut layout_data.data.before_flow_construction_result,
|
||||
NoConstructionResult)
|
||||
|
|
|
@ -396,7 +396,7 @@ fn get_content(content_list: &content::T) -> ~str {
|
|||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
pub enum ElementType {
|
||||
pub enum PseudoElementType {
|
||||
Normal,
|
||||
Before,
|
||||
After,
|
||||
|
@ -406,11 +406,12 @@ pub enum ElementType {
|
|||
|
||||
/// A thread-safe version of `LayoutNode`, used during flow construction. This type of layout
|
||||
/// node does not allow any parents or siblings of nodes to be accessed, to avoid races.
|
||||
#[deriving(Clone)]
|
||||
pub struct ThreadSafeLayoutNode<'ln> {
|
||||
/// The wrapped node.
|
||||
priv node: LayoutNode<'ln>,
|
||||
|
||||
priv pseudo: ElementType,
|
||||
priv pseudo: PseudoElementType,
|
||||
}
|
||||
|
||||
impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
|
||||
|
@ -449,10 +450,10 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
|
|||
|
||||
if self.has_before_pseudo() {
|
||||
if self.is_block(Before) && self.pseudo == Normal {
|
||||
let pseudo_before_node = ThreadSafeLayoutNode::new_with_pseudo_without_self(&self.node, BeforeBlock);
|
||||
let pseudo_before_node = self.with_pseudo(BeforeBlock);
|
||||
return Some(pseudo_before_node)
|
||||
} else if self.pseudo == Normal || self.pseudo == BeforeBlock {
|
||||
let pseudo_before_node = ThreadSafeLayoutNode::new_with_pseudo_without_self(&self.node, Before);
|
||||
let pseudo_before_node = self.with_pseudo(Before);
|
||||
return Some(pseudo_before_node)
|
||||
}
|
||||
}
|
||||
|
@ -486,14 +487,6 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'ln> Clone for ThreadSafeLayoutNode<'ln> {
|
||||
fn clone(&self) -> ThreadSafeLayoutNode<'ln> {
|
||||
ThreadSafeLayoutNode {
|
||||
node: self.node.clone(),
|
||||
pseudo: self.pseudo,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||
/// Creates a new `ThreadSafeLayoutNode` from the given `LayoutNode`.
|
||||
|
@ -504,19 +497,12 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_with_pseudo_without_self<'a>(node: &LayoutNode<'a>, element_type: ElementType) -> ThreadSafeLayoutNode<'a> {
|
||||
ThreadSafeLayoutNode {
|
||||
node: node.clone(),
|
||||
pseudo: element_type,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Creates a new `ThreadSafeLayoutNode` from the given `LayoutNode`.
|
||||
pub fn new_with_pseudo<'a>(&'a self, element_type: ElementType) -> ThreadSafeLayoutNode<'a> {
|
||||
/// Creates a new `ThreadSafeLayoutNode` for the same `LayoutNode`
|
||||
/// with a different pseudo-element type.
|
||||
pub fn with_pseudo(&self, pseudo: PseudoElementType) -> ThreadSafeLayoutNode<'ln> {
|
||||
ThreadSafeLayoutNode {
|
||||
node: self.node.clone(),
|
||||
pseudo: element_type,
|
||||
pseudo: pseudo,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -533,7 +519,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
pub fn children(&self) -> ThreadSafeLayoutNodeChildrenIterator<'ln> {
|
||||
ThreadSafeLayoutNodeChildrenIterator {
|
||||
current_node: self.first_child(),
|
||||
parent_node: Some(ThreadSafeLayoutNode::new_with_pseudo_without_self(&self.node, self.pseudo)),
|
||||
parent_node: Some(self.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -551,11 +537,11 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_element_type(&self) -> ElementType {
|
||||
pub fn get_pseudo_element_type(&self) -> PseudoElementType {
|
||||
self.pseudo
|
||||
}
|
||||
|
||||
pub fn is_block(&self, kind: ElementType) -> bool {
|
||||
pub fn is_block(&self, kind: PseudoElementType) -> bool {
|
||||
let mut layout_data_ref = self.mutate_layout_data();
|
||||
let node_layout_data_wrapper = layout_data_ref.get_mut_ref();
|
||||
|
||||
|
@ -668,10 +654,10 @@ impl<'a> Iterator<ThreadSafeLayoutNode<'a>> for ThreadSafeLayoutNodeChildrenIter
|
|||
Some(ref parent_node) => {
|
||||
if parent_node.has_after_pseudo() {
|
||||
let pseudo_after_node = if parent_node.is_block(After) && parent_node.pseudo == Normal {
|
||||
let pseudo_after_node = ThreadSafeLayoutNode::new_with_pseudo_without_self(&parent_node.node, AfterBlock);
|
||||
let pseudo_after_node = parent_node.with_pseudo(AfterBlock);
|
||||
Some(pseudo_after_node)
|
||||
} else if parent_node.pseudo == Normal || parent_node.pseudo == AfterBlock {
|
||||
let pseudo_after_node = ThreadSafeLayoutNode::new_with_pseudo_without_self(&parent_node.node, After);
|
||||
let pseudo_after_node = parent_node.with_pseudo(After);
|
||||
Some(pseudo_after_node)
|
||||
} else {
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue