diff --git a/src/servo/layout/base.rs b/src/servo/layout/base.rs index 03ae0345bf2..fce119c2d22 100644 --- a/src/servo/layout/base.rs +++ b/src/servo/layout/base.rs @@ -19,6 +19,8 @@ import style::style::SpecifiedStyle; import text::text_layout_methods; import vec::{push, push_all}; +import future::future; + enum BoxKind { BlockBox, InlineBox, @@ -27,7 +29,7 @@ enum BoxKind { } class Appearance { - let mut background_image: option<@image>; + let mut background_image: option>; let mut background_color: Color; new() { diff --git a/src/servo/layout/display_list_builder.rs b/src/servo/layout/display_list_builder.rs index 3c1d99f3824..09eeab8d524 100644 --- a/src/servo/layout/display_list_builder.rs +++ b/src/servo/layout/display_list_builder.rs @@ -1,18 +1,19 @@ export build_display_list; -import dl = display_list; -import dom::rcu::Scope; -import dom::base::{Text, NodeScope}; -import gfx::geometry::{au, au_to_px, box, px_to_au}; -import gfx::renderer; -import util::color::methods; -import util::tree; +import base::{Box, TextBox, BTree, BoxTreeReadMethods}; import box_builder::box_builder_methods; -import text::text_layout_methods; -import geom::size::Size2D; +import dl = display_list; +import dom::base::{Text, NodeScope}; +import dom::rcu::Scope; import geom::point::Point2D; import geom::rect::Rect; -import base::{Box, TextBox, BTree, BoxTreeReadMethods}; +import geom::size::Size2D; +import gfx::geometry::{au, au_to_px, box, px_to_au}; +import gfx::renderer; +import text::text_layout_methods; +import util::color::methods; +import util::tree; + import vec::push; #[doc = " @@ -85,9 +86,10 @@ fn box_to_display_items(box: @Box, origin: Point2D) -> ~[dl::display_item] { bounds: bounds })); } - (_, some(image)) { + (_, some(image)) { + // FIXME: This should not copy and instead should use an ARC. push(items, dl::display_item({ - item_type: dl::display_item_image(~copy *image), + item_type: dl::display_item_image(copy image.get()), bounds: bounds })); } diff --git a/src/servo/layout/style/apply.rs b/src/servo/layout/style/apply.rs index 95f796db753..4c5b27f7d45 100644 --- a/src/servo/layout/style/apply.rs +++ b/src/servo/layout/style/apply.rs @@ -6,6 +6,8 @@ import image::base::load; import base::{Box, BTree, NTree, LayoutData, BoxTreeReadMethods, SpecifiedStyle}; import style::{default_style_methods, style_methods}; +import future_spawn = future::spawn; + trait ApplyStyleBoxMethods { fn apply_style_for_subtree(); fn apply_style(); @@ -28,7 +30,7 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box { "] fn apply_style() { // Right now, we only handle images. - self.node.read(|node| { + do self.node.read |node| { alt node.kind { ~Element(element) { let style = self.node.get_specified_style(); @@ -44,10 +46,10 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box { some(url) { // FIXME: Some sort of BASE HREF support! // FIXME: Parse URLs! - // FIXME: Do not load synchronously! + self.appearance.background_image = some(do future_spawn { + ~load(url) + }); #debug("loading image from %s", url); - let image = @load(url); - self.appearance.background_image = some(image); } none { /* Ignore. */ @@ -59,7 +61,7 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box { } _ { /* Ignore. */ } } - }) + } } }