diff --git a/src/components/gfx/buffer_map.rs b/src/components/gfx/buffer_map.rs index 899e077a93d..ea16f5f4e1b 100644 --- a/src/components/gfx/buffer_map.rs +++ b/src/components/gfx/buffer_map.rs @@ -54,7 +54,7 @@ impl BufferKey { /// A helper struct to keep track of buffers in the HashMap struct BufferValue { /// An array of buffers, all the same size - buffers: ~[T], + buffers: Vec, /// The counter when this size was last requested last_action: uint, } @@ -86,7 +86,7 @@ impl BufferMap { // use lazy insertion function to prevent unnecessary allocation let counter = &self.counter; self.map.find_or_insert_with(new_key, |_| BufferValue { - buffers: ~[], + buffers: Vec::new(), last_action: *counter }).buffers.push(new_buffer); diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs index 9f00a883098..7405f416d9b 100644 --- a/src/components/gfx/font.rs +++ b/src/components/gfx/font.rs @@ -101,7 +101,7 @@ pub struct FontStyle { pub pt_size: f64, pub weight: font_weight::T, pub style: font_style::T, - pub families: ~[~str], + pub families: Vec<~str>, // TODO(Issue #198): font-stretch, text-decoration, font-variant, size-adjust } @@ -143,15 +143,15 @@ pub enum FontSelector { // The ordering of font instances is mainly decided by the CSS // 'font-family' property. The last font is a system fallback font. pub struct FontGroup { - pub families: ~[~str], + pub families: Vec<~str>, // style of the first western font in group, which is // used for purposes of calculating text run metrics. pub style: UsedFontStyle, - pub fonts: ~[Rc>] + pub fonts: Vec>> } impl FontGroup { - pub fn new(families: ~[~str], style: &UsedFontStyle, fonts: ~[Rc>]) -> FontGroup { + pub fn new(families: Vec<~str>, style: &UsedFontStyle, fonts: Vec>>) -> FontGroup { FontGroup { families: families, style: (*style).clone(), @@ -160,14 +160,14 @@ impl FontGroup { } pub fn teardown(&mut self) { - self.fonts = ~[]; + self.fonts = Vec::new(); } pub fn create_textrun(&self, text: ~str, decoration: text_decoration::T) -> TextRun { assert!(self.fonts.len() > 0); // TODO(Issue #177): Actually fall back through the FontGroup when a font is unsuitable. - TextRun::new(&mut *self.fonts[0].borrow_mut(), text.clone(), decoration) + TextRun::new(&mut *self.fonts.get(0).borrow_mut(), text.clone(), decoration) } } diff --git a/src/components/gfx/font_context.rs b/src/components/gfx/font_context.rs index 75ae81ac659..623160cb804 100644 --- a/src/components/gfx/font_context.rs +++ b/src/components/gfx/font_context.rs @@ -116,7 +116,7 @@ impl FontContext { } fn create_font_group(&mut self, style: &SpecifiedFontStyle) -> Rc> { - let mut fonts = ~[]; + let mut fonts = Vec::new(); debug!("(create font group) --- starting ---"); @@ -200,7 +200,7 @@ impl FontContext { Rc::new( RefCell::new( - FontGroup::new(style.families.to_owned(), &used_style, fonts))) + FontGroup::new(style.families.clone(), &used_style, fonts))) } fn create_font_instance(&self, desc: &FontDescriptor) -> Result>, ()> { diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs index 1ae5a0cbee2..cb3e876d86d 100644 --- a/src/components/main/layout/text.rs +++ b/src/components/main/layout/text.rs @@ -225,7 +225,7 @@ impl TextRunScanner { // sequence. If no clump takes ownership, however, it will leak. let clump = self.clump; let run = if clump.length() != 0 && run_str.len() > 0 { - Some(Arc::new(~TextRun::new(&mut *fontgroup.borrow().fonts[0].borrow_mut(), + Some(Arc::new(~TextRun::new(&mut *fontgroup.borrow().fonts.get(0).borrow_mut(), run_str.clone(), decoration))) } else { None @@ -267,7 +267,7 @@ impl TextRunScanner { pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: &FontStyle) -> FontMetrics { let fontgroup = font_context.get_resolved_font_for_style(font_style); - fontgroup.borrow().fonts[0].borrow().metrics.clone() + fontgroup.borrow().fonts.get(0).borrow().metrics.clone() } /// Converts a computed style to a font style used for rendering. diff --git a/src/components/style/properties.rs.mako b/src/components/style/properties.rs.mako index 682c373c7ab..06b4412d6ff 100644 --- a/src/components/style/properties.rs.mako +++ b/src/components/style/properties.rs.mako @@ -705,10 +705,10 @@ pub mod longhands { // Fantasy, // Monospace, } - pub type T = ~[FontFamily]; + pub type T = Vec; } pub type SpecifiedValue = computed_value::T; - #[inline] pub fn get_initial_value() -> computed_value::T { ~[FamilyName(~"serif")] } + #[inline] pub fn get_initial_value() -> computed_value::T { vec!(FamilyName(~"serif")) } /// # /// = | [ + ] /// TODO: @@ -716,7 +716,7 @@ pub mod longhands { from_iter(input.skip_whitespace()) } pub fn from_iter<'a>(mut iter: SkipWhitespaceIterator<'a>) -> Option { - let mut result = ~[]; + let mut result = Vec::new(); macro_rules! add( ($value: expr, $b: expr) => { { @@ -743,7 +743,7 @@ pub mod longhands { // "fantasy" => add!(Fantasy, break 'outer), // "monospace" => add!(Monospace, break 'outer), _ => { - let mut idents = ~[value.as_slice()]; + let mut idents = vec!(value.as_slice()); loop { match iter.next() { Some(&Ident(ref value)) => idents.push(value.as_slice()),