Skip to content
This repository
Browse code

Fixed the changing alt syntax and cleaned up some compiler warnings

  • Loading branch information...
commit 0b796c410cf5d0924b652186d5b17e8b3ad285a8 1 parent f290f18
mmeyerho mmeyerho authored

Showing 40 changed files with 482 additions and 485 deletions. Show diff stats Hide diff stats

  1. +1 1  src/rust-glut
  2. +1 1  src/rust-http-client
  3. +1 1  src/rust-layers
  4. +18 20 src/servo/content.rs
  5. +3 3 src/servo/dom/base.rs
  6. +7 7 src/servo/dom/bindings/node.rs
  7. +2 2 src/servo/dom/bindings/utils.rs
  8. +6 6 src/servo/dom/rcu.rs
  9. +4 2 src/servo/engine.rs
  10. +3 3 src/servo/gfx/pngsink.rs
  11. +11 19 src/servo/gfx/renderer.rs
  12. +1 1  src/servo/gfx/surface.rs
  13. +4 4 src/servo/layout/base.rs
  14. +23 27 src/servo/layout/box_builder.rs
  15. +19 11 src/servo/layout/display_list_builder.rs
  16. +25 27 src/servo/layout/layout_task.rs
  17. +6 6 src/servo/layout/style/apply.rs
  18. +47 52 src/servo/layout/style/matching.rs
  19. +8 8 src/servo/layout/style/style.rs
  20. +3 3 src/servo/layout/text.rs
  21. +1 1  src/servo/layout/traverse.rs
  22. +5 5 src/servo/opts.rs
  23. +47 46 src/servo/parser/css_builder.rs
  24. +30 30 src/servo/parser/css_lexer.rs
  25. +54 49 src/servo/parser/html_builder.rs
  26. +17 16 src/servo/parser/html_lexer.rs
  27. +12 11 src/servo/parser/lexer_util.rs
  28. +28 28 src/servo/parser/parser_util.rs
  29. +5 11 src/servo/platform/osmain.rs
  30. +3 3 src/servo/resource/file_loader.rs
  31. +8 5 src/servo/resource/http_loader.rs
  32. +13 10 src/servo/resource/resource_task.rs
  33. +1 1  src/servo/servo.rc
  34. +10 11 src/servo/servo.rs
  35. +2 2 src/servo/text/font.rs
  36. +1 1  src/servo/text/native_font/ft_native_font.rs
  37. +7 7 src/servo/text/shaper.rs
  38. +36 36 src/servo/util/color.rs
  39. +6 6 src/servo/util/tree.rs
  40. +3 2 src/servo/util/url.rs
2  src/rust-glut
... ... @@ -1 +1 @@
1   -Subproject commit 6a72d19ff22e0d0539b8bf6cb22ac3378625cca8
  1 +Subproject commit 377d4a6eecef416c9fc082914c265c2ece765909
2  src/rust-http-client
... ... @@ -1 +1 @@
1   -Subproject commit 1159f92f8a66a4f9aaa9c8c91c437dc36221dfcc
  1 +Subproject commit b63c020bacba761619d7da85cf112c4fae75b6d5
2  src/rust-layers
... ... @@ -1 +1 @@
1   -Subproject commit a3ddb0bc112e12ec1438679378e9e0a67b86373f
  1 +Subproject commit f071d5e2772973580df979a643deaf9745f5a7f7
38 src/servo/content.rs
@@ -9,6 +9,7 @@ export PingMsg, PongMsg;
9 9 export create_content;
10 10 export Document;
11 11
  12 +import arc::{arc, clone};
12 13 import comm::{port, chan, listen, select2};
13 14 import task::{spawn, spawn_listener};
14 15 import io::{read_whole_file, println};
@@ -55,7 +56,7 @@ enum PingMsg {
55 56 }
56 57
57 58 #[doc="Sends a ping to layout and waits for the response."]
58   -#[warn(no_non_implicitly_copyable_typarams)]
  59 +#[allow(non_implicitly_copyable_typarams)]
