mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Fixed deprecated vector syntax
This commit is contained in:
parent
12a05daa5d
commit
1212f3df65
28 changed files with 128 additions and 127 deletions
|
@ -186,11 +186,11 @@ check-rust-opengles:
|
||||||
$(MAKE) check -C src/rust-opengles
|
$(MAKE) check -C src/rust-opengles
|
||||||
|
|
||||||
.PHONY: check-rust-glut
|
.PHONY: check-rust-glut
|
||||||
check-rust-glut:
|
check-rust-glut: $(GLUT_DEPS)
|
||||||
RUSTFLAGS="-L ../rust-opengles" $(MAKE) check -C src/rust-glut
|
RUSTFLAGS="-L ../rust-opengles" $(MAKE) check -C src/rust-glut
|
||||||
|
|
||||||
.PHONY: check-rust-layers
|
.PHONY: check-rust-layers
|
||||||
check-rust-layers:
|
check-rust-layers: $(LAYERS_DEPS)
|
||||||
RUSTFLAGS="-L ../rust-geom -L ../rust-opengles -L ../rust-glut -L ../rust-azure -L ../rust-cocoa" \
|
RUSTFLAGS="-L ../rust-geom -L ../rust-opengles -L ../rust-glut -L ../rust-azure -L ../rust-cocoa" \
|
||||||
$(MAKE) check -C src/rust-layers
|
$(MAKE) check -C src/rust-layers
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e9f7c1a5944608dd55d5dfb517c86c408e23a0ff
|
Subproject commit 50c5e964d91316ce19d7be8de68903eedca87703
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9a133eb6edcc576b006fdb446a80072f7da3e229
|
Subproject commit fc51299da10833faa6fe322ced5e998139015c76
|
|
@ -1 +1 @@
|
||||||
Subproject commit a878f4fa59f7f95e527e342eeb1a7041e735582a
|
Subproject commit ce58ddadbc61b3c79033db13b3e63ac2946c7588
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2d87ae88486ee1a438fa71d1199dd7bc987b17fa
|
Subproject commit 30f1c06c32979da20f6dc82119b4037deba08229
|
|
@ -51,6 +51,7 @@ of the RCU nodes themselves.
|
||||||
|
|
||||||
import ptr::extensions;
|
import ptr::extensions;
|
||||||
import core::libc::types::os::arch::c95::size_t;
|
import core::libc::types::os::arch::c95::size_t;
|
||||||
|
import vec::push;
|
||||||
|
|
||||||
export Handle;
|
export Handle;
|
||||||
export ReaderMethods;
|
export ReaderMethods;
|
||||||
|
@ -59,7 +60,7 @@ export Scope;
|
||||||
|
|
||||||
type ScopeData<T:send,A> = {
|
type ScopeData<T:send,A> = {
|
||||||
mut layout_active: bool,
|
mut layout_active: bool,
|
||||||
mut free_list: [Handle<T,A>],
|
mut free_list: ~[Handle<T,A>],
|
||||||
mut first_dirty: Handle<T,A>
|
mut first_dirty: Handle<T,A>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ fn null_handle<T:send,A>() -> Handle<T,A> {
|
||||||
|
|
||||||
fn Scope<T:send,A>() -> Scope<T,A> {
|
fn Scope<T:send,A>() -> Scope<T,A> {
|
||||||
@ScopeResource({mut layout_active: false,
|
@ScopeResource({mut layout_active: false,
|
||||||
mut free_list: [],
|
mut free_list: ~[],
|
||||||
mut first_dirty: null_handle()})
|
mut first_dirty: null_handle()})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +220,7 @@ impl WriterMethods<T:copy send,A> for Scope<T,A> {
|
||||||
(*d).read_aux = ptr::null();
|
(*d).read_aux = ptr::null();
|
||||||
(*d).next_dirty = null_handle();
|
(*d).next_dirty = null_handle();
|
||||||
let h = _Handle(d);
|
let h = _Handle(d);
|
||||||
self.d.free_list += [h];
|
push(self.d.free_list, h);
|
||||||
ret h;
|
ret h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,12 @@ enum Attr{
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Selector{
|
enum Selector{
|
||||||
Element(str, [Attr]),
|
Element(str, ~[Attr]),
|
||||||
Child(~Selector, ~Selector),
|
Child(~Selector, ~Selector),
|
||||||
Descendant(~Selector, ~Selector),
|
Descendant(~Selector, ~Selector),
|
||||||
Sibling(~Selector, ~Selector)
|
Sibling(~Selector, ~Selector)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Rule = ([~Selector], [StyleDeclaration]);
|
type Rule = (~[~Selector], ~[StyleDeclaration]);
|
||||||
|
|
||||||
type Stylesheet = [~Rule];
|
type Stylesheet = ~[~Rule];
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
A graphics sink that renders to PNG format buffers
|
A graphics sink that renders to PNG format buffers
|
||||||
|
|
||||||
Each time the renderer renders a frame the bufsink will output a
|
Each time the renderer renders a frame the bufsink will output a
|
||||||
`[u8]` containing the frame in PNG format.
|
`~[u8]` containing the frame in PNG format.
|
||||||
"];
|
"];
|
||||||
|
|
||||||
export PngSink, Msg, Exit;
|
export PngSink, Msg, Exit;
|
||||||
|
@ -45,7 +45,7 @@ impl PngSink of Sink for chan<Msg> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn PngSink(output: chan<[u8]>) -> PngSink {
|
fn PngSink(output: chan<~[u8]>) -> PngSink {
|
||||||
spawn_listener::<Msg>(|po| {
|
spawn_listener::<Msg>(|po| {
|
||||||
let cairo_surf = cairo_image_surface_create(
|
let cairo_surf = cairo_image_surface_create(
|
||||||
CAIRO_FORMAT_ARGB32, 800 as c_int, 600 as c_int
|
CAIRO_FORMAT_ARGB32, 800 as c_int, 600 as c_int
|
||||||
|
@ -76,10 +76,10 @@ fn PngSink(output: chan<[u8]>) -> PngSink {
|
||||||
|
|
||||||
fn do_draw(sender: chan<AzDrawTargetRef>,
|
fn do_draw(sender: chan<AzDrawTargetRef>,
|
||||||
dt: AzDrawTargetRef,
|
dt: AzDrawTargetRef,
|
||||||
output: chan<[u8]>,
|
output: chan<~[u8]>,
|
||||||
cairo_surf: *cairo_surface_t) {
|
cairo_surf: *cairo_surface_t) {
|
||||||
|
|
||||||
listen(|data_ch: chan<[u8]>| {
|
listen(|data_ch: chan<~[u8]>| {
|
||||||
|
|
||||||
extern fn write_fn(closure: *c_void,
|
extern fn write_fn(closure: *c_void,
|
||||||
data: *c_uchar,
|
data: *c_uchar,
|
||||||
|
@ -87,7 +87,7 @@ fn do_draw(sender: chan<AzDrawTargetRef>,
|
||||||
|
|
||||||
-> cairo_status_t unsafe {
|
-> cairo_status_t unsafe {
|
||||||
|
|
||||||
let p: *chan<[u8]> = reinterpret_cast(closure);
|
let p: *chan<~[u8]> = reinterpret_cast(closure);
|
||||||
let data_ch = *p;
|
let data_ch = *p;
|
||||||
|
|
||||||
// Convert from *c_uchar to *u8
|
// Convert from *c_uchar to *u8
|
||||||
|
@ -108,7 +108,7 @@ fn do_draw(sender: chan<AzDrawTargetRef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect the entire image into a single vector
|
// Collect the entire image into a single vector
|
||||||
let mut result = [];
|
let mut result = ~[];
|
||||||
while data_ch.peek() {
|
while data_ch.peek() {
|
||||||
result += data_ch.recv();
|
result += data_ch.recv();
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ fn sanity_check() {
|
||||||
let sink = PngSink(self_channel);
|
let sink = PngSink(self_channel);
|
||||||
let renderer = Renderer(sink);
|
let renderer = Renderer(sink);
|
||||||
|
|
||||||
let dlist = [];
|
let dlist = ~[];
|
||||||
renderer.send(RenderMsg(dlist));
|
renderer.send(RenderMsg(dlist));
|
||||||
listen(|from_renderer| {
|
listen(|from_renderer| {
|
||||||
renderer.send(renderer::ExitMsg(from_renderer));
|
renderer.send(renderer::ExitMsg(from_renderer));
|
||||||
|
|
|
@ -9,7 +9,7 @@ enum format {
|
||||||
type image_surface = {
|
type image_surface = {
|
||||||
size: Size2D<int>,
|
size: Size2D<int>,
|
||||||
format: format,
|
format: format,
|
||||||
buffer: [u8]
|
buffer: ~[u8]
|
||||||
};
|
};
|
||||||
|
|
||||||
impl format for format {
|
impl format for format {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import util::color::Color;
|
||||||
import text::text_box;
|
import text::text_box;
|
||||||
import style::style::computed_style;
|
import style::style::computed_style;
|
||||||
import text::text_layout_methods;
|
import text::text_layout_methods;
|
||||||
|
import vec::{push, push_all};
|
||||||
|
|
||||||
enum BoxKind {
|
enum BoxKind {
|
||||||
BlockBox,
|
BlockBox,
|
||||||
|
@ -171,7 +172,7 @@ mod test {
|
||||||
fn with_screen(f: fn(*sdl::surface)) {
|
fn with_screen(f: fn(*sdl::surface)) {
|
||||||
let screen = video::set_video_mode(
|
let screen = video::set_video_mode(
|
||||||
320, 200, 32,
|
320, 200, 32,
|
||||||
[video::hwsurface], [video::doublebuf]);
|
~[video::hwsurface], ~[video::doublebuf]);
|
||||||
assert screen != ptr::null();
|
assert screen != ptr::null();
|
||||||
|
|
||||||
f(screen);
|
f(screen);
|
||||||
|
@ -180,12 +181,15 @@ mod test {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fn flat_bounds(root: @Box) -> [Rect<au>] {
|
fn flat_bounds(root: @Box) -> ~[Rect<au>] {
|
||||||
let mut r = [];
|
let mut r = ~[];
|
||||||
for tree::each_child(BTree, root) |c| {
|
for tree::each_child(BTree, root) |c| {
|
||||||
r += flat_bounds(c);
|
push_all(r, flat_bounds(c));
|
||||||
}
|
}
|
||||||
ret r + [copy root.bounds];
|
|
||||||
|
push(r, copy root.bounds);
|
||||||
|
|
||||||
|
ret r;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -218,7 +222,7 @@ mod test {
|
||||||
b3.reflow_block(au(100));
|
b3.reflow_block(au(100));
|
||||||
let fb = flat_bounds(b3);
|
let fb = flat_bounds(b3);
|
||||||
#debug["fb=%?", fb];
|
#debug["fb=%?", fb];
|
||||||
assert fb == [geometry::box(au(0), au(0), au(10), au(10)), // n0
|
assert fb == ~[geometry::box(au(0), au(0), au(10), au(10)), // n0
|
||||||
geometry::box(au(0), au(10), au(10), au(15)), // n1
|
geometry::box(au(0), au(10), au(10), au(15)), // n1
|
||||||
geometry::box(au(0), au(25), au(10), au(20)), // n2
|
geometry::box(au(0), au(25), au(10), au(20)), // n2
|
||||||
geometry::box(au(0), au(0), au(100), au(45))]; // n3
|
geometry::box(au(0), au(0), au(100), au(45))]; // n3
|
||||||
|
|
|
@ -16,4 +16,4 @@ enum display_item = {
|
||||||
bounds: Rect<au>
|
bounds: Rect<au>
|
||||||
};
|
};
|
||||||
|
|
||||||
type display_list = [display_item];
|
type display_list = ~[display_item];
|
||||||
|
|
|
@ -13,6 +13,7 @@ import geom::size::Size2D;
|
||||||
import geom::point::Point2D;
|
import geom::point::Point2D;
|
||||||
import geom::rect::Rect;
|
import geom::rect::Rect;
|
||||||
import base::{Box, TextBox, BTree, BoxTreeReadMethods};
|
import base::{Box, TextBox, BTree, BoxTreeReadMethods};
|
||||||
|
import vec::push;
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
|
|
||||||
|
@ -63,8 +64,8 @@ Creates a display list item for a single block.
|
||||||
|
|
||||||
"]
|
"]
|
||||||
#[warn(no_non_implicitly_copyable_typarams)]
|
#[warn(no_non_implicitly_copyable_typarams)]
|
||||||
fn box_to_display_items(box: @Box, origin: Point2D<au>) -> [dl::display_item] {
|
fn box_to_display_items(box: @Box, origin: Point2D<au>) -> ~[dl::display_item] {
|
||||||
let mut items = [];
|
let mut items = ~[];
|
||||||
|
|
||||||
#debug("request to display a box from origin %?", origin);
|
#debug("request to display a box from origin %?", origin);
|
||||||
|
|
||||||
|
@ -74,38 +75,36 @@ fn box_to_display_items(box: @Box, origin: Point2D<au>) -> [dl::display_item] {
|
||||||
(TextBox(subbox), _, _) {
|
(TextBox(subbox), _, _) {
|
||||||
let run = copy subbox.run;
|
let run = copy subbox.run;
|
||||||
assert run.is_some();
|
assert run.is_some();
|
||||||
items += [
|
push(items, dl::display_item({
|
||||||
dl::display_item({
|
|
||||||
item_type: dl::display_item_solid_color(255u8, 255u8, 255u8),
|
item_type: dl::display_item_solid_color(255u8, 255u8, 255u8),
|
||||||
bounds: bounds
|
bounds: bounds
|
||||||
}),
|
}));
|
||||||
dl::display_item({
|
push(items, dl::display_item({
|
||||||
item_type: dl::display_item_text(run.get()),
|
item_type: dl::display_item_text(run.get()),
|
||||||
bounds: bounds
|
bounds: bounds
|
||||||
})
|
}));
|
||||||
];
|
|
||||||
}
|
}
|
||||||
(_, some(image), some(*)) | (_, some(image), none) {
|
(_, some(image), some(*)) | (_, some(image), none) {
|
||||||
items += [dl::display_item({
|
push(items, dl::display_item({
|
||||||
item_type: dl::display_item_image(~copy *image),
|
item_type: dl::display_item_image(~copy *image),
|
||||||
bounds: bounds
|
bounds: bounds
|
||||||
})];
|
}));
|
||||||
}
|
}
|
||||||
(_, none, some(col)) {
|
(_, none, some(col)) {
|
||||||
#debug("Assigning color %? to box with bounds %?", col, bounds);
|
#debug("Assigning color %? to box with bounds %?", col, bounds);
|
||||||
items += [dl::display_item({
|
push(items, dl::display_item({
|
||||||
item_type: dl::display_item_solid_color(col.red, col.green, col.blue),
|
item_type: dl::display_item_solid_color(col.red, col.green, col.blue),
|
||||||
bounds: bounds
|
bounds: bounds
|
||||||
})];
|
}));
|
||||||
}
|
}
|
||||||
(_, none, none) {
|
(_, none, none) {
|
||||||
let r = rand::rng();
|
let r = rand::rng();
|
||||||
items += [dl::display_item({
|
push(items, dl::display_item({
|
||||||
item_type: dl::display_item_solid_color(r.next() as u8,
|
item_type: dl::display_item_solid_color(r.next() as u8,
|
||||||
r.next() as u8,
|
r.next() as u8,
|
||||||
r.next() as u8),
|
r.next() as u8),
|
||||||
bounds: bounds
|
bounds: bounds
|
||||||
})];
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ mod test {
|
||||||
let scope = NodeScope();
|
let scope = NodeScope();
|
||||||
let node = new_node_from_attr(scope, "lang", "en-us");
|
let node = new_node_from_attr(scope, "lang", "en-us");
|
||||||
|
|
||||||
let sel = Element("*", [StartsWith("lang", "en")]);
|
let sel = Element("*", ~[StartsWith("lang", "en")]);
|
||||||
|
|
||||||
assert node.matches_selector(~sel);
|
assert node.matches_selector(~sel);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ mod test {
|
||||||
let scope = NodeScope();
|
let scope = NodeScope();
|
||||||
let node = new_node_from_attr(scope, "lang", "en");
|
let node = new_node_from_attr(scope, "lang", "en");
|
||||||
|
|
||||||
let sel = Element("*", [StartsWith("lang", "en")]);
|
let sel = Element("*", ~[StartsWith("lang", "en")]);
|
||||||
|
|
||||||
assert node.matches_selector(~sel);
|
assert node.matches_selector(~sel);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ mod test {
|
||||||
let scope = NodeScope();
|
let scope = NodeScope();
|
||||||
let node = new_node_from_attr(scope, "lang", "english");
|
let node = new_node_from_attr(scope, "lang", "english");
|
||||||
|
|
||||||
let sel = Element("*", [StartsWith("lang", "en")]);
|
let sel = Element("*", ~[StartsWith("lang", "en")]);
|
||||||
|
|
||||||
assert !node.matches_selector(~sel);
|
assert !node.matches_selector(~sel);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ mod test {
|
||||||
let scope = NodeScope();
|
let scope = NodeScope();
|
||||||
let node = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
let node = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
||||||
|
|
||||||
let sel = Element("div", [Includes("mad", "hatter")]);
|
let sel = Element("div", ~[Includes("mad", "hatter")]);
|
||||||
|
|
||||||
assert node.matches_selector(~sel);
|
assert node.matches_selector(~sel);
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,8 @@ mod test {
|
||||||
let scope = NodeScope();
|
let scope = NodeScope();
|
||||||
let node = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
let node = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
||||||
|
|
||||||
let sel1 = Element("div", [Exists("mad")]);
|
let sel1 = Element("div", ~[Exists("mad")]);
|
||||||
let sel2 = Element("div", [Exists("hatter")]);
|
let sel2 = Element("div", ~[Exists("hatter")]);
|
||||||
|
|
||||||
assert node.matches_selector(~sel1);
|
assert node.matches_selector(~sel1);
|
||||||
assert !node.matches_selector(~sel2);
|
assert !node.matches_selector(~sel2);
|
||||||
|
@ -272,7 +272,7 @@ mod test {
|
||||||
let node1 = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
let node1 = new_node_from_attr(scope, "mad", "hatter cobler cooper");
|
||||||
let node2 = new_node_from_attr(scope, "mad", "hatter");
|
let node2 = new_node_from_attr(scope, "mad", "hatter");
|
||||||
|
|
||||||
let sel = Element("div", [Exact("mad", "hatter")]);
|
let sel = Element("div", ~[Exact("mad", "hatter")]);
|
||||||
|
|
||||||
assert !node1.matches_selector(~copy sel);
|
assert !node1.matches_selector(~copy sel);
|
||||||
assert node2.matches_selector(~sel);
|
assert node2.matches_selector(~sel);
|
||||||
|
@ -295,8 +295,8 @@ mod test {
|
||||||
scope.add_child(gchild, ggchild);
|
scope.add_child(gchild, ggchild);
|
||||||
scope.add_child(ggchild, gggchild);
|
scope.add_child(ggchild, gggchild);
|
||||||
|
|
||||||
let sel1 = Descendant(~Element("*", [Exact("class", "blue")]),
|
let sel1 = Descendant(~Element("*", ~[Exact("class", "blue")]),
|
||||||
~Element("*", []));
|
~Element("*", ~[]));
|
||||||
|
|
||||||
assert !root.matches_selector(~copy sel1);
|
assert !root.matches_selector(~copy sel1);
|
||||||
assert child1.matches_selector(~copy sel1);
|
assert child1.matches_selector(~copy sel1);
|
||||||
|
@ -305,9 +305,9 @@ mod test {
|
||||||
assert ggchild.matches_selector(~copy sel1);
|
assert ggchild.matches_selector(~copy sel1);
|
||||||
assert gggchild.matches_selector(~sel1);
|
assert gggchild.matches_selector(~sel1);
|
||||||
|
|
||||||
let sel2 = Descendant(~Child(~Element("*", [Exact("class", "blue")]),
|
let sel2 = Descendant(~Child(~Element("*", ~[Exact("class", "blue")]),
|
||||||
~Element("*", [])),
|
~Element("*", ~[])),
|
||||||
~Element("div", [Exists("flag")]));
|
~Element("div", ~[Exists("flag")]));
|
||||||
|
|
||||||
assert !root.matches_selector(~copy sel2);
|
assert !root.matches_selector(~copy sel2);
|
||||||
assert !child1.matches_selector(~copy sel2);
|
assert !child1.matches_selector(~copy sel2);
|
||||||
|
@ -316,7 +316,7 @@ mod test {
|
||||||
assert ggchild.matches_selector(~copy sel2);
|
assert ggchild.matches_selector(~copy sel2);
|
||||||
assert gggchild.matches_selector(~sel2);
|
assert gggchild.matches_selector(~sel2);
|
||||||
|
|
||||||
let sel3 = Sibling(~Element("*", []), ~Element("*", []));
|
let sel3 = Sibling(~Element("*", ~[]), ~Element("*", ~[]));
|
||||||
|
|
||||||
assert !root.matches_selector(~copy sel3);
|
assert !root.matches_selector(~copy sel3);
|
||||||
assert child1.matches_selector(~copy sel3);
|
assert child1.matches_selector(~copy sel3);
|
||||||
|
@ -325,9 +325,9 @@ mod test {
|
||||||
assert !ggchild.matches_selector(~copy sel3);
|
assert !ggchild.matches_selector(~copy sel3);
|
||||||
assert !gggchild.matches_selector(~sel3);
|
assert !gggchild.matches_selector(~sel3);
|
||||||
|
|
||||||
let sel4 = Descendant(~Child(~Element("*", [Exists("class")]),
|
let sel4 = Descendant(~Child(~Element("*", ~[Exists("class")]),
|
||||||
~Element("*", [])),
|
~Element("*", ~[])),
|
||||||
~Element("*", []));
|
~Element("*", ~[]));
|
||||||
|
|
||||||
assert !root.matches_selector(~copy sel4);
|
assert !root.matches_selector(~copy sel4);
|
||||||
assert !child1.matches_selector(~copy sel4);
|
assert !child1.matches_selector(~copy sel4);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import uri::uri;
|
||||||
|
|
||||||
iface input_stream {
|
iface input_stream {
|
||||||
fn close();
|
fn close();
|
||||||
fn read() -> [u8];
|
fn read() -> ~[u8];
|
||||||
}
|
}
|
||||||
|
|
||||||
iface channel {
|
iface channel {
|
||||||
|
|
|
@ -6,7 +6,7 @@ from command line arguments.
|
||||||
"];
|
"];
|
||||||
|
|
||||||
type Opts = {
|
type Opts = {
|
||||||
urls: [str],
|
urls: ~[str],
|
||||||
render_mode: RenderMode
|
render_mode: RenderMode
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@ enum RenderMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[warn(no_non_implicitly_copyable_typarams)]
|
#[warn(no_non_implicitly_copyable_typarams)]
|
||||||
fn from_cmdline_args(args: [str]) -> Opts {
|
fn from_cmdline_args(args: ~[str]) -> Opts {
|
||||||
import std::getopts;
|
import std::getopts;
|
||||||
|
|
||||||
let args = args.tail();
|
let args = args.tail();
|
||||||
|
|
||||||
let opts = [
|
let opts = ~[
|
||||||
getopts::optopt("o")
|
getopts::optopt("o")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import parser::css_lexer::{Token, StartDescription, EndDescription,
|
||||||
import comm::recv;
|
import comm::recv;
|
||||||
import option::is_none;
|
import option::is_none;
|
||||||
import util::color::parsing::parse_color;
|
import util::color::parsing::parse_color;
|
||||||
|
import vec::push;
|
||||||
|
|
||||||
type TokenReader = {stream : port<Token>, mut lookahead : option<Token>};
|
type TokenReader = {stream : port<Token>, mut lookahead : option<Token>};
|
||||||
|
|
||||||
|
@ -37,13 +38,13 @@ fn parse_element(reader : TokenReader) -> option<~style::Selector> {
|
||||||
_ { fail "Expected an element" }
|
_ { fail "Expected an element" }
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut attr_list = [];
|
let mut attr_list = ~[];
|
||||||
|
|
||||||
// Get the attributes associated with that element
|
// Get the attributes associated with that element
|
||||||
loop {
|
loop {
|
||||||
let tok = reader.get();
|
let tok = reader.get();
|
||||||
alt tok {
|
alt tok {
|
||||||
Attr(attr) { attr_list += [copy attr]; }
|
Attr(attr) { push(attr_list, copy attr); }
|
||||||
StartDescription | Descendant | Child | Sibling | Comma {
|
StartDescription | Descendant | Child | Sibling | Comma {
|
||||||
reader.unget(tok);
|
reader.unget(tok);
|
||||||
break;
|
break;
|
||||||
|
@ -60,8 +61,8 @@ fn parse_element(reader : TokenReader) -> option<~style::Selector> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_rule(reader : TokenReader) -> option<~style::Rule> {
|
fn parse_rule(reader : TokenReader) -> option<~style::Rule> {
|
||||||
let mut sel_list = [];
|
let mut sel_list = ~[];
|
||||||
let mut desc_list = [];
|
let mut desc_list = ~[];
|
||||||
|
|
||||||
// Collect all the selectors that this rule applies to
|
// Collect all the selectors that this rule applies to
|
||||||
loop {
|
loop {
|
||||||
|
@ -107,13 +108,13 @@ fn parse_rule(reader : TokenReader) -> option<~style::Rule> {
|
||||||
}
|
}
|
||||||
StartDescription {
|
StartDescription {
|
||||||
let built_sel <- cur_sel;
|
let built_sel <- cur_sel;
|
||||||
sel_list += [built_sel];
|
push(sel_list, built_sel);
|
||||||
reader.unget(StartDescription);
|
reader.unget(StartDescription);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Comma {
|
Comma {
|
||||||
let built_sel <- cur_sel;
|
let built_sel <- cur_sel;
|
||||||
sel_list += [built_sel];
|
push(sel_list, built_sel);
|
||||||
reader.unget(Comma);
|
reader.unget(Comma);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -146,27 +147,25 @@ fn parse_rule(reader : TokenReader) -> option<~style::Rule> {
|
||||||
let num = val.substr(0u, val.len() - 2u);
|
let num = val.substr(0u, val.len() - 2u);
|
||||||
|
|
||||||
alt uint::from_str(num) {
|
alt uint::from_str(num) {
|
||||||
some(n) { desc_list += [FontSize(n)]; }
|
some(n) { push(desc_list, FontSize(n)); }
|
||||||
none { fail "Nonnumber provided as font size"; }
|
none { fail "Nonnumber provided as font size"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"display" {
|
"display" {
|
||||||
alt val {
|
alt val {
|
||||||
"inline" { desc_list += [Display(DisInline)]; }
|
"inline" { push(desc_list, Display(DisInline)); }
|
||||||
"block" { desc_list += [Display(DisBlock)]; }
|
"block" { push(desc_list, Display(DisBlock)); }
|
||||||
"none" { desc_list += [Display(DisNone)]; }
|
"none" { push(desc_list, Display(DisNone)); }
|
||||||
_ { #debug["Recieved unknown display value '%s'",
|
_ { #debug["Recieved unknown display value '%s'", val]; }
|
||||||
val]; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"color" {
|
"color" {
|
||||||
desc_list += [TextColor(parse_color(val))];
|
push(desc_list, TextColor(parse_color(val)));
|
||||||
}
|
}
|
||||||
"background-color" {
|
"background-color" {
|
||||||
desc_list += [BackgroundColor(parse_color(val))];
|
push(desc_list, BackgroundColor(parse_color(val)));
|
||||||
}
|
}
|
||||||
_ { #debug["Recieved unknown style property '%s'",
|
_ { #debug["Recieved unknown style property '%s'", val]; }
|
||||||
val]; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Eof { ret none; }
|
Eof { ret none; }
|
||||||
|
@ -180,13 +179,13 @@ fn parse_rule(reader : TokenReader) -> option<~style::Rule> {
|
||||||
ret some(~(sel_list, desc_list));
|
ret some(~(sel_list, desc_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_stylesheet(stream : port<Token>) -> [~style::Rule] {
|
fn build_stylesheet(stream : port<Token>) -> ~[~style::Rule] {
|
||||||
let mut rule_list = [];
|
let mut rule_list = ~[];
|
||||||
let reader = {stream : stream, mut lookahead : none};
|
let reader = {stream : stream, mut lookahead : none};
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
alt parse_rule(reader) {
|
alt parse_rule(reader) {
|
||||||
some(rule) { rule_list += [copy rule]; }
|
some(rule) { push(rule_list, copy rule); }
|
||||||
none { break; }
|
none { break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import comm::{port, chan};
|
||||||
import dom::style;
|
import dom::style;
|
||||||
import option::is_none;
|
import option::is_none;
|
||||||
import str::from_bytes;
|
import str::from_bytes;
|
||||||
|
import vec::push;
|
||||||
|
|
||||||
import lexer_util::*;
|
import lexer_util::*;
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ impl css_methods for CssLexer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut desc_name = [];
|
let mut desc_name = ~[];
|
||||||
|
|
||||||
// Get the name of the descriptor
|
// Get the name of the descriptor
|
||||||
loop {
|
loop {
|
||||||
|
@ -168,7 +169,7 @@ impl css_methods for CssLexer {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
desc_name += [ch];
|
push(desc_name, ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
alt self.input_state.get() {
|
alt self.input_state.get() {
|
||||||
|
@ -178,7 +179,7 @@ impl css_methods for CssLexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.input_state.eat_whitespace();
|
self.input_state.eat_whitespace();
|
||||||
let mut desc_val = [];
|
let mut desc_val = ~[];
|
||||||
|
|
||||||
// Get the value of the descriptor
|
// Get the value of the descriptor
|
||||||
loop {
|
loop {
|
||||||
|
@ -203,7 +204,7 @@ impl css_methods for CssLexer {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
desc_val += [ch];
|
push(desc_val, ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import gfx::geometry::au;
|
||||||
import parser = parser::html_lexer;
|
import parser = parser::html_lexer;
|
||||||
import parser::Token;
|
import parser::Token;
|
||||||
import dom::style::Stylesheet;
|
import dom::style::Stylesheet;
|
||||||
|
import vec::{push, push_all_move, flat_map};
|
||||||
import dvec::extensions;
|
import dvec::extensions;
|
||||||
|
|
||||||
enum css_message {
|
enum css_message {
|
||||||
|
@ -86,7 +86,7 @@ spawned, collates them, and sends them to the given result channel.
|
||||||
|
|
||||||
"]
|
"]
|
||||||
fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_message>) {
|
fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_message>) {
|
||||||
let mut result_vec = [];
|
let mut result_vec = ~[];
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
alt from_parent.recv() {
|
alt from_parent.recv() {
|
||||||
|
@ -101,7 +101,7 @@ fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_messag
|
||||||
let mut css_rules = css_builder::build_stylesheet(css_stream);
|
let mut css_rules = css_builder::build_stylesheet(css_stream);
|
||||||
result_chan.send(css_rules);
|
result_chan.send(css_rules);
|
||||||
});
|
});
|
||||||
result_vec += [result_port];
|
push(result_vec, result_port);
|
||||||
}
|
}
|
||||||
exit {
|
exit {
|
||||||
break;
|
break;
|
||||||
|
@ -109,12 +109,7 @@ fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_messag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let css_rules = [];
|
let css_rules = flat_map(result_vec, |result_port| { result_port.recv() });
|
||||||
|
|
||||||
let css_rules = result_vec.foldl(css_rules, |rules, result_port| {
|
|
||||||
let new_rules = result_port.recv();
|
|
||||||
rules + new_rules
|
|
||||||
});
|
|
||||||
|
|
||||||
to_parent.send(css_rules);
|
to_parent.send(css_rules);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import comm::{port, chan};
|
||||||
import dom::style;
|
import dom::style;
|
||||||
import option::is_none;
|
import option::is_none;
|
||||||
import str::from_bytes;
|
import str::from_bytes;
|
||||||
|
import vec::push;
|
||||||
import lexer_util::*;
|
import lexer_util::*;
|
||||||
|
|
||||||
enum Token {
|
enum Token {
|
||||||
|
@ -76,7 +77,7 @@ impl html_methods for HtmlLexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a text node.
|
// Make a text node.
|
||||||
let mut s: [u8] = [ch];
|
let mut s: ~[u8] = ~[ch];
|
||||||
loop {
|
loop {
|
||||||
alt self.input_state.get() {
|
alt self.input_state.get() {
|
||||||
CoeChar(c) {
|
CoeChar(c) {
|
||||||
|
@ -84,7 +85,7 @@ impl html_methods for HtmlLexer {
|
||||||
self.input_state.unget(c);
|
self.input_state.unget(c);
|
||||||
ret Text(from_bytes(s));
|
ret Text(from_bytes(s));
|
||||||
}
|
}
|
||||||
s += [c];
|
push(s, c);
|
||||||
}
|
}
|
||||||
CoeEof { ret Text(from_bytes(s)); }
|
CoeEof { ret Text(from_bytes(s)); }
|
||||||
}
|
}
|
||||||
|
@ -120,12 +121,12 @@ impl html_methods for HtmlLexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse an attribute.
|
// Parse an attribute.
|
||||||
let mut attribute_name = [ch];
|
let mut attribute_name = ~[ch];
|
||||||
loop {
|
loop {
|
||||||
alt self.input_state.get() {
|
alt self.input_state.get() {
|
||||||
CoeChar(c) {
|
CoeChar(c) {
|
||||||
if c == ('=' as u8) { break; }
|
if c == ('=' as u8) { break; }
|
||||||
attribute_name += [c];
|
push(attribute_name, c);
|
||||||
}
|
}
|
||||||
CoeEof {
|
CoeEof {
|
||||||
let name = from_bytes(attribute_name);
|
let name = from_bytes(attribute_name);
|
||||||
|
@ -136,12 +137,12 @@ impl html_methods for HtmlLexer {
|
||||||
|
|
||||||
// Parse the attribute value.
|
// Parse the attribute value.
|
||||||
self.input_state.expect('"' as u8);
|
self.input_state.expect('"' as u8);
|
||||||
let mut attribute_value = [];
|
let mut attribute_value = ~[];
|
||||||
loop {
|
loop {
|
||||||
alt self.input_state.get() {
|
alt self.input_state.get() {
|
||||||
CoeChar(c) {
|
CoeChar(c) {
|
||||||
if c == ('"' as u8) { break; }
|
if c == ('"' as u8) { break; }
|
||||||
attribute_value += [c];
|
push(attribute_value, c);
|
||||||
}
|
}
|
||||||
CoeEof {
|
CoeEof {
|
||||||
ret Attr(from_bytes(attribute_name), from_bytes(attribute_value));
|
ret Attr(from_bytes(attribute_name), from_bytes(attribute_value));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import option::is_none;
|
import option::is_none;
|
||||||
import str::from_bytes;
|
import str::from_bytes;
|
||||||
|
import vec::push;
|
||||||
|
|
||||||
enum CharOrEof {
|
enum CharOrEof {
|
||||||
CoeChar(u8),
|
CoeChar(u8),
|
||||||
|
@ -63,12 +63,12 @@ impl util_methods for InputState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_ident() -> str {
|
fn parse_ident() -> str {
|
||||||
let mut result: [u8] = [];
|
let mut result: ~[u8] = ~[];
|
||||||
loop {
|
loop {
|
||||||
alt self.get() {
|
alt self.get() {
|
||||||
CoeChar(c) {
|
CoeChar(c) {
|
||||||
if (c.is_alpha()) {
|
if (c.is_alpha()) {
|
||||||
result += [c];
|
push(result, c);
|
||||||
} else if result.len() == 0u {
|
} else if result.len() == 0u {
|
||||||
self.parse_err("expected ident");
|
self.parse_err("expected ident");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import dom::event::{Event, ResizeEvent};
|
||||||
import layers::ImageLayer;
|
import layers::ImageLayer;
|
||||||
import geom::size::Size2D;
|
import geom::size::Size2D;
|
||||||
import std::cmp::fuzzy_eq;
|
import std::cmp::fuzzy_eq;
|
||||||
|
import vec::push;
|
||||||
|
|
||||||
type OSMain = chan<Msg>;
|
type OSMain = chan<Msg>;
|
||||||
|
|
||||||
|
@ -200,6 +201,7 @@ type surface = {
|
||||||
|
|
||||||
fn mk_surface() -> surface {
|
fn mk_surface() -> surface {
|
||||||
let cairo_surf = cairo_image_surface_create(cairo::CAIRO_FORMAT_RGB24, 800, 600);
|
let cairo_surf = cairo_image_surface_create(cairo::CAIRO_FORMAT_RGB24, 800, 600);
|
||||||
|
|
||||||
assert !ptr::is_null(cairo_surf);
|
assert !ptr::is_null(cairo_surf);
|
||||||
|
|
||||||
let azure_target = AzCreateDrawTargetForCairoSurface(cairo_surf);
|
let azure_target = AzCreateDrawTargetForCairoSurface(cairo_surf);
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
#[license = "MPL"];
|
#[license = "MPL"];
|
||||||
#[crate_type = "lib"];
|
#[crate_type = "lib"];
|
||||||
|
|
||||||
#[warn(no_old_vecs)];
|
|
||||||
|
|
||||||
use std;
|
use std;
|
||||||
use sdl;
|
use sdl;
|
||||||
use azure;
|
use azure;
|
||||||
|
@ -96,6 +94,7 @@ mod util {
|
||||||
mod unsafe;
|
mod unsafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[warn(no_non_implicitly_copyable_typarams)]
|
||||||
mod content {
|
mod content {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import osmain::{OSMain, AddKeyHandler};
|
||||||
import opts::{Opts, Screen, Png};
|
import opts::{Opts, Screen, Png};
|
||||||
import engine::{Engine, LoadURLMsg};
|
import engine::{Engine, LoadURLMsg};
|
||||||
|
|
||||||
fn main(args: [str]) {
|
fn main(args: ~[str]) {
|
||||||
run(opts::from_cmdline_args(args))
|
run(opts::from_cmdline_args(args))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ fn run(opts: Opts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_pipeline_screen(urls: [str]) {
|
fn run_pipeline_screen(urls: ~[str]) {
|
||||||
|
|
||||||
// The platform event handler thread
|
// The platform event handler thread
|
||||||
let osmain = OSMain();
|
let osmain = OSMain();
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Font {
|
||||||
let cairo_font: *cairo_scaled_font_t;
|
let cairo_font: *cairo_scaled_font_t;
|
||||||
let font_dtor: fn@();
|
let font_dtor: fn@();
|
||||||
|
|
||||||
new(-fontbuf: [u8]) {
|
new(-fontbuf: ~[u8]) {
|
||||||
let (cairo_font, font_dtor) = get_cairo_font(© fontbuf);
|
let (cairo_font, font_dtor) = get_cairo_font(© fontbuf);
|
||||||
assert cairo_font.is_not_null();
|
assert cairo_font.is_not_null();
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class Font {
|
||||||
|
|
||||||
#debug("getting h advance for glyph %?", glyph);
|
#debug("getting h advance for glyph %?", glyph);
|
||||||
|
|
||||||
let glyphs: [cairo_glyph_t] = [{
|
let glyphs: ~[cairo_glyph_t] = ~[{
|
||||||
index: glyph as c_ulong,
|
index: glyph as c_ulong,
|
||||||
x: 0 as c_double,
|
x: 0 as c_double,
|
||||||
y: 0 as c_double,
|
y: 0 as c_double,
|
||||||
|
@ -264,7 +264,7 @@ fn create_test_font() -> @Font {
|
||||||
ret flib.get_test_font();
|
ret flib.get_test_font();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_font_bin() -> [u8] { #include_bin("JosefinSans-SemiBold.ttf") }
|
fn test_font_bin() -> ~[u8] { #include_bin("JosefinSans-SemiBold.ttf") }
|
||||||
|
|
||||||
fn should_destruct_on_fail_without_leaking() {
|
fn should_destruct_on_fail_without_leaking() {
|
||||||
#[test];
|
#[test];
|
||||||
|
|
|
@ -48,7 +48,7 @@ class QuartzNativeFont/& {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(buf: [u8]) -> result<QuartzNativeFont, ()> {
|
fn create(buf: ~[u8]) -> result<QuartzNativeFont, ()> {
|
||||||
let fontprov = vec::as_buf(buf, |cbuf| {
|
let fontprov = vec::as_buf(buf, |cbuf| {
|
||||||
CGDataProviderCreateWithData(
|
CGDataProviderCreateWithData(
|
||||||
null(),
|
null(),
|
||||||
|
|
|
@ -35,7 +35,7 @@ import harfbuzz::bindgen::{hb_blob_create, hb_blob_destroy,
|
||||||
Calculate the layout metrics associated with a some given text
|
Calculate the layout metrics associated with a some given text
|
||||||
when rendered in a specific font.
|
when rendered in a specific font.
|
||||||
"]
|
"]
|
||||||
fn shape_text(font: &Font, text: str) -> [Glyph] unsafe {
|
fn shape_text(font: &Font, text: str) -> ~[Glyph] unsafe {
|
||||||
#debug("shaping text '%s'", text);
|
#debug("shaping text '%s'", text);
|
||||||
|
|
||||||
let face_blob = vec::as_buf(*(*font).buf(), |buf| {
|
let face_blob = vec::as_buf(*(*font).buf(), |buf| {
|
||||||
|
@ -79,7 +79,7 @@ fn shape_text(font: &Font, text: str) -> [Glyph] unsafe {
|
||||||
|
|
||||||
assert info_len == pos_len;
|
assert info_len == pos_len;
|
||||||
|
|
||||||
let mut glyphs = [];
|
let mut glyphs = ~[];
|
||||||
|
|
||||||
for uint::range(0u, info_len as uint) |i| {
|
for uint::range(0u, info_len as uint) |i| {
|
||||||
let info_ = offset(info_, i);
|
let info_ = offset(info_, i);
|
||||||
|
@ -89,7 +89,7 @@ fn shape_text(font: &Font, text: str) -> [Glyph] unsafe {
|
||||||
#debug("glyph %?: codep %?, x_adv %?, y_adv %?, x_off %?, y_of %?",
|
#debug("glyph %?: codep %?, x_adv %?, y_adv %?, x_off %?, y_of %?",
|
||||||
i, codepoint, pos.advance.x, pos.advance.y, pos.offset.x, pos.offset.y);
|
i, codepoint, pos.advance.x, pos.advance.y, pos.offset.x, pos.offset.y);
|
||||||
|
|
||||||
glyphs += [Glyph(codepoint, pos)];
|
glyphs += ~[Glyph(codepoint, pos)];
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_buffer_destroy(buffer);
|
hb_buffer_destroy(buffer);
|
||||||
|
@ -148,7 +148,7 @@ fn should_get_glyph_indexes() {
|
||||||
let font = font::create_test_font();
|
let font = font::create_test_font();
|
||||||
let glyphs = shape_text(font, "firecracker");
|
let glyphs = shape_text(font, "firecracker");
|
||||||
let idxs = glyphs.map(|glyph| glyph.index);
|
let idxs = glyphs.map(|glyph| glyph.index);
|
||||||
assert idxs == [32u, 8u, 13u, 14u, 10u, 13u, 201u, 10u, 37u, 14u, 13u];
|
assert idxs == ~[32u, 8u, 13u, 14u, 10u, 13u, 201u, 10u, 37u, 14u, 13u];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_get_glyph_h_advance() {
|
fn should_get_glyph_h_advance() {
|
||||||
|
@ -158,6 +158,6 @@ fn should_get_glyph_h_advance() {
|
||||||
let font = font::create_test_font();
|
let font = font::create_test_font();
|
||||||
let glyphs = shape_text(font, "firecracker");
|
let glyphs = shape_text(font, "firecracker");
|
||||||
let actual = glyphs.map(|g| g.pos.advance.x);
|
let actual = glyphs.map(|g| g.pos.advance.x);
|
||||||
let expected = [6, 4, 7, 9, 8, 7, 10, 8, 9, 9, 7].map(|a| px_to_au(a));
|
let expected = (~[6, 4, 7, 9, 8, 7, 10, 8, 9, 9, 7]).map(|a| px_to_au(a));
|
||||||
assert expected == actual;
|
assert expected == actual;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import shaper::shape_text;
|
||||||
|
|
||||||
#[doc="A single, unbroken line of text."]
|
#[doc="A single, unbroken line of text."]
|
||||||
class TextRun {
|
class TextRun {
|
||||||
let glyphs: [Glyph];
|
let glyphs: ~[Glyph];
|
||||||
|
|
||||||
new(font: Font, text: str) {
|
new(font: Font, text: str) {
|
||||||
self.glyphs = shape_text(&font, text);
|
self.glyphs = shape_text(&font, text);
|
||||||
|
|
|
@ -99,8 +99,8 @@ mod test {
|
||||||
dummy(@{fields: empty(), value: v})
|
dummy(@{fields: empty(), value: v})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_with_3_children() -> {p: dummy, children: [dummy]} {
|
fn parent_with_3_children() -> {p: dummy, children: ~[dummy]} {
|
||||||
let children = [new_dummy(0u),
|
let children = ~[new_dummy(0u),
|
||||||
new_dummy(1u),
|
new_dummy(1u),
|
||||||
new_dummy(2u)];
|
new_dummy(2u)];
|
||||||
let p = new_dummy(3u);
|
let p = new_dummy(3u);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue