mirror of
https://github.com/servo/servo.git
synced 2025-06-22 08:08:59 +01:00
Appease the new borrow checker.
This commit is contained in:
parent
3c291678ad
commit
5324cabbf8
6 changed files with 34 additions and 55 deletions
|
@ -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);
|
||||
}
|
||||
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,18 +373,11 @@ impl ImageCache {
|
|||
}
|
||||
|
||||
priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) {
|
||||
match self.wait_map.find(&url) {
|
||||
match self.wait_map.pop(&url) {
|
||||
Some(waiters) => {
|
||||
let waiters = *waiters;
|
||||
let mut new_waiters = ~[];
|
||||
new_waiters <-> *waiters;
|
||||
|
||||
for new_waiters.each |response| {
|
||||
for waiters.each |response| {
|
||||
response.send(f());
|
||||
}
|
||||
|
||||
*waiters <-> new_waiters;
|
||||
self.wait_map.remove(&url);
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
|
@ -410,15 +403,13 @@ 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 => {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Decoded(image) => {
|
||||
response.send(ImageReady(clone_arc(image)));
|
||||
|
|
|
@ -76,13 +76,10 @@ 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;
|
||||
}
|
||||
}
|
||||
ImageNotReady => {
|
||||
if last_round == self.round_number {
|
||||
let (port, chan) = comm::stream();
|
||||
|
@ -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 => {
|
||||
*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
|
||||
};
|
||||
self.state_map.insert(copy *url, new_state);
|
||||
self.get_state(url)
|
||||
}
|
||||
new_state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue