servo: Add missing files
authorPatrick Walton <pcwalton@mimiga.net>
Thu, 24 May 2012 19:07:32 -0700
changeset 470745 afe07e6b28db356c5d94e0a1a4d678ec8b772c64
parent 470744 084df16f7586f4e1fe901b912a4d63979c0ba0ae
child 470746 31cb486a3db28b6e4e8b2879ee8223ebd650901a
push id44079
push userbmo:gps@mozilla.com
push dateSat, 04 Feb 2017 00:14:49 +0000
servo: Add missing files Source-Repo: https://github.com/servo/servo Source-Revision: c4111d11b84a3fec1a3906c5fedc29d7ca509868
servo/src/servo/image/base.rs
servo/src/servo/layout/style/apply.rs
new file mode 100644
--- /dev/null
+++ b/servo/src/servo/image/base.rs
@@ -0,0 +1,4 @@
+export image;
+export load;
+import stb_image::image::{image, load};
+
new file mode 100644
--- /dev/null
+++ b/servo/src/servo/layout/style/apply.rs
@@ -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. */ }
+			}
+		}
+	}
+}
+