mirror of
https://github.com/servo/servo.git
synced 2025-06-12 02:14:41 +00:00
Document global.rs.
This commit is contained in:
parent
ecf0317bc0
commit
31edd21d68
1 changed files with 10 additions and 0 deletions
|
@ -7,6 +7,8 @@
|
||||||
//! This module contains smart pointers to global scopes, to simplify writing
|
//! This module contains smart pointers to global scopes, to simplify writing
|
||||||
//! code that works in workers as well as window scopes.
|
//! code that works in workers as well as window scopes.
|
||||||
|
|
||||||
|
#[deny(missing_docs)]
|
||||||
|
|
||||||
use dom::bindings::conversions::FromJSValConvertible;
|
use dom::bindings::conversions::FromJSValConvertible;
|
||||||
use dom::bindings::js::{JS, JSRef, Root};
|
use dom::bindings::js::{JS, JSRef, Root};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
|
@ -28,13 +30,17 @@ use std::ptr;
|
||||||
/// A freely-copyable reference to a rooted global object.
|
/// A freely-copyable reference to a rooted global object.
|
||||||
#[deriving(Copy)]
|
#[deriving(Copy)]
|
||||||
pub enum GlobalRef<'a> {
|
pub enum GlobalRef<'a> {
|
||||||
|
/// A reference to a `Window` object.
|
||||||
Window(JSRef<'a, window::Window>),
|
Window(JSRef<'a, window::Window>),
|
||||||
|
/// A reference to a `WorkerGlobalScope` object.
|
||||||
Worker(JSRef<'a, WorkerGlobalScope>),
|
Worker(JSRef<'a, WorkerGlobalScope>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A stack-based rooted reference to a global object.
|
/// A stack-based rooted reference to a global object.
|
||||||
pub enum GlobalRoot {
|
pub enum GlobalRoot {
|
||||||
|
/// A root for a `Window` object.
|
||||||
Window(Root<window::Window>),
|
Window(Root<window::Window>),
|
||||||
|
/// A root for a `WorkerGlobalScope` object.
|
||||||
Worker(Root<WorkerGlobalScope>),
|
Worker(Root<WorkerGlobalScope>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +49,9 @@ pub enum GlobalRoot {
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
pub enum GlobalField {
|
pub enum GlobalField {
|
||||||
|
/// A field for a `Window` object.
|
||||||
Window(JS<window::Window>),
|
Window(JS<window::Window>),
|
||||||
|
/// A field for a `WorkerGlobalScope` object.
|
||||||
Worker(JS<WorkerGlobalScope>),
|
Worker(JS<WorkerGlobalScope>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +74,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the `ResourceTask` for this global scope.
|
||||||
pub fn resource_task(&self) -> ResourceTask {
|
pub fn resource_task(&self) -> ResourceTask {
|
||||||
match *self {
|
match *self {
|
||||||
GlobalRef::Window(ref window) => window.page().resource_task.clone(),
|
GlobalRef::Window(ref window) => window.page().resource_task.clone(),
|
||||||
|
@ -73,6 +82,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the URL for this global scope.
|
||||||
pub fn get_url(&self) -> Url {
|
pub fn get_url(&self) -> Url {
|
||||||
match *self {
|
match *self {
|
||||||
GlobalRef::Window(ref window) => window.get_url(),
|
GlobalRef::Window(ref window) => window.get_url(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue