mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Remove #[legacy_modes]
This commit is contained in:
parent
47d05c9908
commit
f2022f86b7
33 changed files with 103 additions and 98 deletions
|
@ -61,7 +61,7 @@ pub enum PingMsg {
|
|||
pub type ContentTask = Chan<ControlMsg>;
|
||||
|
||||
fn ContentTask<S: Compositor Send Copy>(layout_task: LayoutTask,
|
||||
+compositor: S,
|
||||
compositor: S,
|
||||
resource_task: ResourceTask,
|
||||
img_cache_task: ImageCacheTask) -> ContentTask {
|
||||
do task().sched_mode(SingleThreaded).spawn_listener::<ControlMsg> |from_master| {
|
||||
|
@ -143,14 +143,14 @@ impl Content {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_msg(+msg: Either<ControlMsg,Event>) -> bool {
|
||||
fn handle_msg(msg: Either<ControlMsg,Event>) -> bool {
|
||||
match move msg {
|
||||
Left(move control_msg) => self.handle_control_msg(control_msg),
|
||||
Right(move event) => self.handle_event(event)
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_control_msg(+control_msg: ControlMsg) -> bool {
|
||||
fn handle_control_msg(control_msg: ControlMsg) -> bool {
|
||||
match move control_msg {
|
||||
ParseMsg(move url) => {
|
||||
debug!("content: Received url `%s` to parse", url_to_str(copy url));
|
||||
|
|
|
@ -237,7 +237,7 @@ fn parser(input_port: comm::Port<ProgressMsg>, state : ParserState) -> CssLexer
|
|||
};
|
||||
}
|
||||
|
||||
fn lex_css_from_bytes(+input_port: comm::Port<ProgressMsg>, result_chan : &Chan<Token>) {
|
||||
fn lex_css_from_bytes(input_port: comm::Port<ProgressMsg>, result_chan : &Chan<Token>) {
|
||||
let lexer = parser(input_port, CssElement);
|
||||
|
||||
loop {
|
||||
|
@ -252,7 +252,7 @@ fn lex_css_from_bytes(+input_port: comm::Port<ProgressMsg>, result_chan : &Chan<
|
|||
}
|
||||
}
|
||||
|
||||
fn spawn_css_lexer_from_string(+content : ~str) -> pipes::Port<Token> {
|
||||
fn spawn_css_lexer_from_string(content : ~str) -> pipes::Port<Token> {
|
||||
let (result_chan, result_port) = pipes::stream();
|
||||
|
||||
do task::spawn {
|
||||
|
@ -267,7 +267,7 @@ fn spawn_css_lexer_from_string(+content : ~str) -> pipes::Port<Token> {
|
|||
}
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
pub fn spawn_css_lexer_task(+url: Url, resource_task: ResourceTask) -> pipes::Port<Token> {
|
||||
pub fn spawn_css_lexer_task(url: Url, resource_task: ResourceTask) -> pipes::Port<Token> {
|
||||
let (result_chan, result_port) = pipes::stream();
|
||||
|
||||
do task::spawn || {
|
||||
|
|
|
@ -32,7 +32,7 @@ impl TokenReader : TokenReaderMethods {
|
|||
}
|
||||
}
|
||||
|
||||
fn unget(+tok : Token) {
|
||||
fn unget(tok : Token) {
|
||||
assert is_none(&self.lookahead);
|
||||
self.lookahead = Some(tok);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ impl TokenReader : ParserMethods {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn build_stylesheet(+stream : pipes::Port<Token>) -> ~[~css::Rule] {
|
||||
pub fn build_stylesheet(stream : pipes::Port<Token>) -> ~[~css::Rule] {
|
||||
let mut rule_list = ~[];
|
||||
let reader = {stream : stream, mut lookahead : None};
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ struct StyleApplicator {
|
|||
}
|
||||
|
||||
// TODO: normalize this into a normal preorder tree traversal function
|
||||
fn apply_style(layout_ctx: &LayoutContext, node: Node, +reflow: fn~()) {
|
||||
fn apply_style(layout_ctx: &LayoutContext, node: Node, reflow: fn~()) {
|
||||
let applicator = StyleApplicator {
|
||||
node: node,
|
||||
reflow: reflow
|
||||
|
@ -54,7 +54,7 @@ fn apply_style(layout_ctx: &LayoutContext, node: Node, +reflow: fn~()) {
|
|||
/** A wrapper around a set of functions that can be applied as a
|
||||
* top-down traversal of layout boxes.
|
||||
*/
|
||||
fn inheritance_wrapper(layout_ctx: &LayoutContext, node : Node, +reflow: fn~()) {
|
||||
fn inheritance_wrapper(layout_ctx: &LayoutContext, node : Node, reflow: fn~()) {
|
||||
let applicator = StyleApplicator {
|
||||
node: node,
|
||||
reflow: reflow
|
||||
|
|
|
@ -225,7 +225,7 @@ mod test {
|
|||
use dvec::DVec;
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn new_node_from_attr(scope: NodeScope, +name: ~str, +val: ~str) -> Node {
|
||||
fn new_node_from_attr(scope: &NodeScope, name: ~str, val: ~str) -> Node {
|
||||
let elmt = ElementData(~"div", ~HTMLDivElement);
|
||||
let attr = ~Attr(name, val);
|
||||
elmt.attrs.push(attr);
|
||||
|
@ -235,7 +235,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_match_pipe1() {
|
||||
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")]);
|
||||
|
||||
|
@ -245,7 +245,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_match_pipe2() {
|
||||
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")]);
|
||||
|
||||
|
@ -255,7 +255,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_not_match_pipe() {
|
||||
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")]);
|
||||
|
||||
|
@ -265,7 +265,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_match_includes() {
|
||||
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")]);
|
||||
|
||||
|
@ -275,7 +275,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_match_exists() {
|
||||
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 sel2 = Element(~"div", ~[Exists(~"hatter")]);
|
||||
|
@ -287,8 +287,8 @@ mod test {
|
|||
#[test]
|
||||
fn test_match_exact() {
|
||||
let scope = NodeScope();
|
||||
let node1 = new_node_from_attr(scope, ~"mad", ~"hatter cobler cooper");
|
||||
let node2 = new_node_from_attr(scope, ~"mad", ~"hatter");
|
||||
let node1 = new_node_from_attr(&scope, ~"mad", ~"hatter cobler cooper");
|
||||
let node2 = new_node_from_attr(&scope, ~"mad", ~"hatter");
|
||||
|
||||
let sel = Element(~"div", ~[Exact(~"mad", ~"hatter")]);
|
||||
|
||||
|
@ -300,12 +300,12 @@ mod test {
|
|||
fn match_tree() {
|
||||
let scope = NodeScope();
|
||||
|
||||
let root = new_node_from_attr(scope, ~"class", ~"blue");
|
||||
let child1 = new_node_from_attr(scope, ~"id", ~"green");
|
||||
let child2 = new_node_from_attr(scope, ~"flag", ~"black");
|
||||
let gchild = new_node_from_attr(scope, ~"flag", ~"grey");
|
||||
let ggchild = new_node_from_attr(scope, ~"flag", ~"white");
|
||||
let gggchild = new_node_from_attr(scope, ~"flag", ~"purple");
|
||||
let root = new_node_from_attr(&scope, ~"class", ~"blue");
|
||||
let child1 = new_node_from_attr(&scope, ~"id", ~"green");
|
||||
let child2 = new_node_from_attr(&scope, ~"flag", ~"black");
|
||||
let gchild = new_node_from_attr(&scope, ~"flag", ~"grey");
|
||||
let ggchild = new_node_from_attr(&scope, ~"flag", ~"white");
|
||||
let gggchild = new_node_from_attr(&scope, ~"flag", ~"purple");
|
||||
|
||||
scope.add_child(root, child1);
|
||||
scope.add_child(root, child2);
|
||||
|
|
|
@ -24,10 +24,10 @@ enum CSSValue<T : Copy> {
|
|||
}
|
||||
|
||||
impl<T : Copy> ParseResult<T> {
|
||||
pure fn extract<U>(f: fn(+v: CSSValue<T>) -> U) -> Option<U> { extract(&self, f) }
|
||||
pure fn extract<U>(f: fn(v: CSSValue<T>) -> U) -> Option<U> { extract(&self, f) }
|
||||
}
|
||||
|
||||
pure fn extract<T : Copy, U>(res: &ParseResult<T>, f: fn(+v: CSSValue<T>) -> U) -> Option<U> {
|
||||
pure fn extract<T : Copy, U>(res: &ParseResult<T>, f: fn(v: CSSValue<T>) -> U) -> Option<U> {
|
||||
match *res {
|
||||
Fail => None,
|
||||
CSSInitial => Some(f(Initial)),
|
||||
|
|
|
@ -18,7 +18,7 @@ enum DOMString {
|
|||
|
||||
type rust_box<T> = {rc: uint, td: *sys::TypeDesc, next: *(), prev: *(), payload: T};
|
||||
|
||||
unsafe fn squirrel_away<T>(+x: @T) -> *rust_box<T> {
|
||||
unsafe fn squirrel_away<T>(x: @T) -> *rust_box<T> {
|
||||
let y: *rust_box<T> = cast::reinterpret_cast(&x);
|
||||
cast::forget(x);
|
||||
y
|
||||
|
@ -26,7 +26,7 @@ unsafe fn squirrel_away<T>(+x: @T) -> *rust_box<T> {
|
|||
|
||||
type rust_unique<T> = {payload: T};
|
||||
|
||||
unsafe fn squirrel_away_unique<T>(+x: ~T) -> *rust_box<T> {
|
||||
unsafe fn squirrel_away_unique<T>(x: ~T) -> *rust_box<T> {
|
||||
let y: *rust_box<T> = cast::reinterpret_cast(&x);
|
||||
cast::forget(x);
|
||||
y
|
||||
|
@ -94,8 +94,8 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *jsval, bp: *mut JSB
|
|||
return 1;
|
||||
}
|
||||
|
||||
pub fn prototype_jsclass(+name: ~str) -> fn(+compartment: bare_compartment) -> JSClass {
|
||||
|+compartment: bare_compartment| {
|
||||
pub fn prototype_jsclass(name: ~str) -> fn(compartment: bare_compartment) -> JSClass {
|
||||
|compartment: bare_compartment| {
|
||||
{name: compartment.add_name(copy name),
|
||||
flags: 0,
|
||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
|
@ -122,9 +122,9 @@ pub fn prototype_jsclass(+name: ~str) -> fn(+compartment: bare_compartment) -> J
|
|||
}
|
||||
}
|
||||
|
||||
pub fn instance_jsclass(+name: ~str, finalize: *u8)
|
||||
-> fn(+compartment: bare_compartment) -> JSClass {
|
||||
|+compartment: bare_compartment| {
|
||||
pub fn instance_jsclass(name: ~str, finalize: *u8)
|
||||
-> fn(compartment: bare_compartment) -> JSClass {
|
||||
|compartment: bare_compartment| {
|
||||
{name: compartment.add_name(copy name),
|
||||
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
|
||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
|
@ -152,7 +152,7 @@ pub fn instance_jsclass(+name: ~str, finalize: *u8)
|
|||
}
|
||||
|
||||
// FIXME: A lot of string copies here
|
||||
pub fn define_empty_prototype(+name: ~str, +proto: Option<~str>, compartment: &bare_compartment)
|
||||
pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: &bare_compartment)
|
||||
-> js::rust::jsobj {
|
||||
compartment.register_class(utils::prototype_jsclass(copy name));
|
||||
|
||||
|
|
|
@ -73,11 +73,12 @@ struct ScopeResource<T:Send,A> {
|
|||
d : ScopeData<T,A>,
|
||||
|
||||
drop unsafe {
|
||||
error!("dropp!");
|
||||
for self.d.free_list.each |h| { free_handle(*h); }
|
||||
}
|
||||
}
|
||||
|
||||
fn ScopeResource<T:Send,A>(+d : ScopeData<T,A>) -> ScopeResource<T,A> {
|
||||
fn ScopeResource<T:Send,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> {
|
||||
ScopeResource { d: d }
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,7 @@ impl<T:Send,A> Handle<T,A> {
|
|||
fn set_read_ptr(t: *T) unsafe { (**self).read_ptr = t; }
|
||||
fn set_write_ptr(t: *mut T) unsafe { (**self).write_ptr = t; }
|
||||
fn set_read_aux(t: *A) unsafe { (**self).read_aux = t; }
|
||||
fn set_next_dirty(+h: Handle<T,A>) unsafe { (**self).next_dirty = h; }
|
||||
fn set_next_dirty(h: Handle<T,A>) unsafe { (**self).next_dirty = h; }
|
||||
|
||||
pure fn is_null() -> bool { (*self).is_null() }
|
||||
fn is_not_null() -> bool { (*self).is_not_null() }
|
||||
|
@ -222,6 +223,7 @@ impl<T:Copy Send,A> Scope<T,A> {
|
|||
// FIXME: This could avoid a deep copy by taking ownership of `v`
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn handle(v: &T) -> Handle<T,A> unsafe {
|
||||
debug!("vv: %?", *v);
|
||||
let d: *HandleData<T,A> =
|
||||
cast::reinterpret_cast(
|
||||
&libc::malloc(sys::size_of::<HandleData<T,A>>() as size_t));
|
||||
|
@ -231,6 +233,9 @@ impl<T:Copy Send,A> Scope<T,A> {
|
|||
(*d).next_dirty = null_handle();
|
||||
let h = _Handle(d);
|
||||
push(&mut self.d.free_list, h);
|
||||
do self.read(&h) |v| {
|
||||
debug!("vv: %?", *v);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ struct Document {
|
|||
css_rules: ARC<Stylesheet>,
|
||||
}
|
||||
|
||||
fn Document(+root: Node, +scope: NodeScope, +css_rules: Stylesheet) -> Document {
|
||||
fn Document(root: Node, scope: NodeScope, css_rules: Stylesheet) -> Document {
|
||||
Document {
|
||||
root : root,
|
||||
scope : scope,
|
||||
|
|
|
@ -20,7 +20,7 @@ impl ElementData {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_attr(name: &str, +value: ~str) {
|
||||
fn set_attr(name: &str, value: ~str) {
|
||||
let idx = do self.attrs.position |attr| { name == attr.name };
|
||||
match idx {
|
||||
Some(idx) => self.attrs.set_elt(idx, ~Attr(name.to_str(), value)),
|
||||
|
@ -29,7 +29,7 @@ impl ElementData {
|
|||
}
|
||||
}
|
||||
|
||||
fn ElementData(+tag_name: ~str, +kind: ~ElementKind) -> ElementData {
|
||||
fn ElementData(tag_name: ~str, kind: ~ElementKind) -> ElementData {
|
||||
ElementData {
|
||||
tag_name : tag_name,
|
||||
kind : kind,
|
||||
|
@ -42,7 +42,7 @@ struct Attr {
|
|||
value: ~str,
|
||||
}
|
||||
|
||||
fn Attr(+name: ~str, +value: ~str) -> Attr {
|
||||
fn Attr(name: ~str, value: ~str) -> Attr {
|
||||
Attr {
|
||||
name : name,
|
||||
value : value,
|
||||
|
|
|
@ -101,8 +101,8 @@ struct DoctypeData {
|
|||
force_quirks: bool
|
||||
}
|
||||
|
||||
fn DoctypeData(+name: ~str, +public_id: Option<~str>,
|
||||
+system_id: Option<~str>, force_quirks: bool) -> DoctypeData {
|
||||
fn DoctypeData(name: ~str, public_id: Option<~str>,
|
||||
system_id: Option<~str>, force_quirks: bool) -> DoctypeData {
|
||||
DoctypeData {
|
||||
name : name,
|
||||
public_id : public_id,
|
||||
|
@ -146,7 +146,7 @@ trait NodeScopeExtensions {
|
|||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
impl NodeScope : NodeScopeExtensions {
|
||||
fn new_node(+k: NodeKind) -> Node {
|
||||
fn new_node(k: NodeKind) -> Node {
|
||||
self.handle(&NodeData({tree: tree::empty(), kind: ~k}))
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ impl NodeScope : tree::ReadMethods<Node> {
|
|||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
impl NodeScope : tree::WriteMethods<Node> {
|
||||
fn add_child(+node: Node, +child: Node) {
|
||||
fn add_child(node: Node, child: Node) {
|
||||
tree::add_child(&self, node, child)
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ pub struct Engine<C:Compositor Send Copy> {
|
|||
content_task: ContentTask
|
||||
}
|
||||
|
||||
pub fn Engine<C:Compositor Send Copy>(+compositor: C,
|
||||
+resource_task: ResourceTask,
|
||||
+image_cache_task: ImageCacheTask) -> Engine<C> {
|
||||
pub fn Engine<C:Compositor Send Copy>(compositor: C,
|
||||
resource_task: ResourceTask,
|
||||
image_cache_task: ImageCacheTask) -> Engine<C> {
|
||||
let render_task = RenderTask(compositor);
|
||||
let layout_task = LayoutTask(render_task, image_cache_task);
|
||||
let content_task = ContentTask(layout_task, compositor, resource_task, image_cache_task);
|
||||
|
@ -48,7 +48,7 @@ impl<C: Compositor Copy Send> Engine<C> {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_request(+request: Msg) -> bool {
|
||||
fn handle_request(request: Msg) -> bool {
|
||||
match request {
|
||||
LoadURLMsg(url) => {
|
||||
// TODO: change copy to move once we have match move
|
||||
|
|
|
@ -6,8 +6,8 @@ The interface used to by the renderer to aquire draw targets for
|
|||
each rendered frame and submit them to be drawn to the display
|
||||
*/
|
||||
trait Compositor {
|
||||
fn begin_drawing(+next_dt: pipes::Chan<DrawTarget>);
|
||||
fn draw(+next_dt: pipes::Chan<DrawTarget>, +draw_me: DrawTarget);
|
||||
fn begin_drawing(next_dt: pipes::Chan<DrawTarget>);
|
||||
fn draw(next_dt: pipes::Chan<DrawTarget>, +draw_me: DrawTarget);
|
||||
fn add_event_listener(listener: comm::Chan<Event>);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ pub fn SolidColor(bounds: Rect<au>, r: u8, g: u8, b: u8) -> DisplayItem {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn Text(bounds: Rect<au>, +run: ~TextRun, offset: uint, length: uint) -> DisplayItem {
|
||||
pub fn Text(bounds: Rect<au>, run: ~TextRun, offset: uint, length: uint) -> DisplayItem {
|
||||
DisplayItem {
|
||||
draw: |self, ctx| draw_Text(self, ctx),
|
||||
bounds: bounds,
|
||||
|
@ -66,7 +66,7 @@ pub fn Text(bounds: Rect<au>, +run: ~TextRun, offset: uint, length: uint) -> Dis
|
|||
}
|
||||
|
||||
// ARC should be cloned into ImageData, but Images are not sendable
|
||||
pub fn Image(bounds: Rect<au>, +image: ARC<~image::base::Image>) -> DisplayItem {
|
||||
pub fn Image(bounds: Rect<au>, image: ARC<~image::base::Image>) -> DisplayItem {
|
||||
DisplayItem {
|
||||
draw: |self, ctx| draw_Image(self, ctx),
|
||||
bounds: bounds,
|
||||
|
|
|
@ -15,7 +15,7 @@ impl au : Num {
|
|||
|
||||
pure fn to_int() -> int { *self as int }
|
||||
|
||||
static pure fn from_int(+n: int) -> au {
|
||||
static pure fn from_int(n: int) -> au {
|
||||
au((n & (i32::max_value as int)) as i32)
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ impl au : cmp::Eq {
|
|||
pub pure fn min(x: au, y: au) -> au { if x < y { x } else { y } }
|
||||
pub pure fn max(x: au, y: au) -> au { if x > y { x } else { y } }
|
||||
|
||||
pub fn box<A:Copy Num>(+x: A, +y: A, +w: A, +h: A) -> Rect<A> {
|
||||
pub fn box<A:Copy Num>(x: A, y: A, w: A, h: A) -> Rect<A> {
|
||||
Rect(Point2D(x, y), Size2D(w, h))
|
||||
}
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@ pub enum Msg {
|
|||
}
|
||||
|
||||
impl Chan<Msg> : Compositor {
|
||||
fn begin_drawing(+next_dt: pipes::Chan<DrawTarget>) {
|
||||
fn begin_drawing(next_dt: pipes::Chan<DrawTarget>) {
|
||||
self.send(BeginDrawing(next_dt))
|
||||
}
|
||||
fn draw(+next_dt: pipes::Chan<DrawTarget>, +draw_me: DrawTarget) {
|
||||
fn draw(next_dt: pipes::Chan<DrawTarget>, draw_me: DrawTarget) {
|
||||
self.send(Draw(next_dt, draw_me))
|
||||
}
|
||||
fn add_event_listener(_listener: Chan<Event>) {
|
||||
|
@ -69,8 +69,8 @@ pub fn PngCompositor(output: Chan<~[u8]>) -> PngCompositor {
|
|||
}
|
||||
}
|
||||
|
||||
fn do_draw(+sender: pipes::Chan<DrawTarget>,
|
||||
+dt: DrawTarget,
|
||||
fn do_draw(sender: pipes::Chan<DrawTarget>,
|
||||
dt: DrawTarget,
|
||||
output: Chan<~[u8]>,
|
||||
cairo_surface: &ImageSurface) {
|
||||
let buffer = BytesWriter();
|
||||
|
|
|
@ -41,7 +41,7 @@ struct RenderContext {
|
|||
|
||||
pub type RenderTask = comm::Chan<Msg>;
|
||||
|
||||
pub fn RenderTask<C: Compositor Send>(+compositor: C) -> RenderTask {
|
||||
pub fn RenderTask<C: Compositor Send>(compositor: C) -> RenderTask {
|
||||
do task::spawn_listener |po: comm::Port<Msg>| {
|
||||
let (draw_target_ch, draw_target_po) = pipes::stream();
|
||||
let mut draw_target_ch = draw_target_ch;
|
||||
|
@ -120,7 +120,7 @@ pub fn draw_solid_color(ctx: &RenderContext, bounds: &Rect<au>, r: u8, g: u8, b:
|
|||
ctx.canvas.fill_rect(&bounds.to_azure_rect(), &ColorPattern(color));
|
||||
}
|
||||
|
||||
pub fn draw_image(ctx: &RenderContext, bounds: Rect<au>, +image: ARC<~Image>) {
|
||||
pub fn draw_image(ctx: &RenderContext, bounds: Rect<au>, image: ARC<~Image>) {
|
||||
let image = std::arc::get(&image);
|
||||
let size = Size2D(image.width as i32, image.height as i32);
|
||||
let stride = image.width * 4;
|
||||
|
|
|
@ -166,7 +166,7 @@ fn build_element_kind(tag: &str) -> ~ElementKind {
|
|||
}
|
||||
|
||||
pub fn parse_html(scope: NodeScope,
|
||||
+url: Url,
|
||||
url: Url,
|
||||
resource_task: ResourceTask,
|
||||
image_cache_task: ImageCacheTask) -> HtmlParserResult unsafe {
|
||||
// Spawn a CSS parser to receive links to CSS style sheets.
|
||||
|
|
|
@ -100,7 +100,7 @@ impl InputState : InputStateUtil {
|
|||
self.lookahead = Some(CoeChar(ch));
|
||||
}
|
||||
|
||||
fn parse_err(+err: ~str) -> ! {
|
||||
fn parse_err(err: ~str) -> ! {
|
||||
fail err
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ impl InputState : InputStateUtil {
|
|||
return str::from_bytes(result);
|
||||
}
|
||||
|
||||
fn expect_ident(+expected: ~str) {
|
||||
fn expect_ident(expected: ~str) {
|
||||
let actual = self.parse_ident();
|
||||
if expected != actual {
|
||||
self.parse_err(#fmt("expected '%s' but found '%s'", expected, actual));
|
||||
|
|
|
@ -11,7 +11,7 @@ use stb_image = stb_image::image;
|
|||
|
||||
pub type Image = stb_image::Image;
|
||||
|
||||
pub fn Image(width: uint, height: uint, depth: uint, +data: ~[u8]) -> Image {
|
||||
pub fn Image(width: uint, height: uint, depth: uint, data: ~[u8]) -> Image {
|
||||
stb_image::new_image(width, height, depth, data)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ pub struct ImageHolder {
|
|||
|
||||
}
|
||||
|
||||
fn ImageHolder(+url : Url, image_cache_task: ImageCacheTask, +cb: fn~()) -> ImageHolder {
|
||||
fn ImageHolder(url : Url, image_cache_task: ImageCacheTask, cb: fn~()) -> ImageHolder {
|
||||
debug!("ImageHolder() %?", url.to_str());
|
||||
let holder = ImageHolder {
|
||||
url : Some(copy url),
|
||||
|
|
|
@ -270,7 +270,7 @@ impl FlowContext : FlowContextMethods {
|
|||
}
|
||||
|
||||
// Actual methods that do not require much flow-specific logic
|
||||
pure fn foldl_boxes_for_node<B: Copy>(node: Node, +seed: B, blk: pure fn&(+a: B,@RenderBox) -> B) -> B {
|
||||
pure fn foldl_boxes_for_node<B: Copy>(node: Node, seed: B, blk: pure fn&(a: B,@RenderBox) -> B) -> B {
|
||||
match self {
|
||||
RootFlow(*) => match self.root().box {
|
||||
Some(box) if box.d().node == node => { blk(seed, box) },
|
||||
|
|
|
@ -55,7 +55,7 @@ fn OSMain() -> OSMain {
|
|||
}
|
||||
}
|
||||
|
||||
fn mainloop(+mode: Mode, po: comm::Port<Msg>) {
|
||||
fn mainloop(mode: Mode, po: comm::Port<Msg>) {
|
||||
let key_handlers: @DVec<pipes::Chan<()>> = @DVec();
|
||||
let event_listeners: @DVec<comm::Chan<Event>> = @DVec();
|
||||
|
||||
|
@ -166,10 +166,10 @@ Implementation to allow the osmain channel to be used as a graphics
|
|||
compositor for the renderer
|
||||
*/
|
||||
impl OSMain : Compositor {
|
||||
fn begin_drawing(+next_dt: pipes::Chan<DrawTarget>) {
|
||||
fn begin_drawing(next_dt: pipes::Chan<DrawTarget>) {
|
||||
self.send(BeginDrawing(next_dt))
|
||||
}
|
||||
fn draw(+next_dt: pipes::Chan<DrawTarget>, +draw_me: DrawTarget) {
|
||||
fn draw(next_dt: pipes::Chan<DrawTarget>, draw_me: DrawTarget) {
|
||||
self.send(Draw(next_dt, draw_me))
|
||||
}
|
||||
fn add_event_listener(listener: comm::Chan<Event>) {
|
||||
|
@ -182,7 +182,7 @@ struct SurfaceSet {
|
|||
mut back: Surface,
|
||||
}
|
||||
|
||||
fn lend_surface(surfaces: &SurfaceSet, +receiver: pipes::Chan<DrawTarget>) {
|
||||
fn lend_surface(surfaces: &SurfaceSet, receiver: pipes::Chan<DrawTarget>) {
|
||||
// We are in a position to lend out the surface?
|
||||
assert surfaces.front.have;
|
||||
// Ok then take it
|
||||
|
@ -197,7 +197,7 @@ fn lend_surface(surfaces: &SurfaceSet, +receiver: pipes::Chan<DrawTarget>) {
|
|||
assert surfaces.front.have;
|
||||
}
|
||||
|
||||
fn return_surface(surfaces: &SurfaceSet, +draw_target: DrawTarget) {
|
||||
fn return_surface(surfaces: &SurfaceSet, draw_target: DrawTarget) {
|
||||
#debug("osmain: returning surface %?", draw_target);
|
||||
// We have room for a return
|
||||
assert surfaces.front.have;
|
||||
|
@ -227,7 +227,7 @@ fn Surface() -> Surface {
|
|||
}
|
||||
|
||||
/// A function for spawning into the platform's main thread
|
||||
fn on_osmain<T: Send>(+f: fn~(+po: comm::Port<T>)) -> comm::Chan<T> {
|
||||
fn on_osmain<T: Send>(f: fn~(po: comm::Port<T>)) -> comm::Chan<T> {
|
||||
task::task().sched_mode(task::PlatformThread).spawn_listener(f)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use io::{file_reader, ReaderUtil};
|
|||
|
||||
const READ_SIZE: uint = 1024;
|
||||
|
||||
pub fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
pub fn factory(url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
assert url.scheme == ~"file";
|
||||
|
||||
do spawn {
|
||||
|
|
|
@ -6,7 +6,7 @@ use resource_task::{ProgressMsg, Payload, Done};
|
|||
use std::net::url::Url;
|
||||
use http_client::{uv_http_request};
|
||||
|
||||
pub fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
pub fn factory(url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
assert url.scheme == ~"http";
|
||||
|
||||
do spawn {
|
||||
|
|
|
@ -80,7 +80,7 @@ pub fn ImageCacheTask(resource_task: ResourceTask) -> ImageCacheTask {
|
|||
ImageCacheTask_(resource_task, default_decoder_factory)
|
||||
}
|
||||
|
||||
pub fn ImageCacheTask_(resource_task: ResourceTask, +decoder_factory: DecoderFactory) -> ImageCacheTask {
|
||||
pub fn ImageCacheTask_(resource_task: ResourceTask, decoder_factory: DecoderFactory) -> ImageCacheTask {
|
||||
// FIXME: Doing some dancing to avoid copying decoder_factory, our test
|
||||
// version of which contains an uncopyable type which rust will currently
|
||||
// copy unsoundly
|
||||
|
@ -200,18 +200,18 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
priv fn get_state(+url: Url) -> ImageState {
|
||||
priv fn get_state(url: Url) -> ImageState {
|
||||
match self.state_map.find(url) {
|
||||
Some(state) => state,
|
||||
None => Init
|
||||
}
|
||||
}
|
||||
|
||||
priv fn set_state(+url: Url, state: ImageState) {
|
||||
priv fn set_state(url: Url, state: ImageState) {
|
||||
self.state_map.insert(url, state);
|
||||
}
|
||||
|
||||
priv fn prefetch(+url: Url) {
|
||||
priv fn prefetch(url: Url) {
|
||||
match self.get_state(copy url) {
|
||||
Init => {
|
||||
let to_cache = self.from_client.chan();
|
||||
|
@ -246,7 +246,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
priv fn store_prefetched_image_data(+url: Url, data: &Result<Cell<~[u8]>, ()>) {
|
||||
priv fn store_prefetched_image_data(url: Url, data: &Result<Cell<~[u8]>, ()>) {
|
||||
match self.get_state(copy url) {
|
||||
Prefetching(next_step) => {
|
||||
match *data {
|
||||
|
@ -275,7 +275,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
priv fn decode(+url: Url) {
|
||||
priv fn decode(url: Url) {
|
||||
|
||||
match self.get_state(copy url) {
|
||||
Init => fail ~"decoding image before prefetch",
|
||||
|
@ -321,7 +321,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
priv fn store_image(+url: Url, image: &Option<ARC<~Image>>) {
|
||||
priv fn store_image(url: Url, image: &Option<ARC<~Image>>) {
|
||||
|
||||
match self.get_state(copy url) {
|
||||
Decoding => {
|
||||
|
@ -348,7 +348,7 @@ impl ImageCache {
|
|||
|
||||
}
|
||||
|
||||
priv fn purge_waiters(+url: Url, f: fn() -> ImageResponseMsg) {
|
||||
priv fn purge_waiters(url: Url, f: fn() -> ImageResponseMsg) {
|
||||
match self.wait_map.find(copy url) {
|
||||
Some(@waiters) => {
|
||||
for waiters.each |response| {
|
||||
|
@ -361,7 +361,7 @@ impl ImageCache {
|
|||
}
|
||||
|
||||
|
||||
priv fn get_image(+url: Url, response: Chan<ImageResponseMsg>) {
|
||||
priv fn get_image(url: Url, response: Chan<ImageResponseMsg>) {
|
||||
|
||||
match self.get_state(copy url) {
|
||||
Init => fail ~"request for image before prefetch",
|
||||
|
@ -387,7 +387,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
priv fn wait_for_image(+url: Url, response: Chan<ImageResponseMsg>) {
|
||||
priv fn wait_for_image(url: Url, response: Chan<ImageResponseMsg>) {
|
||||
|
||||
match self.get_state(copy url) {
|
||||
Init => fail ~"request for image before prefetch",
|
||||
|
@ -435,7 +435,7 @@ impl ImageCacheTask: ImageCacheTaskClient {
|
|||
|
||||
}
|
||||
|
||||
fn load_image_data(+url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
|
||||
fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
|
||||
let response_port = Port();
|
||||
resource_task.send(resource_task::Load(url, response_port.chan()));
|
||||
|
||||
|
@ -461,7 +461,7 @@ fn default_decoder_factory() -> ~fn(&[u8]) -> Option<Image> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn mock_resource_task(+on_load: ~fn(resource: Chan<resource_task::ProgressMsg>)) -> ResourceTask {
|
||||
fn mock_resource_task(on_load: ~fn(resource: Chan<resource_task::ProgressMsg>)) -> ResourceTask {
|
||||
do spawn_listener |from_client, move on_load| {
|
||||
|
||||
// infer me
|
||||
|
|
|
@ -47,7 +47,7 @@ Creates a task to load a specific resource
|
|||
The ResourceManager delegates loading to a different type of loader task for
|
||||
each URL scheme
|
||||
*/
|
||||
type LoaderTaskFactory = fn~(+url: Url, Chan<ProgressMsg>);
|
||||
type LoaderTaskFactory = fn~(url: Url, Chan<ProgressMsg>);
|
||||
|
||||
/// Create a ResourceTask with the default loaders
|
||||
fn ResourceTask() -> ResourceTask {
|
||||
|
@ -58,7 +58,7 @@ fn ResourceTask() -> ResourceTask {
|
|||
create_resource_task_with_loaders(loaders)
|
||||
}
|
||||
|
||||
fn create_resource_task_with_loaders(+loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceTask {
|
||||
fn create_resource_task_with_loaders(loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceTask {
|
||||
do spawn_listener |from_client| {
|
||||
// TODO: change copy to move once we can move into closures
|
||||
ResourceManager(from_client, copy loaders).start()
|
||||
|
@ -73,7 +73,7 @@ pub struct ResourceManager {
|
|||
|
||||
|
||||
pub fn ResourceManager(from_client: Port<ControlMsg>,
|
||||
+loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceManager {
|
||||
loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceManager {
|
||||
ResourceManager {
|
||||
from_client : from_client,
|
||||
loaders : loaders,
|
||||
|
@ -95,7 +95,7 @@ impl ResourceManager {
|
|||
}
|
||||
}
|
||||
|
||||
fn load(+url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
fn load(url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
|
||||
match self.get_loader_factory(&url) {
|
||||
Some(loader_factory) => {
|
||||
|
@ -143,7 +143,7 @@ fn test_bad_scheme() {
|
|||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn should_delegate_to_scheme_loader() {
|
||||
let payload = ~[1, 2, 3];
|
||||
let loader_factory = fn~(+_url: Url, progress_chan: Chan<ProgressMsg>, copy payload) {
|
||||
let loader_factory = fn~(_url: Url, progress_chan: Chan<ProgressMsg>, copy payload) {
|
||||
progress_chan.send(Payload(copy payload));
|
||||
progress_chan.send(Done(Ok(())));
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#[license = "MPL"];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
#[legacy_modes];
|
||||
//#[legacy_modes];
|
||||
|
||||
extern mod std;
|
||||
extern mod azure;
|
||||
|
|
|
@ -66,7 +66,7 @@ fn run_pipeline_screen(urls: &[~str]) {
|
|||
osmain.send(osmain::Exit);
|
||||
}
|
||||
|
||||
fn run_pipeline_png(+url: ~str, outfile: &str) {
|
||||
fn run_pipeline_png(url: ~str, outfile: &str) {
|
||||
// Use a PNG encoder as the graphics compositor
|
||||
use gfx::png_compositor;
|
||||
use png_compositor::PngCompositor;
|
||||
|
|
|
@ -70,7 +70,7 @@ pub impl Font : FontMethods {
|
|||
|
||||
// TODO: font should compute its own metrics using native_font.
|
||||
// TODO: who should own fontbuf?
|
||||
fn Font(lib: @FontCache, fontbuf: @~[u8], +native_font: NativeFont, +metrics: FontMetrics) -> Font {
|
||||
fn Font(lib: @FontCache, fontbuf: @~[u8], native_font: NativeFont, metrics: FontMetrics) -> Font {
|
||||
Font {
|
||||
lib: lib,
|
||||
fontbuf : fontbuf,
|
||||
|
|
|
@ -126,7 +126,7 @@ impl TextRun {
|
|||
}
|
||||
}
|
||||
|
||||
fn TextRun(font: &Font, +text: ~str) -> TextRun {
|
||||
fn TextRun(font: &Font, text: ~str) -> TextRun {
|
||||
let glyph_store = GlyphStore(text.len());
|
||||
let run = TextRun {
|
||||
text: text,
|
||||
|
@ -160,7 +160,7 @@ fn test_calc_min_break_width() {
|
|||
#[test]
|
||||
#[ignore]
|
||||
fn test_iter_indivisible_pieces() {
|
||||
fn test_pieces(+text: ~str, +res: ~[~str]) {
|
||||
fn test_pieces(text: ~str, res: ~[~str]) {
|
||||
let flib = FontCache();
|
||||
let font = flib.get_test_font();
|
||||
let run = TextRun(font, copy text);
|
||||
|
|
|
@ -41,7 +41,7 @@ pub fn empty<T>() -> Tree<T> {
|
|||
mut next_sibling: None}
|
||||
}
|
||||
|
||||
pub fn add_child<T:Copy,O:WriteMethods<T>>(ops: &O, +parent: T, +child: T) {
|
||||
pub fn add_child<T:Copy,O:WriteMethods<T>>(ops: &O, parent: T, child: T) {
|
||||
|
||||
ops.with_tree_fields(&child, |child_tf| {
|
||||
match child_tf.parent {
|
||||
|
|
|
@ -15,7 +15,7 @@ Create a URL object from a string. Does various helpful browsery things like
|
|||
|
||||
*/
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn make_url(+str_url: ~str, +current_url: Option<Url>) -> Url {
|
||||
fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
||||
let mut schm = url::get_scheme(str_url);
|
||||
let str_url = if result::is_err(&schm) {
|
||||
if current_url.is_none() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue