Allow passing WebDoubles via postMessage.
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Sep 2010 20:55:00 +0000 (20:55 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Sep 2010 20:55:00 +0000 (20:55 +0000)
Reviewed by Anders Carlsson.

* Shared/UserMessageCoders.h:
(WebKit::UserMessageEncoder::baseEncode):
(WebKit::UserMessageDecoder::baseDecode):

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

WebKit2/ChangeLog
WebKit2/Shared/UserMessageCoders.h

index 859481a..55fabd7 100644 (file)
@@ -1,3 +1,13 @@
+2010-09-09  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Allow passing WebDoubles via postMessage.
+
+        * Shared/UserMessageCoders.h:
+        (WebKit::UserMessageEncoder::baseEncode):
+        (WebKit::UserMessageDecoder::baseDecode):
+
 2010-09-08  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Dan Bernstein.
index d9442f3..94023f5 100644 (file)
@@ -28,6 +28,7 @@
 #include "ImmutableArray.h"
 #include "ImmutableDictionary.h"
 #include "WebCoreArgumentCoders.h"
+#include "WebNumber.h"
 #include "WebSerializedScriptValue.h"
 #include "WebString.h"
 
@@ -38,6 +39,7 @@ namespace WebKit {
 //   - Dictionary -> Dictionary
 //   - String -> String
 //   - SerializedScriptValue -> SerializedScriptValue
+//   - WebDouble -> WebDouble
 
 template<typename Owner>
 class UserMessageEncoder {
@@ -83,6 +85,11 @@ public:
             encoder->encodeBytes(scriptValue->data().data(), scriptValue->data().size());
             return true;
         }
+        case APIObject::TypeDouble: {
+            WebDouble* doubleObject = static_cast<WebDouble*>(m_root);
+            encoder->encode(doubleObject->value());
+            return true;
+        }
         default:
             break;
         }
@@ -105,6 +112,8 @@ protected:
 //   - Array -> Array
 //   - Dictionary -> Dictionary
 //   - String -> String
+//   - SerializedScriptValue -> SerializedScriptValue
+//   - WebDouble -> WebDouble
 
 template<typename Owner>
 class UserMessageDecoder {
@@ -173,6 +182,13 @@ public:
             coder.m_root = WebSerializedScriptValue::adopt(buffer);
             break;
         }
+        case APIObject::TypeDouble: {
+            double doubleValue;
+            if (!decoder->decode(doubleValue))
+                return false;
+            coder.m_root = WebDouble::create(doubleValue);
+            break;
+        }
         default:
             break;
         }