Make RootedVec/RootCollection #[no_move]; improve code (fixes #5737)

This commit is contained in:
Manish Goregaokar 2015-04-26 23:31:40 +05:30
parent dcb0a0eab6
commit 369a568264
7 changed files with 8 additions and 8 deletions

View file

@ -577,6 +577,7 @@ impl<T: Assignable<U>, U: Reflectable> TemporaryPushable<T> for Vec<JS<U>> {
///
/// See also [*Exact Stack Rooting - Storing a GCPointer on the CStack*]
/// (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/GC/Exact_Stack_Rooting).
#[no_move]
pub struct RootCollection {
roots: UnsafeCell<RootedVec<*mut JSObject>>,
}

View file

@ -401,6 +401,7 @@ impl VecRootableType for *mut JSObject {
/// A vector of items that are rooted for the lifetime
/// of this struct
#[allow(unrooted_must_root)]
#[no_move]
pub struct RootedVec<T> {
v: Vec<T>
}

View file

@ -728,7 +728,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
fn get_attributes(self, local_name: &Atom, attributes: &mut RootedVec<JS<Attr>>) {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attrs = self.attrs.borrow();
for attr in attrs.iter().map(|attr| attr.root()) {
for ref attr in attrs.iter().map(|attr| attr.root()) {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r();
let attr_local_name = attr.local_name();

View file

@ -841,7 +841,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
.find(|r| r.r().form_owner() == owner);
}
match submit_button {
Some(button) => {
Some(ref button) => {
if button.r().is_instance_activatable() {
button.r().synthetic_click_activation(ctrlKey, shiftKey, altKey, metaKey)
}

View file

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMet
use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived;
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, NodeCast};
use dom::bindings::js::{JS, JSRef, MutNullableHeap, Temporary};
use dom::bindings::js::OptionalRootable;
use dom::bindings::js::{OptionalRootable, RootedReference};
use dom::document::Document;
use dom::domtokenlist::DOMTokenList;
use dom::element::{AttributeHandlers, Element};
@ -60,9 +60,7 @@ impl HTMLLinkElement {
fn get_attr(element: JSRef<Element>, local_name: &Atom) -> Option<String> {
let elem = element.get_attribute(&ns!(""), local_name).root();
elem.as_ref().map(|e| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let e = e.r();
elem.r().map(|e| {
let value = e.value();
(**value).to_owned()
})

View file

@ -298,7 +298,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
}
let parent = self.parent_node().root();
parent.as_ref().map(|parent| vtable_for(&parent.r()).child_inserted(self));
parent.r().map(|parent| vtable_for(&parent).child_inserted(self));
document.r().content_and_heritage_changed(self, NodeDamage::OtherNodeDamage);
}

View file

@ -937,7 +937,7 @@ impl ScriptTask {
self.find_iframe(doc.r(), old_subpage_id)
}).root();
frame_element.as_ref().unwrap().r().update_subpage_id(new_subpage_id);
frame_element.r().unwrap().update_subpage_id(new_subpage_id);
}
/// Handles a notification that reflow completed.