mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
~[] to Vec in FontStyle and FontGroup
This commit is contained in:
parent
b1d0dac50d
commit
7447ed69e3
5 changed files with 16 additions and 16 deletions
|
@ -54,7 +54,7 @@ impl BufferKey {
|
|||
/// A helper struct to keep track of buffers in the HashMap
|
||||
struct BufferValue<T> {
|
||||
/// An array of buffers, all the same size
|
||||
buffers: ~[T],
|
||||
buffers: Vec<T>,
|
||||
/// The counter when this size was last requested
|
||||
last_action: uint,
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ impl<T: Tile> BufferMap<T> {
|
|||
// 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);
|
||||
|
||||
|
|
|
@ -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<RefCell<Font>>]
|
||||
pub fonts: Vec<Rc<RefCell<Font>>>
|
||||
}
|
||||
|
||||
impl FontGroup {
|
||||
pub fn new(families: ~[~str], style: &UsedFontStyle, fonts: ~[Rc<RefCell<Font>>]) -> FontGroup {
|
||||
pub fn new(families: Vec<~str>, style: &UsedFontStyle, fonts: Vec<Rc<RefCell<Font>>>) -> 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ impl FontContext {
|
|||
}
|
||||
|
||||
fn create_font_group(&mut self, style: &SpecifiedFontStyle) -> Rc<RefCell<FontGroup>> {
|
||||
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<Rc<RefCell<Font>>, ()> {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -705,10 +705,10 @@ pub mod longhands {
|
|||
// Fantasy,
|
||||
// Monospace,
|
||||
}
|
||||
pub type T = ~[FontFamily];
|
||||
pub type T = Vec<FontFamily>;
|
||||
}
|
||||
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")) }
|
||||
/// <familiy-name>#
|
||||
/// <familiy-name> = <string> | [ <ident>+ ]
|
||||
/// TODO: <generic-familiy>
|
||||
|
@ -716,7 +716,7 @@ pub mod longhands {
|
|||
from_iter(input.skip_whitespace())
|
||||
}
|
||||
pub fn from_iter<'a>(mut iter: SkipWhitespaceIterator<'a>) -> Option<SpecifiedValue> {
|
||||
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()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue