servo: Merge #14495 - Rename `Reflectable` to `DomObject` (from frewsxcv:reflectable-domobject); r=jdm

Fixes https://github.com/servo/servo/issues/8473.

Source-Repo: https://github.com/servo/servo
Source-Revision: b192ae9db7082346a4a6a985c5557d4cea75d50e
This commit is contained in:
Corey Farwell 2016-12-08 12:41:08 -08:00
Родитель 7b343fddb8
Коммит b429779be4
72 изменённых файлов: 168 добавлений и 168 удалений

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

@ -35,7 +35,7 @@ use syntax::symbol::Symbol;
/// Handles the auto-deriving for `#[derive(JSTraceable)]`
pub mod jstraceable;
pub mod lints;
/// Autogenerates implementations of Reflectable on DOM structs
/// Autogenerates implementations of DomObject on DOM structs
pub mod reflector;
/// Utilities for writing plugins
mod utils;

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

@ -25,14 +25,14 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, annotatable:
Some(f) => {
let field_name = f.ident;
let impl_item = quote_item!(cx,
impl ::dom::bindings::reflector::Reflectable for $struct_name {
impl ::dom::bindings::reflector::DomObject for $struct_name {
fn reflector<'a>(&'a self) -> &'a ::dom::bindings::reflector::Reflector {
&self.$field_name
}
}
);
let impl_item_mut = quote_item!(cx,
impl ::dom::bindings::reflector::MutReflectable for $struct_name {
impl ::dom::bindings::reflector::MutDomObject for $struct_name {
fn init_reflector(&mut self, obj: *mut ::js::jsapi::JSObject) {
self.$field_name.set_jsobject(obj);
}
@ -45,14 +45,14 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, annotatable:
None => {
let field_name = def.fields()[0].ident;
let impl_item = quote_item!(cx,
impl ::dom::bindings::reflector::Reflectable for $struct_name {
impl ::dom::bindings::reflector::DomObject for $struct_name {
fn reflector<'a>(&'a self) -> &'a ::dom::bindings::reflector::Reflector {
self.$field_name.reflector()
}
}
);
let impl_item_mut = quote_item!(cx,
impl ::dom::bindings::reflector::MutReflectable for $struct_name {
impl ::dom::bindings::reflector::MutDomObject for $struct_name {
fn init_reflector(&mut self, obj: *mut ::js::jsapi::JSObject) {
self.$field_name.init_reflector(obj);
}
@ -69,7 +69,7 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, annotatable:
unsafe fn to_jsval(&self,
cx: *mut ::js::jsapi::JSContext,
rval: ::js::jsapi::MutableHandleValue) {
let object = ::dom::bindings::reflector::Reflectable::reflector(self).get_jsobject();
let object = ::dom::bindings::reflector::DomObject::reflector(self).get_jsobject();
object.to_jsval(cx, rval)
}
}

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

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::js::Root;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::USVString;
use dom::blob::{Blob, BlobImpl};
use dom::formdata::FormData;
@ -41,7 +41,7 @@ pub enum FetchedData {
// https://fetch.spec.whatwg.org/#concept-body-consume-body
#[allow(unrooted_must_root)]
pub fn consume_body<T: BodyOperations + Reflectable>(object: &T, body_type: BodyType) -> Rc<Promise> {
pub fn consume_body<T: BodyOperations + DomObject>(object: &T, body_type: BodyType) -> Rc<Promise> {
let promise = Promise::new(&object.global());
// Step 1
@ -63,9 +63,9 @@ pub fn consume_body<T: BodyOperations + Reflectable>(object: &T, body_type: Body
// https://fetch.spec.whatwg.org/#concept-body-consume-body
#[allow(unrooted_must_root)]
pub fn consume_body_with_promise<T: BodyOperations + Reflectable>(object: &T,
body_type: BodyType,
promise: &Promise) {
pub fn consume_body_with_promise<T: BodyOperations + DomObject>(object: &T,
body_type: BodyType,
promise: &Promise) {
// Step 5
let body = match object.take_body() {
Some(body) => body,
@ -93,11 +93,11 @@ pub fn consume_body_with_promise<T: BodyOperations + Reflectable>(object: &T,
// https://fetch.spec.whatwg.org/#concept-body-package-data
#[allow(unsafe_code)]
fn run_package_data_algorithm<T: BodyOperations + Reflectable>(object: &T,
bytes: Vec<u8>,
body_type: BodyType,
mime_type: Ref<Vec<u8>>)
-> Fallible<FetchedData> {
fn run_package_data_algorithm<T: BodyOperations + DomObject>(object: &T,
bytes: Vec<u8>,
body_type: BodyType,
mime_type: Ref<Vec<u8>>)
-> Fallible<FetchedData> {
let global = object.global();
let cx = global.get_cx();
let mime = &*mime_type;

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

@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, jsstring_to_str};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::document::AnimationFrameCallback;
use dom::element::Element;

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

@ -181,7 +181,7 @@ pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Ref
}
}
impl<T: Reflectable> JSTraceable for JS<T> {
impl<T: DomObject> JSTraceable for JS<T> {
unsafe fn trace(&self, trc: *mut JSTracer) {
trace_reflector(trc, "", unsafe { (**self.ptr).reflector() });
}

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

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::structuredclone::StructuredCloneData;
use js::jsapi::{JSRuntime, JS_RequestInterruptCallback};
use js::rust::Runtime;
@ -17,11 +17,11 @@ pub enum WorkerScriptMsg {
DOMMessage(StructuredCloneData)
}
pub struct SimpleWorkerErrorHandler<T: Reflectable> {
pub struct SimpleWorkerErrorHandler<T: DomObject> {
pub addr: Trusted<T>,
}
impl<T: Reflectable> SimpleWorkerErrorHandler<T> {
impl<T: DomObject> SimpleWorkerErrorHandler<T> {
pub fn new(addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> {
SimpleWorkerErrorHandler {
addr: addr

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

@ -4,7 +4,7 @@
use dom::abstractworker::WorkerScriptMsg;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::trace::JSTraceable;
use script_runtime::{ScriptChan, CommonScriptMsg, ScriptPort};
use std::sync::mpsc::{Receiver, Sender};
@ -13,12 +13,12 @@ use std::sync::mpsc::{Receiver, Sender};
/// common event loop messages. While this SendableWorkerScriptChan is alive, the associated
/// Worker object will remain alive.
#[derive(JSTraceable, Clone)]
pub struct SendableWorkerScriptChan<T: Reflectable> {
pub struct SendableWorkerScriptChan<T: DomObject> {
pub sender: Sender<(Trusted<T>, CommonScriptMsg)>,
pub worker: Trusted<T>,
}
impl<T: JSTraceable + Reflectable + 'static> ScriptChan for SendableWorkerScriptChan<T> {
impl<T: JSTraceable + DomObject + 'static> ScriptChan for SendableWorkerScriptChan<T> {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
self.sender.send((self.worker.clone(), msg)).map_err(|_| ())
}
@ -35,12 +35,12 @@ impl<T: JSTraceable + Reflectable + 'static> ScriptChan for SendableWorkerScript
/// worker event loop messages. While this SendableWorkerScriptChan is alive, the associated
/// Worker object will remain alive.
#[derive(JSTraceable, Clone)]
pub struct WorkerThreadWorkerChan<T: Reflectable> {
pub struct WorkerThreadWorkerChan<T: DomObject> {
pub sender: Sender<(Trusted<T>, WorkerScriptMsg)>,
pub worker: Trusted<T>,
}
impl<T: JSTraceable + Reflectable + 'static> ScriptChan for WorkerThreadWorkerChan<T> {
impl<T: JSTraceable + DomObject + 'static> ScriptChan for WorkerThreadWorkerChan<T> {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
self.sender
.send((self.worker.clone(), WorkerScriptMsg::Common(msg)))
@ -55,7 +55,7 @@ impl<T: JSTraceable + Reflectable + 'static> ScriptChan for WorkerThreadWorkerCh
}
}
impl<T: Reflectable> ScriptPort for Receiver<(Trusted<T>, WorkerScriptMsg)> {
impl<T: DomObject> ScriptPort for Receiver<(Trusted<T>, WorkerScriptMsg)> {
fn recv(&self) -> Result<CommonScriptMsg, ()> {
match self.recv().map(|(_, msg)| msg) {
Ok(WorkerScriptMsg::Common(script_msg)) => Ok(script_msg),

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

@ -5,7 +5,7 @@
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::globalscope::GlobalScope;
use js::jsapi::{Heap, MutableHandleObject, RootedObject};
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject};
@ -132,9 +132,9 @@ impl CallbackInterface {
}
/// Wraps the reflector for `p` into the compartment of `cx`.
pub fn wrap_call_this_object<T: Reflectable>(cx: *mut JSContext,
p: &T,
rval: MutableHandleObject) {
pub fn wrap_call_this_object<T: DomObject>(cx: *mut JSContext,
p: &T,
rval: MutableHandleObject) {
rval.set(p.reflector().get_jsobject().get());
assert!(!rval.get().is_null());

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

@ -5528,8 +5528,8 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'dom::bindings::js::RootedReference',
'dom::bindings::namespace::NamespaceObjectClass',
'dom::bindings::namespace::create_namespace_object',
'dom::bindings::reflector::MutReflectable',
'dom::bindings::reflector::Reflectable',
'dom::bindings::reflector::MutDomObject',
'dom::bindings::reflector::DomObject',
'dom::bindings::utils::DOMClass',
'dom::bindings::utils::DOMJSClass',
'dom::bindings::utils::DOM_PROTO_UNFORGEABLE_HOLDER_SLOT',
@ -6294,7 +6294,7 @@ class CGCallback(CGClass):
})
return [ClassMethod(method.name + '_', method.returnType, args,
bodyInHeader=True,
templateArgs=["T: Reflectable"],
templateArgs=["T: DomObject"],
body=bodyWithThis,
visibility='pub'),
ClassMethod(method.name + '__', method.returnType, argsWithoutThis,
@ -6917,7 +6917,7 @@ class GlobalGenRoots():
CGGeneric("use dom::bindings::inheritance::Castable;\n"),
CGGeneric("use dom::bindings::js::{JS, LayoutJS, Root};\n"),
CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
CGGeneric("use dom::bindings::reflector::Reflectable;\n"),
CGGeneric("use dom::bindings::reflector::DomObject;\n"),
CGGeneric("use js::jsapi::JSTracer;\n\n"),
CGGeneric("use std::mem;\n\n")]
allprotos = []

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

@ -35,7 +35,7 @@
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::num::Finite;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::str::{ByteString, DOMString, USVString};
use dom::bindings::utils::DOMClass;
use js;
@ -102,7 +102,7 @@ impl<T: Float + FromJSValConvertible<Config=()>> FromJSValConvertible for Finite
}
}
impl <T: Reflectable + IDLInterface> FromJSValConvertible for Root<T> {
impl <T: DomObject + IDLInterface> FromJSValConvertible for Root<T> {
type Config = ();
unsafe fn from_jsval(_cx: *mut JSContext,
@ -404,7 +404,7 @@ pub unsafe fn private_from_proto_check<F>(mut obj: *mut JSObject,
/// Get a `*const T` for a DOM object accessible from a `JSObject`.
pub fn native_from_object<T>(obj: *mut JSObject) -> Result<*const T, ()>
where T: Reflectable + IDLInterface
where T: DomObject + IDLInterface
{
unsafe {
private_from_proto_check(obj, T::derives).map(|ptr| ptr as *const T)
@ -418,7 +418,7 @@ pub fn native_from_object<T>(obj: *mut JSObject) -> Result<*const T, ()>
/// not a reflector for a DOM object of the given type (as defined by the
/// proto_id and proto_depth).
pub fn root_from_object<T>(obj: *mut JSObject) -> Result<Root<T>, ()>
where T: Reflectable + IDLInterface
where T: DomObject + IDLInterface
{
native_from_object(obj).map(|ptr| unsafe { Root::from_ref(&*ptr) })
}
@ -426,7 +426,7 @@ pub fn root_from_object<T>(obj: *mut JSObject) -> Result<Root<T>, ()>
/// Get a `*const T` for a DOM object accessible from a `HandleValue`.
/// Caller is responsible for throwing a JS exception if needed in case of error.
pub fn native_from_handlevalue<T>(v: HandleValue) -> Result<*const T, ()>
where T: Reflectable + IDLInterface
where T: DomObject + IDLInterface
{
if !v.get().is_object() {
return Err(());
@ -437,7 +437,7 @@ pub fn native_from_handlevalue<T>(v: HandleValue) -> Result<*const T, ()>
/// Get a `Root<T>` for a DOM object accessible from a `HandleValue`.
/// Caller is responsible for throwing a JS exception if needed in case of error.
pub fn root_from_handlevalue<T>(v: HandleValue) -> Result<Root<T>, ()>
where T: Reflectable + IDLInterface
where T: DomObject + IDLInterface
{
if !v.get().is_object() {
return Err(());
@ -447,12 +447,12 @@ pub fn root_from_handlevalue<T>(v: HandleValue) -> Result<Root<T>, ()>
/// Get a `Root<T>` for a DOM object accessible from a `HandleObject`.
pub fn root_from_handleobject<T>(obj: HandleObject) -> Result<Root<T>, ()>
where T: Reflectable + IDLInterface
where T: DomObject + IDLInterface
{
root_from_object(obj.get())
}
impl<T: Reflectable> ToJSValConvertible for Root<T> {
impl<T: DomObject> ToJSValConvertible for Root<T> {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
self.reflector().to_jsval(cx, rval);
}

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

@ -8,12 +8,12 @@ pub use dom::bindings::codegen::InheritTypes::*;
use dom::bindings::conversions::{DerivedFrom, IDLInterface};
use dom::bindings::conversions::get_dom_class;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use std::mem;
/// A trait to hold the cast functions of IDL interfaces that either derive
/// or are derived from other interfaces.
pub trait Castable: IDLInterface + Reflectable + Sized {
pub trait Castable: IDLInterface + DomObject + Sized {
/// Check whether a DOM object implements one of its deriving interfaces.
fn is<T>(&self) -> bool
where T: DerivedFrom<Self>

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

@ -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::js::{JS, Root};
use dom::bindings::reflector::{Reflector, Reflectable, MutReflectable, reflect_dom_object};
use dom::bindings::reflector::{Reflector, DomObject, MutDomObject, reflect_dom_object};
use dom::bindings::trace::JSTraceable;
use dom::globalscope::GlobalScope;
use js::conversions::ToJSValConvertible;
@ -52,36 +52,36 @@ pub trait Iterable {
#[privatize]
#[derive(JSTraceable)]
#[derive(HeapSizeOf)]
pub struct IterableIterator<T: Reflectable + JSTraceable + Iterable> {
pub struct IterableIterator<T: DomObject + JSTraceable + Iterable> {
reflector: Reflector,
iterable: JS<T>,
type_: IteratorType,
index: Cell<u32>,
}
impl<T: Reflectable + JSTraceable + Iterable> Reflectable for IterableIterator<T> {
impl<T: DomObject + JSTraceable + Iterable> DomObject for IterableIterator<T> {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector
}
}
impl<T: Reflectable + JSTraceable + Iterable> MutReflectable for IterableIterator<T> {
impl<T: DomObject + JSTraceable + Iterable> MutDomObject for IterableIterator<T> {
fn init_reflector(&mut self, obj: *mut JSObject) {
self.reflector.set_jsobject(obj);
}
}
impl<T: Reflectable + JSTraceable + Iterable> ToJSValConvertible for IterableIterator<T> {
impl<T: DomObject + JSTraceable + Iterable> ToJSValConvertible for IterableIterator<T> {
#[allow(unsafe_code)]
unsafe fn to_jsval(&self,
cx: *mut JSContext,
rval: MutableHandleValue) {
let object = Reflectable::reflector(self).get_jsobject();
let object = DomObject::reflector(self).get_jsobject();
object.to_jsval(cx, rval)
}
}
impl<T: Reflectable + JSTraceable + Iterable> IterableIterator<T> {
impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
/// Create a new iterator instance for the provided iterable DOM interface.
pub fn new(iterable: &T,
type_: IteratorType,

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

@ -26,7 +26,7 @@
use core::nonzero::NonZero;
use dom::bindings::conversions::DerivedFrom;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::trace::JSTraceable;
use dom::bindings::trace::trace_reflector;
use dom::node::Node;
@ -76,7 +76,7 @@ impl<T> JS<T> {
}
}
impl<T: Reflectable> JS<T> {
impl<T: DomObject> JS<T> {
/// Create a JS<T> from a &T
#[allow(unrooted_must_root)]
pub fn from_ref(obj: &T) -> JS<T> {
@ -87,14 +87,14 @@ impl<T: Reflectable> JS<T> {
}
}
impl<'root, T: Reflectable + 'root> RootedReference<'root> for JS<T> {
impl<'root, T: DomObject + 'root> RootedReference<'root> for JS<T> {
type Ref = &'root T;
fn r(&'root self) -> &'root T {
&self
}
}
impl<T: Reflectable> Deref for JS<T> {
impl<T: DomObject> Deref for JS<T> {
type Target = T;
fn deref(&self) -> &T {
@ -105,7 +105,7 @@ impl<T: Reflectable> Deref for JS<T> {
}
}
unsafe impl<T: Reflectable> JSTraceable for JS<T> {
unsafe impl<T: DomObject> JSTraceable for JS<T> {
unsafe fn trace(&self, trc: *mut JSTracer) {
#[cfg(debug_assertions)]
let trace_str = format!("for {} on heap", type_name::<T>());
@ -158,7 +158,7 @@ impl<T: Castable> LayoutJS<T> {
}
}
impl<T: Reflectable> LayoutJS<T> {
impl<T: DomObject> LayoutJS<T> {
/// Get the reflector.
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
debug_assert!(thread_state::get().is_layout());
@ -240,7 +240,7 @@ pub trait HeapGCValue: JSTraceable {
impl HeapGCValue for Heap<JSVal> {
}
impl<T: Reflectable> HeapGCValue for JS<T> {
impl<T: DomObject> HeapGCValue for JS<T> {
}
/// A holder that provides interior mutability for GC-managed JSVals.
@ -297,7 +297,7 @@ pub struct MutHeap<T: HeapGCValue> {
val: UnsafeCell<T>,
}
impl<T: Reflectable> MutHeap<JS<T>> {
impl<T: DomObject> MutHeap<JS<T>> {
/// Create a new `MutHeap`.
pub fn new(initial: &T) -> MutHeap<JS<T>> {
debug_assert!(thread_state::get().is_script());
@ -330,7 +330,7 @@ impl<T: HeapGCValue> HeapSizeOf for MutHeap<T> {
}
}
impl<T: Reflectable> PartialEq for MutHeap<JS<T>> {
impl<T: DomObject> PartialEq for MutHeap<JS<T>> {
fn eq(&self, other: &Self) -> bool {
unsafe {
*self.val.get() == *other.val.get()
@ -338,7 +338,7 @@ impl<T: Reflectable> PartialEq for MutHeap<JS<T>> {
}
}
impl<T: Reflectable + PartialEq> PartialEq<T> for MutHeap<JS<T>> {
impl<T: DomObject + PartialEq> PartialEq<T> for MutHeap<JS<T>> {
fn eq(&self, other: &T) -> bool {
unsafe {
**self.val.get() == *other
@ -358,7 +358,7 @@ pub struct MutNullableHeap<T: HeapGCValue> {
ptr: UnsafeCell<Option<T>>,
}
impl<T: Reflectable> MutNullableHeap<JS<T>> {
impl<T: DomObject> MutNullableHeap<JS<T>> {
/// Create a new `MutNullableHeap`.
pub fn new(initial: Option<&T>) -> MutNullableHeap<JS<T>> {
debug_assert!(thread_state::get().is_script());
@ -416,7 +416,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
}
}
impl<T: Reflectable> PartialEq for MutNullableHeap<JS<T>> {
impl<T: DomObject> PartialEq for MutNullableHeap<JS<T>> {
fn eq(&self, other: &Self) -> bool {
unsafe {
*self.ptr.get() == *other.ptr.get()
@ -424,7 +424,7 @@ impl<T: Reflectable> PartialEq for MutNullableHeap<JS<T>> {
}
}
impl<'a, T: Reflectable> PartialEq<Option<&'a T>> for MutNullableHeap<JS<T>> {
impl<'a, T: DomObject> PartialEq<Option<&'a T>> for MutNullableHeap<JS<T>> {
fn eq(&self, other: &Option<&T>) -> bool {
unsafe {
*self.ptr.get() == other.map(JS::from_ref)
@ -449,7 +449,7 @@ impl<T: HeapGCValue> HeapSizeOf for MutNullableHeap<T> {
}
}
impl<T: Reflectable> LayoutJS<T> {
impl<T: DomObject> LayoutJS<T> {
/// Returns an unsafe pointer to the interior of this JS object. This is
/// the only method that be safely accessed from layout. (The fact that
/// this is unsafe is what necessitates the layout wrappers.)
@ -475,14 +475,14 @@ pub trait RootedReference<'root> {
fn r(&'root self) -> Self::Ref;
}
impl<'root, T: JSTraceable + Reflectable + 'root> RootedReference<'root> for [JS<T>] {
impl<'root, T: JSTraceable + DomObject + 'root> RootedReference<'root> for [JS<T>] {
type Ref = &'root [&'root T];
fn r(&'root self) -> &'root [&'root T] {
unsafe { mem::transmute(self) }
}
}
impl<'root, T: Reflectable + 'root> RootedReference<'root> for Rc<T> {
impl<'root, T: DomObject + 'root> RootedReference<'root> for Rc<T> {
type Ref = &'root T;
fn r(&'root self) -> &'root T {
self
@ -566,7 +566,7 @@ pub unsafe fn trace_roots(tracer: *mut JSTracer) {
/// for the same JS value. `Root`s cannot outlive the associated
/// `RootCollection` object.
#[allow_unrooted_interior]
pub struct Root<T: Reflectable> {
pub struct Root<T: DomObject> {
/// Reference to rooted value that must not outlive this container
ptr: NonZero<*const T>,
/// List that ensures correct dynamic root ordering
@ -594,7 +594,7 @@ impl<T: Castable> Root<T> {
}
}
impl<T: Reflectable> Root<T> {
impl<T: DomObject> Root<T> {
/// Create a new stack-bounded root for the provided JS-owned value.
/// It cannot outlive its associated `RootCollection`, and it gives
/// out references which cannot outlive this new `Root`.
@ -616,14 +616,14 @@ impl<T: Reflectable> Root<T> {
}
}
impl<'root, T: Reflectable + 'root> RootedReference<'root> for Root<T> {
impl<'root, T: DomObject + 'root> RootedReference<'root> for Root<T> {
type Ref = &'root T;
fn r(&'root self) -> &'root T {
self
}
}
impl<T: Reflectable> Deref for Root<T> {
impl<T: DomObject> Deref for Root<T> {
type Target = T;
fn deref(&self) -> &T {
debug_assert!(thread_state::get().is_script());
@ -631,25 +631,25 @@ impl<T: Reflectable> Deref for Root<T> {
}
}
impl<T: Reflectable + HeapSizeOf> HeapSizeOf for Root<T> {
impl<T: DomObject + HeapSizeOf> HeapSizeOf for Root<T> {
fn heap_size_of_children(&self) -> usize {
(**self).heap_size_of_children()
}
}
impl<T: Reflectable> PartialEq for Root<T> {
impl<T: DomObject> PartialEq for Root<T> {
fn eq(&self, other: &Self) -> bool {
self.ptr == other.ptr
}
}
impl<T: Reflectable> Clone for Root<T> {
impl<T: DomObject> Clone for Root<T> {
fn clone(&self) -> Root<T> {
Root::from_ref(&*self)
}
}
impl<T: Reflectable> Drop for Root<T> {
impl<T: DomObject> Drop for Root<T> {
fn drop(&mut self) {
unsafe {
(*self.root_list).unroot(self.reflector());

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

@ -24,7 +24,7 @@
use core::nonzero::NonZero;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::trace::trace_reflector;
use dom::promise::Promise;
use js::jsapi::JSTracer;
@ -55,7 +55,7 @@ pub struct TrustedReference(*const libc::c_void);
unsafe impl Send for TrustedReference {}
impl TrustedReference {
fn new<T: Reflectable>(ptr: *const T) -> TrustedReference {
fn new<T: DomObject>(ptr: *const T) -> TrustedReference {
TrustedReference(ptr as *const libc::c_void)
}
}
@ -122,7 +122,7 @@ impl TrustedPromise {
/// DOM object is guaranteed to live at least as long as the last outstanding
/// `Trusted<T>` instance.
#[allow_unrooted_interior]
pub struct Trusted<T: Reflectable> {
pub struct Trusted<T: DomObject> {
/// A pointer to the Rust DOM object of type T, but void to allow
/// sending `Trusted<T>` between threads, regardless of T's sendability.
refcount: Arc<TrustedReference>,
@ -130,9 +130,9 @@ pub struct Trusted<T: Reflectable> {
phantom: PhantomData<T>,
}
unsafe impl<T: Reflectable> Send for Trusted<T> {}
unsafe impl<T: DomObject> Send for Trusted<T> {}
impl<T: Reflectable> Trusted<T> {
impl<T: DomObject> Trusted<T> {
/// Create a new `Trusted<T>` instance from an existing DOM pointer. The DOM object will
/// be prevented from being GCed for the duration of the resulting `Trusted<T>` object's
/// lifetime.
@ -164,7 +164,7 @@ impl<T: Reflectable> Trusted<T> {
}
}
impl<T: Reflectable> Clone for Trusted<T> {
impl<T: DomObject> Clone for Trusted<T> {
fn clone(&self) -> Trusted<T> {
Trusted {
refcount: self.refcount.clone(),
@ -200,7 +200,7 @@ impl LiveDOMReferences {
table.entry(&*promise).or_insert(vec![]).push(promise)
}
fn addref<T: Reflectable>(&self, ptr: *const T) -> Arc<TrustedReference> {
fn addref<T: DomObject>(&self, ptr: *const T) -> Arc<TrustedReference> {
let mut table = self.reflectable_table.borrow_mut();
let capacity = table.capacity();
let len = table.len();

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

@ -18,7 +18,7 @@ pub fn reflect_dom_object<T, U>(
global: &U,
wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box<T>) -> Root<T>)
-> Root<T>
where T: Reflectable, U: DerivedFrom<GlobalScope>
where T: DomObject, U: DerivedFrom<GlobalScope>
{
let global_scope = global.upcast();
unsafe {
@ -77,18 +77,18 @@ impl Reflector {
}
/// A trait to provide access to the `Reflector` for a DOM object.
pub trait Reflectable {
pub trait DomObject {
/// Returns the receiver's reflector.
fn reflector(&self) -> &Reflector;
/// Returns the global scope of the realm that the Reflectable was created in.
/// Returns the global scope of the realm that the DomObject was created in.
fn global(&self) -> Root<GlobalScope> where Self: Sized {
GlobalScope::from_reflector(self)
}
}
/// A trait to initialize the `Reflector` for a DOM object.
pub trait MutReflectable: Reflectable {
pub trait MutDomObject: DomObject {
/// Initializes the Reflector
fn init_reflector(&mut self, obj: *mut JSObject);
}

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

@ -38,7 +38,7 @@ use dom::abstractworker::SharedRt;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::js::{JS, Root};
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::utils::WindowProxyHandler;
use dom::document::PendingRestyle;
@ -426,7 +426,7 @@ unsafe impl<T> JSTraceable for IpcReceiver<T> where T: Deserialize + Serialize {
}
}
unsafe impl<T: Reflectable> JSTraceable for Trusted<T> {
unsafe impl<T: DomObject> JSTraceable for Trusted<T> {
#[inline]
unsafe fn trace(&self, _: *mut JSTracer) {
// Do nothing
@ -635,9 +635,9 @@ impl RootedTraceableSet {
/// Roots any JSTraceable thing
///
/// If you have a valid Reflectable, use Root.
/// If you have a valid DomObject, use Root.
/// If you have GC things like *mut JSObject or JSVal, use rooted!.
/// If you have an arbitrary number of Reflectables to root, use rooted_vec!.
/// If you have an arbitrary number of DomObjects to root, use rooted_vec!.
/// If you know what you're doing, use this.
#[derive(JSTraceable)]
pub struct RootedTraceable<'a, T: 'a + JSTraceable> {
@ -690,7 +690,7 @@ pub struct RootedVec<'a, T: 'a + JSTraceable> {
root: &'a mut RootableVec<T>,
}
impl<'a, T: JSTraceable + Reflectable> RootedVec<'a, JS<T>> {
impl<'a, T: JSTraceable + DomObject> RootedVec<'a, JS<T>> {
/// Create a vector of items of type T that is rooted for
/// the lifetime of this struct
pub fn new<I: Iterator<Item = Root<T>>>(root: &'a mut RootableVec<JS<T>>, iter: I)

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

@ -13,7 +13,7 @@
use core::nonzero::NonZero;
use dom::bindings::js::Root;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::trace::JSTraceable;
use heapsize::HeapSizeOf;
use js::jsapi::{JSTracer, JS_GetReservedSlot, JS_SetReservedSlot};
@ -46,7 +46,7 @@ pub struct WeakBox<T: WeakReferenceable> {
}
/// Trait implemented by weak-referenceable interfaces.
pub trait WeakReferenceable: Reflectable + Sized {
pub trait WeakReferenceable: DomObject + Sized {
/// Downgrade a DOM object reference to a weak one.
fn downgrade(&self) -> WeakRef<Self> {
unsafe {

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

@ -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::js::{JS, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::globalscope::GlobalScope;
use encoding::all::UTF_8;

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

@ -17,7 +17,7 @@ use dom::bindings::error::Error::{self, NotFound, Security, Type};
use dom::bindings::error::Fallible;
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
use dom::bluetoothdevice::BluetoothDevice;
@ -53,7 +53,7 @@ const SERVICE_ERROR: &'static str = "'services', if present, must contain at lea
const OPTIONS_ERROR: &'static str = "Fields of 'options' conflict with each other.
Either 'acceptAllDevices' member must be true, or 'filters' member must be set to a value.";
struct BluetoothContext<T: AsyncBluetoothListener + Reflectable> {
struct BluetoothContext<T: AsyncBluetoothListener + DomObject> {
promise: Option<TrustedPromise>,
receiver: Trusted<T>,
}
@ -62,9 +62,9 @@ pub trait AsyncBluetoothListener {
fn handle_response(&self, result: BluetoothResponse, cx: *mut JSContext, promise: &Rc<Promise>);
}
impl<Listener: AsyncBluetoothListener + Reflectable> PreInvoke for BluetoothContext<Listener> {}
impl<Listener: AsyncBluetoothListener + DomObject> PreInvoke for BluetoothContext<Listener> {}
impl<Listener: AsyncBluetoothListener + Reflectable> BluetoothResponseListener for BluetoothContext<Listener> {
impl<Listener: AsyncBluetoothListener + DomObject> BluetoothResponseListener for BluetoothContext<Listener> {
#[allow(unrooted_must_root)]
fn response(&mut self, response: BluetoothResponseResult) {
let promise = self.promise.take().expect("bt promise is missing").root();
@ -174,7 +174,7 @@ impl Bluetooth {
}
}
pub fn response_async<T: AsyncBluetoothListener + Reflectable + 'static>(
pub fn response_async<T: AsyncBluetoothListener + DomObject + 'static>(
promise: &Rc<Promise>,
receiver: &T) -> IpcSender<BluetoothResponseResult> {
let (action_sender, action_receiver) = ipc::channel().unwrap();

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

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMet
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::js::{JS, Root, MutHeap, MutNullableHeap};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::bluetooth::Bluetooth;
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;

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

@ -17,7 +17,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::{ByteString, DOMString};
use dom::bluetooth::{AsyncBluetoothListener, response_async};
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;

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

@ -14,7 +14,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::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::{ByteString, DOMString};
use dom::bluetooth::{AsyncBluetoothListener, response_async};
use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};

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

@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
use dom::bindings::error::Error::{self, Network, Security};
use dom::bindings::error::ErrorResult;
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bluetooth::{AsyncBluetoothListener, response_async};
use dom::bluetoothdevice::BluetoothDevice;
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};

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

@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::Bluetoo
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::error::Error::{self, Network, Security};
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::bluetooth::{AsyncBluetoothListener, response_async};
use dom::bluetoothdevice::BluetoothDevice;

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

@ -6,7 +6,7 @@ use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
use dom::bindings::reflector::{Reflectable, MutReflectable, Reflector};
use dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
use dom::bindings::trace::JSTraceable;
use dom::bindings::utils::WindowProxyHandler;
use dom::bindings::utils::get_array_index_from_id;

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

@ -23,7 +23,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, LayoutJS, Root};
use dom::bindings::num::Finite;
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
use dom::canvaspattern::CanvasPattern;

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

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMet
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::cssrule::CSSRule;
use dom::cssrulelist::{CSSRuleList, RulesSource};

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

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::csskeyframerule::CSSKeyframeRule;
use dom::cssrule::{CSSRule, SpecificCSSRule};

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

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::CSSMediaRuleBinding;
use dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::cssgroupingrule::CSSGroupingRule;
use dom::cssrule::SpecificCSSRule;

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

@ -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::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::csskeyframerule::CSSKeyframeRule;
use dom::cssrule::CSSRule;
use dom::cssstylesheet::CSSStyleSheet;

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

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::js::{JS, Root, MutNullableHeap};
use dom::bindings::reflector::{reflect_dom_object, Reflectable};
use dom::bindings::reflector::{reflect_dom_object, DomObject};
use dom::bindings::str::DOMString;
use dom::cssrulelist::{CSSRuleList, RulesSource};
use dom::element::Element;

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

@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::error::{ErrorInfo, ErrorResult};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootCollection};
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::bindings::structuredclone::StructuredCloneData;
use dom::globalscope::GlobalScope;

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

@ -28,7 +28,7 @@ use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
use dom::bindings::js::RootedReference;
use dom::bindings::num::Finite;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
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;

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

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
use dom::bindings::error;
use dom::bindings::error::Fallible;
use dom::bindings::js::Root;
use dom::bindings::reflector::{reflect_dom_object, Reflectable, Reflector};
use dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use dom::dommatrix::DOMMatrix;
use dom::dompoint::DOMPoint;
use dom::globalscope::GlobalScope;

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

@ -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::js::{Root, JS};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::dompoint::DOMPoint;
use dom::domrect::DOMRect;
use dom::globalscope::GlobalScope;

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

@ -7,7 +7,7 @@ use dom::bindings::callback::ExceptionHandling::Report;
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, Root, RootedReference};
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::document::Document;
use dom::event::{Event, EventPhase};
use dom::eventtarget::{CompiledEventListener, EventTarget, ListenerPhase};

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

@ -9,7 +9,7 @@ use dom::bindings::error::{Error, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::eventtarget::EventTarget;

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

@ -18,7 +18,7 @@ use dom::bindings::codegen::UnionTypes::EventOrString;
use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::str::DOMString;
use dom::element::Element;
use dom::errorevent::ErrorEvent;
@ -142,10 +142,10 @@ pub enum CompiledEventListener {
impl CompiledEventListener {
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#the-event-handler-processing-algorithm
pub fn call_or_handle_event<T: Reflectable>(&self,
object: &T,
event: &Event,
exception_handle: ExceptionHandling) {
pub fn call_or_handle_event<T: DomObject>(&self,
object: &T,
event: &Event,
exception_handle: ExceptionHandling) {
// Step 3
match *self {
CompiledEventListener::Listener(ref listener) => {

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

@ -11,7 +11,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::blob::Blob;
use dom::domexception::{DOMErrorName, DOMException};

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

@ -9,7 +9,7 @@ use dom::bindings::codegen::UnionTypes::FileOrUSVString;
use dom::bindings::error::Fallible;
use dom::bindings::iterable::Iterable;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::{DOMString, USVString};
use dom::blob::{Blob, BlobImpl};
use dom::file::File;

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

@ -9,7 +9,7 @@ use dom::bindings::conversions::root_from_object;
use dom::bindings::error::{ErrorInfo, report_pending_exception};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::crypto::Crypto;
use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
@ -124,7 +124,7 @@ impl GlobalScope {
/// Returns the global scope of the realm that the given DOM object's reflector
/// was created in.
#[allow(unsafe_code)]
pub fn from_reflector<T: Reflectable>(reflector: &T) -> Root<Self> {
pub fn from_reflector<T: DomObject>(reflector: &T) -> Root<Self> {
unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) }
}

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

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding;
use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods;
use dom::bindings::codegen::UnionTypes::RadioNodeListOrElement;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::element::Element;
use dom::htmlcollection::{CollectionFilter, HTMLCollection};

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

@ -15,7 +15,7 @@ use dom::bindings::conversions::DerivedFrom;
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::blob::Blob;
use dom::document::Document;
@ -845,7 +845,7 @@ impl<'a> FormSubmitter<'a> {
}
}
pub trait FormControl: DerivedFrom<Element> + Reflectable {
pub trait FormControl: DerivedFrom<Element> + DomObject {
// FIXME: This is wrong (https://github.com/servo/servo/issues/3553)
// but we need html5ever to do it correctly
fn form_owner(&self) -> Option<Root<HTMLFormElement>> {

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

@ -21,7 +21,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::browsingcontext::BrowsingContext;
use dom::customevent::CustomEvent;

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

@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMet
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::cssstylesheet::CSSStyleSheet;
use dom::document::Document;

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

@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, MutNullableHeap, JS};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{Element, AttributeMutation};

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

@ -14,7 +14,7 @@ use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, Root};
use dom::bindings::js::RootedReference;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, ElementCreator};

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

@ -126,7 +126,7 @@
//! not allowed. In particular, any mutable fields use `Cell` or `DOMRefCell`
//! to manage their mutability.
//!
//! `Reflector` and `Reflectable`
//! `Reflector` and `DomObject`
//! =============================
//!
//! Every DOM object has a `Reflector` as its first (transitive) member field.
@ -136,7 +136,7 @@
//! the DOM object in the reflector, and initializes the pointer to the reflector
//! in the `Reflector` field.
//!
//! The `Reflectable` trait provides a `reflector()` method that returns the
//! The `DomObject` trait provides a `reflector()` method that returns the
//! DOM object's `Reflector`. It is implemented automatically for DOM structs
//! through the `#[dom_struct]` attribute.
//!

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

@ -5,7 +5,7 @@
use dom::bindings::codegen::Bindings::NavigatorBinding;
use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflector, Reflectable, reflect_dom_object};
use dom::bindings::reflector::{Reflector, DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::bluetooth::Bluetooth;
use dom::mimetypearray::MimeTypeArray;

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

@ -24,7 +24,7 @@ use dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId};
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
use dom::bindings::js::Root;
use dom::bindings::js::RootedReference;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::xmlname::namespace_from_domstring;
use dom::characterdata::{CharacterData, LayoutCharacterDataHelpers};
@ -800,7 +800,7 @@ impl Node {
pub fn insert_cell_or_row<F, G, I>(&self, index: i32, get_items: F, new_child: G) -> Fallible<Root<HTMLElement>>
where F: Fn() -> Root<HTMLCollection>,
G: Fn() -> Root<I>,
I: DerivedFrom<Node> + DerivedFrom<HTMLElement> + Reflectable,
I: DerivedFrom<Node> + DerivedFrom<HTMLElement> + DomObject,
{
if index < -1 {
return Err(Error::IndexSize);
@ -1345,7 +1345,7 @@ impl Node {
document: &Document,
wrap_fn: unsafe extern "Rust" fn(*mut JSContext, &GlobalScope, Box<N>) -> Root<N>)
-> Root<N>
where N: DerivedFrom<Node> + Reflectable
where N: DerivedFrom<Node> + DomObject
{
let window = document.window();
reflect_dom_object(node, window, wrap_fn)
@ -2373,11 +2373,11 @@ impl NodeMethods for Node {
}
}
pub fn document_from_node<T: DerivedFrom<Node> + Reflectable>(derived: &T) -> Root<Document> {
pub fn document_from_node<T: DerivedFrom<Node> + DomObject>(derived: &T) -> Root<Document> {
derived.upcast().owner_doc()
}
pub fn window_from_node<T: DerivedFrom<Node> + Reflectable>(derived: &T) -> Root<Window> {
pub fn window_from_node<T: DerivedFrom<Node> + DomObject>(derived: &T) -> Root<Window> {
let document = document_from_node(derived);
Root::from_ref(document.window())
}

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

@ -16,7 +16,7 @@ use dom::bindings::codegen::Bindings::PromiseBinding::AnyCallback;
use dom::bindings::conversions::root_from_object;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::js::MutHeapJSVal;
use dom::bindings::reflector::{Reflectable, MutReflectable, Reflector};
use dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
use dom::globalscope::GlobalScope;
use dom::promisenativehandler::PromiseNativeHandler;
use js::conversions::ToJSValConvertible;

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

@ -18,7 +18,7 @@ use dom::bindings::codegen::Bindings::RequestBinding::RequestRedirect;
use dom::bindings::codegen::Bindings::RequestBinding::RequestType;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::{ByteString, DOMString, USVString};
use dom::globalscope::GlobalScope;
use dom::headers::{Guard, Headers};

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

@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::ResponseBinding::{ResponseMethods, Respons
use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::BodyInit;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::{ByteString, USVString};
use dom::globalscope::GlobalScope;
use dom::headers::{Headers, Guard};

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

@ -10,7 +10,7 @@ use dom::bindings::error::{ErrorResult, Error};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::USVString;
use dom::bindings::structuredclone::StructuredCloneData;
use dom::eventtarget::EventTarget;

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

@ -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::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::USVString;
use dom::client::Client;
use dom::eventtarget::EventTarget;

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

@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding::ServiceWorkerGlobalScopeMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootCollection};
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::eventtarget::EventTarget;

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

@ -8,7 +8,7 @@ use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;

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

@ -25,7 +25,7 @@ use dom::bindings::js::Root;
use dom::bindings::mozmap::MozMap;
use dom::bindings::num::Finite;
use dom::bindings::refcounted::TrustedPromise;
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::{ByteString, DOMString, USVString};
use dom::bindings::weakref::MutableWeakRef;
use dom::blob::{Blob, BlobImpl};

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

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::TestRunnerBinding;
use dom::bindings::codegen::Bindings::TestRunnerBinding::TestRunnerMethods;
use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::globalscope::GlobalScope;
use ipc_channel::ipc::{self, IpcSender};

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

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods};
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::{DOMString, USVString};
use dom::blob::Blob;
use dom::globalscope::GlobalScope;

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

@ -7,7 +7,7 @@ use canvas_traits::CanvasMsg;
use dom::bindings::codegen::Bindings::WebGLProgramBinding;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::webglactiveinfo::WebGLActiveInfo;
use dom::webglobject::WebGLObject;

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

@ -14,7 +14,7 @@ use dom::bindings::conversions::{array_buffer_view_to_vec, array_buffer_view_to_
use dom::bindings::error::{Error, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;

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

@ -13,7 +13,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::{DOMString, USVString, is_token};
use dom::blob::{Blob, BlobImpl};
use dom::closeevent::CloseEvent;

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

@ -22,7 +22,7 @@ use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::num::Finite;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::bindings::structuredclone::StructuredCloneData;
use dom::bindings::utils::{GlobalStaticData, WindowProxyHandler};

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

@ -12,7 +12,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible, ErrorInfo};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::bindings::structuredclone::StructuredCloneData;
use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;

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

@ -12,7 +12,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exceptio
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::crypto::Crypto;
use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;

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

@ -17,7 +17,7 @@ use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutHeapJSVal, MutNullableHeap};
use dom::bindings::js::{Root, RootedReference};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::str::{ByteString, DOMString, USVString, is_token};
use dom::blob::{Blob, BlobImpl};
use dom::document::{Document, IsHTMLDocument};

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

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::ResponseBinding::ResponseType as DOMRespon
use dom::bindings::error::Error;
use dom::bindings::js::Root;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::globalscope::GlobalScope;
use dom::headers::Guard;
use dom::promise::Promise;

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

@ -5,7 +5,7 @@
//! Routines for handling measuring the memory usage of arbitrary DOM nodes.
use dom::bindings::conversions::get_dom_class;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use heapsize::{HeapSizeOf, heap_size_of};
use std::os::raw::c_void;
@ -13,7 +13,7 @@ use std::os::raw::c_void;
// associated box in order to stash their pointers in a reserved slot of their
// JS reflector.
#[allow(unsafe_code)]
pub fn heap_size_of_self_and_children<T: Reflectable + HeapSizeOf>(obj: &T) -> usize {
pub fn heap_size_of_self_and_children<T: DomObject + HeapSizeOf>(obj: &T) -> usize {
unsafe {
let class = get_dom_class(obj.reflector().get_jsobject().get()).unwrap();
(class.heap_size_of)(obj as *const T as *const c_void)

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

@ -36,7 +36,7 @@ use dom::bindings::js::{JS, MutNullableHeap, Root, RootCollection};
use dom::bindings::js::{RootCollectionPtr, RootedReference};
use dom::bindings::num::Finite;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::bindings::trace::JSTraceable;
use dom::bindings::utils::WRAP_CALLBACKS;

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

@ -11,7 +11,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::error::Error;
use dom::bindings::js::JS;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::client::Client;
use dom::globalscope::GlobalScope;
use dom::promise::Promise;

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

@ -5,7 +5,7 @@
use dom::bindings::callback::ExceptionHandling::Report;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
use dom::bindings::reflector::Reflectable;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
use dom::eventsource::EventSourceTimeoutCallback;
use dom::globalscope::GlobalScope;
@ -64,7 +64,7 @@ struct OneshotTimer {
// This enum is required to work around the fact that trait objects do not support generic methods.
// A replacement trait would have a method such as
// `invoke<T: Reflectable>(self: Box<Self>, this: &T, js_timers: &JsTimers);`.
// `invoke<T: DomObject>(self: Box<Self>, this: &T, js_timers: &JsTimers);`.
#[derive(JSTraceable, HeapSizeOf)]
pub enum OneshotTimerCallback {
XhrTimeout(XHRTimeoutCallback),
@ -74,7 +74,7 @@ pub enum OneshotTimerCallback {
}
impl OneshotTimerCallback {
fn invoke<T: Reflectable>(self, this: &T, js_timers: &JsTimers) {
fn invoke<T: DomObject>(self, this: &T, js_timers: &JsTimers) {
match self {
OneshotTimerCallback::XhrTimeout(callback) => callback.invoke(),
OneshotTimerCallback::EventSourceTimeout(callback) => callback.invoke(),
@ -482,7 +482,7 @@ fn clamp_duration(nesting_level: u32, unclamped: MsDuration) -> MsDuration {
impl JsTimerTask {
// see https://html.spec.whatwg.org/multipage/#timer-initialisation-steps
#[allow(unsafe_code)]
pub fn invoke<T: Reflectable>(self, this: &T, timers: &JsTimers) {
pub fn invoke<T: DomObject>(self, this: &T, timers: &JsTimers) {
// step 4.1 can be ignored, because we proactively prevent execution
// of this task when its scheduled execution is canceled.