mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
css, gfx, sub: Eliminate many copies
This commit is contained in:
parent
0c72f6ded8
commit
c31bd43570
3 changed files with 16 additions and 16 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit b1ac22d98de7c6e622709ebd3ae2bd63a762b2b2
|
Subproject commit f5ebbe2787cec856ce52c1aabec28e30939b9b35
|
|
@ -146,15 +146,13 @@ pub impl QuartzFontHandle : FontHandleMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn glyph_index(codepoint: char) -> Option<GlyphIndex> {
|
fn glyph_index(codepoint: char) -> Option<GlyphIndex> {
|
||||||
let characters: ~[UniChar] = ~[codepoint as UniChar];
|
let characters: [UniChar * 1] = [codepoint as UniChar];
|
||||||
let glyphs: ~[mut CGGlyph] = ~[mut 0 as CGGlyph];
|
let glyphs: [mut CGGlyph * 1] = [mut 0 as CGGlyph];
|
||||||
let count: CFIndex = 1;
|
let count: CFIndex = 1;
|
||||||
|
|
||||||
let result = do vec::as_imm_buf(characters) |character_buf, _l| {
|
let result = self.ctfont.get_glyphs_for_characters(ptr::to_unsafe_ptr(&characters[0]),
|
||||||
do vec::as_imm_buf(glyphs) |glyph_buf, _l| {
|
ptr::to_unsafe_ptr(&glyphs[0]),
|
||||||
self.ctfont.get_glyphs_for_characters(character_buf, glyph_buf, count)
|
count);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if !result {
|
if !result {
|
||||||
// No glyph for this character
|
// No glyph for this character
|
||||||
|
@ -166,13 +164,15 @@ pub impl QuartzFontHandle : FontHandleMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn glyph_h_advance(glyph: GlyphIndex) -> Option<FractionalPixel> {
|
fn glyph_h_advance(glyph: GlyphIndex) -> Option<FractionalPixel> {
|
||||||
let glyphs = ~[glyph as CGGlyph];
|
let glyphs = [glyph as CGGlyph];
|
||||||
let advance = do vec::as_imm_buf(glyphs) |glyph_buf, _l| {
|
unsafe {
|
||||||
self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation, glyph_buf, ptr::null(), 1)
|
let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
|
||||||
};
|
ptr::to_unsafe_ptr(&glyphs[0]),
|
||||||
|
ptr::null(),
|
||||||
|
1);
|
||||||
return Some(advance as FractionalPixel);
|
return Some(advance as FractionalPixel);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_metrics() -> FontMetrics {
|
fn get_metrics() -> FontMetrics {
|
||||||
let bounding_rect: CGRect = self.ctfont.bounding_box();
|
let bounding_rect: CGRect = self.ctfont.bounding_box();
|
||||||
|
|
|
@ -71,10 +71,10 @@ impl NodeSelectHandler: SelectHandler<Node> {
|
||||||
self.parent_node(node).is_none()
|
self.parent_node(node).is_none()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_id(node: &Node) -> Option<~str> {
|
fn with_node_id<R>(node: &Node, f: &fn(Option<&str>) -> R) -> R {
|
||||||
do node.read |data| {
|
do node.read |data| {
|
||||||
match *data.kind {
|
match *data.kind {
|
||||||
Element(ref data) => data.get_attr("id"),
|
Element(ref data) => data.with_attr("id", f),
|
||||||
_ => fail ~"attempting to style non-element node"
|
_ => fail ~"attempting to style non-element node"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue