First steps of &JSRef -> JSRef conversion

Replace &JSRef with JSRef in the bulk of the generated code. This will
remove a level of indirection throughout all DOM code.

This patch doesn't change methods implemented on JSRef<T> to take `self`
rather than `&self`, and it leaves a few other uses of &JSRef, but those
changes can be made incrementally.
This commit is contained in:
Cameron Zwarich 2014-09-18 13:43:15 -07:00
parent b8f34bbc51
commit 4fa8725111
126 changed files with 994 additions and 992 deletions

View file

@ -95,7 +95,7 @@ impl Reflectable for Attr {
impl Attr { impl Attr {
fn new_inherited(local_name: Atom, value: AttrValue, fn new_inherited(local_name: Atom, value: AttrValue,
name: Atom, namespace: Namespace, name: Atom, namespace: Namespace,
prefix: Option<DOMString>, owner: &JSRef<Element>) -> Attr { prefix: Option<DOMString>, owner: JSRef<Element>) -> Attr {
Attr { Attr {
reflector_: Reflector::new(), reflector_: Reflector::new(),
local_name: local_name, local_name: local_name,
@ -107,11 +107,11 @@ impl Attr {
} }
} }
pub fn new(window: &JSRef<Window>, local_name: Atom, value: AttrValue, pub fn new(window: JSRef<Window>, local_name: Atom, value: AttrValue,
name: Atom, namespace: Namespace, name: Atom, namespace: Namespace,
prefix: Option<DOMString>, owner: &JSRef<Element>) -> Temporary<Attr> { prefix: Option<DOMString>, owner: JSRef<Element>) -> Temporary<Attr> {
reflect_dom_object(box Attr::new_inherited(local_name, value, name, namespace, prefix, owner), reflect_dom_object(box Attr::new_inherited(local_name, value, name, namespace, prefix, owner),
&Window(*window), AttrBinding::Wrap) &Window(window), AttrBinding::Wrap)
} }
} }
@ -157,13 +157,13 @@ pub trait AttrHelpers {
impl<'a> AttrHelpers for JSRef<'a, Attr> { impl<'a> AttrHelpers for JSRef<'a, Attr> {
fn set_value(&self, set_type: AttrSettingType, value: AttrValue) { fn set_value(&self, set_type: AttrSettingType, value: AttrValue) {
let owner = self.owner.root(); let owner = self.owner.root();
let node: &JSRef<Node> = NodeCast::from_ref(&*owner); let node: JSRef<Node> = NodeCast::from_ref(*owner);
let namespace_is_null = self.namespace == namespace::Null; let namespace_is_null = self.namespace == namespace::Null;
match set_type { match set_type {
ReplacedAttr => { ReplacedAttr => {
if namespace_is_null { if namespace_is_null {
vtable_for(node).before_remove_attr( vtable_for(&node).before_remove_attr(
self.local_name(), self.local_name(),
self.value().as_slice().to_string()) self.value().as_slice().to_string())
} }
@ -174,7 +174,7 @@ impl<'a> AttrHelpers for JSRef<'a, Attr> {
*self.value.deref().borrow_mut() = value; *self.value.deref().borrow_mut() = value;
if namespace_is_null { if namespace_is_null {
vtable_for(node).after_set_attr( vtable_for(&node).after_set_attr(
self.local_name(), self.local_name(),
self.value().as_slice().to_string()) self.value().as_slice().to_string())
} }

View file

@ -115,7 +115,7 @@ impl CallbackInterface {
/// Wraps the reflector for `p` into the compartment of `cx`. /// Wraps the reflector for `p` into the compartment of `cx`.
pub fn WrapCallThisObject<T: Reflectable>(cx: *mut JSContext, pub fn WrapCallThisObject<T: Reflectable>(cx: *mut JSContext,
p: &JSRef<T>) -> *mut JSObject { p: JSRef<T>) -> *mut JSObject {
let mut obj = p.reflector().get_jsobject(); let mut obj = p.reflector().get_jsobject();
assert!(obj.is_not_null()); assert!(obj.is_not_null());
@ -140,7 +140,7 @@ pub struct CallSetup {
impl CallSetup { impl CallSetup {
/// Performs the setup needed to make a call. /// Performs the setup needed to make a call.
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new<T: CallbackContainer>(callback: &T, handling: ExceptionHandling) -> CallSetup { pub fn new<T: CallbackContainer>(callback: T, handling: ExceptionHandling) -> CallSetup {
let global = global_object_for_js_object(callback.callback()); let global = global_object_for_js_object(callback.callback());
let global = global.root(); let global = global.root();
let cx = global.root_ref().get_cx(); let cx = global.root_ref().get_cx();

View file

@ -2170,10 +2170,7 @@ class CGCallGenerator(CGThing):
args = CGList([CGGeneric(arg) for arg in argsPre], ", ") args = CGList([CGGeneric(arg) for arg in argsPre], ", ")
for (a, name) in arguments: for (a, name) in arguments:
#XXXjdm Perhaps we should pass all nontrivial types by borrowed pointer #XXXjdm Perhaps we should pass all nontrivial types by borrowed pointer
if a.type.isGeckoInterface(): if a.type.isDictionary():
if not (a.type.nullable() or a.optional):
name = "&" + name
elif a.type.isDictionary():
name = "&" + name name = "&" + name
args.append(CGGeneric(name)) args.append(CGGeneric(name))
@ -3996,9 +3993,7 @@ class CGInterfaceTrait(CGThing):
elif optional and not defaultValue: elif optional and not defaultValue:
declType = CGWrapper(declType, pre="Option<", post=">") declType = CGWrapper(declType, pre="Option<", post=">")
if ty.isGeckoInterface() and not (ty.nullable() or optional): if ty.isDictionary():
declType = CGWrapper(declType, pre="&")
elif ty.isDictionary():
declType = CGWrapper(declType, pre="&") declType = CGWrapper(declType, pre="&")
return declType.define() return declType.define()
@ -4854,27 +4849,22 @@ class CGNativeMember(ClassMethod):
decl = CGGeneric(decl) decl = CGGeneric(decl)
if handleNullable and type.nullable(): if handleNullable and type.nullable():
decl = CGTemplatedType("Nullable", decl) decl = CGTemplatedType("Nullable", decl)
ref = True
if isMember == "Variadic": if isMember == "Variadic":
arrayType = "Sequence" if self.variadicIsSequence else "nsTArray" arrayType = "Sequence" if self.variadicIsSequence else "nsTArray"
decl = CGTemplatedType(arrayType, decl) decl = CGTemplatedType(arrayType, decl)
ref = True
elif optional: elif optional:
# Note: All variadic args claim to be optional, but we can just use # Note: All variadic args claim to be optional, but we can just use
# empty arrays to represent them not being present. # empty arrays to represent them not being present.
decl = CGTemplatedType("Option", decl) decl = CGTemplatedType("Option", decl)
ref = False return decl
return (decl, ref)
def getArg(self, arg): def getArg(self, arg):
""" """
Get the full argument declaration for an argument Get the full argument declaration for an argument
""" """
(decl, ref) = self.getArgType(arg.type, decl = self.getArgType(arg.type,
arg.optional and not arg.defaultValue, arg.optional and not arg.defaultValue,
"Variadic" if arg.variadic else False) "Variadic" if arg.variadic else False)
if ref:
decl = CGWrapper(decl, pre="&")
return Argument(decl.define(), arg.identifier.name) return Argument(decl.define(), arg.identifier.name)
@ -4931,17 +4921,17 @@ class CGCallback(CGClass):
args.append(Argument("ExceptionHandling", "aExceptionHandling", args.append(Argument("ExceptionHandling", "aExceptionHandling",
"ReportExceptions")) "ReportExceptions"))
args[0] = Argument('&' + args[0].argType, args[0].name, args[0].default) args[0] = Argument(args[0].argType, args[0].name, args[0].default)
method.args[2] = args[0] method.args[2] = args[0]
# And now insert our template argument. # And now insert our template argument.
argsWithoutThis = list(args) argsWithoutThis = list(args)
args.insert(0, Argument("&JSRef<T>", "thisObj")) args.insert(0, Argument("JSRef<T>", "thisObj"))
# And the self argument # And the self argument
method.args.insert(0, Argument(None, "&self")) method.args.insert(0, Argument(None, "self"))
args.insert(0, Argument(None, "&self")) args.insert(0, Argument(None, "self"))
argsWithoutThis.insert(0, Argument(None, "&self")) argsWithoutThis.insert(0, Argument(None, "self"))
setupCall = ("let s = CallSetup::new(self, aExceptionHandling);\n" setupCall = ("let s = CallSetup::new(self, aExceptionHandling);\n"
"if s.GetContext().is_null() {\n" "if s.GetContext().is_null() {\n"
@ -5471,7 +5461,7 @@ class GlobalGenRoots():
cast = [CGGeneric(string.Template('''pub trait ${castTraitName} { cast = [CGGeneric(string.Template('''pub trait ${castTraitName} {
#[inline(always)] #[inline(always)]
fn to_ref<'a, 'b, T: ${toBound}+Reflectable>(base: &'a JSRef<'b, T>) -> Option<&'a JSRef<'b, Self>> { fn to_ref<'a, T: ${toBound}+Reflectable>(base: JSRef<'a, T>) -> Option<JSRef<'a, Self>> {
match base.deref().${checkFn}() { match base.deref().${checkFn}() {
true => unsafe { Some(base.transmute()) }, true => unsafe { Some(base.transmute()) },
false => None false => None
@ -5479,10 +5469,23 @@ class GlobalGenRoots():
} }
#[inline(always)] #[inline(always)]
fn from_ref<'a, 'b, T: ${fromBound}>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, Self> { fn to_borrowed_ref<'a, 'b, T: ${toBound}+Reflectable>(base: &'a JSRef<'b, T>) -> Option<&'a JSRef<'b, Self>> {
match base.deref().${checkFn}() {
true => unsafe { Some(base.transmute_borrowed()) },
false => None
}
}
#[inline(always)]
fn from_ref<'a, T: ${fromBound}>(derived: JSRef<'a, T>) -> JSRef<'a, Self> {
unsafe { derived.transmute() } unsafe { derived.transmute() }
} }
#[inline(always)]
fn from_borrowed_ref<'a, 'b, T: ${fromBound}>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, Self> {
unsafe { derived.transmute_borrowed() }
}
#[inline(always)] #[inline(always)]
fn from_temporary<T: ${fromBound}+Reflectable>(derived: Temporary<T>) -> Temporary<Self> { fn from_temporary<T: ${fromBound}+Reflectable>(derived: Temporary<T>) -> Temporary<Self> {
unsafe { derived.transmute() } unsafe { derived.transmute() }

View file

@ -52,9 +52,9 @@ impl<'a> GlobalRef<'a> {
/// Extract a `Window`, causing task failure if the global object is not /// Extract a `Window`, causing task failure if the global object is not
/// a `Window`. /// a `Window`.
pub fn as_window<'b>(&'b self) -> &'b JSRef<'b, Window> { pub fn as_window<'b>(&'b self) -> JSRef<'b, Window> {
match *self { match *self {
Window(ref window) => window, Window(window) => window,
Worker(_) => fail!("expected a Window scope"), Worker(_) => fail!("expected a Window scope"),
} }
} }
@ -107,8 +107,8 @@ impl GlobalField {
/// Create a new `GlobalField` from a rooted reference. /// Create a new `GlobalField` from a rooted reference.
pub fn from_rooted(global: &GlobalRef) -> GlobalField { pub fn from_rooted(global: &GlobalRef) -> GlobalField {
match *global { match *global {
Window(ref window) => WindowField(JS::from_rooted(window)), Window(window) => WindowField(JS::from_rooted(window)),
Worker(ref worker) => WorkerField(JS::from_rooted(worker)), Worker(worker) => WorkerField(JS::from_rooted(worker)),
} }
} }

View file

@ -21,7 +21,7 @@
//! //!
//! - All methods return `Temporary<T>`, to ensure the value remains alive until it is stored //! - All methods return `Temporary<T>`, to ensure the value remains alive until it is stored
//! somewhere that is reachable by the GC. //! somewhere that is reachable by the GC.
//! - All functions take `&JSRef<T>` arguments, to ensure that they will remain uncollected for //! - All functions take `JSRef<T>` arguments, to ensure that they will remain uncollected for
//! the duration of their usage. //! the duration of their usage.
//! - All types contain `JS<T>` fields and derive the `Encodable` trait, to ensure that they are //! - All types contain `JS<T>` fields and derive the `Encodable` trait, to ensure that they are
//! transitively marked as reachable by the GC if the enclosing value is reachable. //! transitively marked as reachable by the GC if the enclosing value is reachable.
@ -84,7 +84,7 @@ impl<T: Reflectable> Temporary<T> {
} }
/// Create a new `Temporary` value from a rooted value. /// Create a new `Temporary` value from a rooted value.
pub fn from_rooted<'a>(root: &JSRef<'a, T>) -> Temporary<T> { pub fn from_rooted<'a>(root: JSRef<'a, T>) -> Temporary<T> {
Temporary::new(JS::from_rooted(root)) Temporary::new(JS::from_rooted(root))
} }
@ -175,7 +175,7 @@ impl<T: Reflectable> JS<T> {
} }
impl<T: Assignable<U>, U: Reflectable> JS<U> { impl<T: Assignable<U>, U: Reflectable> JS<U> {
pub fn from_rooted(root: &T) -> JS<U> { pub fn from_rooted(root: T) -> JS<U> {
unsafe { unsafe {
root.get_js() root.get_js()
} }
@ -298,7 +298,7 @@ pub trait OptionalUnrootable<T> {
impl<'a, T: Reflectable> OptionalUnrootable<T> for Option<JSRef<'a, T>> { impl<'a, T: Reflectable> OptionalUnrootable<T> for Option<JSRef<'a, T>> {
fn unrooted(&self) -> Option<JS<T>> { fn unrooted(&self) -> Option<JS<T>> {
self.as_ref().map(|inner| JS::from_rooted(inner)) self.as_ref().map(|inner| JS::from_rooted(*inner))
} }
} }
@ -477,12 +477,12 @@ impl<'a, T> PartialEq for JSRef<'a, T> {
impl<'a,T> JSRef<'a,T> { impl<'a,T> JSRef<'a,T> {
//XXXjdm It would be lovely if this could be private. //XXXjdm It would be lovely if this could be private.
pub unsafe fn transmute<'b, To>(&'b self) -> &'b JSRef<'a, To> { pub unsafe fn transmute<To>(self) -> JSRef<'a, To> {
mem::transmute(self) mem::transmute(self)
} }
//XXXjdm It would be lovely if this could be private. // FIXME(zwarich): It would be nice to get rid of this entirely.
pub unsafe fn transmute_mut<'b, To>(&'b mut self) -> &'b mut JSRef<'a, To> { pub unsafe fn transmute_borrowed<'b, To>(&'b self) -> &'b JSRef<'a, To> {
mem::transmute(self) mem::transmute(self)
} }

View file

@ -24,7 +24,7 @@ pub struct BrowserContext {
} }
impl BrowserContext { impl BrowserContext {
pub fn new(document: &JSRef<Document>) -> BrowserContext { pub fn new(document: JSRef<Document>) -> BrowserContext {
let mut context = BrowserContext { let mut context = BrowserContext {
history: vec!(SessionHistoryEntry::new(document)), history: vec!(SessionHistoryEntry::new(document)),
active_index: 0, active_index: 0,
@ -74,7 +74,7 @@ pub struct SessionHistoryEntry {
} }
impl SessionHistoryEntry { impl SessionHistoryEntry {
fn new(document: &JSRef<Document>) -> SessionHistoryEntry { fn new(document: JSRef<Document>) -> SessionHistoryEntry {
SessionHistoryEntry { SessionHistoryEntry {
document: JS::from_rooted(document), document: JS::from_rooted(document),
children: vec!() children: vec!()

View file

@ -26,7 +26,7 @@ pub struct CanvasRenderingContext2D {
} }
impl CanvasRenderingContext2D { impl CanvasRenderingContext2D {
pub fn new_inherited(global: &GlobalRef, canvas: &JSRef<HTMLCanvasElement>, size: Size2D<i32>) -> CanvasRenderingContext2D { pub fn new_inherited(global: &GlobalRef, canvas: JSRef<HTMLCanvasElement>, size: Size2D<i32>) -> CanvasRenderingContext2D {
CanvasRenderingContext2D { CanvasRenderingContext2D {
reflector_: Reflector::new(), reflector_: Reflector::new(),
global: GlobalField::from_rooted(global), global: GlobalField::from_rooted(global),
@ -35,7 +35,7 @@ impl CanvasRenderingContext2D {
} }
} }
pub fn new(global: &GlobalRef, canvas: &JSRef<HTMLCanvasElement>, size: Size2D<i32>) -> Temporary<CanvasRenderingContext2D> { pub fn new(global: &GlobalRef, canvas: JSRef<HTMLCanvasElement>, size: Size2D<i32>) -> Temporary<CanvasRenderingContext2D> {
reflect_dom_object(box CanvasRenderingContext2D::new_inherited(global, canvas, size), reflect_dom_object(box CanvasRenderingContext2D::new_inherited(global, canvas, size),
global, CanvasRenderingContext2DBinding::Wrap) global, CanvasRenderingContext2DBinding::Wrap)
} }

View file

@ -36,7 +36,7 @@ impl CharacterDataDerived for EventTarget {
} }
impl CharacterData { impl CharacterData {
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: &JSRef<Document>) -> CharacterData { pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
CharacterData { CharacterData {
node: Node::new_inherited(id, document), node: Node::new_inherited(id, document),
data: Traceable::new(RefCell::new(data)), data: Traceable::new(RefCell::new(data)),
@ -95,7 +95,7 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
// http://dom.spec.whatwg.org/#dom-childnode-remove // http://dom.spec.whatwg.org/#dom-childnode-remove
fn Remove(&self) { fn Remove(&self) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.remove_self(); node.remove_self();
} }
} }

View file

@ -29,20 +29,20 @@ impl CommentDerived for EventTarget {
} }
impl Comment { impl Comment {
pub fn new_inherited(text: DOMString, document: &JSRef<Document>) -> Comment { pub fn new_inherited(text: DOMString, document: JSRef<Document>) -> Comment {
Comment { Comment {
characterdata: CharacterData::new_inherited(CommentNodeTypeId, text, document) characterdata: CharacterData::new_inherited(CommentNodeTypeId, text, document)
} }
} }
pub fn new(text: DOMString, document: &JSRef<Document>) -> Temporary<Comment> { pub fn new(text: DOMString, document: JSRef<Document>) -> Temporary<Comment> {
Node::reflect_node(box Comment::new_inherited(text, document), Node::reflect_node(box Comment::new_inherited(text, document),
document, CommentBinding::Wrap) document, CommentBinding::Wrap)
} }
pub fn Constructor(global: &GlobalRef, data: DOMString) -> Fallible<Temporary<Comment>> { pub fn Constructor(global: &GlobalRef, data: DOMString) -> Fallible<Temporary<Comment>> {
let document = global.as_window().Document().root(); let document = global.as_window().Document().root();
Ok(Comment::new(data, &*document)) Ok(Comment::new(data, *&*document))
} }
} }

View file

@ -47,7 +47,7 @@ impl CustomEvent {
pub fn new(global: &GlobalRef, type_: DOMString, bubbles: bool, cancelable: bool, detail: JSVal) -> Temporary<CustomEvent> { pub fn new(global: &GlobalRef, type_: DOMString, bubbles: bool, cancelable: bool, detail: JSVal) -> Temporary<CustomEvent> {
let ev = CustomEvent::new_uninitialized(global).root(); let ev = CustomEvent::new_uninitialized(global).root();
ev.deref().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail); ev.deref().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
Temporary::from_rooted(&*ev) Temporary::from_rooted(*ev)
} }
pub fn Constructor(global: &GlobalRef, pub fn Constructor(global: &GlobalRef,
type_: DOMString, type_: DOMString,
@ -68,7 +68,7 @@ impl<'a> CustomEventMethods for JSRef<'a, CustomEvent> {
cancelable: bool, cancelable: bool,
detail: JSVal) { detail: JSVal) {
self.detail.deref().set(Traceable::new(detail)); self.detail.deref().set(Traceable::new(detail));
let event: &JSRef<Event> = EventCast::from_ref(self); let event: JSRef<Event> = EventCast::from_ref(*self);
event.InitEvent(type_, can_bubble, cancelable); event.InitEvent(type_, can_bubble, cancelable);
} }
} }

View file

@ -115,10 +115,10 @@ impl DedicatedWorkerGlobalScope {
} }
global.delayed_release_worker(); global.delayed_release_worker();
let scope: &JSRef<WorkerGlobalScope> = let scope: JSRef<WorkerGlobalScope> =
WorkerGlobalScopeCast::from_ref(&*global); WorkerGlobalScopeCast::from_ref(*global);
let target: &JSRef<EventTarget> = let target: JSRef<EventTarget> =
EventTargetCast::from_ref(&*global); EventTargetCast::from_ref(*global);
loop { loop {
match global.receiver.recv_opt() { match global.receiver.recv_opt() {
Ok(DOMMessage(data, nbytes)) => { Ok(DOMMessage(data, nbytes)) => {
@ -130,7 +130,7 @@ impl DedicatedWorkerGlobalScope {
ptr::null(), ptr::mut_null()) != 0); ptr::null(), ptr::mut_null()) != 0);
} }
MessageEvent::dispatch_jsval(target, &Worker(*scope), message); MessageEvent::dispatch_jsval(target, &Worker(scope), message);
global.delayed_release_worker(); global.delayed_release_worker();
}, },
Ok(XHRProgressMsg(addr, progress)) => { Ok(XHRProgressMsg(addr, progress)) => {
@ -164,12 +164,12 @@ impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalSc
} }
fn GetOnmessage(&self) -> Option<EventHandlerNonNull> { fn GetOnmessage(&self) -> Option<EventHandlerNonNull> {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.get_event_handler_common("message") eventtarget.get_event_handler_common("message")
} }
fn SetOnmessage(&self, listener: Option<EventHandlerNonNull>) { fn SetOnmessage(&self, listener: Option<EventHandlerNonNull>) {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.set_event_handler_common("message", listener) eventtarget.set_event_handler_common("message", listener)
} }
} }

View file

@ -101,49 +101,49 @@ impl DocumentDerived for EventTarget {
struct ImagesFilter; struct ImagesFilter;
impl CollectionFilter for ImagesFilter { impl CollectionFilter for ImagesFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
elem.is_htmlimageelement() elem.is_htmlimageelement()
} }
} }
struct EmbedsFilter; struct EmbedsFilter;
impl CollectionFilter for EmbedsFilter { impl CollectionFilter for EmbedsFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
elem.is_htmlembedelement() elem.is_htmlembedelement()
} }
} }
struct LinksFilter; struct LinksFilter;
impl CollectionFilter for LinksFilter { impl CollectionFilter for LinksFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
(elem.is_htmlanchorelement() || elem.is_htmlareaelement()) && elem.has_attribute("href") (elem.is_htmlanchorelement() || elem.is_htmlareaelement()) && elem.has_attribute("href")
} }
} }
struct FormsFilter; struct FormsFilter;
impl CollectionFilter for FormsFilter { impl CollectionFilter for FormsFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
elem.is_htmlformelement() elem.is_htmlformelement()
} }
} }
struct ScriptsFilter; struct ScriptsFilter;
impl CollectionFilter for ScriptsFilter { impl CollectionFilter for ScriptsFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
elem.is_htmlscriptelement() elem.is_htmlscriptelement()
} }
} }
struct AnchorsFilter; struct AnchorsFilter;
impl CollectionFilter for AnchorsFilter { impl CollectionFilter for AnchorsFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
elem.is_htmlanchorelement() && elem.has_attribute("href") elem.is_htmlanchorelement() && elem.has_attribute("href")
} }
} }
struct AppletsFilter; struct AppletsFilter;
impl CollectionFilter for AppletsFilter { impl CollectionFilter for AppletsFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
elem.is_htmlappletelement() elem.is_htmlappletelement()
} }
} }
@ -157,8 +157,8 @@ pub trait DocumentHelpers {
fn content_changed(&self); fn content_changed(&self);
fn damage_and_reflow(&self, damage: DocumentDamageLevel); fn damage_and_reflow(&self, damage: DocumentDamageLevel);
fn wait_until_safe_to_modify_dom(&self); fn wait_until_safe_to_modify_dom(&self);
fn unregister_named_element(&self, to_unregister: &JSRef<Element>, id: DOMString); fn unregister_named_element(&self, to_unregister: JSRef<Element>, id: DOMString);
fn register_named_element(&self, element: &JSRef<Element>, id: DOMString); fn register_named_element(&self, element: JSRef<Element>, id: DOMString);
fn load_anchor_href(&self, href: DOMString); fn load_anchor_href(&self, href: DOMString);
} }
@ -198,7 +198,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
/// Remove any existing association between the provided id and any elements in this document. /// Remove any existing association between the provided id and any elements in this document.
fn unregister_named_element(&self, fn unregister_named_element(&self,
to_unregister: &JSRef<Element>, to_unregister: JSRef<Element>,
id: DOMString) { id: DOMString) {
let mut idmap = self.idmap.deref().borrow_mut(); let mut idmap = self.idmap.deref().borrow_mut();
let is_empty = match idmap.find_mut(&id) { let is_empty = match idmap.find_mut(&id) {
@ -206,7 +206,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
Some(elements) => { Some(elements) => {
let position = elements.iter() let position = elements.iter()
.map(|elem| elem.root()) .map(|elem| elem.root())
.position(|element| &*element == to_unregister) .position(|element| *element == to_unregister)
.expect("This element should be in registered."); .expect("This element should be in registered.");
elements.remove(position); elements.remove(position);
elements.is_empty() elements.is_empty()
@ -219,10 +219,10 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
/// Associate an element present in this document with the provided id. /// Associate an element present in this document with the provided id.
fn register_named_element(&self, fn register_named_element(&self,
element: &JSRef<Element>, element: JSRef<Element>,
id: DOMString) { id: DOMString) {
assert!({ assert!({
let node: &JSRef<Node> = NodeCast::from_ref(element); let node: JSRef<Node> = NodeCast::from_ref(element);
node.is_in_doc() node.is_in_doc()
}); });
assert!(!id.is_empty()); assert!(!id.is_empty());
@ -234,30 +234,30 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root(); let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
match idmap.find_mut(&id) { match idmap.find_mut(&id) {
Some(elements) => { Some(elements) => {
let new_node: &JSRef<Node> = NodeCast::from_ref(element); let new_node: JSRef<Node> = NodeCast::from_ref(element);
let mut head : uint = 0u; let mut head : uint = 0u;
let root: &JSRef<Node> = NodeCast::from_ref(&*root); let root: JSRef<Node> = NodeCast::from_ref(*root);
for node in root.traverse_preorder() { for node in root.traverse_preorder() {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&node); let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
match elem { match elem {
Some(elem) => { Some(elem) => {
if &*(*elements)[head].root() == elem { if *(*elements)[head].root() == elem {
head = head + 1; head = head + 1;
} }
if new_node == &node || head == elements.len() { if new_node == node || head == elements.len() {
break; break;
} }
} }
None => {} None => {}
} }
} }
elements.insert_unrooted(head, element); elements.insert_unrooted(head, &element);
return; return;
}, },
None => (), None => (),
} }
let mut elements = vec!(); let mut elements = vec!();
elements.push_unrooted(element); elements.push_unrooted(&element);
idmap.insert(id, elements); idmap.insert(id, elements);
} }
@ -268,7 +268,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
} }
impl Document { impl Document {
pub fn new_inherited(window: &JSRef<Window>, pub fn new_inherited(window: JSRef<Window>,
url: Option<Url>, url: Option<Url>,
is_html_document: IsHTMLDocument, is_html_document: IsHTMLDocument,
content_type: Option<DOMString>) -> Document { content_type: Option<DOMString>) -> Document {
@ -311,14 +311,14 @@ impl Document {
Ok(Document::new(global.as_window(), None, NonHTMLDocument, None)) Ok(Document::new(global.as_window(), None, NonHTMLDocument, None))
} }
pub fn new(window: &JSRef<Window>, url: Option<Url>, doctype: IsHTMLDocument, content_type: Option<DOMString>) -> Temporary<Document> { pub fn new(window: JSRef<Window>, url: Option<Url>, doctype: IsHTMLDocument, content_type: Option<DOMString>) -> Temporary<Document> {
let document = reflect_dom_object(box Document::new_inherited(window, url, doctype, content_type), let document = reflect_dom_object(box Document::new_inherited(window, url, doctype, content_type),
&Window(*window), &Window(window),
DocumentBinding::Wrap).root(); DocumentBinding::Wrap).root();
let node: &JSRef<Node> = NodeCast::from_ref(&*document); let node: JSRef<Node> = NodeCast::from_ref(*document);
node.set_owner_doc(&*document); node.set_owner_doc(*&*document);
Temporary::from_rooted(&*document) Temporary::from_rooted(*&*document)
} }
} }
@ -329,27 +329,27 @@ impl Reflectable for Document {
} }
trait PrivateDocumentHelpers { trait PrivateDocumentHelpers {
fn createNodeList(&self, callback: |node: &JSRef<Node>| -> bool) -> Temporary<NodeList>; fn createNodeList(&self, callback: |node: JSRef<Node>| -> bool) -> Temporary<NodeList>;
fn get_html_element(&self) -> Option<Temporary<HTMLHtmlElement>>; fn get_html_element(&self) -> Option<Temporary<HTMLHtmlElement>>;
} }
impl<'a> PrivateDocumentHelpers for JSRef<'a, Document> { impl<'a> PrivateDocumentHelpers for JSRef<'a, Document> {
fn createNodeList(&self, callback: |node: &JSRef<Node>| -> bool) -> Temporary<NodeList> { fn createNodeList(&self, callback: |node: JSRef<Node>| -> bool) -> Temporary<NodeList> {
let window = self.window.root(); let window = self.window.root();
match self.GetDocumentElement().root() { match self.GetDocumentElement().root() {
None => { None => {
NodeList::new_simple_list(&*window, vec!()) NodeList::new_simple_list(*window, vec!())
}, },
Some(root) => { Some(root) => {
let mut nodes = vec!(); let mut nodes = vec!();
let root: &JSRef<Node> = NodeCast::from_ref(&*root); let root: JSRef<Node> = NodeCast::from_ref(*root);
for child in root.traverse_preorder() { for child in root.traverse_preorder() {
if callback(&child) { if callback(child) {
nodes.push(child); nodes.push(child);
} }
} }
NodeList::new_simple_list(&*window, nodes) NodeList::new_simple_list(*window, nodes)
} }
} }
@ -357,10 +357,10 @@ impl<'a> PrivateDocumentHelpers for JSRef<'a, Document> {
fn get_html_element(&self) -> Option<Temporary<HTMLHtmlElement>> { fn get_html_element(&self) -> Option<Temporary<HTMLHtmlElement>> {
self.GetDocumentElement().root().filtered(|root| { self.GetDocumentElement().root().filtered(|root| {
let root: &JSRef<Node> = NodeCast::from_ref(&**root); let root: JSRef<Node> = NodeCast::from_ref(**root);
root.type_id() == ElementNodeTypeId(HTMLHtmlElementTypeId) root.type_id() == ElementNodeTypeId(HTMLHtmlElementTypeId)
}).map(|elem| { }).map(|elem| {
Temporary::from_rooted(HTMLHtmlElementCast::to_ref(&*elem).unwrap()) Temporary::from_rooted(HTMLHtmlElementCast::to_ref(*elem).unwrap())
}) })
} }
} }
@ -369,7 +369,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-implementation // http://dom.spec.whatwg.org/#dom-document-implementation
fn Implementation(&self) -> Temporary<DOMImplementation> { fn Implementation(&self) -> Temporary<DOMImplementation> {
if self.implementation.get().is_none() { if self.implementation.get().is_none() {
self.implementation.assign(Some(DOMImplementation::new(self))); self.implementation.assign(Some(DOMImplementation::new(*self)));
} }
Temporary::new(self.implementation.get().get_ref().clone()) Temporary::new(self.implementation.get().get_ref().clone())
} }
@ -404,38 +404,38 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-doctype // http://dom.spec.whatwg.org/#dom-document-doctype
fn GetDoctype(&self) -> Option<Temporary<DocumentType>> { fn GetDoctype(&self) -> Option<Temporary<DocumentType>> {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.children().find(|child| { node.children().find(|child| {
child.is_doctype() child.is_doctype()
}).map(|node| { }).map(|node| {
let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(&node).unwrap(); let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
Temporary::from_rooted(doctype) Temporary::from_rooted(doctype)
}) })
} }
// http://dom.spec.whatwg.org/#dom-document-documentelement // http://dom.spec.whatwg.org/#dom-document-documentelement
fn GetDocumentElement(&self) -> Option<Temporary<Element>> { fn GetDocumentElement(&self) -> Option<Temporary<Element>> {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.child_elements().next().map(|elem| Temporary::from_rooted(&elem)) node.child_elements().next().map(|elem| Temporary::from_rooted(elem))
} }
// http://dom.spec.whatwg.org/#dom-document-getelementsbytagname // http://dom.spec.whatwg.org/#dom-document-getelementsbytagname
fn GetElementsByTagName(&self, tag_name: DOMString) -> Temporary<HTMLCollection> { fn GetElementsByTagName(&self, tag_name: DOMString) -> Temporary<HTMLCollection> {
let window = self.window.root(); let window = self.window.root();
HTMLCollection::by_tag_name(&*window, NodeCast::from_ref(self), tag_name) HTMLCollection::by_tag_name(*window, NodeCast::from_ref(*self), tag_name)
} }
// http://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens // http://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens
fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>, tag_name: DOMString) -> Temporary<HTMLCollection> { fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>, tag_name: DOMString) -> Temporary<HTMLCollection> {
let window = self.window.root(); let window = self.window.root();
HTMLCollection::by_tag_name_ns(&*window, NodeCast::from_ref(self), tag_name, maybe_ns) HTMLCollection::by_tag_name_ns(*window, NodeCast::from_ref(*self), tag_name, maybe_ns)
} }
// http://dom.spec.whatwg.org/#dom-document-getelementsbyclassname // http://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection> { fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection> {
let window = self.window.root(); let window = self.window.root();
HTMLCollection::by_class_name(&*window, NodeCast::from_ref(self), classes) HTMLCollection::by_class_name(*window, NodeCast::from_ref(*self), classes)
} }
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid // http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
@ -453,7 +453,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
return Err(InvalidCharacter); return Err(InvalidCharacter);
} }
let local_name = local_name.as_slice().to_ascii_lower(); let local_name = local_name.as_slice().to_ascii_lower();
Ok(build_element_from_tag(local_name, namespace::HTML, self)) Ok(build_element_from_tag(local_name, namespace::HTML, *self))
} }
// http://dom.spec.whatwg.org/#dom-document-createelementns // http://dom.spec.whatwg.org/#dom-document-createelementns
@ -497,27 +497,27 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
} }
if ns == namespace::HTML { if ns == namespace::HTML {
Ok(build_element_from_tag(local_name_from_qname.to_string(), ns, self)) Ok(build_element_from_tag(local_name_from_qname.to_string(), ns, *self))
} else { } else {
Ok(Element::new(local_name_from_qname.to_string(), ns, Ok(Element::new(local_name_from_qname.to_string(), ns,
prefix_from_qname.map(|s| s.to_string()), self)) prefix_from_qname.map(|s| s.to_string()), *self))
} }
} }
// http://dom.spec.whatwg.org/#dom-document-createdocumentfragment // http://dom.spec.whatwg.org/#dom-document-createdocumentfragment
fn CreateDocumentFragment(&self) -> Temporary<DocumentFragment> { fn CreateDocumentFragment(&self) -> Temporary<DocumentFragment> {
DocumentFragment::new(self) DocumentFragment::new(*self)
} }
// http://dom.spec.whatwg.org/#dom-document-createtextnode // http://dom.spec.whatwg.org/#dom-document-createtextnode
fn CreateTextNode(&self, data: DOMString) fn CreateTextNode(&self, data: DOMString)
-> Temporary<Text> { -> Temporary<Text> {
Text::new(data, self) Text::new(data, *self)
} }
// http://dom.spec.whatwg.org/#dom-document-createcomment // http://dom.spec.whatwg.org/#dom-document-createcomment
fn CreateComment(&self, data: DOMString) -> Temporary<Comment> { fn CreateComment(&self, data: DOMString) -> Temporary<Comment> {
Comment::new(data, self) Comment::new(data, *self)
} }
// http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction // http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
@ -534,11 +534,11 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
} }
// Step 3. // Step 3.
Ok(ProcessingInstruction::new(target, data, self)) Ok(ProcessingInstruction::new(target, data, *self))
} }
// http://dom.spec.whatwg.org/#dom-document-importnode // http://dom.spec.whatwg.org/#dom-document-importnode
fn ImportNode(&self, node: &JSRef<Node>, deep: bool) -> Fallible<Temporary<Node>> { fn ImportNode(&self, node: JSRef<Node>, deep: bool) -> Fallible<Temporary<Node>> {
// Step 1. // Step 1.
if node.is_document() { if node.is_document() {
return Err(NotSupported); return Err(NotSupported);
@ -550,18 +550,18 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
false => DoNotCloneChildren false => DoNotCloneChildren
}; };
Ok(Node::clone(node, Some(self), clone_children)) Ok(Node::clone(node, Some(*self), clone_children))
} }
// http://dom.spec.whatwg.org/#dom-document-adoptnode // http://dom.spec.whatwg.org/#dom-document-adoptnode
fn AdoptNode(&self, node: &JSRef<Node>) -> Fallible<Temporary<Node>> { fn AdoptNode(&self, node: JSRef<Node>) -> Fallible<Temporary<Node>> {
// Step 1. // Step 1.
if node.is_document() { if node.is_document() {
return Err(NotSupported); return Err(NotSupported);
} }
// Step 2. // Step 2.
Node::adopt(node, self); Node::adopt(node, *self);
// Step 3. // Step 3.
Ok(Temporary::from_rooted(node)) Ok(Temporary::from_rooted(node))
@ -572,8 +572,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
let window = self.window.root(); let window = self.window.root();
match interface.as_slice().to_ascii_lower().as_slice() { match interface.as_slice().to_ascii_lower().as_slice() {
"uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new_uninitialized(&*window))), "uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new_uninitialized(*window))),
"mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new_uninitialized(&*window))), "mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new_uninitialized(*window))),
"customevent" => Ok(EventCast::from_temporary(CustomEvent::new_uninitialized(&Window(*window)))), "customevent" => Ok(EventCast::from_temporary(CustomEvent::new_uninitialized(&Window(*window)))),
"htmlevents" | "events" | "event" => Ok(Event::new_uninitialized(&Window(*window))), "htmlevents" | "events" | "event" => Ok(Event::new_uninitialized(&Window(*window))),
_ => Err(NotSupported) _ => Err(NotSupported)
@ -590,26 +590,26 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-createrange // http://dom.spec.whatwg.org/#dom-document-createrange
fn CreateRange(&self) -> Temporary<Range> { fn CreateRange(&self) -> Temporary<Range> {
Range::new(self) Range::new(*self)
} }
// http://dom.spec.whatwg.org/#dom-document-createtreewalker // http://dom.spec.whatwg.org/#dom-document-createtreewalker
fn CreateTreeWalker(&self, root: &JSRef<Node>, whatToShow: u32, filter: Option<NodeFilter>) fn CreateTreeWalker(&self, root: JSRef<Node>, whatToShow: u32, filter: Option<NodeFilter>)
-> Temporary<TreeWalker> { -> Temporary<TreeWalker> {
TreeWalker::new(self, root, whatToShow, filter) TreeWalker::new(*self, root, whatToShow, filter)
} }
// http://www.whatwg.org/specs/web-apps/current-work/#document.title // http://www.whatwg.org/specs/web-apps/current-work/#document.title
fn Title(&self) -> DOMString { fn Title(&self) -> DOMString {
let mut title = String::new(); let mut title = String::new();
self.GetDocumentElement().root().map(|root| { self.GetDocumentElement().root().map(|root| {
let root: &JSRef<Node> = NodeCast::from_ref(&*root); let root: JSRef<Node> = NodeCast::from_ref(*root);
root.traverse_preorder() root.traverse_preorder()
.find(|node| node.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId)) .find(|node| node.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId))
.map(|title_elem| { .map(|title_elem| {
for child in title_elem.children() { for child in title_elem.children() {
if child.is_text() { if child.is_text() {
let text: &JSRef<Text> = TextCast::to_ref(&child).unwrap(); let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
title.push_str(text.deref().characterdata.data.deref().borrow().as_slice()); title.push_str(text.deref().characterdata.data.deref().borrow().as_slice());
} }
} }
@ -622,7 +622,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://www.whatwg.org/specs/web-apps/current-work/#document.title // http://www.whatwg.org/specs/web-apps/current-work/#document.title
fn SetTitle(&self, title: DOMString) -> ErrorResult { fn SetTitle(&self, title: DOMString) -> ErrorResult {
self.GetDocumentElement().root().map(|root| { self.GetDocumentElement().root().map(|root| {
let root: &JSRef<Node> = NodeCast::from_ref(&*root); let root: JSRef<Node> = NodeCast::from_ref(*root);
let head_node = root.traverse_preorder().find(|child| { let head_node = root.traverse_preorder().find(|child| {
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
}); });
@ -634,20 +634,20 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
match title_node { match title_node {
Some(ref title_node) => { Some(ref title_node) => {
for title_child in title_node.children() { for title_child in title_node.children() {
assert!(title_node.RemoveChild(&title_child).is_ok()); assert!(title_node.RemoveChild(title_child).is_ok());
} }
if !title.is_empty() { if !title.is_empty() {
let new_text = self.CreateTextNode(title.clone()).root(); let new_text = self.CreateTextNode(title.clone()).root();
assert!(title_node.AppendChild(NodeCast::from_ref(&*new_text)).is_ok()); assert!(title_node.AppendChild(NodeCast::from_ref(*new_text)).is_ok());
} }
}, },
None => { None => {
let new_title = HTMLTitleElement::new("title".to_string(), self).root(); let new_title = HTMLTitleElement::new("title".to_string(), *self).root();
let new_title: &JSRef<Node> = NodeCast::from_ref(&*new_title); let new_title: JSRef<Node> = NodeCast::from_ref(*new_title);
if !title.is_empty() { if !title.is_empty() {
let new_text = self.CreateTextNode(title.clone()).root(); let new_text = self.CreateTextNode(title.clone()).root();
assert!(new_title.AppendChild(NodeCast::from_ref(&*new_text)).is_ok()); assert!(new_title.AppendChild(NodeCast::from_ref(*new_text)).is_ok());
} }
assert!(head.AppendChild(new_title).is_ok()); assert!(head.AppendChild(new_title).is_ok());
}, },
@ -661,11 +661,11 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn GetHead(&self) -> Option<Temporary<HTMLHeadElement>> { fn GetHead(&self) -> Option<Temporary<HTMLHeadElement>> {
self.get_html_element().and_then(|root| { self.get_html_element().and_then(|root| {
let root = root.root(); let root = root.root();
let node: &JSRef<Node> = NodeCast::from_ref(&*root); let node: JSRef<Node> = NodeCast::from_ref(*root);
node.children().find(|child| { node.children().find(|child| {
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
}).map(|node| { }).map(|node| {
Temporary::from_rooted(HTMLHeadElementCast::to_ref(&node).unwrap()) Temporary::from_rooted(HTMLHeadElementCast::to_ref(node).unwrap())
}) })
}) })
} }
@ -674,7 +674,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn GetBody(&self) -> Option<Temporary<HTMLElement>> { fn GetBody(&self) -> Option<Temporary<HTMLElement>> {
self.get_html_element().and_then(|root| { self.get_html_element().and_then(|root| {
let root = root.root(); let root = root.root();
let node: &JSRef<Node> = NodeCast::from_ref(&*root); let node: JSRef<Node> = NodeCast::from_ref(*root);
node.children().find(|child| { node.children().find(|child| {
match child.type_id() { match child.type_id() {
ElementNodeTypeId(HTMLBodyElementTypeId) | ElementNodeTypeId(HTMLBodyElementTypeId) |
@ -682,7 +682,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
_ => false _ => false
} }
}).map(|node| { }).map(|node| {
Temporary::from_rooted(HTMLElementCast::to_ref(&node).unwrap()) Temporary::from_rooted(HTMLElementCast::to_ref(node).unwrap())
}) })
}) })
} }
@ -692,7 +692,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// Step 1. // Step 1.
match new_body { match new_body {
Some(ref htmlelem) => { Some(ref htmlelem) => {
let node: &JSRef<Node> = NodeCast::from_ref(htmlelem); let node: JSRef<Node> = NodeCast::from_ref(*htmlelem);
match node.type_id() { match node.type_id() {
ElementNodeTypeId(HTMLBodyElementTypeId) | ElementNodeTypeId(HTMLFrameSetElementTypeId) => {} ElementNodeTypeId(HTMLBodyElementTypeId) | ElementNodeTypeId(HTMLFrameSetElementTypeId) => {}
_ => return Err(HierarchyRequest) _ => return Err(HierarchyRequest)
@ -714,12 +714,12 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
None => return Err(HierarchyRequest), None => return Err(HierarchyRequest),
Some(ref root) => { Some(ref root) => {
let new_body_unwrapped = new_body.unwrap(); let new_body_unwrapped = new_body.unwrap();
let new_body: &JSRef<Node> = NodeCast::from_ref(&new_body_unwrapped); let new_body: JSRef<Node> = NodeCast::from_ref(new_body_unwrapped);
let root: &JSRef<Node> = NodeCast::from_ref(&**root); let root: JSRef<Node> = NodeCast::from_ref(**root);
match old_body { match old_body {
Some(ref child) => { Some(ref child) => {
let child: &JSRef<Node> = NodeCast::from_ref(&**child); let child: JSRef<Node> = NodeCast::from_ref(**child);
assert!(root.ReplaceChild(new_body, child).is_ok()) assert!(root.ReplaceChild(new_body, child).is_ok())
} }
@ -737,7 +737,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
return false; return false;
} }
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap(); let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
element.get_attribute(Null, "name").root().map_or(false, |attr| { element.get_attribute(Null, "name").root().map_or(false, |attr| {
attr.value().as_slice() == name.as_slice() attr.value().as_slice() == name.as_slice()
}) })
@ -747,9 +747,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Images(&self) -> Temporary<HTMLCollection> { fn Images(&self) -> Temporary<HTMLCollection> {
if self.images.get().is_none() { if self.images.get().is_none() {
let window = self.window.root(); let window = self.window.root();
let root = NodeCast::from_ref(self); let root = NodeCast::from_ref(*self);
let filter = box ImagesFilter; let filter = box ImagesFilter;
self.images.assign(Some(HTMLCollection::create(&*window, root, filter))); self.images.assign(Some(HTMLCollection::create(*window, root, filter)));
} }
Temporary::new(self.images.get().get_ref().clone()) Temporary::new(self.images.get().get_ref().clone())
} }
@ -757,9 +757,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Embeds(&self) -> Temporary<HTMLCollection> { fn Embeds(&self) -> Temporary<HTMLCollection> {
if self.embeds.get().is_none() { if self.embeds.get().is_none() {
let window = self.window.root(); let window = self.window.root();
let root = NodeCast::from_ref(self); let root = NodeCast::from_ref(*self);
let filter = box EmbedsFilter; let filter = box EmbedsFilter;
self.embeds.assign(Some(HTMLCollection::create(&*window, root, filter))); self.embeds.assign(Some(HTMLCollection::create(*window, root, filter)));
} }
Temporary::new(self.embeds.get().get_ref().clone()) Temporary::new(self.embeds.get().get_ref().clone())
} }
@ -771,9 +771,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Links(&self) -> Temporary<HTMLCollection> { fn Links(&self) -> Temporary<HTMLCollection> {
if self.links.get().is_none() { if self.links.get().is_none() {
let window = self.window.root(); let window = self.window.root();
let root = NodeCast::from_ref(self); let root = NodeCast::from_ref(*self);
let filter = box LinksFilter; let filter = box LinksFilter;
self.links.assign(Some(HTMLCollection::create(&*window, root, filter))); self.links.assign(Some(HTMLCollection::create(*window, root, filter)));
} }
Temporary::new(self.links.get().get_ref().clone()) Temporary::new(self.links.get().get_ref().clone())
} }
@ -781,9 +781,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Forms(&self) -> Temporary<HTMLCollection> { fn Forms(&self) -> Temporary<HTMLCollection> {
if self.forms.get().is_none() { if self.forms.get().is_none() {
let window = self.window.root(); let window = self.window.root();
let root = NodeCast::from_ref(self); let root = NodeCast::from_ref(*self);
let filter = box FormsFilter; let filter = box FormsFilter;
self.forms.assign(Some(HTMLCollection::create(&*window, root, filter))); self.forms.assign(Some(HTMLCollection::create(*window, root, filter)));
} }
Temporary::new(self.forms.get().get_ref().clone()) Temporary::new(self.forms.get().get_ref().clone())
} }
@ -791,9 +791,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Scripts(&self) -> Temporary<HTMLCollection> { fn Scripts(&self) -> Temporary<HTMLCollection> {
if self.scripts.get().is_none() { if self.scripts.get().is_none() {
let window = self.window.root(); let window = self.window.root();
let root = NodeCast::from_ref(self); let root = NodeCast::from_ref(*self);
let filter = box ScriptsFilter; let filter = box ScriptsFilter;
self.scripts.assign(Some(HTMLCollection::create(&*window, root, filter))); self.scripts.assign(Some(HTMLCollection::create(*window, root, filter)));
} }
Temporary::new(self.scripts.get().get_ref().clone()) Temporary::new(self.scripts.get().get_ref().clone())
} }
@ -801,9 +801,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Anchors(&self) -> Temporary<HTMLCollection> { fn Anchors(&self) -> Temporary<HTMLCollection> {
if self.anchors.get().is_none() { if self.anchors.get().is_none() {
let window = self.window.root(); let window = self.window.root();
let root = NodeCast::from_ref(self); let root = NodeCast::from_ref(*self);
let filter = box AnchorsFilter; let filter = box AnchorsFilter;
self.anchors.assign(Some(HTMLCollection::create(&*window, root, filter))); self.anchors.assign(Some(HTMLCollection::create(*window, root, filter)));
} }
Temporary::new(self.anchors.get().get_ref().clone()) Temporary::new(self.anchors.get().get_ref().clone())
} }
@ -812,9 +812,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// FIXME: This should be return OBJECT elements containing applets. // FIXME: This should be return OBJECT elements containing applets.
if self.applets.get().is_none() { if self.applets.get().is_none() {
let window = self.window.root(); let window = self.window.root();
let root = NodeCast::from_ref(self); let root = NodeCast::from_ref(*self);
let filter = box AppletsFilter; let filter = box AppletsFilter;
self.applets.assign(Some(HTMLCollection::create(&*window, root, filter))); self.applets.assign(Some(HTMLCollection::create(*window, root, filter)));
} }
Temporary::new(self.applets.get().get_ref().clone()) Temporary::new(self.applets.get().get_ref().clone())
} }
@ -827,38 +827,38 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-parentnode-children // http://dom.spec.whatwg.org/#dom-parentnode-children
fn Children(&self) -> Temporary<HTMLCollection> { fn Children(&self) -> Temporary<HTMLCollection> {
let window = self.window.root(); let window = self.window.root();
HTMLCollection::children(&*window, NodeCast::from_ref(self)) HTMLCollection::children(*window, NodeCast::from_ref(*self))
} }
// http://dom.spec.whatwg.org/#dom-parentnode-queryselector // http://dom.spec.whatwg.org/#dom-parentnode-queryselector
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> { fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> {
let root: &JSRef<Node> = NodeCast::from_ref(self); let root: JSRef<Node> = NodeCast::from_ref(*self);
root.query_selector(selectors) root.query_selector(selectors)
} }
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall // http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>> { fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>> {
let root: &JSRef<Node> = NodeCast::from_ref(self); let root: JSRef<Node> = NodeCast::from_ref(*self);
root.query_selector_all(selectors) root.query_selector_all(selectors)
} }
fn GetOnclick(&self) -> Option<EventHandlerNonNull> { fn GetOnclick(&self) -> Option<EventHandlerNonNull> {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.get_event_handler_common("click") eventtarget.get_event_handler_common("click")
} }
fn SetOnclick(&self, listener: Option<EventHandlerNonNull>) { fn SetOnclick(&self, listener: Option<EventHandlerNonNull>) {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.set_event_handler_common("click", listener) eventtarget.set_event_handler_common("click", listener)
} }
fn GetOnload(&self) -> Option<EventHandlerNonNull> { fn GetOnload(&self) -> Option<EventHandlerNonNull> {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.get_event_handler_common("load") eventtarget.get_event_handler_common("load")
} }
fn SetOnload(&self, listener: Option<EventHandlerNonNull>) { fn SetOnload(&self, listener: Option<EventHandlerNonNull>) {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.set_event_handler_common("load", listener) eventtarget.set_event_handler_common("load", listener)
} }
} }

View file

@ -32,13 +32,13 @@ impl DocumentFragmentDerived for EventTarget {
impl DocumentFragment { impl DocumentFragment {
/// Creates a new DocumentFragment. /// Creates a new DocumentFragment.
pub fn new_inherited(document: &JSRef<Document>) -> DocumentFragment { pub fn new_inherited(document: JSRef<Document>) -> DocumentFragment {
DocumentFragment { DocumentFragment {
node: Node::new_inherited(DocumentFragmentNodeTypeId, document), node: Node::new_inherited(DocumentFragmentNodeTypeId, document),
} }
} }
pub fn new(document: &JSRef<Document>) -> Temporary<DocumentFragment> { pub fn new(document: JSRef<Document>) -> Temporary<DocumentFragment> {
Node::reflect_node(box DocumentFragment::new_inherited(document), Node::reflect_node(box DocumentFragment::new_inherited(document),
document, DocumentFragmentBinding::Wrap) document, DocumentFragmentBinding::Wrap)
} }
@ -47,26 +47,26 @@ impl DocumentFragment {
let document = global.as_window().Document(); let document = global.as_window().Document();
let document = document.root(); let document = document.root();
Ok(DocumentFragment::new(&document.root_ref())) Ok(DocumentFragment::new(*document))
} }
} }
impl<'a> DocumentFragmentMethods for JSRef<'a, DocumentFragment> { impl<'a> DocumentFragmentMethods for JSRef<'a, DocumentFragment> {
// http://dom.spec.whatwg.org/#dom-parentnode-children // http://dom.spec.whatwg.org/#dom-parentnode-children
fn Children(&self) -> Temporary<HTMLCollection> { fn Children(&self) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
HTMLCollection::children(&window.root_ref(), NodeCast::from_ref(self)) HTMLCollection::children(*window, NodeCast::from_ref(*self))
} }
// http://dom.spec.whatwg.org/#dom-parentnode-queryselector // http://dom.spec.whatwg.org/#dom-parentnode-queryselector
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> { fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> {
let root: &JSRef<Node> = NodeCast::from_ref(self); let root: JSRef<Node> = NodeCast::from_ref(*self);
root.query_selector(selectors) root.query_selector(selectors)
} }
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall // http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>> { fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>> {
let root: &JSRef<Node> = NodeCast::from_ref(self); let root: JSRef<Node> = NodeCast::from_ref(*self);
root.query_selector_all(selectors) root.query_selector_all(selectors)
} }

View file

@ -32,7 +32,7 @@ impl DocumentType {
pub fn new_inherited(name: DOMString, pub fn new_inherited(name: DOMString,
public_id: Option<DOMString>, public_id: Option<DOMString>,
system_id: Option<DOMString>, system_id: Option<DOMString>,
document: &JSRef<Document>) document: JSRef<Document>)
-> DocumentType { -> DocumentType {
DocumentType { DocumentType {
node: Node::new_inherited(DoctypeNodeTypeId, document), node: Node::new_inherited(DoctypeNodeTypeId, document),
@ -45,7 +45,7 @@ impl DocumentType {
pub fn new(name: DOMString, pub fn new(name: DOMString,
public_id: Option<DOMString>, public_id: Option<DOMString>,
system_id: Option<DOMString>, system_id: Option<DOMString>,
document: &JSRef<Document>) document: JSRef<Document>)
-> Temporary<DocumentType> { -> Temporary<DocumentType> {
let documenttype = DocumentType::new_inherited(name, let documenttype = DocumentType::new_inherited(name,
public_id, public_id,
@ -70,7 +70,7 @@ impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
// http://dom.spec.whatwg.org/#dom-childnode-remove // http://dom.spec.whatwg.org/#dom-childnode-remove
fn Remove(&self) { fn Remove(&self) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.remove_self(); node.remove_self();
} }
} }

View file

@ -30,14 +30,14 @@ pub struct DOMImplementation {
} }
impl DOMImplementation { impl DOMImplementation {
pub fn new_inherited(document: &JSRef<Document>) -> DOMImplementation { pub fn new_inherited(document: JSRef<Document>) -> DOMImplementation {
DOMImplementation { DOMImplementation {
document: JS::from_rooted(document), document: JS::from_rooted(document),
reflector_: Reflector::new(), reflector_: Reflector::new(),
} }
} }
pub fn new(document: &JSRef<Document>) -> Temporary<DOMImplementation> { pub fn new(document: JSRef<Document>) -> Temporary<DOMImplementation> {
let window = document.window.root(); let window = document.window.root();
reflect_dom_object(box DOMImplementation::new_inherited(document), reflect_dom_object(box DOMImplementation::new_inherited(document),
&Window(*window), &Window(*window),
@ -63,7 +63,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
// Step 3. // Step 3.
QName => { QName => {
let document = self.document.root(); let document = self.document.root();
Ok(DocumentType::new(qname, Some(pubid), Some(sysid), &*document)) Ok(DocumentType::new(qname, Some(pubid), Some(sysid), *document))
} }
} }
} }
@ -75,7 +75,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
let win = doc.window.root(); let win = doc.window.root();
// Step 1. // Step 1.
let doc = Document::new(&win.root_ref(), None, NonHTMLDocument, None).root(); let doc = Document::new(*win, None, NonHTMLDocument, None).root();
// Step 2-3. // Step 2-3.
let maybe_elem = if qname.is_empty() { let maybe_elem = if qname.is_empty() {
None None
@ -87,13 +87,13 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
}; };
{ {
let doc_node: &JSRef<Node> = NodeCast::from_ref(&*doc); let doc_node: JSRef<Node> = NodeCast::from_ref(*doc);
// Step 4. // Step 4.
match maybe_doctype { match maybe_doctype {
None => (), None => (),
Some(ref doctype) => { Some(ref doctype) => {
let doc_type: &JSRef<Node> = NodeCast::from_ref(doctype); let doc_type: JSRef<Node> = NodeCast::from_ref(*doctype);
assert!(doc_node.AppendChild(doc_type).is_ok()) assert!(doc_node.AppendChild(doc_type).is_ok())
} }
} }
@ -102,7 +102,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
match maybe_elem.root() { match maybe_elem.root() {
None => (), None => (),
Some(elem) => { Some(elem) => {
assert!(doc_node.AppendChild(NodeCast::from_ref(&*elem)).is_ok()) assert!(doc_node.AppendChild(NodeCast::from_ref(*elem)).is_ok())
} }
} }
} }
@ -111,7 +111,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
// FIXME: https://github.com/mozilla/servo/issues/1522 // FIXME: https://github.com/mozilla/servo/issues/1522
// Step 7. // Step 7.
Ok(Temporary::from_rooted(&*doc)) Ok(Temporary::from_rooted(*doc))
} }
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument // http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
@ -120,54 +120,54 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
let win = document.window.root(); let win = document.window.root();
// Step 1-2. // Step 1-2.
let doc = Document::new(&win.root_ref(), None, HTMLDocument, None).root(); let doc = Document::new(*win, None, HTMLDocument, None).root();
let doc_node: &JSRef<Node> = NodeCast::from_ref(&*doc); let doc_node: JSRef<Node> = NodeCast::from_ref(*doc);
{ {
// Step 3. // Step 3.
let doc_type = DocumentType::new("html".to_string(), None, None, &*doc).root(); let doc_type = DocumentType::new("html".to_string(), None, None, *doc).root();
assert!(doc_node.AppendChild(NodeCast::from_ref(&*doc_type)).is_ok()); assert!(doc_node.AppendChild(NodeCast::from_ref(*doc_type)).is_ok());
} }
{ {
// Step 4. // Step 4.
let doc_html: Root<Node> = NodeCast::from_temporary(HTMLHtmlElement::new("html".to_string(), &*doc)).root(); let doc_html: Root<Node> = NodeCast::from_temporary(HTMLHtmlElement::new("html".to_string(), *doc)).root();
let doc_html = doc_html.deref(); let doc_html = doc_html.deref();
assert!(doc_node.AppendChild(doc_html).is_ok()); assert!(doc_node.AppendChild(*doc_html).is_ok());
{ {
// Step 5. // Step 5.
let doc_head: Root<Node> = NodeCast::from_temporary(HTMLHeadElement::new("head".to_string(), &*doc)).root(); let doc_head: Root<Node> = NodeCast::from_temporary(HTMLHeadElement::new("head".to_string(), *doc)).root();
let doc_head = doc_head.deref(); let doc_head = doc_head.deref();
assert!(doc_html.AppendChild(doc_head).is_ok()); assert!(doc_html.AppendChild(*doc_head).is_ok());
// Step 6. // Step 6.
match title { match title {
None => (), None => (),
Some(title_str) => { Some(title_str) => {
// Step 6.1. // Step 6.1.
let doc_title: Root<Node> = NodeCast::from_temporary(HTMLTitleElement::new("title".to_string(), &*doc)).root(); let doc_title: Root<Node> = NodeCast::from_temporary(HTMLTitleElement::new("title".to_string(), *doc)).root();
let doc_title = doc_title.deref(); let doc_title = doc_title.deref();
assert!(doc_head.AppendChild(doc_title).is_ok()); assert!(doc_head.AppendChild(*doc_title).is_ok());
// Step 6.2. // Step 6.2.
let title_text: Root<Text> = Text::new(title_str, &*doc).root(); let title_text: Root<Text> = Text::new(title_str, *doc).root();
let title_text = title_text.deref(); let title_text = title_text.deref();
assert!(doc_title.AppendChild(NodeCast::from_ref(title_text)).is_ok()); assert!(doc_title.AppendChild(NodeCast::from_ref(*title_text)).is_ok());
} }
} }
} }
// Step 7. // Step 7.
let doc_body: Root<HTMLBodyElement> = HTMLBodyElement::new("body".to_string(), &*doc).root(); let doc_body: Root<HTMLBodyElement> = HTMLBodyElement::new("body".to_string(), *doc).root();
let doc_body = doc_body.deref(); let doc_body = doc_body.deref();
assert!(doc_html.AppendChild(NodeCast::from_ref(doc_body)).is_ok()); assert!(doc_html.AppendChild(NodeCast::from_ref(*doc_body)).is_ok());
} }
// Step 8. // Step 8.
// FIXME: https://github.com/mozilla/servo/issues/1522 // FIXME: https://github.com/mozilla/servo/issues/1522
// Step 9. // Step 9.
Temporary::from_rooted(&*doc) Temporary::from_rooted(*doc)
} }
} }

View file

@ -21,15 +21,15 @@ pub struct DOMParser {
} }
impl DOMParser { impl DOMParser {
pub fn new_inherited(window: &JSRef<Window>) -> DOMParser { pub fn new_inherited(window: JSRef<Window>) -> DOMParser {
DOMParser { DOMParser {
window: JS::from_rooted(window), window: JS::from_rooted(window),
reflector_: Reflector::new() reflector_: Reflector::new()
} }
} }
pub fn new(window: &JSRef<Window>) -> Temporary<DOMParser> { pub fn new(window: JSRef<Window>) -> Temporary<DOMParser> {
reflect_dom_object(box DOMParser::new_inherited(window), &Window(*window), reflect_dom_object(box DOMParser::new_inherited(window), &Window(window),
DOMParserBinding::Wrap) DOMParserBinding::Wrap)
} }
@ -46,10 +46,10 @@ impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
let window = self.window.root(); let window = self.window.root();
match ty { match ty {
Text_html => { Text_html => {
Ok(Document::new(&window.root_ref(), None, HTMLDocument, Some("text/html".to_string()))) Ok(Document::new(*window, None, HTMLDocument, Some("text/html".to_string())))
} }
Text_xml => { Text_xml => {
Ok(Document::new(&window.root_ref(), None, NonHTMLDocument, Some("text/xml".to_string()))) Ok(Document::new(*window, None, NonHTMLDocument, Some("text/xml".to_string())))
} }
_ => { _ => {
Err(FailureUnknown) Err(FailureUnknown)

View file

@ -32,11 +32,11 @@ impl DOMRect {
} }
} }
pub fn new(window: &JSRef<Window>, pub fn new(window: JSRef<Window>,
top: Au, bottom: Au, top: Au, bottom: Au,
left: Au, right: Au) -> Temporary<DOMRect> { left: Au, right: Au) -> Temporary<DOMRect> {
reflect_dom_object(box DOMRect::new_inherited(top, bottom, left, right), reflect_dom_object(box DOMRect::new_inherited(top, bottom, left, right),
&Window(*window), DOMRectBinding::Wrap) &Window(window), DOMRectBinding::Wrap)
} }
} }

View file

@ -19,9 +19,9 @@ pub struct DOMRectList {
} }
impl DOMRectList { impl DOMRectList {
pub fn new_inherited(window: &JSRef<Window>, pub fn new_inherited(window: JSRef<Window>,
rects: Vec<JSRef<DOMRect>>) -> DOMRectList { rects: Vec<JSRef<DOMRect>>) -> DOMRectList {
let rects = rects.iter().map(|rect| JS::from_rooted(rect)).collect(); let rects = rects.iter().map(|rect| JS::from_rooted(*rect)).collect();
DOMRectList { DOMRectList {
reflector_: Reflector::new(), reflector_: Reflector::new(),
rects: rects, rects: rects,
@ -29,10 +29,10 @@ impl DOMRectList {
} }
} }
pub fn new(window: &JSRef<Window>, pub fn new(window: JSRef<Window>,
rects: Vec<JSRef<DOMRect>>) -> Temporary<DOMRectList> { rects: Vec<JSRef<DOMRect>>) -> Temporary<DOMRectList> {
reflect_dom_object(box DOMRectList::new_inherited(window, rects), reflect_dom_object(box DOMRectList::new_inherited(window, rects),
&Window(*window), DOMRectListBinding::Wrap) &Window(window), DOMRectListBinding::Wrap)
} }
} }

View file

@ -25,7 +25,7 @@ pub struct DOMTokenList {
} }
impl DOMTokenList { impl DOMTokenList {
pub fn new_inherited(element: &JSRef<Element>, pub fn new_inherited(element: JSRef<Element>,
local_name: &'static str) -> DOMTokenList { local_name: &'static str) -> DOMTokenList {
DOMTokenList { DOMTokenList {
reflector_: Reflector::new(), reflector_: Reflector::new(),
@ -34,7 +34,7 @@ impl DOMTokenList {
} }
} }
pub fn new(element: &JSRef<Element>, pub fn new(element: JSRef<Element>,
local_name: &'static str) -> Temporary<DOMTokenList> { local_name: &'static str) -> Temporary<DOMTokenList> {
let window = window_from_node(element).root(); let window = window_from_node(element).root();
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name), reflect_dom_object(box DOMTokenList::new_inherited(element, local_name),

View file

@ -149,7 +149,7 @@ pub enum ElementTypeId {
// //
impl Element { impl Element {
pub fn new_inherited(type_id: ElementTypeId, local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: &JSRef<Document>) -> Element { pub fn new_inherited(type_id: ElementTypeId, local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: JSRef<Document>) -> Element {
Element { Element {
node: Node::new_inherited(ElementNodeTypeId(type_id), document), node: Node::new_inherited(ElementNodeTypeId(type_id), document),
local_name: Atom::from_slice(local_name.as_slice()), local_name: Atom::from_slice(local_name.as_slice()),
@ -162,7 +162,7 @@ impl Element {
} }
} }
pub fn new(local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: &JSRef<Document>) -> Temporary<Element> { pub fn new(local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<Element> {
Node::reflect_node(box Element::new_inherited(ElementTypeId, local_name, namespace, prefix, document), Node::reflect_node(box Element::new_inherited(ElementTypeId, local_name, namespace, prefix, document),
document, ElementBinding::Wrap) document, ElementBinding::Wrap)
} }
@ -246,7 +246,7 @@ pub trait ElementHelpers {
impl<'a> ElementHelpers for JSRef<'a, Element> { impl<'a> ElementHelpers for JSRef<'a, Element> {
fn html_element_in_html_document(&self) -> bool { fn html_element_in_html_document(&self) -> bool {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
self.namespace == namespace::HTML && node.is_in_html_doc() self.namespace == namespace::HTML && node.is_in_html_doc()
} }
@ -282,7 +282,7 @@ pub trait AttributeHandlers {
fn set_attribute(&self, name: &str, value: AttrValue); fn set_attribute(&self, name: &str, value: AttrValue);
fn do_set_attribute(&self, local_name: Atom, value: AttrValue, fn do_set_attribute(&self, local_name: Atom, value: AttrValue,
name: Atom, namespace: Namespace, name: Atom, namespace: Namespace,
prefix: Option<DOMString>, cb: |&JSRef<Attr>| -> bool); prefix: Option<DOMString>, cb: |JSRef<Attr>| -> bool);
fn parse_attribute(&self, namespace: &Namespace, local_name: &Atom, fn parse_attribute(&self, namespace: &Namespace, local_name: &Atom,
value: DOMString) -> AttrValue; value: DOMString) -> AttrValue;
@ -309,7 +309,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
let local_name = Atom::from_slice(local_name); let local_name = Atom::from_slice(local_name);
self.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| { self.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| {
*attr.local_name() == local_name && attr.namespace == namespace *attr.local_name() == local_name && attr.namespace == namespace
}).map(|x| Temporary::from_rooted(&*x)) }).map(|x| Temporary::from_rooted(*x))
} }
fn set_attribute_from_parser(&self, local_name: Atom, fn set_attribute_from_parser(&self, local_name: Atom,
@ -330,7 +330,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
assert!(name == name.to_ascii_lower().as_slice()); assert!(name == name.to_ascii_lower().as_slice());
assert!(!name.contains(":")); assert!(!name.contains(":"));
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.wait_until_safe_to_modify_dom(); node.wait_until_safe_to_modify_dom();
let name = Atom::from_slice(name); let name = Atom::from_slice(name);
@ -340,16 +340,16 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
fn do_set_attribute(&self, local_name: Atom, value: AttrValue, fn do_set_attribute(&self, local_name: Atom, value: AttrValue,
name: Atom, namespace: Namespace, name: Atom, namespace: Namespace,
prefix: Option<DOMString>, cb: |&JSRef<Attr>| -> bool) { prefix: Option<DOMString>, cb: |JSRef<Attr>| -> bool) {
let idx = self.deref().attrs.borrow().iter() let idx = self.deref().attrs.borrow().iter()
.map(|attr| attr.root()) .map(|attr| attr.root())
.position(|attr| cb(&*attr)); .position(|attr| cb(*attr));
let (idx, set_type) = match idx { let (idx, set_type) = match idx {
Some(idx) => (idx, ReplacedAttr), Some(idx) => (idx, ReplacedAttr),
None => { None => {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
let attr = Attr::new(&*window, local_name, value.clone(), let attr = Attr::new(*window, local_name, value.clone(),
name, namespace.clone(), prefix, self); name, namespace.clone(), prefix, *self);
self.deref().attrs.borrow_mut().push_unrooted(&attr); self.deref().attrs.borrow_mut().push_unrooted(&attr);
(self.deref().attrs.borrow().len() - 1, FirstSetAttr) (self.deref().attrs.borrow().len() - 1, FirstSetAttr)
} }
@ -361,7 +361,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
fn parse_attribute(&self, namespace: &Namespace, local_name: &Atom, fn parse_attribute(&self, namespace: &Namespace, local_name: &Atom,
value: DOMString) -> AttrValue { value: DOMString) -> AttrValue {
if *namespace == namespace::Null { if *namespace == namespace::Null {
vtable_for(NodeCast::from_ref(self)) vtable_for(&NodeCast::from_ref(*self))
.parse_plain_attribute(local_name.as_slice(), value) .parse_plain_attribute(local_name.as_slice(), value)
} else { } else {
StringAttrValue(value) StringAttrValue(value)
@ -380,13 +380,13 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
None => (), None => (),
Some(idx) => { Some(idx) => {
{ {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.wait_until_safe_to_modify_dom(); node.wait_until_safe_to_modify_dom();
} }
if namespace == namespace::Null { if namespace == namespace::Null {
let removed_raw_value = (*self.deref().attrs.borrow())[idx].root().Value(); let removed_raw_value = (*self.deref().attrs.borrow())[idx].root().Value();
vtable_for(NodeCast::from_ref(self)) vtable_for(&NodeCast::from_ref(*self))
.before_remove_attr(&local_name, .before_remove_attr(&local_name,
removed_raw_value); removed_raw_value);
} }
@ -397,7 +397,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
} }
fn notify_attribute_changed(&self, local_name: &Atom) { fn notify_attribute_changed(&self, local_name: &Atom) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() { if node.is_in_doc() {
let damage = match local_name.as_slice() { let damage = match local_name.as_slice() {
"style" | "id" | "class" => MatchSelectorsDocumentDamage, "style" | "id" | "class" => MatchSelectorsDocumentDamage,
@ -561,9 +561,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
match self.class_list.get() { match self.class_list.get() {
Some(class_list) => Temporary::new(class_list), Some(class_list) => Temporary::new(class_list),
None => { None => {
let class_list = DOMTokenList::new(self, "class").root(); let class_list = DOMTokenList::new(*self, "class").root();
self.class_list.assign(Some(class_list.deref().clone())); self.class_list.assign(Some(class_list.deref().clone()));
Temporary::from_rooted(&*class_list) Temporary::from_rooted(*class_list)
} }
} }
} }
@ -576,11 +576,11 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
} }
let doc = { let doc = {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.owner_doc().root() node.owner_doc().root()
}; };
let window = doc.deref().window.root(); let window = doc.deref().window.root();
let list = NamedNodeMap::new(&*window, self); let list = NamedNodeMap::new(*window, *self);
self.attr_list.assign(Some(list)); self.attr_list.assign(Some(list));
Temporary::new(self.attr_list.get().get_ref().clone()) Temporary::new(self.attr_list.get().get_ref().clone())
} }
@ -610,7 +610,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
name: DOMString, name: DOMString,
value: DOMString) -> ErrorResult { value: DOMString) -> ErrorResult {
{ {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.wait_until_safe_to_modify_dom(); node.wait_until_safe_to_modify_dom();
} }
@ -642,7 +642,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
name: DOMString, name: DOMString,
value: DOMString) -> ErrorResult { value: DOMString) -> ErrorResult {
{ {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.wait_until_safe_to_modify_dom(); node.wait_until_safe_to_modify_dom();
} }
@ -737,45 +737,45 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
} }
fn GetElementsByTagName(&self, localname: DOMString) -> Temporary<HTMLCollection> { fn GetElementsByTagName(&self, localname: DOMString) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
HTMLCollection::by_tag_name(&*window, NodeCast::from_ref(self), localname) HTMLCollection::by_tag_name(*window, NodeCast::from_ref(*self), localname)
} }
fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>, fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>,
localname: DOMString) -> Temporary<HTMLCollection> { localname: DOMString) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
HTMLCollection::by_tag_name_ns(&*window, NodeCast::from_ref(self), localname, maybe_ns) HTMLCollection::by_tag_name_ns(*window, NodeCast::from_ref(*self), localname, maybe_ns)
} }
fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection> { fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
HTMLCollection::by_class_name(&*window, NodeCast::from_ref(self), classes) HTMLCollection::by_class_name(*window, NodeCast::from_ref(*self), classes)
} }
// http://dev.w3.org/csswg/cssom-view/#dom-element-getclientrects // http://dev.w3.org/csswg/cssom-view/#dom-element-getclientrects
fn GetClientRects(&self) -> Temporary<DOMRectList> { fn GetClientRects(&self) -> Temporary<DOMRectList> {
let win = window_from_node(self).root(); let win = window_from_node(*self).root();
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let rects = node.get_content_boxes(); let rects = node.get_content_boxes();
let rects: Vec<Root<DOMRect>> = rects.iter().map(|r| { let rects: Vec<Root<DOMRect>> = rects.iter().map(|r| {
DOMRect::new( DOMRect::new(
&*win, *win,
r.origin.y, r.origin.y,
r.origin.y + r.size.height, r.origin.y + r.size.height,
r.origin.x, r.origin.x,
r.origin.x + r.size.width).root() r.origin.x + r.size.width).root()
}).collect(); }).collect();
DOMRectList::new(&*win, rects.iter().map(|rect| rect.deref().clone()).collect()) DOMRectList::new(*win, rects.iter().map(|rect| rect.deref().clone()).collect())
} }
// http://dev.w3.org/csswg/cssom-view/#dom-element-getboundingclientrect // http://dev.w3.org/csswg/cssom-view/#dom-element-getboundingclientrect
fn GetBoundingClientRect(&self) -> Temporary<DOMRect> { fn GetBoundingClientRect(&self) -> Temporary<DOMRect> {
let win = window_from_node(self).root(); let win = window_from_node(*self).root();
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let rect = node.get_bounding_content_box(); let rect = node.get_bounding_content_box();
DOMRect::new( DOMRect::new(
&*win, *win,
rect.origin.y, rect.origin.y,
rect.origin.y + rect.size.height, rect.origin.y + rect.size.height,
rect.origin.x, rect.origin.x,
@ -784,34 +784,34 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
fn GetInnerHTML(&self) -> Fallible<DOMString> { fn GetInnerHTML(&self) -> Fallible<DOMString> {
//XXX TODO: XML case //XXX TODO: XML case
Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(self), false, false))) Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(*self), false, false)))
} }
fn GetOuterHTML(&self) -> Fallible<DOMString> { fn GetOuterHTML(&self) -> Fallible<DOMString> {
Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(self), true, false))) Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(*self), true, false)))
} }
// http://dom.spec.whatwg.org/#dom-parentnode-children // http://dom.spec.whatwg.org/#dom-parentnode-children
fn Children(&self) -> Temporary<HTMLCollection> { fn Children(&self) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
HTMLCollection::children(&*window, NodeCast::from_ref(self)) HTMLCollection::children(*window, NodeCast::from_ref(*self))
} }
// http://dom.spec.whatwg.org/#dom-parentnode-queryselector // http://dom.spec.whatwg.org/#dom-parentnode-queryselector
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> { fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> {
let root: &JSRef<Node> = NodeCast::from_ref(self); let root: JSRef<Node> = NodeCast::from_ref(*self);
root.query_selector(selectors) root.query_selector(selectors)
} }
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall // http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>> { fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>> {
let root: &JSRef<Node> = NodeCast::from_ref(self); let root: JSRef<Node> = NodeCast::from_ref(*self);
root.query_selector_all(selectors) root.query_selector_all(selectors)
} }
// http://dom.spec.whatwg.org/#dom-childnode-remove // http://dom.spec.whatwg.org/#dom-childnode-remove
fn Remove(&self) { fn Remove(&self) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.remove_self(); node.remove_self();
} }
@ -820,8 +820,8 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
match parse_selector_list_from_str(selectors.as_slice()) { match parse_selector_list_from_str(selectors.as_slice()) {
Err(()) => Err(Syntax), Err(()) => Err(Syntax),
Ok(ref selectors) => { Ok(ref selectors) => {
let root: &JSRef<Node> = NodeCast::from_ref(self); let root: JSRef<Node> = NodeCast::from_ref(*self);
Ok(matches(selectors, root, &mut None)) Ok(matches(selectors, &root, &mut None))
} }
} }
} }
@ -842,7 +842,7 @@ pub fn get_attribute_parts<'a>(name: &'a str) -> (Option<&'a str>, &'a str) {
impl<'a> VirtualMethods for JSRef<'a, Element> { impl<'a> VirtualMethods for JSRef<'a, Element> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: &JSRef<Node> = NodeCast::from_borrowed_ref(self);
Some(node as &VirtualMethods) Some(node as &VirtualMethods)
} }
@ -854,16 +854,16 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
match name.as_slice() { match name.as_slice() {
"style" => { "style" => {
let doc = document_from_node(self).root(); let doc = document_from_node(*self).root();
let base_url = doc.deref().url().clone(); let base_url = doc.deref().url().clone();
let style = Some(style::parse_style_attribute(value.as_slice(), &base_url)); let style = Some(style::parse_style_attribute(value.as_slice(), &base_url));
*self.deref().style_attribute.deref().borrow_mut() = style; *self.deref().style_attribute.deref().borrow_mut() = style;
} }
"id" => { "id" => {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() && !value.is_empty() { if node.is_in_doc() && !value.is_empty() {
let doc = document_from_node(self).root(); let doc = document_from_node(*self).root();
doc.register_named_element(self, value.clone()); doc.register_named_element(*self, value.clone());
} }
} }
_ => () _ => ()
@ -883,10 +883,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
*self.deref().style_attribute.deref().borrow_mut() = None; *self.deref().style_attribute.deref().borrow_mut() = None;
} }
"id" => { "id" => {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() && !value.is_empty() { if node.is_in_doc() && !value.is_empty() {
let doc = document_from_node(self).root(); let doc = document_from_node(*self).root();
doc.unregister_named_element(self, value); doc.unregister_named_element(*self, value);
} }
} }
_ => () _ => ()
@ -913,10 +913,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
match self.get_attribute(Null, "id").root() { match self.get_attribute(Null, "id").root() {
Some(attr) => { Some(attr) => {
let doc = document_from_node(self).root(); let doc = document_from_node(*self).root();
let value = attr.deref().Value(); let value = attr.deref().Value();
if !value.is_empty() { if !value.is_empty() {
doc.deref().register_named_element(self, value); doc.deref().register_named_element(*self, value);
} }
} }
_ => () _ => ()
@ -933,10 +933,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
match self.get_attribute(Null, "id").root() { match self.get_attribute(Null, "id").root() {
Some(attr) => { Some(attr) => {
let doc = document_from_node(self).root(); let doc = document_from_node(*self).root();
let value = attr.deref().Value(); let value = attr.deref().Value();
if !value.is_empty() { if !value.is_empty() {
doc.deref().unregister_named_element(self, value); doc.deref().unregister_named_element(*self, value);
} }
} }
_ => () _ => ()
@ -952,7 +952,7 @@ impl<'a> style::TElement for JSRef<'a, Element> {
} }
fn get_link(&self) -> Option<&'static str> { fn get_link(&self) -> Option<&'static str> {
// FIXME: This is HTML only. // FIXME: This is HTML only.
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match node.type_id() { match node.type_id() {
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html# // http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#
// selector-link // selector-link
@ -969,7 +969,7 @@ impl<'a> style::TElement for JSRef<'a, Element> {
(self as &ElementHelpers).get_namespace() (self as &ElementHelpers).get_namespace()
} }
fn get_hover_state(&self) -> bool { fn get_hover_state(&self) -> bool {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.get_hover_state() node.get_hover_state()
} }
fn get_id<'a>(&self) -> Option<Atom> { fn get_id<'a>(&self) -> Option<Atom> {
@ -982,11 +982,11 @@ impl<'a> style::TElement for JSRef<'a, Element> {
}) })
} }
fn get_disabled_state(&self) -> bool { fn get_disabled_state(&self) -> bool {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.get_disabled_state() node.get_disabled_state()
} }
fn get_enabled_state(&self) -> bool { fn get_enabled_state(&self) -> bool {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.get_enabled_state() node.get_enabled_state()
} }
fn has_class(&self, name: &str) -> bool { fn has_class(&self, name: &str) -> bool {

View file

@ -87,7 +87,7 @@ impl Event {
cancelable: bool) -> Temporary<Event> { cancelable: bool) -> Temporary<Event> {
let event = Event::new_uninitialized(global).root(); let event = Event::new_uninitialized(global).root();
event.deref().InitEvent(type_, can_bubble, cancelable); event.deref().InitEvent(type_, can_bubble, cancelable);
Temporary::from_rooted(&*event) Temporary::from_rooted(*event)
} }
pub fn Constructor(global: &GlobalRef, pub fn Constructor(global: &GlobalRef,

View file

@ -12,9 +12,9 @@ use dom::node::{Node, NodeHelpers};
use dom::virtualmethods::vtable_for; use dom::virtualmethods::vtable_for;
// See http://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm // See http://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>, pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
pseudo_target: Option<JSRef<'b, EventTarget>>, pseudo_target: Option<JSRef<'b, EventTarget>>,
event: &JSRef<Event>) -> bool { event: JSRef<Event>) -> bool {
assert!(!event.deref().dispatching.deref().get()); assert!(!event.deref().dispatching.deref().get());
event.target.assign(Some(match pseudo_target { event.target.assign(Some(match pseudo_target {
@ -27,9 +27,9 @@ pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>,
//TODO: no chain if not participating in a tree //TODO: no chain if not participating in a tree
let mut chain: Vec<Root<EventTarget>> = if target.deref().is_node() { let mut chain: Vec<Root<EventTarget>> = if target.deref().is_node() {
let target_node: &JSRef<Node> = NodeCast::to_ref(target).unwrap(); let target_node: JSRef<Node> = NodeCast::to_ref(target).unwrap();
target_node.ancestors().map(|ancestor| { target_node.ancestors().map(|ancestor| {
let ancestor_target: &JSRef<EventTarget> = EventTargetCast::from_ref(&ancestor); let ancestor_target: JSRef<EventTarget> = EventTargetCast::from_ref(ancestor);
JS::from_rooted(ancestor_target).root() JS::from_rooted(ancestor_target).root()
}).collect() }).collect()
} else { } else {
@ -47,7 +47,7 @@ pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>,
event.current_target.assign(Some(cur_target.deref().clone())); event.current_target.assign(Some(cur_target.deref().clone()));
for listener in listeners.iter() { for listener in listeners.iter() {
// Explicitly drop any exception on the floor. // Explicitly drop any exception on the floor.
let _ = listener.HandleEvent_(&**cur_target, event, ReportExceptions); let _ = listener.HandleEvent_(**cur_target, event, ReportExceptions);
if event.deref().stop_immediate.deref().get() { if event.deref().stop_immediate.deref().get() {
break; break;
@ -92,7 +92,7 @@ pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>,
event.deref().current_target.assign(Some(cur_target.deref().clone())); event.deref().current_target.assign(Some(cur_target.deref().clone()));
for listener in listeners.iter() { for listener in listeners.iter() {
// Explicitly drop any exception on the floor. // Explicitly drop any exception on the floor.
let _ = listener.HandleEvent_(&**cur_target, event, ReportExceptions); let _ = listener.HandleEvent_(**cur_target, event, ReportExceptions);
if event.deref().stop_immediate.deref().get() { if event.deref().stop_immediate.deref().get() {
break; break;
@ -113,10 +113,10 @@ pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>,
let target = event.GetTarget().root(); let target = event.GetTarget().root();
match target { match target {
Some(target) => { Some(target) => {
let node: Option<&JSRef<Node>> = NodeCast::to_ref(&*target); let node: Option<JSRef<Node>> = NodeCast::to_ref(*target);
match node { match node {
Some(node) => { Some(node) => {
let vtable = vtable_for(node); let vtable = vtable_for(&node);
vtable.handle_event(event); vtable.handle_event(event);
} }
None => {} None => {}

View file

@ -96,7 +96,7 @@ impl EventTarget {
pub trait EventTargetHelpers { pub trait EventTargetHelpers {
fn dispatch_event_with_target<'a>(&self, fn dispatch_event_with_target<'a>(&self,
target: Option<JSRef<'a, EventTarget>>, target: Option<JSRef<'a, EventTarget>>,
event: &JSRef<Event>) -> Fallible<bool>; event: JSRef<Event>) -> Fallible<bool>;
fn set_inline_event_listener(&self, fn set_inline_event_listener(&self,
ty: DOMString, ty: DOMString,
listener: Option<EventListener>); listener: Option<EventListener>);
@ -117,11 +117,11 @@ pub trait EventTargetHelpers {
impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> { impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
fn dispatch_event_with_target<'b>(&self, fn dispatch_event_with_target<'b>(&self,
target: Option<JSRef<'b, EventTarget>>, target: Option<JSRef<'b, EventTarget>>,
event: &JSRef<Event>) -> Fallible<bool> { event: JSRef<Event>) -> Fallible<bool> {
if event.deref().dispatching.deref().get() || !event.deref().initialized.deref().get() { if event.deref().dispatching.deref().get() || !event.deref().initialized.deref().get() {
return Err(InvalidState); return Err(InvalidState);
} }
Ok(dispatch_event(self, target, event)) Ok(dispatch_event(*self, target, event))
} }
fn set_inline_event_listener(&self, fn set_inline_event_listener(&self,
@ -270,7 +270,7 @@ impl<'a> EventTargetMethods for JSRef<'a, EventTarget> {
} }
} }
fn DispatchEvent(&self, event: &JSRef<Event>) -> Fallible<bool> { fn DispatchEvent(&self, event: JSRef<Event>) -> Fallible<bool> {
self.dispatch_event_with_target(None, event) self.dispatch_event_with_target(None, event)
} }
} }

View file

@ -19,7 +19,7 @@ pub struct File {
} }
impl File { impl File {
pub fn new_inherited(_file_bits: &JSRef<Blob>, name: DOMString) -> File { pub fn new_inherited(_file_bits: JSRef<Blob>, name: DOMString) -> File {
File { File {
blob: Blob::new_inherited(), blob: Blob::new_inherited(),
name: name, name: name,
@ -29,7 +29,7 @@ impl File {
// the relevant subfields of file_bits should be copied over // the relevant subfields of file_bits should be copied over
} }
pub fn new(global: &GlobalRef, file_bits: &JSRef<Blob>, name: DOMString) -> Temporary<File> { pub fn new(global: &GlobalRef, file_bits: JSRef<Blob>, name: DOMString) -> Temporary<File> {
reflect_dom_object(box File::new_inherited(file_bits, name), reflect_dom_object(box File::new_inherited(file_bits, name),
global, global,
FileBinding::Wrap) FileBinding::Wrap)

View file

@ -40,7 +40,7 @@ impl FormData {
data: Traceable::new(RefCell::new(HashMap::new())), data: Traceable::new(RefCell::new(HashMap::new())),
reflector_: Reflector::new(), reflector_: Reflector::new(),
global: GlobalField::from_rooted(global), global: GlobalField::from_rooted(global),
form: form.map(|f| JS::from_rooted(&f)), form: form.map(|f| JS::from_rooted(f)),
} }
} }
@ -56,8 +56,8 @@ impl FormData {
impl<'a> FormDataMethods for JSRef<'a, FormData> { impl<'a> FormDataMethods for JSRef<'a, FormData> {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
fn Append(&self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>) { fn Append(&self, name: DOMString, value: JSRef<Blob>, filename: Option<DOMString>) {
let file = FileData(JS::from_rooted(&self.get_file_from_blob(value, filename))); let file = FileData(JS::from_rooted(self.get_file_from_blob(value, filename)));
self.data.deref().borrow_mut().insert_or_update_with(name.clone(), vec!(file.clone()), self.data.deref().borrow_mut().insert_or_update_with(name.clone(), vec!(file.clone()),
|_k, v| {v.push(file.clone());}); |_k, v| {v.push(file.clone());});
} }
@ -88,8 +88,8 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
self.data.deref().borrow().contains_key_equiv(&name) self.data.deref().borrow().contains_key_equiv(&name)
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
fn Set(&self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>) { fn Set(&self, name: DOMString, value: JSRef<Blob>, filename: Option<DOMString>) {
let file = FileData(JS::from_rooted(&self.get_file_from_blob(value, filename))); let file = FileData(JS::from_rooted(self.get_file_from_blob(value, filename)));
self.data.deref().borrow_mut().insert(name, vec!(file)); self.data.deref().borrow_mut().insert(name, vec!(file));
} }
@ -105,13 +105,13 @@ impl Reflectable for FormData {
} }
trait PrivateFormDataHelpers{ trait PrivateFormDataHelpers{
fn get_file_from_blob(&self, value: &JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File>; fn get_file_from_blob(&self, value: JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File>;
} }
impl PrivateFormDataHelpers for FormData { impl PrivateFormDataHelpers for FormData {
fn get_file_from_blob(&self, value: &JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> { fn get_file_from_blob(&self, value: JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> {
let global = self.global.root(); let global = self.global.root();
let f: Option<&JSRef<File>> = FileCast::to_ref(value); let f: Option<JSRef<File>> = FileCast::to_ref(value);
let name = filename.unwrap_or(f.map(|inner| inner.name.clone()).unwrap_or("blob".to_string())); let name = filename.unwrap_or(f.map(|inner| inner.name.clone()).unwrap_or("blob".to_string()));
File::new(&global.root_ref(), value, name) File::new(&global.root_ref(), value, name)
} }

View file

@ -36,33 +36,33 @@ impl HTMLAnchorElementDerived for EventTarget {
} }
impl HTMLAnchorElement { impl HTMLAnchorElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAnchorElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAnchorElement {
HTMLAnchorElement { HTMLAnchorElement {
htmlelement: HTMLElement::new_inherited(HTMLAnchorElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLAnchorElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAnchorElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLAnchorElement> {
let element = HTMLAnchorElement::new_inherited(localName, document); let element = HTMLAnchorElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLAnchorElementBinding::Wrap) Node::reflect_node(box element, document, HTMLAnchorElementBinding::Wrap)
} }
} }
trait PrivateHTMLAnchorElementHelpers { trait PrivateHTMLAnchorElementHelpers {
fn handle_event_impl(&self, event: &JSRef<Event>); fn handle_event_impl(&self, event: JSRef<Event>);
} }
impl<'a> PrivateHTMLAnchorElementHelpers for JSRef<'a, HTMLAnchorElement> { impl<'a> PrivateHTMLAnchorElementHelpers for JSRef<'a, HTMLAnchorElement> {
fn handle_event_impl(&self, event: &JSRef<Event>) { fn handle_event_impl(&self, event: JSRef<Event>) {
if "click" == event.Type().as_slice() && !event.DefaultPrevented() { if "click" == event.Type().as_slice() && !event.DefaultPrevented() {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
let attr = element.get_attribute(Null, "href").root(); let attr = element.get_attribute(Null, "href").root();
match attr { match attr {
Some(ref href) => { Some(ref href) => {
let value = href.Value(); let value = href.Value();
debug!("clicked on link to {:s}", value); debug!("clicked on link to {:s}", value);
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let doc = node.owner_doc().root(); let doc = node.owner_doc().root();
doc.load_anchor_href(value); doc.load_anchor_href(value);
} }
@ -74,7 +74,7 @@ impl<'a> PrivateHTMLAnchorElementHelpers for JSRef<'a, HTMLAnchorElement> {
impl<'a> VirtualMethods for JSRef<'a, HTMLAnchorElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLAnchorElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -84,7 +84,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLAnchorElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"href" => node.set_enabled_state(true), "href" => node.set_enabled_state(true),
_ => () _ => ()
@ -97,14 +97,14 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLAnchorElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"href" => node.set_enabled_state(false), "href" => node.set_enabled_state(false),
_ => () _ => ()
} }
} }
fn handle_event(&self, event: &JSRef<Event>) { fn handle_event(&self, event: JSRef<Event>) {
match self.super_type() { match self.super_type() {
Some(s) => { Some(s) => {
s.handle_event(event); s.handle_event(event);
@ -123,12 +123,12 @@ impl Reflectable for HTMLAnchorElement {
impl<'a> HTMLAnchorElementMethods for JSRef<'a, HTMLAnchorElement> { impl<'a> HTMLAnchorElementMethods for JSRef<'a, HTMLAnchorElement> {
fn Text(&self) -> DOMString { fn Text(&self) -> DOMString {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.GetTextContent().unwrap() node.GetTextContent().unwrap()
} }
fn SetText(&self, value: DOMString) { fn SetText(&self, value: DOMString) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.SetTextContent(Some(value)) node.SetTextContent(Some(value))
} }
} }

View file

@ -26,14 +26,14 @@ impl HTMLAppletElementDerived for EventTarget {
} }
impl HTMLAppletElement { impl HTMLAppletElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAppletElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAppletElement {
HTMLAppletElement { HTMLAppletElement {
htmlelement: HTMLElement::new_inherited(HTMLAppletElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLAppletElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAppletElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLAppletElement> {
let element = HTMLAppletElement::new_inherited(localName, document); let element = HTMLAppletElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLAppletElementBinding::Wrap) Node::reflect_node(box element, document, HTMLAppletElementBinding::Wrap)
} }

View file

@ -30,14 +30,14 @@ impl HTMLAreaElementDerived for EventTarget {
} }
impl HTMLAreaElement { impl HTMLAreaElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAreaElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAreaElement {
HTMLAreaElement { HTMLAreaElement {
htmlelement: HTMLElement::new_inherited(HTMLAreaElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLAreaElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAreaElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLAreaElement> {
let element = HTMLAreaElement::new_inherited(localName, document); let element = HTMLAreaElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLAreaElementBinding::Wrap) Node::reflect_node(box element, document, HTMLAreaElementBinding::Wrap)
} }
@ -45,7 +45,7 @@ impl HTMLAreaElement {
impl<'a> VirtualMethods for JSRef<'a, HTMLAreaElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLAreaElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -55,7 +55,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLAreaElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"href" => node.set_enabled_state(true), "href" => node.set_enabled_state(true),
_ => () _ => ()
@ -68,7 +68,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLAreaElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"href" => node.set_enabled_state(false), "href" => node.set_enabled_state(false),
_ => () _ => ()

View file

@ -26,14 +26,14 @@ impl HTMLAudioElementDerived for EventTarget {
} }
impl HTMLAudioElement { impl HTMLAudioElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAudioElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAudioElement {
HTMLAudioElement { HTMLAudioElement {
htmlmediaelement: HTMLMediaElement::new_inherited(HTMLAudioElementTypeId, localName, document) htmlmediaelement: HTMLMediaElement::new_inherited(HTMLAudioElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLAudioElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLAudioElement> {
let element = HTMLAudioElement::new_inherited(localName, document); let element = HTMLAudioElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLAudioElementBinding::Wrap) Node::reflect_node(box element, document, HTMLAudioElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLBaseElementDerived for EventTarget {
} }
impl HTMLBaseElement { impl HTMLBaseElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBaseElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBaseElement {
HTMLBaseElement { HTMLBaseElement {
htmlelement: HTMLElement::new_inherited(HTMLBaseElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLBaseElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLBaseElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, document); let element = HTMLBaseElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLBaseElementBinding::Wrap) Node::reflect_node(box element, document, HTMLBaseElementBinding::Wrap)
} }

View file

@ -33,14 +33,14 @@ impl HTMLBodyElementDerived for EventTarget {
} }
impl HTMLBodyElement { impl HTMLBodyElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBodyElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBodyElement {
HTMLBodyElement { HTMLBodyElement {
htmlelement: HTMLElement::new_inherited(HTMLBodyElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLBodyElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLBodyElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLBodyElement> {
let element = HTMLBodyElement::new_inherited(localName, document); let element = HTMLBodyElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLBodyElementBinding::Wrap) Node::reflect_node(box element, document, HTMLBodyElementBinding::Wrap)
} }
@ -48,19 +48,19 @@ impl HTMLBodyElement {
impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> { impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
fn GetOnunload(&self) -> Option<EventHandlerNonNull> { fn GetOnunload(&self) -> Option<EventHandlerNonNull> {
let win = window_from_node(self).root(); let win = window_from_node(*self).root();
win.deref().GetOnunload() win.deref().GetOnunload()
} }
fn SetOnunload(&self, listener: Option<EventHandlerNonNull>) { fn SetOnunload(&self, listener: Option<EventHandlerNonNull>) {
let win = window_from_node(self).root(); let win = window_from_node(*self).root();
win.deref().SetOnunload(listener) win.deref().SetOnunload(listener)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let element: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let element: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(element as &VirtualMethods) Some(element as &VirtualMethods)
} }
@ -76,15 +76,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
"onbeforeunload", "onhashchange", "onlanguagechange", "onmessage", "onbeforeunload", "onhashchange", "onlanguagechange", "onmessage",
"onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate", "onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate",
"onstorage", "onresize", "onunload", "onerror"]; "onstorage", "onresize", "onunload", "onerror"];
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
let (cx, url, reflector) = (window.get_cx(), let (cx, url, reflector) = (window.get_cx(),
window.get_url(), window.get_url(),
window.reflector().get_jsobject()); window.reflector().get_jsobject());
let evtarget: &JSRef<EventTarget> = let evtarget: JSRef<EventTarget> =
if forwarded_events.iter().any(|&event| name.as_slice() == event) { if forwarded_events.iter().any(|&event| name.as_slice() == event) {
EventTargetCast::from_ref(&*window) EventTargetCast::from_ref(*window)
} else { } else {
EventTargetCast::from_ref(self) EventTargetCast::from_ref(*self)
}; };
evtarget.set_event_handler_uncompiled(cx, url, reflector, evtarget.set_event_handler_uncompiled(cx, url, reflector,
name.as_slice().slice_from(2), name.as_slice().slice_from(2),

View file

@ -26,14 +26,14 @@ impl HTMLBRElementDerived for EventTarget {
} }
impl HTMLBRElement { impl HTMLBRElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBRElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBRElement {
HTMLBRElement { HTMLBRElement {
htmlelement: HTMLElement::new_inherited(HTMLBRElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLBRElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLBRElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLBRElement> {
let element = HTMLBRElement::new_inherited(localName, document); let element = HTMLBRElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLBRElementBinding::Wrap) Node::reflect_node(box element, document, HTMLBRElementBinding::Wrap)
} }

View file

@ -32,14 +32,14 @@ impl HTMLButtonElementDerived for EventTarget {
} }
impl HTMLButtonElement { impl HTMLButtonElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLButtonElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLButtonElement {
HTMLButtonElement { HTMLButtonElement {
htmlelement: HTMLElement::new_inherited(HTMLButtonElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLButtonElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLButtonElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLButtonElement> {
let element = HTMLButtonElement::new_inherited(localName, document); let element = HTMLButtonElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLButtonElementBinding::Wrap) Node::reflect_node(box element, document, HTMLButtonElementBinding::Wrap)
} }
@ -47,8 +47,8 @@ impl HTMLButtonElement {
impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> { impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> {
fn Validity(&self) -> Temporary<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
ValidityState::new(&*window) ValidityState::new(*window)
} }
// http://www.whatwg.org/html/#dom-fe-disabled // http://www.whatwg.org/html/#dom-fe-disabled
@ -56,14 +56,14 @@ impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> {
// http://www.whatwg.org/html/#dom-fe-disabled // http://www.whatwg.org/html/#dom-fe-disabled
fn SetDisabled(&self, disabled: bool) { fn SetDisabled(&self, disabled: bool) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_bool_attribute("disabled", disabled) elem.set_bool_attribute("disabled", disabled)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -73,7 +73,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(true); node.set_disabled_state(true);
@ -89,7 +89,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(false); node.set_disabled_state(false);
@ -106,7 +106,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.check_ancestors_disabled_state_for_form_control(); node.check_ancestors_disabled_state_for_form_control();
} }
@ -116,7 +116,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) { if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) {
node.check_ancestors_disabled_state_for_form_control(); node.check_ancestors_disabled_state_for_form_control();
} else { } else {

View file

@ -44,7 +44,7 @@ impl HTMLCanvasElementDerived for EventTarget {
} }
impl HTMLCanvasElement { impl HTMLCanvasElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLCanvasElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLCanvasElement {
HTMLCanvasElement { HTMLCanvasElement {
htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, document), htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, document),
context: Traceable::new(Cell::new(None)), context: Traceable::new(Cell::new(None)),
@ -54,7 +54,7 @@ impl HTMLCanvasElement {
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLCanvasElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLCanvasElement> {
let element = HTMLCanvasElement::new_inherited(localName, document); let element = HTMLCanvasElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLCanvasElementBinding::Wrap) Node::reflect_node(box element, document, HTMLCanvasElementBinding::Wrap)
} }
@ -66,7 +66,7 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
} }
fn SetWidth(&self, width: u32) { fn SetWidth(&self, width: u32) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_uint_attribute("width", width) elem.set_uint_attribute("width", width)
} }
@ -75,7 +75,7 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
} }
fn SetHeight(&self, height: u32) { fn SetHeight(&self, height: u32) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_uint_attribute("height", height) elem.set_uint_attribute("height", height)
} }
@ -85,9 +85,9 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
} }
if self.context.get().is_none() { if self.context.get().is_none() {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
let (w, h) = (self.width.get() as i32, self.height.get() as i32); let (w, h) = (self.width.get() as i32, self.height.get() as i32);
let context = CanvasRenderingContext2D::new(&Window(*window), self, Size2D(w, h)); let context = CanvasRenderingContext2D::new(&Window(*window), *self, Size2D(w, h));
self.context.assign(Some(context)); self.context.assign(Some(context));
} }
self.context.get().map(|context| Temporary::new(context)) self.context.get().map(|context| Temporary::new(context))
@ -96,7 +96,7 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let element: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let element: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(element as &VirtualMethods) Some(element as &VirtualMethods)
} }

View file

@ -20,7 +20,7 @@ use serialize::{Encoder, Encodable};
use std::ascii::StrAsciiExt; use std::ascii::StrAsciiExt;
pub trait CollectionFilter { pub trait CollectionFilter {
fn filter(&self, elem: &JSRef<Element>, root: &JSRef<Node>) -> bool; fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool;
} }
impl<S: Encoder<E>, E> Encodable<S, E> for Box<CollectionFilter> { impl<S: Encoder<E>, E> Encodable<S, E> for Box<CollectionFilter> {
@ -51,25 +51,25 @@ impl HTMLCollection {
} }
} }
pub fn new(window: &JSRef<Window>, collection: CollectionTypeId) -> Temporary<HTMLCollection> { pub fn new(window: JSRef<Window>, collection: CollectionTypeId) -> Temporary<HTMLCollection> {
reflect_dom_object(box HTMLCollection::new_inherited(collection), reflect_dom_object(box HTMLCollection::new_inherited(collection),
&Window(*window), HTMLCollectionBinding::Wrap) &Window(window), HTMLCollectionBinding::Wrap)
} }
} }
impl HTMLCollection { impl HTMLCollection {
pub fn create(window: &JSRef<Window>, root: &JSRef<Node>, pub fn create(window: JSRef<Window>, root: JSRef<Node>,
filter: Box<CollectionFilter>) -> Temporary<HTMLCollection> { filter: Box<CollectionFilter>) -> Temporary<HTMLCollection> {
HTMLCollection::new(window, Live(JS::from_rooted(root), filter)) HTMLCollection::new(window, Live(JS::from_rooted(root), filter))
} }
fn all_elements(window: &JSRef<Window>, root: &JSRef<Node>, fn all_elements(window: JSRef<Window>, root: JSRef<Node>,
namespace_filter: Option<Namespace>) -> Temporary<HTMLCollection> { namespace_filter: Option<Namespace>) -> Temporary<HTMLCollection> {
struct AllElementFilter { struct AllElementFilter {
namespace_filter: Option<Namespace> namespace_filter: Option<Namespace>
} }
impl CollectionFilter for AllElementFilter { impl CollectionFilter for AllElementFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
match self.namespace_filter { match self.namespace_filter {
None => true, None => true,
Some(ref namespace) => elem.namespace == *namespace Some(ref namespace) => elem.namespace == *namespace
@ -80,7 +80,7 @@ impl HTMLCollection {
HTMLCollection::create(window, root, box filter) HTMLCollection::create(window, root, box filter)
} }
pub fn by_tag_name(window: &JSRef<Window>, root: &JSRef<Node>, tag: DOMString) pub fn by_tag_name(window: JSRef<Window>, root: JSRef<Node>, tag: DOMString)
-> Temporary<HTMLCollection> { -> Temporary<HTMLCollection> {
if tag.as_slice() == "*" { if tag.as_slice() == "*" {
return HTMLCollection::all_elements(window, root, None); return HTMLCollection::all_elements(window, root, None);
@ -91,7 +91,7 @@ impl HTMLCollection {
ascii_lower_tag: Atom, ascii_lower_tag: Atom,
} }
impl CollectionFilter for TagNameFilter { impl CollectionFilter for TagNameFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
if elem.html_element_in_html_document() { if elem.html_element_in_html_document() {
elem.local_name == self.ascii_lower_tag elem.local_name == self.ascii_lower_tag
} else { } else {
@ -106,7 +106,7 @@ impl HTMLCollection {
HTMLCollection::create(window, root, box filter) HTMLCollection::create(window, root, box filter)
} }
pub fn by_tag_name_ns(window: &JSRef<Window>, root: &JSRef<Node>, tag: DOMString, pub fn by_tag_name_ns(window: JSRef<Window>, root: JSRef<Node>, tag: DOMString,
maybe_ns: Option<DOMString>) -> Temporary<HTMLCollection> { maybe_ns: Option<DOMString>) -> Temporary<HTMLCollection> {
let namespace_filter = match maybe_ns { let namespace_filter = match maybe_ns {
Some(namespace) => { Some(namespace) => {
@ -126,7 +126,7 @@ impl HTMLCollection {
namespace_filter: Option<Namespace> namespace_filter: Option<Namespace>
} }
impl CollectionFilter for TagNameNSFilter { impl CollectionFilter for TagNameNSFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
let ns_match = match self.namespace_filter { let ns_match = match self.namespace_filter {
Some(ref namespace) => { Some(ref namespace) => {
elem.deref().namespace == *namespace elem.deref().namespace == *namespace
@ -143,13 +143,13 @@ impl HTMLCollection {
HTMLCollection::create(window, root, box filter) HTMLCollection::create(window, root, box filter)
} }
pub fn by_class_name(window: &JSRef<Window>, root: &JSRef<Node>, classes: DOMString) pub fn by_class_name(window: JSRef<Window>, root: JSRef<Node>, classes: DOMString)
-> Temporary<HTMLCollection> { -> Temporary<HTMLCollection> {
struct ClassNameFilter { struct ClassNameFilter {
classes: Vec<DOMString> classes: Vec<DOMString>
} }
impl CollectionFilter for ClassNameFilter { impl CollectionFilter for ClassNameFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
self.classes.iter().all(|class| elem.has_class(class.as_slice())) self.classes.iter().all(|class| elem.has_class(class.as_slice()))
} }
} }
@ -159,10 +159,10 @@ impl HTMLCollection {
HTMLCollection::create(window, root, box filter) HTMLCollection::create(window, root, box filter)
} }
pub fn children(window: &JSRef<Window>, root: &JSRef<Node>) -> Temporary<HTMLCollection> { pub fn children(window: JSRef<Window>, root: JSRef<Node>) -> Temporary<HTMLCollection> {
struct ElementChildFilter; struct ElementChildFilter;
impl CollectionFilter for ElementChildFilter { impl CollectionFilter for ElementChildFilter {
fn filter(&self, elem: &JSRef<Element>, root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool {
root.is_parent_of(NodeCast::from_ref(elem)) root.is_parent_of(NodeCast::from_ref(elem))
} }
} }
@ -179,8 +179,8 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
let root = root.root(); let root = root.root();
root.deref().traverse_preorder() root.deref().traverse_preorder()
.filter(|&child| { .filter(|&child| {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&child); let elem: Option<JSRef<Element>> = ElementCast::to_ref(child);
elem.map_or(false, |elem| filter.filter(elem, &*root)) elem.map_or(false, |elem| filter.filter(elem, *root))
}).count() as u32 }).count() as u32
} }
} }
@ -197,13 +197,13 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
let root = root.root(); let root = root.root();
root.deref().traverse_preorder() root.deref().traverse_preorder()
.filter_map(|node| { .filter_map(|node| {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&node); let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
elem.filtered(|&elem| filter.filter(elem, &*root)) elem.filtered(|&elem| filter.filter(elem, *root))
.map(|elem| elem.clone()) .map(|elem| elem.clone())
}) })
.nth(index as uint) .nth(index as uint)
.clone() .clone()
.map(|elem| Temporary::from_rooted(&elem)) .map(|elem| Temporary::from_rooted(elem))
} }
} }
} }
@ -222,19 +222,19 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
.find(|elem| { .find(|elem| {
elem.get_string_attribute("name") == key || elem.get_string_attribute("name") == key ||
elem.get_string_attribute("id") == key }) elem.get_string_attribute("id") == key })
.map(|maybe_elem| Temporary::from_rooted(&*maybe_elem)), .map(|maybe_elem| Temporary::from_rooted(*maybe_elem)),
Live(ref root, ref filter) => { Live(ref root, ref filter) => {
let root = root.root(); let root = root.root();
root.deref().traverse_preorder() root.deref().traverse_preorder()
.filter_map(|node| { .filter_map(|node| {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&node); let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
elem.filtered(|&elem| filter.filter(elem, &*root)) elem.filtered(|&elem| filter.filter(elem, *root))
.map(|elem| elem.clone()) .map(|elem| elem.clone())
}) })
.find(|elem| { .find(|elem| {
elem.get_string_attribute("name") == key || elem.get_string_attribute("name") == key ||
elem.get_string_attribute("id") == key }) elem.get_string_attribute("id") == key })
.map(|maybe_elem| Temporary::from_rooted(&maybe_elem)) .map(|maybe_elem| Temporary::from_rooted(maybe_elem))
} }
} }
} }

View file

@ -26,14 +26,14 @@ impl HTMLDataElementDerived for EventTarget {
} }
impl HTMLDataElement { impl HTMLDataElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDataElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDataElement {
HTMLDataElement { HTMLDataElement {
htmlelement: HTMLElement::new_inherited(HTMLDataElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDataElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDataElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDataElement> {
let element = HTMLDataElement::new_inherited(localName, document); let element = HTMLDataElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLDataElementBinding::Wrap) Node::reflect_node(box element, document, HTMLDataElementBinding::Wrap)
} }

View file

@ -29,14 +29,14 @@ impl HTMLDataListElementDerived for EventTarget {
} }
impl HTMLDataListElement { impl HTMLDataListElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDataListElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDataListElement {
HTMLDataListElement { HTMLDataListElement {
htmlelement: HTMLElement::new_inherited(HTMLDataListElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDataListElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDataListElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDataListElement> {
let element = HTMLDataListElement::new_inherited(localName, document); let element = HTMLDataListElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLDataListElementBinding::Wrap) Node::reflect_node(box element, document, HTMLDataListElementBinding::Wrap)
} }
@ -46,14 +46,14 @@ impl<'a> HTMLDataListElementMethods for JSRef<'a, HTMLDataListElement> {
fn Options(&self) -> Temporary<HTMLCollection> { fn Options(&self) -> Temporary<HTMLCollection> {
struct HTMLDataListOptionsFilter; struct HTMLDataListOptionsFilter;
impl CollectionFilter for HTMLDataListOptionsFilter { impl CollectionFilter for HTMLDataListOptionsFilter {
fn filter(&self, elem: &JSRef<Element>, _root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
elem.is_htmloptionelement() elem.is_htmloptionelement()
} }
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let filter = box HTMLDataListOptionsFilter; let filter = box HTMLDataListOptionsFilter;
let window = window_from_node(node).root(); let window = window_from_node(node).root();
HTMLCollection::create(&*window, node, filter) HTMLCollection::create(*window, node, filter)
} }
} }

View file

@ -26,14 +26,14 @@ impl HTMLDirectoryElementDerived for EventTarget {
} }
impl HTMLDirectoryElement { impl HTMLDirectoryElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDirectoryElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDirectoryElement {
HTMLDirectoryElement { HTMLDirectoryElement {
htmlelement: HTMLElement::new_inherited(HTMLDirectoryElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDirectoryElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDirectoryElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDirectoryElement> {
let element = HTMLDirectoryElement::new_inherited(localName, document); let element = HTMLDirectoryElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLDirectoryElementBinding::Wrap) Node::reflect_node(box element, document, HTMLDirectoryElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLDivElementDerived for EventTarget {
} }
impl HTMLDivElement { impl HTMLDivElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDivElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDivElement {
HTMLDivElement { HTMLDivElement {
htmlelement: HTMLElement::new_inherited(HTMLDivElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDivElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDivElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDivElement> {
let element = HTMLDivElement::new_inherited(localName, document); let element = HTMLDivElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLDivElementBinding::Wrap) Node::reflect_node(box element, document, HTMLDivElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLDListElementDerived for EventTarget {
} }
impl HTMLDListElement { impl HTMLDListElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDListElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDListElement {
HTMLDListElement { HTMLDListElement {
htmlelement: HTMLElement::new_inherited(HTMLDListElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLDListElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLDListElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDListElement> {
let element = HTMLDListElement::new_inherited(localName, document); let element = HTMLDListElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLDListElementBinding::Wrap) Node::reflect_node(box element, document, HTMLDListElementBinding::Wrap)
} }

View file

@ -38,14 +38,14 @@ impl HTMLElementDerived for EventTarget {
} }
impl HTMLElement { impl HTMLElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: &JSRef<Document>) -> HTMLElement { pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: JSRef<Document>) -> HTMLElement {
HTMLElement { HTMLElement {
element: Element::new_inherited(type_id, tag_name, namespace::HTML, None, document) element: Element::new_inherited(type_id, tag_name, namespace::HTML, None, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLElement> {
let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, document); let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, document);
Node::reflect_node(box element, document, HTMLElementBinding::Wrap) Node::reflect_node(box element, document, HTMLElementBinding::Wrap)
} }
@ -57,25 +57,25 @@ trait PrivateHTMLElementHelpers {
impl<'a> PrivateHTMLElementHelpers for JSRef<'a, HTMLElement> { impl<'a> PrivateHTMLElementHelpers for JSRef<'a, HTMLElement> {
fn is_body_or_frameset(&self) -> bool { fn is_body_or_frameset(&self) -> bool {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.is_htmlbodyelement() || eventtarget.is_htmlframesetelement() eventtarget.is_htmlbodyelement() || eventtarget.is_htmlframesetelement()
} }
} }
impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> { impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
fn GetOnclick(&self) -> Option<EventHandlerNonNull> { fn GetOnclick(&self) -> Option<EventHandlerNonNull> {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.get_event_handler_common("click") eventtarget.get_event_handler_common("click")
} }
fn SetOnclick(&self, listener: Option<EventHandlerNonNull>) { fn SetOnclick(&self, listener: Option<EventHandlerNonNull>) {
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let eventtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
eventtarget.set_event_handler_common("click", listener) eventtarget.set_event_handler_common("click", listener)
} }
fn GetOnload(&self) -> Option<EventHandlerNonNull> { fn GetOnload(&self) -> Option<EventHandlerNonNull> {
if self.is_body_or_frameset() { if self.is_body_or_frameset() {
let win = window_from_node(self).root(); let win = window_from_node(*self).root();
win.deref().GetOnload() win.deref().GetOnload()
} else { } else {
None None
@ -84,7 +84,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
fn SetOnload(&self, listener: Option<EventHandlerNonNull>) { fn SetOnload(&self, listener: Option<EventHandlerNonNull>) {
if self.is_body_or_frameset() { if self.is_body_or_frameset() {
let win = window_from_node(self).root(); let win = window_from_node(*self).root();
win.deref().SetOnload(listener) win.deref().SetOnload(listener)
} }
} }
@ -92,7 +92,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
impl<'a> VirtualMethods for JSRef<'a, HTMLElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: &JSRef<Element> = ElementCast::from_borrowed_ref(self);
Some(element as &VirtualMethods) Some(element as &VirtualMethods)
} }
@ -103,11 +103,11 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
} }
if name.as_slice().starts_with("on") { if name.as_slice().starts_with("on") {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
let (cx, url, reflector) = (window.get_cx(), let (cx, url, reflector) = (window.get_cx(),
window.get_url(), window.get_url(),
window.reflector().get_jsobject()); window.reflector().get_jsobject());
let evtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self); let evtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
evtarget.set_event_handler_uncompiled(cx, url, reflector, evtarget.set_event_handler_uncompiled(cx, url, reflector,
name.as_slice().slice_from(2), name.as_slice().slice_from(2),
value); value);

View file

@ -26,14 +26,14 @@ impl HTMLEmbedElementDerived for EventTarget {
} }
impl HTMLEmbedElement { impl HTMLEmbedElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLEmbedElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLEmbedElement {
HTMLEmbedElement { HTMLEmbedElement {
htmlelement: HTMLElement::new_inherited(HTMLEmbedElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLEmbedElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLEmbedElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLEmbedElement> {
let element = HTMLEmbedElement::new_inherited(localName, document); let element = HTMLEmbedElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLEmbedElementBinding::Wrap) Node::reflect_node(box element, document, HTMLEmbedElementBinding::Wrap)
} }

View file

@ -34,14 +34,14 @@ impl HTMLFieldSetElementDerived for EventTarget {
} }
impl HTMLFieldSetElement { impl HTMLFieldSetElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFieldSetElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFieldSetElement {
HTMLFieldSetElement { HTMLFieldSetElement {
htmlelement: HTMLElement::new_inherited(HTMLFieldSetElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFieldSetElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFieldSetElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLFieldSetElement> {
let element = HTMLFieldSetElement::new_inherited(localName, document); let element = HTMLFieldSetElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLFieldSetElementBinding::Wrap) Node::reflect_node(box element, document, HTMLFieldSetElementBinding::Wrap)
} }
@ -52,22 +52,22 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
fn Elements(&self) -> Temporary<HTMLCollection> { fn Elements(&self) -> Temporary<HTMLCollection> {
struct ElementsFilter; struct ElementsFilter;
impl CollectionFilter for ElementsFilter { impl CollectionFilter for ElementsFilter {
fn filter(&self, elem: &JSRef<Element>, root: &JSRef<Node>) -> bool { fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool {
static tag_names: StaticStringVec = &["button", "fieldset", "input", static tag_names: StaticStringVec = &["button", "fieldset", "input",
"keygen", "object", "output", "select", "textarea"]; "keygen", "object", "output", "select", "textarea"];
let root: &JSRef<Element> = ElementCast::to_ref(root).unwrap(); let root: JSRef<Element> = ElementCast::to_ref(root).unwrap();
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.deref().local_name.as_slice()) elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.deref().local_name.as_slice())
} }
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let filter = box ElementsFilter; let filter = box ElementsFilter;
let window = window_from_node(node).root(); let window = window_from_node(node).root();
HTMLCollection::create(&*window, node, filter) HTMLCollection::create(*window, node, filter)
} }
fn Validity(&self) -> Temporary<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
ValidityState::new(&*window) ValidityState::new(*window)
} }
// http://www.whatwg.org/html/#dom-fieldset-disabled // http://www.whatwg.org/html/#dom-fieldset-disabled
@ -75,14 +75,14 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
// http://www.whatwg.org/html/#dom-fieldset-disabled // http://www.whatwg.org/html/#dom-fieldset-disabled
fn SetDisabled(&self, disabled: bool) { fn SetDisabled(&self, disabled: bool) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_bool_attribute("disabled", disabled) elem.set_bool_attribute("disabled", disabled)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -92,7 +92,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(true); node.set_disabled_state(true);
@ -124,7 +124,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(false); node.set_disabled_state(false);

View file

@ -26,14 +26,14 @@ impl HTMLFontElementDerived for EventTarget {
} }
impl HTMLFontElement { impl HTMLFontElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFontElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFontElement {
HTMLFontElement { HTMLFontElement {
htmlelement: HTMLElement::new_inherited(HTMLFontElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFontElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFontElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLFontElement> {
let element = HTMLFontElement::new_inherited(localName, document); let element = HTMLFontElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLFontElementBinding::Wrap) Node::reflect_node(box element, document, HTMLFontElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLFormElementDerived for EventTarget {
} }
impl HTMLFormElement { impl HTMLFormElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFormElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFormElement {
HTMLFormElement { HTMLFormElement {
htmlelement: HTMLElement::new_inherited(HTMLFormElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFormElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFormElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLFormElement> {
let element = HTMLFormElement::new_inherited(localName, document); let element = HTMLFormElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLFormElementBinding::Wrap) Node::reflect_node(box element, document, HTMLFormElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLFrameElementDerived for EventTarget {
} }
impl HTMLFrameElement { impl HTMLFrameElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFrameElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFrameElement {
HTMLFrameElement { HTMLFrameElement {
htmlelement: HTMLElement::new_inherited(HTMLFrameElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFrameElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFrameElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLFrameElement> {
let element = HTMLFrameElement::new_inherited(localName, document); let element = HTMLFrameElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLFrameElementBinding::Wrap) Node::reflect_node(box element, document, HTMLFrameElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLFrameSetElementDerived for EventTarget {
} }
impl HTMLFrameSetElement { impl HTMLFrameSetElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFrameSetElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFrameSetElement {
HTMLFrameSetElement { HTMLFrameSetElement {
htmlelement: HTMLElement::new_inherited(HTMLFrameSetElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLFrameSetElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFrameSetElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLFrameSetElement> {
let element = HTMLFrameSetElement::new_inherited(localName, document); let element = HTMLFrameSetElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLFrameSetElementBinding::Wrap) Node::reflect_node(box element, document, HTMLFrameSetElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLHeadElementDerived for EventTarget {
} }
impl HTMLHeadElement { impl HTMLHeadElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHeadElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLHeadElement {
HTMLHeadElement { HTMLHeadElement {
htmlelement: HTMLElement::new_inherited(HTMLHeadElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLHeadElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLHeadElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLHeadElement> {
let element = HTMLHeadElement::new_inherited(localName, document); let element = HTMLHeadElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLHeadElementBinding::Wrap) Node::reflect_node(box element, document, HTMLHeadElementBinding::Wrap)
} }

View file

@ -37,7 +37,7 @@ impl HTMLHeadingElementDerived for EventTarget {
} }
impl HTMLHeadingElement { impl HTMLHeadingElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>, level: HeadingLevel) -> HTMLHeadingElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>, level: HeadingLevel) -> HTMLHeadingElement {
HTMLHeadingElement { HTMLHeadingElement {
htmlelement: HTMLElement::new_inherited(HTMLHeadingElementTypeId, localName, document), htmlelement: HTMLElement::new_inherited(HTMLHeadingElementTypeId, localName, document),
level: level, level: level,
@ -45,7 +45,7 @@ impl HTMLHeadingElement {
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>, level: HeadingLevel) -> Temporary<HTMLHeadingElement> { pub fn new(localName: DOMString, document: JSRef<Document>, level: HeadingLevel) -> Temporary<HTMLHeadingElement> {
let element = HTMLHeadingElement::new_inherited(localName, document, level); let element = HTMLHeadingElement::new_inherited(localName, document, level);
Node::reflect_node(box element, document, HTMLHeadingElementBinding::Wrap) Node::reflect_node(box element, document, HTMLHeadingElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLHRElementDerived for EventTarget {
} }
impl HTMLHRElement { impl HTMLHRElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHRElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLHRElement {
HTMLHRElement { HTMLHRElement {
htmlelement: HTMLElement::new_inherited(HTMLHRElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLHRElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLHRElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLHRElement> {
let element = HTMLHRElement::new_inherited(localName, document); let element = HTMLHRElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLHRElementBinding::Wrap) Node::reflect_node(box element, document, HTMLHRElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLHtmlElementDerived for EventTarget {
} }
impl HTMLHtmlElement { impl HTMLHtmlElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHtmlElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLHtmlElement {
HTMLHtmlElement { HTMLHtmlElement {
htmlelement: HTMLElement::new_inherited(HTMLHtmlElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLHtmlElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLHtmlElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLHtmlElement> {
let element = HTMLHtmlElement::new_inherited(localName, document); let element = HTMLHtmlElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLHtmlElementBinding::Wrap) Node::reflect_node(box element, document, HTMLHtmlElementBinding::Wrap)
} }

View file

@ -74,13 +74,13 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
} }
fn get_url(&self) -> Option<Url> { fn get_url(&self) -> Option<Url> {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.get_attribute(Null, "src").root().and_then(|src| { element.get_attribute(Null, "src").root().and_then(|src| {
let url = src.deref().value(); let url = src.deref().value();
if url.as_slice().is_empty() { if url.as_slice().is_empty() {
None None
} else { } else {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
UrlParser::new().base_url(&window.deref().page().get_url()) UrlParser::new().base_url(&window.deref().page().get_url())
.parse(url.as_slice()).ok() .parse(url.as_slice()).ok()
} }
@ -100,7 +100,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
}; };
// Subpage Id // Subpage Id
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
let page = window.deref().page(); let page = window.deref().page();
let subpage_id = page.get_next_subpage_id(); let subpage_id = page.get_next_subpage_id();
@ -115,7 +115,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
} }
impl HTMLIFrameElement { impl HTMLIFrameElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLIFrameElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLIFrameElement {
HTMLIFrameElement { HTMLIFrameElement {
htmlelement: HTMLElement::new_inherited(HTMLIFrameElementTypeId, localName, document), htmlelement: HTMLElement::new_inherited(HTMLIFrameElementTypeId, localName, document),
size: Traceable::new(Cell::new(None)), size: Traceable::new(Cell::new(None)),
@ -124,7 +124,7 @@ impl HTMLIFrameElement {
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLIFrameElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLIFrameElement> {
let element = HTMLIFrameElement::new_inherited(localName, document); let element = HTMLIFrameElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLIFrameElementBinding::Wrap) Node::reflect_node(box element, document, HTMLIFrameElementBinding::Wrap)
} }
@ -132,28 +132,28 @@ impl HTMLIFrameElement {
impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> { impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
fn Src(&self) -> DOMString { fn Src(&self) -> DOMString {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.get_string_attribute("src") element.get_string_attribute("src")
} }
fn SetSrc(&self, src: DOMString) { fn SetSrc(&self, src: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_url_attribute("src", src) element.set_url_attribute("src", src)
} }
fn Sandbox(&self) -> DOMString { fn Sandbox(&self) -> DOMString {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.get_string_attribute("sandbox") element.get_string_attribute("sandbox")
} }
fn SetSandbox(&self, sandbox: DOMString) { fn SetSandbox(&self, sandbox: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_string_attribute("sandbox", sandbox); element.set_string_attribute("sandbox", sandbox);
} }
fn GetContentWindow(&self) -> Option<Temporary<Window>> { fn GetContentWindow(&self) -> Option<Temporary<Window>> {
self.size.deref().get().and_then(|size| { self.size.deref().get().and_then(|size| {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
let children = &*window.deref().page.children.deref().borrow(); let children = &*window.deref().page.children.deref().borrow();
let child = children.iter().find(|child| { let child = children.iter().find(|child| {
child.subpage_id.unwrap() == size.subpage_id child.subpage_id.unwrap() == size.subpage_id
@ -169,7 +169,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -196,7 +196,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
} }
if "src" == name.as_slice() { if "src" == name.as_slice() {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() { if node.is_in_doc() {
self.process_the_iframe_attributes() self.process_the_iframe_attributes()
} }

View file

@ -46,7 +46,7 @@ impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> {
/// Makes the local `image` member match the status of the `src` attribute and starts /// Makes the local `image` member match the status of the `src` attribute and starts
/// prefetching the image. This method must be called after `src` is changed. /// prefetching the image. This method must be called after `src` is changed.
fn update_image(&self, value: Option<(DOMString, &Url)>) { fn update_image(&self, value: Option<(DOMString, &Url)>) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let document = node.owner_doc().root(); let document = node.owner_doc().root();
let window = document.deref().window.root(); let window = document.deref().window.root();
let image_cache = &window.image_cache_task; let image_cache = &window.image_cache_task;
@ -72,7 +72,7 @@ impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> {
} }
impl HTMLImageElement { impl HTMLImageElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLImageElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLImageElement {
HTMLImageElement { HTMLImageElement {
htmlelement: HTMLElement::new_inherited(HTMLImageElementTypeId, localName, document), htmlelement: HTMLElement::new_inherited(HTMLImageElementTypeId, localName, document),
image: Untraceable::new(RefCell::new(None)), image: Untraceable::new(RefCell::new(None)),
@ -80,7 +80,7 @@ impl HTMLImageElement {
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLImageElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLImageElement> {
let element = HTMLImageElement::new_inherited(localName, document); let element = HTMLImageElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLImageElementBinding::Wrap) Node::reflect_node(box element, document, HTMLImageElementBinding::Wrap)
} }
@ -100,99 +100,99 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
make_getter!(Alt) make_getter!(Alt)
fn SetAlt(&self, alt: DOMString) { fn SetAlt(&self, alt: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_string_attribute("alt", alt) element.set_string_attribute("alt", alt)
} }
make_getter!(Src) make_getter!(Src)
fn SetSrc(&self, src: DOMString) { fn SetSrc(&self, src: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_url_attribute("src", src) element.set_url_attribute("src", src)
} }
make_getter!(UseMap) make_getter!(UseMap)
fn SetUseMap(&self, use_map: DOMString) { fn SetUseMap(&self, use_map: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_string_attribute("usemap", use_map) element.set_string_attribute("usemap", use_map)
} }
make_bool_getter!(IsMap) make_bool_getter!(IsMap)
fn SetIsMap(&self, is_map: bool) { fn SetIsMap(&self, is_map: bool) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_string_attribute("ismap", is_map.to_string()) element.set_string_attribute("ismap", is_map.to_string())
} }
fn Width(&self) -> u32 { fn Width(&self) -> u32 {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let rect = node.get_bounding_content_box(); let rect = node.get_bounding_content_box();
to_px(rect.size.width) as u32 to_px(rect.size.width) as u32
} }
fn SetWidth(&self, width: u32) { fn SetWidth(&self, width: u32) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_uint_attribute("width", width) elem.set_uint_attribute("width", width)
} }
fn Height(&self) -> u32 { fn Height(&self) -> u32 {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let rect = node.get_bounding_content_box(); let rect = node.get_bounding_content_box();
to_px(rect.size.height) as u32 to_px(rect.size.height) as u32
} }
fn SetHeight(&self, height: u32) { fn SetHeight(&self, height: u32) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_uint_attribute("height", height) elem.set_uint_attribute("height", height)
} }
make_getter!(Name) make_getter!(Name)
fn SetName(&self, name: DOMString) { fn SetName(&self, name: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_string_attribute("name", name) element.set_string_attribute("name", name)
} }
make_getter!(Align) make_getter!(Align)
fn SetAlign(&self, align: DOMString) { fn SetAlign(&self, align: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_string_attribute("align", align) element.set_string_attribute("align", align)
} }
make_uint_getter!(Hspace) make_uint_getter!(Hspace)
fn SetHspace(&self, hspace: u32) { fn SetHspace(&self, hspace: u32) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_uint_attribute("hspace", hspace) element.set_uint_attribute("hspace", hspace)
} }
make_uint_getter!(Vspace) make_uint_getter!(Vspace)
fn SetVspace(&self, vspace: u32) { fn SetVspace(&self, vspace: u32) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_uint_attribute("vspace", vspace) element.set_uint_attribute("vspace", vspace)
} }
make_getter!(LongDesc) make_getter!(LongDesc)
fn SetLongDesc(&self, longdesc: DOMString) { fn SetLongDesc(&self, longdesc: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_string_attribute("longdesc", longdesc) element.set_string_attribute("longdesc", longdesc)
} }
make_getter!(Border) make_getter!(Border)
fn SetBorder(&self, border: DOMString) { fn SetBorder(&self, border: DOMString) {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.set_string_attribute("border", border) element.set_string_attribute("border", border)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -203,7 +203,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
} }
if "src" == name.as_slice() { if "src" == name.as_slice() {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
let url = window.deref().get_url(); let url = window.deref().get_url();
self.update_image(Some((value, &url))); self.update_image(Some((value, &url)));
} }

View file

@ -31,14 +31,14 @@ impl HTMLInputElementDerived for EventTarget {
} }
impl HTMLInputElement { impl HTMLInputElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLInputElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLInputElement {
HTMLInputElement { HTMLInputElement {
htmlelement: HTMLElement::new_inherited(HTMLInputElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLInputElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLInputElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLInputElement> {
let element = HTMLInputElement::new_inherited(localName, document); let element = HTMLInputElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLInputElementBinding::Wrap) Node::reflect_node(box element, document, HTMLInputElementBinding::Wrap)
} }
@ -50,14 +50,14 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> {
// http://www.whatwg.org/html/#dom-fe-disabled // http://www.whatwg.org/html/#dom-fe-disabled
fn SetDisabled(&self, disabled: bool) { fn SetDisabled(&self, disabled: bool) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_bool_attribute("disabled", disabled) elem.set_bool_attribute("disabled", disabled)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -67,7 +67,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(true); node.set_disabled_state(true);
@ -83,7 +83,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(false); node.set_disabled_state(false);
@ -100,7 +100,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.check_ancestors_disabled_state_for_form_control(); node.check_ancestors_disabled_state_for_form_control();
} }
@ -110,7 +110,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) { if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) {
node.check_ancestors_disabled_state_for_form_control(); node.check_ancestors_disabled_state_for_form_control();
} else { } else {

View file

@ -26,14 +26,14 @@ impl HTMLLabelElementDerived for EventTarget {
} }
impl HTMLLabelElement { impl HTMLLabelElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLabelElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLLabelElement {
HTMLLabelElement { HTMLLabelElement {
htmlelement: HTMLElement::new_inherited(HTMLLabelElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLLabelElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLLabelElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLLabelElement> {
let element = HTMLLabelElement::new_inherited(localName, document); let element = HTMLLabelElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLLabelElementBinding::Wrap) Node::reflect_node(box element, document, HTMLLabelElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLLegendElementDerived for EventTarget {
} }
impl HTMLLegendElement { impl HTMLLegendElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLegendElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLLegendElement {
HTMLLegendElement { HTMLLegendElement {
htmlelement: HTMLElement::new_inherited(HTMLLegendElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLLegendElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLLegendElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLLegendElement> {
let element = HTMLLegendElement::new_inherited(localName, document); let element = HTMLLegendElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLLegendElementBinding::Wrap) Node::reflect_node(box element, document, HTMLLegendElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLLIElementDerived for EventTarget {
} }
impl HTMLLIElement { impl HTMLLIElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLIElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLLIElement {
HTMLLIElement { HTMLLIElement {
htmlelement: HTMLElement::new_inherited(HTMLLIElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLLIElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLLIElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLLIElement> {
let element = HTMLLIElement::new_inherited(localName, document); let element = HTMLLIElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLLIElementBinding::Wrap) Node::reflect_node(box element, document, HTMLLIElementBinding::Wrap)
} }

View file

@ -35,14 +35,14 @@ impl HTMLLinkElementDerived for EventTarget {
} }
impl HTMLLinkElement { impl HTMLLinkElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLinkElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLLinkElement {
HTMLLinkElement { HTMLLinkElement {
htmlelement: HTMLElement::new_inherited(HTMLLinkElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLLinkElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLLinkElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLLinkElement> {
let element = HTMLLinkElement::new_inherited(localName, document); let element = HTMLLinkElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLLinkElementBinding::Wrap) Node::reflect_node(box element, document, HTMLLinkElementBinding::Wrap)
} }
@ -50,7 +50,7 @@ impl HTMLLinkElement {
impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -60,7 +60,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"href" => node.set_enabled_state(true), "href" => node.set_enabled_state(true),
_ => () _ => ()
@ -73,7 +73,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"href" => node.set_enabled_state(false), "href" => node.set_enabled_state(false),
_ => () _ => ()
@ -87,7 +87,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
} }
if tree_in_doc { if tree_in_doc {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
// FIXME: workaround for https://github.com/mozilla/rust/issues/13246; // FIXME: workaround for https://github.com/mozilla/rust/issues/13246;
// we get unrooting order failures if these are inside the match. // we get unrooting order failures if these are inside the match.
@ -119,7 +119,7 @@ trait PrivateHTMLLinkElementHelpers {
impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> { impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
fn handle_stylesheet_url(&self, href: &str) { fn handle_stylesheet_url(&self, href: &str) {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
match UrlParser::new().base_url(&window.deref().page().get_url()).parse(href) { match UrlParser::new().base_url(&window.deref().page().get_url()).parse(href) {
Ok(url) => { Ok(url) => {
let LayoutChan(ref layout_chan) = *window.deref().page().layout_chan; let LayoutChan(ref layout_chan) = *window.deref().page().layout_chan;

View file

@ -26,14 +26,14 @@ impl HTMLMapElementDerived for EventTarget {
} }
impl HTMLMapElement { impl HTMLMapElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMapElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLMapElement {
HTMLMapElement { HTMLMapElement {
htmlelement: HTMLElement::new_inherited(HTMLMapElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLMapElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLMapElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLMapElement> {
let element = HTMLMapElement::new_inherited(localName, document); let element = HTMLMapElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLMapElementBinding::Wrap) Node::reflect_node(box element, document, HTMLMapElementBinding::Wrap)
} }

View file

@ -29,7 +29,7 @@ impl HTMLMediaElementDerived for EventTarget {
} }
impl HTMLMediaElement { impl HTMLMediaElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: &JSRef<Document>) -> HTMLMediaElement { pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: JSRef<Document>) -> HTMLMediaElement {
HTMLMediaElement { HTMLMediaElement {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, document) htmlelement: HTMLElement::new_inherited(type_id, tag_name, document)
} }

View file

@ -26,14 +26,14 @@ impl HTMLMetaElementDerived for EventTarget {
} }
impl HTMLMetaElement { impl HTMLMetaElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMetaElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLMetaElement {
HTMLMetaElement { HTMLMetaElement {
htmlelement: HTMLElement::new_inherited(HTMLMetaElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLMetaElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLMetaElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLMetaElement> {
let element = HTMLMetaElement::new_inherited(localName, document); let element = HTMLMetaElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLMetaElementBinding::Wrap) Node::reflect_node(box element, document, HTMLMetaElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLMeterElementDerived for EventTarget {
} }
impl HTMLMeterElement { impl HTMLMeterElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMeterElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLMeterElement {
HTMLMeterElement { HTMLMeterElement {
htmlelement: HTMLElement::new_inherited(HTMLMeterElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLMeterElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLMeterElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLMeterElement> {
let element = HTMLMeterElement::new_inherited(localName, document); let element = HTMLMeterElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLMeterElementBinding::Wrap) Node::reflect_node(box element, document, HTMLMeterElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLModElementDerived for EventTarget {
} }
impl HTMLModElement { impl HTMLModElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLModElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLModElement {
HTMLModElement { HTMLModElement {
htmlelement: HTMLElement::new_inherited(HTMLModElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLModElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLModElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLModElement> {
let element = HTMLModElement::new_inherited(localName, document); let element = HTMLModElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLModElementBinding::Wrap) Node::reflect_node(box element, document, HTMLModElementBinding::Wrap)
} }

View file

@ -39,14 +39,14 @@ impl HTMLObjectElementDerived for EventTarget {
} }
impl HTMLObjectElement { impl HTMLObjectElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLObjectElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLObjectElement {
HTMLObjectElement { HTMLObjectElement {
htmlelement: HTMLElement::new_inherited(HTMLObjectElementTypeId, localName, document), htmlelement: HTMLElement::new_inherited(HTMLObjectElementTypeId, localName, document),
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLObjectElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLObjectElement> {
let element = HTMLObjectElement::new_inherited(localName, document); let element = HTMLObjectElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLObjectElementBinding::Wrap) Node::reflect_node(box element, document, HTMLObjectElementBinding::Wrap)
} }
@ -60,7 +60,7 @@ impl<'a> ProcessDataURL for JSRef<'a, HTMLObjectElement> {
// Makes the local `data` member match the status of the `data` attribute and starts // Makes the local `data` member match the status of the `data` attribute and starts
/// prefetching the image. This method must be called after `data` is changed. /// prefetching the image. This method must be called after `data` is changed.
fn process_data_url(&self, image_cache: ImageCacheTask) { fn process_data_url(&self, image_cache: ImageCacheTask) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
// TODO: support other values // TODO: support other values
match (elem.get_attribute(Null, "type").map(|x| x.root().Value()), match (elem.get_attribute(Null, "type").map(|x| x.root().Value()),
@ -84,14 +84,14 @@ pub fn is_image_data(uri: &str) -> bool {
impl<'a> HTMLObjectElementMethods for JSRef<'a, HTMLObjectElement> { impl<'a> HTMLObjectElementMethods for JSRef<'a, HTMLObjectElement> {
fn Validity(&self) -> Temporary<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
ValidityState::new(&*window) ValidityState::new(*window)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -102,7 +102,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
} }
if "data" == name.as_slice() { if "data" == name.as_slice() {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
self.process_data_url(window.deref().image_cache_task.clone()); self.process_data_url(window.deref().image_cache_task.clone());
} }
} }

View file

@ -26,14 +26,14 @@ impl HTMLOListElementDerived for EventTarget {
} }
impl HTMLOListElement { impl HTMLOListElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOListElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLOListElement {
HTMLOListElement { HTMLOListElement {
htmlelement: HTMLElement::new_inherited(HTMLOListElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLOListElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLOListElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLOListElement> {
let element = HTMLOListElement::new_inherited(localName, document); let element = HTMLOListElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLOListElementBinding::Wrap) Node::reflect_node(box element, document, HTMLOListElementBinding::Wrap)
} }

View file

@ -31,14 +31,14 @@ impl HTMLOptGroupElementDerived for EventTarget {
} }
impl HTMLOptGroupElement { impl HTMLOptGroupElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOptGroupElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLOptGroupElement {
HTMLOptGroupElement { HTMLOptGroupElement {
htmlelement: HTMLElement::new_inherited(HTMLOptGroupElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLOptGroupElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLOptGroupElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLOptGroupElement> {
let element = HTMLOptGroupElement::new_inherited(localName, document); let element = HTMLOptGroupElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLOptGroupElementBinding::Wrap) Node::reflect_node(box element, document, HTMLOptGroupElementBinding::Wrap)
} }
@ -50,14 +50,14 @@ impl<'a> HTMLOptGroupElementMethods for JSRef<'a, HTMLOptGroupElement> {
// http://www.whatwg.org/html#dom-optgroup-disabled // http://www.whatwg.org/html#dom-optgroup-disabled
fn SetDisabled(&self, disabled: bool) { fn SetDisabled(&self, disabled: bool) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_bool_attribute("disabled", disabled) elem.set_bool_attribute("disabled", disabled)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -67,7 +67,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(true); node.set_disabled_state(true);
@ -87,7 +87,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(false); node.set_disabled_state(false);

View file

@ -31,14 +31,14 @@ impl HTMLOptionElementDerived for EventTarget {
} }
impl HTMLOptionElement { impl HTMLOptionElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOptionElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLOptionElement {
HTMLOptionElement { HTMLOptionElement {
htmlelement: HTMLElement::new_inherited(HTMLOptionElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLOptionElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLOptionElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLOptionElement> {
let element = HTMLOptionElement::new_inherited(localName, document); let element = HTMLOptionElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLOptionElementBinding::Wrap) Node::reflect_node(box element, document, HTMLOptionElementBinding::Wrap)
} }
@ -50,14 +50,14 @@ impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> {
// http://www.whatwg.org/html/#dom-option-disabled // http://www.whatwg.org/html/#dom-option-disabled
fn SetDisabled(&self, disabled: bool) { fn SetDisabled(&self, disabled: bool) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_bool_attribute("disabled", disabled) elem.set_bool_attribute("disabled", disabled)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -67,7 +67,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(true); node.set_disabled_state(true);
@ -83,7 +83,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(false); node.set_disabled_state(false);
@ -100,7 +100,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.check_parent_disabled_state_for_option(); node.check_parent_disabled_state_for_option();
} }
@ -110,7 +110,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.parent_node().is_some() { if node.parent_node().is_some() {
node.check_parent_disabled_state_for_option(); node.check_parent_disabled_state_for_option();
} else { } else {

View file

@ -28,14 +28,14 @@ impl HTMLOutputElementDerived for EventTarget {
} }
impl HTMLOutputElement { impl HTMLOutputElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOutputElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLOutputElement {
HTMLOutputElement { HTMLOutputElement {
htmlelement: HTMLElement::new_inherited(HTMLOutputElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLOutputElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLOutputElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLOutputElement> {
let element = HTMLOutputElement::new_inherited(localName, document); let element = HTMLOutputElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLOutputElementBinding::Wrap) Node::reflect_node(box element, document, HTMLOutputElementBinding::Wrap)
} }
@ -43,8 +43,8 @@ impl HTMLOutputElement {
impl<'a> HTMLOutputElementMethods for JSRef<'a, HTMLOutputElement> { impl<'a> HTMLOutputElementMethods for JSRef<'a, HTMLOutputElement> {
fn Validity(&self) -> Temporary<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
ValidityState::new(&*window) ValidityState::new(*window)
} }
} }

View file

@ -26,14 +26,14 @@ impl HTMLParagraphElementDerived for EventTarget {
} }
impl HTMLParagraphElement { impl HTMLParagraphElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLParagraphElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLParagraphElement {
HTMLParagraphElement { HTMLParagraphElement {
htmlelement: HTMLElement::new_inherited(HTMLParagraphElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLParagraphElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLParagraphElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLParagraphElement> {
let element = HTMLParagraphElement::new_inherited(localName, document); let element = HTMLParagraphElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLParagraphElementBinding::Wrap) Node::reflect_node(box element, document, HTMLParagraphElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLParamElementDerived for EventTarget {
} }
impl HTMLParamElement { impl HTMLParamElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLParamElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLParamElement {
HTMLParamElement { HTMLParamElement {
htmlelement: HTMLElement::new_inherited(HTMLParamElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLParamElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLParamElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLParamElement> {
let element = HTMLParamElement::new_inherited(localName, document); let element = HTMLParamElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLParamElementBinding::Wrap) Node::reflect_node(box element, document, HTMLParamElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLPreElementDerived for EventTarget {
} }
impl HTMLPreElement { impl HTMLPreElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLPreElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLPreElement {
HTMLPreElement { HTMLPreElement {
htmlelement: HTMLElement::new_inherited(HTMLPreElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLPreElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLPreElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLPreElement> {
let element = HTMLPreElement::new_inherited(localName, document); let element = HTMLPreElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLPreElementBinding::Wrap) Node::reflect_node(box element, document, HTMLPreElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLProgressElementDerived for EventTarget {
} }
impl HTMLProgressElement { impl HTMLProgressElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLProgressElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLProgressElement {
HTMLProgressElement { HTMLProgressElement {
htmlelement: HTMLElement::new_inherited(HTMLProgressElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLProgressElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLProgressElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLProgressElement> {
let element = HTMLProgressElement::new_inherited(localName, document); let element = HTMLProgressElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLProgressElementBinding::Wrap) Node::reflect_node(box element, document, HTMLProgressElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLQuoteElementDerived for EventTarget {
} }
impl HTMLQuoteElement { impl HTMLQuoteElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLQuoteElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLQuoteElement {
HTMLQuoteElement { HTMLQuoteElement {
htmlelement: HTMLElement::new_inherited(HTMLQuoteElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLQuoteElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLQuoteElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLQuoteElement> {
let element = HTMLQuoteElement::new_inherited(localName, document); let element = HTMLQuoteElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLQuoteElementBinding::Wrap) Node::reflect_node(box element, document, HTMLQuoteElementBinding::Wrap)
} }

View file

@ -32,14 +32,14 @@ impl HTMLScriptElementDerived for EventTarget {
} }
impl HTMLScriptElement { impl HTMLScriptElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLScriptElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLScriptElement {
HTMLScriptElement { HTMLScriptElement {
htmlelement: HTMLElement::new_inherited(HTMLScriptElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLScriptElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLScriptElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLScriptElement> {
let element = HTMLScriptElement::new_inherited(localName, document); let element = HTMLScriptElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLScriptElementBinding::Wrap) Node::reflect_node(box element, document, HTMLScriptElementBinding::Wrap)
} }
@ -74,7 +74,7 @@ static SCRIPT_JS_MIMES: StaticStringVec = &[
impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> { impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
fn is_javascript(&self) -> bool { fn is_javascript(&self) -> bool {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
match element.get_attribute(Null, "type").root().map(|s| s.Value()) { match element.get_attribute(Null, "type").root().map(|s| s.Value()) {
Some(ref s) if s.is_empty() => { Some(ref s) if s.is_empty() => {
// type attr exists, but empty means js // type attr exists, but empty means js
@ -108,19 +108,19 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
impl<'a> HTMLScriptElementMethods for JSRef<'a, HTMLScriptElement> { impl<'a> HTMLScriptElementMethods for JSRef<'a, HTMLScriptElement> {
fn Src(&self) -> DOMString { fn Src(&self) -> DOMString {
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.get_url_attribute("src") element.get_url_attribute("src")
} }
// http://www.whatwg.org/html/#dom-script-text // http://www.whatwg.org/html/#dom-script-text
fn Text(&self) -> DOMString { fn Text(&self) -> DOMString {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
Node::collect_text_contents(node.children()) Node::collect_text_contents(node.children())
} }
// http://www.whatwg.org/html/#dom-script-text // http://www.whatwg.org/html/#dom-script-text
fn SetText(&self, value: DOMString) { fn SetText(&self, value: DOMString) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.SetTextContent(Some(value)) node.SetTextContent(Some(value))
} }
} }

View file

@ -34,14 +34,14 @@ impl HTMLSelectElementDerived for EventTarget {
} }
impl HTMLSelectElement { impl HTMLSelectElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSelectElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLSelectElement {
HTMLSelectElement { HTMLSelectElement {
htmlelement: HTMLElement::new_inherited(HTMLSelectElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLSelectElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLSelectElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLSelectElement> {
let element = HTMLSelectElement::new_inherited(localName, document); let element = HTMLSelectElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLSelectElementBinding::Wrap) Node::reflect_node(box element, document, HTMLSelectElementBinding::Wrap)
} }
@ -49,8 +49,8 @@ impl HTMLSelectElement {
impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> { impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> {
fn Validity(&self) -> Temporary<ValidityState> { fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root(); let window = window_from_node(*self).root();
ValidityState::new(&*window) ValidityState::new(*window)
} }
// Note: this function currently only exists for test_union.html. // Note: this function currently only exists for test_union.html.
@ -62,14 +62,14 @@ impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> {
// http://www.whatwg.org/html/#dom-fe-disabled // http://www.whatwg.org/html/#dom-fe-disabled
fn SetDisabled(&self, disabled: bool) { fn SetDisabled(&self, disabled: bool) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_bool_attribute("disabled", disabled) elem.set_bool_attribute("disabled", disabled)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -79,7 +79,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(true); node.set_disabled_state(true);
@ -95,7 +95,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(false); node.set_disabled_state(false);
@ -112,7 +112,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.check_ancestors_disabled_state_for_form_control(); node.check_ancestors_disabled_state_for_form_control();
} }
@ -122,7 +122,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) { if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) {
node.check_ancestors_disabled_state_for_form_control(); node.check_ancestors_disabled_state_for_form_control();
} else { } else {

View file

@ -34,24 +34,24 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
} }
match node.type_id() { match node.type_id() {
ElementNodeTypeId(..) => { ElementNodeTypeId(..) => {
let elem: &JSRef<Element> = ElementCast::to_ref(&node).unwrap(); let elem: JSRef<Element> = ElementCast::to_ref(node).unwrap();
serialize_elem(elem, &mut open_elements, &mut html) serialize_elem(elem, &mut open_elements, &mut html)
} }
CommentNodeTypeId => { CommentNodeTypeId => {
let comment: &JSRef<Comment> = CommentCast::to_ref(&node).unwrap(); let comment: JSRef<Comment> = CommentCast::to_ref(node).unwrap();
serialize_comment(comment, &mut html) serialize_comment(comment, &mut html)
} }
TextNodeTypeId => { TextNodeTypeId => {
let text: &JSRef<Text> = TextCast::to_ref(&node).unwrap(); let text: JSRef<Text> = TextCast::to_ref(node).unwrap();
serialize_text(text, &mut html) serialize_text(text, &mut html)
} }
DoctypeNodeTypeId => { DoctypeNodeTypeId => {
let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(&node).unwrap(); let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
serialize_doctype(doctype, &mut html) serialize_doctype(doctype, &mut html)
} }
ProcessingInstructionNodeTypeId => { ProcessingInstructionNodeTypeId => {
let processing_instruction: &JSRef<ProcessingInstruction> = let processing_instruction: JSRef<ProcessingInstruction> =
ProcessingInstructionCast::to_ref(&node).unwrap(); ProcessingInstructionCast::to_ref(node).unwrap();
serialize_processing_instruction(processing_instruction, &mut html) serialize_processing_instruction(processing_instruction, &mut html)
} }
DocumentFragmentNodeTypeId => {} DocumentFragmentNodeTypeId => {}
@ -68,17 +68,17 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
html html
} }
fn serialize_comment(comment: &JSRef<Comment>, html: &mut String) { fn serialize_comment(comment: JSRef<Comment>, html: &mut String) {
html.push_str("<!--"); html.push_str("<!--");
html.push_str(comment.deref().characterdata.data.deref().borrow().as_slice()); html.push_str(comment.deref().characterdata.data.deref().borrow().as_slice());
html.push_str("-->"); html.push_str("-->");
} }
fn serialize_text(text: &JSRef<Text>, html: &mut String) { fn serialize_text(text: JSRef<Text>, html: &mut String) {
let text_node: &JSRef<Node> = NodeCast::from_ref(text); let text_node: JSRef<Node> = NodeCast::from_ref(text);
match text_node.parent_node().map(|node| node.root()) { match text_node.parent_node().map(|node| node.root()) {
Some(ref parent) if parent.is_element() => { Some(ref parent) if parent.is_element() => {
let elem: &JSRef<Element> = ElementCast::to_ref(&**parent).unwrap(); let elem: JSRef<Element> = ElementCast::to_ref(**parent).unwrap();
match elem.deref().local_name.as_slice() { match elem.deref().local_name.as_slice() {
"style" | "script" | "xmp" | "iframe" | "style" | "script" | "xmp" | "iframe" |
"noembed" | "noframes" | "plaintext" | "noembed" | "noframes" | "plaintext" |
@ -91,7 +91,7 @@ fn serialize_text(text: &JSRef<Text>, html: &mut String) {
} }
} }
fn serialize_processing_instruction(processing_instruction: &JSRef<ProcessingInstruction>, fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInstruction>,
html: &mut String) { html: &mut String) {
html.push_str("<?"); html.push_str("<?");
html.push_str(processing_instruction.deref().target.as_slice()); html.push_str(processing_instruction.deref().target.as_slice());
@ -100,27 +100,27 @@ fn serialize_processing_instruction(processing_instruction: &JSRef<ProcessingIns
html.push_str("?>"); html.push_str("?>");
} }
fn serialize_doctype(doctype: &JSRef<DocumentType>, html: &mut String) { fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
html.push_str("<!DOCTYPE"); html.push_str("<!DOCTYPE");
html.push_str(doctype.deref().name.as_slice()); html.push_str(doctype.deref().name.as_slice());
html.push_char('>'); html.push_char('>');
} }
fn serialize_elem(elem: &JSRef<Element>, open_elements: &mut Vec<String>, html: &mut String) { fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &mut String) {
html.push_char('<'); html.push_char('<');
html.push_str(elem.deref().local_name.as_slice()); html.push_str(elem.deref().local_name.as_slice());
for attr in elem.deref().attrs.borrow().iter() { for attr in elem.deref().attrs.borrow().iter() {
let attr = attr.root(); let attr = attr.root();
serialize_attr(&*attr, html); serialize_attr(*attr, html);
}; };
html.push_char('>'); html.push_char('>');
match elem.deref().local_name.as_slice() { match elem.deref().local_name.as_slice() {
"pre" | "listing" | "textarea" if elem.deref().namespace == namespace::HTML => { "pre" | "listing" | "textarea" if elem.deref().namespace == namespace::HTML => {
let node: &JSRef<Node> = NodeCast::from_ref(elem); let node: JSRef<Node> = NodeCast::from_ref(elem);
match node.first_child().map(|child| child.root()) { match node.first_child().map(|child| child.root()) {
Some(ref child) if child.is_text() => { Some(ref child) if child.is_text() => {
let text: &JSRef<CharacterData> = CharacterDataCast::to_ref(&**child).unwrap(); let text: JSRef<CharacterData> = CharacterDataCast::to_ref(**child).unwrap();
if text.deref().data.deref().borrow().len() > 0 && text.deref().data.deref().borrow().as_slice().char_at(0) == '\n' { if text.deref().data.deref().borrow().len() > 0 && text.deref().data.deref().borrow().as_slice().char_at(0) == '\n' {
html.push_char('\x0A'); html.push_char('\x0A');
} }
@ -136,7 +136,7 @@ fn serialize_elem(elem: &JSRef<Element>, open_elements: &mut Vec<String>, html:
} }
} }
fn serialize_attr(attr: &JSRef<Attr>, html: &mut String) { fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
html.push_char(' '); html.push_char(' ');
if attr.deref().namespace == namespace::XML { if attr.deref().namespace == namespace::XML {
html.push_str("xml:"); html.push_str("xml:");

View file

@ -26,14 +26,14 @@ impl HTMLSourceElementDerived for EventTarget {
} }
impl HTMLSourceElement { impl HTMLSourceElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSourceElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLSourceElement {
HTMLSourceElement { HTMLSourceElement {
htmlelement: HTMLElement::new_inherited(HTMLSourceElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLSourceElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLSourceElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLSourceElement> {
let element = HTMLSourceElement::new_inherited(localName, document); let element = HTMLSourceElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLSourceElementBinding::Wrap) Node::reflect_node(box element, document, HTMLSourceElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLSpanElementDerived for EventTarget {
} }
impl HTMLSpanElement { impl HTMLSpanElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSpanElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLSpanElement {
HTMLSpanElement { HTMLSpanElement {
htmlelement: HTMLElement::new_inherited(HTMLSpanElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLSpanElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLSpanElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLSpanElement> {
let element = HTMLSpanElement::new_inherited(localName, document); let element = HTMLSpanElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLSpanElementBinding::Wrap) Node::reflect_node(box element, document, HTMLSpanElementBinding::Wrap)
} }

View file

@ -30,14 +30,14 @@ impl HTMLStyleElementDerived for EventTarget {
} }
impl HTMLStyleElement { impl HTMLStyleElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLStyleElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLStyleElement {
HTMLStyleElement { HTMLStyleElement {
htmlelement: HTMLElement::new_inherited(HTMLStyleElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLStyleElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLStyleElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLStyleElement> {
let element = HTMLStyleElement::new_inherited(localName, document); let element = HTMLStyleElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLStyleElementBinding::Wrap) Node::reflect_node(box element, document, HTMLStyleElementBinding::Wrap)
} }
@ -49,7 +49,7 @@ pub trait StyleElementHelpers {
impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> { impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
fn parse_own_css(&self) { fn parse_own_css(&self) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
assert!(node.is_in_doc()); assert!(node.is_in_doc());
let win = window_from_node(node).root(); let win = window_from_node(node).root();
@ -64,17 +64,17 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
impl<'a> VirtualMethods for JSRef<'a, HTMLStyleElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLStyleElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
fn child_inserted(&self, child: &JSRef<Node>) { fn child_inserted(&self, child: JSRef<Node>) {
match self.super_type() { match self.super_type() {
Some(ref s) => s.child_inserted(child), Some(ref s) => s.child_inserted(child),
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() { if node.is_in_doc() {
self.parse_own_css(); self.parse_own_css();
} }

View file

@ -26,14 +26,14 @@ impl HTMLTableCaptionElementDerived for EventTarget {
} }
impl HTMLTableCaptionElement { impl HTMLTableCaptionElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableCaptionElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableCaptionElement {
HTMLTableCaptionElement { HTMLTableCaptionElement {
htmlelement: HTMLElement::new_inherited(HTMLTableCaptionElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableCaptionElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableCaptionElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTableCaptionElement> {
let element = HTMLTableCaptionElement::new_inherited(localName, document); let element = HTMLTableCaptionElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTableCaptionElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTableCaptionElementBinding::Wrap)
} }

View file

@ -29,7 +29,7 @@ impl HTMLTableCellElementDerived for EventTarget {
} }
impl HTMLTableCellElement { impl HTMLTableCellElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: &JSRef<Document>) -> HTMLTableCellElement { pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: JSRef<Document>) -> HTMLTableCellElement {
HTMLTableCellElement { HTMLTableCellElement {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, document) htmlelement: HTMLElement::new_inherited(type_id, tag_name, document)
} }

View file

@ -26,14 +26,14 @@ impl HTMLTableColElementDerived for EventTarget {
} }
impl HTMLTableColElement { impl HTMLTableColElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableColElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableColElement {
HTMLTableColElement { HTMLTableColElement {
htmlelement: HTMLElement::new_inherited(HTMLTableColElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableColElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableColElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTableColElement> {
let element = HTMLTableColElement::new_inherited(localName, document); let element = HTMLTableColElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTableColElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTableColElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLTableDataCellElementDerived for EventTarget {
} }
impl HTMLTableDataCellElement { impl HTMLTableDataCellElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableDataCellElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableDataCellElement {
HTMLTableDataCellElement { HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document) htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableDataCellElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTableDataCellElement> {
let element = HTMLTableDataCellElement::new_inherited(localName, document); let element = HTMLTableDataCellElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTableDataCellElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTableDataCellElementBinding::Wrap)
} }

View file

@ -30,14 +30,14 @@ impl HTMLTableElementDerived for EventTarget {
} }
impl HTMLTableElement { impl HTMLTableElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableElement {
HTMLTableElement { HTMLTableElement {
htmlelement: HTMLElement::new_inherited(HTMLTableElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTableElement> {
let element = HTMLTableElement::new_inherited(localName, document); let element = HTMLTableElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTableElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTableElementBinding::Wrap)
} }
@ -53,30 +53,30 @@ impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> {
// http://www.whatwg.org/html/#dom-table-caption // http://www.whatwg.org/html/#dom-table-caption
fn GetCaption(&self) -> Option<Temporary<HTMLTableCaptionElement>> { fn GetCaption(&self) -> Option<Temporary<HTMLTableCaptionElement>> {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.children().find(|child| { node.children().find(|child| {
child.type_id() == ElementNodeTypeId(HTMLTableCaptionElementTypeId) child.type_id() == ElementNodeTypeId(HTMLTableCaptionElementTypeId)
}).map(|node| { }).map(|node| {
Temporary::from_rooted(HTMLTableCaptionElementCast::to_ref(&node).unwrap()) Temporary::from_rooted(HTMLTableCaptionElementCast::to_ref(node).unwrap())
}) })
} }
// http://www.whatwg.org/html/#dom-table-caption // http://www.whatwg.org/html/#dom-table-caption
fn SetCaption(&self, new_caption: Option<JSRef<HTMLTableCaptionElement>>) { fn SetCaption(&self, new_caption: Option<JSRef<HTMLTableCaptionElement>>) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let old_caption = self.GetCaption(); let old_caption = self.GetCaption();
match old_caption { match old_caption {
Some(htmlelem) => { Some(htmlelem) => {
let htmlelem_jsref = &*htmlelem.root(); let htmlelem_jsref = &*htmlelem.root();
let old_caption_node: &JSRef<Node> = NodeCast::from_ref(htmlelem_jsref); let old_caption_node: JSRef<Node> = NodeCast::from_ref(*htmlelem_jsref);
assert!(node.RemoveChild(old_caption_node).is_ok()); assert!(node.RemoveChild(old_caption_node).is_ok());
} }
None => () None => ()
} }
new_caption.map(|caption| { new_caption.map(|caption| {
let new_caption_node: &JSRef<Node> = NodeCast::from_ref(&caption); let new_caption_node: JSRef<Node> = NodeCast::from_ref(caption);
assert!(node.AppendChild(new_caption_node).is_ok()); assert!(node.AppendChild(new_caption_node).is_ok());
}); });
} }

View file

@ -26,14 +26,14 @@ impl HTMLTableHeaderCellElementDerived for EventTarget {
} }
impl HTMLTableHeaderCellElement { impl HTMLTableHeaderCellElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableHeaderCellElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableHeaderCellElement {
HTMLTableHeaderCellElement { HTMLTableHeaderCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableHeaderCellElementTypeId, localName, document) htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableHeaderCellElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableHeaderCellElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTableHeaderCellElement> {
let element = HTMLTableHeaderCellElement::new_inherited(localName, document); let element = HTMLTableHeaderCellElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTableHeaderCellElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTableHeaderCellElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLTableRowElementDerived for EventTarget {
} }
impl HTMLTableRowElement { impl HTMLTableRowElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableRowElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableRowElement {
HTMLTableRowElement { HTMLTableRowElement {
htmlelement: HTMLElement::new_inherited(HTMLTableRowElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableRowElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableRowElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTableRowElement> {
let element = HTMLTableRowElement::new_inherited(localName, document); let element = HTMLTableRowElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTableRowElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTableRowElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLTableSectionElementDerived for EventTarget {
} }
impl HTMLTableSectionElement { impl HTMLTableSectionElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableSectionElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableSectionElement {
HTMLTableSectionElement { HTMLTableSectionElement {
htmlelement: HTMLElement::new_inherited(HTMLTableSectionElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTableSectionElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTableSectionElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTableSectionElement> {
let element = HTMLTableSectionElement::new_inherited(localName, document); let element = HTMLTableSectionElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTableSectionElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTableSectionElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLTemplateElementDerived for EventTarget {
} }
impl HTMLTemplateElement { impl HTMLTemplateElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTemplateElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTemplateElement {
HTMLTemplateElement { HTMLTemplateElement {
htmlelement: HTMLElement::new_inherited(HTMLTemplateElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTemplateElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTemplateElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTemplateElement> {
let element = HTMLTemplateElement::new_inherited(localName, document); let element = HTMLTemplateElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTemplateElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTemplateElementBinding::Wrap)
} }

View file

@ -31,14 +31,14 @@ impl HTMLTextAreaElementDerived for EventTarget {
} }
impl HTMLTextAreaElement { impl HTMLTextAreaElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTextAreaElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTextAreaElement {
HTMLTextAreaElement { HTMLTextAreaElement {
htmlelement: HTMLElement::new_inherited(HTMLTextAreaElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTextAreaElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTextAreaElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTextAreaElement> {
let element = HTMLTextAreaElement::new_inherited(localName, document); let element = HTMLTextAreaElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTextAreaElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTextAreaElementBinding::Wrap)
} }
@ -50,14 +50,14 @@ impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> {
// http://www.whatwg.org/html/#dom-fe-disabled // http://www.whatwg.org/html/#dom-fe-disabled
fn SetDisabled(&self, disabled: bool) { fn SetDisabled(&self, disabled: bool) {
let elem: &JSRef<Element> = ElementCast::from_ref(self); let elem: JSRef<Element> = ElementCast::from_ref(*self);
elem.set_bool_attribute("disabled", disabled) elem.set_bool_attribute("disabled", disabled)
} }
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self); let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods) Some(htmlelement as &VirtualMethods)
} }
@ -67,7 +67,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(true); node.set_disabled_state(true);
@ -83,7 +83,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
match name.as_slice() { match name.as_slice() {
"disabled" => { "disabled" => {
node.set_disabled_state(false); node.set_disabled_state(false);
@ -100,7 +100,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.check_ancestors_disabled_state_for_form_control(); node.check_ancestors_disabled_state_for_form_control();
} }
@ -110,7 +110,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
_ => (), _ => (),
} }
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) { if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) {
node.check_ancestors_disabled_state_for_form_control(); node.check_ancestors_disabled_state_for_form_control();
} else { } else {

View file

@ -26,14 +26,14 @@ impl HTMLTimeElementDerived for EventTarget {
} }
impl HTMLTimeElement { impl HTMLTimeElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTimeElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTimeElement {
HTMLTimeElement { HTMLTimeElement {
htmlelement: HTMLElement::new_inherited(HTMLTimeElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTimeElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTimeElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTimeElement> {
let element = HTMLTimeElement::new_inherited(localName, document); let element = HTMLTimeElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTimeElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTimeElementBinding::Wrap)
} }

View file

@ -29,14 +29,14 @@ impl HTMLTitleElementDerived for EventTarget {
} }
impl HTMLTitleElement { impl HTMLTitleElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTitleElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTitleElement {
HTMLTitleElement { HTMLTitleElement {
htmlelement: HTMLElement::new_inherited(HTMLTitleElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTitleElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTitleElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTitleElement> {
let element = HTMLTitleElement::new_inherited(localName, document); let element = HTMLTitleElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTitleElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTitleElementBinding::Wrap)
} }
@ -45,10 +45,10 @@ impl HTMLTitleElement {
impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> { impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
// http://www.whatwg.org/html/#dom-title-text // http://www.whatwg.org/html/#dom-title-text
fn Text(&self) -> DOMString { fn Text(&self) -> DOMString {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
let mut content = String::new(); let mut content = String::new();
for child in node.children() { for child in node.children() {
let text: Option<&JSRef<Text>> = TextCast::to_ref(&child); let text: Option<JSRef<Text>> = TextCast::to_ref(child);
match text { match text {
Some(text) => content.push_str(text.characterdata.data.borrow().as_slice()), Some(text) => content.push_str(text.characterdata.data.borrow().as_slice()),
None => (), None => (),
@ -59,7 +59,7 @@ impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
// http://www.whatwg.org/html/#dom-title-text // http://www.whatwg.org/html/#dom-title-text
fn SetText(&self, value: DOMString) { fn SetText(&self, value: DOMString) {
let node: &JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.SetTextContent(Some(value)) node.SetTextContent(Some(value))
} }
} }

View file

@ -26,14 +26,14 @@ impl HTMLTrackElementDerived for EventTarget {
} }
impl HTMLTrackElement { impl HTMLTrackElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTrackElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTrackElement {
HTMLTrackElement { HTMLTrackElement {
htmlelement: HTMLElement::new_inherited(HTMLTrackElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLTrackElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTrackElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTrackElement> {
let element = HTMLTrackElement::new_inherited(localName, document); let element = HTMLTrackElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTrackElementBinding::Wrap) Node::reflect_node(box element, document, HTMLTrackElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLUListElementDerived for EventTarget {
} }
impl HTMLUListElement { impl HTMLUListElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLUListElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLUListElement {
HTMLUListElement { HTMLUListElement {
htmlelement: HTMLElement::new_inherited(HTMLUListElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLUListElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLUListElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLUListElement> {
let element = HTMLUListElement::new_inherited(localName, document); let element = HTMLUListElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLUListElementBinding::Wrap) Node::reflect_node(box element, document, HTMLUListElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLUnknownElementDerived for EventTarget {
} }
impl HTMLUnknownElement { impl HTMLUnknownElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLUnknownElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLUnknownElement {
HTMLUnknownElement { HTMLUnknownElement {
htmlelement: HTMLElement::new_inherited(HTMLUnknownElementTypeId, localName, document) htmlelement: HTMLElement::new_inherited(HTMLUnknownElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLUnknownElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLUnknownElement> {
let element = HTMLUnknownElement::new_inherited(localName, document); let element = HTMLUnknownElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLUnknownElementBinding::Wrap) Node::reflect_node(box element, document, HTMLUnknownElementBinding::Wrap)
} }

View file

@ -26,14 +26,14 @@ impl HTMLVideoElementDerived for EventTarget {
} }
impl HTMLVideoElement { impl HTMLVideoElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLVideoElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLVideoElement {
HTMLVideoElement { HTMLVideoElement {
htmlmediaelement: HTMLMediaElement::new_inherited(HTMLVideoElementTypeId, localName, document) htmlmediaelement: HTMLMediaElement::new_inherited(HTMLVideoElementTypeId, localName, document)
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLVideoElement> { pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLVideoElement> {
let element = HTMLVideoElement::new_inherited(localName, document); let element = HTMLVideoElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLVideoElementBinding::Wrap) Node::reflect_node(box element, document, HTMLVideoElementBinding::Wrap)
} }

View file

@ -29,9 +29,9 @@ impl Location {
} }
} }
pub fn new(window: &JSRef<Window>, page: Rc<Page>) -> Temporary<Location> { pub fn new(window: JSRef<Window>, page: Rc<Page>) -> Temporary<Location> {
reflect_dom_object(box Location::new_inherited(page), reflect_dom_object(box Location::new_inherited(page),
&Window(*window), &Window(window),
LocationBinding::Wrap) LocationBinding::Wrap)
} }
} }

View file

@ -11,7 +11,7 @@ macro_rules! make_getter(
use dom::element::{Element, AttributeHandlers}; use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast; use dom::bindings::codegen::InheritTypes::ElementCast;
use std::ascii::StrAsciiExt; use std::ascii::StrAsciiExt;
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.get_string_attribute(stringify!($attr).to_ascii_lower().as_slice()) element.get_string_attribute(stringify!($attr).to_ascii_lower().as_slice())
} }
); );
@ -24,7 +24,7 @@ macro_rules! make_bool_getter(
use dom::element::{Element, AttributeHandlers}; use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast; use dom::bindings::codegen::InheritTypes::ElementCast;
use std::ascii::StrAsciiExt; use std::ascii::StrAsciiExt;
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.has_attribute(stringify!($attr).to_ascii_lower().as_slice()) element.has_attribute(stringify!($attr).to_ascii_lower().as_slice())
} }
); );
@ -37,7 +37,7 @@ macro_rules! make_uint_getter(
use dom::element::{Element, AttributeHandlers}; use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast; use dom::bindings::codegen::InheritTypes::ElementCast;
use std::ascii::StrAsciiExt; use std::ascii::StrAsciiExt;
let element: &JSRef<Element> = ElementCast::from_ref(self); let element: JSRef<Element> = ElementCast::from_ref(*self);
element.get_uint_attribute(stringify!($attr).to_ascii_lower().as_slice()) element.get_uint_attribute(stringify!($attr).to_ascii_lower().as_slice())
} }
); );

View file

@ -52,9 +52,9 @@ impl MessageEvent {
let ev = reflect_dom_object(box MessageEvent::new_inherited(data, origin, lastEventId), let ev = reflect_dom_object(box MessageEvent::new_inherited(data, origin, lastEventId),
global, global,
MessageEventBinding::Wrap).root(); MessageEventBinding::Wrap).root();
let event: &JSRef<Event> = EventCast::from_ref(&*ev); let event: JSRef<Event> = EventCast::from_ref(*ev);
event.InitEvent(type_, bubbles, cancelable); event.InitEvent(type_, bubbles, cancelable);
Temporary::from_rooted(&*ev) Temporary::from_rooted(*ev)
} }
pub fn Constructor(global: &GlobalRef, pub fn Constructor(global: &GlobalRef,
@ -68,14 +68,14 @@ impl MessageEvent {
} }
impl MessageEvent { impl MessageEvent {
pub fn dispatch_jsval(target: &JSRef<EventTarget>, pub fn dispatch_jsval(target: JSRef<EventTarget>,
scope: &GlobalRef, scope: &GlobalRef,
message: JSVal) { message: JSVal) {
let messageevent = MessageEvent::new( let messageevent = MessageEvent::new(
scope, "message".to_string(), false, false, message, scope, "message".to_string(), false, false, message,
"".to_string(), "".to_string()).root(); "".to_string(), "".to_string()).root();
let event: &JSRef<Event> = EventCast::from_ref(&*messageevent); let event: JSRef<Event> = EventCast::from_ref(*messageevent);
target.dispatch_event_with_target(None, &*event).unwrap(); target.dispatch_event_with_target(None, event).unwrap();
} }
} }

View file

@ -57,13 +57,13 @@ impl MouseEvent {
} }
} }
pub fn new_uninitialized(window: &JSRef<Window>) -> Temporary<MouseEvent> { pub fn new_uninitialized(window: JSRef<Window>) -> Temporary<MouseEvent> {
reflect_dom_object(box MouseEvent::new_inherited(), reflect_dom_object(box MouseEvent::new_inherited(),
&Window(*window), &Window(window),
MouseEventBinding::Wrap) MouseEventBinding::Wrap)
} }
pub fn new(window: &JSRef<Window>, pub fn new(window: JSRef<Window>,
type_: DOMString, type_: DOMString,
canBubble: bool, canBubble: bool,
cancelable: bool, cancelable: bool,
@ -84,7 +84,7 @@ impl MouseEvent {
screenX, screenY, clientX, clientY, screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey, ctrlKey, altKey, shiftKey, metaKey,
button, relatedTarget); button, relatedTarget);
Temporary::from_rooted(&*ev) Temporary::from_rooted(*ev)
} }
pub fn Constructor(global: &GlobalRef, pub fn Constructor(global: &GlobalRef,
@ -160,7 +160,7 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
metaKeyArg: bool, metaKeyArg: bool,
buttonArg: i16, buttonArg: i16,
relatedTargetArg: Option<JSRef<EventTarget>>) { relatedTargetArg: Option<JSRef<EventTarget>>) {
let uievent: &JSRef<UIEvent> = UIEventCast::from_ref(self); let uievent: JSRef<UIEvent> = UIEventCast::from_ref(*self);
uievent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); uievent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
self.screen_x.deref().set(screenXArg); self.screen_x.deref().set(screenXArg);
self.screen_y.deref().set(screenYArg); self.screen_y.deref().set(screenYArg);

View file

@ -19,16 +19,16 @@ pub struct NamedNodeMap {
} }
impl NamedNodeMap { impl NamedNodeMap {
pub fn new_inherited(elem: &JSRef<Element>) -> NamedNodeMap { pub fn new_inherited(elem: JSRef<Element>) -> NamedNodeMap {
NamedNodeMap { NamedNodeMap {
reflector_: Reflector::new(), reflector_: Reflector::new(),
owner: JS::from_rooted(elem), owner: JS::from_rooted(elem),
} }
} }
pub fn new(window: &JSRef<Window>, elem: &JSRef<Element>) -> Temporary<NamedNodeMap> { pub fn new(window: JSRef<Window>, elem: JSRef<Element>) -> Temporary<NamedNodeMap> {
reflect_dom_object(box NamedNodeMap::new_inherited(elem), reflect_dom_object(box NamedNodeMap::new_inherited(elem),
&Window(*window), NamedNodeMapBinding::Wrap) &Window(window), NamedNodeMapBinding::Wrap)
} }
} }

Some files were not shown because too many files have changed in this diff Show more