diff options
author | Alan Jeffrey <ajeffrey@mozilla.com> | 2019-07-18 16:54:29 -0500 |
---|---|---|
committer | Alan Jeffrey <ajeffrey@mozilla.com> | 2019-07-18 17:16:10 -0500 |
commit | 23f15c94efe800db6bbee44a3a5d7464f5c19f31 (patch) | |
tree | 19812009b57f363ca4eb04a0eb6b1e85329f15cb | |
parent | c08ef4cb237342744c21ff392b4156d11db30db9 (diff) | |
download | servo-23f15c94efe800db6bbee44a3a5d7464f5c19f31.tar.gz servo-23f15c94efe800db6bbee44a3a5d7464f5c19f31.zip |
Decoupled DOMErrorName from legacy error codes
-rw-r--r-- | components/script/dom/domexception.rs | 12 | ||||
-rw-r--r-- | components/script/dom/webidls/DOMException.webidl | 4 |
2 files changed, 6 insertions, 10 deletions
diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index 0df528edb87..3cfe6092dd1 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -13,7 +13,7 @@ use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; #[repr(u16)] -#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)] +#[derive(Clone, Copy, Debug, Eq, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] pub enum DOMErrorName { IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR, HierarchyRequestError = DOMExceptionConstants::HIERARCHY_REQUEST_ERR, @@ -36,8 +36,8 @@ pub enum DOMErrorName { TimeoutError = DOMExceptionConstants::TIMEOUT_ERR, InvalidNodeTypeError = DOMExceptionConstants::INVALID_NODE_TYPE_ERR, DataCloneError = DOMExceptionConstants::DATA_CLONE_ERR, - NotReadableError = DOMExceptionConstants::NOT_READABLE_ERR, - OperationError = DOMExceptionConstants::OPERATION_ERR, + NotReadableError, + OperationError, } impl DOMErrorName { @@ -152,11 +152,11 @@ impl DOMException { } impl DOMExceptionMethods for DOMException { - // https://heycam.github.io/webidl/#dfn-DOMException + // https://heycam.github.io/webidl/#dom-domexception-code fn Code(&self) -> u16 { match DOMErrorName::from(&self.name) { - Some(code) => code as u16, - None => 0 as u16, + Some(code) if code <= DOMErrorName::DataCloneError => code as u16, + _ => 0, } } diff --git a/components/script/dom/webidls/DOMException.webidl b/components/script/dom/webidls/DOMException.webidl index 80bf319fdd5..1c7bca4ce66 100644 --- a/components/script/dom/webidls/DOMException.webidl +++ b/components/script/dom/webidls/DOMException.webidl @@ -38,10 +38,6 @@ interface DOMException { const unsigned short TIMEOUT_ERR = 23; const unsigned short INVALID_NODE_TYPE_ERR = 24; const unsigned short DATA_CLONE_ERR = 25; - // Only the first 25 errors are given codes in - // https://heycam.github.io/webidl/#idl-DOMException - const unsigned short NOT_READABLE_ERR = 26; - const unsigned short OPERATION_ERR = 27; // Error code as u16 readonly attribute unsigned short code; |