mirror of
https://github.com/servo/servo.git
synced 2025-06-10 01:23:13 +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
|
||||
//! code that works in workers as well as window scopes.
|
||||
|
||||
#[deny(missing_docs)]
|
||||
|
||||
use dom::bindings::conversions::FromJSValConvertible;
|
||||
use dom::bindings::js::{JS, JSRef, Root};
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
|
@ -28,13 +30,17 @@ use std::ptr;
|
|||
/// A freely-copyable reference to a rooted global object.
|
||||
#[deriving(Copy)]
|
||||
pub enum GlobalRef<'a> {
|
||||
/// A reference to a `Window` object.
|
||||
Window(JSRef<'a, window::Window>),
|
||||
/// A reference to a `WorkerGlobalScope` object.
|
||||
Worker(JSRef<'a, WorkerGlobalScope>),
|
||||
}
|
||||
|
||||
/// A stack-based rooted reference to a global object.
|
||||
pub enum GlobalRoot {
|
||||
/// A root for a `Window` object.
|
||||
Window(Root<window::Window>),
|
||||
/// A root for a `WorkerGlobalScope` object.
|
||||
Worker(Root<WorkerGlobalScope>),
|
||||
}
|
||||
|
||||
|
@ -43,7 +49,9 @@ pub enum GlobalRoot {
|
|||
#[jstraceable]
|
||||
#[must_root]
|
||||
pub enum GlobalField {
|
||||
/// A field for a `Window` object.
|
||||
Window(JS<window::Window>),
|
||||
/// A field for a `WorkerGlobalScope` object.
|
||||
Worker(JS<WorkerGlobalScope>),
|
||||
}
|
||||
|
||||
|
@ -66,6 +74,7 @@ impl<'a> GlobalRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get the `ResourceTask` for this global scope.
|
||||
pub fn resource_task(&self) -> ResourceTask {
|
||||
match *self {
|
||||
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 {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.get_url(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue