mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Rename Root<T> to DomRoot<T>
In a later PR, DomRoot<T> will become a type alias of Root<Dom<T>>, where Root<T> will be able to handle all the things that need to be rooted that have a stable traceable address that doesn't move for the whole lifetime of the root. Stay tuned.
This commit is contained in:
parent
577370746e
commit
f87c2a8d76
291 changed files with 1774 additions and 1770 deletions
|
@ -10,7 +10,7 @@ use dom::bindings::conversions::root_from_object;
|
|||
use dom::bindings::error::{ErrorInfo, report_pending_exception};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::DomObject;
|
||||
use dom::bindings::root::{MutNullableDom, Root};
|
||||
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use dom::bindings::settings_stack::{AutoEntryScript, entry_global, incumbent_global};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::crypto::Crypto;
|
||||
|
@ -148,13 +148,13 @@ 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: DomObject>(reflector: &T) -> Root<Self> {
|
||||
pub fn from_reflector<T: DomObject>(reflector: &T) -> DomRoot<Self> {
|
||||
unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) }
|
||||
}
|
||||
|
||||
/// Returns the global scope of the realm that the given JS object was created in.
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn from_object(obj: *mut JSObject) -> Root<Self> {
|
||||
pub unsafe fn from_object(obj: *mut JSObject) -> DomRoot<Self> {
|
||||
assert!(!obj.is_null());
|
||||
let global = GetGlobalForObjectCrossCompartment(obj);
|
||||
global_scope_from_global(global)
|
||||
|
@ -162,7 +162,7 @@ impl GlobalScope {
|
|||
|
||||
/// Returns the global scope for the given JSContext
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn from_context(cx: *mut JSContext) -> Root<Self> {
|
||||
pub unsafe fn from_context(cx: *mut JSContext) -> DomRoot<Self> {
|
||||
let global = CurrentGlobalOrNull(cx);
|
||||
global_scope_from_global(global)
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ impl GlobalScope {
|
|||
/// Returns the global object of the realm that the given JS object
|
||||
/// was created in, after unwrapping any wrappers.
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn from_object_maybe_wrapped(mut obj: *mut JSObject) -> Root<Self> {
|
||||
pub unsafe fn from_object_maybe_wrapped(mut obj: *mut JSObject) -> DomRoot<Self> {
|
||||
if IsWrapper(obj) {
|
||||
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
||||
assert!(!obj.is_null());
|
||||
|
@ -190,7 +190,7 @@ impl GlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn crypto(&self) -> Root<Crypto> {
|
||||
pub fn crypto(&self) -> DomRoot<Crypto> {
|
||||
self.crypto.or_init(|| Crypto::new(self))
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ impl GlobalScope {
|
|||
|
||||
/// Perform a microtask checkpoint.
|
||||
pub fn perform_a_microtask_checkpoint(&self) {
|
||||
self.microtask_queue.checkpoint(|_| Some(Root::from_ref(self)));
|
||||
self.microtask_queue.checkpoint(|_| Some(DomRoot::from_ref(self)));
|
||||
}
|
||||
|
||||
/// Enqueue a microtask for subsequent execution.
|
||||
|
@ -550,7 +550,7 @@ impl GlobalScope {
|
|||
///
|
||||
/// ["current"]: https://html.spec.whatwg.org/multipage/#current
|
||||
#[allow(unsafe_code)]
|
||||
pub fn current() -> Option<Root<Self>> {
|
||||
pub fn current() -> Option<DomRoot<Self>> {
|
||||
unsafe {
|
||||
let cx = Runtime::get();
|
||||
assert!(!cx.is_null());
|
||||
|
@ -566,18 +566,18 @@ impl GlobalScope {
|
|||
/// Returns the ["entry"] global object.
|
||||
///
|
||||
/// ["entry"]: https://html.spec.whatwg.org/multipage/#entry
|
||||
pub fn entry() -> Root<Self> {
|
||||
pub fn entry() -> DomRoot<Self> {
|
||||
entry_global()
|
||||
}
|
||||
|
||||
/// Returns the ["incumbent"] global object.
|
||||
///
|
||||
/// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent
|
||||
pub fn incumbent() -> Option<Root<Self>> {
|
||||
pub fn incumbent() -> Option<DomRoot<Self>> {
|
||||
incumbent_global()
|
||||
}
|
||||
|
||||
pub fn performance(&self) -> Root<Performance> {
|
||||
pub fn performance(&self) -> DomRoot<Performance> {
|
||||
if let Some(window) = self.downcast::<Window>() {
|
||||
return window.Performance();
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ fn timestamp_in_ms(time: Timespec) -> u64 {
|
|||
|
||||
/// Returns the Rust global scope from a JS global object.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn global_scope_from_global(global: *mut JSObject) -> Root<GlobalScope> {
|
||||
unsafe fn global_scope_from_global(global: *mut JSObject) -> DomRoot<GlobalScope> {
|
||||
assert!(!global.is_null());
|
||||
let clasp = get_object_class(global);
|
||||
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue