Title: [113413] trunk/Source/WebCore
Revision
113413
Author
[email protected]
Date
2012-04-05 21:57:45 -0700 (Thu, 05 Apr 2012)

Log Message

combine two arrays (coreExceptionNames and coreExceptionDescriptions) into one array
https://bugs.webkit.org/show_bug.cgi?id=83141

Patch by Lu Guanqun <[email protected]> on 2012-04-05
Reviewed by Adam Barth.

No new tests required.

* dom/DOMCoreException.cpp:
(CoreException):
(WebCore):
(WebCore::DOMCoreException::initializeDescription):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (113412 => 113413)


--- trunk/Source/WebCore/ChangeLog	2012-04-06 04:49:34 UTC (rev 113412)
+++ trunk/Source/WebCore/ChangeLog	2012-04-06 04:57:45 UTC (rev 113413)
@@ -1,3 +1,17 @@
+2012-04-05  Lu Guanqun  <[email protected]>
+
+        combine two arrays (coreExceptionNames and coreExceptionDescriptions) into one array
+        https://bugs.webkit.org/show_bug.cgi?id=83141
+
+        Reviewed by Adam Barth.
+
+        No new tests required.
+
+        * dom/DOMCoreException.cpp:
+        (CoreException):
+        (WebCore):
+        (WebCore::DOMCoreException::initializeDescription):
+
 2012-04-05  David Barton  <[email protected]>
 
         Remove intrinsic padding from contentBoxRect(), etc.

Modified: trunk/Source/WebCore/dom/DOMCoreException.cpp (113412 => 113413)