59 60 fn join_layout(scope: NodeScope, layout: Layout) {
60 61
61 62 if scope.is_reader_forked() {
@@ -69,11 +70,11 @@ fn join_layout(scope: NodeScope, layout: Layout) {
69 70
70 71 class Document {
71 72 let root: Node;
72   - let css_rules: Stylesheet;
  73 + let css_rules: arc<Stylesheet>;
73 74
74   - new(root: Node, +css_rules: Stylesheet) {
  75 + new(root: Node, -css_rules: Stylesheet) {
75 76 self.root = root;
76   - self.css_rules = css_rules;
  77 + self.css_rules = arc(css_rules);
77 78 }
78 79 }
79 80
@@ -114,24 +115,21 @@ class Content<S:Sink send copy> {
114 115
115 116 fn handle_msg(msg: either<ControlMsg,Event>) -> bool {
116 117 alt msg {
117   - left(control_msg) {
118   - return self.handle_control_msg(control_msg);
119   - }
120   - right(event) {
121   - return self.handle_event(event);
122   - }
  118 + left(control_msg) => self.handle_control_msg(control_msg),
  119 + right(event) => self.handle_event(event)
123 120 }
124 121 }
125 122
126 123 fn handle_control_msg(control_msg: ControlMsg) -> bool {
127 124 alt control_msg {
128   - ParseMsg(url) {
  125 + ParseMsg(url) => {
129 126 #debug["content: Received url `%s` to parse", url_to_str(url)];
130 127
131 128 // Note: we can parse the next document in parallel
132 129 // with any previous documents.
133 130 let stream = spawn_html_lexer_task(copy url, self.resource_task);
134   - let (root, style_port, js_port) = build_dom(self.scope, stream, url, self.resource_task);
  131 + let (root, style_port, js_port) = build_dom(self.scope, stream, url,
  132 + self.resource_task);
135 133 let css_rules = style_port.recv();
136 134 let js_scripts = js_port.recv();
137 135
@@ -160,14 +158,14 @@ class Content<S:Sink send copy> {
160 158 return true;
161 159 }
162 160
163   - ExecuteMsg(url) {
  161 + ExecuteMsg(url) => {
164 162 #debug["content: Received url `%s` to execute", url_to_str(url)];
165 163
166 164 alt read_whole_file(url.path) {
167   - err(msg) {
  165 + err(msg) => {
168 166 println(#fmt["Error opening %s: %s", url_to_str(url), msg]);
169 167 }
170   - ok(bytes) {
  168 + ok(bytes) => {
171 169 let cx = self.jsrt.cx();
172 170 cx.set_default_options_and_version();
173 171 cx.set_logging_error_reporter();
@@ -180,7 +178,7 @@ class Content<S:Sink send copy> {
180 178 return true;
181 179 }
182 180
183   - ExitMsg {
  181 + ExitMsg => {
184 182 self.layout.send(layout_task::ExitMsg);
185 183 return false;
186 184 }
@@ -196,7 +194,7 @@ class Content<S:Sink send copy> {
196 194
197 195 // Send new document and relevant styles to layout
198 196 // FIXME: Put CSS rules in an arc or something.
199   - self.layout.send(BuildMsg(document.root, document.css_rules));
  197 + self.layout.send(BuildMsg(document.root, clone(&document.css_rules)));
200 198
201 199 // Indicate that reader was forked so any further
202 200 // changes will be isolated.
@@ -205,13 +203,13 @@ class Content<S:Sink send copy> {
205 203
206 204 fn handle_event(event: Event) -> bool {
207 205 alt event {
208   - ResizeEvent(new_width, new_height) {
  206 + ResizeEvent(new_width, new_height) => {
209 207 #debug("content got resize event: %d, %d", new_width, new_height);
210 208 alt copy self.document {
211   - none {
  209 + none => {
212 210 // Nothing to do.
213 211 }
214   - some(document) {
  212 + some(document) => {
215 213 self.relayout(*document);
216 214 }
217 215 }
6 src/servo/dom/base.rs
@@ -90,14 +90,14 @@ trait node_scope {
90 90 fn new_node(-k: NodeKind) -> Node;
91 91 }
92 92
93   -#[warn(no_non_implicitly_copyable_typarams)]
  93 +#[allow(non_implicitly_copyable_typarams)]
94 94 impl NodeScope of node_scope for NodeScope {
95 95 fn new_node(-k: NodeKind) -> Node {
96 96 self.handle(NodeData({tree: tree::empty(), kind: ~k}))
97 97 }
98 98 }
99 99
100   -#[warn(no_non_implicitly_copyable_typarams)]
  100 +#[allow(non_implicitly_copyable_typarams)]
101 101 impl TreeReadMethods of tree::ReadMethods<Node> for NodeScope {
102 102 fn each_child(node: Node, f: fn(Node) -> bool) {
103 103 tree::each_child(self, node, f)
@@ -112,7 +112,7 @@ impl TreeReadMethods of tree::ReadMethods<Node> for NodeScope {
112 112 }
113 113 }
114 114
115   -#[warn(no_non_implicitly_copyable_typarams)]
  115 +#[allow(non_implicitly_copyable_typarams)]
116 116 impl TreeWriteMethods of tree::WriteMethods<Node> for NodeScope {
117 117 fn add_child(node: Node, child: Node) {
118 118 tree::add_child(self, node, child)
14 src/servo/dom/bindings/node.rs
@@ -94,11 +94,11 @@ extern fn getFirstChild(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut js
94 94 unsafe {
95 95 (*unwrap(obj)).payload.read(|nd| {
96 96 alt nd.tree.first_child {
97   - some(n) {
  97 + some(n) => {
98 98 let obj = create(cx, n).ptr;
99 99 *rval = RUST_OBJECT_TO_JSVAL(obj);
100 100 }
101   - none {
  101 + none => {
102 102 *rval = JSVAL_NULL;
103 103 }
104 104 }
@@ -111,11 +111,11 @@ extern fn getNextSibling(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut j
111 111 unsafe {
112 112 (*unwrap(obj)).payload.read(|nd| {
113 113 alt nd.tree.next_sibling {
114   - some(n) {
  114 + some(n) => {
115 115 let obj = create(cx, n).ptr;
116 116 *rval = RUST_OBJECT_TO_JSVAL(obj);
117 117 }
118   - none {
  118 + none => {
119 119 *rval = JSVAL_NULL;
120 120 }
121 121 }
@@ -128,11 +128,11 @@ extern fn getTagName(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval
128 128 unsafe {
129 129 (*unwrap(obj)).payload.read(|nd| {
130 130 alt nd.kind {
131   - ~Element(ed) {
132   - let s = str(ed.tag_name);
  131 + ~Element(ed) => {
  132 + let s = str(copy ed.tag_name);
133 133 *rval = domstring_to_jsval(cx, s);
134 134 }
135   - _ {
  135 + _ => {
136 136 //XXXjdm should probably read the spec to figure out what to do here
137 137 *rval = JSVAL_NULL;
138 138 }
4 src/servo/dom/bindings/utils.rs
@@ -55,10 +55,10 @@ fn jsval_to_str(cx: *JSContext, v: jsval) -> result<~str, ()> {
55 55
56 56 unsafe fn domstring_to_jsval(cx: *JSContext, str: DOMString) -> jsval {
57 57 alt str {
58   - null_string {
  58 + null_string => {
59 59 JSVAL_NULL
60 60 }
61   - str(s) {
  61 + str(s) => {
62 62 str::as_buf(s, |buf, len| {
63 63 let cbuf = unsafe::reinterpret_cast(buf);
64 64 RUST_STRING_TO_JSVAL(JS_NewStringCopyN(cx, cbuf, len as libc::size_t))
12 src/servo/dom/rcu.rs
@@ -210,7 +210,7 @@ impl WriterMethods<T:copy send,A> for Scope<T,A> {
210 210 f(*h.write_ptr())
211 211 }
212 212
213   - #[warn(no_non_implicitly_copyable_typarams)]
  213 + #[allow(non_implicitly_copyable_typarams)]
214 214 fn handle(v: T) -> Handle<T,A> unsafe {
215 215 let d: *HandleData<T,A> =
216 216 unsafe::reinterpret_cast(
@@ -226,7 +226,7 @@ impl WriterMethods<T:copy send,A> for Scope<T,A> {
226 226 }
227 227
228 228 #[cfg(test)]
229   -#[warn(no_non_implicitly_copyable_typarams)]
  229 +#[allow(non_implicitly_copyable_typarams)]
230 230 mod test {
231 231
232 232 type animal = {name: ~str, species: species};
@@ -250,15 +250,15 @@ mod test {
250 250
251 251 fn mutate(a: animal) {
252 252 alt a.species {
253   - chicken(c) { c.eggs_per_day += 1u; }
254   - bull(c) { c.horns += 1u; }
  253 + chicken(c) => c.eggs_per_day += 1u,
  254 + bull(c) => c.horns += 1u
255 255 }
256 256 }
257 257
258 258 fn read_characteristic(a: animal) -> uint {
259 259 alt a.species {
260   - chicken(c) { c.eggs_per_day }
261   - bull(c) { c.horns }
  260 + chicken(c) => c.eggs_per_day,
  261 + bull(c) => c.horns
262 262 }
263 263 }
264 264
6 src/servo/engine.rs
@@ -42,7 +42,9 @@ class Engine<S:Sink send copy> {
42 42
43 43 fn handle_request(request: Msg) -> bool {
44 44 alt request {
45   - LoadURLMsg(url) {
  45 + LoadURLMsg(url) => {
  46 + // TODO: change copy to move once we have alt move
  47 + let url = copy url;
46 48 if url.path.ends_with(".js") {
47 49 self.content.send(ExecuteMsg(url))
48 50 } else {
@@ -51,7 +53,7 @@ class Engine<S:Sink send copy> {
51 53 return true;
52 54 }
53 55
54   - ExitMsg(sender) {
  56 + ExitMsg(sender) => {
55 57 self.content.send(content::ExitMsg);
56 58 self.layout.send(layout_task::ExitMsg);
57 59
6 src/servo/gfx/pngsink.rs
@@ -59,15 +59,15 @@ fn PngSink(output: chan<~[u8]>) -> PngSink {
59 59
60 60 loop {
61 61 alt po.recv() {
62   - BeginDrawing(sender) {
  62 + BeginDrawing(sender) => {
63 63 #debug("pngsink: begin_drawing");
64 64 sender.send(draw_target);
65 65 }
66   - Draw(sender, dt) {
  66 + Draw(sender, dt) => {
67 67 #debug("pngsink: draw");
68 68 do_draw(sender, dt, output, cairo_surf);
69 69 }
70   - Exit { break }
  70 + Exit => { break }
71 71 }
72 72 }
73 73
30 src/servo/gfx/renderer.rs
@@ -47,7 +47,7 @@ fn Renderer<S: Sink send copy>(sink: S) -> comm::chan<Msg> {
47 47
48 48 loop {
49 49 alt po.recv() {
50   - RenderMsg(display_list) {
  50 + RenderMsg(display_list) => {
51 51 #debug("renderer: got render request");
52 52 let draw_target = draw_target_po.recv();
53 53 let (ch, po) = pipes::stream();
@@ -64,7 +64,7 @@ fn Renderer<S: Sink send copy>(sink: S) -> comm::chan<Msg> {
64 64 sink.draw(draw_target_ch, draw_target);
65 65 }
66 66 }
67   - ExitMsg(response_ch) {
  67 + ExitMsg(response_ch) => {
68 68 response_ch.send(());
69 69 break;
70 70 }
@@ -88,18 +88,10 @@ fn draw_display_list(draw_target: AzDrawTargetRef, display_list: dl::display_lis
88 88 #debug["drawing %?", item];
89 89
90 90 alt item.item_type {
91   - dl::display_item_solid_color(r, g, b) {
92   - draw_solid_color(draw_target, item, r, g, b);
93   - }
94   - dl::display_item_image(image) {
95   - draw_image(draw_target, item, *image);
96   - }
97   - dl::display_item_text(text_run) {
98   - draw_text(draw_target, item, text_run);
99   - }
100   - dl::padding(*) {
101   - fail ~"should never see padding";
102   - }
  91 + dl::display_item_solid_color(r, g, b) => draw_solid_color(draw_target, item, r, g, b),
  92 + dl::display_item_image(image) => draw_image(draw_target, item, *image),
  93 + dl::display_item_text(text_run) => draw_text(draw_target, item, text_run),
  94 + dl::padding(*) => fail ~"should never see padding"
103 95 }
104 96 }
105 97 }
@@ -141,11 +133,11 @@ fn draw_image(draw_target: AzDrawTargetRef, item: dl::display_item, image: arc<~
141 133 let color = i % 4;
142 134 let pixel = i / 4;
143 135 alt color {
144   - 0 { image.data[pixel * 3 + 2] }
145   - 1 { image.data[pixel * 3 + 1] }
146   - 2 { image.data[pixel * 3 + 0] }
147   - 3 { 0xffu8 }
148   - _ { fail }
  136 + 0 => image.data[pixel * 3 + 2],
  137 + 1 => image.data[pixel * 3 + 1],
  138 + 2 => image.data[pixel * 3 + 0],
  139 + 3 => 0xffu8,
  140 + _ => fail
149 141 }
150 142 };
151 143
2  src/servo/gfx/surface.rs
@@ -15,7 +15,7 @@ type image_surface = {
15 15 impl format for format {
16 16 fn bpp() -> uint {
17 17 alt self {
18   - fo_rgba_8888 { 32u }
  18 + fo_rgba_8888 => 32u
19 19 }
20 20 }
21 21 }
8 src/servo/layout/base.rs
@@ -180,10 +180,10 @@ impl layout_methods for @Box {
180 180 #[doc="The main reflow routine."]
181 181 fn reflow(available_width: au) {
182 182 alt self.kind {
183   - BlockBox { self.reflow_block(available_width) }
184   - InlineBox { self.reflow_inline(available_width) }
185   - IntrinsicBox(size) { self.reflow_intrinsic(*size) }
186   - TextBox(subbox) { self.reflow_text(available_width, subbox) }
  183 + BlockBox => self.reflow_block(available_width),
  184 + InlineBox => self.reflow_inline(available_width),
  185 + IntrinsicBox(size) => self.reflow_intrinsic(*size),
  186 + TextBox(subbox) => self.reflow_text(available_width, subbox)
187 187 }
188 188 }
189 189
50 src/servo/layout/box_builder.rs
@@ -55,12 +55,10 @@ impl methods for ctxt {
55 55
56 56 // Add the child's box to the current enclosing box or the current anonymous box.
57 57 alt kid.get_specified_style().display_type {
58   - some(DisBlock) {
59   - BTree.add_child(self.parent_box, kid_box);
60   - }
61   - some(DisInline) {
  58 + some(DisBlock) => BTree.add_child(self.parent_box, kid_box),
  59 + some(DisInline) => {
62 60 let anon_box = alt self.anon_box {
63   - none {
  61 + none => {
64 62 //
65 63 // The anonymous box inherits the attributes of its parents for now, so
66 64 // that properties of intrinsic boxes are not spread to their parenting
@@ -73,14 +71,14 @@ impl methods for ctxt {
73 71 self.anon_box = some(b);
74 72 b
75 73 }
76   - some(b) { b }
  74 + some(b) => b
77 75 };
78 76 BTree.add_child(anon_box, kid_box);
79 77 }
80   - some(DisNone) {
  78 + some(DisNone) => {
81 79 // Nothing to do.
82 80 }
83   - _ { //hack for now
  81 + _ => { //hack for now
84 82 }
85 83 }
86 84 }
@@ -104,18 +102,18 @@ impl methods for ctxt {
104 102
105 103 // Add the child's box to the current enclosing box.
106 104 alt kid.get_specified_style().display_type {
107   - some(DisBlock) {
  105 + some(DisBlock) => {
108 106 // TODO
109 107 #warn("TODO: non-inline display found inside inline box");
110 108 BTree.add_child(self.parent_box, kid_box);
111 109 }
112   - some(DisInline) {
  110 + some(DisInline) => {
113 111 BTree.add_child(self.parent_box, kid_box);
114 112 }
115   - some(DisNone) {
  113 + some(DisNone) => {
116 114 // Nothing to do.
117 115 }
118   - _ { //hack for now
  116 + _ => { //hack for now
119 117 }
120 118 }
121 119 }
@@ -127,10 +125,10 @@ impl methods for ctxt {
127 125 self.parent_node.dump();
128 126
129 127 alt self.parent_node.get_specified_style().display_type {
130   - some(DisBlock) { self.construct_boxes_for_block_children(); }
131   - some(DisInline) { self.construct_boxes_for_inline_children(); }
132   - some(DisNone) { /* Nothing to do. */ }
133   - _ { //hack for now
  128 + some(DisBlock) => self.construct_boxes_for_block_children(),
  129 + some(DisInline) => self.construct_boxes_for_inline_children(),
  130 + some(DisNone) => { /* Nothing to do. */ }
  131 + _ => { //hack for now
134 132 }
135 133 }
136 134
@@ -144,8 +142,8 @@ impl methods for ctxt {
144 142 "]
145 143 fn finish_anonymous_box_if_necessary() {
146 144 alt copy self.anon_box {
147   - none { /* Nothing to do. */ }
148   - some(b) { BTree.add_child(self.parent_box, b); }
  145 + none => { /* Nothing to do. */ }
  146 + some(b) => BTree.add_child(self.parent_box, b)
149 147 }
150 148 self.anon_box = none;
151 149 }
@@ -162,14 +160,12 @@ impl box_builder_priv of box_builder_priv for Node {
162 160 "]
163 161 fn determine_box_kind() -> BoxKind {
164 162 alt self.read(|n| copy n.kind) {
165   - ~Text(string) {
166   - TextBox(@text_box(copy string))
167   - }
168   - ~Element(element) {
  163 + ~Text(string) => TextBox(@text_box(copy string)),
  164 + ~Element(element) => {
169 165 alt *element.kind {
170   - HTMLDivElement { BlockBox }
171   - HTMLImageElement({size}) { IntrinsicBox(@size) }
172   - UnknownElement { InlineBox }
  166 + HTMLDivElement => BlockBox,
  167 + HTMLImageElement({size}) => IntrinsicBox(@size),
  168 + UnknownElement => InlineBox
173 169 }
174 170 }
175 171 }
@@ -186,11 +182,11 @@ impl box_builder_methods of box_builder_methods for Node {
186 182 let box_kind = self.determine_box_kind();
187 183 let my_box = @Box(self, box_kind);
188 184 alt box_kind {
189   - BlockBox | InlineBox {
  185 + BlockBox | InlineBox => {
190 186 let cx = create_context(self, my_box);
191 187 cx.construct_boxes_for_children();
192 188 }
193   - _ {
  189 + _ => {
194 190 // Nothing to do.
195 191 }
196 192 }
30 src/servo/layout/display_list_builder.rs
@@ -65,7 +65,7 @@ Creates a display list item for a single block.
65 65 * `origin` - The coordinates of upper-left corner of the passed in box.
66 66
67 67 "]
68   -#[warn(no_non_implicitly_copyable_typarams)]
  68 +#[allow(non_implicitly_copyable_typarams)]
69 69 fn box_to_display_items(list: dl::display_list, box: @Box, origin: Point2D<au>) {
70 70 #debug("request to display a box from origin %?", origin);
71 71
@@ -73,7 +73,7 @@ fn box_to_display_items(list: dl::display_list, box: @Box, origin: Point2D<au>)
73 73 let col = box.appearance.background_color;
74 74
75 75 alt box.kind {
76   - TextBox(subbox) {
  76 + TextBox(subbox) => {
77 77 let run = copy subbox.run;
78 78 assert run.is_some();
79 79 list.push(dl::display_item({
@@ -86,7 +86,7 @@ fn box_to_display_items(list: dl::display_list, box: @Box, origin: Point2D<au>)
86 86 }));
87 87 return;
88 88 }
89   - _ {
  89 + _ => {
90 90 // Fall through
91 91 }
92 92 };
@@ -118,14 +118,16 @@ fn should_convert_text_boxes_to_solid_color_background_items() {
118 118 let s = Scope();
119 119 let n = s.new_node(Text(~"firecracker"));
120 120 let b = n.construct_boxes();
121   - let subbox = alt check b.kind { TextBox(subbox) { subbox } };
  121 +
  122 + let subbox = alt check b.kind { TextBox(subbox) => subbox };
  123 +
122 124 b.reflow_text(px_to_au(800), subbox);
123 125 let list = dvec();
124 126 box_to_display_items(list, b, Point2D(px_to_au(0), px_to_au(0)));
125 127
126 128 alt list[0].item_type {
127   - dl::display_item_solid_color(*) { }
128   - _ { fail }
  129 + dl::display_item_solid_color(*) => { }
  130 + _ => { fail }
129 131 }
130 132
131 133 }
@@ -137,14 +139,16 @@ fn should_convert_text_boxes_to_text_items() {
137 139 let s = Scope();
138 140 let n = s.new_node(Text(~"firecracker"));
139 141 let b = n.construct_boxes();
140   - let subbox = alt check b.kind { TextBox(subbox) { subbox } };
  142 +
  143 + let subbox = alt check b.kind { TextBox(subbox) => { subbox } };
  144 +
141 145 b.reflow_text(px_to_au(800), subbox);
142 146 let list = dvec();
143 147 box_to_display_items(list, b, Point2D(px_to_au(0), px_to_au(0)));
144 148
145 149 alt list[1].item_type {
146   - dl::display_item_text(_) { }
147   - _ { fail }
  150 + dl::display_item_text(_) => { }
  151 + _ => { fail }
148 152 }
149 153 }
150 154
@@ -155,7 +159,9 @@ fn should_calculate_the_bounds_of_the_text_box_background_color() {
155 159 let s = Scope();
156 160 let n = s.new_node(Text(~"firecracker"));
157 161 let b = n.construct_boxes();
158   - let subbox = alt check b.kind { TextBox(subbox) { subbox } };
  162 +
  163 + let subbox = alt check b.kind { TextBox(subbox) => { subbox } };
  164 +
159 165 b.reflow_text(px_to_au(800), subbox);
160 166 let list = dvec();
161 167 box_to_display_items(list, b, Point2D(px_to_au(0), px_to_au(0)));
@@ -175,7 +181,9 @@ fn should_calculate_the_bounds_of_the_text_items() {
175 181 let s = Scope();
176 182 let n = s.new_node(Text(~"firecracker"));
177 183 let b = n.construct_boxes();
178   - let subbox = alt check b.kind { TextBox(subbox) { subbox } };
  184 +
  185 + let subbox = alt check b.kind { TextBox(subbox) => { subbox } };
  186 +
179 187 b.reflow_text(px_to_au(800), subbox);
180 188 let list = dvec();
181 189 box_to_display_items(list, b, Point2D(px_to_au(0), px_to_au(0)));
52 src/servo/layout/layout_task.rs
@@ -21,41 +21,39 @@ import comm::*;
21 21 type Layout = chan<Msg>;
22 22
23 23 enum Msg {
24   - BuildMsg(Node, Stylesheet),
  24 + BuildMsg(Node, arc<Stylesheet>),
25 25 PingMsg(chan<content::PingMsg>),
26 26 ExitMsg
27 27 }
28 28
29 29 fn Layout(renderer: Renderer) -> Layout {
30   - spawn_listener::<Msg>(|request| {
  30 + do spawn_listener::<Msg>|request| {
31 31 loop {
32 32 alt request.recv() {
33   - PingMsg(ping_channel) {
34   - ping_channel.send(content::PongMsg);
35   - }
36   - ExitMsg {
37   - #debug("layout: ExitMsg received");
38   - break;
39   - }
40   - BuildMsg(node, styles) {
41   - #debug("layout: received layout request for:");
42   - node.dump();
43   -
44   - do util::time::time(~"layout") {
45   - node.initialize_style_for_subtree();
46   - node.recompute_style_for_subtree(arc(copy styles));
47   -
48   - let this_box = node.construct_boxes();
49   - this_box.dump();
50   -
51   - this_box.apply_css_style();
52   - this_box.reflow(px_to_au(800));
53   -
54   - let dlist = build_display_list(this_box);
55   - renderer.send(renderer::RenderMsg(dlist));
56   - }
  33 + PingMsg(ping_channel) => ping_channel.send(content::PongMsg),
  34 + ExitMsg => {
  35 + #debug("layout: ExitMsg received");
  36 + break;
  37 + }
  38 + BuildMsg(node, styles) => {
  39 + #debug("layout: received layout request for:");
  40 + node.dump();
  41 +
  42 + do util::time::time(~"layout") {
  43 + node.initialize_style_for_subtree();
  44 + node.recompute_style_for_subtree(styles);
  45 +
  46 + let this_box = node.construct_boxes();
  47 + this_box.dump();
  48 +
  49 + this_box.apply_css_style();
  50 + this_box.reflow(px_to_au(800));
  51 +
  52 + let dlist = build_display_list(this_box);
  53 + renderer.send(renderer::RenderMsg(dlist));
57 54 }
  55 + }
58 56 }
59 57 }
60   - })
  58 + }
61 59 }
12 src/servo/layout/style/apply.rs
@@ -34,16 +34,16 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
34 34 // Right now, we only handle images.
35 35 do self.node.read |node| {
36 36 alt node.kind {
37   - ~Element(element) {
  37 + ~Element(element) => {
38 38 let style = self.node.get_specified_style();
39 39
40 40 self.appearance.background_color = alt style.background_color {
41   - some(col) { col }
42   - none { node.kind.default_color() }
  41 + some(col) => col,
  42 + none => node.kind.default_color()
43 43 };
44 44
45 45 alt element.kind {
46   - ~HTMLImageElement(*) {
  46 + ~HTMLImageElement(*) => {
47 47 let url = element.get_attr(~"src");
48 48
49 49 if url.is_some() {
@@ -52,10 +52,10 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
52 52 self.appearance.background_image = some(ImageHolder(option::unwrap(url)))
53 53 };
54 54 }
55   - _ { /* Ignore. */ }
  55 + _ => { /* Ignore. */ }
56 56 }
57 57 }
58   - _ { /* Ignore. */ }
  58 + _ => { /* Ignore. */ }
59 59 }
60 60 }
61 61 }
99 src/servo/layout/style/matching.rs
@@ -14,41 +14,41 @@ export matching_methods;
14 14 #[doc="Check if a CSS attribute matches the attribute of an HTML element."]
15 15 fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
16 16 alt attr {
17   - Exists(name) {
  17 + Exists(name) => {
18 18 alt elmt.get_attr(name) {
19   - some(_) { return true; }
20   - none { return false; }
  19 + some(_) => true,
  20 + none => false
21 21 }
22 22 }
23   - Exact(name, val) {
  23 + Exact(name, val) => {
24 24 alt elmt.get_attr(name) {
25   - some(value) { return value == val; }
26   - none { return false; }
  25 + some(value) => value == val,
  26 + none => false
27 27 }
28 28 }
29   - Includes(name, val) {
  29 + Includes(name, val) => {
30 30 // Comply with css spec, if the specified attribute is empty
31 31 // it cannot match.
32 32 if val == ~"" { return false; }
33 33
34 34 alt elmt.get_attr(name) {
35   - some(value) { return value.split_char(' ').contains(val); }
36   - none { return false; }
  35 + some(value) => value.split_char(' ').contains(val),
  36 + none => false
37 37 }
38 38 }
39   - StartsWith(name, val) {
  39 + StartsWith(name, val) => {
40 40 alt elmt.get_attr(name) {
41   - some(value) {
  41 + some(value) => {
42 42 //check that there is only one attribute value and it
43 43 //starts with the perscribed value
44 44 if !value.starts_with(val) || value.contains(~" ") { return false; }
45 45
46 46 // We match on either the exact value or value-foo
47   - if value.len() == val.len() { return true; }
48   - else { return value.starts_with(val + ~"-"); }
  47 + if value.len() == val.len() { true }
  48 + else { value.starts_with(val + ~"-") }
49 49 }
50   - none {
51   - return false;
  50 + none => {
  51 + false
52 52 }
53 53 }
54 54 }
@@ -67,10 +67,10 @@ impl priv_matching_methods of priv_matching_methods for Node {
67 67 "]
68 68 fn matches_element(sel: ~Selector) -> bool {
69 69 alt *sel {
70   - Child(_, _) | Descendant(_, _) | Sibling(_, _) { return false; }
71   - Element(tag, attrs) {
  70 + Child(_, _) | Descendant(_, _) | Sibling(_, _) => { return false; }
  71 + Element(tag, attrs) => {
72 72 alt self.read(|n| copy *n.kind) {
73   - base::Element(elmt) {
  73 + base::Element(elmt) => {
74 74 if !(tag == ~"*" || tag == elmt.tag_name) {
75 75 return false;
76 76 }
@@ -83,7 +83,7 @@ impl priv_matching_methods of priv_matching_methods for Node {
83 83
84 84 return true;
85 85 }
86   - Text(str) { /*fall through, currently unsupported*/ }
  86 + Text(str) => { /*fall through, currently unsupported*/ }
87 87 }
88 88 }
89 89 }
@@ -95,70 +95,65 @@ impl priv_matching_methods of priv_matching_methods for Node {
95 95 #[doc = "Checks if a generic CSS selector matches a given HTML element"]
96 96 fn matches_selector(sel : ~Selector) -> bool {
97 97 alt *sel {
98   - Element(str, atts) { return self.matches_element(sel); }
99   - Child(sel1, sel2) {
100   - alt self.read(|n| n.tree.parent) {
101   - some(parent) {
102   - return self.matches_element(sel2) &&
103   - parent.matches_selector(sel1);
104   - }
105   - none { return false; }
  98 + Element(str, atts) => { return self.matches_element(sel); }
  99 + Child(sel1, sel2) => {
  100 + return alt self.read(|n| n.tree.parent) {
  101 + some(parent) => self.matches_element(sel2) && parent.matches_selector(sel1),
  102 + none => false
106 103 }
107 104 }
108   - Descendant(sel1, sel2) {
109   - if !self.matches_element(sel2) {
110   - return false;
111   - }
  105 + Descendant(sel1, sel2) => {
  106 + if !self.matches_element(sel2) { return false; }
112 107
113 108 //loop over all ancestors to check if they are the person
114 109 //we should be descended from.
115 110 let mut cur_parent = alt self.read(|n| n.tree.parent) {
116   - some(parent) { parent }
117   - none { return false; }
  111 + some(parent) => parent,
  112 + none => return false
118 113 };
119 114
120 115 loop {
121 116 if cur_parent.matches_selector(sel1) { return true; }
122 117
123 118 cur_parent = alt cur_parent.read(|n| n.tree.parent) {
124   - some(parent) { parent }
125   - none { return false; }
  119 + some(parent) => parent,
  120 + none => return false
126 121 };
127 122 }
128 123 }
129   - Sibling(sel1, sel2) {
  124 + Sibling(sel1, sel2) => {
130 125 if !self.matches_element(sel2) { return false; }
131 126
132 127 // Loop over this node's previous siblings to see if they match.
133 128 alt self.read(|n| n.tree.prev_sibling) {
134   - some(sib) {
  129 + some(sib) => {
135 130 let mut cur_sib = sib;
136 131 loop {
137 132 if cur_sib.matches_selector(sel1) { return true; }
138 133
139 134 cur_sib = alt cur_sib.read(|n| n.tree.prev_sibling) {
140   - some(sib) { sib }
141   - none { break; }
  135 + some(sib) => sib,
  136 + none => { break; }
142 137 };
143 138 }
144 139 }
145   - none { }
  140 + none => { }
146 141 }
147 142
148 143 // check the rest of the siblings
149 144 alt self.read(|n| n.tree.next_sibling) {
150   - some(sib) {
  145 + some(sib) => {
151 146 let mut cur_sib = sib;
152 147 loop {
153 148 if cur_sib.matches_selector(sel1) { return true; }
154 149
155 150 cur_sib = alt cur_sib.read(|n| n.tree.next_sibling) {
156   - some(sib) { sib }
157   - none { break; }
  151 + some(sib) => sib,
  152 + none => { break; }
158 153 };
159 154 }
160 155 }
161   - none { }
  156 + none => { }
162 157 }
163 158
164 159 return false;
@@ -176,13 +171,13 @@ impl priv_style_methods of priv_style_methods for Node {
176 171 fn update_style(decl : StyleDeclaration) {
177 172 self.aux(|layout| {
178 173 alt decl {
179   - BackgroundColor(col) { layout.specified_style.background_color = some(col); }
180   - Display(dis) { layout.specified_style.display_type = some(dis); }
181   - FontSize(size) { layout.specified_style.font_size = some(size); }
182   - Height(size) { layout.specified_style.height = some(size); }
183   - TextColor(col) { layout.specified_style.text_color = some(col); }
184   - Width(size) { layout.specified_style.width = some(size); }
185   - }
  174 + BackgroundColor(col) => layout.specified_style.background_color = some(col),
  175 + Display(dis) => layout.specified_style.display_type = some(dis),
  176 + FontSize(size) => layout.specified_style.font_size = some(size),
  177 + Height(size) => layout.specified_style.height = some(size),
  178 + TextColor(col) => layout.specified_style.text_color = some(col),
  179 + Width(size) => layout.specified_style.width = some(size)
  180 + };
186 181 })
187 182 }
188 183 }
@@ -222,7 +217,7 @@ mod test {
222 217 import dvec::{dvec, extensions};
223 218 import io::println;
224 219
225   - #[warn(no_non_implicitly_copyable_typarams)]
  220 + #[allow(non_implicitly_copyable_typarams)]
226 221 fn new_node_from_attr(scope: NodeScope, -name: ~str, -val: ~str) -> Node {
227 222 let elmt = ElementData(~"div", ~HTMLDivElement);
228 223 let attr = ~Attr(name, val);
16 src/servo/layout/style/style.rs
@@ -30,8 +30,8 @@ trait default_style_methods {
30 30 impl default_style_methods of default_style_methods for NodeKind {
31 31 fn default_color() -> Color {
32 32 alt self {
33   - Text(*) { white() }
34   - Element(*) {
  33 + Text(*) => { white() }
  34 + Element(*) => {
35 35 let r = rand::rng();
36 36 rgb(r.next() as u8, r.next() as u8, r.next() as u8)
37 37 }
@@ -40,13 +40,13 @@ impl default_style_methods of default_style_methods for NodeKind {
40 40
41 41 fn default_display_type() -> DisplayType {
42 42 alt self {
43   - Text(*) { DisInline }
44   - Element(element) {
  43 + Text(*) => { DisInline }
  44 + Element(element) => {
45 45 alt *element.kind {
46   - HTMLDivElement { DisBlock }
47   - HTMLHeadElement { DisNone }
48   - HTMLImageElement(*) { DisInline }
49   - UnknownElement { DisInline }
  46 + HTMLDivElement => DisBlock,
  47 + HTMLHeadElement => DisNone,
  48 + HTMLImageElement(*) => DisInline,
  49 + UnknownElement => DisInline
50 50 }
51 51 }
52 52 }
6 src/servo/layout/text.rs
@@ -24,8 +24,8 @@ trait text_layout_methods {
24 24 impl text_layout_methods of text_layout_methods for @Box {
25 25 fn reflow_text(_available_width: au, subbox: @text_box) {
26 26 alt self.kind {
27   - TextBox(*) { /* ok */ }
28   - _ { fail ~"expected text box in reflow_text!" }
  27 + TextBox(*) => { /* ok */ }
  28 + _ => { fail ~"expected text box in reflow_text!" }
29 29 };
30 30
31 31 // FIXME: The font library should not be initialized here
@@ -51,7 +51,7 @@ fn should_calculate_the_size_of_the_text_box() {
51 51 let n = s.new_node(Text(~"firecracker"));
52 52 let b = n.construct_boxes();
53 53
54   - let subbox = alt check b.kind { TextBox(subbox) { subbox } };
  54 + let subbox = alt check b.kind { TextBox(subbox) => { subbox } };
55 55 b.reflow_text(px_to_au(800), subbox);
56 56 let expected = Size2D(px_to_au(84), px_to_au(20));
57 57 assert b.bounds.size == expected;
2  src/servo/layout/traverse.rs
@@ -88,7 +88,7 @@ fn traverse_helper(-root : @Box, -top_down : fn~(@Box), -bottom_up : fn~(@Box))
88 88 }
89 89
90 90 #[doc="A noneffectful function to be used if only one pass is required."]
91   -fn nop(box : @Box) {
  91 +fn nop(_box : @Box) {
92 92 return;
93 93 }
94 94
10 src/servo/opts.rs
@@ -15,7 +15,7 @@ enum RenderMode {
15 15 Png(~str)
16 16 }
17 17
18   -#[warn(no_non_implicitly_copyable_typarams)]
  18 +#[allow(non_implicitly_copyable_typarams)]
19 19 fn from_cmdline_args(args: ~[~str]) -> Opts {
20 20 import std::getopts;
21 21
@@ -26,8 +26,8 @@ fn from_cmdline_args(args: ~[~str]) -> Opts {
26 26 ];
27 27
28 28 let opt_match = alt getopts::getopts(args, opts) {
29   - result::ok(m) { copy m }
30   - result::err(f) { fail getopts::fail_str(f) }
  29 + result::ok(m) => { copy m }
  30 + result::err(f) => { fail getopts::fail_str(f) }
31 31 };
32 32
33 33 let urls = if opt_match.free.is_empty() {
@@ -37,8 +37,8 @@ fn from_cmdline_args(args: ~[~str]) -> Opts {
37 37 };
38 38
39 39 let render_mode = alt getopts::opt_maybe_str(opt_match, ~"o") {
40   - some(output_file) { Png(copy output_file) }
41   - none { Screen }
  40 + some(output_file) => { Png(copy output_file) }
  41 + none => { Screen }
42 42 };
43 43
44 44 {
93 src/servo/parser/css_builder.rs
@@ -27,8 +27,8 @@ trait util_methods {
27 27 impl util_methods of util_methods for TokenReader {
28 28 fn get() -> Token {
29 29 alt copy self.lookahead {
30   - some(tok) { self.lookahead = none; copy tok }
31   - none { self.stream.recv() }
  30 + some(tok) => { self.lookahead = none; copy tok }
  31 + none => { self.stream.recv() }
32 32 }
33 33 }
34 34
@@ -49,9 +49,9 @@ impl parser_methods of parser_methods for TokenReader {
49 49 fn parse_element() -> option<~style::Selector> {
50 50 // Get the current element type
51 51 let elmt_name = alt self.get() {
52   - Element(tag) { copy tag }
53   - Eof { return none; }
54   - _ { fail ~"Expected an element" }
  52 + Element(tag) => { copy tag }
  53 + Eof => { return none; }
  54 + _ => { fail ~"Expected an element" }
55 55 };
56 56
57 57 let mut attr_list = ~[];
@@ -60,15 +60,15 @@ impl parser_methods of parser_methods for TokenReader {
60 60 loop {
61 61 let tok = self.get();
62 62 alt tok {
63   - Attr(attr) { push(attr_list, copy attr); }
64   - StartDescription | Descendant | Child | Sibling | Comma {
  63 + Attr(attr) => { push(attr_list, copy attr); }
  64 + StartDescription | Descendant | Child | Sibling | Comma => {
65 65 self.unget(tok);
66 66 break;
67 67 }
68   - Eof { return none; }
69   - Element(_) { fail ~"Unexpected second element without relation to first element"; }
70   - EndDescription { fail ~"Unexpected '}'"; }
71   - Description(_, _) { fail ~"Unexpected description"; }
  68 + Eof => { return none; }
  69 + Element(_) => fail ~"Unexpected second element without relation to first element",
  70 + EndDescription => fail ~"Unexpected '}'",
  71 + Description(_, _) => fail ~"Unexpected description"
72 72 }
73 73 }
74 74 return some(~style::Element(elmt_name, attr_list));
@@ -82,8 +82,8 @@ impl parser_methods of parser_methods for TokenReader {
82 82 let mut cur_sel;
83 83
84 84 alt self.parse_element() {
85   - some(elmt) { cur_sel = copy elmt; }
86   - none { return none; } // we hit an eof in the middle of a rule
  85 + some(elmt) => { cur_sel = copy elmt; }
  86 + none => { return none; } // we hit an eof in the middle of a rule
87 87 }
88 88
89 89 loop {
@@ -91,47 +91,47 @@ impl parser_methods of parser_methods for TokenReader {
91 91 let built_sel <- cur_sel;
92 92
93 93 alt tok {
94   - Descendant {
  94 + Descendant => {
95 95 alt self.parse_element() {
96   - some(elmt) {
  96 + some(elmt) => {
97 97 let new_sel = copy elmt;
98 98 cur_sel <- ~style::Descendant(built_sel, new_sel)
99 99 }
100   - none { return none; }
  100 + none => { return none; }
101 101 }
102 102 }
103   - Child {
  103 + Child => {
104 104 alt self.parse_element() {
105   - some(elmt) {
  105 + some(elmt) => {
106 106 let new_sel = copy elmt;
107 107 cur_sel <- ~style::Child(built_sel, new_sel)
108 108 }
109   - none { return none; }
  109 + none => { return none; }
110 110 }
111 111 }
112   - Sibling {
  112 + Sibling => {
113 113 alt self.parse_element() {
114   - some(elmt) {
  114 + some(elmt) => {
115 115 let new_sel = copy elmt;
116 116 cur_sel <- ~style::Sibling(built_sel, new_sel)
117 117 }
118   - none { return none; }
  118 + none => { return none; }
119 119 }
120 120 }
121   - StartDescription {
  121 + StartDescription => {
122 122 push(sel_list, built_sel);
123 123 self.unget(StartDescription);
124 124 break;
125 125 }
126   - Comma {
  126 + Comma => {
127 127 push(sel_list, built_sel);
128 128 self.unget(Comma);
129 129 break;
130 130 }
131   - Attr(_) | EndDescription | Element(_) | Description(_, _) {
  131 + Attr(_) | EndDescription | Element(_) | Description(_, _) => {
132 132 fail #fmt["Unexpected token %? in elements", tok];
133 133 }
134   - Eof { return none; }
  134 + Eof => { return none; }
135 135 }
136 136 }
137 137
@@ -139,9 +139,9 @@ impl parser_methods of parser_methods for TokenReader {
139 139 // TODO: fix this when rust gets labelled loops
140 140 let tok = self.get();
141 141 alt tok {
142   - StartDescription { break; }
143   - Comma { }
144   - _ { self.unget(tok); }
  142 + StartDescription => { break; }
  143 + Comma => { }
  144 + _ => { self.unget(tok); }
145 145 }
146 146 }