mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
fix indent & some code
This commit is contained in:
parent
ab1291f34a
commit
86e2cac8e8
7 changed files with 53 additions and 54 deletions
|
@ -148,8 +148,7 @@ impl<E> DisplayItem<E> {
|
|||
font.metrics.clone()
|
||||
});
|
||||
let origin = text.base.bounds.origin;
|
||||
let baseline_origin = Point2D(origin.x, origin.y +
|
||||
font.with_borrow( |font| {font.metrics.ascent} ));
|
||||
let baseline_origin = Point2D(origin.x, origin.y + font_metrics.ascent);
|
||||
font.with_mut_borrow( |font| {
|
||||
font.draw_text_into_context(render_context,
|
||||
&text.text_run,
|
||||
|
|
|
@ -195,12 +195,11 @@ impl FontGroup {
|
|||
|
||||
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.
|
||||
let lr = self.fonts[0].with_mut_borrow(|font| {
|
||||
self.fonts[0].with_mut_borrow(|font| {
|
||||
TextRun::new(font, text.clone(), decoration)
|
||||
});
|
||||
lr
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,8 +320,7 @@ impl<'self> Font {
|
|||
|
||||
let shaper = Shaper::new(self);
|
||||
self.shaper = Some(shaper);
|
||||
let s:&'self Shaper = self.shaper.get_ref();
|
||||
s
|
||||
self.shaper.get_ref()
|
||||
}
|
||||
|
||||
pub fn get_table_for_tag(&self, tag: FontTableTag) -> Option<FontTable> {
|
||||
|
|
|
@ -103,7 +103,7 @@ impl<'self> FontContext {
|
|||
debug!("font cache miss");
|
||||
let result = self.create_font_instance(desc);
|
||||
match result.clone() {
|
||||
Ok(font) => {
|
||||
Ok(ref font) => {
|
||||
self.instance_cache.insert(desc.clone(), font.clone());
|
||||
}, _ => {}
|
||||
};
|
||||
|
@ -137,27 +137,31 @@ impl<'self> FontContext {
|
|||
let result = match self.font_list {
|
||||
Some(ref mut fl) => {
|
||||
let font_in_family = fl.find_font_in_family(&transformed_family_name, style);
|
||||
if font_in_family.is_some() {
|
||||
let font_entry = font_in_family.unwrap();
|
||||
let font_id =
|
||||
SelectorPlatformIdentifier(font_entry.handle.face_identifier());
|
||||
match font_in_family {
|
||||
Some(font_entry) => {
|
||||
let font_id =
|
||||
SelectorPlatformIdentifier(font_entry.handle.face_identifier());
|
||||
let font_desc = FontDescriptor::new((*style).clone(), font_id);
|
||||
Some(font_desc)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
None => {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
|
||||
if result.is_some() {
|
||||
found = true;
|
||||
let instance = self.get_font_by_descriptor(&result.unwrap());
|
||||
match result {
|
||||
Some(ref result) => {
|
||||
found = true;
|
||||
let instance = self.get_font_by_descriptor(result);
|
||||
|
||||
for font in instance.iter() { fonts.push(font.clone()); }
|
||||
for font in instance.iter() { fonts.push(font.clone()); }
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
||||
if !found {
|
||||
debug!("(create font group) didn't find `{:s}`", transformed_family_name);
|
||||
}
|
||||
|
@ -166,24 +170,25 @@ impl<'self> FontContext {
|
|||
if fonts.len() == 0 {
|
||||
let last_resort = FontList::get_last_resort_font_families();
|
||||
for family in last_resort.iter() {
|
||||
let result = match self.font_list {
|
||||
Some(ref fl) => fl.find_font_in_family(*family, style),
|
||||
None => None,
|
||||
};
|
||||
|
||||
for family in last_resort.iter() {
|
||||
if self.font_list.is_some() {
|
||||
let font_desc = {
|
||||
let font_list = self.font_list.get_mut_ref();
|
||||
let font_entry = font_list.find_font_in_family(family, style);
|
||||
match font_entry {
|
||||
Some(v) => {
|
||||
let font_id =
|
||||
SelectorPlatformIdentifier(v.handle.face_identifier());
|
||||
Some(FontDescriptor::new((*style).clone(), font_id))
|
||||
}, None => {
|
||||
None
|
||||
}
|
||||
let font_desc = match self.font_list {
|
||||
Some(ref mut font_list) => {
|
||||
let font_desc = {
|
||||
let font_entry = font_list.find_font_in_family(family, style);
|
||||
match font_entry {
|
||||
Some(v) => {
|
||||
let font_id =
|
||||
SelectorPlatformIdentifier(v.handle.face_identifier());
|
||||
Some(FontDescriptor::new((*style).clone(), font_id))
|
||||
},
|
||||
None => {
|
||||
None
|
||||
}
|
||||
}
|
||||
};
|
||||
font_desc
|
||||
},
|
||||
None => {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -194,12 +199,11 @@ impl<'self> FontContext {
|
|||
for font in instance.iter() {
|
||||
fonts.push(font.clone());
|
||||
}
|
||||
}, None => {
|
||||
}
|
||||
}
|
||||
},
|
||||
None => { }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
assert!(fonts.len() > 0);
|
||||
// TODO(Issue #179): Split FontStyle into specified and used styles
|
||||
let used_style = (*style).clone();
|
||||
|
|
|
@ -59,7 +59,7 @@ impl<'self> FontList {
|
|||
// look up canonical name
|
||||
if self.family_map.contains_key(family_name) {
|
||||
//FIXME call twice!(ksh8281)
|
||||
debug!("FontList: {:s} font family with name={:s}", "Found", family_name.to_str());
|
||||
debug!("FontList: Found font family with name={:s}", family_name.to_str());
|
||||
let s: &'self mut FontFamily = self.family_map.get_mut(family_name);
|
||||
// TODO(Issue #192: handle generic font families, like 'serif' and 'sans-serif'.
|
||||
// if such family exists, try to match style to a font
|
||||
|
@ -69,9 +69,8 @@ impl<'self> FontList {
|
|||
}
|
||||
|
||||
None
|
||||
}
|
||||
else {
|
||||
debug!("FontList: {:s} font family with name={:s}", "Couldn't find", family_name.to_str());
|
||||
} else {
|
||||
debug!("FontList: Couldn't find font family with name={:s}", family_name.to_str());
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ impl FontContextHandle {
|
|||
None => {
|
||||
let ctx: FT_Library = ptr::null();
|
||||
let result = FT_Init_FreeType(ptr::to_unsafe_ptr(&ctx));
|
||||
if !result.succeeded() { fail!(); }
|
||||
if !result.succeeded() { fail!("Unable to initialize FreeType library"); }
|
||||
ft_pointer = Some(ctx);
|
||||
font_context_ref_count = font_context_ref_count + 1;
|
||||
FontContextHandle {
|
||||
|
@ -68,7 +68,7 @@ impl FontContextHandleMethods for FontContextHandle {
|
|||
fn clone(&self) -> FontContextHandle {
|
||||
unsafe {
|
||||
font_context_ref_count = font_context_ref_count + 1;
|
||||
FontContextHandle{
|
||||
FontContextHandle {
|
||||
ctx: self.ctx.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -955,7 +955,7 @@ impl Box {
|
|||
self.position.mutate().ptr.size.width = image_width
|
||||
}
|
||||
ScannedTextBox(_) => {
|
||||
|
||||
// Scanned text boxes will have already had their widths assigned by this point.
|
||||
}
|
||||
UnscannedTextBox(_) => fail!("Unscanned text boxes should have been scanned by now!"),
|
||||
}
|
||||
|
|
|
@ -188,11 +188,10 @@ 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 {
|
||||
let font = {
|
||||
fontgroup.with_borrow( |fg| fg.fonts[0].clone())
|
||||
};
|
||||
font.with_mut_borrow( |font| {
|
||||
Some(@TextRun::new(font, run_str.clone(), decoration))
|
||||
fontgroup.with_borrow( |fg| {
|
||||
fg.fonts[0].with_mut_borrow( |font| {
|
||||
Some(@TextRun::new(font, run_str.clone(), decoration))
|
||||
})
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue