Add missing files

This commit is contained in:
Patrick Walton 2012-05-24 19:07:32 -07:00
parent 8a007476ec
commit c4111d11b8
2 changed files with 52 additions and 0 deletions

4
src/servo/image/base.rs Normal file
View file

@ -0,0 +1,4 @@
export image;
export load;
import stb_image::image::{image, load};

View file

@ -0,0 +1,48 @@
#[doc="Applies style to boxes."]
import dom::base::{es_img, nk_element, node};
import dom::rcu::reader_methods;
import image::base::load;
import /*layout::*/base::*;
impl apply_style_methods for @box {
fn apply_style_for_subtree() {
self.apply_style();
for btree.each_child(self) {
|child|
child.apply_style_for_subtree();
}
}
#[doc="Applies CSS style."]
fn apply_style() {
// Right now, we only handle images.
self.node.rd {
|node|
alt node.kind {
~nk_element(element) {
alt element.subclass {
~es_img(*) {
alt element.get_attr("src") {
some(url) {
// FIXME: Some sort of BASE HREF support!
// FIXME: Parse URLs!
// FIXME: Don't load synchronously!
#debug("loading image from %s", url);
let image = @load(url);
self.appearance.background_image =
some(image);
}
none {
/* Ignore. */
}
}
}
_ { /* Ignore. */ }
}
}
_ { /* Ignore. */ }
}
}
}
}