mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
~[] to Vec in layout flow, block, table, row, rowgroup, wrapper
This commit is contained in:
parent
3d1a885a55
commit
e761649cda
6 changed files with 70 additions and 70 deletions
|
@ -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();
|
||||
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
@ -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<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() {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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<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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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<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
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue