Skip to content

Commit

Permalink
~[] to Vec in table, table_colgroup, and text
Browse files Browse the repository at this point in the history
  • Loading branch information
murphm8 authored and Ms2ger committed May 4, 2014
1 parent e761649 commit 7605464
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/main/layout/table.rs
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions src/components/main/layout/table_colgroup.rs
Expand Up @@ -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 {
Expand All @@ -34,7 +34,7 @@ impl TableColGroupFlow {
base: BaseFlow::new((*node).clone()),
box_: Some(box_),
cols: boxes,
widths: ~[],
widths: Vec::new(),
}
}

Expand All @@ -44,7 +44,7 @@ impl TableColGroupFlow {
}
self.box_ = None;
self.cols = Vec::new();
self.widths = ~[];
self.widths = Vec::new();
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/components/main/layout/text.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}

Expand All @@ -236,19 +235,19 @@ 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}",
in_boxes[i].debug_str());
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)
}
}
Expand Down

0 comments on commit 7605464

Please sign in to comment.