aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/construct.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2015-08-14 14:34:13 +0200
committerSimon Sapin <simon.sapin@exyr.org>2015-08-20 16:49:48 +0200
commit649250130b221685dfa8e570ae07d0d2f634bd40 (patch)
tree13d4a188e49d12874824f1c7ce98725846baf126 /components/layout/construct.rs
parent2d22aa8e7e99ef52198e0f5918a2a16483aaba0e (diff)
downloadservo-649250130b221685dfa8e570ae07d0d2f634bd40.tar.gz
servo-649250130b221685dfa8e570ae07d0d2f634bd40.zip
Replace FlowRef with Arc<Flow>, now that Arc supports DST.
… and WeakFlowRef with Weak<Flow>.
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r--components/layout/construct.rs60
1 files changed, 27 insertions, 33 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index e726f687beb..fe41ee5b922 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -375,7 +375,7 @@ impl<'a> FlowConstructor<'a> {
style,
child_node.restyle_damage(),
SpecificFragmentInfo::TableRow);
- let mut new_child = FlowRef::new(box TableRowFlow::from_fragment(fragment));
+ let mut new_child: FlowRef = Arc::new(TableRowFlow::from_fragment(fragment));
new_child.add_new_child(child.clone());
child.finish();
*child = new_child
@@ -388,7 +388,7 @@ impl<'a> FlowConstructor<'a> {
style,
child_node.restyle_damage(),
SpecificFragmentInfo::Table);
- let mut new_child = FlowRef::new(box TableFlow::from_fragment(fragment));
+ let mut new_child: FlowRef = Arc::new(TableFlow::from_fragment(fragment));
new_child.add_new_child(child.clone());
child.finish();
*child = new_child
@@ -402,7 +402,7 @@ impl<'a> FlowConstructor<'a> {
style,
child_node.restyle_damage(),
SpecificFragmentInfo::TableWrapper);
- let mut new_child = FlowRef::new(box TableWrapperFlow::from_fragment(fragment, None));
+ let mut new_child: FlowRef = Arc::new(TableWrapperFlow::from_fragment(fragment, None));
new_child.add_new_child(child.clone());
child.finish();
*child = new_child
@@ -457,9 +457,8 @@ impl<'a> FlowConstructor<'a> {
let scanned_fragments =
TextRunScanner::new().scan_for_runs(&mut self.layout_context.font_context(),
fragments.fragments);
- let mut inline_flow_ref =
- FlowRef::new(box InlineFlow::from_fragments(scanned_fragments,
- node.style().writing_mode));
+ let mut inline_flow_ref: FlowRef = Arc::new(
+ InlineFlow::from_fragments(scanned_fragments, node.style().writing_mode));
// Add all the inline-block fragments as children of the inline flow.
for inline_block_flow in &inline_block_flows {
@@ -753,12 +752,12 @@ impl<'a> FlowConstructor<'a> {
fn build_flow_for_block(&mut self, node: &ThreadSafeLayoutNode, float_kind: Option<FloatKind>)
-> ConstructionResult {
let fragment = self.build_fragment_for_block(node);
- let flow = if node.style().is_multicol() {
- box MulticolFlow::from_fragment(fragment, float_kind) as Box<Flow>
+ let flow: FlowRef = if node.style().is_multicol() {
+ Arc::new(MulticolFlow::from_fragment(fragment, float_kind))
} else {
- box BlockFlow::from_fragment(fragment, float_kind) as Box<Flow>
+ Arc::new(BlockFlow::from_fragment(fragment, float_kind))
};
- self.build_flow_for_block_like(FlowRef::new(flow), node)
+ self.build_flow_for_block_like(flow, node)
}
/// Bubbles up {ib} splits.
@@ -1072,13 +1071,11 @@ impl<'a> FlowConstructor<'a> {
fn build_flow_for_table_wrapper(&mut self, node: &ThreadSafeLayoutNode, float_value: float::T)
-> ConstructionResult {
let fragment = Fragment::new(node, SpecificFragmentInfo::TableWrapper);
- let wrapper_flow =
- box TableWrapperFlow::from_fragment(fragment, FloatKind::from_property(float_value));
- let mut wrapper_flow = FlowRef::new(wrapper_flow as Box<Flow>);
+ let mut wrapper_flow: FlowRef = Arc::new(
+ TableWrapperFlow::from_fragment(fragment, FloatKind::from_property(float_value)));
let table_fragment = Fragment::new(node, SpecificFragmentInfo::Table);
- let table_flow = box TableFlow::from_fragment(table_fragment);
- let table_flow = FlowRef::new(table_flow as Box<Flow>);
+ let table_flow = Arc::new(TableFlow::from_fragment(table_fragment));
// First populate the table flow with its children.
let construction_result = self.build_flow_for_block_like(table_flow, node);
@@ -1135,8 +1132,8 @@ impl<'a> FlowConstructor<'a> {
/// with possibly other `BlockFlow`s or `InlineFlow`s underneath it.
fn build_flow_for_table_caption(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
let fragment = self.build_fragment_for_block(node);
- let flow = box TableCaptionFlow::from_fragment(fragment) as Box<Flow>;
- self.build_flow_for_block_like(FlowRef::new(flow), node)
+ let flow = Arc::new(TableCaptionFlow::from_fragment(fragment));
+ self.build_flow_for_block_like(flow, node)
}
/// Builds a flow for a node with `display: table-row-group`. This yields a `TableRowGroupFlow`
@@ -1144,16 +1141,16 @@ impl<'a> FlowConstructor<'a> {
fn build_flow_for_table_rowgroup(&mut self, node: &ThreadSafeLayoutNode)
-> ConstructionResult {
let fragment = Fragment::new(node, SpecificFragmentInfo::TableRow);
- let flow = box TableRowGroupFlow::from_fragment(fragment) as Box<Flow>;
- self.build_flow_for_block_like(FlowRef::new(flow), node)
+ let flow = Arc::new(TableRowGroupFlow::from_fragment(fragment));
+ self.build_flow_for_block_like(flow, node)
}
/// Builds a flow for a node with `display: table-row`. This yields a `TableRowFlow` with
/// possibly other `TableCellFlow`s underneath it.
fn build_flow_for_table_row(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
let fragment = Fragment::new(node, SpecificFragmentInfo::TableRow);
- let flow = box TableRowFlow::from_fragment(fragment) as Box<Flow>;
- self.build_flow_for_block_like(FlowRef::new(flow), node)
+ let flow = Arc::new(TableRowFlow::from_fragment(fragment));
+ self.build_flow_for_block_like(flow, node)
}
/// Builds a flow for a node with `display: table-cell`. This yields a `TableCellFlow` with
@@ -1172,9 +1169,9 @@ impl<'a> FlowConstructor<'a> {
position == position::T::fixed
});
- let flow = box TableCellFlow::from_node_fragment_and_visibility_flag(node, fragment, !hide)
- as Box<Flow>;
- self.build_flow_for_block_like(FlowRef::new(flow), node)
+ let flow = Arc::new(
+ TableCellFlow::from_node_fragment_and_visibility_flag(node, fragment, !hide));
+ self.build_flow_for_block_like(flow, node)
}
/// Builds a flow for a node with `display: list-item`. This yields a `ListItemFlow` with
@@ -1222,21 +1219,19 @@ impl<'a> FlowConstructor<'a> {
let main_fragment = self.build_fragment_for_block(node);
let flow = match node.style().get_list().list_style_position {
list_style_position::T::outside => {
- box ListItemFlow::from_fragments_and_flotation(main_fragment,
- marker_fragments,
- flotation)
+ Arc::new(ListItemFlow::from_fragments_and_flotation(
+ main_fragment, marker_fragments, flotation))
}
list_style_position::T::inside => {
for marker_fragment in marker_fragments {
initial_fragments.fragments.push_back(marker_fragment)
}
- box ListItemFlow::from_fragments_and_flotation(main_fragment, vec![], flotation)
+ Arc::new(ListItemFlow::from_fragments_and_flotation(
+ main_fragment, vec![], flotation))
}
};
- self.build_flow_for_block_starting_with_fragments(FlowRef::new(flow as Box<Flow>),
- node,
- initial_fragments)
+ self.build_flow_for_block_starting_with_fragments(flow, node, initial_fragments)
}
/// Creates a fragment for a node with `display: table-column`.
@@ -1277,8 +1272,7 @@ impl<'a> FlowConstructor<'a> {
let specific = SpecificFragmentInfo::TableColumn(TableColumnFragmentInfo::new(node));
col_fragments.push(Fragment::new(node, specific));
}
- let flow = box TableColGroupFlow::from_fragments(fragment, col_fragments);
- let mut flow = FlowRef::new(flow as Box<Flow>);
+ let mut flow: FlowRef = Arc::new(TableColGroupFlow::from_fragments(fragment, col_fragments));
flow.finish();
ConstructionResult::Flow(flow, AbsoluteDescendants::new())