servo: Merge #3422 - First steps of &JSRef -> JSRef conversion (from zwarich:jsref)

Source-Repo: https://github.com/servo/servo
Source-Revision: e9ad87e27eb30cfacd66b575e104ee2784f95591
This commit is contained in:
Cameron Zwarich 2014-09-19 19:28:32 -07:00
Родитель e161bd08a0
Коммит 74b96ae97e
126 изменённых файлов: 994 добавлений и 992 удалений

Просмотреть файл

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

Просмотреть файл

@ -115,7 +115,7 @@ impl CallbackInterface {
/// Wraps the reflector for `p` into the compartment of `cx`.
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();
assert!(obj.is_not_null());
@ -140,7 +140,7 @@ pub struct CallSetup {
impl CallSetup {
/// Performs the setup needed to make a call.
#[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.root();
let cx = global.root_ref().get_cx();

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -21,7 +21,7 @@
//!
//! - All methods return `Temporary<T>`, to ensure the value remains alive until it is stored
//! 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.
//! - 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.
@ -84,7 +84,7 @@ impl<T: Reflectable> Temporary<T> {
}
/// 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))
}
@ -175,7 +175,7 @@ impl<T: Reflectable> JS<T> {
}
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 {
root.get_js()
}
@ -298,7 +298,7 @@ pub trait OptionalUnrootable<T> {
impl<'a, T: Reflectable> OptionalUnrootable<T> for Option<JSRef<'a, 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> {
//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)
}
//XXXjdm It would be lovely if this could be private.
pub unsafe fn transmute_mut<'b, To>(&'b mut self) -> &'b mut JSRef<'a, To> {
// FIXME(zwarich): It would be nice to get rid of this entirely.
pub unsafe fn transmute_borrowed<'b, To>(&'b self) -> &'b JSRef<'a, To> {
mem::transmute(self)
}

Просмотреть файл

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

Просмотреть файл

@ -26,7 +26,7 @@ pub struct 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 {
reflector_: Reflector::new(),
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),
global, CanvasRenderingContext2DBinding::Wrap)
}

Просмотреть файл

@ -36,7 +36,7 @@ impl CharacterDataDerived for EventTarget {
}
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 {
node: Node::new_inherited(id, document),
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
fn Remove(&self) {
let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.remove_self();
}
}

Просмотреть файл

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

Просмотреть файл

@ -47,7 +47,7 @@ impl CustomEvent {
pub fn new(global: &GlobalRef, type_: DOMString, bubbles: bool, cancelable: bool, detail: JSVal) -> Temporary<CustomEvent> {
let ev = CustomEvent::new_uninitialized(global).root();
ev.deref().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
Temporary::from_rooted(&*ev)
Temporary::from_rooted(*ev)
}
pub fn Constructor(global: &GlobalRef,
type_: DOMString,
@ -68,7 +68,7 @@ impl<'a> CustomEventMethods for JSRef<'a, CustomEvent> {
cancelable: bool,
detail: JSVal) {
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);
}
}

Просмотреть файл

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

Просмотреть файл

