<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[163045] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163045">163045</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2014-01-29 16:00:25 -0800 (Wed, 29 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>IDB: Fully implement IDBKeyData encoding/decoding
https://bugs.webkit.org/show_bug.cgi?id=127863

Rubberstamped by Alexey Proskuryakov.

Source/WebCore:

* platform/KeyedCoding.h:

* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::encode):
(WebCore::IDBKeyData::decode):

* WebCore.exp.in:

Source/WebKit2:

Handle invalid buffers, and pass IDBKeyData decoding along:
* DatabaseProcess/IndexedDB/IDBSerialization.cpp:
(WebKit::deserializeIDBKeyPath):
(WebKit::serializeIDBKeyData):
(WebKit::deserializeIDBKeyData):
* DatabaseProcess/IndexedDB/IDBSerialization.h:

Implement decodeBool and decodeDouble:
* Shared/cf/KeyedDecoder.cpp:
(WebKit::KeyedDecoder::decodeBool):
(WebKit::KeyedDecoder::decodeDouble):
* Shared/cf/KeyedDecoder.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeyDatacpp">trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreplatformKeyedCodingh">trunk/Source/WebCore/platform/KeyedCoding.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBIDBSerializationcpp">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/IDBSerialization.cpp</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBIDBSerializationh">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/IDBSerialization.h</a></li>
<li><a href="#trunkSourceWebKit2SharedcfKeyedDecodercpp">trunk/Source/WebKit2/Shared/cf/KeyedDecoder.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedcfKeyedDecoderh">trunk/Source/WebKit2/Shared/cf/KeyedDecoder.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebCore/ChangeLog        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-01-29  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        IDB: Fully implement IDBKeyData encoding/decoding
+        https://bugs.webkit.org/show_bug.cgi?id=127863
+
+        Rubberstamped by Alexey Proskuryakov.
+
+        * platform/KeyedCoding.h:
+
+        * Modules/indexeddb/IDBKeyData.cpp:
+        (WebCore::IDBKeyData::encode):
+        (WebCore::IDBKeyData::decode):
+
+        * WebCore.exp.in:
+
</ins><span class="cx"> 2014-01-29  Bem Jones-Bey  &lt;bjonesbe@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         clip-path swaps bottom radii for the inset shape
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeyDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -141,9 +141,7 @@
</span><span class="cx">         return;
</span><span class="cx">     case IDBKey::ArrayType:
</span><span class="cx">         encoder.encodeObjects(&quot;array&quot;, arrayValue.begin(), arrayValue.end(), [](KeyedEncoder&amp; encoder, const IDBKeyData&amp; key) {
</span><del>-            encoder.encodeObject(&quot;idbKeyData&quot;, key, [](KeyedEncoder&amp; encoder, const IDBKeyData&amp; key) {
-                key.encode(encoder);
-            });
</del><ins>+            key.encode(encoder);
</ins><span class="cx">         });
</span><span class="cx">         return;
</span><span class="cx">     case IDBKey::StringType:
</span><span class="lines">@@ -161,10 +159,45 @@
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool IDBKeyData::decode(KeyedDecoder&amp;, IDBKeyData&amp;)
</del><ins>+bool IDBKeyData::decode(KeyedDecoder&amp; decoder, IDBKeyData&amp; result)
</ins><span class="cx"> {
</span><del>-    // FIXME: Implement when IDB Get support is implemented (&lt;rdar://problem/15779644&gt;)
-    return false;
</del><ins>+    if (!decoder.decodeBool(&quot;null&quot;, result.isNull))
+        return false;
+
+    if (result.isNull)
+        return true;
+
+    auto enumFunction = [](int64_t value) {
+        return value == IDBKey::InvalidType
+            || value == IDBKey::ArrayType
+            || value == IDBKey::StringType
+            || value == IDBKey::DateType
+            || value == IDBKey::NumberType
+            || value == IDBKey::MinType;
+    };
+    if (!decoder.decodeVerifiedEnum(&quot;type&quot;, result.type, enumFunction))
+        return false;
+
+    if (result.type == IDBKey::InvalidType)
+        return true;
+
+    if (result.type == IDBKey::MinType) {
+        ASSERT_NOT_REACHED();
+        return true;
+    }
+
+    if (result.type == IDBKey::StringType)
+        return decoder.decodeString(&quot;string&quot;, result.stringValue);
+
+    if (result.type == IDBKey::NumberType || result.type == IDBKey::DateType)
+        return decoder.decodeDouble(&quot;number&quot;, result.numberValue);
+
+    ASSERT(result.type == IDBKey::ArrayType);
+
+    auto arrayFunction = [](KeyedDecoder&amp; decoder, IDBKeyData&amp; result) {
+        return decode(decoder, result);
+    };
+    return decoder.decodeObjects(&quot;array&quot;, result.arrayValue, arrayFunction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -3081,6 +3081,7 @@
</span><span class="cx"> __ZNK7WebCore11IDBKeyRange9isOnlyKeyEv
</span><span class="cx"> __ZNK7WebCore15IDBKeyRangeData22maybeCreateIDBKeyRangeEv
</span><span class="cx"> __ZNK7WebCore6IDBKey7isValidEv
</span><ins>+__ZN7WebCore10IDBKeyData6decodeERNS_12KeyedDecoderERS0_
</ins><span class="cx"> __ZN7WebCore10IDBKeyDataC1EPKNS_6IDBKeyE
</span><span class="cx"> __ZN7WebCore10IDBKeyPathC1ERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore10IDBKeyPathC1ERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEE
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformKeyedCodingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/KeyedCoding.h (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/KeyedCoding.h        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebCore/platform/KeyedCoding.h        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -39,6 +39,8 @@
</span><span class="cx">     virtual ~KeyedDecoder() { }
</span><span class="cx"> 
</span><span class="cx"> public:
</span><ins>+    virtual bool decodeBool(const String&amp; key, bool&amp;) = 0;
+    virtual bool decodeDouble(const String&amp; key, double&amp;) = 0;
</ins><span class="cx">     virtual bool decodeInt64(const String&amp; key, int64_t&amp;) = 0;
</span><span class="cx">     virtual bool decodeUInt32(const String&amp; key, uint32_t&amp;) = 0;
</span><span class="cx">     virtual bool decodeString(const String&amp; key, String&amp;) = 0;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebKit2/ChangeLog        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2014-01-29  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        IDB: Fully implement IDBKeyData encoding/decoding
+        https://bugs.webkit.org/show_bug.cgi?id=127863
+
+        Rubberstamped by Alexey Proskuryakov.
+
+        Handle invalid buffers, and pass IDBKeyData decoding along:
+        * DatabaseProcess/IndexedDB/IDBSerialization.cpp:
+        (WebKit::deserializeIDBKeyPath):
+        (WebKit::serializeIDBKeyData):
+        (WebKit::deserializeIDBKeyData):
+        * DatabaseProcess/IndexedDB/IDBSerialization.h:
+
+        Implement decodeBool and decodeDouble:
+        * Shared/cf/KeyedDecoder.cpp:
+        (WebKit::KeyedDecoder::decodeBool):
+        (WebKit::KeyedDecoder::decodeDouble):
+        * Shared/cf/KeyedDecoder.h:
+
</ins><span class="cx"> 2014-01-29  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebKit2 View Gestures (Swipe): Update rubberBandsAt{Left,Right} when WebKit swipe is enabled
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBIDBSerializationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/IDBSerialization.cpp (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/IDBSerialization.cpp        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/IDBSerialization.cpp        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -46,17 +46,29 @@
</span><span class="cx"> 
</span><span class="cx"> bool deserializeIDBKeyPath(const uint8_t* data, size_t size, IDBKeyPath&amp; result)
</span><span class="cx"> {
</span><ins>+    if (!data || !size)
+        return false;
+
</ins><span class="cx">     KeyedDecoder decoder(data, size);
</span><span class="cx">     return IDBKeyPath::decode(decoder, result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr&lt;WebCore::SharedBuffer&gt; serializeIDBKeyData(const IDBKeyData&amp; key)
</del><ins>+RefPtr&lt;SharedBuffer&gt; serializeIDBKeyData(const IDBKeyData&amp; key)
</ins><span class="cx"> {
</span><span class="cx">     KeyedEncoder encoder;
</span><span class="cx">     key.encode(encoder);
</span><span class="cx">     return encoder.finishEncoding();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool deserializeIDBKeyData(const uint8_t* data, size_t size, IDBKeyData&amp; result)
+{
+    if (!data || !size)
+        return false;
+
+    KeyedDecoder decoder(data, size);
+    return IDBKeyData::decode(decoder, result);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(INDEXED_DATABASE)
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBIDBSerializationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/IDBSerialization.h (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/IDBSerialization.h        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/IDBSerialization.h        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx"> bool deserializeIDBKeyPath(const uint8_t* buffer, size_t bufferSize, WebCore::IDBKeyPath&amp;);
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;WebCore::SharedBuffer&gt; serializeIDBKeyData(const WebCore::IDBKeyData&amp;);
</span><del>-bool deserializeIDBKey(const uint8_t* buffer, size_t bufferSize, WebCore::IDBKeyData&amp;);
</del><ins>+bool deserializeIDBKeyData(const uint8_t* buffer, size_t bufferSize, WebCore::IDBKeyData&amp;);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedcfKeyedDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/cf/KeyedDecoder.cpp (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/cf/KeyedDecoder.cpp        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebKit2/Shared/cf/KeyedDecoder.cpp        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -50,6 +50,31 @@
</span><span class="cx">     ASSERT(m_arrayIndexStack.isEmpty());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool KeyedDecoder::decodeBool(const String&amp; key, bool&amp; result)
+{
+    if (!m_dictionaryStack.last())
+        return false;
+
+    CFBooleanRef boolean = static_cast&lt;CFBooleanRef&gt;(CFDictionaryGetValue(m_dictionaryStack.last(), key.createCFString().get()));
+    if (!boolean || CFGetTypeID(boolean) != CFBooleanGetTypeID())
+        return false;
+
+    result = CFBooleanGetValue(boolean);
+    return true;
+}
+
+bool KeyedDecoder::decodeDouble(const String&amp; key, double&amp; result)
+{
+    if (!m_dictionaryStack.last())
+        return false;
+
+    CFNumberRef number = static_cast&lt;CFNumberRef&gt;(CFDictionaryGetValue(m_dictionaryStack.last(), key.createCFString().get()));
+    if (!number || CFGetTypeID(number) != CFNumberGetTypeID() || (CFNumberGetType(number) != kCFNumberDoubleType &amp;&amp; CFNumberGetType(number) != kCFNumberFloat64Type))
+        return false;
+
+    return CFNumberGetValue(number, kCFNumberDoubleType, &amp;result);
+}
+
</ins><span class="cx"> bool KeyedDecoder::decodeInt64(const String&amp; key, int64_t&amp; result)
</span><span class="cx"> {
</span><span class="cx">     if (!m_dictionaryStack.last())
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedcfKeyedDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/cf/KeyedDecoder.h (163044 => 163045)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/cf/KeyedDecoder.h        2014-01-29 23:30:18 UTC (rev 163044)
+++ trunk/Source/WebKit2/Shared/cf/KeyedDecoder.h        2014-01-30 00:00:25 UTC (rev 163045)
</span><span class="lines">@@ -35,20 +35,22 @@
</span><span class="cx"> class KeyedDecoder final : public WebCore::KeyedDecoder {
</span><span class="cx"> public:
</span><span class="cx">     KeyedDecoder(const uint8_t* data, size_t);
</span><del>-    virtual ~KeyedDecoder();
</del><ins>+    virtual ~KeyedDecoder() override;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    virtual bool decodeInt64(const String&amp; key, int64_t&amp;);
-    virtual bool decodeUInt32(const String&amp; key, uint32_t&amp;);
-    virtual bool decodeString(const String&amp; key, String&amp;);
</del><ins>+    virtual bool decodeBool(const String&amp; key, bool&amp;) override;
+    virtual bool decodeDouble(const String&amp; key, double&amp;) override;
+    virtual bool decodeInt64(const String&amp; key, int64_t&amp;) override;
+    virtual bool decodeUInt32(const String&amp; key, uint32_t&amp;) override;
+    virtual bool decodeString(const String&amp; key, String&amp;) override;
</ins><span class="cx"> 
</span><del>-    virtual bool beginObject(const String&amp; key);
-    virtual void endObject();
</del><ins>+    virtual bool beginObject(const String&amp; key) override;
+    virtual void endObject() override;
</ins><span class="cx"> 
</span><del>-    virtual bool beginArray(const String&amp; key);
-    virtual bool beginArrayElement();
-    virtual void endArrayElement();
-    virtual void endArray();
</del><ins>+    virtual bool beginArray(const String&amp; key) override;
+    virtual bool beginArrayElement() override;
+    virtual void endArrayElement() override;
+    virtual void endArray() override;
</ins><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;CFDictionaryRef&gt; m_rootDictionary;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>