combine two arrays in RangeException.cpp into one
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 05:50:16 +0000 (05:50 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 05:50:16 +0000 (05:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83450

Patch by Lu Guanqun <guanqun.lu@intel.com> on 2012-04-09
Reviewed by Kentaro Hara.

No new tests required.

* dom/RangeException.cpp:
(RangeExceptionNameDescription):
(WebCore):
(WebCore::RangeException::initializeDescription):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113685 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/RangeException.cpp

index 3441689..6ba2919 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-09  Lu Guanqun  <guanqun.lu@intel.com>
+
+        combine two arrays in RangeException.cpp into one
+        https://bugs.webkit.org/show_bug.cgi?id=83450
+
+        Reviewed by Kentaro Hara.
+
+        No new tests required.
+
+        * dom/RangeException.cpp:
+        (RangeExceptionNameDescription):
+        (WebCore):
+        (WebCore::RangeException::initializeDescription):
+
 2012-04-09  No'am Rosenthal  <noam.rosenthal@nokia.com>
 
         [Texmap] Improve TextureMapperGL readability
index 226963f..2258c30 100644 (file)
 
 namespace WebCore {
 
-// FIXME: This should be an array of structs to pair the names and descriptions.
-static const char* const rangeExceptionNames[] = {
-    "BAD_BOUNDARYPOINTS_ERR",
-    "INVALID_NODE_TYPE_ERR"
+static struct RangeExceptionNameDescription {
+    const char* const name;
+    const char* const description;
+} exceptions[] = {
+    { "BAD_BOUNDARYPOINTS_ERR", "The boundary-points of a Range did not meet specific requirements." },
+    { "INVALID_NODE_TYPE_ERR", "The container of an boundary-point of a Range was being set to either a node of an invalid type or a node with an ancestor of an invalid type." }
 };
 
-static const char* const rangeExceptionDescriptions[] = {
-    "The boundary-points of a Range did not meet specific requirements.",
-    "The container of an boundary-point of a Range was being set to either a node of an invalid type or a node with an ancestor of an invalid type."
-};
-
-COMPILE_ASSERT(WTF_ARRAY_LENGTH(rangeExceptionNames) == WTF_ARRAY_LENGTH(rangeExceptionDescriptions), RangeExceptionTablesMustMatch);
-
 bool RangeException::initializeDescription(ExceptionCode ec, ExceptionCodeDescription* description)
 {
     if (ec < RangeExceptionOffset || ec > RangeExceptionMax)
@@ -53,11 +48,11 @@ bool RangeException::initializeDescription(ExceptionCode ec, ExceptionCodeDescri
     description->code = ec - RangeExceptionOffset;
     description->type = RangeExceptionType;
 
-    size_t tableSize = WTF_ARRAY_LENGTH(rangeExceptionNames);
+    size_t tableSize = WTF_ARRAY_LENGTH(exceptions);
     size_t tableIndex = ec - BAD_BOUNDARYPOINTS_ERR;
 
-    description->name = tableIndex < tableSize ? rangeExceptionNames[tableIndex] : 0;
-    description->description = tableIndex < tableSize ? rangeExceptionDescriptions[tableIndex] : 0;
+    description->name = tableIndex < tableSize ? exceptions[tableIndex].name : 0;
+    description->description = tableIndex < tableSize ? exceptions[tableIndex].description : 0;
 
     return true;
 }