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.
#![deny(missing_docs)]
use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::global::GlobalRef;
use dom::domexception::DOMException;
@ -21,22 +23,38 @@ use std::ptr;
/// DOM exceptions that can be thrown by a native DOM method.
#[deriving(Show, Clone)]
pub enum Error {
/// IndexSizeError
IndexSize,
FailureUnknown,
/// NotFoundError
NotFound,
/// HierarchyRequestError
HierarchyRequest,
/// InvalidCharacterError
InvalidCharacter,
/// NotSupportedError
NotSupported,
/// InvalidStateError
InvalidState,
/// SyntaxError
Syntax,
/// NamespaceError
NamespaceError,
/// InvalidAccessError
InvalidAccess,
/// SecurityError
Security,
/// NetworkError
Network,
/// AbortError
Abort,
/// TimeoutError
Timeout,
/// DataCloneError
DataClone,
NoModificationAllowedError
/// NoModificationAllowedError
NoModificationAllowedError,
/// Unknown failure
FailureUnknown,
}
/// 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
//! 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(),