diff --git a/src/components/gfx/text/util.rs b/src/components/gfx/text/util.rs index 79cbc6930c3..a149af36c01 100644 --- a/src/components/gfx/text/util.rs +++ b/src/components/gfx/text/util.rs @@ -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) -> (~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]) } diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs index 41b133243e1..fe5eff68402 100644 --- a/src/components/main/layout/box_.rs +++ b/src/components/main/layout/box_.rs @@ -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, } /// 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) }; diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs index cb3e876d86d..aecf7f71cee 100644 --- a/src/components/main/layout/text.rs +++ b/src/components/main/layout/text.rs @@ -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, } // 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,