--- trunk/Source/WebCore/dom/DOMCoreException.cpp	2012-04-06 04:49:34 UTC (rev 113412)
+++ trunk/Source/WebCore/dom/DOMCoreException.cpp	2012-04-06 04:57:45 UTC (rev 113413)
@@ -31,77 +31,49 @@
 
 namespace WebCore {
 
-// FIXME: This should be an array of structs to pair the names and descriptions.
-static const char* const coreExceptionNames[] = {
-    "INDEX_SIZE_ERR",
-    "DOMSTRING_SIZE_ERR",
-    "HIERARCHY_REQUEST_ERR",
-    "WRONG_DOCUMENT_ERR",
-    "INVALID_CHARACTER_ERR",
-    "NO_DATA_ALLOWED_ERR",
-    "NO_MODIFICATION_ALLOWED_ERR",
-    "NOT_FOUND_ERR",
-    "NOT_SUPPORTED_ERR",
-    "INUSE_ATTRIBUTE_ERR",
-    "INVALID_STATE_ERR",
-    "SYNTAX_ERR",
-    "INVALID_MODIFICATION_ERR",
-    "NAMESPACE_ERR",
-    "INVALID_ACCESS_ERR",
-    "VALIDATION_ERR",
-    "TYPE_MISMATCH_ERR",
-    "SECURITY_ERR",
-    "NETWORK_ERR",
-    "ABORT_ERR",
-    "URL_MISMATCH_ERR",
-    "QUOTA_EXCEEDED_ERR",
-    "TIMEOUT_ERR",
-    "INVALID_NODE_TYPE_ERR",
-    "DATA_CLONE_ERR"
-};
-
-static const char* const coreExceptionDescriptions[] = {
-    "Index or size was negative, or greater than the allowed value.",
-    "The specified range of text did not fit into a DOMString.",
-    "A Node was inserted somewhere it doesn't belong.",
-    "A Node was used in a different document than the one that created it (that doesn't support it).",
-    "An invalid or illegal character was specified, such as in an XML name.",
-    "Data was specified for a Node which does not support data.",
-    "An attempt was made to modify an object where modifications are not allowed.",
-    "An attempt was made to reference a Node in a context where it does not exist.",
-    "The implementation did not support the requested type of object or operation.",
-    "An attempt was made to add an attribute that is already in use elsewhere.",
-    "An attempt was made to use an object that is not, or is no longer, usable.",
-    "An invalid or illegal string was specified.",
-    "An attempt was made to modify the type of the underlying object.",
-    "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces.",
-    "A parameter or an operation was not supported by the underlying object.",
-    "A call to a method such as insertBefore or removeChild would make the Node invalid with respect to \"partial validity\", this exception would be raised and the operation would not be done.",
-    "The type of an object was incompatible with the expected type of the parameter associated to the object.",
-    "An attempt was made to break through the security policy of the user agent.",
+static struct CoreException {
+    const char* const name;
+    const char* const description;
+} coreExceptions[] = {
+    { "INDEX_SIZE_ERR", "Index or size was negative, or greater than the allowed value." },
+    { "DOMSTRING_SIZE_ERR", "The specified range of text did not fit into a DOMString." },
+    { "HIERARCHY_REQUEST_ERR", "A Node was inserted somewhere it doesn't belong." },
+    { "WRONG_DOCUMENT_ERR", "A Node was used in a different document than the one that created it (that doesn't support it)." },
+    { "INVALID_CHARACTER_ERR", "An invalid or illegal character was specified, such as in an XML name." },
+    { "NO_DATA_ALLOWED_ERR", "Data was specified for a Node which does not support data." },
+    { "NO_MODIFICATION_ALLOWED_ERR", "An attempt was made to modify an object where modifications are not allowed." },
+    { "NOT_FOUND_ERR", "An attempt was made to reference a Node in a context where it does not exist." },
+    { "NOT_SUPPORTED_ERR", "The implementation did not support the requested type of object or operation." },
+    { "INUSE_ATTRIBUTE_ERR", "An attempt was made to add an attribute that is already in use elsewhere." },
+    { "INVALID_STATE_ERR", "An attempt was made to use an object that is not, or is no longer, usable." },
+    { "SYNTAX_ERR", "An invalid or illegal string was specified." },
+    { "INVALID_MODIFICATION_ERR", "An attempt was made to modify the type of the underlying object." },
+    { "NAMESPACE_ERR", "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces." },
+    { "INVALID_ACCESS_ERR", "A parameter or an operation was not supported by the underlying object." },
+    { "VALIDATION_ERR", "A call to a method such as insertBefore or removeChild would make the Node invalid with respect to \"partial validity\", this exception would be raised and the operation would not be done." },
+    { "TYPE_MISMATCH_ERR", "The type of an object was incompatible with the expected type of the parameter associated to the object." },
+    { "SECURITY_ERR", "An attempt was made to break through the security policy of the user agent." },
     // FIXME: Couldn't find a description in the HTML/DOM specifications for NETWORK_ERR, ABORT_ERR, URL_MISMATCH_ERR, and QUOTA_EXCEEDED_ERR
-    "A network error occurred.",
-    "The user aborted a request.",
-    "A worker global scope represented an absolute URL that is not equal to the resulting absolute URL.",
-    "An attempt was made to add something to storage that exceeded the quota.",
-    "A timeout occurred.",
-    "The supplied node is invalid or has an invalid ancestor for this operation.",
-    "An object could not be cloned."
+    { "NETWORK_ERR", "A network error occurred." },
+    { "ABORT_ERR", "The user aborted a request." },
+    { "URL_MISMATCH_ERR", "A worker global scope represented an absolute URL that is not equal to the resulting absolute URL." },
+    { "QUOTA_EXCEEDED_ERR", "An attempt was made to add something to storage that exceeded the quota." },
+    { "TIMEOUT_ERR", "A timeout occurred." },
+    { "INVALID_NODE_TYPE_ERR", "The supplied node is invalid or has an invalid ancestor for this operation." },
+    { "DATA_CLONE_ERR", "An object could not be cloned." }
 };
 
-COMPILE_ASSERT(WTF_ARRAY_LENGTH(coreExceptionNames) == WTF_ARRAY_LENGTH(coreExceptionDescriptions), DOMCoreExceptionTablesMustMatch);
-
 bool DOMCoreException::initializeDescription(ExceptionCode ec, ExceptionCodeDescription* description)
 {
     description->typeName = "DOM";
     description->code = ec;
     description->type = DOMCoreExceptionType;
 
-    size_t tableSize = WTF_ARRAY_LENGTH(coreExceptionNames);
+    size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions);
     size_t tableIndex = ec - INDEX_SIZE_ERR;
 
-    description->name = tableIndex < tableSize ? coreExceptionNames[tableIndex] : 0;
-    description->description = tableIndex < tableSize ? coreExceptionDescriptions[tableIndex] : 0;
+    description->name = tableIndex < tableSize ? coreExceptions[tableIndex].name : 0;
+    description->description = tableIndex < tableSize ? coreExceptions[tableIndex].description : 0;
 
     return true;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to