aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/htmlstyleelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script/dom/htmlstyleelement.rs')
-rw-r--r--src/components/script/dom/htmlstyleelement.rs61
1 files changed, 36 insertions, 25 deletions
diff --git a/src/components/script/dom/htmlstyleelement.rs b/src/components/script/dom/htmlstyleelement.rs
index 29caa80da1d..b0688f30889 100644
--- a/src/components/script/dom/htmlstyleelement.rs
+++ b/src/components/script/dom/htmlstyleelement.rs
@@ -4,13 +4,13 @@
use dom::bindings::codegen::BindingDeclarations::HTMLStyleElementBinding;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLStyleElementDerived, NodeCast};
-use dom::bindings::js::JS;
+use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::error::ErrorResult;
use dom::document::Document;
use dom::element::HTMLStyleElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
-use dom::node::{Node, ElementNodeTypeId, window_from_node};
+use dom::node::{Node, NodeMethods, ElementNodeTypeId, window_from_node};
use dom::virtualmethods::VirtualMethods;
use html::cssparse::parse_inline_css;
use layout_interface::{AddStylesheetMsg, LayoutChan};
@@ -31,47 +31,58 @@ impl HTMLStyleElementDerived for EventTarget {
}
impl HTMLStyleElement {
- pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLStyleElement {
+ pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLStyleElement {
HTMLStyleElement {
htmlelement: HTMLElement::new_inherited(HTMLStyleElementTypeId, localName, document)
}
}
- pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLStyleElement> {
- let element = HTMLStyleElement::new_inherited(localName, document.clone());
+ pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLStyleElement> {
+ let element = HTMLStyleElement::new_inherited(localName, document);
Node::reflect_node(~element, document, HTMLStyleElementBinding::Wrap)
}
}
-impl HTMLStyleElement {
- pub fn Disabled(&self) -> bool {
+pub trait HTMLStyleElementMethods {
+ fn Disabled(&self) -> bool;
+ fn SetDisabled(&self, _disabled: bool);
+ fn Media(&self) -> DOMString;
+ fn SetMedia(&mut self, _media: DOMString) -> ErrorResult;
+ fn Type(&self) -> DOMString;
+ fn SetType(&mut self, _type: DOMString) -> ErrorResult;
+ fn Scoped(&self) -> bool;
+ fn SetScoped(&self, _scoped: bool) -> ErrorResult;
+}
+
+impl<'a> HTMLStyleElementMethods for JSRef<'a, HTMLStyleElement> {
+ fn Disabled(&self) -> bool {
false
}
- pub fn SetDisabled(&self, _disabled: bool) {
+ fn SetDisabled(&self, _disabled: bool) {
}
- pub fn Media(&self) -> DOMString {
+ fn Media(&self) -> DOMString {
~""
}
- pub fn SetMedia(&mut self, _media: DOMString) -> ErrorResult {
+ fn SetMedia(&mut self, _media: DOMString) -> ErrorResult {
Ok(())
}
- pub fn Type(&self) -> DOMString {
+ fn Type(&self) -> DOMString {
~""
}
- pub fn SetType(&mut self, _type: DOMString) -> ErrorResult {
+ fn SetType(&mut self, _type: DOMString) -> ErrorResult {
Ok(())
}
- pub fn Scoped(&self) -> bool {
+ fn Scoped(&self) -> bool {
false
}
- pub fn SetScoped(&self, _scoped: bool) -> ErrorResult {
+ fn SetScoped(&self, _scoped: bool) -> ErrorResult {
Ok(())
}
}
@@ -80,26 +91,26 @@ pub trait StyleElementHelpers {
fn parse_own_css(&self);
}
-impl StyleElementHelpers for JS<HTMLStyleElement> {
+impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
fn parse_own_css(&self) {
- let node: JS<Node> = NodeCast::from(self);
- let win = window_from_node(&node);
- let url = win.get().page().get_url();
+ let node: &JSRef<Node> = NodeCast::from_ref(self);
+ let win = window_from_node(node).root();
+ let url = win.deref().page().get_url();
- let data = node.get().GetTextContent(&node).expect("Element.textContent must be a string");
+ let data = node.GetTextContent().expect("Element.textContent must be a string");
let sheet = parse_inline_css(url, data);
- let LayoutChan(ref layout_chan) = *win.get().page().layout_chan;
+ let LayoutChan(ref layout_chan) = *win.deref().page().layout_chan;
layout_chan.send(AddStylesheetMsg(sheet));
}
}
-impl VirtualMethods for JS<HTMLStyleElement> {
- fn super_type(&self) -> Option<~VirtualMethods:> {
- let htmlelement: JS<HTMLElement> = HTMLElementCast::from(self);
- Some(~htmlelement as ~VirtualMethods:)
+impl<'a> VirtualMethods for JSRef<'a, HTMLStyleElement> {
+ fn super_type<'a>(&'a mut self) -> Option<&'a mut VirtualMethods:> {
+ let htmlelement: &mut JSRef<HTMLElement> = HTMLElementCast::from_mut_ref(self);
+ Some(htmlelement as &mut VirtualMethods:)
}
- fn child_inserted(&mut self, child: &JS<Node>) {
+ fn child_inserted(&mut self, child: &JSRef<Node>) {
match self.super_type() {
Some(ref mut s) => s.child_inserted(child),
_ => (),