@ -101,49 +101,49 @@ impl DocumentDerived for EventTarget {
struct 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()
}
}
struct 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()
}
}
struct 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")
}
}
struct 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()
}
}
struct 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()
}
}
struct 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")
}
}
struct 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()
}
}
@ -157,8 +157,8 @@ pub trait DocumentHelpers {
fn content_changed(&self);
fn damage_and_reflow(&self, damage: DocumentDamageLevel);
fn wait_until_safe_to_modify_dom(&self);
fn unregister_named_element(&self, to_unregister: &JSRef<Element>, id: DOMString);
fn register_named_element(&self, element: &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 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.
fn unregister_named_element(&self,
to_unregister: &JSRef<Element>,
to_unregister: JSRef<Element>,
id: DOMString) {
let mut idmap = self.idmap.deref().borrow_mut();
let is_empty = match idmap.find_mut(&id) {
@ -206,7 +206,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
Some(elements) => {
let position = elements.iter()
.map(|elem| elem.root())
.position(|element| &*element == to_unregister)
.position(|element| *element == to_unregister)
.expect("This element should be in registered.");
elements.remove(position);
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.
fn register_named_element(&self,
element: &JSRef<Element>,
element: JSRef<Element>,
id: DOMString) {
assert!({
let node: &JSRef<Node> = NodeCast::from_ref(element);
let node: JSRef<Node> = NodeCast::from_ref(element);
node.is_in_doc()
});
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();
match idmap.find_mut(&id) {
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 root: &JSRef<Node> = NodeCast::from_ref(&*root);
let root: JSRef<Node> = NodeCast::from_ref(*root);
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 {
Some(elem) => {
if &*(*elements)[head].root() == elem {
if *(*elements)[head].root() == elem {
head = head + 1;
}
if new_node == &node || head == elements.len() {
if new_node == node || head == elements.len() {
break;
}
}
None => {}
}
}
elements.insert_unrooted(head, element);
elements.insert_unrooted(head, &element);
return;
},
None => (),
}
let mut elements = vec!();
elements.push_unrooted(element);
elements.push_unrooted(&element);
idmap.insert(id, elements);
}
@ -268,7 +268,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
}
impl Document {
pub fn new_inherited(window: &JSRef<Window>,
pub fn new_inherited(window: JSRef<Window>,
url: Option<Url>,
is_html_document: IsHTMLDocument,
content_type: Option<DOMString>) -> Document {
@ -311,14 +311,14 @@ impl Document {
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),
&Window(*window),
&Window(window),
DocumentBinding::Wrap).root();
let node: &JSRef<Node> = NodeCast::from_ref(&*document);
node.set_owner_doc(&*document);
Temporary::from_rooted(&*document)
let node: JSRef<Node> = NodeCast::from_ref(*document);
node.set_owner_doc(*&*document);
Temporary::from_rooted(*&*document)
}
}
@ -329,27 +329,27 @@ impl Reflectable for Document {
}
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>>;
}
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();
match self.GetDocumentElement().root() {
None => {
NodeList::new_simple_list(&*window, vec!())
NodeList::new_simple_list(*window, vec!())
},
Some(root) => {
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() {
if callback(&child) {
if callback(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>> {
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)
}).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
fn Implementation(&self) -> Temporary<DOMImplementation> {
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())
}
@ -404,38 +404,38 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-doctype
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| {
child.is_doctype()
}).map(|node| {
let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(&node).unwrap();
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
Temporary::from_rooted(doctype)
})
}
// http://dom.spec.whatwg.org/#dom-document-documentelement
fn GetDocumentElement(&self) -> Option<Temporary<Element>> {
let node: &JSRef<Node> = NodeCast::from_ref(self);
node.child_elements().next().map(|elem| Temporary::from_rooted(&elem))
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.child_elements().next().map(|elem| Temporary::from_rooted(elem))
}
// http://dom.spec.whatwg.org/#dom-document-getelementsbytagname
fn GetElementsByTagName(&self, tag_name: DOMString) -> Temporary<HTMLCollection> {
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
fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>, tag_name: DOMString) -> Temporary<HTMLCollection> {
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
fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection> {
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
@ -453,7 +453,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
return Err(InvalidCharacter);
}
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
@ -497,27 +497,27 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
}
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 {
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
fn CreateDocumentFragment(&self) -> Temporary<DocumentFragment> {
DocumentFragment::new(self)
DocumentFragment::new(*self)
}
// http://dom.spec.whatwg.org/#dom-document-createtextnode
fn CreateTextNode(&self, data: DOMString)
-> Temporary<Text> {
Text::new(data, self)
Text::new(data, *self)
}
// http://dom.spec.whatwg.org/#dom-document-createcomment
fn CreateComment(&self, data: DOMString) -> Temporary<Comment> {
Comment::new(data, self)
Comment::new(data, *self)
}
// http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
@ -534,11 +534,11 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
}
// Step 3.
Ok(ProcessingInstruction::new(target, data, self))
Ok(ProcessingInstruction::new(target, data, *self))
}
// 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.
if node.is_document() {
return Err(NotSupported);
@ -550,18 +550,18 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
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
fn AdoptNode(&self, node: &JSRef<Node>) -> Fallible<Temporary<Node>> {
fn AdoptNode(&self, node: JSRef<Node>) -> Fallible<Temporary<Node>> {
// Step 1.
if node.is_document() {
return Err(NotSupported);
}
// Step 2.
Node::adopt(node, self);
Node::adopt(node, *self);
// Step 3.
Ok(Temporary::from_rooted(node))
@ -572,8 +572,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
let window = self.window.root();
match interface.as_slice().to_ascii_lower().as_slice() {
"uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new_uninitialized(&*window))),
"mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new_uninitialized(&*window))),
"uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new_uninitialized(*window))),
"mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new_uninitialized(*window))),
"customevent" => Ok(EventCast::from_temporary(CustomEvent::new_uninitialized(&Window(*window)))),
"htmlevents" | "events" | "event" => Ok(Event::new_uninitialized(&Window(*window))),
_ => Err(NotSupported)
@ -590,26 +590,26 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-document-createrange
fn CreateRange(&self) -> Temporary<Range> {
Range::new(self)
Range::new(*self)
}
// 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> {
TreeWalker::new(self, root, whatToShow, filter)
TreeWalker::new(*self, root, whatToShow, filter)
}
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
fn Title(&self) -> DOMString {
let mut title = String::new();
self.GetDocumentElement().root().map(|root| {
let root: &JSRef<Node> = NodeCast::from_ref(&*root);
let root: JSRef<Node> = NodeCast::from_ref(*root);
root.traverse_preorder()
.find(|node| node.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId))
.map(|title_elem| {
for child in title_elem.children() {
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());
}
}
@ -622,7 +622,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
fn SetTitle(&self, title: DOMString) -> ErrorResult {
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| {
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
});
@ -634,20 +634,20 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
match title_node {
Some(ref title_node) => {
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() {
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 => {
let new_title = HTMLTitleElement::new("title".to_string(), self).root();
let new_title: &JSRef<Node> = NodeCast::from_ref(&*new_title);
let new_title = HTMLTitleElement::new("title".to_string(), *self).root();
let new_title: JSRef<Node> = NodeCast::from_ref(*new_title);
if !title.is_empty() {
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());
},
@ -661,11 +661,11 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn GetHead(&self) -> Option<Temporary<HTMLHeadElement>> {
self.get_html_element().and_then(|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| {
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
}).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>> {
self.get_html_element().and_then(|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| {
match child.type_id() {
ElementNodeTypeId(HTMLBodyElementTypeId) |
@ -682,7 +682,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
_ => false
}
}).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.
match new_body {
Some(ref htmlelem) => {
let node: &JSRef<Node> = NodeCast::from_ref(htmlelem);
let node: JSRef<Node> = NodeCast::from_ref(*htmlelem);
match node.type_id() {
ElementNodeTypeId(HTMLBodyElementTypeId) | ElementNodeTypeId(HTMLFrameSetElementTypeId) => {}
_ => return Err(HierarchyRequest)
@ -714,12 +714,12 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
None => return Err(HierarchyRequest),
Some(ref root) => {
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 {
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())
}
@ -737,7 +737,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
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| {
attr.value().as_slice() == name.as_slice()
})
@ -747,9 +747,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Images(&self) -> Temporary<HTMLCollection> {
if self.images.get().is_none() {
let window = self.window.root();
let root = NodeCast::from_ref(self);
let root = NodeCast::from_ref(*self);
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())
}
@ -757,9 +757,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Embeds(&self) -> Temporary<HTMLCollection> {
if self.embeds.get().is_none() {
let window = self.window.root();
let root = NodeCast::from_ref(self);
let root = NodeCast::from_ref(*self);
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())
}
@ -771,9 +771,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Links(&self) -> Temporary<HTMLCollection> {
if self.links.get().is_none() {
let window = self.window.root();
let root = NodeCast::from_ref(self);
let root = NodeCast::from_ref(*self);
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())
}
@ -781,9 +781,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Forms(&self) -> Temporary<HTMLCollection> {
if self.forms.get().is_none() {
let window = self.window.root();
let root = NodeCast::from_ref(self);
let root = NodeCast::from_ref(*self);
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())
}
@ -791,9 +791,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Scripts(&self) -> Temporary<HTMLCollection> {
if self.scripts.get().is_none() {
let window = self.window.root();
let root = NodeCast::from_ref(self);
let root = NodeCast::from_ref(*self);
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())
}
@ -801,9 +801,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn Anchors(&self) -> Temporary<HTMLCollection> {
if self.anchors.get().is_none() {
let window = self.window.root();
let root = NodeCast::from_ref(self);
let root = NodeCast::from_ref(*self);
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())
}
@ -812,9 +812,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// FIXME: This should be return OBJECT elements containing applets.
if self.applets.get().is_none() {
let window = self.window.root();
let root = NodeCast::from_ref(self);
let root = NodeCast::from_ref(*self);
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())
}
@ -827,38 +827,38 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-parentnode-children
fn Children(&self) -> Temporary<HTMLCollection> {
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
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)
}
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
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)
}
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")
}
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)
}
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")
}
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)
}
}

Просмотреть файл

@ -32,13 +32,13 @@ impl DocumentFragmentDerived for EventTarget {
impl DocumentFragment {
/// Creates a new DocumentFragment.
pub fn new_inherited(document: &JSRef<Document>) -> DocumentFragment {
pub fn new_inherited(document: JSRef<Document>) -> DocumentFragment {
DocumentFragment {
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),
document, DocumentFragmentBinding::Wrap)
}
@ -47,26 +47,26 @@ impl DocumentFragment {
let document = global.as_window().Document();
let document = document.root();
Ok(DocumentFragment::new(&document.root_ref()))
Ok(DocumentFragment::new(*document))
}
}
impl<'a> DocumentFragmentMethods for JSRef<'a, DocumentFragment> {
// http://dom.spec.whatwg.org/#dom-parentnode-children
fn Children(&self) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root();
HTMLCollection::children(&window.root_ref(), NodeCast::from_ref(self))
let window = window_from_node(*self).root();
HTMLCollection::children(*window, NodeCast::from_ref(*self))
}
// http://dom.spec.whatwg.org/#dom-parentnode-queryselector
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)
}
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
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)
}

Просмотреть файл

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

Просмотреть файл

