Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest Rust #435

Merged
merged 10 commits into from May 10, 2013

Appease the new borrow checker.

  • Loading branch information
metajack committed May 10, 2013
commit 5324cabbf8757fa68b1aa36548b992041be94ef9
@@ -386,7 +386,7 @@ pub impl Font {
advance += glyph.advance();
}
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
// ascent+descent and advance is sometimes too generous and
@@ -96,10 +96,9 @@ impl FontFamily {
}

fn load_family_variations(@mut self, list: &FontListHandle) {
let this : &mut FontFamily = self; // FIXME: borrow checker workaround
if this.entries.len() > 0 { return; }
if self.entries.len() > 0 { return; }
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)
@@ -16,7 +16,7 @@ use geometry::Au;
use platform::macos::font_context::FontContextHandle;
use text::glyph::GlyphIndex;

use core_foundation::base::{CFIndex, CFWrapper};
use core_foundation::base::CFIndex;
use core_foundation::data::CFData;
use core_foundation::string::UniChar;
use core_graphics::data_provider::CGDataProvider;
@@ -106,7 +106,7 @@ impl FontHandleMethods for FontHandle {

fn boldness(&self) -> CSSFontWeight {
// -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
let normalized = (normalized + 1.0) / 2.0 * 9.0;
if normalized < 1.0 { return FontWeight100; }
@@ -146,13 +146,11 @@ impl FontHandleMethods for FontHandle {

fn glyph_h_advance(&self, glyph: GlyphIndex) -> Option<FractionalPixel> {
let glyphs = [glyph as CGGlyph];
unsafe {
let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
&glyphs[0],
ptr::null(),
1);
return Some(advance as FractionalPixel);
}
let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
&glyphs[0],
ptr::null(),
1);
Some(advance as FractionalPixel)
}

fn get_metrics(&self) -> FontMetrics {
@@ -42,11 +42,9 @@ pub impl FontListHandle {
}

fn load_variations_for_family(&self, family: @mut FontFamily) {
let fam: &mut FontFamily = family; // FIXME: borrow checker workaround
let family_name = &fam.family_name;
debug!("Looking for faces of family: %s", *family_name);
debug!("Looking for faces of family: %s", family.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| {
let desc = CFWrapper::wrap_shared(*descref);
let font = core_text::font::new_from_descriptor(&desc, 0.0);
@@ -373,20 +373,13 @@ impl ImageCache {
}

priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
match self.wait_map.find(&url) {
Some(waiters) => {
let waiters = *waiters;
let mut new_waiters = ~[];
new_waiters <-> *waiters;

for new_waiters.each |response| {
response.send(f());
match self.wait_map.pop(&url) {
Some(waiters) => {
for waiters.each |response| {
response.send(f());
}
}

*waiters <-> new_waiters;
self.wait_map.remove(&url);
}
None => ()
None => ()
}
}

@@ -410,13 +403,11 @@ impl ImageCache {

Prefetching(DoDecode) | Decoding => {
// We don't have this image yet
match self.wait_map.find(&url) {
Some(waiters) => {
vec::push(*waiters, response);
}
None => {
self.wait_map.insert(url, @mut ~[response]);
}
if self.wait_map.contains_key(&url) {
let waiters = self.wait_map.find_mut(&url).unwrap();
waiters.push(response);
} else {
self.wait_map.insert(url, @mut ~[response]);
}
}

@@ -76,12 +76,9 @@ pub impl LocalImageCache {

match state.last_response {
ImageReady(ref image) => {
// FIXME: appease borrowck
unsafe {
let (port, chan) = comm::stream();
chan.send(ImageReady(clone_arc(image)));
return port;
}
let (port, chan) = comm::stream();
chan.send(ImageReady(clone_arc(image)));
return port;
}
ImageNotReady => {
if last_round == self.round_number {
@@ -138,18 +135,14 @@ pub impl LocalImageCache {
}

priv fn get_state(&self, url: &Url) -> @mut ImageState {
match self.state_map.find(url) {
Some(state) => *state,
None => {
let new_state = @mut ImageState {
prefetched: false,
decoded: false,
last_request_round: 0,
last_response: ImageNotReady
};
self.state_map.insert(copy *url, new_state);
self.get_state(url)
}
*do self.state_map.find_or_insert_with(url.clone()) |_| {
let new_state = @mut ImageState {
prefetched: false,
decoded: false,
last_request_round: 0,
last_response: ImageNotReady
};
new_state
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.