Skip to content

Commit

Permalink
~[] to Vec in layout flow, block, table, row, rowgroup, wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
murphm8 authored and Ms2ger committed May 4, 2014
1 parent 3d1a885 commit e761649
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 70 deletions.
6 changes: 3 additions & 3 deletions src/components/main/layout/block.rs
Expand Up @@ -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<Vec<Au>>) {
// 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();
Expand Down Expand Up @@ -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 => {}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/components/main/layout/flow.rs
Expand Up @@ -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<Au> {
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<Au> {
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<Au> {
fail!("called col_pref_widths() on an other flow than table-row/table-rowgroup/table")
}

Expand Down
44 changes: 22 additions & 22 deletions src/components/main/layout/table.rs
Expand Up @@ -25,13 +25,13 @@ pub struct TableFlow {
pub block_flow: BlockFlow,

/// Column widths
pub col_widths: ~[Au],
pub col_widths: Vec<Au>,

/// Column min widths.
pub col_min_widths: ~[Au],
pub col_min_widths: Vec<Au>,

/// Column pref widths.
pub col_pref_widths: ~[Au],
pub col_pref_widths: Vec<Au>,

/// Table-layout property
pub table_layout: TableLayout,
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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<Au>, kid_widths: &Vec<Au>) -> Au {
let mut sum_widths = Au(0);
let mut kid_widths_it = kid_widths.iter();
for self_width in self_widths.mut_iter() {
Expand Down Expand Up @@ -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<Au> {
&mut self.col_widths
}

fn col_min_widths<'a>(&'a self) -> &'a ~[Au] {
fn col_min_widths<'a>(&'a self) -> &'a Vec<Au> {
&self.col_min_widths
}

fn col_pref_widths<'a>(&'a self) -> &'a ~[Au] {
fn col_pref_widths<'a>(&'a self) -> &'a Vec<Au> {
&self.col_pref_widths
}

Expand Down Expand Up @@ -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 => {
Expand All @@ -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;
Expand Down
30 changes: 15 additions & 15 deletions src/components/main/layout/table_row.rs
Expand Up @@ -23,13 +23,13 @@ pub struct TableRowFlow {
pub block_flow: BlockFlow,

/// Column widths.
pub col_widths: ~[Au],
pub col_widths: Vec<Au>,

/// Column min widths.
pub col_min_widths: ~[Au],
pub col_min_widths: Vec<Au>,

/// Column pref widths.
pub col_pref_widths: ~[Au],
pub col_pref_widths: Vec<Au>,
}

impl TableRowFlow {
Expand All @@ -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(),
}
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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<Au> {
&mut self.col_widths
}

fn col_min_widths<'a>(&'a self) -> &'a ~[Au] {
fn col_min_widths<'a>(&'a self) -> &'a Vec<Au> {
&self.col_min_widths
}

fn col_pref_widths<'a>(&'a self) -> &'a ~[Au] {
fn col_pref_widths<'a>(&'a self) -> &'a Vec<Au> {
&self.col_pref_widths
}

Expand Down
38 changes: 19 additions & 19 deletions src/components/main/layout/table_rowgroup.rs
Expand Up @@ -22,13 +22,13 @@ pub struct TableRowGroupFlow {
pub block_flow: BlockFlow,

/// Column widths
pub col_widths: ~[Au],
pub col_widths: Vec<Au>,

/// Column min widths.
pub col_min_widths: ~[Au],
pub col_min_widths: Vec<Au>,

/// Column pref widths.
pub col_pref_widths: ~[Au],
pub col_pref_widths: Vec<Au>,
}

impl TableRowGroupFlow {
Expand All @@ -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(),
}
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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<Au> {
&mut self.col_widths
}

fn col_min_widths<'a>(&'a self) -> &'a ~[Au] {
fn col_min_widths<'a>(&'a self) -> &'a Vec<Au> {
&self.col_min_widths
}

fn col_pref_widths<'a>(&'a self) -> &'a ~[Au] {
fn col_pref_widths<'a>(&'a self) -> &'a Vec<Au> {
&self.col_pref_widths
}

Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions src/components/main/layout/table_wrapper.rs
Expand Up @@ -28,7 +28,7 @@ pub struct TableWrapperFlow {
pub block_flow: BlockFlow,

/// Column widths
pub col_widths: ~[Au],
pub col_widths: Vec<Au>,

/// Table-layout property
pub table_layout: TableLayout,
Expand All @@ -47,7 +47,7 @@ impl TableWrapperFlow {
};
TableWrapperFlow {
block_flow: block_flow,
col_widths: ~[],
col_widths: Vec::new(),
table_layout: table_layout
}
}
Expand All @@ -64,7 +64,7 @@ impl TableWrapperFlow {
};
TableWrapperFlow {
block_flow: block_flow,
col_widths: ~[],
col_widths: Vec::new(),
table_layout: table_layout
}
}
Expand All @@ -82,7 +82,7 @@ impl TableWrapperFlow {
};
TableWrapperFlow {
block_flow: block_flow,
col_widths: ~[],
col_widths: Vec::new(),
table_layout: table_layout
}
}
Expand All @@ -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.
Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e761649

Please sign in to comment.