зеркало из 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 gfx::geometry::au;
|
||||||
import layout::base::*; // FIXME: Can't get around import *; resolve bug.
|
import layout::base::*; // FIXME: Can't get around import *; resolve bug.
|
||||||
import servo_text::text_run::text_run;
|
import servo_text::text_run::text_run;
|
||||||
|
import servo_text::font::create_test_font;
|
||||||
|
|
||||||
class text_box {
|
class text_box {
|
||||||
let text: str;
|
let text: str;
|
||||||
|
@ -23,12 +24,12 @@ impl text_layout_methods for @Box {
|
||||||
_ { fail "expected text box in reflow_text!" }
|
_ { fail "expected text box in reflow_text!" }
|
||||||
};
|
};
|
||||||
|
|
||||||
let run = text_run(copy subbox.text);
|
let font = create_test_font();
|
||||||
subbox.run = some(copy run);
|
let run = text_run(&font, subbox.text);
|
||||||
run.shape();
|
subbox.run = some(run);
|
||||||
|
|
||||||
self.bounds.size =
|
self.bounds.size =
|
||||||
Size2D(alt vec::last_opt(run.glyphs.get()) {
|
Size2D(alt vec::last_opt(run.glyphs) {
|
||||||
some(glyph) {
|
some(glyph) {
|
||||||
au(*glyph.pos.offset.x + *glyph.pos.advance.x)
|
au(*glyph.pos.offset.x + *glyph.pos.advance.x)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,14 @@
|
||||||
import libc::{c_void};
|
import libc::{c_void};
|
||||||
import text::glyph::glyph;
|
import font::font;
|
||||||
|
import glyph::glyph;
|
||||||
import shaper::shape_text;
|
import shaper::shape_text;
|
||||||
|
|
||||||
#[doc="A single, unbroken line of text."]
|
#[doc="A single, unbroken line of text."]
|
||||||
class text_run {
|
class text_run {
|
||||||
let text: str;
|
let glyphs: [glyph];
|
||||||
let mut glyphs: option<[glyph]>;
|
|
||||||
|
|
||||||
new(-text: str) {
|
new(font: &font, text: str) {
|
||||||
self.text = text;
|
self.glyphs = shape_text(font, 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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче