Appease the new borrow checker.

This commit is contained in:
Jack Moffitt 2013-05-10 13:52:31 -06:00
parent 3c291678ad
commit 5324cabbf8
6 changed files with 34 additions and 55 deletions

View file

@ -386,7 +386,7 @@ pub impl Font {
advance += glyph.advance(); advance += glyph.advance();
} }
let bounds = Rect(Point2D(Au(0), -self.metrics.ascent), let bounds = Rect(Point2D(Au(0), -self.metrics.ascent),
Size2D(advance, self.metrics.ascent + self.metrics.descent)); Size2D(advance, self.metrics.ascent + self.metrics.descent));
// TODO(Issue #125): support loose and tight bounding boxes; using the // TODO(Issue #125): support loose and tight bounding boxes; using the
// ascent+descent and advance is sometimes too generous and // ascent+descent and advance is sometimes too generous and

View file

@ -96,10 +96,9 @@ impl FontFamily {
} }
fn load_family_variations(@mut self, list: &FontListHandle) { fn load_family_variations(@mut self, list: &FontListHandle) {
let this : &mut FontFamily = self; // FIXME: borrow checker workaround if self.entries.len() > 0 { return; }
if this.entries.len() > 0 { return; }
list.load_variations_for_family(self); list.load_variations_for_family(self);
assert!(this.entries.len() > 0); assert!(self.entries.len() > 0);
} }
pub fn find_font_for_style(@mut self, list: &FontListHandle, style: &SpecifiedFontStyle) pub fn find_font_for_style(@mut self, list: &FontListHandle, style: &SpecifiedFontStyle)

View file

@ -16,7 +16,7 @@ use geometry::Au;
use platform::macos::font_context::FontContextHandle; use platform::macos::font_context::FontContextHandle;
use text::glyph::GlyphIndex; use text::glyph::GlyphIndex;
use core_foundation::base::{CFIndex, CFWrapper}; use core_foundation::base::CFIndex;
use core_foundation::data::CFData; use core_foundation::data::CFData;
use core_foundation::string::UniChar; use core_foundation::string::UniChar;
use core_graphics::data_provider::CGDataProvider; use core_graphics::data_provider::CGDataProvider;
@ -106,7 +106,7 @@ impl FontHandleMethods for FontHandle {
fn boldness(&self) -> CSSFontWeight { fn boldness(&self) -> CSSFontWeight {
// -1.0 to 1.0 // -1.0 to 1.0
let normalized = unsafe { self.ctfont.all_traits().normalized_weight() }; let normalized = self.ctfont.all_traits().normalized_weight();
// 0.0 to 9.0 // 0.0 to 9.0
let normalized = (normalized + 1.0) / 2.0 * 9.0; let normalized = (normalized + 1.0) / 2.0 * 9.0;
if normalized < 1.0 { return FontWeight100; } if normalized < 1.0 { return FontWeight100; }
@ -146,13 +146,11 @@ impl FontHandleMethods for FontHandle {
fn glyph_h_advance(&self, glyph: GlyphIndex) -> Option<FractionalPixel> { fn glyph_h_advance(&self, glyph: GlyphIndex) -> Option<FractionalPixel> {
let glyphs = [glyph as CGGlyph]; let glyphs = [glyph as CGGlyph];
unsafe { let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation, &glyphs[0],
&glyphs[0], ptr::null(),
ptr::null(), 1);
1); Some(advance as FractionalPixel)
return Some(advance as FractionalPixel);
}
} }
fn get_metrics(&self) -> FontMetrics { fn get_metrics(&self) -> FontMetrics {

View file

@ -42,11 +42,9 @@ pub impl FontListHandle {
} }
fn load_variations_for_family(&self, family: @mut FontFamily) { fn load_variations_for_family(&self, family: @mut FontFamily) {
let fam: &mut FontFamily = family; // FIXME: borrow checker workaround debug!("Looking for faces of family: %s", family.family_name);
let family_name = &fam.family_name;
debug!("Looking for faces of family: %s", *family_name);
let family_collection = core_text::font_collection::create_for_family(*family_name); let family_collection = core_text::font_collection::create_for_family(family.family_name);
for family_collection.get_descriptors().each |descref: &CTFontDescriptorRef| { for family_collection.get_descriptors().each |descref: &CTFontDescriptorRef| {
let desc = CFWrapper::wrap_shared(*descref); let desc = CFWrapper::wrap_shared(*descref);
let font = core_text::font::new_from_descriptor(&desc, 0.0); let font = core_text::font::new_from_descriptor(&desc, 0.0);

View file

@ -373,20 +373,13 @@ impl ImageCache {
} }
priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) { priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
match self.wait_map.find(&url) { match self.wait_map.pop(&url) {
Some(waiters) => { Some(waiters) => {
let waiters = *waiters; for waiters.each |response| {
let mut new_waiters = ~[]; response.send(f());
new_waiters <-> *waiters; }
for new_waiters.each |response| {
response.send(f());
} }
None => ()
*waiters <-> new_waiters;
self.wait_map.remove(&url);
}
None => ()
} }
} }
@ -410,13 +403,11 @@ impl ImageCache {
Prefetching(DoDecode) | Decoding => { Prefetching(DoDecode) | Decoding => {
// We don't have this image yet // We don't have this image yet
match self.wait_map.find(&url) { if self.wait_map.contains_key(&url) {
Some(waiters) => { let waiters = self.wait_map.find_mut(&url).unwrap();
vec::push(*waiters, response); waiters.push(response);
} } else {
None => { self.wait_map.insert(url, @mut ~[response]);
self.wait_map.insert(url, @mut ~[response]);
}
} }
} }

View file

@ -76,12 +76,9 @@ pub impl LocalImageCache {
match state.last_response { match state.last_response {
ImageReady(ref image) => { ImageReady(ref image) => {
// FIXME: appease borrowck let (port, chan) = comm::stream();
unsafe { chan.send(ImageReady(clone_arc(image)));
let (port, chan) = comm::stream(); return port;
chan.send(ImageReady(clone_arc(image)));
return port;
}
} }
ImageNotReady => { ImageNotReady => {
if last_round == self.round_number { if last_round == self.round_number {
@ -138,18 +135,14 @@ pub impl LocalImageCache {
} }
priv fn get_state(&self, url: &Url) -> @mut ImageState { priv fn get_state(&self, url: &Url) -> @mut ImageState {
match self.state_map.find(url) { *do self.state_map.find_or_insert_with(url.clone()) |_| {
Some(state) => *state, let new_state = @mut ImageState {
None => { prefetched: false,
let new_state = @mut ImageState { decoded: false,
prefetched: false, last_request_round: 0,
decoded: false, last_response: ImageNotReady
last_request_round: 0, };
last_response: ImageNotReady new_state
};
self.state_map.insert(copy *url, new_state);
self.get_state(url)
}
} }
} }
} }