From 7605464c24878241c30ed9b4bca54857fc74cc14 Mon Sep 17 00:00:00 2001 From: Matt Murphy Date: Wed, 23 Apr 2014 21:22:15 -0500 Subject: [PATCH] ~[] to Vec in table, table_colgroup, and text --- src/components/main/layout/table.rs | 2 +- src/components/main/layout/table_colgroup.rs | 6 +++--- src/components/main/layout/text.rs | 19 +++++++++---------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/components/main/layout/table.rs b/src/components/main/layout/table.rs index 2d18bc8fffcf..9562c881aac6 100644 --- a/src/components/main/layout/table.rs +++ b/src/components/main/layout/table.rs @@ -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() { diff --git a/src/components/main/layout/table_colgroup.rs b/src/components/main/layout/table_colgroup.rs index 8fc029cbad83..8269e4eac75a 100644 --- a/src/components/main/layout/table_colgroup.rs +++ b/src/components/main/layout/table_colgroup.rs @@ -23,7 +23,7 @@ pub struct TableColGroupFlow { pub cols: Vec, /// The specified widths of table columns - pub widths: ~[Au], + pub widths: Vec, } 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(); } } diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs index aecf7f71ceec..6c77688c02cc 100644 --- a/src/components/main/layout/text.rs +++ b/src/components/main/layout/text.rs @@ -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 = 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 = 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) } }