@ -30,14 +30,14 @@ pub struct DOMImplementation {
}
impl DOMImplementation {
pub fn new_inherited(document: &JSRef<Document>) -> DOMImplementation {
pub fn new_inherited(document: JSRef<Document>) -> DOMImplementation {
DOMImplementation {
document: JS::from_rooted(document),
reflector_: Reflector::new(),
}
}
pub fn new(document: &JSRef<Document>) -> Temporary<DOMImplementation> {
pub fn new(document: JSRef<Document>) -> Temporary<DOMImplementation> {
let window = document.window.root();
reflect_dom_object(box DOMImplementation::new_inherited(document),
&Window(*window),
@ -63,7 +63,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
// Step 3.
QName => {
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();
// 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.
let maybe_elem = if qname.is_empty() {
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.
match maybe_doctype {
None => (),
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())
}
}
@ -102,7 +102,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
match maybe_elem.root() {
None => (),
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
// Step 7.
Ok(Temporary::from_rooted(&*doc))
Ok(Temporary::from_rooted(*doc))
}
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
@ -120,54 +120,54 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
let win = document.window.root();
// Step 1-2.
let doc = Document::new(&win.root_ref(), None, HTMLDocument, None).root();
let doc_node: &JSRef<Node> = NodeCast::from_ref(&*doc);
let doc = Document::new(*win, None, HTMLDocument, None).root();
let doc_node: JSRef<Node> = NodeCast::from_ref(*doc);
{
// Step 3.
let doc_type = DocumentType::new("html".to_string(), None, None, &*doc).root();
assert!(doc_node.AppendChild(NodeCast::from_ref(&*doc_type)).is_ok());
let doc_type = DocumentType::new("html".to_string(), None, None, *doc).root();
assert!(doc_node.AppendChild(NodeCast::from_ref(*doc_type)).is_ok());
}
{
// 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();
assert!(doc_node.AppendChild(doc_html).is_ok());
assert!(doc_node.AppendChild(*doc_html).is_ok());
{
// 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();
assert!(doc_html.AppendChild(doc_head).is_ok());
assert!(doc_html.AppendChild(*doc_head).is_ok());
// Step 6.
match title {
None => (),
Some(title_str) => {
// 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();
assert!(doc_head.AppendChild(doc_title).is_ok());
assert!(doc_head.AppendChild(*doc_title).is_ok());
// 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();
assert!(doc_title.AppendChild(NodeCast::from_ref(title_text)).is_ok());
assert!(doc_title.AppendChild(NodeCast::from_ref(*title_text)).is_ok());
}
}
}
// 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();
assert!(doc_html.AppendChild(NodeCast::from_ref(doc_body)).is_ok());
assert!(doc_html.AppendChild(NodeCast::from_ref(*doc_body)).is_ok());
}
// Step 8.
// FIXME: https://github.com/mozilla/servo/issues/1522
// Step 9.
Temporary::from_rooted(&*doc)
Temporary::from_rooted(*doc)
}
}

Просмотреть файл

@ -21,15 +21,15 @@ pub struct DOMParser {
}
impl DOMParser {
pub fn new_inherited(window: &JSRef<Window>) -> DOMParser {
pub fn new_inherited(window: JSRef<Window>) -> DOMParser {
DOMParser {
window: JS::from_rooted(window),
reflector_: Reflector::new()
}
}
pub fn new(window: &JSRef<Window>) -> Temporary<DOMParser> {
reflect_dom_object(box DOMParser::new_inherited(window), &Window(*window),
pub fn new(window: JSRef<Window>) -> Temporary<DOMParser> {
reflect_dom_object(box DOMParser::new_inherited(window), &Window(window),
DOMParserBinding::Wrap)
}
@ -46,10 +46,10 @@ impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
let window = self.window.root();
match ty {
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 => {
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)

Просмотреть файл

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

Просмотреть файл

@ -19,9 +19,9 @@ pub struct DOMRectList {
}
impl DOMRectList {
pub fn new_inherited(window: &JSRef<Window>,
pub fn new_inherited(window: JSRef<Window>,
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 {
reflector_: Reflector::new(),
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> {
reflect_dom_object(box DOMRectList::new_inherited(window, rects),
&Window(*window), DOMRectListBinding::Wrap)
&Window(window), DOMRectListBinding::Wrap)
}
}

Просмотреть файл

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

Просмотреть файл

@ -149,7 +149,7 @@ pub enum ElementTypeId {
//
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 {
node: Node::new_inherited(ElementNodeTypeId(type_id), document),
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),
document, ElementBinding::Wrap)
}
@ -246,7 +246,7 @@ pub trait ElementHelpers {
impl<'a> ElementHelpers for JSRef<'a, Element> {
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()
}
@ -282,7 +282,7 @@ pub trait AttributeHandlers {
fn set_attribute(&self, name: &str, value: AttrValue);
fn do_set_attribute(&self, local_name: Atom, value: AttrValue,
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,
value: DOMString) -> AttrValue;
@ -309,7 +309,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
let local_name = Atom::from_slice(local_name);
self.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| {
*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,
@ -330,7 +330,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
assert!(name == name.to_ascii_lower().as_slice());
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();
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,
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()
.map(|attr| attr.root())
.position(|attr| cb(&*attr));
.position(|attr| cb(*attr));
let (idx, set_type) = match idx {
Some(idx) => (idx, ReplacedAttr),
None => {
let window = window_from_node(self).root();
let attr = Attr::new(&*window, local_name, value.clone(),
name, namespace.clone(), prefix, self);
let window = window_from_node(*self).root();
let attr = Attr::new(*window, local_name, value.clone(),
name, namespace.clone(), prefix, *self);
self.deref().attrs.borrow_mut().push_unrooted(&attr);
(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,
value: DOMString) -> AttrValue {
if *namespace == namespace::Null {
vtable_for(NodeCast::from_ref(self))
vtable_for(&NodeCast::from_ref(*self))
.parse_plain_attribute(local_name.as_slice(), value)
} else {
StringAttrValue(value)
@ -380,13 +380,13 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
None => (),
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();
}
if namespace == namespace::Null {
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,
removed_raw_value);
}
@ -397,7 +397,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
}
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() {
let damage = match local_name.as_slice() {
"style" | "id" | "class" => MatchSelectorsDocumentDamage,
@ -561,9 +561,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
match self.class_list.get() {
Some(class_list) => Temporary::new(class_list),
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()));
Temporary::from_rooted(&*class_list)
Temporary::from_rooted(*class_list)
}
}
}
@ -576,11 +576,11 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
}
let doc = {
let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.owner_doc().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));
Temporary::new(self.attr_list.get().get_ref().clone())
}
@ -610,7 +610,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
name: DOMString,
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();
}
@ -642,7 +642,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
name: DOMString,
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();
}
@ -737,45 +737,45 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
}
fn GetElementsByTagName(&self, localname: DOMString) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root();
HTMLCollection::by_tag_name(&*window, NodeCast::from_ref(self), localname)
let window = window_from_node(*self).root();
HTMLCollection::by_tag_name(*window, NodeCast::from_ref(*self), localname)
}
fn GetElementsByTagNameNS(&self, maybe_ns: Option<DOMString>,
localname: DOMString) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root();
HTMLCollection::by_tag_name_ns(&*window, NodeCast::from_ref(self), localname, maybe_ns)
let window = window_from_node(*self).root();
HTMLCollection::by_tag_name_ns(*window, NodeCast::from_ref(*self), localname, maybe_ns)
}
fn GetElementsByClassName(&self, classes: DOMString) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root();
HTMLCollection::by_class_name(&*window, NodeCast::from_ref(self), classes)
let window = window_from_node(*self).root();
HTMLCollection::by_class_name(*window, NodeCast::from_ref(*self), classes)
}
// http://dev.w3.org/csswg/cssom-view/#dom-element-getclientrects
fn GetClientRects(&self) -> Temporary<DOMRectList> {
let win = window_from_node(self).root();
let node: &JSRef<Node> = NodeCast::from_ref(self);
let win = window_from_node(*self).root();
let node: JSRef<Node> = NodeCast::from_ref(*self);
let rects = node.get_content_boxes();
let rects: Vec<Root<DOMRect>> = rects.iter().map(|r| {
DOMRect::new(
&*win,
*win,
r.origin.y,
r.origin.y + r.size.height,
r.origin.x,
r.origin.x + r.size.width).root()
}).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
fn GetBoundingClientRect(&self) -> Temporary<DOMRect> {
let win = window_from_node(self).root();
let node: &JSRef<Node> = NodeCast::from_ref(self);
let win = window_from_node(*self).root();
let node: JSRef<Node> = NodeCast::from_ref(*self);
let rect = node.get_bounding_content_box();
DOMRect::new(
&*win,
*win,
rect.origin.y,
rect.origin.y + rect.size.height,
rect.origin.x,
@ -784,34 +784,34 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
fn GetInnerHTML(&self) -> Fallible<DOMString> {
//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> {
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
fn Children(&self) -> Temporary<HTMLCollection> {
let window = window_from_node(self).root();
HTMLCollection::children(&*window, NodeCast::from_ref(self))
let window = window_from_node(*self).root();
HTMLCollection::children(*window, NodeCast::from_ref(*self))
}
// http://dom.spec.whatwg.org/#dom-parentnode-queryselector
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)
}
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
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)
}
// http://dom.spec.whatwg.org/#dom-childnode-remove
fn Remove(&self) {
let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.remove_self();
}
@ -820,8 +820,8 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
match parse_selector_list_from_str(selectors.as_slice()) {
Err(()) => Err(Syntax),
Ok(ref selectors) => {
let root: &JSRef<Node> = NodeCast::from_ref(self);
Ok(matches(selectors, root, &mut None))
let root: JSRef<Node> = NodeCast::from_ref(*self);
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> {
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)
}
@ -854,16 +854,16 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
match name.as_slice() {
"style" => {
let doc = document_from_node(self).root();
let doc = document_from_node(*self).root();
let base_url = doc.deref().url().clone();
let style = Some(style::parse_style_attribute(value.as_slice(), &base_url));
*self.deref().style_attribute.deref().borrow_mut() = style;
}
"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() {
let doc = document_from_node(self).root();
doc.register_named_element(self, value.clone());
let doc = document_from_node(*self).root();
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;
}
"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() {
let doc = document_from_node(self).root();
doc.unregister_named_element(self, value);
let doc = document_from_node(*self).root();
doc.unregister_named_element(*self, value);
}
}
_ => ()
@ -913,10 +913,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
match self.get_attribute(Null, "id").root() {
Some(attr) => {
let doc = document_from_node(self).root();
let doc = document_from_node(*self).root();
let value = attr.deref().Value();
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() {
Some(attr) => {
let doc = document_from_node(self).root();
let doc = document_from_node(*self).root();
let value = attr.deref().Value();
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> {
// 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() {
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#
// selector-link
@ -969,7 +969,7 @@ impl<'a> style::TElement for JSRef<'a, Element> {
(self as &ElementHelpers).get_namespace()
}
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()
}
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 {
let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.get_disabled_state()
}
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()
}
fn has_class(&self, name: &str) -> bool {

Просмотреть файл

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

Просмотреть файл

@ -12,9 +12,9 @@ use dom::node::{Node, NodeHelpers};
use dom::virtualmethods::vtable_for;
// 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>>,
event: &JSRef<Event>) -> bool {
event: JSRef<Event>) -> bool {
assert!(!event.deref().dispatching.deref().get());
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
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| {
let ancestor_target: &JSRef<EventTarget> = EventTargetCast::from_ref(&ancestor);
let ancestor_target: JSRef<EventTarget> = EventTargetCast::from_ref(ancestor);
JS::from_rooted(ancestor_target).root()
}).collect()
} else {
@ -47,7 +47,7 @@ pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>,
event.current_target.assign(Some(cur_target.deref().clone()));
for listener in listeners.iter() {
// 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() {
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()));
for listener in listeners.iter() {
// 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() {
break;
@ -113,10 +113,10 @@ pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>,
let target = event.GetTarget().root();
match target {
Some(target) => {
let node: Option<&JSRef<Node>> = NodeCast::to_ref(&*target);
let node: Option<JSRef<Node>> = NodeCast::to_ref(*target);
match node {
Some(node) => {
let vtable = vtable_for(node);
let vtable = vtable_for(&node);
vtable.handle_event(event);
}
None => {}

Просмотреть файл

@ -96,7 +96,7 @@ impl EventTarget {
pub trait EventTargetHelpers {
fn dispatch_event_with_target<'a>(&self,
target: Option<JSRef<'a, EventTarget>>,
event: &JSRef<Event>) -> Fallible<bool>;
event: JSRef<Event>) -> Fallible<bool>;
fn set_inline_event_listener(&self,
ty: DOMString,
listener: Option<EventListener>);
@ -117,11 +117,11 @@ pub trait EventTargetHelpers {
impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
fn dispatch_event_with_target<'b>(&self,
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() {
return Err(InvalidState);
}
Ok(dispatch_event(self, target, event))
Ok(dispatch_event(*self, target, event))
}
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)
}
}

Просмотреть файл

@ -19,7 +19,7 @@ pub struct 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 {
blob: Blob::new_inherited(),
name: name,
@ -29,7 +29,7 @@ impl File {
// 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),
global,
FileBinding::Wrap)

Просмотреть файл

@ -40,7 +40,7 @@ impl FormData {
data: Traceable::new(RefCell::new(HashMap::new())),
reflector_: Reflector::new(),
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> {
#[allow(unrooted_must_root)]
fn Append(&self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>) {
let file = FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
fn Append(&self, name: DOMString, value: JSRef<Blob>, filename: Option<DOMString>) {
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()),
|_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)
}
#[allow(unrooted_must_root)]
fn Set(&self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>) {
let file = FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
fn Set(&self, name: DOMString, value: JSRef<Blob>, filename: Option<DOMString>) {
let file = FileData(JS::from_rooted(self.get_file_from_blob(value, filename)));
self.data.deref().borrow_mut().insert(name, vec!(file));
}
@ -105,13 +105,13 @@ impl Reflectable for FormData {
}
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 {
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 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()));
File::new(&global.root_ref(), value, name)
}

Просмотреть файл

@ -36,33 +36,33 @@ impl HTMLAnchorElementDerived for EventTarget {
}
impl HTMLAnchorElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAnchorElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAnchorElement {
HTMLAnchorElement {
htmlelement: HTMLElement::new_inherited(HTMLAnchorElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLAnchorElementBinding::Wrap)
}
}
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> {
fn handle_event_impl(&self, event: &JSRef<Event>) {
fn handle_event_impl(&self, event: JSRef<Event>) {
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();
match attr {
Some(ref href) => {
let value = href.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();
doc.load_anchor_href(value);
}
@ -74,7 +74,7 @@ impl<'a> PrivateHTMLAnchorElementHelpers for JSRef<'a, HTMLAnchorElement> {
impl<'a> VirtualMethods for JSRef<'a, HTMLAnchorElement> {
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)
}
@ -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() {
"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() {
"href" => node.set_enabled_state(false),
_ => ()
}
}
fn handle_event(&self, event: &JSRef<Event>) {
fn handle_event(&self, event: JSRef<Event>) {
match self.super_type() {
Some(s) => {
s.handle_event(event);
@ -123,12 +123,12 @@ impl Reflectable for HTMLAnchorElement {
impl<'a> HTMLAnchorElementMethods for JSRef<'a, HTMLAnchorElement> {
fn Text(&self) -> DOMString {
let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.GetTextContent().unwrap()
}
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))
}
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLAppletElementDerived for EventTarget {
}
impl HTMLAppletElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAppletElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAppletElement {
HTMLAppletElement {
htmlelement: HTMLElement::new_inherited(HTMLAppletElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLAppletElementBinding::Wrap)
}

Просмотреть файл

@ -30,14 +30,14 @@ impl HTMLAreaElementDerived for EventTarget {
}
impl HTMLAreaElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAreaElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAreaElement {
HTMLAreaElement {
htmlelement: HTMLElement::new_inherited(HTMLAreaElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLAreaElementBinding::Wrap)
}
@ -45,7 +45,7 @@ impl HTMLAreaElement {
impl<'a> VirtualMethods for JSRef<'a, HTMLAreaElement> {
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)
}
@ -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() {
"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() {
"href" => node.set_enabled_state(false),
_ => ()

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLAudioElementDerived for EventTarget {
}
impl HTMLAudioElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLAudioElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAudioElement {
HTMLAudioElement {
htmlmediaelement: HTMLMediaElement::new_inherited(HTMLAudioElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLAudioElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLBaseElementDerived for EventTarget {
}
impl HTMLBaseElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBaseElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBaseElement {
HTMLBaseElement {
htmlelement: HTMLElement::new_inherited(HTMLBaseElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLBaseElementBinding::Wrap)
}

Просмотреть файл

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

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLBRElementDerived for EventTarget {
}
impl HTMLBRElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLBRElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBRElement {
HTMLBRElement {
htmlelement: HTMLElement::new_inherited(HTMLBRElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLBRElementBinding::Wrap)
}

Просмотреть файл

@ -32,14 +32,14 @@ impl HTMLButtonElementDerived for EventTarget {
}
impl HTMLButtonElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLButtonElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLButtonElement {
HTMLButtonElement {
htmlelement: HTMLElement::new_inherited(HTMLButtonElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLButtonElementBinding::Wrap)
}
@ -47,8 +47,8 @@ impl HTMLButtonElement {
impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> {
fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root();
ValidityState::new(&*window)
let window = window_from_node(*self).root();
ValidityState::new(*window)
}
// 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
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)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
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)
}
@ -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() {
"disabled" => {
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() {
"disabled" => {
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();
}
@ -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()) {
node.check_ancestors_disabled_state_for_form_control();
} else {

Просмотреть файл

@ -44,7 +44,7 @@ impl HTMLCanvasElementDerived for EventTarget {
}
impl HTMLCanvasElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLCanvasElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLCanvasElement {
HTMLCanvasElement {
htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, document),
context: Traceable::new(Cell::new(None)),
@ -54,7 +54,7 @@ impl HTMLCanvasElement {
}
#[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);
Node::reflect_node(box element, document, HTMLCanvasElementBinding::Wrap)
}
@ -66,7 +66,7 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
}
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)
}
@ -75,7 +75,7 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
}
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)
}
@ -85,9 +85,9 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
}
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 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.get().map(|context| Temporary::new(context))
@ -96,7 +96,7 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
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)
}

Просмотреть файл

@ -20,7 +20,7 @@ use serialize::{Encoder, Encodable};
use std::ascii::StrAsciiExt;
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> {
@ -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),
&Window(*window), HTMLCollectionBinding::Wrap)
&Window(window), HTMLCollectionBinding::Wrap)
}
}
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> {
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> {
struct AllElementFilter {
namespace_filter: Option<Namespace>
}
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 {
None => true,
Some(ref namespace) => elem.namespace == *namespace
@ -80,7 +80,7 @@ impl HTMLCollection {
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> {
if tag.as_slice() == "*" {
return HTMLCollection::all_elements(window, root, None);
@ -91,7 +91,7 @@ impl HTMLCollection {
ascii_lower_tag: Atom,
}
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() {
elem.local_name == self.ascii_lower_tag
} else {
@ -106,7 +106,7 @@ impl HTMLCollection {
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> {
let namespace_filter = match maybe_ns {
Some(namespace) => {
@ -126,7 +126,7 @@ impl HTMLCollection {
namespace_filter: Option<Namespace>
}
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 {
Some(ref namespace) => {
elem.deref().namespace == *namespace
@ -143,13 +143,13 @@ impl HTMLCollection {
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> {
struct ClassNameFilter {
classes: Vec<DOMString>
}
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()))
}
}
@ -159,10 +159,10 @@ impl HTMLCollection {
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;
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))
}
}
@ -179,8 +179,8 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
let root = root.root();
root.deref().traverse_preorder()
.filter(|&child| {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&child);
elem.map_or(false, |elem| filter.filter(elem, &*root))
let elem: Option<JSRef<Element>> = ElementCast::to_ref(child);
elem.map_or(false, |elem| filter.filter(elem, *root))
}).count() as u32
}
}
@ -197,13 +197,13 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
let root = root.root();
root.deref().traverse_preorder()
.filter_map(|node| {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&node);
elem.filtered(|&elem| filter.filter(elem, &*root))
let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
elem.filtered(|&elem| filter.filter(elem, *root))
.map(|elem| elem.clone())
})
.nth(index as uint)
.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| {
elem.get_string_attribute("name") == 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) => {
let root = root.root();
root.deref().traverse_preorder()
.filter_map(|node| {
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&node);
elem.filtered(|&elem| filter.filter(elem, &*root))
let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
elem.filtered(|&elem| filter.filter(elem, *root))
.map(|elem| elem.clone())
})
.find(|elem| {
elem.get_string_attribute("name") == key ||
elem.get_string_attribute("id") == key })
.map(|maybe_elem| Temporary::from_rooted(&maybe_elem))
.map(|maybe_elem| Temporary::from_rooted(maybe_elem))
}
}
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLDataElementDerived for EventTarget {
}
impl HTMLDataElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDataElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDataElement {
HTMLDataElement {
htmlelement: HTMLElement::new_inherited(HTMLDataElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLDataElementBinding::Wrap)
}

Просмотреть файл

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

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLDirectoryElementDerived for EventTarget {
}
impl HTMLDirectoryElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDirectoryElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDirectoryElement {
HTMLDirectoryElement {
htmlelement: HTMLElement::new_inherited(HTMLDirectoryElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLDirectoryElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLDivElementDerived for EventTarget {
}
impl HTMLDivElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDivElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDivElement {
HTMLDivElement {
htmlelement: HTMLElement::new_inherited(HTMLDivElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLDivElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLDListElementDerived for EventTarget {
}
impl HTMLDListElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLDListElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDListElement {
HTMLDListElement {
htmlelement: HTMLElement::new_inherited(HTMLDListElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLDListElementBinding::Wrap)
}

Просмотреть файл

@ -38,14 +38,14 @@ impl HTMLElementDerived for EventTarget {
}
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 {
element: Element::new_inherited(type_id, tag_name, namespace::HTML, None, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLElementBinding::Wrap)
}
@ -57,25 +57,25 @@ trait PrivateHTMLElementHelpers {
impl<'a> PrivateHTMLElementHelpers for JSRef<'a, HTMLElement> {
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()
}
}
impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
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")
}
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)
}
fn GetOnload(&self) -> Option<EventHandlerNonNull> {
if self.is_body_or_frameset() {
let win = window_from_node(self).root();
let win = window_from_node(*self).root();
win.deref().GetOnload()
} else {
None
@ -84,7 +84,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
fn SetOnload(&self, listener: Option<EventHandlerNonNull>) {
if self.is_body_or_frameset() {
let win = window_from_node(self).root();
let win = window_from_node(*self).root();
win.deref().SetOnload(listener)
}
}
@ -92,7 +92,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
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)
}
@ -103,11 +103,11 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
}
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(),
window.get_url(),
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,
name.as_slice().slice_from(2),
value);

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLEmbedElementDerived for EventTarget {
}
impl HTMLEmbedElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLEmbedElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLEmbedElement {
HTMLEmbedElement {
htmlelement: HTMLElement::new_inherited(HTMLEmbedElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLEmbedElementBinding::Wrap)
}

Просмотреть файл

@ -34,14 +34,14 @@ impl HTMLFieldSetElementDerived for EventTarget {
}
impl HTMLFieldSetElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFieldSetElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFieldSetElement {
HTMLFieldSetElement {
htmlelement: HTMLElement::new_inherited(HTMLFieldSetElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLFieldSetElementBinding::Wrap)
}
@ -52,22 +52,22 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
fn Elements(&self) -> Temporary<HTMLCollection> {
struct 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",
"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())
}
}
let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JSRef<Node> = NodeCast::from_ref(*self);
let filter = box ElementsFilter;
let window = window_from_node(node).root();
HTMLCollection::create(&*window, node, filter)
HTMLCollection::create(*window, node, filter)
}
fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root();
ValidityState::new(&*window)
let window = window_from_node(*self).root();
ValidityState::new(*window)
}
// 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
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)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
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)
}
@ -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() {
"disabled" => {
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() {
"disabled" => {
node.set_disabled_state(false);

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLFontElementDerived for EventTarget {
}
impl HTMLFontElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFontElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFontElement {
HTMLFontElement {
htmlelement: HTMLElement::new_inherited(HTMLFontElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLFontElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLFormElementDerived for EventTarget {
}
impl HTMLFormElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFormElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFormElement {
HTMLFormElement {
htmlelement: HTMLElement::new_inherited(HTMLFormElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLFormElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLFrameElementDerived for EventTarget {
}
impl HTMLFrameElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFrameElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFrameElement {
HTMLFrameElement {
htmlelement: HTMLElement::new_inherited(HTMLFrameElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLFrameElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLFrameSetElementDerived for EventTarget {
}
impl HTMLFrameSetElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLFrameSetElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFrameSetElement {
HTMLFrameSetElement {
htmlelement: HTMLElement::new_inherited(HTMLFrameSetElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLFrameSetElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLHeadElementDerived for EventTarget {
}
impl HTMLHeadElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHeadElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLHeadElement {
HTMLHeadElement {
htmlelement: HTMLElement::new_inherited(HTMLHeadElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLHeadElementBinding::Wrap)
}

Просмотреть файл

@ -37,7 +37,7 @@ impl HTMLHeadingElementDerived for EventTarget {
}
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 {
htmlelement: HTMLElement::new_inherited(HTMLHeadingElementTypeId, localName, document),
level: level,
@ -45,7 +45,7 @@ impl HTMLHeadingElement {
}
#[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);
Node::reflect_node(box element, document, HTMLHeadingElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLHRElementDerived for EventTarget {
}
impl HTMLHRElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHRElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLHRElement {
HTMLHRElement {
htmlelement: HTMLElement::new_inherited(HTMLHRElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLHRElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLHtmlElementDerived for EventTarget {
}
impl HTMLHtmlElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLHtmlElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLHtmlElement {
HTMLHtmlElement {
htmlelement: HTMLElement::new_inherited(HTMLHtmlElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLHtmlElementBinding::Wrap)
}

Просмотреть файл

@ -74,13 +74,13 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
}
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| {
let url = src.deref().value();
if url.as_slice().is_empty() {
None
} else {
let window = window_from_node(self).root();
let window = window_from_node(*self).root();
UrlParser::new().base_url(&window.deref().page().get_url())
.parse(url.as_slice()).ok()
}
@ -100,7 +100,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
};
// Subpage Id
let window = window_from_node(self).root();
let window = window_from_node(*self).root();
let page = window.deref().page();
let subpage_id = page.get_next_subpage_id();
@ -115,7 +115,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
}
impl HTMLIFrameElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLIFrameElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLIFrameElement {
HTMLIFrameElement {
htmlelement: HTMLElement::new_inherited(HTMLIFrameElementTypeId, localName, document),
size: Traceable::new(Cell::new(None)),
@ -124,7 +124,7 @@ impl HTMLIFrameElement {
}
#[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);
Node::reflect_node(box element, document, HTMLIFrameElementBinding::Wrap)
}
@ -132,28 +132,28 @@ impl HTMLIFrameElement {
impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
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")
}
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)
}
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")
}
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);
}
fn GetContentWindow(&self) -> Option<Temporary<Window>> {
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 child = children.iter().find(|child| {
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> {
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)
}
@ -196,7 +196,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
}
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() {
self.process_the_iframe_attributes()
}

Просмотреть файл

@ -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
/// prefetching the image. This method must be called after `src` is changed.
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 window = document.deref().window.root();
let image_cache = &window.image_cache_task;
@ -72,7 +72,7 @@ impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> {
}
impl HTMLImageElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLImageElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLImageElement {
HTMLImageElement {
htmlelement: HTMLElement::new_inherited(HTMLImageElementTypeId, localName, document),
image: Untraceable::new(RefCell::new(None)),
@ -80,7 +80,7 @@ impl HTMLImageElement {
}
#[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);
Node::reflect_node(box element, document, HTMLImageElementBinding::Wrap)
}
@ -100,99 +100,99 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
make_getter!(Alt)
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)
}
make_getter!(Src)
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)
}
make_getter!(UseMap)
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)
}
make_bool_getter!(IsMap)
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())
}
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();
to_px(rect.size.width) as 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)
}
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();
to_px(rect.size.height) as 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)
}
make_getter!(Name)
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)
}
make_getter!(Align)
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)
}
make_uint_getter!(Hspace)
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)
}
make_uint_getter!(Vspace)
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)
}
make_getter!(LongDesc)
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)
}
make_getter!(Border)
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)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
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)
}
@ -203,7 +203,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
}
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();
self.update_image(Some((value, &url)));
}

Просмотреть файл

@ -31,14 +31,14 @@ impl HTMLInputElementDerived for EventTarget {
}
impl HTMLInputElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLInputElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLInputElement {
HTMLInputElement {
htmlelement: HTMLElement::new_inherited(HTMLInputElementTypeId, localName, document)
}
}
#[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);
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
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)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
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)
}
@ -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() {
"disabled" => {
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() {
"disabled" => {
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();
}
@ -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()) {
node.check_ancestors_disabled_state_for_form_control();
} else {

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLLabelElementDerived for EventTarget {
}
impl HTMLLabelElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLabelElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLLabelElement {
HTMLLabelElement {
htmlelement: HTMLElement::new_inherited(HTMLLabelElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLLabelElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLLegendElementDerived for EventTarget {
}
impl HTMLLegendElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLegendElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLLegendElement {
HTMLLegendElement {
htmlelement: HTMLElement::new_inherited(HTMLLegendElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLLegendElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLLIElementDerived for EventTarget {
}
impl HTMLLIElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLIElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLLIElement {
HTMLLIElement {
htmlelement: HTMLElement::new_inherited(HTMLLIElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLLIElementBinding::Wrap)
}

Просмотреть файл

@ -35,14 +35,14 @@ impl HTMLLinkElementDerived for EventTarget {
}
impl HTMLLinkElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLLinkElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLLinkElement {
HTMLLinkElement {
htmlelement: HTMLElement::new_inherited(HTMLLinkElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLLinkElementBinding::Wrap)
}
@ -50,7 +50,7 @@ impl HTMLLinkElement {
impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
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)
}
@ -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() {
"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() {
"href" => node.set_enabled_state(false),
_ => ()
@ -87,7 +87,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
}
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;
// we get unrooting order failures if these are inside the match.
@ -119,7 +119,7 @@ trait PrivateHTMLLinkElementHelpers {
impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
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) {
Ok(url) => {
let LayoutChan(ref layout_chan) = *window.deref().page().layout_chan;

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLMapElementDerived for EventTarget {
}
impl HTMLMapElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMapElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLMapElement {
HTMLMapElement {
htmlelement: HTMLElement::new_inherited(HTMLMapElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLMapElementBinding::Wrap)
}

Просмотреть файл

@ -29,7 +29,7 @@ impl HTMLMediaElementDerived for EventTarget {
}
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 {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, document)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLMetaElementDerived for EventTarget {
}
impl HTMLMetaElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMetaElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLMetaElement {
HTMLMetaElement {
htmlelement: HTMLElement::new_inherited(HTMLMetaElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLMetaElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLMeterElementDerived for EventTarget {
}
impl HTMLMeterElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLMeterElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLMeterElement {
HTMLMeterElement {
htmlelement: HTMLElement::new_inherited(HTMLMeterElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLMeterElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLModElementDerived for EventTarget {
}
impl HTMLModElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLModElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLModElement {
HTMLModElement {
htmlelement: HTMLElement::new_inherited(HTMLModElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLModElementBinding::Wrap)
}

Просмотреть файл

@ -39,14 +39,14 @@ impl HTMLObjectElementDerived for EventTarget {
}
impl HTMLObjectElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLObjectElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLObjectElement {
HTMLObjectElement {
htmlelement: HTMLElement::new_inherited(HTMLObjectElementTypeId, localName, document),
}
}
#[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);
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
/// prefetching the image. This method must be called after `data` is changed.
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
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> {
fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root();
ValidityState::new(&*window)
let window = window_from_node(*self).root();
ValidityState::new(*window)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
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)
}
@ -102,7 +102,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
}
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());
}
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLOListElementDerived for EventTarget {
}
impl HTMLOListElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOListElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLOListElement {
HTMLOListElement {
htmlelement: HTMLElement::new_inherited(HTMLOListElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLOListElementBinding::Wrap)
}

Просмотреть файл

@ -31,14 +31,14 @@ impl HTMLOptGroupElementDerived for EventTarget {
}
impl HTMLOptGroupElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOptGroupElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLOptGroupElement {
HTMLOptGroupElement {
htmlelement: HTMLElement::new_inherited(HTMLOptGroupElementTypeId, localName, document)
}
}
#[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);
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
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)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
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)
}
@ -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() {
"disabled" => {
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() {
"disabled" => {
node.set_disabled_state(false);

Просмотреть файл

@ -31,14 +31,14 @@ impl HTMLOptionElementDerived for EventTarget {
}
impl HTMLOptionElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOptionElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLOptionElement {
HTMLOptionElement {
htmlelement: HTMLElement::new_inherited(HTMLOptionElementTypeId, localName, document)
}
}
#[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);
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
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)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
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)
}
@ -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() {
"disabled" => {
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() {
"disabled" => {
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();
}
@ -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() {
node.check_parent_disabled_state_for_option();
} else {

Просмотреть файл

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

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLParagraphElementDerived for EventTarget {
}
impl HTMLParagraphElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLParagraphElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLParagraphElement {
HTMLParagraphElement {
htmlelement: HTMLElement::new_inherited(HTMLParagraphElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLParagraphElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLParamElementDerived for EventTarget {
}
impl HTMLParamElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLParamElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLParamElement {
HTMLParamElement {
htmlelement: HTMLElement::new_inherited(HTMLParamElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLParamElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLPreElementDerived for EventTarget {
}
impl HTMLPreElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLPreElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLPreElement {
HTMLPreElement {
htmlelement: HTMLElement::new_inherited(HTMLPreElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLPreElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLProgressElementDerived for EventTarget {
}
impl HTMLProgressElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLProgressElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLProgressElement {
HTMLProgressElement {
htmlelement: HTMLElement::new_inherited(HTMLProgressElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLProgressElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLQuoteElementDerived for EventTarget {
}
impl HTMLQuoteElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLQuoteElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLQuoteElement {
HTMLQuoteElement {
htmlelement: HTMLElement::new_inherited(HTMLQuoteElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLQuoteElementBinding::Wrap)
}

Просмотреть файл

@ -32,14 +32,14 @@ impl HTMLScriptElementDerived for EventTarget {
}
impl HTMLScriptElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLScriptElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLScriptElement {
HTMLScriptElement {
htmlelement: HTMLElement::new_inherited(HTMLScriptElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLScriptElementBinding::Wrap)
}
@ -74,7 +74,7 @@ static SCRIPT_JS_MIMES: StaticStringVec = &[
impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
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()) {
Some(ref s) if s.is_empty() => {
// 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> {
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")
}
// http://www.whatwg.org/html/#dom-script-text
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())
}
// http://www.whatwg.org/html/#dom-script-text
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))
}
}

Просмотреть файл

@ -34,14 +34,14 @@ impl HTMLSelectElementDerived for EventTarget {
}
impl HTMLSelectElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSelectElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLSelectElement {
HTMLSelectElement {
htmlelement: HTMLElement::new_inherited(HTMLSelectElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLSelectElementBinding::Wrap)
}
@ -49,8 +49,8 @@ impl HTMLSelectElement {
impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> {
fn Validity(&self) -> Temporary<ValidityState> {
let window = window_from_node(self).root();
ValidityState::new(&*window)
let window = window_from_node(*self).root();
ValidityState::new(*window)
}
// 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
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)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
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)
}
@ -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() {
"disabled" => {
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() {
"disabled" => {
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();
}
@ -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()) {
node.check_ancestors_disabled_state_for_form_control();
} else {

Просмотреть файл

@ -34,24 +34,24 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
}
match node.type_id() {
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)
}
CommentNodeTypeId => {
let comment: &JSRef<Comment> = CommentCast::to_ref(&node).unwrap();
let comment: JSRef<Comment> = CommentCast::to_ref(node).unwrap();
serialize_comment(comment, &mut html)
}
TextNodeTypeId => {
let text: &JSRef<Text> = TextCast::to_ref(&node).unwrap();
let text: JSRef<Text> = TextCast::to_ref(node).unwrap();
serialize_text(text, &mut html)
}
DoctypeNodeTypeId => {
let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(&node).unwrap();
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
serialize_doctype(doctype, &mut html)
}
ProcessingInstructionNodeTypeId => {
let processing_instruction: &JSRef<ProcessingInstruction> =
ProcessingInstructionCast::to_ref(&node).unwrap();
let processing_instruction: JSRef<ProcessingInstruction> =
ProcessingInstructionCast::to_ref(node).unwrap();
serialize_processing_instruction(processing_instruction, &mut html)
}
DocumentFragmentNodeTypeId => {}
@ -68,17 +68,17 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
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(comment.deref().characterdata.data.deref().borrow().as_slice());
html.push_str("-->");
}
fn serialize_text(text: &JSRef<Text>, html: &mut String) {
let text_node: &JSRef<Node> = NodeCast::from_ref(text);
fn serialize_text(text: JSRef<Text>, html: &mut String) {
let text_node: JSRef<Node> = NodeCast::from_ref(text);
match text_node.parent_node().map(|node| node.root()) {
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() {
"style" | "script" | "xmp" | "iframe" |
"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.push_str("<?");
html.push_str(processing_instruction.deref().target.as_slice());
@ -100,27 +100,27 @@ fn serialize_processing_instruction(processing_instruction: &JSRef<ProcessingIns
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.deref().name.as_slice());
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_str(elem.deref().local_name.as_slice());
for attr in elem.deref().attrs.borrow().iter() {
let attr = attr.root();
serialize_attr(&*attr, html);
serialize_attr(*attr, html);
};
html.push_char('>');
match elem.deref().local_name.as_slice() {
"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()) {
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' {
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(' ');
if attr.deref().namespace == namespace::XML {
html.push_str("xml:");

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLSourceElementDerived for EventTarget {
}
impl HTMLSourceElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSourceElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLSourceElement {
HTMLSourceElement {
htmlelement: HTMLElement::new_inherited(HTMLSourceElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLSourceElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLSpanElementDerived for EventTarget {
}
impl HTMLSpanElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSpanElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLSpanElement {
HTMLSpanElement {
htmlelement: HTMLElement::new_inherited(HTMLSpanElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLSpanElementBinding::Wrap)
}

Просмотреть файл

@ -30,14 +30,14 @@ impl HTMLStyleElementDerived for EventTarget {
}
impl HTMLStyleElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLStyleElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLStyleElement {
HTMLStyleElement {
htmlelement: HTMLElement::new_inherited(HTMLStyleElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLStyleElementBinding::Wrap)
}
@ -49,7 +49,7 @@ pub trait StyleElementHelpers {
impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
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());
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> {
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)
}
fn child_inserted(&self, child: &JSRef<Node>) {
fn child_inserted(&self, child: JSRef<Node>) {
match self.super_type() {
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() {
self.parse_own_css();
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTableCaptionElementDerived for EventTarget {
}
impl HTMLTableCaptionElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableCaptionElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableCaptionElement {
HTMLTableCaptionElement {
htmlelement: HTMLElement::new_inherited(HTMLTableCaptionElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTableCaptionElementBinding::Wrap)
}

Просмотреть файл

@ -29,7 +29,7 @@ impl HTMLTableCellElementDerived for EventTarget {
}
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 {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, document)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTableColElementDerived for EventTarget {
}
impl HTMLTableColElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableColElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableColElement {
HTMLTableColElement {
htmlelement: HTMLElement::new_inherited(HTMLTableColElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTableColElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTableDataCellElementDerived for EventTarget {
}
impl HTMLTableDataCellElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableDataCellElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableDataCellElement {
HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTableDataCellElementBinding::Wrap)
}

Просмотреть файл

@ -30,14 +30,14 @@ impl HTMLTableElementDerived for EventTarget {
}
impl HTMLTableElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableElement {
HTMLTableElement {
htmlelement: HTMLElement::new_inherited(HTMLTableElementTypeId, localName, document)
}
}
#[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);
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
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| {
child.type_id() == ElementNodeTypeId(HTMLTableCaptionElementTypeId)
}).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
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();
match old_caption {
Some(htmlelem) => {
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());
}
None => ()
}
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());
});
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTableHeaderCellElementDerived for EventTarget {
}
impl HTMLTableHeaderCellElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableHeaderCellElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableHeaderCellElement {
HTMLTableHeaderCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableHeaderCellElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTableHeaderCellElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTableRowElementDerived for EventTarget {
}
impl HTMLTableRowElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableRowElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableRowElement {
HTMLTableRowElement {
htmlelement: HTMLElement::new_inherited(HTMLTableRowElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTableRowElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTableSectionElementDerived for EventTarget {
}
impl HTMLTableSectionElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTableSectionElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTableSectionElement {
HTMLTableSectionElement {
htmlelement: HTMLElement::new_inherited(HTMLTableSectionElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTableSectionElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTemplateElementDerived for EventTarget {
}
impl HTMLTemplateElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTemplateElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTemplateElement {
HTMLTemplateElement {
htmlelement: HTMLElement::new_inherited(HTMLTemplateElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTemplateElementBinding::Wrap)
}

Просмотреть файл

@ -31,14 +31,14 @@ impl HTMLTextAreaElementDerived for EventTarget {
}
impl HTMLTextAreaElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTextAreaElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTextAreaElement {
HTMLTextAreaElement {
htmlelement: HTMLElement::new_inherited(HTMLTextAreaElementTypeId, localName, document)
}
}
#[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);
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
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)
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
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)
}
@ -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() {
"disabled" => {
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() {
"disabled" => {
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();
}
@ -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()) {
node.check_ancestors_disabled_state_for_form_control();
} else {

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTimeElementDerived for EventTarget {
}
impl HTMLTimeElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTimeElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTimeElement {
HTMLTimeElement {
htmlelement: HTMLElement::new_inherited(HTMLTimeElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTimeElementBinding::Wrap)
}

Просмотреть файл

@ -29,14 +29,14 @@ impl HTMLTitleElementDerived for EventTarget {
}
impl HTMLTitleElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTitleElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTitleElement {
HTMLTitleElement {
htmlelement: HTMLElement::new_inherited(HTMLTitleElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTitleElementBinding::Wrap)
}
@ -45,10 +45,10 @@ impl HTMLTitleElement {
impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
// http://www.whatwg.org/html/#dom-title-text
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();
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 {
Some(text) => content.push_str(text.characterdata.data.borrow().as_slice()),
None => (),
@ -59,7 +59,7 @@ impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
// http://www.whatwg.org/html/#dom-title-text
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))
}
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLTrackElementDerived for EventTarget {
}
impl HTMLTrackElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTrackElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTrackElement {
HTMLTrackElement {
htmlelement: HTMLElement::new_inherited(HTMLTrackElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLTrackElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLUListElementDerived for EventTarget {
}
impl HTMLUListElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLUListElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLUListElement {
HTMLUListElement {
htmlelement: HTMLElement::new_inherited(HTMLUListElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLUListElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLUnknownElementDerived for EventTarget {
}
impl HTMLUnknownElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLUnknownElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLUnknownElement {
HTMLUnknownElement {
htmlelement: HTMLElement::new_inherited(HTMLUnknownElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLUnknownElementBinding::Wrap)
}

Просмотреть файл

@ -26,14 +26,14 @@ impl HTMLVideoElementDerived for EventTarget {
}
impl HTMLVideoElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLVideoElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLVideoElement {
HTMLVideoElement {
htmlmediaelement: HTMLMediaElement::new_inherited(HTMLVideoElementTypeId, localName, document)
}
}
#[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);
Node::reflect_node(box element, document, HTMLVideoElementBinding::Wrap)
}

Просмотреть файл

@ -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),
&Window(*window),
&Window(window),
LocationBinding::Wrap)
}
}

Просмотреть файл

@ -11,7 +11,7 @@ macro_rules! make_getter(
use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast;
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())
}
);
@ -24,7 +24,7 @@ macro_rules! make_bool_getter(
use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast;
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())
}
);
@ -37,7 +37,7 @@ macro_rules! make_uint_getter(
use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast;
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())
}
);

Просмотреть файл

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

Просмотреть файл

@ -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(),
&Window(*window),
&Window(window),
MouseEventBinding::Wrap)
}
pub fn new(window: &JSRef<Window>,
pub fn new(window: JSRef<Window>,
type_: DOMString,
canBubble: bool,
cancelable: bool,
@ -84,7 +84,7 @@ impl MouseEvent {
screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey,
button, relatedTarget);
Temporary::from_rooted(&*ev)
Temporary::from_rooted(*ev)
}
pub fn Constructor(global: &GlobalRef,
@ -160,7 +160,7 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
metaKeyArg: bool,
buttonArg: i16,
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);
self.screen_x.deref().set(screenXArg);
self.screen_y.deref().set(screenYArg);

Просмотреть файл

@ -19,16 +19,16 @@ pub struct NamedNodeMap {
}
impl NamedNodeMap {
pub fn new_inherited(elem: &JSRef<Element>) -> NamedNodeMap {
pub fn new_inherited(elem: JSRef<Element>) -> NamedNodeMap {
NamedNodeMap {
reflector_: Reflector::new(),
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),
&Window(*window), NamedNodeMapBinding::Wrap)
&Window(window), NamedNodeMapBinding::Wrap)
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше