Use 'TConstants' instead of magic numbers.

This commit is contained in:
Tetsuharu OHZEKI 2014-03-16 14:38:20 +09:00
parent d200a2e444
commit 7216eee31c
2 changed files with 26 additions and 24 deletions

View file

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::DOMExceptionBinding; use dom::bindings::codegen::DOMExceptionBinding;
use dom::bindings::codegen::DOMExceptionBinding::DOMExceptionConstants;
use dom::bindings::js::JS; use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::window::Window; use dom::window::Window;
@ -11,26 +12,26 @@ use servo_util::str::DOMString;
#[repr(uint)] #[repr(uint)]
#[deriving(ToStr, Encodable)] #[deriving(ToStr, Encodable)]
enum DOMErrorName { enum DOMErrorName {
IndexSizeError = 1, IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR,
HierarchyRequestError = 3, HierarchyRequestError = DOMExceptionConstants::HIERARCHY_REQUEST_ERR,
WrongDocumentError = 4, WrongDocumentError = DOMExceptionConstants::WRONG_DOCUMENT_ERR,
InvalidCharacterError = 5, InvalidCharacterError = DOMExceptionConstants::INVALID_CHARACTER_ERR,
NoModificationAllowedError = 7, NoModificationAllowedError = DOMExceptionConstants::NO_MODIFICATION_ALLOWED_ERR,
NotFoundError = 8, NotFoundError = DOMExceptionConstants::NOT_FOUND_ERR,
NotSupportedError = 9, NotSupportedError = DOMExceptionConstants::NOT_SUPPORTED_ERR,
InvalidStateError = 11, InvalidStateError = DOMExceptionConstants::INVALID_STATE_ERR,
SyntaxError = 12, SyntaxError = DOMExceptionConstants::SYNTAX_ERR,
InvalidModificationError = 13, InvalidModificationError = DOMExceptionConstants::INVALID_MODIFICATION_ERR,
NamespaceError = 14, NamespaceError = DOMExceptionConstants::NAMESPACE_ERR,
InvalidAccessError = 15, InvalidAccessError = DOMExceptionConstants::INVALID_ACCESS_ERR,
SecurityError = 18, SecurityError = DOMExceptionConstants::SECURITY_ERR,
NetworkError = 19, NetworkError = DOMExceptionConstants::NETWORK_ERR,
AbortError = 20, AbortError = DOMExceptionConstants::ABORT_ERR,
URLMismatchError = 21, URLMismatchError = DOMExceptionConstants::URL_MISMATCH_ERR,
QuotaExceededError = 22, QuotaExceededError = DOMExceptionConstants::QUOTA_EXCEEDED_ERR,
TimeoutError = 23, TimeoutError = DOMExceptionConstants::TIMEOUT_ERR,
InvalidNodeTypeError = 24, InvalidNodeTypeError = DOMExceptionConstants::INVALID_NODE_TYPE_ERR,
DataCloneError = 25, DataCloneError = DOMExceptionConstants::DATA_CLONE_ERR,
EncodingError EncodingError
} }

View file

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::EventBinding; use dom::bindings::codegen::EventBinding;
use dom::bindings::codegen::EventBinding::EventConstants;
use dom::bindings::js::JS; use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::{Fallible, ErrorResult}; use dom::bindings::error::{Fallible, ErrorResult};
@ -23,10 +24,10 @@ pub enum Event_ {
#[deriving(Encodable)] #[deriving(Encodable)]
pub enum EventPhase { pub enum EventPhase {
Phase_None = 0, Phase_None = EventConstants::NONE,
Phase_Capturing, Phase_Capturing = EventConstants::CAPTURING_PHASE,
Phase_At_Target, Phase_At_Target = EventConstants::AT_TARGET,
Phase_Bubbling Phase_Bubbling = EventConstants::BUBBLING_PHASE,
} }
#[deriving(Eq, Encodable)] #[deriving(Eq, Encodable)]