Rename JS<T> to Dom<T>

This commit is contained in:
Anthony Ramine 2017-09-25 23:56:32 +02:00
parent 0e3c54c191
commit 7be32fb237
96 changed files with 494 additions and 494 deletions

View file

@ -143,7 +143,7 @@ use dom_struct::dom_struct;
#[dom_struct]
pub struct Document {
node: Node,
window: JS<Window>,
window: Dom<Window>,
is_html_document: bool,
...
}
@ -164,11 +164,11 @@ relationship. The `Document` just has a pointer to a `Window`, one of many
pointers to that object, which can live in native DOM data structures or in
JavaScript objects. These are precisely the pointers we need to tell the
garbage collector about. We do this with a
[custom type for traced pointers: `JS<T>`][js] (for example, the `JS<Window>`
above). The implementation of `trace` for `JS<T>` is not auto-generated; this
[custom type for traced pointers: `Dom<T>`][dom] (for example, the `Dom<Window>`
above). The implementation of `trace` for `Dom<T>` is not auto-generated; this
is where we actually call the SpiderMonkey trace hooks:
[js]: http://doc.servo.org/script/dom/bindings/root/struct.JS.html
[dom]: http://doc.servo.org/script/dom/bindings/root/struct.Dom.html
```rust
pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
@ -183,7 +183,7 @@ pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Ref
}
}
impl<T: DomObject> JSTraceable for JS<T> {
impl<T: DomObject> JSTraceable for Dom<T> {
unsafe fn trace(&self, trc: *mut JSTracer) {
trace_reflector(trc, "", unsafe { (**self.ptr).reflector() });
}
@ -257,11 +257,11 @@ through a `Root<T>`.
[deref]: https://doc.rust-lang.org/std/ops/trait.Deref.html
A third way to obtain a reference is from the `JS<T>` struct we encountered
earlier. Whenever we have a reference to a `JS<T>`, we know that the DOM struct
A third way to obtain a reference is from the `Dom<T>` struct we encountered
earlier. Whenever we have a reference to a `Dom<T>`, we know that the DOM struct
that contains it is already rooted, and thus that the garbage collector is
aware of the `JS<T>`, and will keep the DOM object it points to alive.
This allows us to implement the `Deref` trait on `JS<T>` as well.
aware of the `Dom<T>`, and will keep the DOM object it points to alive.
This allows us to implement the `Deref` trait on `Dom<T>` as well.
The correctness of these APIs is heavily dependent on the fact that the
reference cannot outlive the smart pointer it was retrieved from, and the fact
@ -298,10 +298,10 @@ To recapitulate, the safety of our system depends on two major parts:
from Rust without telling SpiderMonkey about our temporary reference.
But there's a hole in this scheme. We could copy an unrooted pointer — a
`JS<T>` — to a local variable on the stack, and then at some later point, root
`Dom<T>` — to a local variable on the stack, and then at some later point, root
it and use the DOM object. In the meantime, SpiderMonkey's garbage collector
won't know about that `JS<T>` on the stack, so it might free the DOM object.
To really be safe, we need to make sure that `JS<T>` *only* appears in places
won't know about that `Dom<T>` on the stack, so it might free the DOM object.
To really be safe, we need to make sure that `Dom<T>` *only* appears in places
where it will be traced, such as DOM structs, and never in local variables,
function arguments, and so forth.
@ -315,10 +315,10 @@ Developing the Servo Web Browser Engine using Rust</cite>][lints].
[lints]: http://arxiv.org/pdf/1505.07383v1.pdf
We have already [implemented a plugin][js-lint] which effectively forbids
`JS<T>` from appearing on the [stack][stack]. Because lint plugins are part of
`Dom<T>` from appearing on the [stack][stack]. Because lint plugins are part of
the usual [warnings infrastructure][warnings], we can use the `allow` attribute
in places where it's okay to use `JS<T>`, like DOM struct definitions and the
implementation of `JS<T>` itself.
in places where it's okay to use `Dom<T>`, like DOM struct definitions and the
implementation of `Dom<T>` itself.
[js-lint]: http://doc.servo.org/plugins/lints/unrooted_must_root/struct.UnrootedPass.html
[stack]: https://en.wikipedia.org/wiki/Stack-based_memory_allocation

View file

@ -5,7 +5,7 @@
//! Tracking of pending loads in a document.
//! https://html.spec.whatwg.org/multipage/#the-end
use dom::bindings::root::JS;
use dom::bindings::root::Dom;
use dom::document::Document;
use ipc_channel::ipc::IpcSender;
use net_traits::{CoreResourceMsg, FetchResponseMsg, ResourceThreads, IpcSend};
@ -43,7 +43,7 @@ impl LoadType {
#[must_root]
pub struct LoadBlocker {
/// The document whose load event is blocked by this object existing.
doc: JS<Document>,
doc: Dom<Document>,
/// The load that is blocking the document's load event.
load: Option<LoadType>,
}
@ -53,7 +53,7 @@ impl LoadBlocker {
pub fn new(doc: &Document, load: LoadType) -> LoadBlocker {
doc.loader_mut().add_blocking_load(load.clone());
LoadBlocker {
doc: JS::from_ref(doc),
doc: Dom::from_ref(doc),
load: Some(load),
}
}

View file

@ -6,7 +6,7 @@
use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript};
use dom::bindings::utils::AsCCharPtrPtr;
use dom::globalscope::GlobalScope;
@ -53,7 +53,7 @@ pub struct CallbackObject {
///
/// ["callback context"]: https://heycam.github.io/webidl/#dfn-callback-context
/// [sometimes]: https://github.com/whatwg/html/issues/2248
incumbent: Option<JS<GlobalScope>>
incumbent: Option<Dom<GlobalScope>>
}
impl Default for CallbackObject {
@ -69,7 +69,7 @@ impl CallbackObject {
CallbackObject {
callback: Heap::default(),
permanent_js_root: Heap::default(),
incumbent: GlobalScope::incumbent().map(|i| JS::from_ref(&*i)),
incumbent: GlobalScope::incumbent().map(|i| Dom::from_ref(&*i)),
}
}
@ -120,7 +120,7 @@ pub trait CallbackContainer {
///
/// ["callback context"]: https://heycam.github.io/webidl/#dfn-callback-context
fn incumbent(&self) -> Option<&GlobalScope> {
self.callback_holder().incumbent.as_ref().map(JS::deref)
self.callback_holder().incumbent.as_ref().map(Dom::deref)
}
}

View file

@ -1272,7 +1272,7 @@ class CGArgumentConverter(CGThing):
arg = "arg%d" % index
if argument.type.isGeckoInterface():
init = "rooted_vec!(let mut %s)" % arg
innerConverter.append(CGGeneric("%s.push(JS::from_ref(&*slot));" % arg))
innerConverter.append(CGGeneric("%s.push(Dom::from_ref(&*slot));" % arg))
else:
init = "let mut %s = vec![]" % arg
innerConverter.append(CGGeneric("%s.push(slot);" % arg))
@ -5712,7 +5712,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'dom::bindings::namespace::create_namespace_object',
'dom::bindings::reflector::MutDomObject',
'dom::bindings::reflector::DomObject',
'dom::bindings::root::JS',
'dom::bindings::root::Dom',
'dom::bindings::root::OptionalHeapSetter',
'dom::bindings::root::Root',
'dom::bindings::root::RootedReference',
@ -6961,7 +6961,7 @@ class CallbackGetter(CallbackMember):
needThisHandling=False)
def getRvalDecl(self):
return "JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());\n"
return "Dom::Rooted<Dom::Value> rval(cx, JS::UndefinedValue());\n"
def getCall(self):
replacements = {
@ -7195,7 +7195,7 @@ class GlobalGenRoots():
imports = [CGGeneric("use dom::types::*;\n"),
CGGeneric("use dom::bindings::conversions::{DerivedFrom, get_dom_class};\n"),
CGGeneric("use dom::bindings::inheritance::Castable;\n"),
CGGeneric("use dom::bindings::root::{JS, LayoutJS, Root};\n"),
CGGeneric("use dom::bindings::root::{Dom, LayoutJS, Root};\n"),
CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
CGGeneric("use dom::bindings::reflector::DomObject;\n"),
CGGeneric("use js::jsapi::JSTracer;\n\n"),

View file

@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndVal
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult;
use dom::bindings::error::Fallible;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::trace::JSTraceable;
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
@ -51,7 +51,7 @@ pub trait Iterable {
#[dom_struct]
pub struct IterableIterator<T: DomObject + JSTraceable + Iterable> {
reflector: Reflector,
iterable: JS<T>,
iterable: Dom<T>,
type_: IteratorType,
index: Cell<u32>,
}
@ -65,7 +65,7 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
let iterator = box IterableIterator {
reflector: Reflector::new(),
type_: type_,
iterable: JS::from_ref(iterable),
iterable: Dom::from_ref(iterable),
index: Cell::new(0),
};
reflect_dom_object(iterator, &*iterable.global(), wrap)

View file

@ -12,10 +12,10 @@
//! Here is a brief overview of the important types:
//!
//! - `Root<T>`: a stack-based reference to a rooted DOM object.
//! - `JS<T>`: a reference to a DOM object that can automatically be traced by
//! - `Dom<T>`: a reference to a DOM object that can automatically be traced by
//! the GC when encountered as a field of a Rust structure.
//!
//! `JS<T>` does not allow access to their inner value without explicitly
//! `Dom<T>` does not allow access to their inner value without explicitly
//! creating a stack-based root via the `root` method. This returns a `Root<T>`,
//! which causes the JS-owned value to be uncollectable for the duration of the
//! `Root` object's lifetime. A reference to the object can then be obtained
@ -50,24 +50,24 @@ use style::thread_state;
/// A traced reference to a DOM object
///
/// This type is critical to making garbage collection work with the DOM,
/// but it is very dangerous; if garbage collection happens with a `JS<T>`
/// on the stack, the `JS<T>` can point to freed memory.
/// but it is very dangerous; if garbage collection happens with a `Dom<T>`
/// on the stack, the `Dom<T>` can point to freed memory.
///
/// This should only be used as a field in other DOM objects.
#[must_root]
pub struct JS<T> {
pub struct Dom<T> {
ptr: NonZero<*const T>,
}
// JS<T> is similar to Rc<T>, in that it's not always clear how to avoid double-counting.
// Dom<T> is similar to Rc<T>, in that it's not always clear how to avoid double-counting.
// For now, we choose not to follow any such pointers.
impl<T> HeapSizeOf for JS<T> {
impl<T> HeapSizeOf for Dom<T> {
fn heap_size_of_children(&self) -> usize {
0
}
}
impl<T> JS<T> {
impl<T> Dom<T> {
/// Returns `LayoutJS<T>` containing the same pointer.
pub unsafe fn to_layout(&self) -> LayoutJS<T> {
debug_assert!(thread_state::get().is_layout());
@ -77,36 +77,36 @@ impl<T> JS<T> {
}
}
impl<T: DomObject> JS<T> {
/// Create a JS<T> from a &T
impl<T: DomObject> Dom<T> {
/// Create a Dom<T> from a &T
#[allow(unrooted_must_root)]
pub fn from_ref(obj: &T) -> JS<T> {
pub fn from_ref(obj: &T) -> Dom<T> {
debug_assert!(thread_state::get().is_script());
JS {
Dom {
ptr: unsafe { NonZero::new_unchecked(&*obj) },
}
}
}
impl<'root, T: DomObject + 'root> RootedReference<'root> for JS<T> {
impl<'root, T: DomObject + 'root> RootedReference<'root> for Dom<T> {
type Ref = &'root T;
fn r(&'root self) -> &'root T {
&self
}
}
impl<T: DomObject> Deref for JS<T> {
impl<T: DomObject> Deref for Dom<T> {
type Target = T;
fn deref(&self) -> &T {
debug_assert!(thread_state::get().is_script());
// We can only have &JS<T> from a rooted thing, so it's safe to deref
// We can only have &Dom<T> from a rooted thing, so it's safe to deref
// it to &T.
unsafe { &*self.ptr.get() }
}
}
unsafe impl<T: DomObject> JSTraceable for JS<T> {
unsafe impl<T: DomObject> JSTraceable for Dom<T> {
unsafe fn trace(&self, trc: *mut JSTracer) {
#[cfg(debug_assertions)]
let trace_str = format!("for {} on heap", type_name::<T>());
@ -169,13 +169,13 @@ impl<T: DomObject> LayoutJS<T> {
impl<T> Copy for LayoutJS<T> {}
impl<T> PartialEq for JS<T> {
fn eq(&self, other: &JS<T>) -> bool {
impl<T> PartialEq for Dom<T> {
fn eq(&self, other: &Dom<T>) -> bool {
self.ptr == other.ptr
}
}
impl<T> Eq for JS<T> {}
impl<T> Eq for Dom<T> {}
impl<T> PartialEq for LayoutJS<T> {
fn eq(&self, other: &LayoutJS<T>) -> bool {
@ -185,7 +185,7 @@ impl<T> PartialEq for LayoutJS<T> {
impl<T> Eq for LayoutJS<T> {}
impl<T> Hash for JS<T> {
impl<T> Hash for Dom<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.ptr.hash(state)
}
@ -197,12 +197,12 @@ impl<T> Hash for LayoutJS<T> {
}
}
impl <T> Clone for JS<T> {
impl <T> Clone for Dom<T> {
#[inline]
#[allow(unrooted_must_root)]
fn clone(&self) -> JS<T> {
fn clone(&self) -> Dom<T> {
debug_assert!(thread_state::get().is_script());
JS {
Dom {
ptr: self.ptr.clone(),
}
}
@ -231,14 +231,14 @@ impl LayoutJS<Node> {
}
/// A holder that provides interior mutability for GC-managed values such as
/// `JS<T>`. Essentially a `Cell<JS<T>>`, but safer.
/// `Dom<T>`. Essentially a `Cell<Dom<T>>`, but safer.
///
/// This should only be used as a field in other DOM objects; see warning
/// on `JS<T>`.
/// on `Dom<T>`.
#[must_root]
#[derive(JSTraceable)]
pub struct MutJS<T: DomObject> {
val: UnsafeCell<JS<T>>,
val: UnsafeCell<Dom<T>>,
}
impl<T: DomObject> MutJS<T> {
@ -246,7 +246,7 @@ impl<T: DomObject> MutJS<T> {
pub fn new(initial: &T) -> MutJS<T> {
debug_assert!(thread_state::get().is_script());
MutJS {
val: UnsafeCell::new(JS::from_ref(initial)),
val: UnsafeCell::new(Dom::from_ref(initial)),
}
}
@ -254,7 +254,7 @@ impl<T: DomObject> MutJS<T> {
pub fn set(&self, val: &T) {
debug_assert!(thread_state::get().is_script());
unsafe {
*self.val.get() = JS::from_ref(val);
*self.val.get() = Dom::from_ref(val);
}
}
@ -269,7 +269,7 @@ impl<T: DomObject> MutJS<T> {
impl<T: DomObject> HeapSizeOf for MutJS<T> {
fn heap_size_of_children(&self) -> usize {
// See comment on HeapSizeOf for JS<T>.
// See comment on HeapSizeOf for Dom<T>.
0
}
}
@ -291,15 +291,15 @@ impl<T: DomObject + PartialEq> PartialEq<T> for MutJS<T> {
}
/// A holder that provides interior mutability for GC-managed values such as
/// `JS<T>`, with nullability represented by an enclosing Option wrapper.
/// Essentially a `Cell<Option<JS<T>>>`, but safer.
/// `Dom<T>`, with nullability represented by an enclosing Option wrapper.
/// Essentially a `Cell<Option<Dom<T>>>`, but safer.
///
/// This should only be used as a field in other DOM objects; see warning
/// on `JS<T>`.
/// on `Dom<T>`.
#[must_root]
#[derive(JSTraceable)]
pub struct MutNullableJS<T: DomObject> {
ptr: UnsafeCell<Option<JS<T>>>,
ptr: UnsafeCell<Option<Dom<T>>>,
}
impl<T: DomObject> MutNullableJS<T> {
@ -307,7 +307,7 @@ impl<T: DomObject> MutNullableJS<T> {
pub fn new(initial: Option<&T>) -> MutNullableJS<T> {
debug_assert!(thread_state::get().is_script());
MutNullableJS {
ptr: UnsafeCell::new(initial.map(JS::from_ref)),
ptr: UnsafeCell::new(initial.map(Dom::from_ref)),
}
}
@ -327,7 +327,7 @@ impl<T: DomObject> MutNullableJS<T> {
}
}
/// Retrieve a copy of the inner optional `JS<T>` as `LayoutJS<T>`.
/// Retrieve a copy of the inner optional `Dom<T>` as `LayoutJS<T>`.
/// For use by layout, which can't use safe types like Temporary.
#[allow(unrooted_must_root)]
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
@ -348,7 +348,7 @@ impl<T: DomObject> MutNullableJS<T> {
pub fn set(&self, val: Option<&T>) {
debug_assert!(thread_state::get().is_script());
unsafe {
*self.ptr.get() = val.map(|p| JS::from_ref(p));
*self.ptr.get() = val.map(|p| Dom::from_ref(p));
}
}
@ -371,7 +371,7 @@ impl<T: DomObject> PartialEq for MutNullableJS<T> {
impl<'a, T: DomObject> PartialEq<Option<&'a T>> for MutNullableJS<T> {
fn eq(&self, other: &Option<&T>) -> bool {
unsafe {
*self.ptr.get() == other.map(JS::from_ref)
*self.ptr.get() == other.map(Dom::from_ref)
}
}
}
@ -388,20 +388,20 @@ impl<T: DomObject> Default for MutNullableJS<T> {
impl<T: DomObject> HeapSizeOf for MutNullableJS<T> {
fn heap_size_of_children(&self) -> usize {
// See comment on HeapSizeOf for JS<T>.
// See comment on HeapSizeOf for Dom<T>.
0
}
}
/// A holder that allows to lazily initialize the value only once
/// `JS<T>`, using OnceCell
/// Essentially a `OnceCell<JS<T>>`.
/// `Dom<T>`, using OnceCell
/// Essentially a `OnceCell<Dom<T>>`.
///
/// This should only be used as a field in other DOM objects; see warning
/// on `JS<T>`.
/// on `Dom<T>`.
#[must_root]
pub struct OnceCellJS<T: DomObject> {
ptr: OnceCell<JS<T>>,
ptr: OnceCell<Dom<T>>,
}
impl<T: DomObject> OnceCellJS<T> {
@ -412,7 +412,7 @@ impl<T: DomObject> OnceCellJS<T> {
where F: FnOnce() -> Root<T>
{
debug_assert!(thread_state::get().is_script());
&self.ptr.init_once(|| JS::from_ref(&cb()))
&self.ptr.init_once(|| Dom::from_ref(&cb()))
}
}
@ -428,7 +428,7 @@ impl<T: DomObject> Default for OnceCellJS<T> {
impl<T: DomObject> HeapSizeOf for OnceCellJS<T> {
fn heap_size_of_children(&self) -> usize {
// See comment on HeapSizeOf for JS<T>.
// See comment on HeapSizeOf for Dom<T>.
0
}
}
@ -468,7 +468,7 @@ pub trait RootedReference<'root> {
fn r(&'root self) -> Self::Ref;
}
impl<'root, T: JSTraceable + DomObject + 'root> RootedReference<'root> for [JS<T>] {
impl<'root, T: JSTraceable + DomObject + 'root> RootedReference<'root> for [Dom<T>] {
type Ref = &'root [&'root T];
fn r(&'root self) -> &'root [&'root T] {
unsafe { mem::transmute(self) }

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::trace::JSTraceable;
use dom::globalscope::GlobalScope;
use js::jsapi::GetScriptedCallerGlobal;
@ -24,7 +24,7 @@ enum StackEntryKind {
#[allow(unrooted_must_root)]
#[derive(JSTraceable)]
struct StackEntry {
global: JS<GlobalScope>,
global: Dom<GlobalScope>,
kind: StackEntryKind,
}
@ -47,7 +47,7 @@ impl AutoEntryScript {
trace!("Prepare to run script with {:p}", global);
let mut stack = stack.borrow_mut();
stack.push(StackEntry {
global: JS::from_ref(global),
global: Dom::from_ref(global),
kind: StackEntryKind::Entry,
});
AutoEntryScript {
@ -109,7 +109,7 @@ impl AutoIncumbentScript {
// Step 1.
let mut stack = stack.borrow_mut();
stack.push(StackEntry {
global: JS::from_ref(global),
global: Dom::from_ref(global),
kind: StackEntryKind::Incumbent,
});
AutoIncumbentScript {

View file

@ -18,9 +18,9 @@
//! achieved via `unsafe_no_jsmanaged_fields!` or similar.
//! 3. For all fields, `Foo::trace()`
//! calls `trace()` on the field.
//! For example, for fields of type `JS<T>`, `JS<T>::trace()` calls
//! For example, for fields of type `Dom<T>`, `Dom<T>::trace()` calls
//! `trace_reflector()`.
//! 4. `trace_reflector()` calls `JS::TraceEdge()` with a
//! 4. `trace_reflector()` calls `Dom::TraceEdge()` with a
//! pointer to the `JSObject` for the reflector. This notifies the GC, which
//! will add the object to the graph, and will trace that object as well.
//! 5. When the GC finishes tracing, it [`finalizes`](../index.html#destruction)
@ -42,7 +42,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::error::Error;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::utils::WindowProxyHandler;
use dom::document::PendingRestyle;
@ -840,16 +840,16 @@ impl<'a, T: 'static + JSTraceable> RootedVec<'a, T> {
}
}
impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, JS<T>> {
/// Create a vector of items of type JS<T> that is rooted for
impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, Dom<T>> {
/// Create a vector of items of type Dom<T> that is rooted for
/// the lifetime of this struct
pub fn from_iter<I>(root: &'a mut RootableVec<JS<T>>, iter: I) -> Self
pub fn from_iter<I>(root: &'a mut RootableVec<Dom<T>>, iter: I) -> Self
where I: Iterator<Item = Root<T>>
{
unsafe {
RootedTraceableSet::add(root);
}
root.v.extend(iter.map(|item| JS::from_ref(&*item)));
root.v.extend(iter.map(|item| Dom::from_ref(&*item)));
RootedVec {
root: root,
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use dom::bindings::codegen::UnionTypes::BlobOrString;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
@ -44,7 +44,7 @@ pub enum BlobImpl {
/// relative positions of current slicing range,
/// IMPORTANT: The depth of tree is only two, i.e. the parent Blob must be
/// either File-based or Memory-based
Sliced(JS<Blob>, RelativePos),
Sliced(Dom<Blob>, RelativePos),
}
impl BlobImpl {
@ -101,11 +101,11 @@ impl Blob {
let blob_impl = match *parent.blob_impl.borrow() {
BlobImpl::File(_) => {
// Create new parent node
BlobImpl::Sliced(JS::from_ref(parent), rel_pos)
BlobImpl::Sliced(Dom::from_ref(parent), rel_pos)
}
BlobImpl::Memory(_) => {
// Create new parent node
BlobImpl::Sliced(JS::from_ref(parent), rel_pos)
BlobImpl::Sliced(Dom::from_ref(parent), rel_pos)
}
BlobImpl::Sliced(ref grandparent, ref old_rel_pos) => {
// Adjust the slicing position, using same parent

View file

@ -20,7 +20,7 @@ use dom::bindings::error::Error::{self, Network, Security, Type};
use dom::bindings::error::Fallible;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::bluetoothdevice::BluetoothDevice;
use dom::bluetoothpermissionresult::BluetoothPermissionResult;
@ -120,7 +120,7 @@ where
#[dom_struct]
pub struct Bluetooth {
eventtarget: EventTarget,
device_instance_map: DOMRefCell<HashMap<String, JS<BluetoothDevice>>>,
device_instance_map: DOMRefCell<HashMap<String, Dom<BluetoothDevice>>>,
}
impl Bluetooth {
@ -141,7 +141,7 @@ impl Bluetooth {
self.global().as_window().bluetooth_thread()
}
pub fn get_device_map(&self) -> &DOMRefCell<HashMap<String, JS<BluetoothDevice>>> {
pub fn get_device_map(&self) -> &DOMRefCell<HashMap<String, Dom<BluetoothDevice>>> {
&self.device_instance_map
}
@ -520,7 +520,7 @@ impl AsyncBluetoothListener for Bluetooth {
DOMString::from(device.id.clone()),
device.name.map(DOMString::from),
&self);
device_instance_map.insert(device.id.clone(), JS::from_ref(&bt_device));
device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device));
self.global().as_window().bluetooth_extra_permission_data().add_new_allowed_device(
AllowedBluetoothDevice {
@ -631,7 +631,7 @@ impl PermissionAlgorithm for Bluetooth {
// TODO: Implement this correctly, not just using device ids here.
// https://webbluetoothcg.github.io/web-bluetooth/#get-the-bluetoothdevice-representing
if let Some(device) = device_map.get(&device_id) {
matching_devices.push(JS::from_ref(&**device));
matching_devices.push(Dom::from_ref(&**device));
}
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods;
use dom::bindings::error::Fallible;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root, RootedReference};
use dom::bindings::root::{Dom, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::bluetoothdevice::BluetoothDevice;
use dom::event::{Event, EventBubbles, EventCancelable};
@ -21,7 +21,7 @@ use servo_atoms::Atom;
#[dom_struct]
pub struct BluetoothAdvertisingEvent {
event: Event,
device: JS<BluetoothDevice>,
device: Dom<BluetoothDevice>,
name: Option<DOMString>,
appearance: Option<u16>,
tx_power: Option<i8>,
@ -37,7 +37,7 @@ impl BluetoothAdvertisingEvent {
-> BluetoothAdvertisingEvent {
BluetoothAdvertisingEvent {
event: Event::new_inherited(),
device: JS::from_ref(device),
device: Dom::from_ref(device),
name: name,
appearance: appearance,
tx_power: tx_power,

View file

@ -12,7 +12,7 @@ use dom::bindings::error::Error;
use dom::bindings::error::ErrorResult;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::DOMString;
use dom::bluetooth::{AsyncBluetoothListener, Bluetooth, response_async};
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
@ -36,10 +36,10 @@ pub struct BluetoothDevice {
id: DOMString,
name: Option<DOMString>,
gatt: MutNullableJS<BluetoothRemoteGATTServer>,
context: JS<Bluetooth>,
attribute_instance_map: (DOMRefCell<HashMap<String, JS<BluetoothRemoteGATTService>>>,
DOMRefCell<HashMap<String, JS<BluetoothRemoteGATTCharacteristic>>>,
DOMRefCell<HashMap<String, JS<BluetoothRemoteGATTDescriptor>>>),
context: Dom<Bluetooth>,
attribute_instance_map: (DOMRefCell<HashMap<String, Dom<BluetoothRemoteGATTService>>>,
DOMRefCell<HashMap<String, Dom<BluetoothRemoteGATTCharacteristic>>>,
DOMRefCell<HashMap<String, Dom<BluetoothRemoteGATTDescriptor>>>),
watching_advertisements: Cell<bool>,
}
@ -53,7 +53,7 @@ impl BluetoothDevice {
id: id,
name: name,
gatt: Default::default(),
context: JS::from_ref(context),
context: Dom::from_ref(context),
attribute_instance_map: (DOMRefCell::new(HashMap::new()),
DOMRefCell::new(HashMap::new()),
DOMRefCell::new(HashMap::new())),
@ -97,7 +97,7 @@ impl BluetoothDevice {
DOMString::from(service.uuid.clone()),
service.is_primary,
service.instance_id.clone());
service_map.insert(service.instance_id.clone(), JS::from_ref(&bt_service));
service_map.insert(service.instance_id.clone(), Dom::from_ref(&bt_service));
return bt_service;
}
@ -126,7 +126,7 @@ impl BluetoothDevice {
DOMString::from(characteristic.uuid.clone()),
&properties,
characteristic.instance_id.clone());
characteristic_map.insert(characteristic.instance_id.clone(), JS::from_ref(&bt_characteristic));
characteristic_map.insert(characteristic.instance_id.clone(), Dom::from_ref(&bt_characteristic));
return bt_characteristic;
}
@ -150,7 +150,7 @@ impl BluetoothDevice {
characteristic,
DOMString::from(descriptor.uuid.clone()),
descriptor.instance_id.clone());
descriptor_map.insert(descriptor.instance_id.clone(), JS::from_ref(&bt_descriptor));
descriptor_map.insert(descriptor.instance_id.clone(), Dom::from_ref(&bt_descriptor));
return bt_descriptor;
}

View file

@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusB
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use dom::bindings::error::Error;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::bluetooth::{AsyncBluetoothListener, Bluetooth, AllowedBluetoothDevice};
use dom::bluetoothdevice::BluetoothDevice;
@ -26,7 +26,7 @@ use std::rc::Rc;
#[dom_struct]
pub struct BluetoothPermissionResult {
status: PermissionStatus,
devices: DOMRefCell<Vec<JS<BluetoothDevice>>>,
devices: DOMRefCell<Vec<Dom<BluetoothDevice>>>,
}
impl BluetoothPermissionResult {
@ -67,7 +67,7 @@ impl BluetoothPermissionResult {
}
#[allow(unrooted_must_root)]
pub fn set_devices(&self, devices: Vec<JS<BluetoothDevice>>) {
pub fn set_devices(&self, devices: Vec<Dom<BluetoothDevice>>) {
*self.devices.borrow_mut() = devices;
}
}
@ -93,7 +93,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
if let Some(ref existing_device) = device_instance_map.get(&device.id) {
// https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission
// Step 3.
self.set_devices(vec!(JS::from_ref(&*existing_device)));
self.set_devices(vec!(Dom::from_ref(&*existing_device)));
// https://w3c.github.io/permissions/#dom-permissions-request
// Step 8.
@ -103,7 +103,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
DOMString::from(device.id.clone()),
device.name.map(DOMString::from),
&bluetooth);
device_instance_map.insert(device.id.clone(), JS::from_ref(&bt_device));
device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device));
self.global().as_window().bluetooth_extra_permission_data().add_new_allowed_device(
AllowedBluetoothDevice {
deviceId: DOMString::from(device.id),
@ -112,7 +112,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
);
// https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission
// Step 3.
self.set_devices(vec!(JS::from_ref(&bt_device)));
self.set_devices(vec!(Dom::from_ref(&bt_device)));
// https://w3c.github.io/permissions/#dom-permissions-request
// Step 8.

View file

@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::Bluetoo
use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::{ByteString, DOMString};
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async};
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
@ -36,9 +36,9 @@ pub const MAXIMUM_ATTRIBUTE_LENGTH: usize = 512;
#[dom_struct]
pub struct BluetoothRemoteGATTCharacteristic {
eventtarget: EventTarget,
service: JS<BluetoothRemoteGATTService>,
service: Dom<BluetoothRemoteGATTService>,
uuid: DOMString,
properties: JS<BluetoothCharacteristicProperties>,
properties: Dom<BluetoothCharacteristicProperties>,
value: DOMRefCell<Option<ByteString>>,
instance_id: String,
}
@ -51,9 +51,9 @@ impl BluetoothRemoteGATTCharacteristic {
-> BluetoothRemoteGATTCharacteristic {
BluetoothRemoteGATTCharacteristic {
eventtarget: EventTarget::new_inherited(),
service: JS::from_ref(service),
service: Dom::from_ref(service),
uuid: uuid,
properties: JS::from_ref(properties),
properties: Dom::from_ref(properties),
value: DOMRefCell::new(None),
instance_id: instance_id,
}

View file

@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
use dom::bindings::error::Error::{self, InvalidModification, Network, Security};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::{ByteString, DOMString};
use dom::bluetooth::{AsyncBluetoothListener, response_async};
use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};
@ -27,7 +27,7 @@ use std::rc::Rc;
#[dom_struct]
pub struct BluetoothRemoteGATTDescriptor {
reflector_: Reflector,
characteristic: JS<BluetoothRemoteGATTCharacteristic>,
characteristic: Dom<BluetoothRemoteGATTCharacteristic>,
uuid: DOMString,
value: DOMRefCell<Option<ByteString>>,
instance_id: String,
@ -40,7 +40,7 @@ impl BluetoothRemoteGATTDescriptor {
-> BluetoothRemoteGATTDescriptor {
BluetoothRemoteGATTDescriptor {
reflector_: Reflector::new(),
characteristic: JS::from_ref(characteristic),
characteristic: Dom::from_ref(characteristic),
uuid: uuid,
value: DOMRefCell::new(None),
instance_id: instance_id,

View file

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
use dom::bindings::error::Error;
use dom::bindings::error::ErrorResult;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async};
use dom::bluetoothdevice::BluetoothDevice;
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
@ -24,7 +24,7 @@ use std::rc::Rc;
#[dom_struct]
pub struct BluetoothRemoteGATTServer {
reflector_: Reflector,
device: JS<BluetoothDevice>,
device: Dom<BluetoothDevice>,
connected: Cell<bool>,
}
@ -32,7 +32,7 @@ impl BluetoothRemoteGATTServer {
pub fn new_inherited(device: &BluetoothDevice) -> BluetoothRemoteGATTServer {
BluetoothRemoteGATTServer {
reflector_: Reflector::new(),
device: JS::from_ref(device),
device: Dom::from_ref(device),
connected: Cell::new(false),
}
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
use dom::bindings::error::Error;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children};
use dom::bluetoothdevice::BluetoothDevice;
@ -23,7 +23,7 @@ use std::rc::Rc;
#[dom_struct]
pub struct BluetoothRemoteGATTService {
eventtarget: EventTarget,
device: JS<BluetoothDevice>,
device: Dom<BluetoothDevice>,
uuid: DOMString,
is_primary: bool,
instance_id: String,
@ -37,7 +37,7 @@ impl BluetoothRemoteGATTService {
-> BluetoothRemoteGATTService {
BluetoothRemoteGATTService {
eventtarget: EventTarget::new_inherited(),
device: JS::from_ref(device),
device: Dom::from_ref(device),
uuid: uuid,
is_primary: is_primary,
instance_id: instance_id,

View file

@ -23,7 +23,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, LayoutJS, Root};
use dom::bindings::root::{Dom, LayoutJS, Root};
use dom::bindings::str::DOMString;
use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
use dom::canvaspattern::CanvasPattern;
@ -55,8 +55,8 @@ use unpremultiplytable::UNPREMULTIPLY_TABLE;
#[allow(dead_code)]
enum CanvasFillOrStrokeStyle {
Color(RGBA),
Gradient(JS<CanvasGradient>),
Pattern(JS<CanvasPattern>),
Gradient(Dom<CanvasGradient>),
Pattern(Dom<CanvasPattern>),
}
// https://html.spec.whatwg.org/multipage/#canvasrenderingcontext2d
@ -67,7 +67,7 @@ pub struct CanvasRenderingContext2D {
ipc_renderer: IpcSender<CanvasMsg>,
/// For rendering contexts created by an HTML canvas element, this is Some,
/// for ones created by a paint worklet, this is None.
canvas: Option<JS<HTMLCanvasElement>>,
canvas: Option<Dom<HTMLCanvasElement>>,
#[ignore_heap_size_of = "Arc"]
image_cache: Arc<ImageCache>,
/// Any missing image URLs.
@ -138,7 +138,7 @@ impl CanvasRenderingContext2D {
CanvasRenderingContext2D {
reflector_: Reflector::new(),
ipc_renderer: ipc_renderer,
canvas: canvas.map(JS::from_ref),
canvas: canvas.map(Dom::from_ref),
image_cache: image_cache,
missing_image_urls: DOMRefCell::new(Vec::new()),
base_url: base_url,
@ -1019,14 +1019,14 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
},
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(gradient) => {
self.state.borrow_mut().stroke_style =
CanvasFillOrStrokeStyle::Gradient(JS::from_ref(&*gradient));
CanvasFillOrStrokeStyle::Gradient(Dom::from_ref(&*gradient));
let msg = CanvasMsg::Canvas2d(
Canvas2dMsg::SetStrokeStyle(gradient.to_fill_or_stroke_style()));
self.ipc_renderer.send(msg).unwrap();
},
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(pattern) => {
self.state.borrow_mut().stroke_style =
CanvasFillOrStrokeStyle::Pattern(JS::from_ref(&*pattern));
CanvasFillOrStrokeStyle::Pattern(Dom::from_ref(&*pattern));
let msg = CanvasMsg::Canvas2d(
Canvas2dMsg::SetStrokeStyle(pattern.to_fill_or_stroke_style()));
self.ipc_renderer.send(msg).unwrap();
@ -1068,14 +1068,14 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
}
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(gradient) => {
self.state.borrow_mut().fill_style =
CanvasFillOrStrokeStyle::Gradient(JS::from_ref(&*gradient));
CanvasFillOrStrokeStyle::Gradient(Dom::from_ref(&*gradient));
let msg = CanvasMsg::Canvas2d(
Canvas2dMsg::SetFillStyle(gradient.to_fill_or_stroke_style()));
self.ipc_renderer.send(msg).unwrap();
}
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(pattern) => {
self.state.borrow_mut().fill_style =
CanvasFillOrStrokeStyle::Pattern(JS::from_ref(&*pattern));
CanvasFillOrStrokeStyle::Pattern(Dom::from_ref(&*pattern));
let msg = CanvasMsg::Canvas2d(
Canvas2dMsg::SetFillStyle(pattern.to_fill_or_stroke_style()));
self.ipc_renderer.send(msg).unwrap();

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::{self, CSSKeyframeRuleMethods};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::DOMString;
use dom::cssrule::{CSSRule, SpecificCSSRule};
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
@ -51,7 +51,7 @@ impl CSSKeyframeRuleMethods for CSSKeyframeRule {
CSSStyleDeclaration::new(
self.global().as_window(),
CSSStyleOwner::CSSRule(
JS::from_ref(self.upcast()),
Dom::from_ref(self.upcast()),
self.keyframerule.read_with(&guard).block.clone(),
),
None,

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::Reflector;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::cssfontfacerule::CSSFontFaceRule;
use dom::cssimportrule::CSSImportRule;
@ -27,7 +27,7 @@ use style::stylesheets::CssRule as StyleCssRule;
#[dom_struct]
pub struct CSSRule {
reflector_: Reflector,
parent_stylesheet: JS<CSSStyleSheet>,
parent_stylesheet: Dom<CSSStyleSheet>,
/// Whether the parentStyleSheet attribute should return null.
/// We keep parent_stylesheet in that case because insertRule needs it
@ -40,7 +40,7 @@ impl CSSRule {
pub fn new_inherited(parent_stylesheet: &CSSStyleSheet) -> CSSRule {
CSSRule {
reflector_: Reflector::new(),
parent_stylesheet: JS::from_ref(parent_stylesheet),
parent_stylesheet: Dom::from_ref(parent_stylesheet),
parent_stylesheet_removed: Cell::new(false),
}
}

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSRuleListBinding;
use dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::csskeyframerule::CSSKeyframeRule;
use dom::cssrule::CSSRule;
use dom::cssstylesheet::CSSStyleSheet;
@ -36,7 +36,7 @@ impl From<RulesMutateError> for Error {
#[dom_struct]
pub struct CSSRuleList {
reflector_: Reflector,
parent_stylesheet: JS<CSSStyleSheet>,
parent_stylesheet: Dom<CSSStyleSheet>,
#[ignore_heap_size_of = "Arc"]
rules: RulesSource,
dom_rules: DOMRefCell<Vec<MutNullableJS<CSSRule>>>
@ -62,7 +62,7 @@ impl CSSRuleList {
CSSRuleList {
reflector_: Reflector::new(),
parent_stylesheet: JS::from_ref(parent_stylesheet),
parent_stylesheet: Dom::from_ref(parent_stylesheet),
rules: rules,
dom_rules: DOMRefCell::new(dom_rules),
}

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::cssrule::CSSRule;
use dom::element::Element;
@ -36,8 +36,8 @@ pub struct CSSStyleDeclaration {
#[derive(HeapSizeOf, JSTraceable)]
#[must_root]
pub enum CSSStyleOwner {
Element(JS<Element>),
CSSRule(JS<CSSRule>,
Element(Dom<Element>),
CSSRule(Dom<CSSRule>,
#[ignore_heap_size_of = "Arc"]
Arc<Locked<PropertyDeclarationBlock>>),
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::CSSStyleRuleBinding::{self, CSSStyleRuleMe
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::DOMString;
use dom::cssrule::{CSSRule, SpecificCSSRule};
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
@ -69,7 +69,7 @@ impl CSSStyleRuleMethods for CSSStyleRule {
CSSStyleDeclaration::new(
self.global().as_window(),
CSSStyleOwner::CSSRule(
JS::from_ref(self.upcast()),
Dom::from_ref(self.upcast()),
self.stylerule.read_with(&guard).block.clone()
),
None,

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::reflector::{reflect_dom_object, DomObject};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::DOMString;
use dom::cssrulelist::{CSSRuleList, RulesSource};
use dom::element::Element;
@ -22,7 +22,7 @@ use style::stylesheets::Stylesheet as StyleStyleSheet;
#[dom_struct]
pub struct CSSStyleSheet {
stylesheet: StyleSheet,
owner: JS<Element>,
owner: Dom<Element>,
rulelist: MutNullableJS<CSSRuleList>,
#[ignore_heap_size_of = "Arc"]
style_stylesheet: Arc<StyleStyleSheet>,
@ -37,7 +37,7 @@ impl CSSStyleSheet {
stylesheet: Arc<StyleStyleSheet>) -> CSSStyleSheet {
CSSStyleSheet {
stylesheet: StyleSheet::new_inherited(type_, href, title),
owner: JS::from_ref(owner),
owner: Dom::from_ref(owner),
rulelist: MutNullableJS::new(None),
style_stylesheet: stylesheet,
origin_clean: Cell::new(true),

View file

@ -14,7 +14,7 @@ use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, Stringi
use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception, throw_dom_exception};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::domexception::{DOMErrorName, DOMException};
@ -45,7 +45,7 @@ use std::rc::Rc;
pub struct CustomElementRegistry {
reflector_: Reflector,
window: JS<Window>,
window: Dom<Window>,
#[ignore_heap_size_of = "Rc"]
when_defined: DOMRefCell<HashMap<LocalName, Rc<Promise>>>,
@ -60,7 +60,7 @@ impl CustomElementRegistry {
fn new_inherited(window: &Window) -> CustomElementRegistry {
CustomElementRegistry {
reflector_: Reflector::new(),
window: JS::from_ref(window),
window: Dom::from_ref(window),
when_defined: DOMRefCell::new(HashMap::new()),
element_definition_is_running: Cell::new(false),
definitions: DOMRefCell::new(HashMap::new()),
@ -776,7 +776,7 @@ impl CustomElementReactionStack {
#[derive(HeapSizeOf, JSTraceable)]
#[must_root]
struct ElementQueue {
queue: DOMRefCell<VecDeque<JS<Element>>>,
queue: DOMRefCell<VecDeque<Dom<Element>>>,
}
impl ElementQueue {
@ -796,11 +796,11 @@ impl ElementQueue {
}
fn next_element(&self) -> Option<Root<Element>> {
self.queue.borrow_mut().pop_front().as_ref().map(JS::deref).map(Root::from_ref)
self.queue.borrow_mut().pop_front().as_ref().map(Dom::deref).map(Root::from_ref)
}
fn append_element(&self, element: &Element) {
self.queue.borrow_mut().push_back(JS::from_ref(element));
self.queue.borrow_mut().push_back(Dom::from_ref(element));
}
}

View file

@ -86,7 +86,7 @@ pub struct DedicatedWorkerGlobalScope {
own_sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>,
#[ignore_heap_size_of = "Defined in std"]
timer_event_port: Receiver<(TrustedWorkerAddress, TimerEvent)>,
#[ignore_heap_size_of = "Trusted<T> has unclear ownership like JS<T>"]
#[ignore_heap_size_of = "Trusted<T> has unclear ownership like Dom<T>"]
worker: DOMRefCell<Option<TrustedWorkerAddress>>,
#[ignore_heap_size_of = "Can't measure trait objects"]
/// Sender to the parent thread.

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DissimilarOriginLocationBinding::Dissimila
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::reflector::Reflector;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::bindings::str::USVString;
use dom::dissimilaroriginwindow::DissimilarOriginWindow;
@ -27,7 +27,7 @@ pub struct DissimilarOriginLocation {
reflector: Reflector,
/// The window associated with this location.
window: JS<DissimilarOriginWindow>,
window: Dom<DissimilarOriginWindow>,
}
impl DissimilarOriginLocation {
@ -35,7 +35,7 @@ impl DissimilarOriginLocation {
fn new_inherited(window: &DissimilarOriginWindow) -> DissimilarOriginLocation {
DissimilarOriginLocation {
reflector: Reflector::new(),
window: JS::from_ref(window),
window: Dom::from_ref(window),
}
}

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding;
use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding::DissimilarOriginWindowMethods;
use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::DOMString;
use dom::bindings::structuredclone::StructuredCloneData;
use dom::dissimilaroriginlocation::DissimilarOriginLocation;
@ -37,7 +37,7 @@ pub struct DissimilarOriginWindow {
globalscope: GlobalScope,
/// The window proxy for this window.
window_proxy: JS<WindowProxy>,
window_proxy: Dom<WindowProxy>,
/// The location of this window, initialized lazily.
location: MutNullableJS<DissimilarOriginLocation>,
@ -67,7 +67,7 @@ impl DissimilarOriginWindow {
// here, but this whole DOM interface is a hack anyway.
global_to_clone_from.microtask_queue().clone(),
),
window_proxy: JS::from_ref(window_proxy),
window_proxy: Dom::from_ref(window_proxy),
location: Default::default(),
};
unsafe { DissimilarOriginWindowBinding::Wrap(cx, win) }

View file

@ -27,7 +27,7 @@ use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, Nod
use dom::bindings::num::Finite;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
use dom::bindings::xmlname::XMLName::InvalidXMLName;
@ -196,7 +196,7 @@ impl PendingRestyle {
struct StyleSheetInDocument {
#[ignore_heap_size_of = "Arc"]
sheet: Arc<Stylesheet>,
owner: JS<Element>,
owner: Dom<Element>,
}
impl PartialEq for StyleSheetInDocument {
@ -223,7 +223,7 @@ impl ::style::stylesheets::StylesheetInDocument for StyleSheetInDocument {
#[dom_struct]
pub struct Document {
node: Node,
window: JS<Window>,
window: Dom<Window>,
implementation: MutNullableJS<DOMImplementation>,
content_type: DOMString,
last_modified: Option<String>,
@ -235,10 +235,10 @@ pub struct Document {
#[ignore_heap_size_of = "defined in selectors"]
quirks_mode: Cell<QuirksMode>,
/// Caches for the getElement methods
id_map: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>,
tag_map: DOMRefCell<HashMap<LocalName, JS<HTMLCollection>>>,
tagns_map: DOMRefCell<HashMap<QualName, JS<HTMLCollection>>>,
classes_map: DOMRefCell<HashMap<Vec<Atom>, JS<HTMLCollection>>>,
id_map: DOMRefCell<HashMap<Atom, Vec<Dom<Element>>>>,
tag_map: DOMRefCell<HashMap<LocalName, Dom<HTMLCollection>>>,
tagns_map: DOMRefCell<HashMap<QualName, Dom<HTMLCollection>>>,
classes_map: DOMRefCell<HashMap<Vec<Atom>, Dom<HTMLCollection>>>,
images: MutNullableJS<HTMLCollection>,
embeds: MutNullableJS<HTMLCollection>,
links: MutNullableJS<HTMLCollection>,
@ -270,7 +270,7 @@ pub struct Document {
/// https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-in-order-as-soon-as-possible
asap_in_order_scripts_list: PendingInOrderScriptVec,
/// https://html.spec.whatwg.org/multipage/#set-of-scripts-that-will-execute-as-soon-as-possible
asap_scripts_set: DOMRefCell<Vec<JS<HTMLScriptElement>>>,
asap_scripts_set: DOMRefCell<Vec<Dom<HTMLScriptElement>>>,
/// https://html.spec.whatwg.org/multipage/#concept-n-noscript
/// True if scripting is enabled for all scripts in this document
scripting_enabled: bool,
@ -298,12 +298,12 @@ pub struct Document {
appropriate_template_contents_owner_document: MutNullableJS<Document>,
/// Information on elements needing restyle to ship over to the layout thread when the
/// time comes.
pending_restyles: DOMRefCell<HashMap<JS<Element>, PendingRestyle>>,
pending_restyles: DOMRefCell<HashMap<Dom<Element>, PendingRestyle>>,
/// This flag will be true if layout suppressed a reflow attempt that was
/// needed in order for the page to be painted.
needs_paint: Cell<bool>,
/// http://w3c.github.io/touch-events/#dfn-active-touch-point
active_touch_points: DOMRefCell<Vec<JS<Touch>>>,
active_touch_points: DOMRefCell<Vec<Dom<Touch>>>,
/// Navigation Timing properties:
/// https://w3c.github.io/navigation-timing/#sec-PerformanceNavigationTiming
dom_loading: Cell<u64>,
@ -347,7 +347,7 @@ pub struct Document {
/// whenever any element with the same ID as the form attribute
/// is inserted or removed from the document.
/// See https://html.spec.whatwg.org/multipage/#form-owner
form_id_listener_map: DOMRefCell<HashMap<Atom, HashSet<JS<Element>>>>,
form_id_listener_map: DOMRefCell<HashMap<Atom, HashSet<Dom<Element>>>>,
}
#[derive(HeapSizeOf, JSTraceable)]
@ -659,13 +659,13 @@ impl Document {
let mut map = self.form_id_listener_map.borrow_mut();
let listener = listener.to_element();
let set = map.entry(Atom::from(id)).or_insert(HashSet::new());
set.insert(JS::from_ref(listener));
set.insert(Dom::from_ref(listener));
}
pub fn unregister_form_id_listener<T: ?Sized + FormControl>(&self, id: DOMString, listener: &T) {
let mut map = self.form_id_listener_map.borrow_mut();
if let Occupied(mut entry) = map.entry(Atom::from(id)) {
entry.get_mut().remove(&JS::from_ref(listener.to_element()));
entry.get_mut().remove(&Dom::from_ref(listener.to_element()));
if entry.get().is_empty() {
entry.remove();
}
@ -1274,13 +1274,13 @@ impl Document {
match event_type {
TouchEventType::Down => {
// Add a new touch point
self.active_touch_points.borrow_mut().push(JS::from_ref(&*touch));
self.active_touch_points.borrow_mut().push(Dom::from_ref(&*touch));
}
TouchEventType::Move => {
// Replace an existing touch point
let mut active_touch_points = self.active_touch_points.borrow_mut();
match active_touch_points.iter_mut().find(|t| t.Identifier() == identifier) {
Some(t) => *t = JS::from_ref(&*touch),
Some(t) => *t = Dom::from_ref(&*touch),
None => warn!("Got a touchmove event for a non-active touch point"),
}
}
@ -1820,7 +1820,7 @@ impl Document {
// https://html.spec.whatwg.org/multipage/#set-of-scripts-that-will-execute-as-soon-as-possible
pub fn add_asap_script(&self, script: &HTMLScriptElement) {
self.asap_scripts_set.borrow_mut().push(JS::from_ref(script));
self.asap_scripts_set.borrow_mut().push(Dom::from_ref(script));
}
/// https://html.spec.whatwg.org/multipage/#the-end step 5.
@ -2217,7 +2217,7 @@ impl Document {
Document {
node: Node::new_document_node(),
window: JS::from_ref(window),
window: Dom::from_ref(window),
has_browsing_context: has_browsing_context == HasBrowsingContext::Yes,
implementation: Default::default(),
content_type: match content_type {
@ -2426,7 +2426,7 @@ impl Document {
None,
StyleSheetInDocument {
sheet: s.clone(),
owner: JS::from_ref(owner),
owner: Dom::from_ref(owner),
},
&guard,
);
@ -2461,7 +2461,7 @@ impl Document {
let sheet = StyleSheetInDocument {
sheet,
owner: JS::from_ref(owner),
owner: Dom::from_ref(owner),
};
let lock = self.style_shared_lock();
@ -2522,7 +2522,7 @@ impl Document {
pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> {
let map = self.pending_restyles.borrow_mut();
RefMut::map(map, |m| m.entry(JS::from_ref(el)).or_insert_with(PendingRestyle::new))
RefMut::map(map, |m| m.entry(Dom::from_ref(el)).or_insert_with(PendingRestyle::new))
}
pub fn element_state_will_change(&self, el: &Element) {
@ -2748,7 +2748,7 @@ impl Element {
impl DocumentMethods for Document {
// https://drafts.csswg.org/cssom/#dom-document-stylesheets
fn StyleSheets(&self) -> Root<StyleSheetList> {
self.stylesheet_list.or_init(|| StyleSheetList::new(&self.window, JS::from_ref(&self)))
self.stylesheet_list.or_init(|| StyleSheetList::new(&self.window, Dom::from_ref(&self)))
}
// https://dom.spec.whatwg.org/#dom-document-implementation
@ -2916,7 +2916,7 @@ impl DocumentMethods for Document {
Vacant(entry) => {
let result = HTMLCollection::by_qualified_name(
&self.window, self.upcast(), qualified_name);
entry.insert(JS::from_ref(&*result));
entry.insert(Dom::from_ref(&*result));
result
}
}
@ -2934,7 +2934,7 @@ impl DocumentMethods for Document {
Occupied(entry) => Root::from_ref(entry.get()),
Vacant(entry) => {
let result = HTMLCollection::by_qual_tag_name(&self.window, self.upcast(), qname);
entry.insert(JS::from_ref(&*result));
entry.insert(Dom::from_ref(&*result));
result
}
}
@ -2951,7 +2951,7 @@ impl DocumentMethods for Document {
let result = HTMLCollection::by_atomic_class_name(&self.window,
self.upcast(),
class_atoms);
entry.insert(JS::from_ref(&*result));
entry.insert(Dom::from_ref(&*result));
result
}
}
@ -4117,17 +4117,17 @@ impl PendingInOrderScriptVec {
#[derive(HeapSizeOf, JSTraceable)]
#[must_root]
struct PendingScript {
element: JS<HTMLScriptElement>,
element: Dom<HTMLScriptElement>,
load: Option<ScriptResult>,
}
impl PendingScript {
fn new(element: &HTMLScriptElement) -> Self {
Self { element: JS::from_ref(element), load: None }
Self { element: Dom::from_ref(element), load: None }
}
fn new_with_load(element: &HTMLScriptElement, load: Option<ScriptResult>) -> Self {
Self { element: JS::from_ref(element), load }
Self { element: Dom::from_ref(element), load }
}
fn loaded(&mut self, result: ScriptResult) {

View file

@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::error::Fallible;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::bindings::xmlname::{namespace_from_domstring, validate_qualified_name};
use dom::document::{Document, HasBrowsingContext, IsHTMLDocument};
@ -30,14 +30,14 @@ use script_traits::DocumentActivity;
#[dom_struct]
pub struct DOMImplementation {
reflector_: Reflector,
document: JS<Document>,
document: Dom<Document>,
}
impl DOMImplementation {
fn new_inherited(document: &Document) -> DOMImplementation {
DOMImplementation {
reflector_: Reflector::new(),
document: JS::from_ref(document),
document: Dom::from_ref(document),
}
}

View file

@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::Fallible;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::document::{Document, HasBrowsingContext, IsHTMLDocument};
use dom::document::DocumentSource;
@ -25,14 +25,14 @@ use script_traits::DocumentActivity;
#[dom_struct]
pub struct DOMParser {
reflector_: Reflector,
window: JS<Window>, // XXXjdm Document instead?
window: Dom<Window>, // XXXjdm Document instead?
}
impl DOMParser {
fn new_inherited(window: &Window) -> DOMParser {
DOMParser {
reflector_: Reflector::new(),
window: JS::from_ref(window),
window: Dom::from_ref(window),
}
}

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMetho
use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectInit;
use dom::bindings::error::Fallible;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{Root, JS};
use dom::bindings::root::{Root, Dom};
use dom::dompoint::DOMPoint;
use dom::domrect::DOMRect;
use dom::globalscope::GlobalScope;
@ -17,10 +17,10 @@ use dom_struct::dom_struct;
#[dom_struct]
pub struct DOMQuad {
reflector_: Reflector,
p1: JS<DOMPoint>,
p2: JS<DOMPoint>,
p3: JS<DOMPoint>,
p4: JS<DOMPoint>,
p1: Dom<DOMPoint>,
p2: Dom<DOMPoint>,
p3: Dom<DOMPoint>,
p4: Dom<DOMPoint>,
}
impl DOMQuad {
@ -31,10 +31,10 @@ impl DOMQuad {
-> DOMQuad {
DOMQuad {
reflector_: Reflector::new(),
p1: JS::from_ref(p1),
p2: JS::from_ref(p2),
p3: JS::from_ref(p3),
p4: JS::from_ref(p4),
p1: Dom::from_ref(p1),
p2: Dom::from_ref(p2),
p3: Dom::from_ref(p3),
p4: Dom::from_ref(p4),
}
}

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::DOMStringMapBinding;
use dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods;
use dom::bindings::error::ErrorResult;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::htmlelement::HTMLElement;
use dom::node::window_from_node;
@ -15,14 +15,14 @@ use dom_struct::dom_struct;
#[dom_struct]
pub struct DOMStringMap {
reflector_: Reflector,
element: JS<HTMLElement>,
element: Dom<HTMLElement>,
}
impl DOMStringMap {
fn new_inherited(element: &HTMLElement) -> DOMStringMap {
DOMStringMap {
reflector_: Reflector::new(),
element: JS::from_ref(element),
element: Dom::from_ref(element),
}
}

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMTokenListBinding;
use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::element::Element;
use dom::node::window_from_node;
@ -19,7 +19,7 @@ use style::str::HTML_SPACE_CHARACTERS;
#[dom_struct]
pub struct DOMTokenList {
reflector_: Reflector,
element: JS<Element>,
element: Dom<Element>,
local_name: LocalName,
}
@ -27,7 +27,7 @@ impl DOMTokenList {
pub fn new_inherited(element: &Element, local_name: LocalName) -> DOMTokenList {
DOMTokenList {
reflector_: Reflector::new(),
element: JS::from_ref(element),
element: Dom::from_ref(element),
local_name: local_name,
}
}

View file

@ -24,7 +24,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{JS, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
use dom::bindings::xmlname::XMLName::InvalidXMLName;
@ -131,7 +131,7 @@ pub struct Element {
tag_name: TagName,
namespace: Namespace,
prefix: DOMRefCell<Option<Prefix>>,
attrs: DOMRefCell<Vec<JS<Attr>>>,
attrs: DOMRefCell<Vec<Dom<Attr>>>,
id_attribute: DOMRefCell<Option<Atom>>,
is: DOMRefCell<Option<LocalName>>,
#[ignore_heap_size_of = "Arc"]
@ -912,7 +912,7 @@ impl Element {
*self.prefix.borrow_mut() = prefix;
}
pub fn attrs(&self) -> Ref<[JS<Attr>]> {
pub fn attrs(&self) -> Ref<[Dom<Attr>]> {
Ref::map(self.attrs.borrow(), |attrs| &**attrs)
}
@ -1118,7 +1118,7 @@ impl Element {
assert!(attr.GetOwnerElement().r() == Some(self));
self.will_mutate_attr(attr);
self.attrs.borrow_mut().push(JS::from_ref(attr));
self.attrs.borrow_mut().push(Dom::from_ref(attr));
if attr.namespace() == &ns!() {
vtable_for(self.upcast()).attribute_mutated(attr, AttributeMutation::Set(None));
}
@ -1692,7 +1692,7 @@ impl ElementMethods for Element {
}
self.will_mutate_attr(attr);
attr.set_owner(Some(self));
self.attrs.borrow_mut()[position] = JS::from_ref(attr);
self.attrs.borrow_mut()[position] = Dom::from_ref(attr);
old_attr.set_owner(None);
if attr.namespace() == &ns!() {
vtable.attribute_mutated(

View file

@ -11,7 +11,7 @@ use dom::bindings::error::Fallible;
use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, MutNullableJS, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::eventtarget::{CompiledEventListener, EventTarget, ListenerPhase};
@ -137,13 +137,13 @@ impl Event {
// Step 4.
if let Some(target_node) = target.downcast::<Node>() {
for ancestor in target_node.ancestors() {
event_path.push(JS::from_ref(ancestor.upcast::<EventTarget>()));
event_path.push(Dom::from_ref(ancestor.upcast::<EventTarget>()));
}
let top_most_ancestor_or_target =
Root::from_ref(event_path.r().last().cloned().unwrap_or(target));
if let Some(document) = Root::downcast::<Document>(top_most_ancestor_or_target) {
if self.type_() != atom!("load") && document.browsing_context().is_some() {
event_path.push(JS::from_ref(document.window().upcast()));
event_path.push(Dom::from_ref(document.window().upcast()));
}
}
}

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::FileListBinding;
use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::file::File;
use dom::window::Window;
use dom_struct::dom_struct;
@ -15,12 +15,12 @@ use std::slice::Iter;
#[dom_struct]
pub struct FileList {
reflector_: Reflector,
list: Vec<JS<File>>
list: Vec<Dom<File>>
}
impl FileList {
#[allow(unrooted_must_root)]
fn new_inherited(files: Vec<JS<File>>) -> FileList {
fn new_inherited(files: Vec<Dom<File>>) -> FileList {
FileList {
reflector_: Reflector::new(),
list: files
@ -29,12 +29,12 @@ impl FileList {
#[allow(unrooted_must_root)]
pub fn new(window: &Window, files: Vec<Root<File>>) -> Root<FileList> {
reflect_dom_object(box FileList::new_inherited(files.iter().map(|r| JS::from_ref(&**r)).collect()),
reflect_dom_object(box FileList::new_inherited(files.iter().map(|r| Dom::from_ref(&**r)).collect()),
window,
FileListBinding::Wrap)
}
pub fn iter_files(&self) -> Iter<JS<File>> {
pub fn iter_files(&self) -> Iter<Dom<File>> {
self.list.iter()
}
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::GamepadBinding::GamepadMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::eventtarget::EventTarget;
@ -33,8 +33,8 @@ pub struct Gamepad {
timestamp: Cell<f64>,
mapping_type: String,
axes: Heap<*mut JSObject>,
buttons: JS<GamepadButtonList>,
pose: Option<JS<VRPose>>,
buttons: Dom<GamepadButtonList>,
pose: Option<Dom<VRPose>>,
#[ignore_heap_size_of = "Defined in rust-webvr"]
hand: WebVRGamepadHand,
display_id: u32
@ -60,8 +60,8 @@ impl Gamepad {
timestamp: Cell::new(timestamp),
mapping_type: mapping_type,
axes: Heap::default(),
buttons: JS::from_ref(buttons),
pose: pose.map(JS::from_ref),
buttons: Dom::from_ref(buttons),
pose: pose.map(Dom::from_ref),
hand: hand,
display_id: display_id
}

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::GamepadButtonListBinding;
use dom::bindings::codegen::Bindings::GamepadButtonListBinding::GamepadButtonListMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root, RootedReference};
use dom::bindings::root::{Dom, Root, RootedReference};
use dom::gamepadbutton::GamepadButton;
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
@ -15,7 +15,7 @@ use webvr_traits::WebVRGamepadButton;
#[dom_struct]
pub struct GamepadButtonList {
reflector_: Reflector,
list: Vec<JS<GamepadButton>>
list: Vec<Dom<GamepadButton>>
}
impl GamepadButtonList {
@ -23,7 +23,7 @@ impl GamepadButtonList {
fn new_inherited(list: &[&GamepadButton]) -> GamepadButtonList {
GamepadButtonList {
reflector_: Reflector::new(),
list: list.iter().map(|button| JS::from_ref(*button)).collect(),
list: list.iter().map(|button| Dom::from_ref(*button)).collect(),
}
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::GamepadEventBinding::GamepadEventMethods;
use dom::bindings::error::Fallible;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::gamepad::Gamepad;
@ -20,7 +20,7 @@ use servo_atoms::Atom;
#[dom_struct]
pub struct GamepadEvent {
event: Event,
gamepad: JS<Gamepad>,
gamepad: Dom<Gamepad>,
}
pub enum GamepadEventType {
@ -32,7 +32,7 @@ impl GamepadEvent {
fn new_inherited(gamepad: &Gamepad) -> GamepadEvent {
GamepadEvent {
event: Event::new_inherited(),
gamepad: JS::from_ref(gamepad),
gamepad: Dom::from_ref(gamepad),
}
}

View file

@ -6,7 +6,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::GamepadListBinding;
use dom::bindings::codegen::Bindings::GamepadListBinding::GamepadListMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::gamepad::Gamepad;
use dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
@ -15,14 +15,14 @@ use dom_struct::dom_struct;
#[dom_struct]
pub struct GamepadList {
reflector_: Reflector,
list: DOMRefCell<Vec<JS<Gamepad>>>
list: DOMRefCell<Vec<Dom<Gamepad>>>
}
impl GamepadList {
fn new_inherited(list: &[&Gamepad]) -> GamepadList {
GamepadList {
reflector_: Reflector::new(),
list: DOMRefCell::new(list.iter().map(|g| JS::from_ref(&**g)).collect())
list: DOMRefCell::new(list.iter().map(|g| Dom::from_ref(&**g)).collect())
}
}
@ -35,7 +35,7 @@ impl GamepadList {
pub fn add_if_not_exists(&self, gamepads: &[Root<Gamepad>]) {
for gamepad in gamepads {
if !self.list.borrow().iter().any(|g| g.gamepad_id() == gamepad.gamepad_id()) {
self.list.borrow_mut().push(JS::from_ref(&*gamepad));
self.list.borrow_mut().push(Dom::from_ref(&*gamepad));
// Ensure that the gamepad has the correct index
gamepad.update_index(self.list.borrow().len() as i32 - 1);
}

View file

@ -409,7 +409,7 @@ impl GlobalScope {
let _aes = AutoEntryScript::new(self);
let options = CompileOptionsWrapper::new(cx, filename.as_ptr(), line_number);
debug!("evaluating JS string");
debug!("evaluating Dom string");
let result = unsafe {
Evaluate2(cx, options.ptr, code.as_ptr(),
code.len() as libc::size_t,
@ -417,7 +417,7 @@ impl GlobalScope {
};
if !result {
debug!("error evaluating JS string");
debug!("error evaluating Dom string");
unsafe { report_pending_exception(cx, true) };
}

View file

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::globalscope::GlobalScope;
use dom::window::Window;
use dom_struct::dom_struct;
@ -21,14 +21,14 @@ use script_traits::ScriptMsg;
#[dom_struct]
pub struct History {
reflector_: Reflector,
window: JS<Window>,
window: Dom<Window>,
}
impl History {
pub fn new_inherited(window: &Window) -> History {
History {
reflector_: Reflector::new(),
window: JS::from_ref(&window),
window: Dom::from_ref(&window),
}
}

View file

@ -15,7 +15,7 @@ use dom::bindings::conversions::ConversionResult;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::root::{JS, LayoutJS, Root};
use dom::bindings::root::{Dom, LayoutJS, Root};
use dom::bindings::str::DOMString;
use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers};
use dom::document::Document;
@ -44,8 +44,8 @@ const DEFAULT_HEIGHT: u32 = 150;
#[must_root]
#[derive(Clone, HeapSizeOf, JSTraceable)]
pub enum CanvasContext {
Context2d(JS<CanvasRenderingContext2D>),
WebGL(JS<WebGLRenderingContext>),
Context2d(Dom<CanvasRenderingContext2D>),
WebGL(Dom<WebGLRenderingContext>),
}
#[dom_struct]
@ -156,7 +156,7 @@ impl HTMLCanvasElement {
let window = window_from_node(self);
let size = self.get_size();
let context = CanvasRenderingContext2D::new(window.upcast::<GlobalScope>(), self, size);
*self.context.borrow_mut() = Some(CanvasContext::Context2d(JS::from_ref(&*context)));
*self.context.borrow_mut() = Some(CanvasContext::Context2d(Dom::from_ref(&*context)));
}
match *self.context.borrow().as_ref().unwrap() {
@ -192,7 +192,7 @@ impl HTMLCanvasElement {
let maybe_ctx = WebGLRenderingContext::new(&window, self, size, attrs);
*self.context.borrow_mut() = maybe_ctx.map( |ctx| CanvasContext::WebGL(JS::from_ref(&*ctx)));
*self.context.borrow_mut() = maybe_ctx.map( |ctx| CanvasContext::WebGL(Dom::from_ref(&*ctx)));
}
if let Some(CanvasContext::WebGL(ref context)) = *self.context.borrow() {

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::HTMLCollectionBinding;
use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root, MutNullableJS};
use dom::bindings::root::{Dom, Root, MutNullableJS};
use dom::bindings::str::DOMString;
use dom::bindings::trace::JSTraceable;
use dom::bindings::xmlname::namespace_from_domstring;
@ -53,7 +53,7 @@ impl OptionU32 {
#[dom_struct]
pub struct HTMLCollection {
reflector_: Reflector,
root: JS<Node>,
root: Dom<Node>,
#[ignore_heap_size_of = "Contains a trait object; can't measure due to #6870"]
filter: Box<CollectionFilter + 'static>,
// We cache the version of the root node and all its decendents,
@ -70,7 +70,7 @@ impl HTMLCollection {
pub fn new_inherited(root: &Node, filter: Box<CollectionFilter + 'static>) -> HTMLCollection {
HTMLCollection {
reflector_: Reflector::new(),
root: JS::from_ref(root),
root: Dom::from_ref(root),
filter: filter,
// Default values for the cache
cached_version: Cell::new(root.inclusive_descendants_version()),

View file

@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::inheritance::{ElementTypeId, HTMLElementTypeId, NodeTypeId};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{JS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, MutNullableJS, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
use dom::document::{Document, FocusType};
@ -115,7 +115,7 @@ impl HTMLElementMethods for HTMLElement {
self.style_decl.or_init(|| {
let global = window_from_node(self);
CSSStyleDeclaration::new(&global,
CSSStyleOwner::Element(JS::from_ref(self.upcast())),
CSSStyleOwner::Element(Dom::from_ref(self.upcast())),
None,
CSSModificationAccess::ReadWrite)
})

View file

@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaEl
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{JS, OnceCellJS, Root, RootedReference};
use dom::bindings::root::{Dom, OnceCellJS, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::blob::Blob;
use dom::document::Document;
@ -66,7 +66,7 @@ pub struct HTMLFormElement {
marked_for_reset: Cell<bool>,
elements: OnceCellJS<HTMLFormControlsCollection>,
generation_id: Cell<GenerationId>,
controls: DOMRefCell<Vec<JS<Element>>>,
controls: DOMRefCell<Vec<Dom<Element>>>,
}
impl HTMLFormElement {

View file

@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{JS, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, LayoutElementHelpers, RawLayoutElementHelpers};
@ -110,7 +110,7 @@ struct InputActivationState {
indeterminate: bool,
checked: bool,
checked_changed: bool,
checked_radio: Option<JS<HTMLInputElement>>,
checked_radio: Option<Dom<HTMLInputElement>>,
// In case mutability changed
was_mutable: bool,
// In case the type changed
@ -1251,7 +1251,7 @@ impl Activatable for HTMLInputElement {
in_same_group(&*r, owner.r(), group.as_ref()) &&
r.Checked()
});
cache.checked_radio = checked_member.r().map(JS::from_ref);
cache.checked_radio = checked_member.r().map(Dom::from_ref);
cache.checked_changed = self.checked_changed.get();
self.SetChecked(true);
}

View file

@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{JS, Root, RootedReference};
use dom::bindings::root::{Dom, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, ElementCreator};
@ -61,7 +61,7 @@ pub struct HTMLScriptElement {
non_blocking: Cell<bool>,
/// Document of the parser that created this element
parser_document: JS<Document>,
parser_document: Dom<Document>,
/// Track line line_number
line_number: u64,
@ -76,7 +76,7 @@ impl HTMLScriptElement {
already_started: Cell::new(false),
parser_inserted: Cell::new(creator.is_parser_created()),
non_blocking: Cell::new(!creator.is_parser_created()),
parser_document: JS::from_ref(document),
parser_document: Dom::from_ref(document),
line_number: creator.return_line_number(),
}
}

View file

@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementM
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{JS, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
@ -38,7 +38,7 @@ pub struct HTMLTableElement {
#[allow(unrooted_must_root)]
#[derive(HeapSizeOf, JSTraceable)]
struct TableRowFilter {
sections: Vec<JS<Node>>,
sections: Vec<Dom<Node>>,
}
impl CollectionFilter for TableRowFilter {
@ -141,7 +141,7 @@ impl HTMLTableElement {
sections: self.upcast::<Node>()
.children()
.filter_map(|ref node|
node.downcast::<HTMLTableSectionElement>().map(|_| JS::from_ref(&**node)))
node.downcast::<HTMLTableSectionElement>().map(|_| Dom::from_ref(&**node)))
.collect()
}
}

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::{DOMString, USVString};
use dom::globalscope::GlobalScope;
use dom::urlhelper::UrlHelper;
@ -18,14 +18,14 @@ use servo_url::{MutableOrigin, ServoUrl};
#[dom_struct]
pub struct Location {
reflector_: Reflector,
window: JS<Window>,
window: Dom<Window>,
}
impl Location {
fn new_inherited(window: &Window) -> Location {
Location {
reflector_: Reflector::new(),
window: JS::from_ref(window)
window: Dom::from_ref(window)
}
}

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::MediaListBinding;
use dom::bindings::codegen::Bindings::MediaListBinding::MediaListMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
@ -23,7 +23,7 @@ use style_traits::{PARSING_MODE_DEFAULT, ToCss};
#[dom_struct]
pub struct MediaList {
reflector_: Reflector,
parent_stylesheet: JS<CSSStyleSheet>,
parent_stylesheet: Dom<CSSStyleSheet>,
#[ignore_heap_size_of = "Arc"]
media_queries: Arc<Locked<StyleMediaList>>,
}
@ -33,7 +33,7 @@ impl MediaList {
pub fn new_inherited(parent_stylesheet: &CSSStyleSheet,
media_queries: Arc<Locked<StyleMediaList>>) -> MediaList {
MediaList {
parent_stylesheet: JS::from_ref(parent_stylesheet),
parent_stylesheet: Dom::from_ref(parent_stylesheet),
reflector_: Reflector::new(),
media_queries: media_queries,
}

View file

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::MediaQueryListBinding::{self, MediaQueryLi
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::DomObject;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::bindings::trace::JSTraceable;
use dom::bindings::weakref::{WeakRef, WeakRefVec};
@ -32,7 +32,7 @@ pub enum MediaQueryListMatchState {
#[dom_struct]
pub struct MediaQueryList {
eventtarget: EventTarget,
document: JS<Document>,
document: Dom<Document>,
media_query_list: MediaList,
last_match_state: Cell<Option<bool>>
}
@ -41,7 +41,7 @@ impl MediaQueryList {
fn new_inherited(document: &Document, media_query_list: MediaList) -> MediaQueryList {
MediaQueryList {
eventtarget: EventTarget::new_inherited(),
document: JS::from_ref(document),
document: Dom::from_ref(document),
media_query_list: media_query_list,
last_match_state: Cell::new(None),
}
@ -134,7 +134,7 @@ impl WeakMediaQueryListVec {
let mql = mql.root().unwrap();
if let MediaQueryListMatchState::Changed(_) = mql.evaluate_changes() {
// Recording list of changed Media Queries
mql_list.push(JS::from_ref(&*mql));
mql_list.push(Dom::from_ref(&*mql));
}
});
// Sending change events for all changed Media Queries

View file

@ -31,7 +31,7 @@
//!
//! * rooting pointers on the stack:
//! the [`Root`](bindings/root/struct.Root.html) smart pointer;
//! * tracing pointers in member fields: the [`JS`](bindings/root/struct.JS.html),
//! * tracing pointers in member fields: the [`Dom`](bindings/root/struct.Dom.html),
//! [`MutNullableJS`](bindings/root/struct.MutNullableJS.html) and
//! [`MutJS`](bindings/root/struct.MutJS.html) smart pointers and
//! [the tracing implementation](bindings/trace/index.html);
@ -44,7 +44,7 @@
//! Rust does not support struct inheritance, as would be used for the
//! object-oriented DOM APIs. To work around this issue, Servo stores an
//! instance of the superclass in the first field of its subclasses. (Note that
//! it is stored by value, rather than in a smart pointer such as `JS<T>`.)
//! it is stored by value, rather than in a smart pointer such as `Dom<T>`.)
//!
//! This implies that a pointer to an object can safely be cast to a pointer
//! to all its classes.

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::MutationRecordBinding::MutationRecordBinding;
use dom::bindings::codegen::Bindings::MutationRecordBinding::MutationRecordBinding::MutationRecordMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::DOMString;
use dom::node::{Node, window_from_node};
use dom::nodelist::NodeList;
@ -16,14 +16,14 @@ use html5ever::{LocalName, Namespace};
pub struct MutationRecord {
reflector_: Reflector,
record_type: DOMString,
target: JS<Node>,
target: Dom<Node>,
attribute_name: Option<DOMString>,
attribute_namespace: Option<DOMString>,
old_value: Option<DOMString>,
added_nodes: MutNullableJS<NodeList>,
removed_nodes: MutNullableJS<NodeList>,
next_sibling: Option<JS<Node>>,
prev_sibling: Option<JS<Node>>,
next_sibling: Option<Dom<Node>>,
prev_sibling: Option<Dom<Node>>,
}
impl MutationRecord {
@ -73,14 +73,14 @@ impl MutationRecord {
MutationRecord {
reflector_: Reflector::new(),
record_type: DOMString::from(record_type),
target: JS::from_ref(target),
target: Dom::from_ref(target),
attribute_name: attribute_name,
attribute_namespace: attribute_namespace,
old_value: old_value,
added_nodes: MutNullableJS::new(added_nodes),
removed_nodes: MutNullableJS::new(removed_nodes),
next_sibling: next_sibling.map(JS::from_ref),
prev_sibling: prev_sibling.map(JS::from_ref),
next_sibling: next_sibling.map(Dom::from_ref),
prev_sibling: prev_sibling.map(Dom::from_ref),
}
}
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::NamedNodeMapBinding;
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::bindings::xmlname::namespace_from_domstring;
use dom::element::Element;
@ -20,14 +20,14 @@ use std::ascii::AsciiExt;
#[dom_struct]
pub struct NamedNodeMap {
reflector_: Reflector,
owner: JS<Element>,
owner: Dom<Element>,
}
impl NamedNodeMap {
fn new_inherited(elem: &Element) -> NamedNodeMap {
NamedNodeMap {
reflector_: Reflector::new(),
owner: JS::from_ref(elem),
owner: Dom::from_ref(elem),
}
}

View file

@ -23,7 +23,7 @@ use dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId};
use dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId};
use dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutJS, MutNullableJS, Root, RootedReference};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::xmlname::namespace_from_domstring;
use dom::characterdata::{CharacterData, LayoutCharacterDataHelpers};
@ -989,7 +989,7 @@ pub unsafe fn from_untrusted_node_address(_runtime: *mut JSRuntime, candidate: U
// candidate);
let object: *mut JSObject = mem::transmute(candidate);
if object.is_null() {
panic!("Attempted to create a `JS<Node>` from an invalid pointer!")
panic!("Attempted to create a `Dom<Node>` from an invalid pointer!")
}
let boxed_node = conversions::private_from_object(object) as *const Node;
Root::from_ref(&*boxed_node)
@ -1612,7 +1612,7 @@ impl Node {
rooted_vec!(let mut new_nodes);
let new_nodes = if let NodeTypeId::DocumentFragment = node.type_id() {
// Step 3.
new_nodes.extend(node.children().map(|kid| JS::from_ref(&*kid)));
new_nodes.extend(node.children().map(|kid| Dom::from_ref(&*kid)));
// Step 4.
for kid in new_nodes.r() {
Node::remove(*kid, node, SuppressObserver::Suppressed);
@ -1687,7 +1687,7 @@ impl Node {
rooted_vec!(let mut added_nodes);
let added_nodes = if let Some(node) = node.as_ref() {
if let NodeTypeId::DocumentFragment = node.type_id() {
added_nodes.extend(node.children().map(|child| JS::from_ref(&*child)));
added_nodes.extend(node.children().map(|child| Dom::from_ref(&*child)));
added_nodes.r()
} else {
ref_slice(node)
@ -2216,7 +2216,7 @@ impl NodeMethods for Node {
// Step 12.
rooted_vec!(let mut nodes);
let nodes = if node.type_id() == NodeTypeId::DocumentFragment {
nodes.extend(node.children().map(|node| JS::from_ref(&*node)));
nodes.extend(node.children().map(|node| Dom::from_ref(&*node)));
nodes.r()
} else {
ref_slice(&node)
@ -2786,7 +2786,7 @@ pub trait VecPreOrderInsertionHelper<T> {
fn insert_pre_order(&mut self, elem: &T, tree_root: &Node);
}
impl<T> VecPreOrderInsertionHelper<T> for Vec<JS<T>>
impl<T> VecPreOrderInsertionHelper<T> for Vec<Dom<T>>
where T: DerivedFrom<Node> + DomObject
{
/// This algorithm relies on the following assumptions:
@ -2800,7 +2800,7 @@ impl<T> VecPreOrderInsertionHelper<T> for Vec<JS<T>>
/// the traversal.
fn insert_pre_order(&mut self, elem: &T, tree_root: &Node) {
if self.is_empty() {
self.push(JS::from_ref(elem));
self.push(Dom::from_ref(elem));
return;
}
@ -2815,6 +2815,6 @@ impl<T> VecPreOrderInsertionHelper<T> for Vec<JS<T>>
break;
}
}
self.insert(head, JS::from_ref(elem));
self.insert(head, Dom::from_ref(elem));
}
}

View file

@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::NodeIteratorBinding;
use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods;
use dom::bindings::error::Fallible;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutJS, Root};
use dom::bindings::root::{Dom, MutJS, Root};
use dom::document::Document;
use dom::node::Node;
use dom_struct::dom_struct;
@ -20,7 +20,7 @@ use std::rc::Rc;
#[dom_struct]
pub struct NodeIterator {
reflector_: Reflector,
root_node: JS<Node>,
root_node: Dom<Node>,
#[ignore_heap_size_of = "Defined in rust-mozjs"]
reference_node: MutJS<Node>,
pointer_before_reference_node: Cell<bool>,
@ -35,7 +35,7 @@ impl NodeIterator {
filter: Filter) -> NodeIterator {
NodeIterator {
reflector_: Reflector::new(),
root_node: JS::from_ref(root_node),
root_node: Dom::from_ref(root_node),
reference_node: MutJS::new(root_node),
pointer_before_reference_node: Cell::new(true),
what_to_show: what_to_show,

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::Bindings::NodeListBinding;
use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, MutNullableJS, Root, RootedReference};
use dom::node::{ChildrenMutation, Node};
use dom::window::Window;
use dom_struct::dom_struct;
@ -15,7 +15,7 @@ use std::cell::Cell;
#[derive(HeapSizeOf, JSTraceable)]
#[must_root]
pub enum NodeListType {
Simple(Vec<JS<Node>>),
Simple(Vec<Dom<Node>>),
Children(ChildrenList),
}
@ -44,11 +44,11 @@ impl NodeList {
pub fn new_simple_list<T>(window: &Window, iter: T) -> Root<NodeList>
where T: Iterator<Item=Root<Node>> {
NodeList::new(window, NodeListType::Simple(iter.map(|r| JS::from_ref(&*r)).collect()))
NodeList::new(window, NodeListType::Simple(iter.map(|r| Dom::from_ref(&*r)).collect()))
}
pub fn new_simple_list_slice(window: &Window, slice: &[&Node]) -> Root<NodeList> {
NodeList::new(window, NodeListType::Simple(slice.iter().map(|r| JS::from_ref(*r)).collect()))
NodeList::new(window, NodeListType::Simple(slice.iter().map(|r| Dom::from_ref(*r)).collect()))
}
pub fn new_child_list(window: &Window, node: &Node) -> Root<NodeList> {
@ -95,7 +95,7 @@ impl NodeList {
}
}
pub fn as_simple_list(&self) -> &Vec<JS<Node>> {
pub fn as_simple_list(&self) -> &Vec<Dom<Node>> {
if let NodeListType::Simple(ref list) = self.list_type {
list
} else {
@ -112,7 +112,7 @@ impl NodeList {
#[derive(HeapSizeOf, JSTraceable)]
#[must_root]
pub struct ChildrenList {
node: JS<Node>,
node: Dom<Node>,
#[ignore_heap_size_of = "Defined in rust-mozjs"]
last_visited: MutNullableJS<Node>,
last_index: Cell<u32>,
@ -122,7 +122,7 @@ impl ChildrenList {
pub fn new(node: &Node) -> ChildrenList {
let last_visited = node.GetFirstChild();
ChildrenList {
node: JS::from_ref(node),
node: Dom::from_ref(node),
last_visited: MutNullableJS::new(last_visited.r()),
last_index: Cell::new(0u32),
}

View file

@ -13,7 +13,7 @@ use dom::bindings::error::Error;
use dom::bindings::error::Fallible;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::cssstylevalue::CSSStyleValue;
use dom::paintrenderingcontext2d::PaintRenderingContext2D;
@ -476,7 +476,7 @@ struct PaintDefinition {
// TODO: the spec calls for fresh rendering contexts each time a paint image is drawn,
// but to avoid having the primary worklet thread create a new renering context,
// we recycle them.
context: JS<PaintRenderingContext2D>,
context: Dom<PaintRenderingContext2D>,
}
impl PaintDefinition {
@ -493,7 +493,7 @@ impl PaintDefinition {
constructor_valid_flag: Cell::new(true),
context_alpha_flag: alpha,
input_arguments_len: input_arguments_len,
context: JS::from_ref(context),
context: Dom::from_ref(context),
});
result.class_constructor.set(class_constructor.get());
result.paint_function.set(paint_function.get());

View file

@ -10,7 +10,7 @@ use dom::bindings::error::{Error, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::globalscope::GlobalScope;
use dom::performanceentry::PerformanceEntry;
@ -110,7 +110,7 @@ struct PerformanceObserver {
#[dom_struct]
pub struct Performance {
reflector_: Reflector,
timing: Option<JS<PerformanceTiming>>,
timing: Option<Dom<PerformanceTiming>>,
entries: DOMRefCell<PerformanceEntryList>,
observers: DOMRefCell<Vec<PerformanceObserver>>,
pending_notification_observers_task: Cell<bool>,
@ -124,7 +124,7 @@ impl Performance {
Performance {
reflector_: Reflector::new(),
timing: if global.is::<Window>() {
Some(JS::from_ref(&*PerformanceTiming::new(global.as_window(),
Some(Dom::from_ref(&*PerformanceTiming::new(global.as_window(),
navigation_start,
navigation_start_precise)))
} else {

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::PerformanceTimingBinding;
use dom::bindings::codegen::Bindings::PerformanceTimingBinding::PerformanceTimingMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::document::Document;
use dom::window::Window;
use dom_struct::dom_struct;
@ -16,7 +16,7 @@ pub struct PerformanceTiming {
reflector_: Reflector,
navigation_start: u64,
navigation_start_precise: f64,
document: JS<Document>,
document: Dom<Document>,
}
impl PerformanceTiming {
@ -28,7 +28,7 @@ impl PerformanceTiming {
reflector_: Reflector::new(),
navigation_start: nav_start,
navigation_start_precise: nav_start_precise,
document: JS::from_ref(document),
document: Dom::from_ref(document),
}
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::RadioNodeListBinding;
use dom::bindings::codegen::Bindings::RadioNodeListBinding::RadioNodeListMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::htmlinputelement::HTMLInputElement;
use dom::node::Node;
@ -38,7 +38,7 @@ impl RadioNodeList {
pub fn new_simple_list<T>(window: &Window, iter: T) -> Root<RadioNodeList>
where T: Iterator<Item=Root<Node>> {
RadioNodeList::new(window, NodeListType::Simple(iter.map(|r| JS::from_ref(&*r)).collect()))
RadioNodeList::new(window, NodeListType::Simple(iter.map(|r| Dom::from_ref(&*r)).collect()))
}
// FIXME: This shouldn't need to be implemented here since NodeList (the parent of

View file

@ -14,7 +14,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutJS, Root, RootedReference};
use dom::bindings::root::{Dom, MutJS, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::bindings::trace::JSTraceable;
use dom::bindings::weakref::{WeakRef, WeakRefVec};
@ -770,7 +770,7 @@ impl RangeMethods for Range {
let mut next = iter.next();
while let Some(child) = next {
if self.contains(&child) {
contained_children.push(JS::from_ref(&*child));
contained_children.push(Dom::from_ref(&*child));
next = iter.next_skipping_children();
} else {
next = iter.next();

View file

@ -796,7 +796,7 @@ impl Into<RequestMode> for NetTraitsRequestMode {
NetTraitsRequestMode::SameOrigin => RequestMode::Same_origin,
NetTraitsRequestMode::NoCors => RequestMode::No_cors,
NetTraitsRequestMode::CorsMode => RequestMode::Cors,
NetTraitsRequestMode::WebSocket => unreachable!("Websocket request mode should never be exposed to JS"),
NetTraitsRequestMode::WebSocket => unreachable!("Websocket request mode should never be exposed to Dom"),
}
}
}

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{ServiceWor
use dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions;
use dom::bindings::error::Error;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::USVString;
use dom::client::Client;
use dom::eventtarget::EventTarget;
@ -24,7 +24,7 @@ use std::rc::Rc;
pub struct ServiceWorkerContainer {
eventtarget: EventTarget,
controller: MutNullableJS<ServiceWorker>,
client: JS<Client>
client: Dom<Client>
}
impl ServiceWorkerContainer {
@ -32,7 +32,7 @@ impl ServiceWorkerContainer {
ServiceWorkerContainer {
eventtarget: EventTarget::new_inherited(),
controller: Default::default(),
client: JS::from_ref(client),
client: Dom::from_ref(client),
}
}

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::ServiceWorkerBinding::ServiceWorkerState;
use dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::{ServiceWorkerRegistrationMethods, Wrap};
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::USVString;
use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
@ -20,9 +20,9 @@ use std::cell::Cell;
#[dom_struct]
pub struct ServiceWorkerRegistration {
eventtarget: EventTarget,
active: Option<JS<ServiceWorker>>,
installing: Option<JS<ServiceWorker>>,
waiting: Option<JS<ServiceWorker>>,
active: Option<Dom<ServiceWorker>>,
installing: Option<Dom<ServiceWorker>>,
waiting: Option<Dom<ServiceWorker>>,
scope: ServoUrl,
uninstalling: Cell<bool>
}
@ -31,7 +31,7 @@ impl ServiceWorkerRegistration {
fn new_inherited(active_sw: &ServiceWorker, scope: ServoUrl) -> ServiceWorkerRegistration {
ServiceWorkerRegistration {
eventtarget: EventTarget::new_inherited(),
active: Some(JS::from_ref(active_sw)),
active: Some(Dom::from_ref(active_sw)),
installing: None,
waiting: None,
scope: scope,

View file

@ -7,7 +7,7 @@
use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::comment::Comment;
use dom::document::Document;
@ -168,13 +168,13 @@ fn create_buffer_queue(mut buffers: VecDeque<SendTendril<UTF8>>) -> BufferQueue
#[derive(HeapSizeOf, JSTraceable)]
#[must_root]
pub struct Tokenizer {
document: JS<Document>,
document: Dom<Document>,
#[ignore_heap_size_of = "Defined in std"]
receiver: Receiver<ToTokenizerMsg>,
#[ignore_heap_size_of = "Defined in std"]
html_tokenizer_sender: Sender<ToHtmlTokenizerMsg>,
#[ignore_heap_size_of = "Defined in std"]
nodes: HashMap<ParseNodeId, JS<Node>>,
nodes: HashMap<ParseNodeId, Dom<Node>>,
url: ServoUrl,
}
@ -190,13 +190,13 @@ impl Tokenizer {
let (to_tokenizer_sender, tokenizer_receiver) = channel();
let mut tokenizer = Tokenizer {
document: JS::from_ref(document),
document: Dom::from_ref(document),
receiver: tokenizer_receiver,
html_tokenizer_sender: to_html_tokenizer_sender,
nodes: HashMap::new(),
url: url
};
tokenizer.insert_node(0, JS::from_ref(document.upcast()));
tokenizer.insert_node(0, Dom::from_ref(document.upcast()));
let mut sink = Sink::new(to_tokenizer_sender.clone());
let mut ctxt_parse_node = None;
@ -204,12 +204,12 @@ impl Tokenizer {
let mut fragment_context_is_some = false;
if let Some(fc) = fragment_context {
let node = sink.new_parse_node();
tokenizer.insert_node(node.id, JS::from_ref(fc.context_elem));
tokenizer.insert_node(node.id, Dom::from_ref(fc.context_elem));
ctxt_parse_node = Some(node);
form_parse_node = fc.form_elem.map(|form_elem| {
let node = sink.new_parse_node();
tokenizer.insert_node(node.id, JS::from_ref(form_elem));
tokenizer.insert_node(node.id, Dom::from_ref(form_elem));
node
});
fragment_context_is_some = true;
@ -278,18 +278,18 @@ impl Tokenizer {
self.html_tokenizer_sender.send(ToHtmlTokenizerMsg::SetPlainTextState).unwrap();
}
fn insert_node(&mut self, id: ParseNodeId, node: JS<Node>) {
fn insert_node(&mut self, id: ParseNodeId, node: Dom<Node>) {
assert!(self.nodes.insert(id, node).is_none());
}
fn get_node<'a>(&'a self, id: &ParseNodeId) -> &'a JS<Node> {
fn get_node<'a>(&'a self, id: &ParseNodeId) -> &'a Dom<Node> {
self.nodes.get(id).expect("Node not found!")
}
fn append_before_sibling(&mut self, sibling: ParseNodeId, node: NodeOrText) {
let node = match node {
NodeOrText::Node(n) => HtmlNodeOrText::AppendNode(JS::from_ref(&**self.get_node(&n.id))),
NodeOrText::Node(n) => HtmlNodeOrText::AppendNode(Dom::from_ref(&**self.get_node(&n.id))),
NodeOrText::Text(text) => HtmlNodeOrText::AppendText(
Tendril::from(text)
)
@ -302,7 +302,7 @@ impl Tokenizer {
fn append(&mut self, parent: ParseNodeId, node: NodeOrText) {
let node = match node {
NodeOrText::Node(n) => HtmlNodeOrText::AppendNode(JS::from_ref(&**self.get_node(&n.id))),
NodeOrText::Node(n) => HtmlNodeOrText::AppendNode(Dom::from_ref(&**self.get_node(&n.id))),
NodeOrText::Text(text) => HtmlNodeOrText::AppendText(
Tendril::from(text)
)
@ -333,7 +333,7 @@ impl Tokenizer {
let target = Root::from_ref(&**self.get_node(&target));
let template = target.downcast::<HTMLTemplateElement>().expect(
"Tried to extract contents from non-template element while parsing");
self.insert_node(contents, JS::from_ref(template.Content().upcast()));
self.insert_node(contents, Dom::from_ref(template.Content().upcast()));
}
ParseOperation::CreateElement { node, name, attrs, current_line } => {
let is = attrs.iter()
@ -349,11 +349,11 @@ impl Tokenizer {
elem.set_attribute_from_parser(attr.name, DOMString::from(attr.value), None);
}
self.insert_node(node, JS::from_ref(elem.upcast()));
self.insert_node(node, Dom::from_ref(elem.upcast()));
}
ParseOperation::CreateComment { text, node } => {
let comment = Comment::new(DOMString::from(text), document);
self.insert_node(node, JS::from_ref(&comment.upcast()));
self.insert_node(node, Dom::from_ref(&comment.upcast()));
}
ParseOperation::AppendBeforeSibling { sibling, node } => {
self.append_before_sibling(sibling, node);
@ -429,7 +429,7 @@ impl Tokenizer {
DOMString::from(target),
DOMString::from(data),
document);
self.insert_node(node, JS::from_ref(pi.upcast()));
self.insert_node(node, Dom::from_ref(pi.upcast()));
}
ParseOperation::SetQuirksMode { mode } => {
document.set_quirks_mode(mode);

View file

@ -6,7 +6,7 @@
use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods;
use dom::bindings::inheritance::{Castable, CharacterDataTypeId, NodeTypeId};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::trace::JSTraceable;
use dom::characterdata::CharacterData;
use dom::document::Document;
@ -32,7 +32,7 @@ use std::io;
#[must_root]
pub struct Tokenizer {
#[ignore_heap_size_of = "Defined in html5ever"]
inner: HtmlTokenizer<TreeBuilder<JS<Node>, Sink>>,
inner: HtmlTokenizer<TreeBuilder<Dom<Node>, Sink>>,
}
impl Tokenizer {
@ -43,7 +43,7 @@ impl Tokenizer {
-> Self {
let sink = Sink {
base_url: url,
document: JS::from_ref(document),
document: Dom::from_ref(document),
current_line: 1,
script: Default::default(),
};
@ -56,8 +56,8 @@ impl Tokenizer {
let inner = if let Some(fc) = fragment_context {
let tb = TreeBuilder::new_for_fragment(
sink,
JS::from_ref(fc.context_elem),
fc.form_elem.map(|n| JS::from_ref(n)),
Dom::from_ref(fc.context_elem),
fc.form_elem.map(|n| Dom::from_ref(n)),
options);
let tok_options = TokenizerOpts {
@ -96,15 +96,15 @@ impl Tokenizer {
}
#[allow(unsafe_code)]
unsafe impl JSTraceable for HtmlTokenizer<TreeBuilder<JS<Node>, Sink>> {
unsafe impl JSTraceable for HtmlTokenizer<TreeBuilder<Dom<Node>, Sink>> {
unsafe fn trace(&self, trc: *mut JSTracer) {
struct Tracer(*mut JSTracer);
let tracer = Tracer(trc);
impl HtmlTracer for Tracer {
type Handle = JS<Node>;
type Handle = Dom<Node>;
#[allow(unrooted_must_root)]
fn trace_handle(&self, node: &JS<Node>) {
fn trace_handle(&self, node: &Dom<Node>) {
unsafe { node.trace(self.0); }
}
}

View file

@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::ServoParserBinding;
use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root, RootedReference};
use dom::bindings::root::{Dom, MutNullableJS, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::characterdata::CharacterData;
use dom::comment::Comment;
@ -72,7 +72,7 @@ mod xml;
pub struct ServoParser {
reflector: Reflector,
/// The document associated with this parser.
document: JS<Document>,
document: Dom<Document>,
/// Input received from network.
#[ignore_heap_size_of = "Defined in html5ever"]
network_input: DOMRefCell<BufferQueue>,
@ -319,7 +319,7 @@ impl ServoParser {
-> Self {
ServoParser {
reflector: Reflector::new(),
document: JS::from_ref(document),
document: Dom::from_ref(document),
incomplete_utf8: DOMRefCell::new(None),
network_input: DOMRefCell::new(BufferQueue::new()),
script_input: DOMRefCell::new(BufferQueue::new()),
@ -721,7 +721,7 @@ pub struct FragmentContext<'a> {
}
#[allow(unrooted_must_root)]
fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText<JS<Node>>) {
fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText<Dom<Node>>) {
match child {
NodeOrText::AppendNode(n) => {
parent.InsertBefore(&n, reference_child).unwrap();
@ -746,7 +746,7 @@ fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText<JS<No
#[must_root]
pub struct Sink {
base_url: ServoUrl,
document: JS<Document>,
document: Dom<Document>,
current_line: u64,
script: MutNullableJS<HTMLScriptElement>,
}
@ -756,23 +756,23 @@ impl TreeSink for Sink {
type Output = Self;
fn finish(self) -> Self { self }
type Handle = JS<Node>;
type Handle = Dom<Node>;
fn get_document(&mut self) -> JS<Node> {
JS::from_ref(self.document.upcast())
fn get_document(&mut self) -> Dom<Node> {
Dom::from_ref(self.document.upcast())
}
fn get_template_contents(&mut self, target: &JS<Node>) -> JS<Node> {
fn get_template_contents(&mut self, target: &Dom<Node>) -> Dom<Node> {
let template = target.downcast::<HTMLTemplateElement>()
.expect("tried to get template contents of non-HTMLTemplateElement in HTML parsing");
JS::from_ref(template.Content().upcast())
Dom::from_ref(template.Content().upcast())
}
fn same_node(&self, x: &JS<Node>, y: &JS<Node>) -> bool {
fn same_node(&self, x: &Dom<Node>, y: &Dom<Node>) -> bool {
x == y
}
fn elem_name<'a>(&self, target: &'a JS<Node>) -> ExpandedName<'a> {
fn elem_name<'a>(&self, target: &'a Dom<Node>) -> ExpandedName<'a> {
let elem = target.downcast::<Element>()
.expect("tried to get name of non-Element in HTML parsing");
ExpandedName {
@ -781,7 +781,7 @@ impl TreeSink for Sink {
}
}
fn same_tree(&self, x: &JS<Node>, y: &JS<Node>) -> bool {
fn same_tree(&self, x: &Dom<Node>, y: &Dom<Node>) -> bool {
let x = x.downcast::<Element>().expect("Element node expected");
let y = y.downcast::<Element>().expect("Element node expected");
@ -789,7 +789,7 @@ impl TreeSink for Sink {
}
fn create_element(&mut self, name: QualName, attrs: Vec<Attribute>, _flags: ElementFlags)
-> JS<Node> {
-> Dom<Node> {
let is = attrs.iter()
.find(|attr| attr.name.local.eq_str_ignore_ascii_case("is"))
.map(|attr| LocalName::from(&*attr.value));
@ -804,27 +804,27 @@ impl TreeSink for Sink {
elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None);
}
JS::from_ref(elem.upcast())
Dom::from_ref(elem.upcast())
}
fn create_comment(&mut self, text: StrTendril) -> JS<Node> {
fn create_comment(&mut self, text: StrTendril) -> Dom<Node> {
let comment = Comment::new(DOMString::from(String::from(text)), &*self.document);
JS::from_ref(comment.upcast())
Dom::from_ref(comment.upcast())
}
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> JS<Node> {
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Dom<Node> {
let doc = &*self.document;
let pi = ProcessingInstruction::new(
DOMString::from(String::from(target)), DOMString::from(String::from(data)),
doc);
JS::from_ref(pi.upcast())
Dom::from_ref(pi.upcast())
}
fn has_parent_node(&self, node: &JS<Node>) -> bool {
fn has_parent_node(&self, node: &Dom<Node>) -> bool {
node.GetParentNode().is_some()
}
fn associate_with_form(&mut self, target: &JS<Node>, form: &JS<Node>, nodes: (&JS<Node>, Option<&JS<Node>>)) {
fn associate_with_form(&mut self, target: &Dom<Node>, form: &Dom<Node>, nodes: (&Dom<Node>, Option<&Dom<Node>>)) {
let (element, prev_element) = nodes;
let tree_node = prev_element.map_or(element, |prev| {
if self.has_parent_node(element) { element } else { prev }
@ -849,8 +849,8 @@ impl TreeSink for Sink {
}
fn append_before_sibling(&mut self,
sibling: &JS<Node>,
new_node: NodeOrText<JS<Node>>) {
sibling: &Dom<Node>,
new_node: NodeOrText<Dom<Node>>) {
let parent = sibling.GetParentNode()
.expect("append_before_sibling called on node without parent");
@ -870,15 +870,15 @@ impl TreeSink for Sink {
self.document.set_quirks_mode(mode);
}
fn append(&mut self, parent: &JS<Node>, child: NodeOrText<JS<Node>>) {
fn append(&mut self, parent: &Dom<Node>, child: NodeOrText<Dom<Node>>) {
insert(&parent, None, child);
}
fn append_based_on_parent_node(
&mut self,
elem: &JS<Node>,
prev_elem: &JS<Node>,
child: NodeOrText<JS<Node>>,
elem: &Dom<Node>,
prev_elem: &Dom<Node>,
child: NodeOrText<Dom<Node>>,
) {
if self.has_parent_node(elem) {
self.append_before_sibling(elem, child);
@ -896,7 +896,7 @@ impl TreeSink for Sink {
doc.upcast::<Node>().AppendChild(doctype.upcast()).expect("Appending failed");
}
fn add_attrs_if_missing(&mut self, target: &JS<Node>, attrs: Vec<Attribute>) {
fn add_attrs_if_missing(&mut self, target: &Dom<Node>, attrs: Vec<Attribute>) {
let elem = target.downcast::<Element>()
.expect("tried to set attrs on non-Element in HTML parsing");
for attr in attrs {
@ -904,18 +904,18 @@ impl TreeSink for Sink {
}
}
fn remove_from_parent(&mut self, target: &JS<Node>) {
fn remove_from_parent(&mut self, target: &Dom<Node>) {
if let Some(ref parent) = target.GetParentNode() {
parent.RemoveChild(&*target).unwrap();
}
}
fn mark_script_already_started(&mut self, node: &JS<Node>) {
fn mark_script_already_started(&mut self, node: &Dom<Node>) {
let script = node.downcast::<HTMLScriptElement>();
script.map(|script| script.set_already_started(true));
}
fn complete_script(&mut self, node: &JS<Node>) -> NextParserState {
fn complete_script(&mut self, node: &Dom<Node>) -> NextParserState {
if let Some(script) = node.downcast() {
self.script.set(Some(script));
NextParserState::Suspend
@ -924,7 +924,7 @@ impl TreeSink for Sink {
}
}
fn reparent_children(&mut self, node: &JS<Node>, new_parent: &JS<Node>) {
fn reparent_children(&mut self, node: &Dom<Node>, new_parent: &Dom<Node>) {
while let Some(ref child) = node.GetFirstChild() {
new_parent.AppendChild(&child).unwrap();
}
@ -932,7 +932,7 @@ impl TreeSink for Sink {
/// https://html.spec.whatwg.org/multipage/#html-integration-point
/// Specifically, the <annotation-xml> cases.
fn is_mathml_annotation_xml_integration_point(&self, handle: &JS<Node>) -> bool {
fn is_mathml_annotation_xml_integration_point(&self, handle: &Dom<Node>) -> bool {
let elem = handle.downcast::<Element>().unwrap();
elem.get_attribute(&ns!(), &local_name!("encoding")).map_or(false, |attr| {
attr.value().eq_ignore_ascii_case("text/html")
@ -944,7 +944,7 @@ impl TreeSink for Sink {
self.current_line = line_number;
}
fn pop(&mut self, node: &JS<Node>) {
fn pop(&mut self, node: &Dom<Node>) {
let node = Root::from_ref(&**node);
vtable_for(&node).pop();
}

View file

@ -4,7 +4,7 @@
#![allow(unrooted_must_root)]
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::trace::JSTraceable;
use dom::document::Document;
use dom::htmlscriptelement::HTMLScriptElement;
@ -20,14 +20,14 @@ use xml5ever::tree_builder::{Tracer as XmlTracer, XmlTreeBuilder};
#[must_root]
pub struct Tokenizer {
#[ignore_heap_size_of = "Defined in xml5ever"]
inner: XmlTokenizer<XmlTreeBuilder<JS<Node>, Sink>>,
inner: XmlTokenizer<XmlTreeBuilder<Dom<Node>, Sink>>,
}
impl Tokenizer {
pub fn new(document: &Document, url: ServoUrl) -> Self {
let sink = Sink {
base_url: url,
document: JS::from_ref(document),
document: Dom::from_ref(document),
current_line: 1,
script: Default::default(),
};
@ -67,15 +67,15 @@ impl Tokenizer {
}
#[allow(unsafe_code)]
unsafe impl JSTraceable for XmlTokenizer<XmlTreeBuilder<JS<Node>, Sink>> {
unsafe impl JSTraceable for XmlTokenizer<XmlTreeBuilder<Dom<Node>, Sink>> {
unsafe fn trace(&self, trc: *mut JSTracer) {
struct Tracer(*mut JSTracer);
let tracer = Tracer(trc);
impl XmlTracer for Tracer {
type Handle = JS<Node>;
type Handle = Dom<Node>;
#[allow(unrooted_must_root)]
fn trace_handle(&self, node: &JS<Node>) {
fn trace_handle(&self, node: &Dom<Node>) {
unsafe { node.trace(self.0); }
}
}

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::StylePropertyMapReadOnlyBinding::StyleProp
use dom::bindings::codegen::Bindings::StylePropertyMapReadOnlyBinding::Wrap;
use dom::bindings::reflector::Reflector;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::cssstylevalue::CSSStyleValue;
use dom::globalscope::GlobalScope;
@ -20,12 +20,12 @@ use style::custom_properties;
#[dom_struct]
pub struct StylePropertyMapReadOnly {
reflector: Reflector,
entries: HashMap<Atom, JS<CSSStyleValue>>,
entries: HashMap<Atom, Dom<CSSStyleValue>>,
}
impl StylePropertyMapReadOnly {
fn new_inherited<Entries>(entries: Entries) -> StylePropertyMapReadOnly where
Entries: IntoIterator<Item=(Atom, JS<CSSStyleValue>)>
Entries: IntoIterator<Item=(Atom, Dom<CSSStyleValue>)>
{
StylePropertyMapReadOnly {
reflector: Reflector::new(),
@ -45,7 +45,7 @@ impl StylePropertyMapReadOnly {
for (key, value) in iter {
let value = CSSStyleValue::new(global, value);
keys.push(key);
values.push(JS::from_ref(&*value));
values.push(Dom::from_ref(&*value));
}
let iter = keys.drain(..).zip(values.iter().cloned());
reflect_dom_object(box StylePropertyMapReadOnly::new_inherited(iter), global, Wrap)

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::StyleSheetListBinding;
use dom::bindings::codegen::Bindings::StyleSheetListBinding::StyleSheetListMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::document::Document;
use dom::stylesheet::StyleSheet;
use dom::window::Window;
@ -14,12 +14,12 @@ use dom_struct::dom_struct;
#[dom_struct]
pub struct StyleSheetList {
reflector_: Reflector,
document: JS<Document>,
document: Dom<Document>,
}
impl StyleSheetList {
#[allow(unrooted_must_root)]
fn new_inherited(doc: JS<Document>) -> StyleSheetList {
fn new_inherited(doc: Dom<Document>) -> StyleSheetList {
StyleSheetList {
reflector_: Reflector::new(),
document: doc
@ -27,7 +27,7 @@ impl StyleSheetList {
}
#[allow(unrooted_must_root)]
pub fn new(window: &Window, document: JS<Document>) -> Root<StyleSheetList> {
pub fn new(window: &Window, document: Dom<Document>) -> Root<StyleSheetList> {
reflect_dom_object(box StyleSheetList::new_inherited(document),
window, StyleSheetListBinding::Wrap)
}

View file

@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::WorkletBinding::WorkletOptions;
use dom::bindings::error::Fallible;
use dom::bindings::reflector::Reflector;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::bindings::str::USVString;
use dom::promise::Promise;
@ -25,14 +25,14 @@ use std::rc::Rc;
#[dom_struct]
pub struct TestWorklet {
reflector: Reflector,
worklet: JS<Worklet>,
worklet: Dom<Worklet>,
}
impl TestWorklet {
fn new_inherited(worklet: &Worklet) -> TestWorklet {
TestWorklet {
reflector: Reflector::new(),
worklet: JS::from_ref(worklet),
worklet: Dom::from_ref(worklet),
}
}

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::TouchListBinding;
use dom::bindings::codegen::Bindings::TouchListBinding::TouchListMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::touch::Touch;
use dom::window::Window;
use dom_struct::dom_struct;
@ -13,14 +13,14 @@ use dom_struct::dom_struct;
#[dom_struct]
pub struct TouchList {
reflector_: Reflector,
touches: Vec<JS<Touch>>,
touches: Vec<Dom<Touch>>,
}
impl TouchList {
fn new_inherited(touches: &[&Touch]) -> TouchList {
TouchList {
reflector_: Reflector::new(),
touches: touches.iter().map(|touch| JS::from_ref(*touch)).collect(),
touches: touches.iter().map(|touch| Dom::from_ref(*touch)).collect(),
}
}

View file

@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::TreeWalkerBinding;
use dom::bindings::codegen::Bindings::TreeWalkerBinding::TreeWalkerMethods;
use dom::bindings::error::Fallible;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutJS, Root};
use dom::bindings::root::{Dom, MutJS, Root};
use dom::document::Document;
use dom::node::Node;
use dom_struct::dom_struct;
@ -20,7 +20,7 @@ use std::rc::Rc;
#[dom_struct]
pub struct TreeWalker {
reflector_: Reflector,
root_node: JS<Node>,
root_node: Dom<Node>,
current_node: MutJS<Node>,
what_to_show: u32,
#[ignore_heap_size_of = "function pointers and Rc<T> are hard"]
@ -33,7 +33,7 @@ impl TreeWalker {
filter: Filter) -> TreeWalker {
TreeWalker {
reflector_: Reflector::new(),
root_node: JS::from_ref(root_node),
root_node: Dom::from_ref(root_node),
current_node: MutJS::new(root_node),
what_to_show: what_to_show,
filter: filter
@ -55,7 +55,7 @@ impl TreeWalker {
node_filter: Option<Rc<NodeFilter>>) -> Root<TreeWalker> {
let filter = match node_filter {
None => Filter::None,
Some(jsfilter) => Filter::JS(jsfilter)
Some(jsfilter) => Filter::Dom(jsfilter)
};
TreeWalker::new_with_filter(document, root_node, what_to_show, filter)
}
@ -76,7 +76,7 @@ impl TreeWalkerMethods for TreeWalker {
fn GetFilter(&self) -> Option<Rc<NodeFilter>> {
match self.filter {
Filter::None => None,
Filter::JS(ref nf) => Some(nf.clone()),
Filter::Dom(ref nf) => Some(nf.clone()),
Filter::Native(_) => panic!("Cannot convert native node filter to DOM NodeFilter")
}
}
@ -430,12 +430,12 @@ impl TreeWalker {
match self.filter {
Filter::None => Ok(NodeFilterConstants::FILTER_ACCEPT),
Filter::Native(f) => Ok((f)(node)),
Filter::JS(ref callback) => callback.AcceptNode_(self, node, Rethrow)
Filter::Dom(ref callback) => callback.AcceptNode_(self, node, Rethrow)
}
}
fn is_root_node(&self, node: &Node) -> bool {
JS::from_ref(node) == self.root_node
Dom::from_ref(node) == self.root_node
}
fn is_current_node(&self, node: &Node) -> bool {
@ -464,5 +464,5 @@ impl<'a> Iterator for &'a TreeWalker {
pub enum Filter {
None,
Native(fn (node: &Node) -> u16),
JS(Rc<NodeFilter>)
Dom(Rc<NodeFilter>)
}

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::ValidityStateBinding;
use dom::bindings::codegen::Bindings::ValidityStateBinding::ValidityStateMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::element::Element;
use dom::window::Window;
use dom_struct::dom_struct;
@ -46,7 +46,7 @@ bitflags!{
#[dom_struct]
pub struct ValidityState {
reflector_: Reflector,
element: JS<Element>,
element: Dom<Element>,
state: ValidityStatus
}
@ -55,7 +55,7 @@ impl ValidityState {
fn new_inherited(element: &Element) -> ValidityState {
ValidityState {
reflector_: Reflector::new(),
element: JS::from_ref(element),
element: Dom::from_ref(element),
state: ValidityStatus::Valid
}
}

View file

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods;
use dom::bindings::error::Error;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::event::Event;
use dom::eventtarget::EventTarget;
use dom::gamepad::Gamepad;
@ -28,8 +28,8 @@ use webvr_traits::{WebVRGamepadData, WebVRGamepadEvent, WebVRGamepadState};
#[dom_struct]
pub struct VR {
reflector_: Reflector,
displays: DOMRefCell<Vec<JS<VRDisplay>>>,
gamepads: DOMRefCell<Vec<JS<Gamepad>>>
displays: DOMRefCell<Vec<Dom<VRDisplay>>>,
gamepads: DOMRefCell<Vec<Dom<Gamepad>>>
}
impl VR {
@ -83,7 +83,7 @@ impl VRMethods for VR {
return promise;
}
// convert from JS to Root
// convert from Dom to Root
let displays: Vec<Root<VRDisplay>> = self.displays.borrow().iter()
.map(|d| Root::from_ref(&**d))
.collect();
@ -126,7 +126,7 @@ impl VR {
existing
} else {
let root = VRDisplay::new(&self.global(), display.clone());
self.displays.borrow_mut().push(JS::from_ref(&*root));
self.displays.borrow_mut().push(Dom::from_ref(&*root));
root
}
}
@ -223,7 +223,7 @@ impl VR {
index as i32,
&data,
&state);
self.gamepads.borrow_mut().push(JS::from_ref(&*root));
self.gamepads.borrow_mut().push(Dom::from_ref(&*root));
if state.connected {
root.notify_event(GamepadEventType::Connected);
}

View file

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::VRDisplayEventBinding::VRDisplayEventReaso
use dom::bindings::error::Fallible;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::globalscope::GlobalScope;
@ -22,7 +22,7 @@ use webvr_traits::{WebVRDisplayEvent, WebVRDisplayEventReason};
#[dom_struct]
pub struct VRDisplayEvent {
event: Event,
display: JS<VRDisplay>,
display: Dom<VRDisplay>,
reason: Option<VRDisplayEventReason>
}
@ -32,7 +32,7 @@ impl VRDisplayEvent {
-> VRDisplayEvent {
VRDisplayEvent {
event: Event::new_inherited(),
display: JS::from_ref(display),
display: Dom::from_ref(display),
reason: reason.clone()
}
}

View file

@ -7,7 +7,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::VREyeParametersBinding;
use dom::bindings::codegen::Bindings::VREyeParametersBinding::VREyeParametersMethods;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::globalscope::GlobalScope;
use dom::vrfieldofview::VRFieldOfView;
use dom_struct::dom_struct;
@ -23,7 +23,7 @@ pub struct VREyeParameters {
#[ignore_heap_size_of = "Defined in rust-webvr"]
parameters: DOMRefCell<WebVREyeParameters>,
offset: Heap<*mut JSObject>,
fov: JS<VRFieldOfView>,
fov: Dom<VRFieldOfView>,
}
unsafe_no_jsmanaged_fields!(WebVREyeParameters);
@ -34,7 +34,7 @@ impl VREyeParameters {
reflector_: Reflector::new(),
parameters: DOMRefCell::new(parameters),
offset: Heap::default(),
fov: JS::from_ref(&*fov)
fov: Dom::from_ref(&*fov)
}
}

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::VRFrameDataBinding::VRFrameDataMethods;
use dom::bindings::error::Fallible;
use dom::bindings::num::Finite;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::globalscope::GlobalScope;
use dom::vrpose::VRPose;
use dom::window::Window;
@ -26,7 +26,7 @@ pub struct VRFrameData {
left_view: Heap<*mut JSObject>,
right_proj: Heap<*mut JSObject>,
right_view: Heap<*mut JSObject>,
pose: JS<VRPose>,
pose: Dom<VRPose>,
timestamp: Cell<f64>,
first_timestamp: Cell<f64>
}
@ -39,7 +39,7 @@ impl VRFrameData {
left_view: Heap::default(),
right_proj: Heap::default(),
right_view: Heap::default(),
pose: JS::from_ref(&*pose),
pose: Dom::from_ref(&*pose),
timestamp: Cell::new(0.0),
first_timestamp: Cell::new(0.0)
}

View file

@ -6,7 +6,7 @@ use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLError};
use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{self, OESVertexArrayObjectMethods};
use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::webglrenderingcontext::WebGLRenderingContext;
use dom::webglvertexarrayobjectoes::WebGLVertexArrayObjectOES;
use dom_struct::dom_struct;
@ -19,7 +19,7 @@ use super::{WebGLExtension, WebGLExtensions};
#[dom_struct]
pub struct OESVertexArrayObject {
reflector_: Reflector,
ctx: JS<WebGLRenderingContext>,
ctx: Dom<WebGLRenderingContext>,
bound_vao: MutNullableJS<WebGLVertexArrayObjectOES>,
}
@ -27,7 +27,7 @@ impl OESVertexArrayObject {
fn new_inherited(ctx: &WebGLRenderingContext) -> OESVertexArrayObject {
Self {
reflector_: Reflector::new(),
ctx: JS::from_ref(ctx),
ctx: Dom::from_ref(ctx),
bound_vao: MutNullableJS::new(None)
}
}

View file

@ -8,7 +8,7 @@ use core::iter::FromIterator;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::WebGLVertexArrayObjectOESBinding;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::globalscope::GlobalScope;
use dom::webglbuffer::WebGLBuffer;
use dom::webglobject::WebGLObject;
@ -22,7 +22,7 @@ pub struct WebGLVertexArrayObjectOES {
id: WebGLVertexArrayId,
ever_bound: Cell<bool>,
is_deleted: Cell<bool>,
bound_attrib_buffers: DOMRefCell<HashMap<u32, JS<WebGLBuffer>>>,
bound_attrib_buffers: DOMRefCell<HashMap<u32, Dom<WebGLBuffer>>>,
bound_buffer_element_array: MutNullableJS<WebGLBuffer>,
}
@ -64,7 +64,7 @@ impl WebGLVertexArrayObjectOES {
self.ever_bound.set(true);
}
pub fn borrow_bound_attrib_buffers(&self) -> Ref<HashMap<u32, JS<WebGLBuffer>>> {
pub fn borrow_bound_attrib_buffers(&self) -> Ref<HashMap<u32, Dom<WebGLBuffer>>> {
self.bound_attrib_buffers.borrow()
}
@ -73,7 +73,7 @@ impl WebGLVertexArrayObjectOES {
}
pub fn set_bound_attrib_buffers<'a, T>(&self, iter: T) where T: Iterator<Item=(u32, &'a WebGLBuffer)> {
*self.bound_attrib_buffers.borrow_mut() = HashMap::from_iter(iter.map(|(k,v)| (k, JS::from_ref(v))));
*self.bound_attrib_buffers.borrow_mut() = HashMap::from_iter(iter.map(|(k,v)| (k, Dom::from_ref(v))));
}
pub fn bound_buffer_element_array(&self) -> Option<Root<WebGLBuffer>> {

View file

@ -10,7 +10,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::WebGLFramebufferBinding;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root};
use dom::bindings::root::{Dom, Root};
use dom::webglobject::WebGLObject;
use dom::webglrenderbuffer::WebGLRenderbuffer;
use dom::webgltexture::WebGLTexture;
@ -21,8 +21,8 @@ use std::cell::Cell;
#[must_root]
#[derive(Clone, HeapSizeOf, JSTraceable)]
enum WebGLFramebufferAttachment {
Renderbuffer(JS<WebGLRenderbuffer>),
Texture { texture: JS<WebGLTexture>, level: i32 },
Renderbuffer(Dom<WebGLRenderbuffer>),
Texture { texture: Dom<WebGLTexture>, level: i32 },
}
#[dom_struct]
@ -194,7 +194,7 @@ impl WebGLFramebuffer {
let rb_id = match rb {
Some(rb) => {
*binding.borrow_mut() = Some(WebGLFramebufferAttachment::Renderbuffer(JS::from_ref(rb)));
*binding.borrow_mut() = Some(WebGLFramebufferAttachment::Renderbuffer(Dom::from_ref(rb)));
Some(rb.id())
}
@ -267,7 +267,7 @@ impl WebGLFramebuffer {
}
*binding.borrow_mut() = Some(WebGLFramebufferAttachment::Texture {
texture: JS::from_ref(texture),
texture: Dom::from_ref(texture),
level: level }
);

View file

@ -20,7 +20,7 @@ use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSVal
use dom::bindings::error::{Error, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{JS, LayoutJS, MutNullableJS, Root};
use dom::bindings::root::{Dom, LayoutJS, MutNullableJS, Root};
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::htmlcanvaselement::HTMLCanvasElement;
@ -140,7 +140,7 @@ pub struct WebGLRenderingContext {
share_mode: WebGLContextShareMode,
#[ignore_heap_size_of = "Defined in offscreen_gl_context"]
limits: GLLimits,
canvas: JS<HTMLCanvasElement>,
canvas: Dom<HTMLCanvasElement>,
#[ignore_heap_size_of = "Defined in canvas_traits"]
last_error: Cell<Option<WebGLError>>,
texture_unpacking_settings: Cell<TextureUnpacking>,
@ -151,7 +151,7 @@ pub struct WebGLRenderingContext {
bound_texture_cube_map: MutNullableJS<WebGLTexture>,
bound_buffer_array: MutNullableJS<WebGLBuffer>,
bound_buffer_element_array: MutNullableJS<WebGLBuffer>,
bound_attrib_buffers: DOMRefCell<FnvHashMap<u32, JS<WebGLBuffer>>>,
bound_attrib_buffers: DOMRefCell<FnvHashMap<u32, Dom<WebGLBuffer>>>,
current_program: MutNullableJS<WebGLProgram>,
#[ignore_heap_size_of = "Because it's small"]
current_vertex_attrib_0: Cell<(f32, f32, f32, f32)>,
@ -185,7 +185,7 @@ impl WebGLRenderingContext {
webrender_image: Cell::new(None),
share_mode: ctx_data.share_mode,
limits: ctx_data.limits,
canvas: JS::from_ref(canvas),
canvas: Dom::from_ref(canvas),
last_error: Cell::new(None),
texture_unpacking_settings: Cell::new(CONVERT_COLORSPACE),
texture_unpacking_alignment: Cell::new(4),
@ -239,12 +239,12 @@ impl WebGLRenderingContext {
}
}
pub fn borrow_bound_attrib_buffers(&self) -> Ref<FnvHashMap<u32, JS<WebGLBuffer>>> {
pub fn borrow_bound_attrib_buffers(&self) -> Ref<FnvHashMap<u32, Dom<WebGLBuffer>>> {
self.bound_attrib_buffers.borrow()
}
pub fn set_bound_attrib_buffers<'a, T>(&self, iter: T) where T: Iterator<Item=(u32, &'a WebGLBuffer)> {
*self.bound_attrib_buffers.borrow_mut() = FnvHashMap::from_iter(iter.map(|(k,v)| (k, JS::from_ref(v))));
*self.bound_attrib_buffers.borrow_mut() = FnvHashMap::from_iter(iter.map(|(k,v)| (k, Dom::from_ref(v))));
}
pub fn bound_buffer_element_array(&self) -> Option<Root<WebGLBuffer>> {
@ -3024,7 +3024,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
self.bound_attrib_buffers.borrow_mut().insert(attrib_id, JS::from_ref(&*buffer_array));
self.bound_attrib_buffers.borrow_mut().insert(attrib_id, Dom::from_ref(&*buffer_array));
let msg = WebGLCommand::VertexAttribPointer(attrib_id, size, data_type, normalized, stride, offset as u32);
self.send_command(msg);

View file

@ -21,7 +21,7 @@ use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::DOMString;
use dom::bindings::structuredclone::StructuredCloneData;
use dom::bindings::trace::RootedTraceableBox;
@ -280,7 +280,7 @@ pub struct Window {
/// initiated by layout during a reflow. They are stored in the script thread
/// to ensure that the element can be marked dirty when the image data becomes
/// available at some point in the future.
pending_layout_images: DOMRefCell<HashMap<PendingImageId, Vec<JS<Node>>>>,
pending_layout_images: DOMRefCell<HashMap<PendingImageId, Vec<Dom<Node>>>>,
/// Directory to store unminified scripts for this window if unminify-js
/// opt is enabled.
@ -840,7 +840,7 @@ impl WindowMethods for Window {
// Step 5.
CSSStyleDeclaration::new(self,
CSSStyleOwner::Element(JS::from_ref(element)),
CSSStyleOwner::Element(Dom::from_ref(element)),
pseudo,
CSSModificationAccess::Readonly)
}
@ -1305,7 +1305,7 @@ impl Window {
let _ = image_cache_chan.send((pipeline, message.to().unwrap()));
});
self.image_cache.add_listener(id, ImageResponder::new(responder, id));
nodes.push(JS::from_ref(&*node));
nodes.push(Dom::from_ref(&*node));
}
}

View file

@ -7,7 +7,7 @@ use dom::bindings::error::{Error, throw_dom_exception};
use dom::bindings::inheritance::Castable;
use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::root::{JS, Root, RootedReference};
use dom::bindings::root::{Dom, Root, RootedReference};
use dom::bindings::trace::JSTraceable;
use dom::bindings::utils::{WindowProxyHandler, get_array_index_from_id, AsVoidPtr};
use dom::dissimilaroriginwindow::DissimilarOriginWindow;
@ -66,10 +66,10 @@ pub struct WindowProxy {
discarded: Cell<bool>,
/// The containing iframe element, if this is a same-origin iframe
frame_element: Option<JS<Element>>,
frame_element: Option<Dom<Element>>,
/// The parent browsing context's window proxy, if this is a nested browsing context
parent: Option<JS<WindowProxy>>,
parent: Option<Dom<WindowProxy>>,
}
impl WindowProxy {
@ -86,8 +86,8 @@ impl WindowProxy {
top_level_browsing_context_id: top_level_browsing_context_id,
currently_active: Cell::new(currently_active),
discarded: Cell::new(false),
frame_element: frame_element.map(JS::from_ref),
parent: parent.map(JS::from_ref),
frame_element: frame_element.map(Dom::from_ref),
parent: parent.map(Dom::from_ref),
}
}

View file

@ -20,7 +20,7 @@ use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::TrustedPromise;
use dom::bindings::reflector::Reflector;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::{JS, Root, RootCollection};
use dom::bindings::root::{Dom, Root, RootCollection};
use dom::bindings::str::USVString;
use dom::bindings::trace::JSTraceable;
use dom::bindings::trace::RootedTraceableBox;
@ -78,7 +78,7 @@ const MIN_GC_THRESHOLD: u32 = 1_000_000;
/// https://drafts.css-houdini.org/worklets/#worklet
pub struct Worklet {
reflector: Reflector,
window: JS<Window>,
window: Dom<Window>,
worklet_id: WorkletId,
global_type: WorkletGlobalScopeType,
}
@ -87,7 +87,7 @@ impl Worklet {
fn new_inherited(window: &Window, global_type: WorkletGlobalScopeType) -> Worklet {
Worklet {
reflector: Reflector::new(),
window: JS::from_ref(window),
window: Dom::from_ref(window),
worklet_id: WorkletId::new(),
global_type: global_type,
}
@ -396,7 +396,7 @@ struct WorkletThread {
global_init: WorkletGlobalScopeInit,
/// The global scopes created by this thread
global_scopes: HashMap<WorkletId, JS<WorkletGlobalScope>>,
global_scopes: HashMap<WorkletId, Dom<WorkletGlobalScope>>,
/// A one-place buffer for control messages
control_buffer: Option<WorkletControl>,
@ -546,7 +546,7 @@ impl WorkletThread {
debug!("Creating new worklet global scope.");
let executor = WorkletExecutor::new(worklet_id, self.primary_sender.clone());
let result = global_type.new(&self.runtime, pipeline_id, base_url, executor, &self.global_init);
entry.insert(JS::from_ref(&*result));
entry.insert(Dom::from_ref(&*result));
result
},
}

View file

@ -86,7 +86,7 @@ impl WorkletGlobalScope {
/// Evaluate a JS script in this global.
pub fn evaluate_js(&self, script: &str) -> bool {
debug!("Evaluating JS.");
debug!("Evaluating Dom.");
rooted!(in (self.globalscope.get_cx()) let mut rval = UndefinedValue());
self.globalscope.evaluate_js_on_global_with_result(&*script, rval.handle_mut())
}

View file

@ -16,7 +16,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{JS, MutNullableJS, Root};
use dom::bindings::root::{Dom, MutNullableJS, Root};
use dom::bindings::str::{ByteString, DOMString, USVString, is_token};
use dom::blob::{Blob, BlobImpl};
use dom::document::{Document, HasBrowsingContext, IsHTMLDocument};
@ -123,7 +123,7 @@ pub struct XMLHttpRequest {
ready_state: Cell<XMLHttpRequestState>,
timeout: Cell<u32>,
with_credentials: Cell<bool>,
upload: JS<XMLHttpRequestUpload>,
upload: Dom<XMLHttpRequestUpload>,
response_url: DOMRefCell<String>,
status: Cell<u16>,
status_text: DOMRefCell<ByteString>,
@ -174,7 +174,7 @@ impl XMLHttpRequest {
ready_state: Cell::new(XMLHttpRequestState::Unsent),
timeout: Cell::new(0u32),
with_credentials: Cell::new(false),
upload: JS::from_ref(&*XMLHttpRequestUpload::new(global)),
upload: Dom::from_ref(&*XMLHttpRequestUpload::new(global)),
response_url: DOMRefCell::new(String::new()),
status: Cell::new(0),
status_text: DOMRefCell::new(ByteString::new(vec!())),

View file

@ -34,7 +34,7 @@ use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, Stringi
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{JS, MutNullableJS, Root, RootCollection};
use dom::bindings::root::{Dom, MutNullableJS, Root, RootCollection};
use dom::bindings::root::{RootCollectionPtr, RootedReference};
use dom::bindings::str::DOMString;
use dom::bindings::structuredclone::StructuredCloneData;
@ -320,7 +320,7 @@ impl OpaqueSender<CommonScriptMsg> for Sender<MainThreadScriptMsg> {
#[derive(JSTraceable)]
#[must_root]
pub struct Documents {
map: HashMap<PipelineId, JS<Document>>,
map: HashMap<PipelineId, Dom<Document>>,
}
impl Documents {
@ -331,7 +331,7 @@ impl Documents {
}
pub fn insert(&mut self, pipeline_id: PipelineId, doc: &Document) {
self.map.insert(pipeline_id, JS::from_ref(doc));
self.map.insert(pipeline_id, Dom::from_ref(doc));
}
pub fn remove(&mut self, pipeline_id: PipelineId) -> Option<Root<Document>> {
@ -369,7 +369,7 @@ impl Documents {
#[allow(unrooted_must_root)]
pub struct DocumentsIter<'a> {
iter: hash_map::Iter<'a, PipelineId, JS<Document>>,
iter: hash_map::Iter<'a, PipelineId, Dom<Document>>,
}
impl<'a> Iterator for DocumentsIter<'a> {
@ -388,13 +388,13 @@ pub struct ScriptThread {
documents: DOMRefCell<Documents>,
/// The window proxies known by this thread
/// TODO: this map grows, but never shrinks. Issue #15258.
window_proxies: DOMRefCell<HashMap<BrowsingContextId, JS<WindowProxy>>>,
window_proxies: DOMRefCell<HashMap<BrowsingContextId, Dom<WindowProxy>>>,
/// A list of data pertaining to loads that have not yet received a network response
incomplete_loads: DOMRefCell<Vec<InProgressLoad>>,
/// A vector containing parser contexts which have not yet been fully processed
incomplete_parser_contexts: DOMRefCell<Vec<(PipelineId, ParserContext)>>,
/// A map to store service worker registrations for a given origin
registration_map: DOMRefCell<HashMap<ServoUrl, JS<ServiceWorkerRegistration>>>,
registration_map: DOMRefCell<HashMap<ServoUrl, Dom<ServiceWorkerRegistration>>>,
/// A job queue for Service Workers keyed by their scope url
job_queue_map: Rc<JobQueue>,
/// Image cache for this script thread.
@ -476,7 +476,7 @@ pub struct ScriptThread {
mutation_observer_compound_microtask_queued: Cell<bool>,
/// The unit of related similar-origin browsing contexts' list of MutationObserver objects
mutation_observers: DOMRefCell<Vec<JS<MutationObserver>>>,
mutation_observers: DOMRefCell<Vec<Dom<MutationObserver>>>,
/// A handle to the webgl thread
webgl_chan: WebGLPipeline,
@ -489,11 +489,11 @@ pub struct ScriptThread {
/// A list of pipelines containing documents that finished loading all their blocking
/// resources during a turn of the event loop.
docs_with_no_blocking_loads: DOMRefCell<HashSet<JS<Document>>>,
docs_with_no_blocking_loads: DOMRefCell<HashSet<Dom<Document>>>,
/// A list of nodes with in-progress CSS transitions, which roots them for the duration
/// of the transition.
transitioning_nodes: DOMRefCell<Vec<JS<Node>>>,
transitioning_nodes: DOMRefCell<Vec<Dom<Node>>>,
/// https://html.spec.whatwg.org/multipage/#custom-element-reactions-stack
custom_element_reaction_stack: CustomElementReactionStack,
@ -588,7 +588,7 @@ impl ScriptThread {
let js_runtime = script_thread.js_runtime.rt();
let new_nodes = nodes
.into_iter()
.map(|n| JS::from_ref(&*from_untrusted_node_address(js_runtime, n)));
.map(|n| Dom::from_ref(&*from_untrusted_node_address(js_runtime, n)));
script_thread.transitioning_nodes.borrow_mut().extend(new_nodes);
})
}
@ -612,7 +612,7 @@ impl ScriptThread {
let script_thread = unsafe { &*root.get().unwrap() };
script_thread.mutation_observers
.borrow_mut()
.push(JS::from_ref(observer));
.push(Dom::from_ref(observer));
})
}
@ -628,7 +628,7 @@ impl ScriptThread {
let script_thread = unsafe { &*root.get().unwrap() };
script_thread.docs_with_no_blocking_loads
.borrow_mut()
.insert(JS::from_ref(doc));
.insert(Dom::from_ref(doc));
})
}
@ -1699,7 +1699,7 @@ impl ScriptThread {
// according to spec we should replace if an older registration exists for
// same scope otherwise just insert the new one
let _ = reg_ref.remove(scope);
reg_ref.insert(scope.clone(), JS::from_ref(registration));
reg_ref.insert(scope.clone(), Dom::from_ref(registration));
}
// send ScopeThings to sw-manager
@ -1959,7 +1959,7 @@ impl ScriptThread {
browsing_context_id,
top_level_browsing_context_id,
parent.r());
self.window_proxies.borrow_mut().insert(browsing_context_id, JS::from_ref(&*window_proxy));
self.window_proxies.borrow_mut().insert(browsing_context_id, Dom::from_ref(&*window_proxy));
Some(window_proxy)
}
@ -1996,7 +1996,7 @@ impl ScriptThread {
top_level_browsing_context_id,
iframe.r().map(Castable::upcast),
parent.r());
self.window_proxies.borrow_mut().insert(browsing_context_id, JS::from_ref(&*window_proxy));
self.window_proxies.borrow_mut().insert(browsing_context_id, Dom::from_ref(&*window_proxy));
window_proxy
}

View file

@ -11,7 +11,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::error::Error;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::DomObject;
use dom::bindings::root::JS;
use dom::bindings::root::Dom;
use dom::client::Client;
use dom::promise::Promise;
use dom::serviceworkerregistration::ServiceWorkerRegistration;
@ -46,7 +46,7 @@ pub struct Job {
pub promise: Rc<Promise>,
pub equivalent_jobs: Vec<Job>,
// client can be a window client, worker client so `Client` will be an enum in future
pub client: JS<Client>,
pub client: Dom<Client>,
pub referrer: ServoUrl
}
@ -64,7 +64,7 @@ impl Job {
script_url: script_url,
promise: promise,
equivalent_jobs: vec![],
client: JS::from_ref(client),
client: Dom::from_ref(client),
referrer: client.creation_url()
}
}

View file

@ -7,7 +7,7 @@ pub use dom::headers::normalize_value;
// For compile-fail tests only.
pub use dom::bindings::cell::DOMRefCell;
pub use dom::bindings::root::JS;
pub use dom::bindings::root::Dom;
pub use dom::node::Node;
pub use dom::bindings::refcounted::TrustedPromise;

View file

@ -574,10 +574,10 @@ def check_rust(file_name, lines):
# No benefit over using &str
(r": &String", "use &str instead of &String", no_filter),
# There should be any use of banned types:
# Cell<JSVal>, Cell<JS<T>>, DOMRefCell<JS<T>>, DOMRefCell<HEAP<T>>
# Cell<JSVal>, Cell<Dom<T>>, DOMRefCell<Dom<T>>, DOMRefCell<HEAP<T>>
(r"(\s|:)+Cell<JSVal>", "Banned type Cell<JSVal> detected. Use MutJS<JSVal> instead", no_filter),
(r"(\s|:)+Cell<JS<.+>>", "Banned type Cell<JS<T>> detected. Use MutJS<T> instead", no_filter),
(r"DOMRefCell<JS<.+>>", "Banned type DOMRefCell<JS<T>> detected. Use MutJS<T> instead", no_filter),
(r"(\s|:)+Cell<Dom<.+>>", "Banned type Cell<Dom<T>> detected. Use MutJS<T> instead", no_filter),
(r"DOMRefCell<Dom<.+>>", "Banned type DOMRefCell<Dom<T>> detected. Use MutJS<T> instead", no_filter),
(r"DOMRefCell<Heap<.+>>", "Banned type DOMRefCell<Heap<T>> detected. Use MutJS<T> instead", no_filter),
# No benefit to using &Root<T>
(r": &Root<", "use &T instead of &Root<T>", no_filter),

View file

@ -7,13 +7,13 @@
extern crate script;
use script::test::Dom;
use script::test::DOMRefCell;
use script::test::JS;
use script::test::Node;
struct Foo {
bar: DOMRefCell<JS<Node>>
//~^ ERROR Banned type DOMRefCell<JS<T>> detected. Use MutJS<T> instead
bar: DOMRefCell<Dom<Node>>
//~^ ERROR Banned type DOMRefCell<Dom<T>> detected. Use MutJS<T> instead
}
fn main() {}

View file

@ -151,7 +151,7 @@ class CheckTidiness(unittest.TestCase):
self.assertNoMoreErrors(ban_errors)
ban_errors = tidy.collect_errors_for_files(iterFile('ban-domrefcell.rs'), [], [tidy.check_rust], print_text=False)
self.assertEqual('Banned type DOMRefCell<JS<T>> detected. Use MutJS<T> instead', ban_errors.next()[2])
self.assertEqual('Banned type DOMRefCell<Dom<T>> detected. Use MutJS<T> instead', ban_errors.next()[2])
self.assertNoMoreErrors(ban_errors)
def test_spec_link(self):