зеркало из https://github.com/mozilla/gecko-dev.git
servo: Make text_run immutable
Source-Repo: https://github.com/servo/servo Source-Revision: 5af6c891ed30fcc8e0635ae8f7cc6bcf324d591a
This commit is contained in:
Родитель
a920d4d482
Коммит
66f7c08e73
|
@ -4,6 +4,7 @@ import geom::size::Size2D;
|
|||
import gfx::geometry::au;
|
||||
import layout::base::*; // FIXME: Can't get around import *; resolve bug.
|
||||
import servo_text::text_run::text_run;
|
||||
import servo_text::font::create_test_font;
|
||||
|
||||
class text_box {
|
||||
let text: str;
|
||||
|
@ -23,12 +24,12 @@ impl text_layout_methods for @Box {
|
|||
_ { fail "expected text box in reflow_text!" }
|
||||
};
|
||||
|
||||
let run = text_run(copy subbox.text);
|
||||
subbox.run = some(copy run);
|
||||
run.shape();
|
||||
let font = create_test_font();
|
||||
let run = text_run(&font, subbox.text);
|
||||
subbox.run = some(run);
|
||||
|
||||
self.bounds.size =
|
||||
Size2D(alt vec::last_opt(run.glyphs.get()) {
|
||||
Size2D(alt vec::last_opt(run.glyphs) {
|
||||
some(glyph) {
|
||||
au(*glyph.pos.offset.x + *glyph.pos.advance.x)
|
||||
}
|
||||
|
|
|
@ -1,24 +1,14 @@
|
|||
import libc::{c_void};
|
||||
import text::glyph::glyph;
|
||||
import font::font;
|
||||
import glyph::glyph;
|
||||
import shaper::shape_text;
|
||||
|
||||
#[doc="A single, unbroken line of text."]
|
||||
class text_run {
|
||||
let text: str;
|
||||
let mut glyphs: option<[glyph]>;
|
||||
let glyphs: [glyph];
|
||||
|
||||
new(-text: str) {
|
||||
self.text = text;
|
||||
self.glyphs = none;
|
||||
}
|
||||
|
||||
#[doc="
|
||||
Shapes text. This determines the location of each glyph and determines
|
||||
line break positions.
|
||||
"]
|
||||
fn shape() {
|
||||
let font = font::create_test_font();
|
||||
self.glyphs = some(shape_text(&font, self.text));
|
||||
new(font: &font, text: str) {
|
||||
self.glyphs = shape_text(font, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче