From e761649cdac02ef78252592653db2d8330037434 Mon Sep 17 00:00:00 2001 From: Matt Murphy Date: Tue, 22 Apr 2014 23:26:37 -0500 Subject: [PATCH] ~[] to Vec in layout flow, block, table, row, rowgroup, wrapper --- src/components/main/layout/block.rs | 6 +-- src/components/main/layout/flow.rs | 6 +-- src/components/main/layout/table.rs | 44 ++++++++++---------- src/components/main/layout/table_row.rs | 30 ++++++------- src/components/main/layout/table_rowgroup.rs | 38 ++++++++--------- src/components/main/layout/table_wrapper.rs | 16 +++---- 6 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs index e1fd7adb8395..5e80bbcb04d8 100644 --- a/src/components/main/layout/block.rs +++ b/src/components/main/layout/block.rs @@ -1311,7 +1311,7 @@ impl BlockFlow { pub fn propagate_assigned_width_to_children(&mut self, left_content_edge: Au, content_width: Au, - opt_col_widths: Option<~[Au]>) { + opt_col_widths: Option>) { // Keep track of whether floats could impact each child. let mut left_floats_impact_child = self.base.flags.impacted_by_left_floats(); let mut right_floats_impact_child = self.base.flags.impacted_by_right_floats(); @@ -1382,7 +1382,7 @@ impl BlockFlow { propagate_column_widths_to_child(kid, i, content_width, - *col_widths, + col_widths.as_slice(), &mut left_margin_edge) } None => {} @@ -2358,7 +2358,7 @@ fn propagate_column_widths_to_child(kid: &mut Flow, // // FIXME(pcwalton): This seems inefficient. Reference count it instead? let width = if kid.is_table() || kid.is_table_rowgroup() || kid.is_table_row() { - *kid.col_widths() = column_widths.to_owned(); + *kid.col_widths() = column_widths.iter().map(|&x| x).collect(); // Width of kid flow is our content width. content_width diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs index d16fb5622a6c..f599e5f7225e 100644 --- a/src/components/main/layout/flow.rs +++ b/src/components/main/layout/flow.rs @@ -128,19 +128,19 @@ pub trait Flow { /// If this is a table row or table rowgroup or table flow, returns column widths. /// Fails otherwise. - fn col_widths<'a>(&'a mut self) -> &'a mut ~[Au] { + fn col_widths<'a>(&'a mut self) -> &'a mut Vec { fail!("called col_widths() on an other flow than table-row/table-rowgroup/table") } /// If this is a table row flow or table rowgroup flow or table flow, returns column min widths. /// Fails otherwise. - fn col_min_widths<'a>(&'a self) -> &'a ~[Au] { + fn col_min_widths<'a>(&'a self) -> &'a Vec { fail!("called col_min_widths() on an other flow than table-row/table-rowgroup/table") } /// If this is a table row flow or table rowgroup flow or table flow, returns column min widths. /// Fails otherwise. - fn col_pref_widths<'a>(&'a self) -> &'a ~[Au] { + fn col_pref_widths<'a>(&'a self) -> &'a Vec { fail!("called col_pref_widths() on an other flow than table-row/table-rowgroup/table") } diff --git a/src/components/main/layout/table.rs b/src/components/main/layout/table.rs index 67ac6bd34b55..2d18bc8fffcf 100644 --- a/src/components/main/layout/table.rs +++ b/src/components/main/layout/table.rs @@ -25,13 +25,13 @@ pub struct TableFlow { pub block_flow: BlockFlow, /// Column widths - pub col_widths: ~[Au], + pub col_widths: Vec, /// Column min widths. - pub col_min_widths: ~[Au], + pub col_min_widths: Vec, /// Column pref widths. - pub col_pref_widths: ~[Au], + pub col_pref_widths: Vec, /// Table-layout property pub table_layout: TableLayout, @@ -50,9 +50,9 @@ impl TableFlow { }; TableFlow { block_flow: block_flow, - col_widths: ~[], - col_min_widths: ~[], - col_pref_widths: ~[], + col_widths: Vec::new(), + col_min_widths: Vec::new(), + col_pref_widths: Vec::new(), table_layout: table_layout } } @@ -69,9 +69,9 @@ impl TableFlow { }; TableFlow { block_flow: block_flow, - col_widths: ~[], - col_min_widths: ~[], - col_pref_widths: ~[], + col_widths: Vec::new(), + col_min_widths: Vec::new(), + col_pref_widths: Vec::new(), table_layout: table_layout } } @@ -89,23 +89,23 @@ impl TableFlow { }; TableFlow { block_flow: block_flow, - col_widths: ~[], - col_min_widths: ~[], - col_pref_widths: ~[], + col_widths: Vec::new(), + col_min_widths: Vec::new(), + col_pref_widths: Vec::new(), table_layout: table_layout } } pub fn teardown(&mut self) { self.block_flow.teardown(); - self.col_widths = ~[]; - self.col_min_widths = ~[]; - self.col_pref_widths = ~[]; + self.col_widths = Vec::new(); + self.col_min_widths = Vec::new(); + self.col_pref_widths = Vec::new(); } /// Update the corresponding value of self_widths if a value of kid_widths has larger value /// than one of self_widths. - pub fn update_col_widths(self_widths: &mut ~[Au], kid_widths: &~[Au]) -> Au { + pub fn update_col_widths(self_widths: &mut Vec, kid_widths: &Vec) -> Au { let mut sum_widths = Au(0); let mut kid_widths_it = kid_widths.iter(); for self_width in self_widths.mut_iter() { @@ -152,15 +152,15 @@ impl Flow for TableFlow { &mut self.block_flow } - fn col_widths<'a>(&'a mut self) -> &'a mut ~[Au] { + fn col_widths<'a>(&'a mut self) -> &'a mut Vec { &mut self.col_widths } - fn col_min_widths<'a>(&'a self) -> &'a ~[Au] { + fn col_min_widths<'a>(&'a self) -> &'a Vec { &self.col_min_widths } - fn col_pref_widths<'a>(&'a self) -> &'a ~[Au] { + fn col_pref_widths<'a>(&'a self) -> &'a Vec { &self.col_pref_widths } @@ -207,7 +207,7 @@ impl Flow for TableFlow { debug!("table until the previous row has {} column(s) and this row has {} column(s)", num_cols, num_child_cols); for i in range(num_cols, num_child_cols) { - self.col_widths.push( kid_col_widths[i] ); + self.col_widths.push( *kid_col_widths.get(i) ); } }, AutoLayout => { @@ -221,9 +221,9 @@ impl Flow for TableFlow { num_cols, num_child_cols); for i in range(num_cols, num_child_cols) { self.col_widths.push(Au::new(0)); - let new_kid_min = kid.col_min_widths()[i]; + let new_kid_min = *kid.col_min_widths().get(i); self.col_min_widths.push( new_kid_min ); - let new_kid_pref = kid.col_pref_widths()[i]; + let new_kid_pref = *kid.col_pref_widths().get(i); self.col_pref_widths.push( new_kid_pref ); min_width = min_width + new_kid_min; pref_width = pref_width + new_kid_pref; diff --git a/src/components/main/layout/table_row.rs b/src/components/main/layout/table_row.rs index 9665a7171d52..cf23ce2e2d44 100644 --- a/src/components/main/layout/table_row.rs +++ b/src/components/main/layout/table_row.rs @@ -23,13 +23,13 @@ pub struct TableRowFlow { pub block_flow: BlockFlow, /// Column widths. - pub col_widths: ~[Au], + pub col_widths: Vec, /// Column min widths. - pub col_min_widths: ~[Au], + pub col_min_widths: Vec, /// Column pref widths. - pub col_pref_widths: ~[Au], + pub col_pref_widths: Vec, } impl TableRowFlow { @@ -38,9 +38,9 @@ impl TableRowFlow { -> TableRowFlow { TableRowFlow { block_flow: BlockFlow::from_node_and_box(node, box_), - col_widths: ~[], - col_min_widths: ~[], - col_pref_widths: ~[], + col_widths: Vec::new(), + col_min_widths: Vec::new(), + col_pref_widths: Vec::new(), } } @@ -49,17 +49,17 @@ impl TableRowFlow { -> TableRowFlow { TableRowFlow { block_flow: BlockFlow::from_node(constructor, node), - col_widths: ~[], - col_min_widths: ~[], - col_pref_widths: ~[], + col_widths: Vec::new(), + col_min_widths: Vec::new(), + col_pref_widths: Vec::new(), } } pub fn teardown(&mut self) { self.block_flow.teardown(); - self.col_widths = ~[]; - self.col_min_widths = ~[]; - self.col_pref_widths = ~[]; + self.col_widths = Vec::new(); + self.col_min_widths = Vec::new(); + self.col_pref_widths = Vec::new(); } pub fn box_<'a>(&'a mut self) -> &'a Box { @@ -151,15 +151,15 @@ impl Flow for TableRowFlow { &mut self.block_flow } - fn col_widths<'a>(&'a mut self) -> &'a mut ~[Au] { + fn col_widths<'a>(&'a mut self) -> &'a mut Vec { &mut self.col_widths } - fn col_min_widths<'a>(&'a self) -> &'a ~[Au] { + fn col_min_widths<'a>(&'a self) -> &'a Vec { &self.col_min_widths } - fn col_pref_widths<'a>(&'a self) -> &'a ~[Au] { + fn col_pref_widths<'a>(&'a self) -> &'a Vec { &self.col_pref_widths } diff --git a/src/components/main/layout/table_rowgroup.rs b/src/components/main/layout/table_rowgroup.rs index 43e7008c6496..608cf24033f5 100644 --- a/src/components/main/layout/table_rowgroup.rs +++ b/src/components/main/layout/table_rowgroup.rs @@ -22,13 +22,13 @@ pub struct TableRowGroupFlow { pub block_flow: BlockFlow, /// Column widths - pub col_widths: ~[Au], + pub col_widths: Vec, /// Column min widths. - pub col_min_widths: ~[Au], + pub col_min_widths: Vec, /// Column pref widths. - pub col_pref_widths: ~[Au], + pub col_pref_widths: Vec, } impl TableRowGroupFlow { @@ -37,9 +37,9 @@ impl TableRowGroupFlow { -> TableRowGroupFlow { TableRowGroupFlow { block_flow: BlockFlow::from_node_and_box(node, box_), - col_widths: ~[], - col_min_widths: ~[], - col_pref_widths: ~[], + col_widths: Vec::new(), + col_min_widths: Vec::new(), + col_pref_widths: Vec::new(), } } @@ -48,17 +48,17 @@ impl TableRowGroupFlow { -> TableRowGroupFlow { TableRowGroupFlow { block_flow: BlockFlow::from_node(constructor, node), - col_widths: ~[], - col_min_widths: ~[], - col_pref_widths: ~[], + col_widths: Vec::new(), + col_min_widths: Vec::new(), + col_pref_widths: Vec::new(), } } pub fn teardown(&mut self) { self.block_flow.teardown(); - self.col_widths = ~[]; - self.col_min_widths = ~[]; - self.col_pref_widths = ~[]; + self.col_widths = Vec::new(); + self.col_min_widths = Vec::new(); + self.col_pref_widths = Vec::new(); } pub fn box_<'a>(&'a mut self) -> &'a Box { @@ -118,15 +118,15 @@ impl Flow for TableRowGroupFlow { &mut self.block_flow } - fn col_widths<'a>(&'a mut self) -> &'a mut ~[Au] { + fn col_widths<'a>(&'a mut self) -> &'a mut Vec { &mut self.col_widths } - fn col_min_widths<'a>(&'a self) -> &'a ~[Au] { + fn col_min_widths<'a>(&'a self) -> &'a Vec { &self.col_min_widths } - fn col_pref_widths<'a>(&'a self) -> &'a ~[Au] { + fn col_pref_widths<'a>(&'a self) -> &'a Vec { &self.col_pref_widths } @@ -162,10 +162,10 @@ impl Flow for TableRowGroupFlow { let num_child_cols = kid.col_min_widths().len(); for i in range(num_cols, num_child_cols) { self.col_widths.push(Au::new(0)); - let new_kid_min = kid.col_min_widths()[i]; - self.col_min_widths.push(kid.col_min_widths()[i]); - let new_kid_pref = kid.col_pref_widths()[i]; - self.col_pref_widths.push(kid.col_pref_widths()[i]); + let new_kid_min = *kid.col_min_widths().get(i); + self.col_min_widths.push(*kid.col_min_widths().get(i)); + let new_kid_pref = *kid.col_pref_widths().get(i); + self.col_pref_widths.push(*kid.col_pref_widths().get(i)); min_width = min_width + new_kid_min; pref_width = pref_width + new_kid_pref; } diff --git a/src/components/main/layout/table_wrapper.rs b/src/components/main/layout/table_wrapper.rs index 6ae2dd350c2a..5a6a47bc96d2 100644 --- a/src/components/main/layout/table_wrapper.rs +++ b/src/components/main/layout/table_wrapper.rs @@ -28,7 +28,7 @@ pub struct TableWrapperFlow { pub block_flow: BlockFlow, /// Column widths - pub col_widths: ~[Au], + pub col_widths: Vec, /// Table-layout property pub table_layout: TableLayout, @@ -47,7 +47,7 @@ impl TableWrapperFlow { }; TableWrapperFlow { block_flow: block_flow, - col_widths: ~[], + col_widths: Vec::new(), table_layout: table_layout } } @@ -64,7 +64,7 @@ impl TableWrapperFlow { }; TableWrapperFlow { block_flow: block_flow, - col_widths: ~[], + col_widths: Vec::new(), table_layout: table_layout } } @@ -82,7 +82,7 @@ impl TableWrapperFlow { }; TableWrapperFlow { block_flow: block_flow, - col_widths: ~[], + col_widths: Vec::new(), table_layout: table_layout } } @@ -93,7 +93,7 @@ impl TableWrapperFlow { pub fn teardown(&mut self) { self.block_flow.teardown(); - self.col_widths = ~[]; + self.col_widths = Vec::new(); } /// Assign height for table-wrapper flow. @@ -137,7 +137,7 @@ impl Flow for TableWrapperFlow { assert!(kid.is_table_caption() || kid.is_table()); if kid.is_table() { - self.col_widths.push_all(kid.as_table().col_widths); + self.col_widths.push_all(kid.as_table().col_widths.as_slice()); } } @@ -257,8 +257,8 @@ impl TableWrapper { let mut cap_min = Au(0); let mut cols_min = Au(0); let mut cols_max = Au(0); - let mut col_min_widths = &~[]; - let mut col_pref_widths = &~[]; + let mut col_min_widths = &Vec::new(); + let mut col_pref_widths = &Vec::new(); for kid in table_wrapper.block_flow.base.child_iter() { if kid.is_table_caption() { cap_min = kid.as_block().base.intrinsic_widths.minimum_width;