OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "core/dom/DOMCoreException.h" | 30 #include "core/dom/DOMCoreException.h" |
31 | 31 |
32 #include "DOMException.h" | 32 #include "DOMException.h" |
| 33 #include "ExceptionCode.h" |
33 | 34 |
34 namespace WebCore { | 35 namespace WebCore { |
35 | 36 |
36 static struct CoreException { | 37 static struct CoreException { |
37 const char* const name; | 38 const char* const name; |
38 const char* const description; | 39 const char* const description; |
| 40 const int code; |
39 } coreExceptions[] = { | 41 } coreExceptions[] = { |
40 { "IndexSizeError", "Index or size was negative, or greater than the allowed
value." }, | 42 { "IndexSizeError", "Index or size was negative, or greater than the allowed
value.", IndexSizeErrorLegacyCode }, |
41 { 0, 0 }, // DOMStringSizeError | 43 { "HierarchyRequestError", "A Node was inserted somewhere it doesn't belong.
", HierarchyRequestErrorLegacyCode }, |
42 { "HierarchyRequestError", "A Node was inserted somewhere it doesn't belong.
" }, | 44 { "WrongDocumentError", "A Node was used in a different document than the on
e that created it (that doesn't support it).", WrongDocumentErrorLegacyCode }, |
43 { "WrongDocumentError", "A Node was used in a different document than the on
e that created it (that doesn't support it)." }, | 45 { "InvalidCharacterError", "An invalid or illegal character was specified, s
uch as in an XML name.", InvalidCharacterErrorLegacyCode }, |
44 { "InvalidCharacterError", "An invalid or illegal character was specified, s
uch as in an XML name." }, | 46 { "NoModificationAllowedError", "An attempt was made to modify an object whe
re modifications are not allowed.", NoModificationAllowedErrorLegacyCode }, |
45 { 0, 0 }, // NoDataAllowedError | 47 { "NotFoundError", "An attempt was made to reference a Node in a context whe
re it does not exist.", NotFoundErrorLegacyCode }, |
46 { "NoModificationAllowedError", "An attempt was made to modify an object whe
re modifications are not allowed." }, | 48 { "NotSupportedError", "The implementation did not support the requested typ
e of object or operation.", NotSupportedErrorLegacyCode }, |
47 { "NotFoundError", "An attempt was made to reference a Node in a context whe
re it does not exist." }, | 49 { "InUseAttributeError", "An attempt was made to add an attribute that is al
ready in use elsewhere.", InuseAttributeErrorLegacyCode }, |
48 { "NotSupportedError", "The implementation did not support the requested typ
e of object or operation." }, | 50 { "InvalidStateError", "An attempt was made to use an object that is not, or
is no longer, usable.", InvalidStateErrorLegacyCode }, |
49 { "InUseAttributeError", "An attempt was made to add an attribute that is al
ready in use elsewhere." }, | 51 { "SyntaxError", "An invalid or illegal string was specified.", SyntaxErrorL
egacyCode }, |
50 { "InvalidStateError", "An attempt was made to use an object that is not, or
is no longer, usable." }, | 52 { "InvalidModificationError", "An attempt was made to modify the type of the
underlying object.", InvalidModificationErrorLegacyCode }, |
51 { "SyntaxError", "An invalid or illegal string was specified." }, | 53 { "NamespaceError", "An attempt was made to create or change an object in a
way which is incorrect with regard to namespaces.", NamespaceErrorLegacyCode }, |
52 { "InvalidModificationError", "An attempt was made to modify the type of the
underlying object." }, | 54 { "InvalidAccessError", "A parameter or an operation was not supported by th
e underlying object.", InvalidAccessErrorLegacyCode }, |
53 { "NamespaceError", "An attempt was made to create or change an object in a
way which is incorrect with regard to namespaces." }, | 55 { "TypeMismatchError", "The type of an object was incompatible with the expe
cted type of the parameter associated to the object.", TypeMismatchErrorLegacyCo
de }, |
54 { "InvalidAccessError", "A parameter or an operation was not supported by th
e underlying object." }, | 56 { "SecurityError", "An attempt was made to break through the security policy
of the user agent.", SecurityErrorLegacyCode }, |
55 { 0, 0 }, // ValidationError | 57 // FIXME: Couldn't find a description in the HTML/DOM specifications for NET
WORKERR, ABORTERR, URLMISMATCHERR, and QUOTAEXCEEDEDERR |
56 { "TypeMismatchError", "The type of an object was incompatible with the expe
cted type of the parameter associated to the object." }, | 58 { "NetworkError", "A network error occurred.", NetworkErrorLegacyCode }, |
57 { "SecurityError", "An attempt was made to break through the security policy
of the user agent." }, | 59 { "AbortError", "The user aborted a request.", AbortErrorLegacyCode }, |
58 // FIXME: Couldn't find a description in the HTML/DOM specifications for NET
WORK_ERR, ABORT_ERR, URL_MISMATCH_ERR, and QUOTA_EXCEEDED_ERR | 60 { "URLMismatchError", "A worker global scope represented an absolute URL tha
t is not equal to the resulting absolute URL.", UrlMismatchErrorLegacyCode }, |
59 { "NetworkError", "A network error occurred." }, | 61 { "QuotaExceededError", "An attempt was made to add something to storage tha
t exceeded the quota.", QuotaExceededErrorLegacyCode }, |
60 { "AbortError", "The user aborted a request." }, | 62 { "TimeoutError", "A timeout occurred.", TimeoutErrorLegacyCode }, |
61 { "URLMismatchError", "A worker global scope represented an absolute URL tha
t is not equal to the resulting absolute URL." }, | 63 { "InvalidNodeTypeError", "The supplied node is invalid or has an invalid an
cestor for this operation.", InvalidNodeTypeErrorLegacyCode }, |
62 { "QuotaExceededError", "An attempt was made to add something to storage tha
t exceeded the quota." }, | 64 { "DataCloneError", "An object could not be cloned.", DataCloneErrorLegacyCo
de } |
63 { "TimeoutError", "A timeout occurred." }, | |
64 { "InvalidNodeTypeError", "The supplied node is invalid or has an invalid an
cestor for this operation." }, | |
65 { "DataCloneError", "An object could not be cloned." } | |
66 }; | 65 }; |
67 | 66 |
| 67 static const CoreException* getErrorEntry(ExceptionCode ec) |
| 68 { |
| 69 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions); |
| 70 size_t tableIndex = ec - INDEX_SIZE_ERR; |
| 71 |
| 72 return tableIndex < tableSize ? &coreExceptions[tableIndex] : 0; |
| 73 } |
| 74 |
68 bool DOMCoreException::initializeDescription(ExceptionCode ec, ExceptionCodeDesc
ription* description) | 75 bool DOMCoreException::initializeDescription(ExceptionCode ec, ExceptionCodeDesc
ription* description) |
69 { | 76 { |
70 description->code = ec; | 77 const CoreException* entry = getErrorEntry(ec); |
| 78 if (!entry) |
| 79 return false; |
| 80 |
71 description->type = DOMCoreExceptionType; | 81 description->type = DOMCoreExceptionType; |
72 | 82 description->name = entry->name; |
73 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions); | 83 description->description = entry->description; |
74 size_t tableIndex = ec - INDEX_SIZE_ERR; | 84 description->code = entry->code; |
75 | |
76 description->name = tableIndex < tableSize ? coreExceptions[tableIndex].name
: 0; | |
77 description->description = tableIndex < tableSize ? coreExceptions[tableInde
x].description : 0; | |
78 | 85 |
79 return true; | 86 return true; |
80 } | 87 } |
81 | 88 |
| 89 int DOMCoreException::getLegacyErrorCode(ExceptionCode ec) |
| 90 { |
| 91 const CoreException* entry = getErrorEntry(ec); |
| 92 ASSERT(entry); |
| 93 |
| 94 return (entry && entry->code) ? entry->code : 0; |
| 95 } |
| 96 |
82 } // namespace WebCore | 97 } // namespace WebCore |
OLD | NEW |