~[] to Vec in main/layout/box_.rs, gfx/text/util.rs, main/layout/text.rs

This commit is contained in:
Matt Murphy 2014-04-22 19:16:39 -05:00 committed by Ms2ger
parent 62bbe1f555
commit 36fdcdc929
3 changed files with 14 additions and 13 deletions

View file

@ -20,7 +20,7 @@ pub enum CompressionMode {
// * Issue #114: record skipped and kept chars for mapping original to new text
//
// * Untracked: various edge cases for bidi, CJK, etc.
pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bool, new_line_pos: &mut ~[uint]) -> (~str, bool) {
pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bool, new_line_pos: &mut Vec<uint>) -> (~str, bool) {
let mut out_str: ~str = "".to_owned();
let out_whitespace = match mode {
CompressNone | DiscardNewline => {
@ -149,7 +149,7 @@ fn test_transform_compress_none() {
let mode = CompressNone;
for i in range(0, test_strs.len()) {
let mut new_line_pos = ~[];
let mut new_line_pos = Vec::new();
let (trimmed_str, _out) = transform_text(test_strs[i], mode, true, &mut new_line_pos);
assert_eq!(&trimmed_str, &test_strs[i])
}
@ -178,7 +178,7 @@ fn test_transform_discard_newline() {
let mode = DiscardNewline;
for i in range(0, test_strs.len()) {
let mut new_line_pos = ~[];
let mut new_line_pos = Vec::new();
let (trimmed_str, _out) = transform_text(test_strs[i], mode, true, &mut new_line_pos);
assert_eq!(&trimmed_str, &oracle_strs[i])
}
@ -266,7 +266,7 @@ fn test_transform_compress_whitespace_newline_no_incoming() {
let mode = CompressWhitespaceNewline;
for i in range(0, test_strs.len()) {
let mut new_line_pos = ~[];
let mut new_line_pos = Vec::new();
let (trimmed_str, _out) = transform_text(test_strs[i], mode, false, &mut new_line_pos);
assert_eq!(&trimmed_str, &oracle_strs[i])
}

View file

@ -94,7 +94,7 @@ pub struct Box {
/// New-line chracter(\n)'s positions(relative, not absolute)
///
/// FIXME(#2260, pcwalton): This is very inefficient; remove.
pub new_line_pos: ~[uint],
pub new_line_pos: Vec<uint>,
}
/// Info specific to the kind of box. Keep this enum small.
@ -313,7 +313,7 @@ impl Box {
border_padding: Zero::zero(),
margin: Zero::zero(),
specific: constructor.build_specific_box_info_for_node(node),
new_line_pos: ~[],
new_line_pos: Vec::new(),
}
}
@ -326,7 +326,7 @@ impl Box {
border_padding: Zero::zero(),
margin: Zero::zero(),
specific: specific,
new_line_pos: ~[],
new_line_pos: Vec::new(),
}
}
@ -350,7 +350,7 @@ impl Box {
border_padding: Zero::zero(),
margin: Zero::zero(),
specific: specific,
new_line_pos: ~[],
new_line_pos: Vec::new(),
}
}
@ -366,7 +366,7 @@ impl Box {
border_padding: Zero::zero(),
margin: Zero::zero(),
specific: specific,
new_line_pos: ~[],
new_line_pos: Vec::new(),
}
}
@ -1114,7 +1114,7 @@ impl Box {
let new_text_box_info = ScannedTextBoxInfo::new(text_box_info.run.clone(), left_range);
let new_metrics = new_text_box_info.run.metrics_for_range(&left_range);
let mut new_box = self.transform(new_metrics.bounding_box.size, ScannedTextBox(new_text_box_info));
new_box.new_line_pos = ~[];
new_box.new_line_pos = Vec::new();
Some(new_box)
};

View file

@ -22,7 +22,7 @@ use style::computed_values::{font_family, line_height, white_space};
use sync::Arc;
struct NewLinePositions {
new_line_pos: ~[uint],
new_line_pos: Vec<uint>,
}
// A helper function.
@ -138,7 +138,8 @@ impl TextRunScanner {
white_space::pre => CompressNone,
};
let mut new_line_pos = ~[];
let mut new_line_pos = Vec::new();
let (transformed_text, whitespace) = transform_text(*text,
compression,
last_whitespace,
@ -195,7 +196,7 @@ impl TextRunScanner {
_ => fail!("Expected an unscanned text box!"),
};
let mut new_line_pos = ~[];
let mut new_line_pos = Vec::new();
let (new_str, new_whitespace) = transform_text(*in_box,
compression,