aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/htmlimageelement.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2014-04-17 14:54:11 -0400
committerJosh Matthews <josh@joshmatthews.net>2014-04-17 17:41:09 -0400
commit742f73ded59eb9e9f4208642e053ddbfc48bce73 (patch)
tree0bdc322085ecc7113d45bd5e487c01ad534ea16c /src/components/script/dom/htmlimageelement.rs
parent7441dae1aff4966e40ef3cf4129f307d23e2eeba (diff)
downloadservo-742f73ded59eb9e9f4208642e053ddbfc48bce73.tar.gz
servo-742f73ded59eb9e9f4208642e053ddbfc48bce73.zip
Add transparent Traceable and Untraceable types to aid proper rooting practices, and replace ad-hoc Untraceable structs with empty Encodable implementations.
Diffstat (limited to 'src/components/script/dom/htmlimageelement.rs')
-rw-r--r--src/components/script/dom/htmlimageelement.rs26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/components/script/dom/htmlimageelement.rs b/src/components/script/dom/htmlimageelement.rs
index 3b966bbfe24..a62aea8b991 100644
--- a/src/components/script/dom/htmlimageelement.rs
+++ b/src/components/script/dom/htmlimageelement.rs
@@ -5,8 +5,9 @@
use dom::bindings::codegen::HTMLImageElementBinding;
use dom::bindings::codegen::InheritTypes::{NodeCast, HTMLImageElementDerived};
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
-use dom::bindings::js::JS;
use dom::bindings::error::ErrorResult;
+use dom::bindings::js::JS;
+use dom::bindings::trace::Untraceable;
use dom::document::Document;
use dom::element::{Element, HTMLImageElementTypeId};
use dom::element::AttributeHandlers;
@@ -21,21 +22,10 @@ use servo_util::url::parse_url;
use servo_util::str::DOMString;
use url::Url;
-use serialize::{Encoder, Encodable};
-
#[deriving(Encodable)]
pub struct HTMLImageElement {
htmlelement: HTMLElement,
- priv extra: Untraceable,
-}
-
-struct Untraceable {
- image: Option<Url>,
-}
-
-impl<S: Encoder> Encodable<S> for Untraceable {
- fn encode(&self, _s: &mut S) {
- }
+ image: Untraceable<Option<Url>>,
}
impl HTMLImageElementDerived for EventTarget {
@@ -51,9 +41,7 @@ impl HTMLImageElement {
pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLImageElement {
HTMLImageElement {
htmlelement: HTMLElement::new_inherited(HTMLImageElementTypeId, localName, document),
- extra: Untraceable {
- image: None,
- }
+ image: Untraceable::new(None),
}
}
@@ -65,7 +53,7 @@ impl HTMLImageElement {
impl HTMLImageElement {
pub fn image<'a>(&'a self) -> &'a Option<Url> {
- &self.extra.image
+ &*self.image
}
/// Makes the local `image` member match the status of the `src` attribute and starts
@@ -77,11 +65,11 @@ impl HTMLImageElement {
let image_cache = &window.image_cache_task;
match value {
None => {
- self.extra.image = None;
+ *self.image = None;
}
Some(src) => {
let img_url = parse_url(src, url);
- self.extra.image = Some(img_url.clone());
+ *self.image = Some(img_url.clone());
// inform the image cache to load this, but don't store a
// handle.