mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Remove @self hack from FontCache
This commit is contained in:
parent
c3170ac865
commit
03732b0cce
1 changed files with 5 additions and 14 deletions
|
@ -2,10 +2,6 @@ export FontCache, native;
|
||||||
use font::{Font, test_font_bin};
|
use font::{Font, test_font_bin};
|
||||||
|
|
||||||
struct FontCache {
|
struct FontCache {
|
||||||
// FIXME: This is a hack to hold onto a boxed reference to
|
|
||||||
// the self pointer until explicit self types work on methods.
|
|
||||||
// This is a huge space leak.
|
|
||||||
mut at_self: Option<@FontCache>,
|
|
||||||
native_lib: native::NativeFontCache,
|
native_lib: native::NativeFontCache,
|
||||||
|
|
||||||
drop {
|
drop {
|
||||||
|
@ -14,27 +10,22 @@ struct FontCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FontCache {
|
impl FontCache {
|
||||||
fn get_font() -> @Font {
|
fn get_font(@self) -> @Font {
|
||||||
assert self.at_self.is_some();
|
match create_font(self, &self.native_lib) {
|
||||||
match create_font(self.at_self.get(), &self.native_lib) {
|
|
||||||
Ok(font) => font,
|
Ok(font) => font,
|
||||||
Err(*) => /* FIXME */ fail
|
Err(*) => /* FIXME */ fail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_test_font() -> @Font {
|
fn get_test_font(@self) -> @Font {
|
||||||
self.get_font()
|
self.get_font()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FontCache() -> @FontCache {
|
fn FontCache() -> @FontCache {
|
||||||
let lib = @FontCache {
|
@FontCache {
|
||||||
mut at_self: None,
|
|
||||||
native_lib: native::create_native_lib()
|
native_lib: native::create_native_lib()
|
||||||
};
|
}
|
||||||
|
|
||||||
lib.at_self = Some(lib);
|
|
||||||
return lib;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_font(lib: @FontCache, native_lib: &native::NativeFontCache) -> Result<@Font, ()> {
|
fn create_font(lib: @FontCache, native_lib: &native::NativeFontCache) -> Result<@Font, ()> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue