~[] to Vec in table, table_colgroup, and text

This commit is contained in:
Matt Murphy 2014-04-23 21:22:15 -05:00 committed by Ms2ger
parent e761649cda
commit 7605464c24
3 changed files with 13 additions and 14 deletions

View file

@ -177,7 +177,7 @@ impl Flow for TableFlow {
assert!(kid.is_proper_table_child());
if kid.is_table_colgroup() {
self.col_widths.push_all(kid.as_table_colgroup().widths);
self.col_widths.push_all(kid.as_table_colgroup().widths.as_slice());
self.col_min_widths = self.col_widths.clone();
self.col_pref_widths = self.col_widths.clone();
} else if kid.is_table_rowgroup() || kid.is_table_row() {

View file

@ -23,7 +23,7 @@ pub struct TableColGroupFlow {
pub cols: Vec<Box>,
/// The specified widths of table columns
pub widths: ~[Au],
pub widths: Vec<Au>,
}
impl TableColGroupFlow {
@ -34,7 +34,7 @@ impl TableColGroupFlow {
base: BaseFlow::new((*node).clone()),
box_: Some(box_),
cols: boxes,
widths: ~[],
widths: Vec::new(),
}
}
@ -44,7 +44,7 @@ impl TableColGroupFlow {
}
self.box_ = None;
self.cols = Vec::new();
self.widths = ~[];
self.widths = Vec::new();
}
}

View file

@ -16,7 +16,6 @@ use servo_util::geometry::Au;
use servo_util::range::Range;
use servo_util::smallvec::{SmallVec, SmallVec0};
use std::mem;
use std::slice;
use style::ComputedValues;
use style::computed_values::{font_family, line_height, white_space};
use sync::Arc;
@ -182,11 +181,11 @@ impl TextRunScanner {
white_space::pre => CompressNone,
};
let mut new_line_positions: ~[NewLinePositions] = ~[];
let mut new_line_positions: Vec<NewLinePositions> = Vec::new();
// First, transform/compress text of all the nodes.
let mut last_whitespace_in_clump = new_whitespace;
let transformed_strs: ~[~str] = slice::from_fn(self.clump.length(), |i| {
let transformed_strs: Vec<~str> = Vec::from_fn(self.clump.length(), |i| {
// TODO(#113): We should be passing the compression context between calls to
// `transform_text`, so that boxes starting and/or ending with whitespace can
// be compressed correctly with respect to the text run.
@ -212,12 +211,12 @@ impl TextRunScanner {
// Next, concatenate all of the transformed strings together, saving the new
// character indices.
let mut run_str: ~str = "".to_owned();
let mut new_ranges: ~[Range] = ~[];
let mut new_ranges: Vec<Range> = Vec::new();
let mut char_total = 0;
for i in range(0, transformed_strs.len()) {
let added_chars = transformed_strs[i].char_len();
let added_chars = transformed_strs.get(i).char_len();
new_ranges.push(Range::new(char_total, added_chars));
run_str.push_str(transformed_strs[i]);
run_str.push_str(*transformed_strs.get(i));
char_total += added_chars;
}
@ -236,7 +235,7 @@ impl TextRunScanner {
debug!("TextRunScanner: pushing box(es) in range: {}", self.clump);
for i in clump.eachi() {
let logical_offset = i - self.clump.begin();
let range = new_ranges[logical_offset];
let range = new_ranges.get(logical_offset);
if range.length() == 0 {
debug!("Elided an `UnscannedTextbox` because it was zero-length after \
compression; {:s}",
@ -244,11 +243,11 @@ impl TextRunScanner {
continue
}
let new_text_box_info = ScannedTextBoxInfo::new(run.get_ref().clone(), range);
let new_metrics = new_text_box_info.run.metrics_for_range(&range);
let new_text_box_info = ScannedTextBoxInfo::new(run.get_ref().clone(), *range);
let new_metrics = new_text_box_info.run.metrics_for_range(range);
let mut new_box = in_boxes[i].transform(new_metrics.bounding_box.size,
ScannedTextBox(new_text_box_info));
new_box.new_line_pos = new_line_positions[logical_offset].new_line_pos.clone();
new_box.new_line_pos = new_line_positions.get(logical_offset).new_line_pos.clone();
out_boxes.push(new_box)
}
}