mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Add missing files
This commit is contained in:
parent
8a007476ec
commit
c4111d11b8
2 changed files with 52 additions and 0 deletions
4
src/servo/image/base.rs
Normal file
4
src/servo/image/base.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export image;
|
||||||
|
export load;
|
||||||
|
import stb_image::image::{image, load};
|
||||||
|
|
48
src/servo/layout/style/apply.rs
Normal file
48
src/servo/layout/style/apply.rs
Normal 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. */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue