diff options
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r-- | components/layout/construct.rs | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index eb90fbf734e..9e14e2244ab 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -31,7 +31,7 @@ use fragment::TableColumnFragmentInfo; use fragment::UnscannedTextFragmentInfo; use incremental::{RECONSTRUCT_FLOW, RestyleDamage}; use inline::InlineFlow; -use list_item::{mod, ListItemFlow}; +use list_item::{self, ListItemFlow}; use parallel; use table_wrapper::TableWrapperFlow; use table::TableFlow; @@ -50,17 +50,18 @@ use script::dom::htmlelement::HTMLElementTypeId; use script::dom::htmlobjectelement::is_image_data; use script::dom::node::NodeTypeId; use servo_util::opts; +use std::borrow::ToOwned; use std::collections::DList; use std::mem; -use std::sync::atomic::Relaxed; +use std::sync::atomic::Ordering; use style::computed_values::{caption_side, display, empty_cells, float, list_style_position}; use style::computed_values::{position}; -use style::{mod, ComputedValues}; +use style::{self, ComputedValues}; use std::sync::Arc; use url::Url; /// The results of flow construction for a DOM node. -#[deriving(Clone)] +#[derive(Clone)] pub enum ConstructionResult { /// This node contributes nothing at all (`display: none`). Alternately, this is what newly /// created nodes have their `ConstructionResult` set to. @@ -89,7 +90,7 @@ impl ConstructionResult { match self { &ConstructionResult::None => 0u, &ConstructionResult::ConstructionItem(_) => 0u, - &ConstructionResult::Flow(ref flow_ref, _) => flow::base(flow_ref.deref()).debug_id(), + &ConstructionResult::Flow(ref flow_ref, _) => flow::base(&**flow_ref).debug_id(), } } } @@ -97,7 +98,7 @@ impl ConstructionResult { /// Represents the output of flow construction for a DOM node that has not yet resulted in a /// complete flow. Construction items bubble up the tree until they find a `Flow` to be attached /// to. -#[deriving(Clone)] +#[derive(Clone)] pub enum ConstructionItem { /// Inline fragments and associated {ib} splits that have not yet found flows. InlineFragments(InlineFragmentsConstructionResult), @@ -108,7 +109,7 @@ pub enum ConstructionItem { } /// Represents inline fragments and {ib} splits that are bubbling up from an inline. -#[deriving(Clone)] +#[derive(Clone)] pub struct InlineFragmentsConstructionResult { /// Any {ib} splits that we're bubbling up. pub splits: DList<InlineBlockSplit>, @@ -146,7 +147,7 @@ pub struct InlineFragmentsConstructionResult { /// C /// ]) /// ``` -#[deriving(Clone)] +#[derive(Clone)] pub struct InlineBlockSplit { /// The inline fragments that precede the flow. pub predecessors: DList<Fragment>, @@ -221,8 +222,8 @@ pub struct FlowConstructor<'a> { impl<'a> FlowConstructor<'a> { /// Creates a new flow constructor. - pub fn new<'a>(layout_context: &'a LayoutContext<'a>) - -> FlowConstructor<'a> { + pub fn new<'b>(layout_context: &'b LayoutContext<'b>) + -> FlowConstructor<'b> { FlowConstructor { layout_context: layout_context, } @@ -375,7 +376,7 @@ impl<'a> FlowConstructor<'a> { ConstructionResult::Flow(kid_flow, kid_abs_descendants) => { // If kid_flow is TableCaptionFlow, kid_flow should be added under // TableWrapperFlow. - if flow.is_table() && kid_flow.deref().is_table_caption() { + if flow.is_table() && kid_flow.is_table_caption() { kid.set_flow_construction_result(ConstructionResult::Flow(kid_flow, Descendants::new())) } else if flow.need_anonymous_flow(&*kid_flow) { @@ -455,7 +456,7 @@ impl<'a> FlowConstructor<'a> { // Add whitespace results. They will be stripped out later on when // between block elements, and retained when between inline elements. let fragment_info = - SpecificFragmentInfo::UnscannedText(UnscannedTextFragmentInfo::from_text(" ".into_string())); + SpecificFragmentInfo::UnscannedText(UnscannedTextFragmentInfo::from_text(" ".to_owned())); let fragment = Fragment::from_opaque_node_and_style(whitespace_node, whitespace_style, whitespace_damage, @@ -652,7 +653,7 @@ impl<'a> FlowConstructor<'a> { whitespace_damage)) => { // Instantiate the whitespace fragment. let fragment_info = SpecificFragmentInfo::UnscannedText(UnscannedTextFragmentInfo::from_text( - " ".into_string())); + " ".to_owned())); let fragment = Fragment::from_opaque_node_and_style(whitespace_node, whitespace_style, whitespace_damage, @@ -814,7 +815,7 @@ impl<'a> FlowConstructor<'a> { for kid in node.children() { match kid.swap_out_construction_result() { ConstructionResult::Flow(mut kid_flow, _) => { - if kid_flow.deref().is_table_caption() && + if kid_flow.is_table_caption() && kid_flow.as_block() .fragment .style() @@ -986,7 +987,7 @@ impl<'a> FlowConstructor<'a> { .list_style_type) { None => None, Some(text) => { - let text = text.into_string(); + let text = text.to_owned(); let mut unscanned_marker_fragments = DList::new(); unscanned_marker_fragments.push_back(Fragment::new_from_specific_info( node, @@ -1149,7 +1150,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> { } }; - debug!("building flow for node: {} {} {}", display, float, node.type_id()); + debug!("building flow for node: {:?} {:?} {:?}", display, float, node.type_id()); // Switch on display and floatedness. match (display, float, positioning) { @@ -1376,15 +1377,15 @@ impl FlowConstructionUtils for FlowRef { /// /// This must not be public because only the layout constructor can do this. fn add_new_child(&mut self, mut new_child: FlowRef) { - let base = flow::mut_base(self.deref_mut()); + let base = flow::mut_base(&mut **self); { - let kid_base = flow::mut_base(new_child.deref_mut()); + let kid_base = flow::mut_base(&mut *new_child); kid_base.parallel.parent = parallel::mut_owned_flow_to_unsafe_flow(self); } base.children.push_back(new_child); - let _ = base.parallel.children_count.fetch_add(1, Relaxed); + let _ = base.parallel.children_count.fetch_add(1, Ordering::Relaxed); } /// Finishes a flow. Once a flow is finished, no more child flows or fragments may be added to |