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

@ -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);
return Some(advance as FractionalPixel); 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,18 +373,11 @@ 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 = ~[];
new_waiters <-> *waiters;
for new_waiters.each |response| {
response.send(f()); response.send(f());
} }
*waiters <-> new_waiters;
self.wait_map.remove(&url);
} }
None => () None => ()
} }
@ -410,15 +403,13 @@ 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]);
} }
} }
}
Decoded(image) => { Decoded(image) => {
response.send(ImageReady(clone_arc(image))); response.send(ImageReady(clone_arc(image)));

View file

@ -76,13 +76,10 @@ pub impl LocalImageCache {
match state.last_response { match state.last_response {
ImageReady(ref image) => { ImageReady(ref image) => {
// FIXME: appease borrowck
unsafe {
let (port, chan) = comm::stream(); let (port, chan) = comm::stream();
chan.send(ImageReady(clone_arc(image))); chan.send(ImageReady(clone_arc(image)));
return port; return port;
} }
}
ImageNotReady => { ImageNotReady => {
if last_round == self.round_number { if last_round == self.round_number {
let (port, chan) = comm::stream(); let (port, chan) = comm::stream();
@ -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,
None => {
let new_state = @mut ImageState { let new_state = @mut ImageState {
prefetched: false, prefetched: false,
decoded: false, decoded: false,
last_request_round: 0, last_request_round: 0,
last_response: ImageNotReady last_response: ImageNotReady
}; };
self.state_map.insert(copy *url, new_state); new_state
self.get_state(url)
}
} }
} }
} }