auto merge of #4654 : Ms2ger/servo/bindings-docs, r=jdm

This commit is contained in:
bors-servo 2015-01-18 20:48:48 -07:00
commit 58c1b121a7
2 changed files with 30 additions and 2 deletions

View file

@ -4,6 +4,8 @@
//! Utilities to throw exceptions from Rust bindings. //! Utilities to throw exceptions from Rust bindings.
#![deny(missing_docs)]
use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::domexception::DOMException; use dom::domexception::DOMException;
@ -21,22 +23,38 @@ use std::ptr;
/// DOM exceptions that can be thrown by a native DOM method. /// DOM exceptions that can be thrown by a native DOM method.
#[deriving(Show, Clone)] #[deriving(Show, Clone)]
pub enum Error { pub enum Error {
/// IndexSizeError
IndexSize, IndexSize,
FailureUnknown, /// NotFoundError
NotFound, NotFound,
/// HierarchyRequestError
HierarchyRequest, HierarchyRequest,
/// InvalidCharacterError
InvalidCharacter, InvalidCharacter,
/// NotSupportedError
NotSupported, NotSupported,
/// InvalidStateError
InvalidState, InvalidState,
/// SyntaxError
Syntax, Syntax,
/// NamespaceError
NamespaceError, NamespaceError,
/// InvalidAccessError
InvalidAccess, InvalidAccess,
/// SecurityError
Security, Security,
/// NetworkError
Network, Network,
/// AbortError
Abort, Abort,
/// TimeoutError
Timeout, Timeout,
/// DataCloneError
DataClone, DataClone,
NoModificationAllowedError /// NoModificationAllowedError
NoModificationAllowedError,
/// Unknown failure
FailureUnknown,
} }
/// The return type for IDL operations that can throw DOM exceptions. /// The return type for IDL operations that can throw DOM exceptions.

View file

@ -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(),